ldkit 0.6.2 → 0.6.4
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 +1 -1
- package/README.md +113 -3
- package/esm/library/decoder.js +2 -1
- package/esm/library/encoder.js +2 -1
- package/esm/library/namespaces/dbo.js +3650 -0
- package/esm/library/namespaces/dc.js +22 -0
- package/esm/library/namespaces/foaf.js +70 -0
- package/esm/library/namespaces/gr.js +176 -0
- package/esm/library/namespaces/mod.js +7 -2
- package/esm/library/namespaces/sioc.js +106 -0
- package/esm/library/rdf.js +87 -9
- package/esm/library/resource/query_builder.js +2 -1
- package/esm/library/schema/data_types.js +2 -1
- package/esm/library/schema/utils.js +1 -1
- package/package.json +1 -2
- package/script/library/decoder.js +11 -7
- package/script/library/encoder.js +8 -4
- package/script/library/namespaces/dbo.js +3652 -0
- package/script/library/namespaces/dc.js +24 -0
- package/script/library/namespaces/foaf.js +72 -0
- package/script/library/namespaces/gr.js +178 -0
- package/script/library/namespaces/mod.js +15 -5
- package/script/library/namespaces/sioc.js +108 -0
- package/script/library/rdf.js +89 -10
- package/script/library/resource/query_builder.js +8 -4
- package/script/library/schema/data_types.js +39 -35
- package/script/library/schema/utils.js +6 -3
- package/types/library/namespaces/dbo.d.ts +3649 -0
- package/types/library/namespaces/dc.d.ts +21 -0
- package/types/library/namespaces/dcterms.d.ts +17 -17
- package/types/library/namespaces/foaf.d.ts +69 -0
- package/types/library/namespaces/gr.d.ts +175 -0
- package/types/library/namespaces/mod.d.ts +7 -2
- package/types/library/namespaces/rdf.d.ts +1 -1
- package/types/library/namespaces/rdfs.d.ts +4 -4
- package/types/library/namespaces/schema.d.ts +261 -261
- package/types/library/namespaces/sioc.d.ts +105 -0
- package/types/library/namespaces/skos.d.ts +3 -3
- package/types/library/namespaces/xsd.d.ts +3 -3
- package/types/library/rdf.d.ts +30 -11
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createNamespace } from "./namespace.js";
|
|
2
|
+
export default createNamespace({
|
|
3
|
+
iri: "http://purl.org/dc/elements/1.1/",
|
|
4
|
+
prefix: "dc:",
|
|
5
|
+
terms: [
|
|
6
|
+
"contributor",
|
|
7
|
+
"coverage",
|
|
8
|
+
"creator",
|
|
9
|
+
"date",
|
|
10
|
+
"description",
|
|
11
|
+
"format",
|
|
12
|
+
"identifier",
|
|
13
|
+
"language",
|
|
14
|
+
"publisher",
|
|
15
|
+
"relation",
|
|
16
|
+
"rights",
|
|
17
|
+
"source",
|
|
18
|
+
"subject",
|
|
19
|
+
"title",
|
|
20
|
+
"type",
|
|
21
|
+
],
|
|
22
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createNamespace } from "./namespace.js";
|
|
2
|
+
export default createNamespace({
|
|
3
|
+
iri: "http://xmlns.com/foaf/0.1/",
|
|
4
|
+
prefix: "foaf:",
|
|
5
|
+
terms: [
|
|
6
|
+
"Agent",
|
|
7
|
+
"Document",
|
|
8
|
+
"Group",
|
|
9
|
+
"Image",
|
|
10
|
+
"OnlineAccount",
|
|
11
|
+
"OnlineChatAccount",
|
|
12
|
+
"OnlineEcommerceAccount",
|
|
13
|
+
"OnlineGamingAccount",
|
|
14
|
+
"Organization",
|
|
15
|
+
"Person",
|
|
16
|
+
"PersonalProfileDocument",
|
|
17
|
+
"Project",
|
|
18
|
+
"accountName",
|
|
19
|
+
"accountServiceHomepage",
|
|
20
|
+
"aimChatID",
|
|
21
|
+
"based_near",
|
|
22
|
+
"currentProject",
|
|
23
|
+
"depiction",
|
|
24
|
+
"depicts",
|
|
25
|
+
"dnaChecksum",
|
|
26
|
+
"family_name",
|
|
27
|
+
"firstName",
|
|
28
|
+
"fundedBy",
|
|
29
|
+
"geekcode",
|
|
30
|
+
"gender",
|
|
31
|
+
"givenname",
|
|
32
|
+
"holdsAccount",
|
|
33
|
+
"homepage",
|
|
34
|
+
"icqChatID",
|
|
35
|
+
"img",
|
|
36
|
+
"interest",
|
|
37
|
+
"jabberID",
|
|
38
|
+
"knows",
|
|
39
|
+
"logo",
|
|
40
|
+
"made",
|
|
41
|
+
"maker",
|
|
42
|
+
"mbox",
|
|
43
|
+
"mbox_sha1sum",
|
|
44
|
+
"member",
|
|
45
|
+
"membershipClass",
|
|
46
|
+
"msnChatID",
|
|
47
|
+
"myersBriggs",
|
|
48
|
+
"name",
|
|
49
|
+
"nick",
|
|
50
|
+
"page",
|
|
51
|
+
"pastProject",
|
|
52
|
+
"phone",
|
|
53
|
+
"plan",
|
|
54
|
+
"primaryTopic",
|
|
55
|
+
"publications",
|
|
56
|
+
"schoolHomepage",
|
|
57
|
+
"sha1",
|
|
58
|
+
"surname",
|
|
59
|
+
"theme",
|
|
60
|
+
"thumbnail",
|
|
61
|
+
"tipjar",
|
|
62
|
+
"title",
|
|
63
|
+
"topic",
|
|
64
|
+
"topic_interest",
|
|
65
|
+
"weblog",
|
|
66
|
+
"workInfoHomepage",
|
|
67
|
+
"workplaceHomepage",
|
|
68
|
+
"yahooChatID",
|
|
69
|
+
],
|
|
70
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { createNamespace } from "./namespace.js";
|
|
2
|
+
export default createNamespace({
|
|
3
|
+
iri: "http://purl.org/goodrelations/v1#",
|
|
4
|
+
prefix: "gr:",
|
|
5
|
+
terms: [
|
|
6
|
+
"ActualProductOrServiceInstance",
|
|
7
|
+
"AmericanExpress",
|
|
8
|
+
"Brand",
|
|
9
|
+
"Business",
|
|
10
|
+
"BusinessEntity",
|
|
11
|
+
"BusinessEntityType",
|
|
12
|
+
"BusinessFunction",
|
|
13
|
+
"Buy",
|
|
14
|
+
"ByBankTransferInAdvance",
|
|
15
|
+
"ByInvoice",
|
|
16
|
+
"COD",
|
|
17
|
+
"Cash",
|
|
18
|
+
"CheckInAdvance",
|
|
19
|
+
"ConstructionInstallation",
|
|
20
|
+
"DHL",
|
|
21
|
+
"DayOfWeek",
|
|
22
|
+
"DeliveryChargeSpecification",
|
|
23
|
+
"DeliveryMethod",
|
|
24
|
+
"DeliveryModeDirectDownload",
|
|
25
|
+
"DeliveryModeFreight",
|
|
26
|
+
"DeliveryModeMail",
|
|
27
|
+
"DeliveryModeOwnFleet",
|
|
28
|
+
"DeliveryModeParcelService",
|
|
29
|
+
"DeliveryModePickUp",
|
|
30
|
+
"DinersClub",
|
|
31
|
+
"DirectDebit",
|
|
32
|
+
"Discover",
|
|
33
|
+
"Dispose",
|
|
34
|
+
"Enduser",
|
|
35
|
+
"FederalExpress",
|
|
36
|
+
"Friday",
|
|
37
|
+
"GoogleCheckout",
|
|
38
|
+
"Individual",
|
|
39
|
+
"JCB",
|
|
40
|
+
"LeaseOut",
|
|
41
|
+
"License",
|
|
42
|
+
"Location",
|
|
43
|
+
"LocationOfSalesOrServiceProvisioning",
|
|
44
|
+
"Maintain",
|
|
45
|
+
"MasterCard",
|
|
46
|
+
"Monday",
|
|
47
|
+
"Offering",
|
|
48
|
+
"OpeningHoursSpecification",
|
|
49
|
+
"PayPal",
|
|
50
|
+
"PaySwarm",
|
|
51
|
+
"PaymentChargeSpecification",
|
|
52
|
+
"PaymentMethod",
|
|
53
|
+
"PaymentMethodCreditCard",
|
|
54
|
+
"PriceSpecification",
|
|
55
|
+
"ProductOrService",
|
|
56
|
+
"ProductOrServiceModel",
|
|
57
|
+
"ProductOrServicesSomeInstancesPlaceholder",
|
|
58
|
+
"ProvideService",
|
|
59
|
+
"PublicHolidays",
|
|
60
|
+
"PublicInstitution",
|
|
61
|
+
"QualitativeValue",
|
|
62
|
+
"QuantitativeValue",
|
|
63
|
+
"QuantitativeValueFloat",
|
|
64
|
+
"QuantitativeValueInteger",
|
|
65
|
+
"Repair",
|
|
66
|
+
"Reseller",
|
|
67
|
+
"Saturday",
|
|
68
|
+
"Sell",
|
|
69
|
+
"SomeItems",
|
|
70
|
+
"Sunday",
|
|
71
|
+
"Thursday",
|
|
72
|
+
"Tuesday",
|
|
73
|
+
"TypeAndQuantityNode",
|
|
74
|
+
"UPS",
|
|
75
|
+
"UnitPriceSpecification",
|
|
76
|
+
"VISA",
|
|
77
|
+
"WarrantyPromise",
|
|
78
|
+
"WarrantyScope",
|
|
79
|
+
"Wednesday",
|
|
80
|
+
"acceptedPaymentMethods",
|
|
81
|
+
"addOn",
|
|
82
|
+
"advanceBookingRequirement",
|
|
83
|
+
"amountOfThisGood",
|
|
84
|
+
"appliesToDeliveryMethod",
|
|
85
|
+
"appliesToPaymentMethod",
|
|
86
|
+
"availabilityEnds",
|
|
87
|
+
"availabilityStarts",
|
|
88
|
+
"availableAtOrFrom",
|
|
89
|
+
"availableDeliveryMethods",
|
|
90
|
+
"billingIncrement",
|
|
91
|
+
"category",
|
|
92
|
+
"closes",
|
|
93
|
+
"color",
|
|
94
|
+
"condition",
|
|
95
|
+
"datatypeProductOrServiceProperty",
|
|
96
|
+
"deliveryLeadTime",
|
|
97
|
+
"depth",
|
|
98
|
+
"description",
|
|
99
|
+
"displayPosition",
|
|
100
|
+
"durationOfWarrantyInMonths",
|
|
101
|
+
"eligibleCustomerTypes",
|
|
102
|
+
"eligibleDuration",
|
|
103
|
+
"eligibleRegions",
|
|
104
|
+
"eligibleTransactionVolume",
|
|
105
|
+
"equal",
|
|
106
|
+
"greater",
|
|
107
|
+
"greaterOrEqual",
|
|
108
|
+
"hasBrand",
|
|
109
|
+
"hasBusinessFunction",
|
|
110
|
+
"hasCurrency",
|
|
111
|
+
"hasCurrencyValue",
|
|
112
|
+
"hasDUNS",
|
|
113
|
+
"hasEligibleQuantity",
|
|
114
|
+
"hasGlobalLocationNumber",
|
|
115
|
+
"hasISICv4",
|
|
116
|
+
"hasInventoryLevel",
|
|
117
|
+
"hasMPN",
|
|
118
|
+
"hasMakeAndModel",
|
|
119
|
+
"hasManufacturer",
|
|
120
|
+
"hasMaxCurrencyValue",
|
|
121
|
+
"hasMaxValue",
|
|
122
|
+
"hasMaxValueFloat",
|
|
123
|
+
"hasMaxValueInteger",
|
|
124
|
+
"hasMinCurrencyValue",
|
|
125
|
+
"hasMinValue",
|
|
126
|
+
"hasMinValueFloat",
|
|
127
|
+
"hasMinValueInteger",
|
|
128
|
+
"hasNAICS",
|
|
129
|
+
"hasNext",
|
|
130
|
+
"hasOpeningHoursDayOfWeek",
|
|
131
|
+
"hasOpeningHoursSpecification",
|
|
132
|
+
"hasPOS",
|
|
133
|
+
"hasPrevious",
|
|
134
|
+
"hasPriceSpecification",
|
|
135
|
+
"hasStockKeepingUnit",
|
|
136
|
+
"hasUnitOfMeasurement",
|
|
137
|
+
"hasValue",
|
|
138
|
+
"hasValueFloat",
|
|
139
|
+
"hasValueInteger",
|
|
140
|
+
"hasWarrantyPromise",
|
|
141
|
+
"hasWarrantyScope",
|
|
142
|
+
"height",
|
|
143
|
+
"includes",
|
|
144
|
+
"includesObject",
|
|
145
|
+
"isAccessoryOrSparePartFor",
|
|
146
|
+
"isConsumableFor",
|
|
147
|
+
"isListPrice",
|
|
148
|
+
"isSimilarTo",
|
|
149
|
+
"isVariantOf",
|
|
150
|
+
"legalName",
|
|
151
|
+
"lesser",
|
|
152
|
+
"lesserOrEqual",
|
|
153
|
+
"name",
|
|
154
|
+
"nonEqual",
|
|
155
|
+
"offers",
|
|
156
|
+
"opens",
|
|
157
|
+
"owns",
|
|
158
|
+
"predecessorOf",
|
|
159
|
+
"priceType",
|
|
160
|
+
"qualitativeProductOrServiceProperty",
|
|
161
|
+
"quantitativeProductOrServiceProperty",
|
|
162
|
+
"relatedWebService",
|
|
163
|
+
"seeks",
|
|
164
|
+
"serialNumber",
|
|
165
|
+
"successorOf",
|
|
166
|
+
"taxID",
|
|
167
|
+
"typeOfGood",
|
|
168
|
+
"validFrom",
|
|
169
|
+
"validThrough",
|
|
170
|
+
"valueAddedTaxIncluded",
|
|
171
|
+
"valueReference",
|
|
172
|
+
"vatID",
|
|
173
|
+
"weight",
|
|
174
|
+
"width",
|
|
175
|
+
],
|
|
176
|
+
});
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
1
|
+
export { default as dbo } from "./dbo.js";
|
|
2
|
+
export { default as dc } from "./dc.js";
|
|
3
3
|
export { default as dcterms } from "./dcterms.js";
|
|
4
|
+
export { default as foaf } from "./foaf.js";
|
|
5
|
+
export { default as gr } from "./gr.js";
|
|
4
6
|
export { default as ldkit } from "./ldkit.js";
|
|
7
|
+
export { default as rdf } from "./rdf.js";
|
|
8
|
+
export { default as rdfs } from "./rdfs.js";
|
|
5
9
|
export { default as schema } from "./schema.js";
|
|
10
|
+
export { default as sioc } from "./sioc.js";
|
|
6
11
|
export { default as skos } from "./skos.js";
|
|
7
12
|
export { default as xsd } from "./xsd.js";
|
|
8
13
|
export { createNamespace } from "./namespace.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createNamespace } from "./namespace.js";
|
|
2
|
+
export default createNamespace({
|
|
3
|
+
iri: "http://rdfs.org/sioc/ns#",
|
|
4
|
+
prefix: "sioc:",
|
|
5
|
+
terms: [
|
|
6
|
+
"Community",
|
|
7
|
+
"Container",
|
|
8
|
+
"Forum",
|
|
9
|
+
"Item",
|
|
10
|
+
"Post",
|
|
11
|
+
"Role",
|
|
12
|
+
"Site",
|
|
13
|
+
"Space",
|
|
14
|
+
"Thread",
|
|
15
|
+
"User",
|
|
16
|
+
"UserAccount",
|
|
17
|
+
"Usergroup",
|
|
18
|
+
"about",
|
|
19
|
+
"account_of",
|
|
20
|
+
"addressed_to",
|
|
21
|
+
"administrator_of",
|
|
22
|
+
"attachment",
|
|
23
|
+
"avatar",
|
|
24
|
+
"container_of",
|
|
25
|
+
"content",
|
|
26
|
+
"content_encoded",
|
|
27
|
+
"created_at",
|
|
28
|
+
"creator_of",
|
|
29
|
+
"delivered_at",
|
|
30
|
+
"description",
|
|
31
|
+
"discussion_of",
|
|
32
|
+
"earlier_version",
|
|
33
|
+
"email",
|
|
34
|
+
"email_sha1",
|
|
35
|
+
"embeds_knowledge",
|
|
36
|
+
"feed",
|
|
37
|
+
"first_name",
|
|
38
|
+
"follows",
|
|
39
|
+
"function_of",
|
|
40
|
+
"generator",
|
|
41
|
+
"group_of",
|
|
42
|
+
"has_administrator",
|
|
43
|
+
"has_container",
|
|
44
|
+
"has_creator",
|
|
45
|
+
"has_discussion",
|
|
46
|
+
"has_function",
|
|
47
|
+
"has_group",
|
|
48
|
+
"has_host",
|
|
49
|
+
"has_member",
|
|
50
|
+
"has_moderator",
|
|
51
|
+
"has_modifier",
|
|
52
|
+
"has_owner",
|
|
53
|
+
"has_parent",
|
|
54
|
+
"has_part",
|
|
55
|
+
"has_reply",
|
|
56
|
+
"has_scope",
|
|
57
|
+
"has_space",
|
|
58
|
+
"has_subscriber",
|
|
59
|
+
"has_usergroup",
|
|
60
|
+
"host_of",
|
|
61
|
+
"id",
|
|
62
|
+
"ip_address",
|
|
63
|
+
"last_activity_date",
|
|
64
|
+
"last_item_date",
|
|
65
|
+
"last_name",
|
|
66
|
+
"last_reply_date",
|
|
67
|
+
"later_version",
|
|
68
|
+
"latest_version",
|
|
69
|
+
"likes",
|
|
70
|
+
"link",
|
|
71
|
+
"links_to",
|
|
72
|
+
"member_of",
|
|
73
|
+
"mentions",
|
|
74
|
+
"moderator_of",
|
|
75
|
+
"modified_at",
|
|
76
|
+
"modifier_of",
|
|
77
|
+
"name",
|
|
78
|
+
"next_by_date",
|
|
79
|
+
"next_version",
|
|
80
|
+
"note",
|
|
81
|
+
"num_authors",
|
|
82
|
+
"num_items",
|
|
83
|
+
"num_replies",
|
|
84
|
+
"num_threads",
|
|
85
|
+
"num_views",
|
|
86
|
+
"owner_of",
|
|
87
|
+
"parent_of",
|
|
88
|
+
"part_of",
|
|
89
|
+
"previous_by_date",
|
|
90
|
+
"previous_version",
|
|
91
|
+
"read_at",
|
|
92
|
+
"reference",
|
|
93
|
+
"related_to",
|
|
94
|
+
"reply_of",
|
|
95
|
+
"respond_to",
|
|
96
|
+
"scope_of",
|
|
97
|
+
"shared_by",
|
|
98
|
+
"sibling",
|
|
99
|
+
"space_of",
|
|
100
|
+
"subject",
|
|
101
|
+
"subscriber_of",
|
|
102
|
+
"title",
|
|
103
|
+
"topic",
|
|
104
|
+
"usergroup_of",
|
|
105
|
+
],
|
|
106
|
+
});
|
package/esm/library/rdf.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { fromRdf, toRdf } from "rdf-literal";
|
|
2
2
|
import { DataFactory } from "rdf-data-factory";
|
|
3
3
|
export { DataFactory };
|
|
4
|
-
import { BindingsFactory as ComunicaBindingsFactory } from "@comunica/bindings-factory";
|
|
5
4
|
export const quadsToGraph = (quads) => {
|
|
6
5
|
const graph = new Map();
|
|
7
6
|
for (const quad of quads) {
|
|
@@ -39,10 +38,89 @@ export class TermFactory {
|
|
|
39
38
|
return this.dataFactory.literal(jsonTerm.value);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
export class
|
|
43
|
-
constructor(dataFactory = new DataFactory()
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
export class ReadOnlyBindings {
|
|
42
|
+
constructor(bindings, dataFactory = new DataFactory()) {
|
|
43
|
+
Object.defineProperty(this, "type", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: "bindings"
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, "dataFactory", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: void 0
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, "entries", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: void 0
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, "variables", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
value: void 0
|
|
66
|
+
});
|
|
67
|
+
this.entries = bindings;
|
|
68
|
+
this.dataFactory = dataFactory;
|
|
69
|
+
this.variables = new Map();
|
|
70
|
+
for (const variable of bindings.keys()) {
|
|
71
|
+
this.variables.set(variable.value, variable);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
has(key) {
|
|
75
|
+
const stringKey = typeof key === "string" ? key : key.value;
|
|
76
|
+
const variableKey = this.variables.get(stringKey);
|
|
77
|
+
return this.entries.has(variableKey);
|
|
78
|
+
}
|
|
79
|
+
get(key) {
|
|
80
|
+
const stringKey = typeof key === "string" ? key : key.value;
|
|
81
|
+
const variableKey = this.variables.get(stringKey);
|
|
82
|
+
return this.entries.get(variableKey);
|
|
83
|
+
}
|
|
84
|
+
set(_key, _value) {
|
|
85
|
+
throw new Error("Method not implemented.");
|
|
86
|
+
}
|
|
87
|
+
delete(_key) {
|
|
88
|
+
throw new Error("Method not implemented.");
|
|
89
|
+
}
|
|
90
|
+
keys() {
|
|
91
|
+
return this.entries.keys();
|
|
92
|
+
}
|
|
93
|
+
values() {
|
|
94
|
+
return this.entries.values();
|
|
95
|
+
}
|
|
96
|
+
forEach(fn) {
|
|
97
|
+
return this.entries.forEach(fn);
|
|
98
|
+
}
|
|
99
|
+
get size() {
|
|
100
|
+
return this.entries.size;
|
|
101
|
+
}
|
|
102
|
+
[Symbol.iterator]() {
|
|
103
|
+
return this.entries.entries();
|
|
104
|
+
}
|
|
105
|
+
equals(_other) {
|
|
106
|
+
throw new Error("Method not implemented.");
|
|
107
|
+
}
|
|
108
|
+
filter(_fn) {
|
|
109
|
+
throw new Error("Method not implemented.");
|
|
110
|
+
}
|
|
111
|
+
map(_fn) {
|
|
112
|
+
throw new Error("Method not implemented.");
|
|
113
|
+
}
|
|
114
|
+
merge(_other) {
|
|
115
|
+
throw new Error("Method not implemented.");
|
|
116
|
+
}
|
|
117
|
+
mergeWith(_merger, _other) {
|
|
118
|
+
throw new Error("Method not implemented.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export class BindingsFactory {
|
|
122
|
+
constructor(dataFactory = new DataFactory(), termFactory = new TermFactory(dataFactory)) {
|
|
123
|
+
Object.defineProperty(this, "dataFactory", {
|
|
46
124
|
enumerable: true,
|
|
47
125
|
configurable: true,
|
|
48
126
|
writable: true,
|
|
@@ -54,21 +132,21 @@ export class BindingsFactory extends ComunicaBindingsFactory {
|
|
|
54
132
|
writable: true,
|
|
55
133
|
value: void 0
|
|
56
134
|
});
|
|
57
|
-
this.
|
|
135
|
+
this.dataFactory = dataFactory;
|
|
58
136
|
this.termFactory = termFactory;
|
|
59
137
|
}
|
|
60
138
|
fromJson(jsonBindings) {
|
|
61
139
|
const bindingsEntries = Object.entries(jsonBindings).map(([varName, jsonTerm]) => {
|
|
62
140
|
return [
|
|
63
|
-
this.
|
|
141
|
+
this.dataFactory.variable(varName),
|
|
64
142
|
this.termFactory.fromJson(jsonTerm),
|
|
65
143
|
];
|
|
66
144
|
});
|
|
67
|
-
return
|
|
145
|
+
return new ReadOnlyBindings(new Map(bindingsEntries), this.dataFactory);
|
|
68
146
|
}
|
|
69
147
|
}
|
|
70
148
|
export class QuadFactory {
|
|
71
|
-
constructor(dataFactory = new DataFactory(), termFactory = new TermFactory()) {
|
|
149
|
+
constructor(dataFactory = new DataFactory(), termFactory = new TermFactory(dataFactory)) {
|
|
72
150
|
Object.defineProperty(this, "dataFactory", {
|
|
73
151
|
enumerable: true,
|
|
74
152
|
configurable: true,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getSchemaProperties } from "../schema/mod.js";
|
|
2
2
|
import { $, CONSTRUCT, DELETE, INSERT, SELECT } from "../sparql.js";
|
|
3
3
|
import { DataFactory } from "../rdf.js";
|
|
4
|
-
import
|
|
4
|
+
import ldkit from "../namespaces/ldkit.js";
|
|
5
|
+
import rdf from "../namespaces/rdf.js";
|
|
5
6
|
import { encode } from "../encoder.js";
|
|
6
7
|
import { QueryHelper } from "./query_helper.js";
|
|
7
8
|
export class QueryBuilder {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "./script/mod.js",
|
|
4
4
|
"types": "./types/mod.d.ts",
|
|
5
5
|
"name": "ldkit",
|
|
6
|
-
"version": "0.6.
|
|
6
|
+
"version": "0.6.4",
|
|
7
7
|
"description": "LDkit, a Linked Data query toolkit for TypeScript developers",
|
|
8
8
|
"homepage": "https://ldkit.io",
|
|
9
9
|
"author": "Karel Klima <karelklima@gmail.com> (https://karelklima.com)",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@comunica/bindings-factory": "2.2.0",
|
|
48
47
|
"@comunica/types": "2.4.0",
|
|
49
48
|
"@tpluscode/rdf-string": "0.2.26",
|
|
50
49
|
"@tpluscode/sparql-builder": "0.3.23",
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.decode = void 0;
|
|
4
7
|
const rdf_js_1 = require("./rdf.js");
|
|
5
|
-
const
|
|
8
|
+
const ldkit_js_1 = __importDefault(require("./namespaces/ldkit.js"));
|
|
9
|
+
const rdf_js_2 = __importDefault(require("./namespaces/rdf.js"));
|
|
6
10
|
class Decoder {
|
|
7
11
|
constructor(graph, schema, context) {
|
|
8
12
|
Object.defineProperty(this, "graph", {
|
|
@@ -51,17 +55,17 @@ class Decoder {
|
|
|
51
55
|
decode() {
|
|
52
56
|
const output = [];
|
|
53
57
|
for (const [iri, properties] of this.graph) {
|
|
54
|
-
if (properties.has(
|
|
55
|
-
const types = properties.get(
|
|
58
|
+
if (properties.has(rdf_js_2.default.type)) {
|
|
59
|
+
const types = properties.get(rdf_js_2.default.type);
|
|
56
60
|
for (const type of types) {
|
|
57
|
-
if (type.termType === "NamedNode" && type.value ===
|
|
61
|
+
if (type.termType === "NamedNode" && type.value === ldkit_js_1.default.Resource) {
|
|
58
62
|
output.push(this.decodeNode(iri, this.schema));
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
if (this.graph.size > 0 && output.length < 1) {
|
|
64
|
-
throw new Error(`Unable to decode graph - no resources with type <${
|
|
68
|
+
throw new Error(`Unable to decode graph - no resources with type <${ldkit_js_1.default.Resource}> found`);
|
|
65
69
|
}
|
|
66
70
|
return output;
|
|
67
71
|
}
|
|
@@ -91,12 +95,12 @@ class Decoder {
|
|
|
91
95
|
return output;
|
|
92
96
|
}
|
|
93
97
|
decodeNodeType(node) {
|
|
94
|
-
const typeTerms = node.get(
|
|
98
|
+
const typeTerms = node.get(rdf_js_2.default.type);
|
|
95
99
|
if (!typeTerms) {
|
|
96
100
|
return [];
|
|
97
101
|
}
|
|
98
102
|
return typeTerms.reduce((acc, term) => {
|
|
99
|
-
if (term.value !==
|
|
103
|
+
if (term.value !== ldkit_js_1.default.Resource) {
|
|
100
104
|
acc.push(term.value);
|
|
101
105
|
}
|
|
102
106
|
return acc;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.encode = void 0;
|
|
4
7
|
const rdf_js_1 = require("./rdf.js");
|
|
5
|
-
const
|
|
8
|
+
const xsd_js_1 = __importDefault(require("./namespaces/xsd.js"));
|
|
9
|
+
const rdf_js_2 = __importDefault(require("./namespaces/rdf.js"));
|
|
6
10
|
const encode = (node, schema, context, variableInitCounter = 0) => {
|
|
7
11
|
return Encoder.encode(node, schema, context, variableInitCounter);
|
|
8
12
|
};
|
|
@@ -72,7 +76,7 @@ class Encoder {
|
|
|
72
76
|
encodeNodeType(node, requiredTypes, nodeId) {
|
|
73
77
|
const finalTypes = new Set([...this.getNodeTypes(node), ...requiredTypes]);
|
|
74
78
|
finalTypes.forEach((type) => {
|
|
75
|
-
this.push(nodeId, this.df.namedNode(
|
|
79
|
+
this.push(nodeId, this.df.namedNode(rdf_js_2.default.type), this.df.namedNode(type));
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
encodeNodeProperty(value, property, nodeId) {
|
|
@@ -104,9 +108,9 @@ class Encoder {
|
|
|
104
108
|
this.push(nodeId, propertyId, subNodeId);
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
107
|
-
const propertyType = property["@type"] ? property["@type"] :
|
|
111
|
+
const propertyType = property["@type"] ? property["@type"] : xsd_js_1.default.string;
|
|
108
112
|
if (typeof val === "string" && this.context.language) {
|
|
109
|
-
if (propertyType ===
|
|
113
|
+
if (propertyType === xsd_js_1.default.string || propertyType === rdf_js_2.default.langString) {
|
|
110
114
|
this.push(nodeId, propertyId, this.df.literal(val, this.context.language));
|
|
111
115
|
return;
|
|
112
116
|
}
|