@traqula/rules-sparql-1-1 0.0.1-alpha.176 → 0.0.1

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.
Files changed (100) hide show
  1. package/lib/RoundTripTypes.d.ts +379 -0
  2. package/lib/RoundTripTypes.js +2 -0
  3. package/lib/RoundTripTypes.js.map +1 -0
  4. package/lib/Sparql11types.d.ts +18 -245
  5. package/lib/Sparql11types.js.map +1 -1
  6. package/lib/SparqlParser.d.ts +13 -4
  7. package/lib/SparqlParser.js +7 -4
  8. package/lib/SparqlParser.js.map +1 -1
  9. package/lib/expressionHelpers.d.ts +8 -19
  10. package/lib/expressionHelpers.js +40 -103
  11. package/lib/expressionHelpers.js.map +1 -1
  12. package/lib/factory.d.ts +447 -0
  13. package/lib/factory.js +105 -0
  14. package/lib/factory.js.map +1 -0
  15. package/lib/factoryMixins/ContextFactory.d.ts +38 -0
  16. package/lib/factoryMixins/ContextFactory.js +30 -0
  17. package/lib/factoryMixins/ContextFactory.js.map +1 -0
  18. package/lib/factoryMixins/ExpressionFactory.d.ts +60 -0
  19. package/lib/factoryMixins/ExpressionFactory.js +83 -0
  20. package/lib/factoryMixins/ExpressionFactory.js.map +1 -0
  21. package/lib/factoryMixins/GraphRefFactory.d.ts +43 -0
  22. package/lib/factoryMixins/GraphRefFactory.js +51 -0
  23. package/lib/factoryMixins/GraphRefFactory.js.map +1 -0
  24. package/lib/factoryMixins/PathFactory.d.ts +51 -0
  25. package/lib/factoryMixins/PathFactory.js +68 -0
  26. package/lib/factoryMixins/PathFactory.js.map +1 -0
  27. package/lib/factoryMixins/Patternfactory.d.ts +55 -0
  28. package/lib/factoryMixins/Patternfactory.js +98 -0
  29. package/lib/factoryMixins/Patternfactory.js.map +1 -0
  30. package/lib/factoryMixins/QueryFactory.d.ts +41 -0
  31. package/lib/factoryMixins/QueryFactory.js +43 -0
  32. package/lib/factoryMixins/QueryFactory.js.map +1 -0
  33. package/lib/factoryMixins/SolutionModifiersFactory.d.ts +43 -0
  34. package/lib/factoryMixins/SolutionModifiersFactory.js +55 -0
  35. package/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -0
  36. package/lib/factoryMixins/TermFactory.d.ts +76 -0
  37. package/lib/factoryMixins/TermFactory.js +84 -0
  38. package/lib/factoryMixins/TermFactory.js.map +1 -0
  39. package/lib/factoryMixins/UpdateOperationFactory.d.ts +68 -0
  40. package/lib/factoryMixins/UpdateOperationFactory.js +126 -0
  41. package/lib/factoryMixins/UpdateOperationFactory.js.map +1 -0
  42. package/lib/factoryMixins/mixins.d.ts +14 -0
  43. package/lib/factoryMixins/mixins.js +20 -0
  44. package/lib/factoryMixins/mixins.js.map +1 -0
  45. package/lib/grammar/builtIn.d.ts +59 -59
  46. package/lib/grammar/builtIn.js +50 -57
  47. package/lib/grammar/builtIn.js.map +1 -1
  48. package/lib/grammar/dataSetClause.d.ts +22 -9
  49. package/lib/grammar/dataSetClause.js +57 -14
  50. package/lib/grammar/dataSetClause.js.map +1 -1
  51. package/lib/grammar/expression.d.ts +12 -16
  52. package/lib/grammar/expression.js +224 -296
  53. package/lib/grammar/expression.js.map +1 -1
  54. package/lib/grammar/general.d.ts +8 -8
  55. package/lib/grammar/general.js +59 -94
  56. package/lib/grammar/general.js.map +1 -1
  57. package/lib/grammar/literals.d.ts +16 -13
  58. package/lib/grammar/literals.js +161 -144
  59. package/lib/grammar/literals.js.map +1 -1
  60. package/lib/grammar/propertyPaths.d.ts +16 -12
  61. package/lib/grammar/propertyPaths.js +100 -129
  62. package/lib/grammar/propertyPaths.js.map +1 -1
  63. package/lib/grammar/queryUnit/queryUnit.d.ts +13 -17
  64. package/lib/grammar/queryUnit/queryUnit.js +195 -329
  65. package/lib/grammar/queryUnit/queryUnit.js.map +1 -1
  66. package/lib/grammar/solutionModifier.d.ts +12 -11
  67. package/lib/grammar/solutionModifier.js +125 -109
  68. package/lib/grammar/solutionModifier.js.map +1 -1
  69. package/lib/grammar/tripleBlock.d.ts +24 -33
  70. package/lib/grammar/tripleBlock.js +172 -126
  71. package/lib/grammar/tripleBlock.js.map +1 -1
  72. package/lib/grammar/updateUnit/updateUnit.d.ts +28 -33
  73. package/lib/grammar/updateUnit/updateUnit.js +282 -367
  74. package/lib/grammar/updateUnit/updateUnit.js.map +1 -1
  75. package/lib/grammar/whereClause.d.ts +20 -19
  76. package/lib/grammar/whereClause.js +232 -245
  77. package/lib/grammar/whereClause.js.map +1 -1
  78. package/lib/grammar-helpers/utils.d.ts +0 -4
  79. package/lib/grammar-helpers/utils.js +0 -37
  80. package/lib/grammar-helpers/utils.js.map +1 -1
  81. package/lib/index.cjs +3061 -2438
  82. package/lib/index.d.ts +4 -2
  83. package/lib/index.js +4 -2
  84. package/lib/index.js.map +1 -1
  85. package/lib/lexer/lexer.d.ts +4 -3
  86. package/lib/lexer/lexer.js +11 -7
  87. package/lib/lexer/lexer.js.map +1 -1
  88. package/lib/lexer/terminals.d.ts +0 -34
  89. package/lib/lexer/terminals.js +35 -37
  90. package/lib/lexer/terminals.js.map +1 -1
  91. package/lib/utils.d.ts +0 -3
  92. package/lib/utils.js +0 -6
  93. package/lib/utils.js.map +1 -1
  94. package/lib/validation/validators.d.ts +14 -0
  95. package/lib/validation/validators.js +235 -0
  96. package/lib/validation/validators.js.map +1 -0
  97. package/package.json +6 -8
  98. package/lib/Wildcard.d.ts +0 -9
  99. package/lib/Wildcard.js +0 -19
  100. package/lib/Wildcard.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import type { CoreFactory, SubTyped, SourceLocation } from '@traqula/core';
2
+ import type { ContextDefinitionBase, ContextDefinitionPrefix, TermIriFull } from '../RoundTripTypes';
3
+ import type { Constructor } from './mixins';
4
+ type NodeType = 'contextDef';
5
+ export declare function ContextFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase): {
6
+ new (...args: any[]): {
7
+ contextDefinitionPrefix(loc: SourceLocation, key: string, value: TermIriFull): ContextDefinitionPrefix;
8
+ isContextDefinitionPrefix(contextDef: object): contextDef is SubTyped<NodeType, "prefix">;
9
+ contextDefinitionBase(loc: SourceLocation, value: TermIriFull): ContextDefinitionBase;
10
+ isContextDefinitionBase(contextDef: object): contextDef is SubTyped<NodeType, "base">;
11
+ wrap<T>(val: T, loc: SourceLocation): import("@traqula/core").Wrap<T>;
12
+ isLocalized(obj: unknown): obj is import("@traqula/core").Localized;
13
+ sourceLocation(...elements: (undefined | import("chevrotain").IToken | import("@traqula/core").Localized)[]): SourceLocation;
14
+ sourceLocationNoMaterialize(): import("@traqula/core").SourceLocationNoMaterialize;
15
+ dematerialized<T extends import("@traqula/core").Node>(arg: T): T & {
16
+ loc: import("@traqula/core").SourceLocationNoMaterialize;
17
+ };
18
+ safeObjectTransform(value: unknown, mapper: (some: object) => any): any;
19
+ forcedAutoGenTree<T extends object>(obj: T): T;
20
+ forceMaterialized<T extends import("@traqula/core").Node>(arg: T): T;
21
+ isSourceLocation(loc: object): loc is SourceLocation;
22
+ sourceLocationSource(start: number, end: number): import("@traqula/core").SourceLocationSource;
23
+ gen(): import("@traqula/core").SourceLocationNodeAutoGenerate;
24
+ isSourceLocationSource(loc: object): loc is import("@traqula/core").SourceLocationSource;
25
+ isSourceLocationStringReplace(loc: object): loc is import("@traqula/core").SourceLocationStringReplace;
26
+ sourceLocationNodeReplaceUnsafe(loc: SourceLocation): import("@traqula/core").SourceLocationNodeReplace;
27
+ sourceLocationNodeReplace(location: import("@traqula/core").SourceLocationSource): import("@traqula/core").SourceLocationNodeReplace;
28
+ sourceLocationNodeReplace(start: number, end: number): import("@traqula/core").SourceLocationNodeReplace;
29
+ isSourceLocationNodeReplace(loc: object): loc is import("@traqula/core").SourceLocationNodeReplace;
30
+ isSourceLocationNodeAutoGenerate(loc: object): loc is import("@traqula/core").SourceLocationNodeAutoGenerate;
31
+ nodeShouldPrint(node: import("@traqula/core").Localized): boolean;
32
+ printFilter(node: import("@traqula/core").Localized, callback: () => void): void;
33
+ isSourceLocationNoMaterialize(loc: object): loc is import("@traqula/core").SourceLocationNoMaterialize;
34
+ isOfType<Type extends string>(obj: object, type: Type): obj is import("@traqula/core").Typed<Type>;
35
+ isOfSubType<Type extends string, SubType extends string>(obj: object, type: Type, subType: SubType): obj is SubTyped<Type, SubType>;
36
+ };
37
+ } & TBase;
38
+ export {};
@@ -0,0 +1,30 @@
1
+ const nodeType = 'contextDef';
2
+ // eslint-disable-next-line ts/explicit-function-return-type
3
+ export function ContextFactoryMixin(Base) {
4
+ return class ContextFactory extends Base {
5
+ contextDefinitionPrefix(loc, key, value) {
6
+ return {
7
+ type: nodeType,
8
+ subType: 'prefix',
9
+ key,
10
+ value,
11
+ loc,
12
+ };
13
+ }
14
+ isContextDefinitionPrefix(contextDef) {
15
+ return this.isOfSubType(contextDef, nodeType, 'prefix');
16
+ }
17
+ contextDefinitionBase(loc, value) {
18
+ return {
19
+ type: 'contextDef',
20
+ subType: 'base',
21
+ value,
22
+ loc,
23
+ };
24
+ }
25
+ isContextDefinitionBase(contextDef) {
26
+ return this.isOfSubType(contextDef, nodeType, 'base');
27
+ }
28
+ };
29
+ }
30
+ //# sourceMappingURL=ContextFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextFactory.js","sourceRoot":"","sources":["ContextFactory.ts"],"names":[],"mappings":"AASA,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,4DAA4D;AAC5D,MAAM,UAAU,mBAAmB,CAAyC,IAAW;IACrF,OAAO,MAAM,cAAe,SAAQ,IAAI;QAC/B,uBAAuB,CAAC,GAAmB,EAAE,GAAW,EAAE,KAAkB;YACjF,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,QAAQ;gBACjB,GAAG;gBACH,KAAK;gBACL,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,yBAAyB,CAAC,UAAkB;YACjD,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC;QAEM,qBAAqB,CAAC,GAAmB,EAAE,KAAkB;YAClE,OAAO;gBACL,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,MAAM;gBACf,KAAK;gBACL,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,uBAAuB,CAAC,UAAkB;YAC/C,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { CoreFactory, SubTyped, SourceLocation } from '@traqula/core';\nimport type {\n ContextDefinitionBase,\n ContextDefinitionPrefix,\n TermIriFull,\n} from '../RoundTripTypes';\nimport type { Constructor } from './mixins';\n\ntype NodeType = 'contextDef';\nconst nodeType: NodeType = 'contextDef';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function ContextFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase) {\n return class ContextFactory extends Base {\n public contextDefinitionPrefix(loc: SourceLocation, key: string, value: TermIriFull): ContextDefinitionPrefix {\n return {\n type: nodeType,\n subType: 'prefix',\n key,\n value,\n loc,\n };\n }\n\n public isContextDefinitionPrefix(contextDef: object): contextDef is SubTyped<NodeType, 'prefix'> {\n return this.isOfSubType(contextDef, nodeType, 'prefix');\n }\n\n public contextDefinitionBase(loc: SourceLocation, value: TermIriFull): ContextDefinitionBase {\n return {\n type: 'contextDef',\n subType: 'base',\n value,\n loc,\n };\n }\n\n public isContextDefinitionBase(contextDef: object): contextDef is SubTyped<NodeType, 'base'> {\n return this.isOfSubType(contextDef, nodeType, 'base');\n }\n };\n}\n"]}
@@ -0,0 +1,60 @@
1
+ import type { CoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';
2
+ import type { Expression, ExpressionAggregate, ExpressionAggregateDefault, ExpressionAggregateOnWildcard, ExpressionAggregateSeparator, ExpressionFunctionCall, ExpressionOperation, ExpressionPatternOperation, PatternGroup, TermIri, Wildcard } from '../RoundTripTypes';
3
+ import type { Constructor } from './mixins';
4
+ type NodeType = 'expression';
5
+ export declare function ExpressionFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase): {
6
+ new (...args: any[]): {
7
+ isExpressionPure(obj: object): obj is Typed<NodeType>;
8
+ formatOperator(operator: string): string;
9
+ expressionOperation<Args extends Expression[]>(operator: string, args: Args, loc: SourceLocation): ExpressionOperation & {
10
+ args: Args;
11
+ };
12
+ isExpressionOperator(obj: object): obj is SubTyped<NodeType, "operation">;
13
+ expressionFunctionCall<Args extends Expression[]>(functionOp: TermIri, args: Args, distinct: boolean, loc: SourceLocation): ExpressionFunctionCall & {
14
+ args: Args;
15
+ };
16
+ isExpressionFunctionCall(obj: object): obj is SubTyped<NodeType, "functionCall">;
17
+ expressionPatternOperation(operator: string, args: PatternGroup, loc: SourceLocation): ExpressionPatternOperation;
18
+ isExpressionPatternOperation(obj: object): obj is SubTyped<NodeType, "patternOperation">;
19
+ aggregate(aggregation: string, distinct: boolean, arg: Expression, separator: undefined, loc: SourceLocation): ExpressionAggregateDefault;
20
+ aggregate(aggregation: string, distinct: boolean, arg: Wildcard, separator: undefined, loc: SourceLocation): ExpressionAggregateOnWildcard;
21
+ aggregate(aggregation: string, distinct: boolean, arg: Expression, separator: string, loc: SourceLocation): ExpressionAggregateSeparator;
22
+ aggregate(aggregation: string, distinct: boolean, arg: Expression | Wildcard, separator: string | undefined, loc: SourceLocation): ExpressionAggregate;
23
+ isExpressionAggregate(obj: object): obj is SubTyped<NodeType, "aggregate">;
24
+ isExpressionAggregateSeparator(obj: object): obj is SubTyped<NodeType, "aggregate"> & {
25
+ separator: string;
26
+ };
27
+ isExpressionAggregateOnWildcard(obj: object): obj is SubTyped<NodeType, "aggregate"> & {
28
+ expression: [Typed<"wildcard">];
29
+ };
30
+ isExpressionAggregateDefault(obj: object): obj is SubTyped<NodeType, "aggregate"> & {
31
+ expression: [Expression];
32
+ };
33
+ wrap<T>(val: T, loc: SourceLocation): import("@traqula/core").Wrap<T>;
34
+ isLocalized(obj: unknown): obj is import("@traqula/core").Localized;
35
+ sourceLocation(...elements: (undefined | import("chevrotain").IToken | import("@traqula/core").Localized)[]): SourceLocation;
36
+ sourceLocationNoMaterialize(): import("@traqula/core").SourceLocationNoMaterialize;
37
+ dematerialized<T extends import("@traqula/core").Node>(arg: T): T & {
38
+ loc: import("@traqula/core").SourceLocationNoMaterialize;
39
+ };
40
+ safeObjectTransform(value: unknown, mapper: (some: object) => any): any;
41
+ forcedAutoGenTree<T extends object>(obj: T): T;
42
+ forceMaterialized<T extends import("@traqula/core").Node>(arg: T): T;
43
+ isSourceLocation(loc: object): loc is SourceLocation;
44
+ sourceLocationSource(start: number, end: number): import("@traqula/core").SourceLocationSource;
45
+ gen(): import("@traqula/core").SourceLocationNodeAutoGenerate;
46
+ isSourceLocationSource(loc: object): loc is import("@traqula/core").SourceLocationSource;
47
+ isSourceLocationStringReplace(loc: object): loc is import("@traqula/core").SourceLocationStringReplace;
48
+ sourceLocationNodeReplaceUnsafe(loc: SourceLocation): import("@traqula/core").SourceLocationNodeReplace;
49
+ sourceLocationNodeReplace(location: import("@traqula/core").SourceLocationSource): import("@traqula/core").SourceLocationNodeReplace;
50
+ sourceLocationNodeReplace(start: number, end: number): import("@traqula/core").SourceLocationNodeReplace;
51
+ isSourceLocationNodeReplace(loc: object): loc is import("@traqula/core").SourceLocationNodeReplace;
52
+ isSourceLocationNodeAutoGenerate(loc: object): loc is import("@traqula/core").SourceLocationNodeAutoGenerate;
53
+ nodeShouldPrint(node: import("@traqula/core").Localized): boolean;
54
+ printFilter(node: import("@traqula/core").Localized, callback: () => void): void;
55
+ isSourceLocationNoMaterialize(loc: object): loc is import("@traqula/core").SourceLocationNoMaterialize;
56
+ isOfType<Type extends string>(obj: object, type: Type): obj is Typed<Type>;
57
+ isOfSubType<Type extends string, SubType extends string>(obj: object, type: Type, subType: SubType): obj is SubTyped<Type, SubType>;
58
+ };
59
+ } & TBase;
60
+ export {};
@@ -0,0 +1,83 @@
1
+ const nodeType = 'expression';
2
+ // eslint-disable-next-line ts/explicit-function-return-type
3
+ export function ExpressionFactoryMixin(Base) {
4
+ return class ExpressionFactory extends Base {
5
+ isExpressionPure(obj) {
6
+ return this.isOfType(obj, nodeType);
7
+ }
8
+ formatOperator(operator) {
9
+ return operator.toLowerCase().replaceAll(' ', '');
10
+ }
11
+ expressionOperation(operator, args, loc) {
12
+ return {
13
+ type: nodeType,
14
+ subType: 'operation',
15
+ operator: this.formatOperator(operator),
16
+ args,
17
+ loc,
18
+ };
19
+ }
20
+ isExpressionOperator(obj) {
21
+ return this.isOfSubType(obj, nodeType, 'operation');
22
+ }
23
+ expressionFunctionCall(functionOp, args, distinct, loc) {
24
+ return {
25
+ type: 'expression',
26
+ subType: 'functionCall',
27
+ function: functionOp,
28
+ args,
29
+ distinct,
30
+ loc,
31
+ };
32
+ }
33
+ isExpressionFunctionCall(obj) {
34
+ return this.isOfSubType(obj, nodeType, 'functionCall');
35
+ }
36
+ expressionPatternOperation(operator, args, loc) {
37
+ return {
38
+ type: nodeType,
39
+ subType: 'patternOperation',
40
+ operator: this.formatOperator(operator),
41
+ args,
42
+ loc,
43
+ };
44
+ }
45
+ isExpressionPatternOperation(obj) {
46
+ return this.isOfSubType(obj, nodeType, 'patternOperation');
47
+ }
48
+ aggregate(aggregation, distinct, arg, separator, loc) {
49
+ const base = {
50
+ type: 'expression',
51
+ subType: 'aggregate',
52
+ aggregation: this.formatOperator(aggregation),
53
+ distinct,
54
+ loc,
55
+ };
56
+ if (this.isOfType(arg, 'wildcard')) {
57
+ return { ...base, expression: [arg] };
58
+ }
59
+ if (separator === undefined) {
60
+ return { ...base, expression: [arg] };
61
+ }
62
+ return { ...base, expression: [arg], separator };
63
+ }
64
+ isExpressionAggregate(obj) {
65
+ return this.isOfSubType(obj, nodeType, 'aggregate');
66
+ }
67
+ isExpressionAggregateSeparator(obj) {
68
+ return this.isOfSubType(obj, nodeType, 'aggregate') &&
69
+ typeof obj.separator === 'string';
70
+ }
71
+ isExpressionAggregateOnWildcard(obj) {
72
+ const casted = obj;
73
+ return this.isOfSubType(obj, nodeType, 'aggregate') && Array.isArray(casted.expression) &&
74
+ casted.expression.length === 1 && this.isOfType(casted.expression[0], 'wildcard');
75
+ }
76
+ isExpressionAggregateDefault(obj) {
77
+ const casted = obj;
78
+ return this.isOfSubType(obj, nodeType, 'operation') && Array.isArray(casted.expression) &&
79
+ casted.expression.length === 1 && !this.isOfType(casted.expression[0], 'wildcard');
80
+ }
81
+ };
82
+ }
83
+ //# sourceMappingURL=ExpressionFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["ExpressionFactory.ts"],"names":[],"mappings":"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","sourcesContent":["import type { CoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';\nimport type {\n Expression,\n ExpressionAggregate,\n ExpressionAggregateDefault,\n ExpressionAggregateOnWildcard,\n ExpressionAggregateSeparator,\n ExpressionFunctionCall,\n ExpressionOperation,\n ExpressionPatternOperation,\n PatternGroup,\n TermIri,\n Wildcard,\n} from '../RoundTripTypes';\nimport type { Constructor } from './mixins';\n\ntype NodeType = 'expression';\nconst nodeType: NodeType = 'expression';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function ExpressionFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase) {\n return class ExpressionFactory extends Base {\n public isExpressionPure(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public formatOperator(operator: string): string {\n return operator.toLowerCase().replaceAll(' ', '');\n }\n\n public expressionOperation<Args extends Expression[]>(\n operator: string,\n args: Args,\n loc: SourceLocation,\n ): ExpressionOperation & { args: Args } {\n return {\n type: nodeType,\n subType: 'operation',\n operator: this.formatOperator(operator),\n args,\n loc,\n };\n }\n\n public isExpressionOperator(obj: object): obj is SubTyped<NodeType, 'operation'> {\n return this.isOfSubType(obj, nodeType, 'operation');\n }\n\n public expressionFunctionCall<Args extends Expression[]>(\n functionOp: TermIri,\n args: Args,\n distinct: boolean,\n loc: SourceLocation,\n ): ExpressionFunctionCall & { args: Args } {\n return {\n type: 'expression',\n subType: 'functionCall',\n function: functionOp,\n args,\n distinct,\n loc,\n };\n }\n\n public isExpressionFunctionCall(obj: object): obj is SubTyped<NodeType, 'functionCall'> {\n return this.isOfSubType(obj, nodeType, 'functionCall');\n }\n\n public expressionPatternOperation(\n operator: string,\n args: PatternGroup,\n loc: SourceLocation,\n ): ExpressionPatternOperation {\n return {\n type: nodeType,\n subType: 'patternOperation',\n operator: this.formatOperator(operator),\n args,\n loc,\n };\n }\n\n public isExpressionPatternOperation(obj: object): obj is SubTyped<NodeType, 'patternOperation'> {\n return this.isOfSubType(obj, nodeType, 'patternOperation');\n }\n\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression,\n separator: undefined,\n loc: SourceLocation\n ): ExpressionAggregateDefault;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Wildcard,\n separator: undefined,\n loc: SourceLocation\n ): ExpressionAggregateOnWildcard;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression,\n separator: string,\n loc: SourceLocation\n ): ExpressionAggregateSeparator;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression | Wildcard,\n separator: string | undefined,\n loc: SourceLocation,\n ): ExpressionAggregate;\n public aggregate(\n aggregation: string,\n distinct: boolean,\n arg: Expression | Wildcard,\n separator: string | undefined,\n loc: SourceLocation,\n ): ExpressionAggregate {\n const base = <const> {\n type: 'expression',\n subType: 'aggregate',\n aggregation: this.formatOperator(aggregation),\n distinct,\n loc,\n };\n if (this.isOfType(arg, 'wildcard')) {\n return { ...base, expression: [ arg ]} satisfies ExpressionAggregateOnWildcard;\n }\n if (separator === undefined) {\n return { ...base, expression: [ arg ]} satisfies ExpressionAggregateDefault;\n }\n return { ...base, expression: [ arg ], separator } satisfies ExpressionAggregateSeparator;\n }\n\n public isExpressionAggregate(obj: object): obj is SubTyped<NodeType, 'aggregate'> {\n return this.isOfSubType(obj, nodeType, 'aggregate');\n }\n\n public isExpressionAggregateSeparator(obj: object): obj is SubTyped<NodeType, 'aggregate'> & { separator: string } {\n return this.isOfSubType(obj, nodeType, 'aggregate') &&\n typeof (<{ separator?: unknown }> obj).separator === 'string';\n }\n\n public isExpressionAggregateOnWildcard(obj: object):\n obj is SubTyped<NodeType, 'aggregate'> & { expression: [Typed<'wildcard'>]} {\n const casted = <{ expression?: unknown }> obj;\n return this.isOfSubType(obj, nodeType, 'aggregate') && Array.isArray(casted.expression) &&\n casted.expression.length === 1 && this.isOfType(casted.expression[0], 'wildcard');\n }\n\n public isExpressionAggregateDefault(obj: object):\n obj is SubTyped<NodeType, 'aggregate'> & { expression: [Expression]} {\n const casted = <{ expression?: unknown }> obj;\n\n return this.isOfSubType(obj, nodeType, 'operation') && Array.isArray(casted.expression) &&\n casted.expression.length === 1 && !this.isOfType(casted.expression[0], 'wildcard');\n }\n };\n}\n"]}
@@ -0,0 +1,43 @@
1
+ import type { CoreFactory, SubTyped, SourceLocation, Typed } from '@traqula/core';
2
+ import type { GraphRefAll, GraphRefDefault, GraphRefNamed, GraphRefSpecific, TermIri } from '../RoundTripTypes';
3
+ import type { Constructor } from './mixins';
4
+ type NodeType = 'graphRef';
5
+ export declare function GraphRefFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase): {
6
+ new (...args: any[]): {
7
+ isGraphRef(obj: object): obj is Typed<NodeType>;
8
+ graphRefDefault(loc: SourceLocation): GraphRefDefault;
9
+ isGraphRefDefault(graphRef: object): graphRef is SubTyped<NodeType, "default">;
10
+ graphRefNamed(loc: SourceLocation): GraphRefNamed;
11
+ isGraphRefNamed(graphRef: object): graphRef is SubTyped<NodeType, "named">;
12
+ graphRefAll(loc: SourceLocation): GraphRefAll;
13
+ isGraphRefAll(graphRef: object): graphRef is SubTyped<NodeType, "all">;
14
+ graphRefSpecific(graph: TermIri, loc: SourceLocation): GraphRefSpecific;
15
+ isGraphRefSpecific(graphRef: object): graphRef is SubTyped<NodeType, "specific">;
16
+ wrap<T>(val: T, loc: SourceLocation): import("@traqula/core").Wrap<T>;
17
+ isLocalized(obj: unknown): obj is import("@traqula/core").Localized;
18
+ sourceLocation(...elements: (undefined | import("chevrotain").IToken | import("@traqula/core").Localized)[]): SourceLocation;
19
+ sourceLocationNoMaterialize(): import("@traqula/core").SourceLocationNoMaterialize;
20
+ dematerialized<T extends import("@traqula/core").Node>(arg: T): T & {
21
+ loc: import("@traqula/core").SourceLocationNoMaterialize;
22
+ };
23
+ safeObjectTransform(value: unknown, mapper: (some: object) => any): any;
24
+ forcedAutoGenTree<T extends object>(obj: T): T;
25
+ forceMaterialized<T extends import("@traqula/core").Node>(arg: T): T;
26
+ isSourceLocation(loc: object): loc is SourceLocation;
27
+ sourceLocationSource(start: number, end: number): import("@traqula/core").SourceLocationSource;
28
+ gen(): import("@traqula/core").SourceLocationNodeAutoGenerate;
29
+ isSourceLocationSource(loc: object): loc is import("@traqula/core").SourceLocationSource;
30
+ isSourceLocationStringReplace(loc: object): loc is import("@traqula/core").SourceLocationStringReplace;
31
+ sourceLocationNodeReplaceUnsafe(loc: SourceLocation): import("@traqula/core").SourceLocationNodeReplace;
32
+ sourceLocationNodeReplace(location: import("@traqula/core").SourceLocationSource): import("@traqula/core").SourceLocationNodeReplace;
33
+ sourceLocationNodeReplace(start: number, end: number): import("@traqula/core").SourceLocationNodeReplace;
34
+ isSourceLocationNodeReplace(loc: object): loc is import("@traqula/core").SourceLocationNodeReplace;
35
+ isSourceLocationNodeAutoGenerate(loc: object): loc is import("@traqula/core").SourceLocationNodeAutoGenerate;
36
+ nodeShouldPrint(node: import("@traqula/core").Localized): boolean;
37
+ printFilter(node: import("@traqula/core").Localized, callback: () => void): void;
38
+ isSourceLocationNoMaterialize(loc: object): loc is import("@traqula/core").SourceLocationNoMaterialize;
39
+ isOfType<Type extends string>(obj: object, type: Type): obj is Typed<Type>;
40
+ isOfSubType<Type extends string, SubType extends string>(obj: object, type: Type, subType: SubType): obj is SubTyped<Type, SubType>;
41
+ };
42
+ } & TBase;
43
+ export {};
@@ -0,0 +1,51 @@
1
+ const nodeType = 'graphRef';
2
+ // eslint-disable-next-line ts/explicit-function-return-type
3
+ export function GraphRefFactoryMixin(Base) {
4
+ return class GraphRefFactory extends Base {
5
+ isGraphRef(obj) {
6
+ return this.isOfType(obj, nodeType);
7
+ }
8
+ graphRefDefault(loc) {
9
+ return {
10
+ type: nodeType,
11
+ subType: 'default',
12
+ loc,
13
+ };
14
+ }
15
+ isGraphRefDefault(graphRef) {
16
+ return this.isOfSubType(graphRef, nodeType, 'default');
17
+ }
18
+ graphRefNamed(loc) {
19
+ return {
20
+ type: nodeType,
21
+ subType: 'named',
22
+ loc,
23
+ };
24
+ }
25
+ isGraphRefNamed(graphRef) {
26
+ return this.isOfSubType(graphRef, nodeType, 'named');
27
+ }
28
+ graphRefAll(loc) {
29
+ return {
30
+ type: nodeType,
31
+ subType: 'all',
32
+ loc,
33
+ };
34
+ }
35
+ isGraphRefAll(graphRef) {
36
+ return this.isOfSubType(graphRef, nodeType, 'all');
37
+ }
38
+ graphRefSpecific(graph, loc) {
39
+ return {
40
+ type: nodeType,
41
+ subType: 'specific',
42
+ graph,
43
+ loc,
44
+ };
45
+ }
46
+ isGraphRefSpecific(graphRef) {
47
+ return this.isOfSubType(graphRef, nodeType, 'specific');
48
+ }
49
+ };
50
+ }
51
+ //# sourceMappingURL=GraphRefFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphRefFactory.js","sourceRoot":"","sources":["GraphRefFactory.ts"],"names":[],"mappings":"AAWA,MAAM,QAAQ,GAAa,UAAU,CAAC;AAEtC,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB,CAAyC,IAAW;IACtF,OAAO,MAAM,eAAgB,SAAQ,IAAI;QAChC,UAAU,CAAC,GAAW;YAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QAEM,eAAe,CAAC,GAAmB;YACxC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,SAAS;gBAClB,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,iBAAiB,CAAC,QAAgB;YACvC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACzD,CAAC;QAEM,aAAa,CAAC,GAAmB;YACtC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,OAAO;gBAChB,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,eAAe,CAAC,QAAgB;YACrC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QAEM,WAAW,CAAC,GAAmB;YACpC,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,KAAK;gBACd,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,aAAa,CAAC,QAAgB;YACnC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;QAEM,gBAAgB,CAAC,KAAc,EAAE,GAAmB;YACzD,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,UAAU;gBACnB,KAAK;gBACL,GAAG;aACJ,CAAC;QACJ,CAAC;QAEM,kBAAkB,CAAC,QAAgB;YACxC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { CoreFactory, SubTyped, SourceLocation, Typed } from '@traqula/core';\nimport type {\n GraphRefAll,\n GraphRefDefault,\n GraphRefNamed,\n GraphRefSpecific,\n TermIri,\n} from '../RoundTripTypes';\nimport type { Constructor } from './mixins';\n\ntype NodeType = 'graphRef';\nconst nodeType: NodeType = 'graphRef';\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function GraphRefFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase) {\n return class GraphRefFactory extends Base {\n public isGraphRef(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public graphRefDefault(loc: SourceLocation): GraphRefDefault {\n return {\n type: nodeType,\n subType: 'default',\n loc,\n };\n }\n\n public isGraphRefDefault(graphRef: object): graphRef is SubTyped<NodeType, 'default'> {\n return this.isOfSubType(graphRef, nodeType, 'default');\n }\n\n public graphRefNamed(loc: SourceLocation): GraphRefNamed {\n return {\n type: nodeType,\n subType: 'named',\n loc,\n };\n }\n\n public isGraphRefNamed(graphRef: object): graphRef is SubTyped<NodeType, 'named'> {\n return this.isOfSubType(graphRef, nodeType, 'named');\n }\n\n public graphRefAll(loc: SourceLocation): GraphRefAll {\n return {\n type: nodeType,\n subType: 'all',\n loc,\n };\n }\n\n public isGraphRefAll(graphRef: object): graphRef is SubTyped<NodeType, 'all'> {\n return this.isOfSubType(graphRef, nodeType, 'all');\n }\n\n public graphRefSpecific(graph: TermIri, loc: SourceLocation): GraphRefSpecific {\n return {\n type: nodeType,\n subType: 'specific',\n graph,\n loc,\n };\n }\n\n public isGraphRefSpecific(graphRef: object): graphRef is SubTyped<NodeType, 'specific'> {\n return this.isOfSubType(graphRef, nodeType, 'specific');\n }\n };\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import type { CoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';
2
+ import type { Path, PathAlternativeLimited, PathModified, PathNegated, PathNegatedElt, PropertyPathChain, TermIri } from '../RoundTripTypes';
3
+ import type { Constructor } from './mixins';
4
+ type NodeType = 'path';
5
+ type RawNegatedElt = SubTyped<NodeType, '^'> & {
6
+ items: [SubTyped<'term', 'namedNode'>];
7
+ };
8
+ export declare function PathFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase): {
9
+ new (...args: any[]): {
10
+ isPathPure(obj: object): obj is Typed<NodeType>;
11
+ path(subType: "|", items: (TermIri | PathNegatedElt)[], loc: SourceLocation): PathAlternativeLimited;
12
+ path(subType: "!", items: [TermIri | PathNegatedElt | PathAlternativeLimited], loc: SourceLocation): PathNegated;
13
+ path(subType: "^", items: [TermIri], loc: SourceLocation): PathNegatedElt;
14
+ path(subType: PathModified["subType"], item: [Path], loc: SourceLocation): PathModified;
15
+ path(subType: "|" | "/", items: Path[], loc: SourceLocation): PropertyPathChain;
16
+ isPathOfType<T extends U[], U extends string>(obj: object, subTypes: T): obj is SubTyped<NodeType, U>;
17
+ isPathChain(obj: object): obj is SubTyped<NodeType, "|" | "/">;
18
+ isPathModified(obj: object): obj is SubTyped<NodeType, "?" | "*" | "+" | "^">;
19
+ isPathNegatedElt(obj: object): obj is RawNegatedElt;
20
+ isPathNegated(obj: object): obj is SubTyped<NodeType, "!">;
21
+ isPathAlternativeLimited(obj: object): obj is SubTyped<NodeType, "|"> & {
22
+ items: (SubTyped<"term", "namedNode"> | RawNegatedElt)[];
23
+ };
24
+ wrap<T>(val: T, loc: SourceLocation): import("@traqula/core").Wrap<T>;
25
+ isLocalized(obj: unknown): obj is import("@traqula/core").Localized;
26
+ sourceLocation(...elements: (undefined | import("chevrotain").IToken | import("@traqula/core").Localized)[]): SourceLocation;
27
+ sourceLocationNoMaterialize(): import("@traqula/core").SourceLocationNoMaterialize;
28
+ dematerialized<T extends import("@traqula/core").Node>(arg: T): T & {
29
+ loc: import("@traqula/core").SourceLocationNoMaterialize;
30
+ };
31
+ safeObjectTransform(value: unknown, mapper: (some: object) => any): any;
32
+ forcedAutoGenTree<T extends object>(obj: T): T;
33
+ forceMaterialized<T extends import("@traqula/core").Node>(arg: T): T;
34
+ isSourceLocation(loc: object): loc is SourceLocation;
35
+ sourceLocationSource(start: number, end: number): import("@traqula/core").SourceLocationSource;
36
+ gen(): import("@traqula/core").SourceLocationNodeAutoGenerate;
37
+ isSourceLocationSource(loc: object): loc is import("@traqula/core").SourceLocationSource;
38
+ isSourceLocationStringReplace(loc: object): loc is import("@traqula/core").SourceLocationStringReplace;
39
+ sourceLocationNodeReplaceUnsafe(loc: SourceLocation): import("@traqula/core").SourceLocationNodeReplace;
40
+ sourceLocationNodeReplace(location: import("@traqula/core").SourceLocationSource): import("@traqula/core").SourceLocationNodeReplace;
41
+ sourceLocationNodeReplace(start: number, end: number): import("@traqula/core").SourceLocationNodeReplace;
42
+ isSourceLocationNodeReplace(loc: object): loc is import("@traqula/core").SourceLocationNodeReplace;
43
+ isSourceLocationNodeAutoGenerate(loc: object): loc is import("@traqula/core").SourceLocationNodeAutoGenerate;
44
+ nodeShouldPrint(node: import("@traqula/core").Localized): boolean;
45
+ printFilter(node: import("@traqula/core").Localized, callback: () => void): void;
46
+ isSourceLocationNoMaterialize(loc: object): loc is import("@traqula/core").SourceLocationNoMaterialize;
47
+ isOfType<Type extends string>(obj: object, type: Type): obj is Typed<Type>;
48
+ isOfSubType<Type extends string, SubType extends string>(obj: object, type: Type, subType: SubType): obj is SubTyped<Type, SubType>;
49
+ };
50
+ } & TBase;
51
+ export {};
@@ -0,0 +1,68 @@
1
+ const nodeType = 'path';
2
+ // eslint-disable-next-line ts/explicit-function-return-type
3
+ export function PathFactoryMixin(Base) {
4
+ return class PathFactory extends Base {
5
+ isPathPure(obj) {
6
+ return this.isOfType(obj, nodeType);
7
+ }
8
+ path(subType, items, loc) {
9
+ const base = {
10
+ type: nodeType,
11
+ loc,
12
+ items,
13
+ };
14
+ if (subType === '|' || subType === '/') {
15
+ return {
16
+ ...base,
17
+ subType,
18
+ };
19
+ }
20
+ if ((subType === '?' || subType === '*' || subType === '+' || subType === '^') && items.length === 1) {
21
+ return {
22
+ ...base,
23
+ subType,
24
+ items: items,
25
+ };
26
+ }
27
+ if (subType === '^' && items.length === 1 && !this.isPathPure(items[0])) {
28
+ return {
29
+ ...base,
30
+ subType,
31
+ items: items,
32
+ };
33
+ }
34
+ if (subType === '!' && items.length === 1 && (this.isPathAlternativeLimited(items[0]) || !this.isPathPure(items[0]) || this.isPathNegatedElt(items[0]))) {
35
+ return {
36
+ ...base,
37
+ subType,
38
+ items: items,
39
+ };
40
+ }
41
+ throw new Error('Invalid path type');
42
+ }
43
+ isPathOfType(obj, subTypes) {
44
+ return this.isOfType(obj, nodeType) && subTypes.includes(obj.subType);
45
+ }
46
+ isPathChain(obj) {
47
+ return this.isOfSubType(obj, nodeType, '/') || this.isOfSubType(obj, nodeType, '|');
48
+ }
49
+ isPathModified(obj) {
50
+ return this.isOfSubType(obj, nodeType, '?') || this.isOfSubType(obj, nodeType, '*') ||
51
+ this.isOfSubType(obj, nodeType, '+') || this.isOfSubType(obj, nodeType, '^');
52
+ }
53
+ isPathNegatedElt(obj) {
54
+ const casted = obj;
55
+ return this.isOfSubType(obj, nodeType, '^') && Array.isArray(casted.items) && casted.items.length === 1 &&
56
+ typeof casted.items[0] === 'object' && (casted.items[0] ?? false) && !this.isPathPure(casted.items[0]);
57
+ }
58
+ isPathNegated(obj) {
59
+ return this.isOfSubType(obj, nodeType, '!');
60
+ }
61
+ isPathAlternativeLimited(obj) {
62
+ const casted = obj;
63
+ return this.isOfSubType(obj, nodeType, '|') && Array.isArray(casted.items) &&
64
+ casted.items.every(item => !this.isPathPure(item) || this.isPathNegatedElt(item));
65
+ }
66
+ };
67
+ }
68
+ //# sourceMappingURL=PathFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathFactory.js","sourceRoot":"","sources":["PathFactory.ts"],"names":[],"mappings":"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","sourcesContent":["import type { CoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';\nimport type {\n Path,\n PathAlternativeLimited,\n PathModified,\n PathNegated,\n PathNegatedElt,\n PropertyPathChain,\n TermIri,\n} from '../RoundTripTypes';\nimport type { Constructor } from './mixins';\n\ntype NodeType = 'path';\nconst nodeType: NodeType = 'path';\n\ntype RawNegatedElt = SubTyped<NodeType, '^'> & { items: [SubTyped<'term', 'namedNode'>]};\n\n// eslint-disable-next-line ts/explicit-function-return-type\nexport function PathFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase) {\n return class PathFactory extends Base {\n public isPathPure(obj: object): obj is Typed<NodeType> {\n return this.isOfType(obj, nodeType);\n }\n\n public path(\n subType: '|',\n items: (TermIri | PathNegatedElt)[],\n loc: SourceLocation\n ): PathAlternativeLimited;\n public path(\n subType: '!',\n items: [TermIri | PathNegatedElt | PathAlternativeLimited],\n loc: SourceLocation\n ): PathNegated;\n public path(subType: '^', items: [TermIri], loc: SourceLocation): PathNegatedElt;\n public path(subType: PathModified['subType'], item: [Path], loc: SourceLocation): PathModified;\n public path(subType: '|' | '/', items: Path[], loc: SourceLocation):\n PropertyPathChain;\n public path(\n subType: (PropertyPathChain | PathModified | PathNegated)['subType'],\n items: Path[],\n loc: SourceLocation,\n ): Path {\n const base = <const>{\n type: nodeType,\n loc,\n items,\n };\n if (subType === '|' || subType === '/') {\n return {\n ...base,\n subType,\n } satisfies PropertyPathChain;\n }\n if ((subType === '?' || subType === '*' || subType === '+' || subType === '^') && items.length === 1) {\n return {\n ...base,\n subType,\n items: <[Path]>items,\n } satisfies PathModified;\n }\n if (subType === '^' && items.length === 1 && !this.isPathPure(items[0])) {\n return {\n ...base,\n subType,\n items: <[TermIri]>items,\n } satisfies PathNegatedElt;\n }\n if (subType === '!' && items.length === 1 && (\n this.isPathAlternativeLimited(items[0]) || !this.isPathPure(items[0]) || this.isPathNegatedElt(items[0]))) {\n return {\n ...base,\n subType,\n items: <[TermIri | PathNegatedElt | PathAlternativeLimited]>items,\n } satisfies PathNegated;\n }\n throw new Error('Invalid path type');\n }\n\n public isPathOfType<T extends U[], U extends string>(obj: object, subTypes: T): obj is SubTyped<NodeType, U> {\n return this.isOfType(obj, nodeType) && subTypes.includes(<any>(<{ subType?: unknown }>obj).subType);\n }\n\n public isPathChain(obj: object): obj is SubTyped<NodeType, '|' | '/'> {\n return this.isOfSubType(obj, nodeType, '/') || this.isOfSubType(obj, nodeType, '|');\n }\n\n public isPathModified(obj: object): obj is SubTyped<NodeType, '?' | '*' | '+' | '^'> {\n return this.isOfSubType(obj, nodeType, '?') || this.isOfSubType(obj, nodeType, '*') ||\n this.isOfSubType(obj, nodeType, '+') || this.isOfSubType(obj, nodeType, '^');\n }\n\n public isPathNegatedElt(obj: object): obj is RawNegatedElt {\n const casted: { items?: unknown } = obj;\n return this.isOfSubType(obj, nodeType, '^') && Array.isArray(casted.items) && casted.items.length === 1 &&\n typeof casted.items[0] === 'object' && (casted.items[0] ?? false) && !this.isPathPure(casted.items[0]);\n }\n\n public isPathNegated(obj: object): obj is SubTyped<NodeType, '!'> {\n return this.isOfSubType(obj, nodeType, '!');\n }\n\n public isPathAlternativeLimited(obj: object):\n obj is SubTyped<NodeType, '|'> & { items: (SubTyped<'term', 'namedNode'> | RawNegatedElt)[] } {\n const casted: { items?: unknown } = obj;\n return this.isOfSubType(obj, nodeType, '|') && Array.isArray(casted.items) &&\n casted.items.every(item => !this.isPathPure(item) || this.isPathNegatedElt(item));\n }\n };\n}\n"]}
@@ -0,0 +1,55 @@
1
+ import type { CoreFactory, SourceLocation, Typed, SubTyped } from '@traqula/core';
2
+ import type { BasicGraphPattern, Expression, Pattern, PatternBgp, PatternBind, PatternFilter, PatternGraph, PatternGroup, PatternMinus, PatternOptional, PatternService, PatternUnion, PatternValues, TermIri, TermVariable, ValuePatternRow } from '../RoundTripTypes';
3
+ import type { Constructor } from './mixins';
4
+ type NodeType = 'pattern';
5
+ export declare function PatternFactoryMixin<TBase extends Constructor<CoreFactory>>(Base: TBase): {
6
+ new (...args: any[]): {
7
+ isPattern(obj: object): obj is Typed<NodeType>;
8
+ patternBgp(triples: BasicGraphPattern, loc: SourceLocation): PatternBgp;
9
+ isPatternBgp(obj: object): obj is SubTyped<NodeType, "bgp">;
10
+ patternGroup(patterns: Pattern[], loc: SourceLocation): PatternGroup;
11
+ isPatternGroup(obj: object): obj is SubTyped<NodeType, "group">;
12
+ patternGraph(name: TermIri | TermVariable, patterns: Pattern[], loc: SourceLocation): PatternGraph;
13
+ isPatternGraph(obj: object): obj is SubTyped<NodeType, "graph">;
14
+ patternOptional(patterns: Pattern[], loc: SourceLocation): PatternOptional;
15
+ isPatternOptional(obj: object): obj is SubTyped<NodeType, "optional">;
16
+ patternValues(values: ValuePatternRow[], loc: SourceLocation): PatternValues;
17
+ isPatternValues(obj: object): obj is SubTyped<NodeType, "values">;
18
+ patternFilter(expression: Expression, loc: SourceLocation): PatternFilter;
19
+ isPatternFilter(obj: object): obj is SubTyped<NodeType, "filter">;
20
+ patternBind(expression: Expression, variable: TermVariable, loc: SourceLocation): PatternBind;
21
+ isPatternBind(obj: object): obj is SubTyped<NodeType, "bind">;
22
+ patternUnion(patterns: PatternGroup[], loc: SourceLocation): PatternUnion;
23
+ isPatternUnion(obj: object): obj is SubTyped<NodeType, "union">;
24
+ patternMinus(patterns: Pattern[], loc: SourceLocation): PatternMinus;
25
+ isPatternMinus(obj: object): obj is SubTyped<NodeType, "minus">;
26
+ patternService(name: TermIri | TermVariable, patterns: Pattern[], silent: boolean, loc: SourceLocation): PatternService;
27
+ isPatternService(obj: object): obj is SubTyped<NodeType, "service">;
28
+ wrap<T>(val: T, loc: SourceLocation): import("@traqula/core").Wrap<T>;
29
+ isLocalized(obj: unknown): obj is import("@traqula/core").Localized;
30
+ sourceLocation(...elements: (undefined | import("chevrotain").IToken | import("@traqula/core").Localized)[]): SourceLocation;
31
+ sourceLocationNoMaterialize(): import("@traqula/core").SourceLocationNoMaterialize;
32
+ dematerialized<T extends import("@traqula/core").Node>(arg: T): T & {
33
+ loc: import("@traqula/core").SourceLocationNoMaterialize;
34
+ };
35
+ safeObjectTransform(value: unknown, mapper: (some: object) => any): any;
36
+ forcedAutoGenTree<T extends object>(obj: T): T;
37
+ forceMaterialized<T extends import("@traqula/core").Node>(arg: T): T;
38
+ isSourceLocation(loc: object): loc is SourceLocation;
39
+ sourceLocationSource(start: number, end: number): import("@traqula/core").SourceLocationSource;
40
+ gen(): import("@traqula/core").SourceLocationNodeAutoGenerate;
41
+ isSourceLocationSource(loc: object): loc is import("@traqula/core").SourceLocationSource;
42
+ isSourceLocationStringReplace(loc: object): loc is import("@traqula/core").SourceLocationStringReplace;
43
+ sourceLocationNodeReplaceUnsafe(loc: SourceLocation): import("@traqula/core").SourceLocationNodeReplace;
44
+ sourceLocationNodeReplace(location: import("@traqula/core").SourceLocationSource): import("@traqula/core").SourceLocationNodeReplace;
45
+ sourceLocationNodeReplace(start: number, end: number): import("@traqula/core").SourceLocationNodeReplace;
46
+ isSourceLocationNodeReplace(loc: object): loc is import("@traqula/core").SourceLocationNodeReplace;
47
+ isSourceLocationNodeAutoGenerate(loc: object): loc is import("@traqula/core").SourceLocationNodeAutoGenerate;
48
+ nodeShouldPrint(node: import("@traqula/core").Localized): boolean;
49
+ printFilter(node: import("@traqula/core").Localized, callback: () => void): void;
50
+ isSourceLocationNoMaterialize(loc: object): loc is import("@traqula/core").SourceLocationNoMaterialize;
51
+ isOfType<Type extends string>(obj: object, type: Type): obj is Typed<Type>;
52
+ isOfSubType<Type extends string, SubType extends string>(obj: object, type: Type, subType: SubType): obj is SubTyped<Type, SubType>;
53
+ };
54
+ } & TBase;
55
+ export {};