@traqula/generator-sparql-1-1 0.0.21 → 0.0.23

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.test.js","sourceRoot":"","sources":["../../../test/integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,CAAC,GAAG,IAAI,UAAU,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE,CAAC;IAEzC,EAAE,CAAE,gCAAgC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACnD,MAAM,KAAK,GAAG,6BAA6B,CAAC;QAC5C,MAAM,GAAG,GAAe,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAE,6BAA6B,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QAChD,MAAM,KAAK,GAAG,+BAA+B,CAAC;QAC9C,MAAM,GAAG,GAAG,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1';\nimport type * as T11 from '@traqula/rules-sparql-1-1';\nimport { AstFactory, AstTransformer } from '@traqula/rules-sparql-1-1';\nimport { describe, it } from 'vitest';\nimport { Generator } from '../lib/index.js';\n\ndescribe('a SPARQL 1.1 generator', () => {\n const generator = new Generator();\n const parser = new Parser();\n const F = new AstFactory();\n const transformer = new AstTransformer();\n\n it ('generates simple round tripped', ({ expect }) => {\n const query = 'SELECT * WHERE { ?s ?p ?o }';\n const ast = <T11.Query> parser.parse(query);\n const result = generator.generate(ast, { origSource: query });\n expect(result).toBe(query);\n });\n\n it ('self generates on no pretty', ({ expect }) => {\n const query = 'SELECT * WHERE { ?s ?p ?o . }';\n const ast = parser.parse(query);\n const result = generator.generate(F.forcedAutoGenTree(ast), { [traqulaIndentation]: -1, indentInc: 0 });\n expect(result).toBe(query);\n });\n\n describe('on altered nodes', () => {\n it('translates ?s -> ?subject', ({ expect }) => {\n const query = 'SELECT * WHERE { ?s ?p ?o }';\n const ast = <T11.Query> parser.parse(query);\n\n const altered = transformer.transformNodeSpecific<'unsafe', T11.Query>(\n ast,\n {},\n { term: { variable: {\n transform: variable => variable.value === 's' ?\n F.termVariable('subject', F.sourceLocationNodeReplaceUnsafe(variable.loc)) :\n variable,\n }}},\n );\n\n const result = generator.generate(altered, { origSource: query });\n expect(result).toBe(`SELECT * WHERE { ?subject ?p ?o }`);\n });\n\n it('translates blanknodes -> variables', ({ expect }) => {\n const query = `\n\nBASE <ex:>\nCONSTRUCT { \n ?s0 ?p0 _:g_0 .\n_:g_0 <a0> _:g_1 .\n_:g_1 <b0> <c0> .\n[\n <a0> [\n <b0> <c0> ; \n ] ; \n] ?p0 ?o0 .\n\n}\nWHERE {\n ?s1 ?p1 _:g_4 .\n?s1 ?p1 <a1> .\n?s1 ?q1 <b1> .\n?s1 ?q1 <c1> .\n_:g_5 ?p2 ?o2 .\n?s3 ?p3 _:g_6 .\n_:g_6 <a3> <b3> .\n?s4 ?p4 _:g_7 .\n_:g_7 <a4> <b4> .\n_:g_7 <c4> <d4> .\n_:g_7 <c4> <e4> .\n?s5 ?p5 _:g_8 .\n_:g_8 <a5> _:g_9 .\n_:g_9 <b5> <c5> .\n[\n <a6> [\n <b6> <c6> ; \n ] ; \n] ?p6 ?o6 .\n_:g_12 <a7> <b7> .\n_:g_12 <c7> <d7> .\n_:g_12 <c7> <e7> .\n\n}`;\n const ast = <T11.Query> parser.parse(query);\n\n function extractCollection(collection: T11.TripleCollection): T11.TripleNesting[] {\n const result: T11.TripleNesting[] = [];\n for (const entry of collection.triples) {\n const subject = entry.subject;\n const pred = entry.predicate;\n if (F.isTripleCollection(entry.object)) {\n const identifier = { ...F.graphNodeIdentifier(entry.object) };\n result.push(F.triple(subject, pred, identifier, F.gen()));\n result.push(...extractCollection(entry.object));\n } else {\n result.push(F.triple(\n subject,\n pred,\n entry.object,\n F.gen(),\n ));\n }\n }\n return result;\n }\n\n const flattenCollections = transformer.transformNodeSpecific<'unsafe', T11.Query>(\n ast,\n {},\n { pattern: { bgp: {\n transform: (current) => {\n const bgpCopy = F.forcedAutoGenTree(current);\n const newTriples: T11.TripleNesting[] = [];\n for (const entry of bgpCopy.triples) {\n if (F.isTriple(entry)) {\n const subject = entry.subject;\n const pred = entry.predicate;\n if (F.isTripleCollection(entry.object)) {\n const object = entry.object;\n const identifier = { ...F.graphNodeIdentifier(object) };\n newTriples.push(F.triple(subject, pred, identifier));\n newTriples.push(...extractCollection(object));\n } else {\n newTriples.push(F.triple(\n subject,\n pred,\n entry.object,\n F.gen(),\n ));\n }\n } else {\n const genTriples = extractCollection(entry);\n newTriples.push(...genTriples);\n }\n }\n return F.patternBgp(newTriples, F.sourceLocationNodeReplaceUnsafe(current.loc));\n },\n }}},\n );\n\n const result = generator.generate(flattenCollections, { origSource: query });\n expect(result).toBe(`BASE <ex:>\nCONSTRUCT { \n ?s0 ?p0 _:g_0 .\n_:g_0 <a0> _:g_1 .\n_:g_1 <b0> <c0> .\n[\n <a0> [\n <b0> <c0> ;\n ] ;\n] ?p0 ?o0 .\n\n\n}\nWHERE {\n ?s1 ?p1 _:g_4 .\n?s1 ?p1 <a1> .\n?s1 ?q1 <b1> .\n?s1 ?q1 <c1> .\n_:g_5 ?p2 ?o2 .\n?s3 ?p3 _:g_6 .\n_:g_6 <a3> <b3> .\n?s4 ?p4 _:g_7 .\n_:g_7 <a4> <b4> .\n_:g_7 <c4> <d4> .\n_:g_7 <c4> <e4> .\n?s5 ?p5 _:g_8 .\n_:g_8 <a5> _:g_9 .\n_:g_9 <b5> <c5> .\n[\n <a6> [\n <b6> <c6> ;\n ] ;\n] ?p6 ?o6 .\n_:g_12 <a7> <b7> .\n_:g_12 <c7> <d7> .\n_:g_12 <c7> <e7> .\n\n\n}`);\n });\n });\n\n it ('generates hand constructed query', ({ expect }) => {\n const query = `\nSELECT * WHERE {\n ?s ?p ?o .\n}`;\n const ast = F.querySelect({\n variables: [ F.wildcard(F.gen()) ],\n datasets: F.datasetClauses([], F.sourceLocation()),\n context: [],\n where: F.patternGroup([\n F.patternBgp([\n F.triple(F.termVariable('s', F.gen()), F.termVariable('p', F.gen()), F.termVariable('o', F.gen())),\n ], F.gen()),\n ], F.gen()),\n solutionModifiers: {},\n }, F.gen());\n const result = generator.generate(ast);\n expect(result.trim()).toBe(query.trim());\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { AstFactory } from '@traqula/rules-sparql-1-1';
4
+ import { positiveTest, getStaticFilePath } from '@traqula/test-utils';
5
+ import { describe, it } from 'vitest';
6
+ import { Generator } from '../lib/index.js';
7
+ describe('a SPARQL 1.1 generator', () => {
8
+ const generator = new Generator();
9
+ const F = new AstFactory();
10
+ function _sinkGenerated(suite, test, response) {
11
+ const dir = getStaticFilePath();
12
+ const fileLoc = path.join(dir, suite, `${test}-generated.sparql`);
13
+ // eslint-disable-next-line no-sync
14
+ fs.writeFileSync(fileLoc, response);
15
+ }
16
+ describe('positive paths', () => {
17
+ for (const { name, statics } of positiveTest('paths')) {
18
+ it(`can generate ${name}`, async ({ expect }) => {
19
+ const { query, ast, autoGen } = await statics();
20
+ const path = ast;
21
+ const generated = generator.generatePath(path, { origSource: query });
22
+ expect(generated, 'round-trip generation').toEqual(query.trim());
23
+ const replaceLoc = F.sourceLocationNodeReplaceUnsafe(path.loc);
24
+ const autoGenAst = F.forcedAutoGenTree(path);
25
+ autoGenAst.loc = replaceLoc;
26
+ const selfGenerated = generator.generatePath(autoGenAst);
27
+ // _sinkGenerated('paths', name, selfGenerated);
28
+ expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());
29
+ });
30
+ }
31
+ });
32
+ describe('positive sparql 1.1', () => {
33
+ for (const { name, statics } of positiveTest('sparql-1-1')) {
34
+ it(`can generate ${name}`, async ({ expect }) => {
35
+ const { query, ast, autoGen } = await statics();
36
+ const queryUpdate = ast;
37
+ const roundTripped = generator.generate(queryUpdate, { origSource: query });
38
+ expect(roundTripped, 'round-trip generation').toEqual(query.trim());
39
+ const replaceLoc = F.sourceLocationNodeReplaceUnsafe(queryUpdate.loc);
40
+ const autoGenAst = F.forcedAutoGenTree(queryUpdate);
41
+ autoGenAst.loc = replaceLoc;
42
+ const selfGenerated = generator.generate(autoGenAst);
43
+ // _sinkGenerated('sparql-1-1', name, selfGenerated);
44
+ expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());
45
+ });
46
+ }
47
+ });
48
+ });
49
+ //# sourceMappingURL=statics.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statics.test.js","sourceRoot":"","sources":["../../../test/statics.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAA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AC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport type * as T11 from '@traqula/rules-sparql-1-1';\nimport { AstFactory } from '@traqula/rules-sparql-1-1';\nimport { positiveTest, getStaticFilePath } from '@traqula/test-utils';\nimport { describe, it } from 'vitest';\nimport { Generator } from '../lib/index.js';\n\ndescribe('a SPARQL 1.1 generator', () => {\n const generator = new Generator();\n const F = new AstFactory();\n\n function _sinkGenerated(suite: string, test: string, response: string): void {\n const dir = getStaticFilePath();\n const fileLoc = path.join(dir, suite, `${test}-generated.sparql`);\n // eslint-disable-next-line no-sync\n fs.writeFileSync(fileLoc, response);\n }\n\n describe('positive paths', () => {\n for (const { name, statics } of positiveTest('paths')) {\n it(`can generate ${name}`, async({ expect }) => {\n const { query, ast, autoGen } = await statics();\n const path = <T11.Path>ast;\n\n const generated = generator.generatePath(path, { origSource: query });\n expect(generated, 'round-trip generation').toEqual(query.trim());\n\n const replaceLoc = F.sourceLocationNodeReplaceUnsafe(path.loc);\n const autoGenAst = F.forcedAutoGenTree(path);\n autoGenAst.loc = replaceLoc;\n const selfGenerated = generator.generatePath(autoGenAst);\n // _sinkGenerated('paths', name, selfGenerated);\n expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());\n });\n }\n });\n\n describe('positive sparql 1.1', () => {\n for (const { name, statics } of positiveTest('sparql-1-1')) {\n it(`can generate ${name}`, async({ expect }) => {\n const { query, ast, autoGen } = await statics();\n const queryUpdate = <T11.Query | T11.Update>ast;\n\n const roundTripped = generator.generate(queryUpdate, { origSource: query });\n expect(roundTripped, 'round-trip generation').toEqual(query.trim());\n\n const replaceLoc = F.sourceLocationNodeReplaceUnsafe(queryUpdate.loc);\n const autoGenAst = F.forcedAutoGenTree(queryUpdate);\n autoGenAst.loc = replaceLoc;\n const selfGenerated = generator.generate(autoGenAst);\n // _sinkGenerated('sparql-1-1', name, selfGenerated);\n expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());\n });\n }\n });\n});\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@traqula/generator-sparql-1-1",
3
3
  "type": "module",
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "description": "SPARQL 1.1 generator",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -17,37 +17,36 @@
17
17
  "exports": {
18
18
  "./package.json": "./package.json",
19
19
  ".": {
20
- "types": "./lib/index.d.ts",
21
- "import": "./lib/index.js",
22
- "require": "./lib/index.cjs"
20
+ "types": "./dist/esm/lib/index.d.ts",
21
+ "import": "./dist/esm/lib/index.js",
22
+ "require": "./dist/cjs/lib/index.js"
23
23
  }
24
24
  },
25
- "main": "lib/index.js",
25
+ "main": "dist/esm/lib/index.js",
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
29
  "files": [
30
- "lib/**/*.cjs",
31
- "lib/**/*.d.ts",
32
- "lib/**/*.js",
33
- "lib/**/*.js.map"
30
+ "dist/**/*.d.ts",
31
+ "dist/**/*.js",
32
+ "dist/**/*.js.map",
33
+ "dist/**/package.json"
34
34
  ],
35
35
  "engines": {
36
36
  "node": "^20.19.0 || >=22.12.0"
37
37
  },
38
- "typings": "lib/index",
39
38
  "scripts": {
40
39
  "build": "yarn build:ts && yarn build:transpile",
41
- "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
42
- "build:transpile": " node \"../../node_modules/esbuild/bin/esbuild\" --format=cjs --bundle --log-level=error --outfile=lib/index.cjs lib/index.ts"
40
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\" -b",
41
+ "build:transpile": "esbuild \"dist/esm/**/*.js\" --outdir=dist/cjs --platform=node --format=cjs"
43
42
  },
44
43
  "dependencies": {
45
- "@traqula/core": "^0.0.21",
46
- "@traqula/rules-sparql-1-1": "^0.0.21"
44
+ "@traqula/core": "^0.0.23",
45
+ "@traqula/rules-sparql-1-1": "^0.0.23"
47
46
  },
48
47
  "devDependencies": {
49
- "@traqula/parser-sparql-1-1": "^0.0.21",
50
- "@traqula/test-utils": "^0.0.21"
48
+ "@traqula/parser-sparql-1-1": "^0.0.23",
49
+ "@traqula/test-utils": "^0.0.23"
51
50
  },
52
- "gitHead": "6e27b4bab942e473c11576196320bd52894ea5a4"
51
+ "gitHead": "36ec1aae80524a84f044182811a55ebeef6d9cda"
53
52
  }