sparkql 0.1.0-alpha.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.md +21 -0
- package/README.md +198 -0
- package/dist/database/ask.d.ts +6 -0
- package/dist/database/ask.js +15 -0
- package/dist/database/ask.js.map +1 -0
- package/dist/database/base.d.ts +42 -0
- package/dist/database/base.js +87 -0
- package/dist/database/base.js.map +1 -0
- package/dist/database/construct.d.ts +7 -0
- package/dist/database/construct.js +21 -0
- package/dist/database/construct.js.map +1 -0
- package/dist/database/describe.d.ts +7 -0
- package/dist/database/describe.js +22 -0
- package/dist/database/describe.js.map +1 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.js +2 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/query.d.ts +8 -0
- package/dist/database/query.js +58 -0
- package/dist/database/query.js.map +1 -0
- package/dist/database/select.d.ts +32 -0
- package/dist/database/select.js +128 -0
- package/dist/database/select.js.map +1 -0
- package/dist/database/sparql-query.d.ts +34 -0
- package/dist/database/sparql-query.js +338 -0
- package/dist/database/sparql-query.js.map +1 -0
- package/dist/database/update.d.ts +29 -0
- package/dist/database/update.js +137 -0
- package/dist/database/update.js.map +1 -0
- package/dist/database/with.d.ts +19 -0
- package/dist/database/with.js +97 -0
- package/dist/database/with.js.map +1 -0
- package/dist/functions/aggregate.d.ts +14 -0
- package/dist/functions/aggregate.js +37 -0
- package/dist/functions/aggregate.js.map +1 -0
- package/dist/functions/function.d.ts +57 -0
- package/dist/functions/function.js +177 -0
- package/dist/functions/function.js.map +1 -0
- package/dist/functions/index.d.ts +4 -0
- package/dist/functions/index.js +5 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/operation.d.ts +16 -0
- package/dist/functions/operation.js +52 -0
- package/dist/functions/operation.js.map +1 -0
- package/dist/functions/utils.d.ts +5 -0
- package/dist/functions/utils.js +29 -0
- package/dist/functions/utils.js.map +1 -0
- package/dist/generic.d.ts +262 -0
- package/dist/generic.js +11 -0
- package/dist/generic.js.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/structures/blank.d.ts +11 -0
- package/dist/structures/blank.js +18 -0
- package/dist/structures/blank.js.map +1 -0
- package/dist/structures/expression.d.ts +33 -0
- package/dist/structures/expression.js +169 -0
- package/dist/structures/expression.js.map +1 -0
- package/dist/structures/index.d.ts +7 -0
- package/dist/structures/index.js +8 -0
- package/dist/structures/index.js.map +1 -0
- package/dist/structures/iri.d.ts +18 -0
- package/dist/structures/iri.js +35 -0
- package/dist/structures/iri.js.map +1 -0
- package/dist/structures/ordering.d.ts +3 -0
- package/dist/structures/ordering.js +7 -0
- package/dist/structures/ordering.js.map +1 -0
- package/dist/structures/path.d.ts +25 -0
- package/dist/structures/path.js +29 -0
- package/dist/structures/path.js.map +1 -0
- package/dist/structures/pattern.d.ts +13 -0
- package/dist/structures/pattern.js +78 -0
- package/dist/structures/pattern.js.map +1 -0
- package/dist/structures/variable.d.ts +13 -0
- package/dist/structures/variable.js +28 -0
- package/dist/structures/variable.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/functions/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,UAAU,EAAE,CAAC,GAAG,IAA8B;IAClD,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,EAAE,CAAC,GAAG,IAA8B;IAClD,OAAO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turnType, OperationExpression, AggregateExpression, FunctionCallExpression } from '../generic.js';
|
|
2
|
+
export declare function op<K extends QueryReturnType>(operator: string, args: (ExpressionWithTuple | Pattern)[], transform?: (self: BaseQueryReturnType, ...other: any[]) => K): OperationExpression<K>;
|
|
3
|
+
export declare function func<K extends QueryReturnType>(func: string | IriTerm, args: ExpressionWithTuple[], transform?: (self: BaseQueryReturnType, ...other: any[]) => K): FunctionCallExpression<K>;
|
|
4
|
+
export declare function agg<K extends QueryReturnType>(expression: ExpressionWithTuple | Wildcard, aggregation: string, separator?: string | undefined, transform?: (self: BaseQueryReturnType, ...other: any[]) => K): AggregateExpression<K>;
|
|
5
|
+
export declare function distinct<K extends QueryReturnType, T extends OperationExpression<K> | FunctionCallExpression<K> | AggregateExpression<K>>(expression: T): T;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function op(operator, args, transform) {
|
|
2
|
+
return {
|
|
3
|
+
type: 'operation',
|
|
4
|
+
operator: operator,
|
|
5
|
+
args: args,
|
|
6
|
+
transform: transform,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function func(func, args, transform) {
|
|
10
|
+
return {
|
|
11
|
+
type: 'functionCall',
|
|
12
|
+
function: func,
|
|
13
|
+
args: args,
|
|
14
|
+
transform: transform,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function agg(expression, aggregation, separator, transform) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'aggregate',
|
|
20
|
+
expression: expression,
|
|
21
|
+
aggregation: aggregation,
|
|
22
|
+
separator: separator,
|
|
23
|
+
transform: transform,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function distinct(expression) {
|
|
27
|
+
return { ...expression, distinct: true };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/functions/utils.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,EAAE,CAChB,QAAgB,EAChB,IAAuC,EACvC,SAA6D;IAE7D,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,SAAS;KACrB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI,CAClB,IAAsB,EACtB,IAA2B,EAC3B,SAA6D;IAE7D,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,SAAS;KACrB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,CACjB,UAA0C,EAC1C,WAAmB,EACnB,SAA8B,EAC9B,SAA6D;IAE7D,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE,WAAW;QACxB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;KACrB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAGtB,UAAa;IACb,OAAO,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type * as SparqlJs from 'sparqljs';
|
|
2
|
+
import type * as RdfJs from 'rdf-data-factory';
|
|
3
|
+
import { SelectQueryBuilderBase } from './database/select.js';
|
|
4
|
+
export { SparqlJs, RdfJs };
|
|
5
|
+
export type { StreamClient as SparqlClient } from 'sparql-http-client';
|
|
6
|
+
export type DataFactory = RdfJs.DataFactory;
|
|
7
|
+
export type ExcludePrefix<T extends string, K extends string> = T extends `${K}${number}` ? never : T;
|
|
8
|
+
export type FactoryFunctions<K extends string = string> = {
|
|
9
|
+
variable: (value: string) => SparqlJs.VariableTerm;
|
|
10
|
+
iri: <T extends string>(value: T) => SparqlJs.IriTerm;
|
|
11
|
+
blank: <T extends string>(value?: ExcludePrefix<T, K>) => SparqlJs.BlankTerm;
|
|
12
|
+
literal: (value: string, lang?: string | IriTerm) => SparqlJs.LiteralTerm;
|
|
13
|
+
};
|
|
14
|
+
export type Wildcard = SparqlJs.Wildcard;
|
|
15
|
+
export type SparqlGenerator = SparqlJs.SparqlGenerator;
|
|
16
|
+
export type SparqlQuery = Query | Update;
|
|
17
|
+
export type Query = SelectQuery | ConstructQuery | AskQuery | DescribeQuery;
|
|
18
|
+
export interface BaseQuery {
|
|
19
|
+
type: 'query';
|
|
20
|
+
base?: string | undefined;
|
|
21
|
+
prefixes: {
|
|
22
|
+
[p: string]: string;
|
|
23
|
+
};
|
|
24
|
+
from?: {
|
|
25
|
+
default: IriTerm[];
|
|
26
|
+
named: IriTerm[];
|
|
27
|
+
} | undefined;
|
|
28
|
+
where?: Pattern[] | undefined;
|
|
29
|
+
values?: ValuePatternColumns | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface SelectQuery extends BaseQuery {
|
|
32
|
+
queryType: 'SELECT';
|
|
33
|
+
variables: Variable[];
|
|
34
|
+
distinct?: boolean | undefined;
|
|
35
|
+
reduced?: boolean | undefined;
|
|
36
|
+
group?: Grouping[] | undefined;
|
|
37
|
+
having?: Expression[] | undefined;
|
|
38
|
+
order?: Ordering[] | undefined;
|
|
39
|
+
limit?: number | undefined;
|
|
40
|
+
offset?: number | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface ConstructQuery extends BaseQuery {
|
|
43
|
+
queryType: 'CONSTRUCT';
|
|
44
|
+
template?: Triple[] | undefined;
|
|
45
|
+
}
|
|
46
|
+
export interface AskQuery extends BaseQuery {
|
|
47
|
+
queryType: 'ASK';
|
|
48
|
+
}
|
|
49
|
+
export interface DescribeQuery extends BaseQuery {
|
|
50
|
+
queryType: 'DESCRIBE';
|
|
51
|
+
variables: Array<VariableTerm | IriTerm> | [Wildcard];
|
|
52
|
+
}
|
|
53
|
+
export interface Update {
|
|
54
|
+
type: 'update';
|
|
55
|
+
base?: string | undefined;
|
|
56
|
+
prefixes: {
|
|
57
|
+
[p: string]: string;
|
|
58
|
+
};
|
|
59
|
+
updates: UpdateOperation[];
|
|
60
|
+
}
|
|
61
|
+
export type UpdateOperation = InsertDeleteOperation | ManagementOperation;
|
|
62
|
+
export type InsertDeleteOperation = {
|
|
63
|
+
updateType: 'insert';
|
|
64
|
+
graph?: GraphOrDefault;
|
|
65
|
+
insert: Quads[];
|
|
66
|
+
} | {
|
|
67
|
+
updateType: 'delete';
|
|
68
|
+
graph?: GraphOrDefault;
|
|
69
|
+
delete: Quads[];
|
|
70
|
+
} | {
|
|
71
|
+
updateType: 'insertdelete';
|
|
72
|
+
graph?: IriTerm;
|
|
73
|
+
insert: Quads[];
|
|
74
|
+
delete: Quads[];
|
|
75
|
+
using?: {
|
|
76
|
+
default: IriTerm[];
|
|
77
|
+
named: IriTerm[];
|
|
78
|
+
};
|
|
79
|
+
where: Pattern[];
|
|
80
|
+
} | {
|
|
81
|
+
updateType: 'deletewhere';
|
|
82
|
+
graph?: GraphOrDefault;
|
|
83
|
+
delete: Quads[];
|
|
84
|
+
};
|
|
85
|
+
export type ManagementOperation = CopyMoveAddOperation | LoadOperation | CreateOperation | ClearDropOperation;
|
|
86
|
+
export type CopyMoveAddOperation = {
|
|
87
|
+
type: 'copy' | 'move' | 'add';
|
|
88
|
+
silent: boolean;
|
|
89
|
+
source: GraphOrDefault;
|
|
90
|
+
destination: GraphOrDefault;
|
|
91
|
+
};
|
|
92
|
+
export type LoadOperation = {
|
|
93
|
+
type: 'load';
|
|
94
|
+
silent: boolean;
|
|
95
|
+
source: IriTerm;
|
|
96
|
+
destination: IriTerm | false;
|
|
97
|
+
};
|
|
98
|
+
export type CreateOperation = {
|
|
99
|
+
type: 'create';
|
|
100
|
+
silent: boolean;
|
|
101
|
+
graph: GraphOrDefault;
|
|
102
|
+
};
|
|
103
|
+
export type ClearDropOperation = {
|
|
104
|
+
type: 'clear' | 'drop';
|
|
105
|
+
silent: boolean;
|
|
106
|
+
graph: GraphReference;
|
|
107
|
+
};
|
|
108
|
+
export type Quads = Triple | BgpPattern | GraphQuads;
|
|
109
|
+
export interface GraphOrDefault {
|
|
110
|
+
type: 'graph';
|
|
111
|
+
name?: IriTerm | undefined;
|
|
112
|
+
default?: boolean | undefined;
|
|
113
|
+
}
|
|
114
|
+
export interface GraphReference extends GraphOrDefault {
|
|
115
|
+
named?: boolean | undefined;
|
|
116
|
+
all?: boolean | undefined;
|
|
117
|
+
}
|
|
118
|
+
export type Grouping = Expression | VariableExpression;
|
|
119
|
+
export type Ordering = Expression | {
|
|
120
|
+
expression: Expression;
|
|
121
|
+
descending: boolean | undefined;
|
|
122
|
+
};
|
|
123
|
+
export type BaseIriTerm = SparqlJs.IriTerm;
|
|
124
|
+
export type IriTerm = BaseIriTerm;
|
|
125
|
+
export type AnonymousBlankTerm = [] | symbol;
|
|
126
|
+
export type BaseBlankTerm = SparqlJs.BlankTerm;
|
|
127
|
+
export type BlankTerm = BaseBlankTerm | AnonymousBlankTerm;
|
|
128
|
+
export type PrimitiveTerm = number | bigint | string | boolean | Date;
|
|
129
|
+
export type BaseLiteralTerm = SparqlJs.LiteralTerm;
|
|
130
|
+
export type LiteralTerm = BaseLiteralTerm | PrimitiveTerm;
|
|
131
|
+
export type Variable<T extends QueryReturnType = BaseQueryReturnType, K extends Presence = Presence.required> = VariableExpression<T, K> | VariableTerm<T, K>;
|
|
132
|
+
export interface VariableExpression<T extends QueryReturnType = BaseQueryReturnType, K extends Presence = Presence.required> {
|
|
133
|
+
expression: Expression<T>;
|
|
134
|
+
variable: VariableTerm<T, K>;
|
|
135
|
+
}
|
|
136
|
+
export declare enum Presence {
|
|
137
|
+
required = "required",
|
|
138
|
+
optional = "optional"
|
|
139
|
+
}
|
|
140
|
+
export declare enum Strictness {
|
|
141
|
+
strict = "strict",
|
|
142
|
+
loose = "loose"
|
|
143
|
+
}
|
|
144
|
+
export type Transform<T extends QueryReturnType = QueryReturnType, K extends any[] = []> = (self: BaseQueryReturnType, ...other: K) => T;
|
|
145
|
+
export type OptionalTransform<T extends QueryReturnType = QueryReturnType, K extends any[] = []> = (self: BaseQueryReturnType | undefined, ...other: K) => T | undefined;
|
|
146
|
+
export interface VariableTerm<T extends QueryReturnType = BaseQueryReturnType, K extends Presence = Presence.required> extends SparqlJs.VariableTerm {
|
|
147
|
+
presence?: K;
|
|
148
|
+
transform?: Transform<T>;
|
|
149
|
+
_invariant?: (arg: T) => T;
|
|
150
|
+
}
|
|
151
|
+
export type DefaultGraph = RdfJs.DefaultGraph;
|
|
152
|
+
export type QuadTerm = SparqlJs.QuadTerm;
|
|
153
|
+
export type QuadGraph = DefaultGraph | IriTerm | BlankTerm | VariableTerm;
|
|
154
|
+
export type QuadSubject = IriTerm | BlankTerm | QuadTerm | VariableTerm;
|
|
155
|
+
export type QuadPredicate = IriTerm | VariableTerm;
|
|
156
|
+
export type QuadObject = Term;
|
|
157
|
+
export type Term = VariableTerm | IriTerm | LiteralTerm | BlankTerm | QuadTerm;
|
|
158
|
+
export type BaseQueryReturnType = BaseIriTerm | BaseBlankTerm | BaseLiteralTerm;
|
|
159
|
+
export type QueryReturnType = BaseQueryReturnType | any;
|
|
160
|
+
export type PropertyPath = SparqlJs.PropertyPath;
|
|
161
|
+
export type NegatedPropertySet = SparqlJs.NegatedPropertySet;
|
|
162
|
+
export type PropertySet = Exclude<PropertyPath, NegatedPropertySet>;
|
|
163
|
+
export type TripleSubject = IriTerm | BlankTerm | VariableTerm;
|
|
164
|
+
export type TriplePredicate = IriTerm | VariableTerm | PropertyPath;
|
|
165
|
+
export type TripleObject = Term;
|
|
166
|
+
export type QualitativeAnonymousBlankTerm = [TriplePredicate, TriplesObject] | [TriplesPredicatePairs];
|
|
167
|
+
export type ExtendedBlankTerm = BlankTerm | QualitativeAnonymousBlankTerm;
|
|
168
|
+
export type ExtendedTerm = VariableTerm | IriTerm | LiteralTerm | ExtendedBlankTerm | QuadTerm;
|
|
169
|
+
export type TriplesSubject = IriTerm | ExtendedBlankTerm | VariableTerm;
|
|
170
|
+
export type TriplesObject = ExtendedTerm | TriplesObjectPairs;
|
|
171
|
+
export type TriplesPredicatePairs = {
|
|
172
|
+
type: 'triplespredicatepairs';
|
|
173
|
+
values: [TriplePredicate, TriplesObject][];
|
|
174
|
+
};
|
|
175
|
+
export type TriplesObjectPairs = {
|
|
176
|
+
type: 'triplesobjectpairs';
|
|
177
|
+
values: TriplesObject[];
|
|
178
|
+
};
|
|
179
|
+
export interface Triple extends Record<keyof SparqlJs.Triple, unknown> {
|
|
180
|
+
type: 'triple';
|
|
181
|
+
subject: TripleSubject;
|
|
182
|
+
predicate: TriplePredicate;
|
|
183
|
+
object: TripleObject;
|
|
184
|
+
}
|
|
185
|
+
export type Pattern = Triple | BgpPattern | BlockPattern | FilterPattern | BindPattern | ValuesPattern;
|
|
186
|
+
export type PatternWithSelectQuery = Pattern | SelectQueryBuilderBase<any>;
|
|
187
|
+
export interface BgpPattern {
|
|
188
|
+
type: 'bgp';
|
|
189
|
+
triples: Triple[];
|
|
190
|
+
}
|
|
191
|
+
export interface GraphQuads {
|
|
192
|
+
type: 'graph';
|
|
193
|
+
name: IriTerm | VariableTerm;
|
|
194
|
+
triples: Triple[];
|
|
195
|
+
}
|
|
196
|
+
export type BlockPattern = OptionalPattern | UnionPattern | GroupPattern | GraphPattern | MinusPattern | ServicePattern;
|
|
197
|
+
export interface OptionalPattern {
|
|
198
|
+
type: 'optional';
|
|
199
|
+
patterns: PatternWithSelectQuery[];
|
|
200
|
+
}
|
|
201
|
+
export interface UnionPattern {
|
|
202
|
+
type: 'union';
|
|
203
|
+
patterns: PatternWithSelectQuery[];
|
|
204
|
+
}
|
|
205
|
+
export interface GroupPattern {
|
|
206
|
+
type: 'group';
|
|
207
|
+
patterns: PatternWithSelectQuery[];
|
|
208
|
+
}
|
|
209
|
+
export interface GraphPattern {
|
|
210
|
+
type: 'graph';
|
|
211
|
+
name: IriTerm | VariableTerm;
|
|
212
|
+
patterns: PatternWithSelectQuery[];
|
|
213
|
+
}
|
|
214
|
+
export interface MinusPattern {
|
|
215
|
+
type: 'minus';
|
|
216
|
+
patterns: PatternWithSelectQuery[];
|
|
217
|
+
}
|
|
218
|
+
export interface ServicePattern {
|
|
219
|
+
type: 'service';
|
|
220
|
+
name: IriTerm | VariableTerm;
|
|
221
|
+
silent: boolean;
|
|
222
|
+
patterns: PatternWithSelectQuery[];
|
|
223
|
+
}
|
|
224
|
+
export interface FilterPattern {
|
|
225
|
+
type: 'filter';
|
|
226
|
+
expression: Expression;
|
|
227
|
+
}
|
|
228
|
+
export interface BindPattern {
|
|
229
|
+
type: 'bind';
|
|
230
|
+
expression: Expression;
|
|
231
|
+
variable: VariableTerm;
|
|
232
|
+
}
|
|
233
|
+
export interface ValuesPattern {
|
|
234
|
+
type: 'values';
|
|
235
|
+
values: ValuePatternColumns;
|
|
236
|
+
}
|
|
237
|
+
export interface ValuePatternColumns {
|
|
238
|
+
[variable: string]: (IriTerm | BlankTerm | LiteralTerm | undefined)[];
|
|
239
|
+
}
|
|
240
|
+
export type Expression<T extends QueryReturnType = QueryReturnType> = OperationExpression<T> | FunctionCallExpression<T> | AggregateExpression<T> | IriTerm | VariableTerm<T> | LiteralTerm;
|
|
241
|
+
export interface ExpressionTuple extends Array<Expression> {
|
|
242
|
+
}
|
|
243
|
+
export type ExpressionWithTuple<T extends QueryReturnType = QueryReturnType> = Expression<T> | ExpressionTuple;
|
|
244
|
+
export interface BaseExpression<T extends QueryReturnType = QueryReturnType> extends SparqlJs.BaseExpression {
|
|
245
|
+
transform?: Transform<T>;
|
|
246
|
+
}
|
|
247
|
+
export interface OperationExpression<T extends QueryReturnType = QueryReturnType> extends BaseExpression<T> {
|
|
248
|
+
type: 'operation';
|
|
249
|
+
operator: string;
|
|
250
|
+
args: Array<ExpressionWithTuple | Pattern>;
|
|
251
|
+
}
|
|
252
|
+
export interface FunctionCallExpression<T extends QueryReturnType = QueryReturnType> extends BaseExpression<T> {
|
|
253
|
+
type: 'functionCall';
|
|
254
|
+
function: string | IriTerm;
|
|
255
|
+
args: ExpressionWithTuple[];
|
|
256
|
+
}
|
|
257
|
+
export interface AggregateExpression<T extends QueryReturnType = QueryReturnType> extends BaseExpression<T> {
|
|
258
|
+
type: 'aggregate';
|
|
259
|
+
expression: ExpressionWithTuple | Wildcard;
|
|
260
|
+
aggregation: string;
|
|
261
|
+
separator?: string | undefined;
|
|
262
|
+
}
|
package/dist/generic.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var Presence;
|
|
2
|
+
(function (Presence) {
|
|
3
|
+
Presence["required"] = "required";
|
|
4
|
+
Presence["optional"] = "optional";
|
|
5
|
+
})(Presence || (Presence = {}));
|
|
6
|
+
export var Strictness;
|
|
7
|
+
(function (Strictness) {
|
|
8
|
+
Strictness["strict"] = "strict";
|
|
9
|
+
Strictness["loose"] = "loose";
|
|
10
|
+
})(Strictness || (Strictness = {}));
|
|
11
|
+
//# sourceMappingURL=generic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":"AAyLA,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,iCAAqB,CAAA;AACvB,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AAED,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;AACjB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index.js"), exports);
|
|
18
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FactoryFunctions, BlankTerm } from '../generic.js';
|
|
2
|
+
export type BlankProxy = Record<string, BlankTerm | (() => BlankTerm)>;
|
|
3
|
+
export type BlankManager<K extends string> = {
|
|
4
|
+
__: () => BlankTerm;
|
|
5
|
+
} & {
|
|
6
|
+
[P in `${K}${number}`]: undefined;
|
|
7
|
+
} & {
|
|
8
|
+
[key: string]: BlankTerm;
|
|
9
|
+
};
|
|
10
|
+
export declare function createBlankManager<K extends string>(factoryFunctions: FactoryFunctions<K>): BlankManager<K>;
|
|
11
|
+
export declare function createBlankProxy<K extends string>(factoryFunctions: FactoryFunctions<K>): BlankProxy;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function createBlankManager(factoryFunctions) {
|
|
2
|
+
return createBlankProxy(factoryFunctions);
|
|
3
|
+
}
|
|
4
|
+
export function createBlankProxy(factoryFunctions) {
|
|
5
|
+
const cache = { __: () => factoryFunctions.blank() };
|
|
6
|
+
return new Proxy({}, {
|
|
7
|
+
get(target, prop, receiver) {
|
|
8
|
+
if (typeof prop === 'string') {
|
|
9
|
+
if (!cache[prop]) {
|
|
10
|
+
cache[prop] = factoryFunctions.blank(prop);
|
|
11
|
+
}
|
|
12
|
+
return cache[prop];
|
|
13
|
+
}
|
|
14
|
+
return Reflect.get(target, prop, receiver);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=blank.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blank.js","sourceRoot":"","sources":["../../src/structures/blank.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,kBAAkB,CAChC,gBAAqC;IAErC,OAAO,gBAAgB,CAAC,gBAAgB,CAAoB,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,gBAAqC;IAErC,MAAM,KAAK,GAAe,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,EAAE,CAAC;IACjE,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACjB,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAqC,CAAC,CAAC;gBAC9E,CAAC;gBACD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseIriTerm, BaseBlankTerm, BaseLiteralTerm, BaseQueryReturnType, Expression, Presence, QualitativeAnonymousBlankTerm, Transform, Triple, TripleObject, TriplePredicate, TriplesObject, TriplesObjectPairs, TriplesPredicatePairs, TriplesSubject, TripleSubject, Variable, VariableExpression, VariableTerm } from '../generic.js';
|
|
2
|
+
export declare function triple(subject: TripleSubject, predicate: TriplePredicate, object: TripleObject): Triple;
|
|
3
|
+
export declare function objects(...obj: TriplesObject[]): TriplesObjectPairs;
|
|
4
|
+
export declare function predicates(...obj: [TriplePredicate, TriplesObject][]): TriplesPredicatePairs;
|
|
5
|
+
export declare function triples(subject: QualitativeAnonymousBlankTerm): Triple[];
|
|
6
|
+
export declare function triples(subject: TriplesSubject, predicate: TriplesPredicatePairs): Triple[];
|
|
7
|
+
export declare function triples(subject: TriplesSubject, predicate: TriplePredicate, object: TriplesObject): Triple[];
|
|
8
|
+
export declare function transformIri(self: BaseQueryReturnType): BaseIriTerm;
|
|
9
|
+
export declare function transformLiteral(self: BaseQueryReturnType): BaseLiteralTerm;
|
|
10
|
+
export declare function transformBlank(self: BaseQueryReturnType): BaseBlankTerm;
|
|
11
|
+
export declare const transformString: (self: BaseQueryReturnType) => string;
|
|
12
|
+
export declare const transformLangstring: (self: BaseQueryReturnType) => string;
|
|
13
|
+
export declare const transformBigint: (self: BaseQueryReturnType) => bigint;
|
|
14
|
+
export declare const transformNumber: (self: BaseQueryReturnType) => number;
|
|
15
|
+
export declare const transformBoolean: (self: BaseQueryReturnType) => boolean;
|
|
16
|
+
export declare const transformArray: (self: BaseQueryReturnType, separator?: string) => string[];
|
|
17
|
+
export declare const transformDate: (self: BaseQueryReturnType) => Date;
|
|
18
|
+
export declare const castIri: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<import("sparqljs").IriTerm, P>;
|
|
19
|
+
export declare const castLiteral: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<import("@rdfjs/types").Literal, P>;
|
|
20
|
+
export declare const castBlank: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<import("@rdfjs/types").BlankNode, P>;
|
|
21
|
+
export declare const castString: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<string, P>;
|
|
22
|
+
export declare const castLangstring: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<string, P>;
|
|
23
|
+
export declare const castBoolean: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<boolean, P>;
|
|
24
|
+
export declare const castNumber: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<number, P>;
|
|
25
|
+
export declare const castBigint: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<bigint, P>;
|
|
26
|
+
export declare const castArray: <R2, P extends Presence>(variable: Variable<R2, P>, separator?: string | undefined) => Variable<string[], P>;
|
|
27
|
+
export declare const castDate: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<Date, P>;
|
|
28
|
+
export declare const castUndefinedString: <R2, P extends Presence>(variable: Variable<R2, P>) => Variable<string | undefined, P>;
|
|
29
|
+
export declare function as<R1>(expression: Expression<R1>, variableTerm: VariableTerm<any, Presence>): VariableExpression<R1>;
|
|
30
|
+
export declare function applyTransform<R1, R2, P extends Presence>(variable: Variable<R1, P>, transform: Transform<R2>): Variable<R2, P>;
|
|
31
|
+
export declare function createCast<R1, O extends any[] = []>(transform: Transform<R1, O>): <R2, P extends Presence>(variable: Variable<R2, P>, ...other: O) => Variable<R1, P>;
|
|
32
|
+
export declare function always<T>(variable: Variable<T, Presence>): Variable<T>;
|
|
33
|
+
export declare function maybe<T>(variable: Variable<T, Presence>): Variable<T, Presence.optional>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Presence, } from '../generic.js';
|
|
2
|
+
export function triple(subject, predicate, object) {
|
|
3
|
+
return {
|
|
4
|
+
type: 'triple',
|
|
5
|
+
subject: subject,
|
|
6
|
+
predicate: predicate,
|
|
7
|
+
object: object,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function objects(...obj) {
|
|
11
|
+
return {
|
|
12
|
+
type: 'triplesobjectpairs',
|
|
13
|
+
values: obj,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function predicates(...obj) {
|
|
17
|
+
return {
|
|
18
|
+
type: 'triplespredicatepairs',
|
|
19
|
+
values: obj,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function triples(subject, predicate, object) {
|
|
23
|
+
function processTerm(term) {
|
|
24
|
+
if (isQualitativeAnonymousBlankTerm(term)) {
|
|
25
|
+
// Recursively call the main function to expand this blank node's properties
|
|
26
|
+
const extraTriples = triples(term);
|
|
27
|
+
return [extraTriples[0].subject, extraTriples];
|
|
28
|
+
}
|
|
29
|
+
return [term, []];
|
|
30
|
+
}
|
|
31
|
+
// Overload 1: triples2(QualitativeAnonymousBlankTerm)
|
|
32
|
+
if (arguments.length === 1 && isQualitativeAnonymousBlankTerm(subject)) {
|
|
33
|
+
const bnode = Symbol();
|
|
34
|
+
const predicateOrPairs = subject[0];
|
|
35
|
+
if (isTriplesPredicatePairs(predicateOrPairs)) {
|
|
36
|
+
return triples(bnode, predicateOrPairs);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const obj = subject[1];
|
|
40
|
+
return triples(bnode, predicateOrPairs, obj);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const [processedSubject, subjectTriples] = processTerm(subject);
|
|
44
|
+
// Overload 2: triples2(subject, TriplesPredicatePairs)
|
|
45
|
+
if (arguments.length === 2 && isTriplesPredicatePairs(predicate)) {
|
|
46
|
+
const predicateObjectTriples = predicate.values.flatMap(([p, o]) =>
|
|
47
|
+
// Recurse for each predicate-object pair
|
|
48
|
+
triples(processedSubject, p, o));
|
|
49
|
+
return [...predicateObjectTriples, ...subjectTriples];
|
|
50
|
+
}
|
|
51
|
+
// Overload 3: triples2(subject, predicate, object)
|
|
52
|
+
if (arguments.length === 3 && predicate && object !== undefined) {
|
|
53
|
+
const objects = isTriplesObjectPairs(object) ? object.values : [object];
|
|
54
|
+
const resultTriples = [];
|
|
55
|
+
for (const obj of objects) {
|
|
56
|
+
const [processedObject, objectTriples] = processTerm(obj);
|
|
57
|
+
resultTriples.push(triple(processedSubject, predicate, processedObject));
|
|
58
|
+
resultTriples.push(...objectTriples);
|
|
59
|
+
}
|
|
60
|
+
return [...resultTriples, ...subjectTriples];
|
|
61
|
+
}
|
|
62
|
+
// Should not be reached if called correctly
|
|
63
|
+
throw new Error('Invalid arguments for `triples()` function');
|
|
64
|
+
}
|
|
65
|
+
function isQualitativeAnonymousBlankTerm(term) {
|
|
66
|
+
return Array.isArray(term) && term.length !== 0;
|
|
67
|
+
}
|
|
68
|
+
function isTriplesPredicatePairs(object) {
|
|
69
|
+
return (typeof object === 'object' &&
|
|
70
|
+
'type' in object &&
|
|
71
|
+
object.type === 'triplespredicatepairs' &&
|
|
72
|
+
'values' in object &&
|
|
73
|
+
Array.isArray(object.values));
|
|
74
|
+
}
|
|
75
|
+
function isTriplesObjectPairs(object) {
|
|
76
|
+
return (typeof object === 'object' &&
|
|
77
|
+
'type' in object &&
|
|
78
|
+
object.type === 'triplesobjectpairs' &&
|
|
79
|
+
'values' in object &&
|
|
80
|
+
Array.isArray(object.values));
|
|
81
|
+
}
|
|
82
|
+
export function transformIri(self) {
|
|
83
|
+
if (self.termType === 'NamedNode')
|
|
84
|
+
return self;
|
|
85
|
+
return { termType: 'NamedNode', value: self.value, equals: self.equals };
|
|
86
|
+
}
|
|
87
|
+
export function transformLiteral(self) {
|
|
88
|
+
if (self.termType === 'Literal')
|
|
89
|
+
return self;
|
|
90
|
+
return {
|
|
91
|
+
...self,
|
|
92
|
+
language: '',
|
|
93
|
+
termType: 'Literal',
|
|
94
|
+
datatype: {
|
|
95
|
+
termType: 'NamedNode',
|
|
96
|
+
value: 'http://www.w3.org/2001/XMLSchema#string',
|
|
97
|
+
equals: self.equals
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function transformBlank(self) {
|
|
102
|
+
if (self.termType === 'BlankNode')
|
|
103
|
+
return self;
|
|
104
|
+
return { termType: 'BlankNode', value: self.value, equals: self.equals };
|
|
105
|
+
}
|
|
106
|
+
export const transformString = (self => self.value);
|
|
107
|
+
export const transformLangstring = (self => 'language' in self ? `'${self.value}'@${self.language}` : self.value);
|
|
108
|
+
export const transformBigint = (self => BigInt(self.value));
|
|
109
|
+
export const transformNumber = (self => parseFloat(self.value));
|
|
110
|
+
export const transformBoolean = (self => self.value.toLowerCase() === 'true');
|
|
111
|
+
export const transformArray = ((self, separator = '\u001f') => self.value.split(separator));
|
|
112
|
+
export const transformDate = (self => new Date(self.value));
|
|
113
|
+
export const castIri = createCast(transformIri);
|
|
114
|
+
export const castLiteral = createCast(transformLiteral);
|
|
115
|
+
export const castBlank = createCast(transformBlank);
|
|
116
|
+
export const castString = createCast(transformString);
|
|
117
|
+
export const castLangstring = createCast(transformLangstring);
|
|
118
|
+
export const castBoolean = createCast(transformBoolean);
|
|
119
|
+
export const castNumber = createCast(transformNumber);
|
|
120
|
+
export const castBigint = createCast(transformBigint);
|
|
121
|
+
export const castArray = createCast(transformArray);
|
|
122
|
+
export const castDate = createCast(transformDate);
|
|
123
|
+
export const castUndefinedString = createCast((self) => self.value);
|
|
124
|
+
export function as(expression, variableTerm) {
|
|
125
|
+
const newTerm = { ...variableTerm };
|
|
126
|
+
if (typeof expression === 'object' && 'type' in expression) {
|
|
127
|
+
newTerm.transform = expression.transform;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
variable: newTerm,
|
|
131
|
+
expression: expression,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function applyTransform(variable, transform) {
|
|
135
|
+
const newTerm = { ...variable };
|
|
136
|
+
if ('expression' in newTerm) {
|
|
137
|
+
if (typeof newTerm.expression === 'object' && 'type' in newTerm.expression) {
|
|
138
|
+
newTerm.expression.transform = transform;
|
|
139
|
+
newTerm.variable.transform = transform;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
newTerm.transform = transform;
|
|
144
|
+
}
|
|
145
|
+
return newTerm;
|
|
146
|
+
}
|
|
147
|
+
export function createCast(transform) {
|
|
148
|
+
return (variable, ...other) => applyTransform(variable, self => transform(self, ...other));
|
|
149
|
+
}
|
|
150
|
+
export function always(variable) {
|
|
151
|
+
if ('expression' in variable) {
|
|
152
|
+
variable.variable.presence = Presence.required;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
variable.presence = Presence.required;
|
|
156
|
+
}
|
|
157
|
+
return variable;
|
|
158
|
+
}
|
|
159
|
+
export function maybe(variable) {
|
|
160
|
+
const resultVariable = variable;
|
|
161
|
+
if ('expression' in resultVariable) {
|
|
162
|
+
resultVariable.variable.presence = Presence.optional;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
resultVariable.presence = Presence.optional;
|
|
166
|
+
}
|
|
167
|
+
return resultVariable;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../src/structures/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,QAAQ,GAcT,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,MAAM,CACpB,OAAsB,EACtB,SAA0B,EAC1B,MAAoB;IAEpB,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,OAAO,EAA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