-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinsert-handler.cjs
More file actions
66 lines (59 loc) · 1.69 KB
/
insert-handler.cjs
File metadata and controls
66 lines (59 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
({ deep, data: { newLink, triggeredByLinkId } }) => {
const timestamp = Date.now();
const containTypeLinkId = deep.id('@deep-foundation/core', 'Contain');
const reservedIds = deep.reserve(2);
const logLinkInsertData = {
id: reservedIds[0],
type_id: deep.id("@deep-foundation/logger", "LogLink"),
...(newLink.from_id && {from_id: newLink.from_id}),
...(newLink.to_id && {from_id: newLink.to_id}),
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};
const logInsertInsertData = {
id: reservedIds[1],
type_id: deep.id("@deep-foundation/logger", "LogInsert"),
from_id: logLinkInsertData.id,
to_id: newLink.id,
number: timestamp, // TODO: number field must be of type MutationInsertLink or smth like this, but not number. Issue: https://github.com/deep-foundation/deeplinks/issues/80
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};
const logTypeLinkInsertData = {
type_id: deep.id("@deep-foundation/logger", "LogType"),
from_id: logLinkInsertData.id,
to_id: newLink.type_id,
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};
const logSubjectLinkInsertData = {
type_id: deep.id("@deep-foundation/logger", "LogSubject"),
from_id: triggeredByLinkId,
to_id: logInsertInsertData.id,
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};
deep.insert([
logLinkInsertData,
logInsertInsertData,
logTypeLinkInsertData,
logSubjectLinkInsertData,
logSubjectLinkInsertData
])
}