@manta-eu/rdf-lib 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/action-plan-schemas.d.ts +305 -0
- package/dist/action-plan-schemas.d.ts.map +1 -0
- package/dist/action-plan-schemas.js +45 -0
- package/dist/detail-view-types.d.ts +5 -0
- package/dist/detail-view-types.d.ts.map +1 -0
- package/dist/detail-view-types.js +19 -0
- package/dist/jsonld-types.d.ts +33 -0
- package/dist/jsonld-types.d.ts.map +1 -0
- package/dist/jsonld-types.js +190 -0
- package/dist/rdf-namespaces.d.ts +321 -0
- package/dist/rdf-namespaces.d.ts.map +1 -0
- package/dist/rdf-namespaces.js +310 -0
- package/dist/shacl-shape-query.d.ts +4 -0
- package/dist/shacl-shape-query.d.ts.map +1 -0
- package/dist/shacl-shape-query.js +64 -0
- package/dist/sparql-literal-escape.d.ts +2 -0
- package/dist/sparql-literal-escape.d.ts.map +1 -0
- package/dist/sparql-literal-escape.js +14 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Manta AI AS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
export declare const MetaCampaignPlanSchema: {
|
|
2
|
+
readonly label: {
|
|
3
|
+
readonly "@id": "rdfs:label";
|
|
4
|
+
readonly "@optional": true;
|
|
5
|
+
};
|
|
6
|
+
readonly schemaName: {
|
|
7
|
+
readonly "@id": "schema:name";
|
|
8
|
+
readonly "@optional": true;
|
|
9
|
+
};
|
|
10
|
+
readonly pauseReason: {
|
|
11
|
+
readonly "@id": ":pauseReason";
|
|
12
|
+
readonly "@optional": true;
|
|
13
|
+
};
|
|
14
|
+
readonly scaleReason: {
|
|
15
|
+
readonly "@id": ":scaleReason";
|
|
16
|
+
readonly "@optional": true;
|
|
17
|
+
};
|
|
18
|
+
readonly wastedSpend: {
|
|
19
|
+
readonly "@id": ":wastedSpend";
|
|
20
|
+
readonly "@type": "xsd:decimal";
|
|
21
|
+
readonly "@optional": true;
|
|
22
|
+
};
|
|
23
|
+
readonly currentRoas: {
|
|
24
|
+
readonly "@id": ":currentRoas";
|
|
25
|
+
readonly "@type": "xsd:decimal";
|
|
26
|
+
readonly "@optional": true;
|
|
27
|
+
};
|
|
28
|
+
readonly planDailyBudget: {
|
|
29
|
+
readonly "@id": ":dailyBudget";
|
|
30
|
+
readonly "@type": "xsd:decimal";
|
|
31
|
+
readonly "@optional": true;
|
|
32
|
+
};
|
|
33
|
+
readonly previousDailyBudget: {
|
|
34
|
+
readonly "@id": ":previousDailyBudget";
|
|
35
|
+
readonly "@type": "xsd:decimal";
|
|
36
|
+
readonly "@optional": true;
|
|
37
|
+
};
|
|
38
|
+
readonly budgetIncreaseFactor: {
|
|
39
|
+
readonly "@id": ":budgetIncreaseFactor";
|
|
40
|
+
readonly "@type": "xsd:decimal";
|
|
41
|
+
readonly "@optional": true;
|
|
42
|
+
};
|
|
43
|
+
readonly "@type": "meta:Campaign";
|
|
44
|
+
readonly dailyBudget: {
|
|
45
|
+
readonly "@id": "meta:dailyBudget";
|
|
46
|
+
readonly "@type": "xsd:integer";
|
|
47
|
+
readonly "@optional": true;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare const MetaAdSetPlanSchema: {
|
|
51
|
+
readonly label: {
|
|
52
|
+
readonly "@id": "rdfs:label";
|
|
53
|
+
readonly "@optional": true;
|
|
54
|
+
};
|
|
55
|
+
readonly schemaName: {
|
|
56
|
+
readonly "@id": "schema:name";
|
|
57
|
+
readonly "@optional": true;
|
|
58
|
+
};
|
|
59
|
+
readonly pauseReason: {
|
|
60
|
+
readonly "@id": ":pauseReason";
|
|
61
|
+
readonly "@optional": true;
|
|
62
|
+
};
|
|
63
|
+
readonly scaleReason: {
|
|
64
|
+
readonly "@id": ":scaleReason";
|
|
65
|
+
readonly "@optional": true;
|
|
66
|
+
};
|
|
67
|
+
readonly wastedSpend: {
|
|
68
|
+
readonly "@id": ":wastedSpend";
|
|
69
|
+
readonly "@type": "xsd:decimal";
|
|
70
|
+
readonly "@optional": true;
|
|
71
|
+
};
|
|
72
|
+
readonly currentRoas: {
|
|
73
|
+
readonly "@id": ":currentRoas";
|
|
74
|
+
readonly "@type": "xsd:decimal";
|
|
75
|
+
readonly "@optional": true;
|
|
76
|
+
};
|
|
77
|
+
readonly planDailyBudget: {
|
|
78
|
+
readonly "@id": ":dailyBudget";
|
|
79
|
+
readonly "@type": "xsd:decimal";
|
|
80
|
+
readonly "@optional": true;
|
|
81
|
+
};
|
|
82
|
+
readonly previousDailyBudget: {
|
|
83
|
+
readonly "@id": ":previousDailyBudget";
|
|
84
|
+
readonly "@type": "xsd:decimal";
|
|
85
|
+
readonly "@optional": true;
|
|
86
|
+
};
|
|
87
|
+
readonly budgetIncreaseFactor: {
|
|
88
|
+
readonly "@id": ":budgetIncreaseFactor";
|
|
89
|
+
readonly "@type": "xsd:decimal";
|
|
90
|
+
readonly "@optional": true;
|
|
91
|
+
};
|
|
92
|
+
readonly "@type": "meta:AdSet";
|
|
93
|
+
readonly campaign: {
|
|
94
|
+
readonly "@id": "meta:campaign";
|
|
95
|
+
readonly "@type": "ldkit:IRI";
|
|
96
|
+
readonly "@optional": true;
|
|
97
|
+
};
|
|
98
|
+
readonly dailyBudget: {
|
|
99
|
+
readonly "@id": "meta:dailyBudget";
|
|
100
|
+
readonly "@type": "xsd:integer";
|
|
101
|
+
readonly "@optional": true;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export declare const MetaAdPlanSchema: {
|
|
105
|
+
readonly label: {
|
|
106
|
+
readonly "@id": "rdfs:label";
|
|
107
|
+
readonly "@optional": true;
|
|
108
|
+
};
|
|
109
|
+
readonly schemaName: {
|
|
110
|
+
readonly "@id": "schema:name";
|
|
111
|
+
readonly "@optional": true;
|
|
112
|
+
};
|
|
113
|
+
readonly pauseReason: {
|
|
114
|
+
readonly "@id": ":pauseReason";
|
|
115
|
+
readonly "@optional": true;
|
|
116
|
+
};
|
|
117
|
+
readonly scaleReason: {
|
|
118
|
+
readonly "@id": ":scaleReason";
|
|
119
|
+
readonly "@optional": true;
|
|
120
|
+
};
|
|
121
|
+
readonly wastedSpend: {
|
|
122
|
+
readonly "@id": ":wastedSpend";
|
|
123
|
+
readonly "@type": "xsd:decimal";
|
|
124
|
+
readonly "@optional": true;
|
|
125
|
+
};
|
|
126
|
+
readonly currentRoas: {
|
|
127
|
+
readonly "@id": ":currentRoas";
|
|
128
|
+
readonly "@type": "xsd:decimal";
|
|
129
|
+
readonly "@optional": true;
|
|
130
|
+
};
|
|
131
|
+
readonly planDailyBudget: {
|
|
132
|
+
readonly "@id": ":dailyBudget";
|
|
133
|
+
readonly "@type": "xsd:decimal";
|
|
134
|
+
readonly "@optional": true;
|
|
135
|
+
};
|
|
136
|
+
readonly previousDailyBudget: {
|
|
137
|
+
readonly "@id": ":previousDailyBudget";
|
|
138
|
+
readonly "@type": "xsd:decimal";
|
|
139
|
+
readonly "@optional": true;
|
|
140
|
+
};
|
|
141
|
+
readonly budgetIncreaseFactor: {
|
|
142
|
+
readonly "@id": ":budgetIncreaseFactor";
|
|
143
|
+
readonly "@type": "xsd:decimal";
|
|
144
|
+
readonly "@optional": true;
|
|
145
|
+
};
|
|
146
|
+
readonly "@type": "meta:Ad";
|
|
147
|
+
readonly campaign: {
|
|
148
|
+
readonly "@id": "meta:campaign";
|
|
149
|
+
readonly "@type": "ldkit:IRI";
|
|
150
|
+
readonly "@optional": true;
|
|
151
|
+
};
|
|
152
|
+
readonly adSet: {
|
|
153
|
+
readonly "@id": "meta:adSet";
|
|
154
|
+
readonly "@type": "ldkit:IRI";
|
|
155
|
+
readonly "@optional": true;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
export declare const GoogleCampaignPlanSchema: {
|
|
159
|
+
readonly label: {
|
|
160
|
+
readonly "@id": "rdfs:label";
|
|
161
|
+
readonly "@optional": true;
|
|
162
|
+
};
|
|
163
|
+
readonly schemaName: {
|
|
164
|
+
readonly "@id": "schema:name";
|
|
165
|
+
readonly "@optional": true;
|
|
166
|
+
};
|
|
167
|
+
readonly pauseReason: {
|
|
168
|
+
readonly "@id": ":pauseReason";
|
|
169
|
+
readonly "@optional": true;
|
|
170
|
+
};
|
|
171
|
+
readonly scaleReason: {
|
|
172
|
+
readonly "@id": ":scaleReason";
|
|
173
|
+
readonly "@optional": true;
|
|
174
|
+
};
|
|
175
|
+
readonly wastedSpend: {
|
|
176
|
+
readonly "@id": ":wastedSpend";
|
|
177
|
+
readonly "@type": "xsd:decimal";
|
|
178
|
+
readonly "@optional": true;
|
|
179
|
+
};
|
|
180
|
+
readonly currentRoas: {
|
|
181
|
+
readonly "@id": ":currentRoas";
|
|
182
|
+
readonly "@type": "xsd:decimal";
|
|
183
|
+
readonly "@optional": true;
|
|
184
|
+
};
|
|
185
|
+
readonly planDailyBudget: {
|
|
186
|
+
readonly "@id": ":dailyBudget";
|
|
187
|
+
readonly "@type": "xsd:decimal";
|
|
188
|
+
readonly "@optional": true;
|
|
189
|
+
};
|
|
190
|
+
readonly previousDailyBudget: {
|
|
191
|
+
readonly "@id": ":previousDailyBudget";
|
|
192
|
+
readonly "@type": "xsd:decimal";
|
|
193
|
+
readonly "@optional": true;
|
|
194
|
+
};
|
|
195
|
+
readonly budgetIncreaseFactor: {
|
|
196
|
+
readonly "@id": ":budgetIncreaseFactor";
|
|
197
|
+
readonly "@type": "xsd:decimal";
|
|
198
|
+
readonly "@optional": true;
|
|
199
|
+
};
|
|
200
|
+
readonly "@type": "google:Campaign";
|
|
201
|
+
};
|
|
202
|
+
export declare const GoogleAdGroupPlanSchema: {
|
|
203
|
+
readonly label: {
|
|
204
|
+
readonly "@id": "rdfs:label";
|
|
205
|
+
readonly "@optional": true;
|
|
206
|
+
};
|
|
207
|
+
readonly schemaName: {
|
|
208
|
+
readonly "@id": "schema:name";
|
|
209
|
+
readonly "@optional": true;
|
|
210
|
+
};
|
|
211
|
+
readonly pauseReason: {
|
|
212
|
+
readonly "@id": ":pauseReason";
|
|
213
|
+
readonly "@optional": true;
|
|
214
|
+
};
|
|
215
|
+
readonly scaleReason: {
|
|
216
|
+
readonly "@id": ":scaleReason";
|
|
217
|
+
readonly "@optional": true;
|
|
218
|
+
};
|
|
219
|
+
readonly wastedSpend: {
|
|
220
|
+
readonly "@id": ":wastedSpend";
|
|
221
|
+
readonly "@type": "xsd:decimal";
|
|
222
|
+
readonly "@optional": true;
|
|
223
|
+
};
|
|
224
|
+
readonly currentRoas: {
|
|
225
|
+
readonly "@id": ":currentRoas";
|
|
226
|
+
readonly "@type": "xsd:decimal";
|
|
227
|
+
readonly "@optional": true;
|
|
228
|
+
};
|
|
229
|
+
readonly planDailyBudget: {
|
|
230
|
+
readonly "@id": ":dailyBudget";
|
|
231
|
+
readonly "@type": "xsd:decimal";
|
|
232
|
+
readonly "@optional": true;
|
|
233
|
+
};
|
|
234
|
+
readonly previousDailyBudget: {
|
|
235
|
+
readonly "@id": ":previousDailyBudget";
|
|
236
|
+
readonly "@type": "xsd:decimal";
|
|
237
|
+
readonly "@optional": true;
|
|
238
|
+
};
|
|
239
|
+
readonly budgetIncreaseFactor: {
|
|
240
|
+
readonly "@id": ":budgetIncreaseFactor";
|
|
241
|
+
readonly "@type": "xsd:decimal";
|
|
242
|
+
readonly "@optional": true;
|
|
243
|
+
};
|
|
244
|
+
readonly "@type": "google:AdGroup";
|
|
245
|
+
readonly campaign: {
|
|
246
|
+
readonly "@id": "google:campaign";
|
|
247
|
+
readonly "@type": "ldkit:IRI";
|
|
248
|
+
readonly "@optional": true;
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
export declare const GoogleAdGroupAdPlanSchema: {
|
|
252
|
+
readonly label: {
|
|
253
|
+
readonly "@id": "rdfs:label";
|
|
254
|
+
readonly "@optional": true;
|
|
255
|
+
};
|
|
256
|
+
readonly schemaName: {
|
|
257
|
+
readonly "@id": "schema:name";
|
|
258
|
+
readonly "@optional": true;
|
|
259
|
+
};
|
|
260
|
+
readonly pauseReason: {
|
|
261
|
+
readonly "@id": ":pauseReason";
|
|
262
|
+
readonly "@optional": true;
|
|
263
|
+
};
|
|
264
|
+
readonly scaleReason: {
|
|
265
|
+
readonly "@id": ":scaleReason";
|
|
266
|
+
readonly "@optional": true;
|
|
267
|
+
};
|
|
268
|
+
readonly wastedSpend: {
|
|
269
|
+
readonly "@id": ":wastedSpend";
|
|
270
|
+
readonly "@type": "xsd:decimal";
|
|
271
|
+
readonly "@optional": true;
|
|
272
|
+
};
|
|
273
|
+
readonly currentRoas: {
|
|
274
|
+
readonly "@id": ":currentRoas";
|
|
275
|
+
readonly "@type": "xsd:decimal";
|
|
276
|
+
readonly "@optional": true;
|
|
277
|
+
};
|
|
278
|
+
readonly planDailyBudget: {
|
|
279
|
+
readonly "@id": ":dailyBudget";
|
|
280
|
+
readonly "@type": "xsd:decimal";
|
|
281
|
+
readonly "@optional": true;
|
|
282
|
+
};
|
|
283
|
+
readonly previousDailyBudget: {
|
|
284
|
+
readonly "@id": ":previousDailyBudget";
|
|
285
|
+
readonly "@type": "xsd:decimal";
|
|
286
|
+
readonly "@optional": true;
|
|
287
|
+
};
|
|
288
|
+
readonly budgetIncreaseFactor: {
|
|
289
|
+
readonly "@id": ":budgetIncreaseFactor";
|
|
290
|
+
readonly "@type": "xsd:decimal";
|
|
291
|
+
readonly "@optional": true;
|
|
292
|
+
};
|
|
293
|
+
readonly "@type": "google:AdGroupAd";
|
|
294
|
+
readonly campaign: {
|
|
295
|
+
readonly "@id": "google:campaign";
|
|
296
|
+
readonly "@type": "ldkit:IRI";
|
|
297
|
+
readonly "@optional": true;
|
|
298
|
+
};
|
|
299
|
+
readonly adGroup: {
|
|
300
|
+
readonly "@id": "google:adGroup";
|
|
301
|
+
readonly "@type": "ldkit:IRI";
|
|
302
|
+
readonly "@optional": true;
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
//# sourceMappingURL=action-plan-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-plan-schemas.d.ts","sourceRoot":"","sources":["../src/action-plan-schemas.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIzB,CAAC;AAEX,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKtB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKnB,CAAC;AAEX,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA2E,CAAC;AAEjH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAI1B,CAAC;AAEX,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAK5B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GoogleAdGroupAdSchema, GoogleAdGroupSchema, GoogleCampaignSchema, MetaAdSchema, MetaAdSetSchema, MetaCampaignSchema, } from "@manta-eu/ldo";
|
|
2
|
+
import { rdfs, schema, xsd } from "ldkit/namespaces";
|
|
3
|
+
import { m } from "./rdf-namespaces.js";
|
|
4
|
+
// Action-plan entity schemas — the base fields the Changes table reads, merged with Manta-computed plan metrics.
|
|
5
|
+
// These are used by useActionPlanEntityMetrics to query the Changes table.
|
|
6
|
+
const planMetricFields = {
|
|
7
|
+
label: { "@id": rdfs.label, "@optional": true },
|
|
8
|
+
schemaName: { "@id": schema.name, "@optional": true },
|
|
9
|
+
pauseReason: { "@id": m.pauseReason, "@optional": true },
|
|
10
|
+
scaleReason: { "@id": m.scaleReason, "@optional": true },
|
|
11
|
+
wastedSpend: { "@id": m.wastedSpend, "@type": xsd.decimal, "@optional": true },
|
|
12
|
+
currentRoas: { "@id": m.currentRoas, "@type": xsd.decimal, "@optional": true },
|
|
13
|
+
planDailyBudget: { "@id": m.dailyBudget, "@type": xsd.decimal, "@optional": true },
|
|
14
|
+
previousDailyBudget: { "@id": m.previousDailyBudget, "@type": xsd.decimal, "@optional": true },
|
|
15
|
+
budgetIncreaseFactor: { "@id": m.budgetIncreaseFactor, "@type": xsd.decimal, "@optional": true },
|
|
16
|
+
};
|
|
17
|
+
export const MetaCampaignPlanSchema = {
|
|
18
|
+
"@type": MetaCampaignSchema["@type"],
|
|
19
|
+
dailyBudget: MetaCampaignSchema.dailyBudget,
|
|
20
|
+
...planMetricFields,
|
|
21
|
+
};
|
|
22
|
+
export const MetaAdSetPlanSchema = {
|
|
23
|
+
"@type": MetaAdSetSchema["@type"],
|
|
24
|
+
campaign: MetaAdSetSchema.campaign,
|
|
25
|
+
dailyBudget: MetaAdSetSchema.dailyBudget,
|
|
26
|
+
...planMetricFields,
|
|
27
|
+
};
|
|
28
|
+
export const MetaAdPlanSchema = {
|
|
29
|
+
"@type": MetaAdSchema["@type"],
|
|
30
|
+
campaign: MetaAdSchema.campaign,
|
|
31
|
+
adSet: MetaAdSchema.adSet,
|
|
32
|
+
...planMetricFields,
|
|
33
|
+
};
|
|
34
|
+
export const GoogleCampaignPlanSchema = { "@type": GoogleCampaignSchema["@type"], ...planMetricFields };
|
|
35
|
+
export const GoogleAdGroupPlanSchema = {
|
|
36
|
+
"@type": GoogleAdGroupSchema["@type"],
|
|
37
|
+
campaign: GoogleAdGroupSchema.campaign,
|
|
38
|
+
...planMetricFields,
|
|
39
|
+
};
|
|
40
|
+
export const GoogleAdGroupAdPlanSchema = {
|
|
41
|
+
"@type": GoogleAdGroupAdSchema["@type"],
|
|
42
|
+
campaign: GoogleAdGroupAdSchema.campaign,
|
|
43
|
+
adGroup: GoogleAdGroupAdSchema.adGroup,
|
|
44
|
+
...planMetricFields,
|
|
45
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const detailViewTypes: readonly string[];
|
|
2
|
+
export declare const lensViewTypes: readonly string[];
|
|
3
|
+
export declare const labelPredicateSuffixes: readonly string[];
|
|
4
|
+
export declare const displayFactPredicates: readonly string[];
|
|
5
|
+
//# sourceMappingURL=detail-view-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail-view-types.d.ts","sourceRoot":"","sources":["../src/detail-view-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAgC,CAAC;AAE9E,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAe1C,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAA8C,CAAC;AAEnG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAsC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { attio, coresignal, google, meta } from "@manta-eu/ldo/namespaces";
|
|
2
|
+
import { wellKnownPredicates } from "./rdf-namespaces.js";
|
|
3
|
+
export const detailViewTypes = [meta.Ad, google.AdGroupAd];
|
|
4
|
+
export const lensViewTypes = [
|
|
5
|
+
google.AdGroup,
|
|
6
|
+
google.AdGroupCriterion,
|
|
7
|
+
google.CampaignBudget,
|
|
8
|
+
google.CampaignCriterion,
|
|
9
|
+
coresignal.Company,
|
|
10
|
+
coresignal.Employee,
|
|
11
|
+
coresignal.Experience,
|
|
12
|
+
coresignal.Job,
|
|
13
|
+
coresignal.KeyExecutiveDeparture,
|
|
14
|
+
attio.CallRecording,
|
|
15
|
+
attio.Deal,
|
|
16
|
+
attio.Note,
|
|
17
|
+
];
|
|
18
|
+
export const labelPredicateSuffixes = ["label", "name", "title", "displayName"];
|
|
19
|
+
export const displayFactPredicates = [wellKnownPredicates.actionShape];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type JsonLdValue = string | number | boolean | null | JsonLdNode | JsonLdValue[];
|
|
2
|
+
export type JsonLdNode = {
|
|
3
|
+
"@id"?: string;
|
|
4
|
+
"@type"?: string | string[];
|
|
5
|
+
"@value"?: string | number | boolean;
|
|
6
|
+
"@language"?: string;
|
|
7
|
+
[key: string]: JsonLdValue | undefined;
|
|
8
|
+
};
|
|
9
|
+
export type JsonLdContext = Record<string, string | {
|
|
10
|
+
"@id": string;
|
|
11
|
+
"@type"?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type JsonLdDocument = {
|
|
14
|
+
"@context"?: JsonLdContext;
|
|
15
|
+
"@graph"?: JsonLdNode[];
|
|
16
|
+
} & JsonLdNode;
|
|
17
|
+
export type JsonLdGraphDocument = JsonLdDocument & {
|
|
18
|
+
"@graph": JsonLdNode[];
|
|
19
|
+
};
|
|
20
|
+
export declare function isJsonLdNode(value: unknown): value is JsonLdNode;
|
|
21
|
+
export declare function isJsonLdDocument(value: unknown): value is JsonLdDocument;
|
|
22
|
+
export declare function isJsonLdGraphDocument(value: unknown): value is JsonLdGraphDocument;
|
|
23
|
+
export declare function getJsonLdGraph(doc: JsonLdDocument): JsonLdNode[];
|
|
24
|
+
export declare function getNodeId(node: JsonLdNode): string | undefined;
|
|
25
|
+
export declare function getNodeType(node: JsonLdNode): string | string[] | undefined;
|
|
26
|
+
export declare function getNodeTypes(node: JsonLdNode): string[];
|
|
27
|
+
export declare function hasType(node: JsonLdNode, typeUri: string): boolean;
|
|
28
|
+
export declare function getStringValue(node: JsonLdNode, predicate: string): string | null;
|
|
29
|
+
export declare function getNumberValue(node: JsonLdNode, predicate: string): number | null;
|
|
30
|
+
export declare function getRefId(node: JsonLdNode, predicate: string): string | null;
|
|
31
|
+
export declare function mergeNodesById(nodes: JsonLdNode[]): JsonLdNode[];
|
|
32
|
+
export declare function mergeJsonLdGraphs(documents: JsonLdGraphDocument[]): JsonLdGraphDocument;
|
|
33
|
+
//# sourceMappingURL=jsonld-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonld-types.d.ts","sourceRoot":"","sources":["../src/jsonld-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC;AAExF,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEzF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB,GAAG,UAAU,CAAC;AAEf,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG;IAAE,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAGxE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAElF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU,EAAE,CAQhE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAE3E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,CA0BvD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAElE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUjF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBjF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ3E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAyChE;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,CA8CvF"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export function isJsonLdNode(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
export function isJsonLdDocument(value) {
|
|
5
|
+
if (!isJsonLdNode(value))
|
|
6
|
+
return false;
|
|
7
|
+
return "@graph" in value || "@context" in value || "@id" in value || "@type" in value;
|
|
8
|
+
}
|
|
9
|
+
export function isJsonLdGraphDocument(value) {
|
|
10
|
+
return isJsonLdDocument(value) && "@graph" in value && Array.isArray(value["@graph"]);
|
|
11
|
+
}
|
|
12
|
+
export function getJsonLdGraph(doc) {
|
|
13
|
+
if (doc["@graph"]) {
|
|
14
|
+
return doc["@graph"];
|
|
15
|
+
}
|
|
16
|
+
if (doc["@id"]) {
|
|
17
|
+
return [doc];
|
|
18
|
+
}
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
export function getNodeId(node) {
|
|
22
|
+
return node["@id"];
|
|
23
|
+
}
|
|
24
|
+
export function getNodeType(node) {
|
|
25
|
+
return node["@type"];
|
|
26
|
+
}
|
|
27
|
+
export function getNodeTypes(node) {
|
|
28
|
+
const types = [];
|
|
29
|
+
const atType = node["@type"];
|
|
30
|
+
if (typeof atType === "string") {
|
|
31
|
+
types.push(atType);
|
|
32
|
+
}
|
|
33
|
+
else if (Array.isArray(atType)) {
|
|
34
|
+
types.push(...atType.filter((t) => typeof t === "string"));
|
|
35
|
+
}
|
|
36
|
+
const rdfTypeValue = node["rdf:type"] || node["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"];
|
|
37
|
+
if (typeof rdfTypeValue === "string") {
|
|
38
|
+
types.push(rdfTypeValue);
|
|
39
|
+
}
|
|
40
|
+
else if (Array.isArray(rdfTypeValue)) {
|
|
41
|
+
for (const item of rdfTypeValue) {
|
|
42
|
+
if (typeof item === "string") {
|
|
43
|
+
types.push(item);
|
|
44
|
+
}
|
|
45
|
+
else if (isJsonLdNode(item) && item["@id"]) {
|
|
46
|
+
types.push(item["@id"]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (isJsonLdNode(rdfTypeValue) && rdfTypeValue["@id"]) {
|
|
51
|
+
types.push(rdfTypeValue["@id"]);
|
|
52
|
+
}
|
|
53
|
+
return types;
|
|
54
|
+
}
|
|
55
|
+
export function hasType(node, typeUri) {
|
|
56
|
+
return getNodeTypes(node).includes(typeUri);
|
|
57
|
+
}
|
|
58
|
+
export function getStringValue(node, predicate) {
|
|
59
|
+
const value = node[predicate];
|
|
60
|
+
if (typeof value === "string")
|
|
61
|
+
return value;
|
|
62
|
+
if (isJsonLdNode(value) && typeof value["@value"] === "string")
|
|
63
|
+
return value["@value"];
|
|
64
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
65
|
+
const first = value[0];
|
|
66
|
+
if (typeof first === "string")
|
|
67
|
+
return first;
|
|
68
|
+
if (isJsonLdNode(first) && typeof first["@value"] === "string")
|
|
69
|
+
return first["@value"];
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
export function getNumberValue(node, predicate) {
|
|
74
|
+
const value = node[predicate];
|
|
75
|
+
if (typeof value === "number")
|
|
76
|
+
return value;
|
|
77
|
+
if (typeof value === "string") {
|
|
78
|
+
const num = Number(value);
|
|
79
|
+
return isNaN(num) ? null : num;
|
|
80
|
+
}
|
|
81
|
+
if (isJsonLdNode(value)) {
|
|
82
|
+
const v = value["@value"];
|
|
83
|
+
if (typeof v === "number")
|
|
84
|
+
return v;
|
|
85
|
+
if (typeof v === "string") {
|
|
86
|
+
const num = Number(v);
|
|
87
|
+
return isNaN(num) ? null : num;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
91
|
+
return getNumberValue({ temp: value[0] }, "temp");
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
export function getRefId(node, predicate) {
|
|
96
|
+
const value = node[predicate];
|
|
97
|
+
if (isJsonLdNode(value) && value["@id"])
|
|
98
|
+
return value["@id"];
|
|
99
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
100
|
+
const first = value[0];
|
|
101
|
+
if (isJsonLdNode(first) && first["@id"])
|
|
102
|
+
return first["@id"];
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
export function mergeNodesById(nodes) {
|
|
107
|
+
const mergedNodes = new Map();
|
|
108
|
+
const nodesWithoutId = [];
|
|
109
|
+
for (const node of nodes) {
|
|
110
|
+
const id = node["@id"];
|
|
111
|
+
if (!id) {
|
|
112
|
+
nodesWithoutId.push(node);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const existing = mergedNodes.get(id);
|
|
116
|
+
if (!existing) {
|
|
117
|
+
mergedNodes.set(id, { ...node });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
for (const [key, value] of Object.entries(node)) {
|
|
121
|
+
if (key === "@id" || value === undefined)
|
|
122
|
+
continue;
|
|
123
|
+
const existingValue = existing[key];
|
|
124
|
+
if (existingValue === undefined) {
|
|
125
|
+
existing[key] = value;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(existingValue) && Array.isArray(value)) {
|
|
129
|
+
existing[key] = [...existingValue, ...value];
|
|
130
|
+
}
|
|
131
|
+
else if (Array.isArray(existingValue) && value !== null) {
|
|
132
|
+
existing[key] = [...existingValue, value];
|
|
133
|
+
}
|
|
134
|
+
else if (Array.isArray(value) && existingValue !== null) {
|
|
135
|
+
existing[key] = [existingValue, ...value];
|
|
136
|
+
}
|
|
137
|
+
else if (existingValue !== null && value !== null) {
|
|
138
|
+
existing[key] = [existingValue, value];
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
existing[key] = value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return [...Array.from(mergedNodes.values()), ...nodesWithoutId];
|
|
146
|
+
}
|
|
147
|
+
export function mergeJsonLdGraphs(documents) {
|
|
148
|
+
if (documents.length === 0) {
|
|
149
|
+
return { "@context": {}, "@graph": [] };
|
|
150
|
+
}
|
|
151
|
+
if (documents.length === 1 && documents[0]) {
|
|
152
|
+
return documents[0];
|
|
153
|
+
}
|
|
154
|
+
const mergedContext = {};
|
|
155
|
+
const nodeMap = new Map();
|
|
156
|
+
for (const doc of documents) {
|
|
157
|
+
if (doc["@context"]) {
|
|
158
|
+
Object.assign(mergedContext, doc["@context"]);
|
|
159
|
+
}
|
|
160
|
+
for (const node of doc["@graph"]) {
|
|
161
|
+
const nodeId = node["@id"];
|
|
162
|
+
if (!nodeId) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const existing = nodeMap.get(nodeId);
|
|
166
|
+
if (existing) {
|
|
167
|
+
for (const [key, value] of Object.entries(node)) {
|
|
168
|
+
if (key === "@id")
|
|
169
|
+
continue;
|
|
170
|
+
if (key === "@type") {
|
|
171
|
+
const existingTypes = getNodeTypes(existing);
|
|
172
|
+
const newTypes = getNodeTypes(node);
|
|
173
|
+
const mergedTypes = [...new Set([...existingTypes, ...newTypes])];
|
|
174
|
+
existing["@type"] = mergedTypes.length === 1 ? mergedTypes[0] : mergedTypes;
|
|
175
|
+
}
|
|
176
|
+
else if (!(key in existing)) {
|
|
177
|
+
existing[key] = value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
nodeMap.set(nodeId, { ...node });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
"@context": mergedContext,
|
|
188
|
+
"@graph": Array.from(nodeMap.values()),
|
|
189
|
+
};
|
|
190
|
+
}
|