@traqula/rules-sparql-1-1 1.0.7 → 1.1.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.
@@ -22,6 +22,11 @@ export function sparqlCodepointEscape(input) {
22
22
  }
23
23
  return sanitizedInput;
24
24
  }
25
+ /**
26
+ * Common IRI constants used across SPARQL parsing and generation.
27
+ * Includes XSD datatypes (BOOLEAN, INTEGER, DECIMAL, DOUBLE, STRING)
28
+ * and RDF vocabulary (FIRST, REST, NIL, TYPE).
29
+ */
25
30
  export var CommonIRIs;
26
31
  (function (CommonIRIs) {
27
32
  // XSD
@@ -36,6 +41,18 @@ export var CommonIRIs;
36
41
  CommonIRIs["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
37
42
  CommonIRIs["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
38
43
  })(CommonIRIs || (CommonIRIs = {}));
44
+ /**
45
+ * A {@link TransformerSubTyped} specialized for the SPARQL 1.1 AST node types.
46
+ * Provides a type-safe visitor/transformer that dispatches based on node `type` and `subType` fields.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const transformer = new AstTransformer();
51
+ * transformer.transformNodeSpecific<'safe', typeof ast>(ast, {
52
+ * query: { select: (node) => { ... } },
53
+ * });
54
+ * ```
55
+ */
39
56
  export class AstTransformer extends TransformerSubTyped {
40
57
  }
41
58
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,2CAA2C,EAC3C,CAAC,CAAC,EAAE,QAAgB,EAAE,QAAgB,EAAE,EAAE;QACxC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC/C,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC/C,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,mBAAmB,GAAG,QAAQ,GAAG,OAAO,CAAC;QAC/C,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC,CAAC;IAC5G,CAAC,CACF,CAAC;IACF,2CAA2C;IAC3C,IAAI,wCAAwC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAN,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,MAAM;IACN,kEAAoD,CAAA;IACpD,kEAAoD,CAAA;IACpD,kEAAoD,CAAA;IACpD,gEAAkD,CAAA;IAClD,gEAAkD,CAAA;IAClD,MAAM;IACN,wEAA0D,CAAA;IAC1D,sEAAwD,CAAA;IACxD,oEAAsD,CAAA;IACtD,sEAAwD,CAAA;AAC1D,CAAC,EAZW,UAAU,KAAV,UAAU,QAYrB;AAED,MAAM,OAAO,cAAe,SAAQ,mBAAkC;CAAG","sourcesContent":["import { TransformerSubTyped } from '@traqula/core';\nimport type { Sparql11Nodes } from './Sparql11types.js';\n\n/**\n * Transform input in accordance to [19.2](https://www.w3.org/TR/sparql11-query/#codepointEscape)\n * and validate unicode codepoints.\n */\nexport function sparqlCodepointEscape(input: string): string {\n const sanitizedInput = input.replaceAll(\n /\\\\u([0-9a-fA-F]{4})|\\\\U([0-9a-fA-F]{8})/gu,\n (_, unicode4: string, unicode8: string) => {\n if (unicode4) {\n const charCode = Number.parseInt(unicode4, 16);\n return String.fromCodePoint(charCode);\n }\n const charCode = Number.parseInt(unicode8, 16);\n if (charCode < 0xFFFF) {\n return String.fromCodePoint(charCode);\n }\n const substractedCharCode = charCode - 0x10000;\n return String.fromCodePoint(0xD800 + (substractedCharCode >> 10), 0xDC00 + (substractedCharCode & 0x3FF));\n },\n );\n // Test for invalid unicode surrogate pairs\n if (/[\\uD800-\\uDBFF](?:[^\\uDC00-\\uDFFF]|$)/u.test(sanitizedInput)) {\n throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);\n }\n return sanitizedInput;\n}\n\nexport enum CommonIRIs {\n // XSD\n BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean',\n INTEGER = 'http://www.w3.org/2001/XMLSchema#integer',\n DECIMAL = 'http://www.w3.org/2001/XMLSchema#decimal',\n DOUBLE = 'http://www.w3.org/2001/XMLSchema#double',\n STRING = 'http://www.w3.org/2001/XMLSchema#string',\n // RDF\n FIRST = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first',\n REST = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',\n NIL = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil',\n TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',\n}\n\nexport class AstTransformer extends TransformerSubTyped<Sparql11Nodes> {}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,2CAA2C,EAC3C,CAAC,CAAC,EAA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odes } from './Sparql11types.js';\n\n/**\n * Transform input in accordance to [19.2](https://www.w3.org/TR/sparql11-query/#codepointEscape)\n * and validate unicode codepoints.\n */\nexport function sparqlCodepointEscape(input: string): string {\n const sanitizedInput = input.replaceAll(\n /\\\\u([0-9a-fA-F]{4})|\\\\U([0-9a-fA-F]{8})/gu,\n (_, unicode4: string, unicode8: string) => {\n if (unicode4) {\n const charCode = Number.parseInt(unicode4, 16);\n return String.fromCodePoint(charCode);\n }\n const charCode = Number.parseInt(unicode8, 16);\n if (charCode < 0xFFFF) {\n return String.fromCodePoint(charCode);\n }\n const substractedCharCode = charCode - 0x10000;\n return String.fromCodePoint(0xD800 + (substractedCharCode >> 10), 0xDC00 + (substractedCharCode & 0x3FF));\n },\n );\n // Test for invalid unicode surrogate pairs\n if (/[\\uD800-\\uDBFF](?:[^\\uDC00-\\uDFFF]|$)/u.test(sanitizedInput)) {\n throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);\n }\n return sanitizedInput;\n}\n\n/**\n * Common IRI constants used across SPARQL parsing and generation.\n * Includes XSD datatypes (BOOLEAN, INTEGER, DECIMAL, DOUBLE, STRING)\n * and RDF vocabulary (FIRST, REST, NIL, TYPE).\n */\nexport enum CommonIRIs {\n // XSD\n BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean',\n INTEGER = 'http://www.w3.org/2001/XMLSchema#integer',\n DECIMAL = 'http://www.w3.org/2001/XMLSchema#decimal',\n DOUBLE = 'http://www.w3.org/2001/XMLSchema#double',\n STRING = 'http://www.w3.org/2001/XMLSchema#string',\n // RDF\n FIRST = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first',\n REST = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',\n NIL = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil',\n TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',\n}\n\n/**\n * A {@link TransformerSubTyped} specialized for the SPARQL 1.1 AST node types.\n * Provides a type-safe visitor/transformer that dispatches based on node `type` and `subType` fields.\n *\n * @example\n * ```typescript\n * const transformer = new AstTransformer();\n * transformer.transformNodeSpecific<'safe', typeof ast>(ast, {\n * query: { select: (node) => { ... } },\n * });\n * ```\n */\nexport class AstTransformer extends TransformerSubTyped<Sparql11Nodes> {}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@traqula/rules-sparql-1-1",
3
3
  "type": "module",
4
- "version": "1.0.7",
4
+ "version": "1.1.1",
5
5
  "description": "TRAQULA Lexer and Grammar Rules for sparql 1.1",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -41,8 +41,8 @@
41
41
  "build:cjs": "node \"../../node_modules/typescript/bin/tsc\" -b tsconfig.cjs.json"
42
42
  },
43
43
  "dependencies": {
44
- "@traqula/chevrotain": "^1.0.7",
45
- "@traqula/core": "^1.0.7"
44
+ "@traqula/chevrotain": "^1.1.0",
45
+ "@traqula/core": "^1.1.1"
46
46
  },
47
- "gitHead": "e0f102abaf3cad07d6d8ef7c2ad00ea8448c6e9c"
47
+ "gitHead": "51799d80873e4f0fb0ca6ab778861f526d3a66d1"
48
48
  }