@traqula/generator-sparql-1-2 0.0.21 → 0.0.22

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,64 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { AstFactory } from '@traqula/rules-sparql-1-2';
4
+ import { getStaticFilePath, positiveTest } from '@traqula/test-utils';
5
+ import { describe, it } from 'vitest';
6
+ import { Generator } from '../lib/index.js';
7
+ describe('a SPARQL 1.2 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 parse ${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 tripped 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
+ expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());
28
+ });
29
+ }
30
+ });
31
+ describe('positive sparql 1.1', () => {
32
+ for (const { name, statics } of positiveTest('sparql-1-1')) {
33
+ it(`can parse ${name}`, async ({ expect }) => {
34
+ const { query, ast, autoGen } = await statics();
35
+ const queryUpdate = ast;
36
+ const roundTripped = generator.generate(queryUpdate, { origSource: query });
37
+ expect(roundTripped, 'round-tripped generation').toEqual(query.trim());
38
+ const replaceLoc = F.sourceLocationNodeReplaceUnsafe(queryUpdate.loc);
39
+ const autoGenAst = F.forcedAutoGenTree(queryUpdate);
40
+ autoGenAst.loc = replaceLoc;
41
+ const selfGenerated = generator.generate(autoGenAst);
42
+ // _sinkGenerated('sparql-1-1', name, selfGenerated);
43
+ expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());
44
+ });
45
+ }
46
+ });
47
+ describe('positive sparql 1.2', () => {
48
+ for (const { name, statics } of positiveTest('sparql-1-2')) {
49
+ it(`can parse ${name}`, async ({ expect }) => {
50
+ const { query, ast, autoGen } = await statics();
51
+ const queryUpdate = ast;
52
+ const roundTripped = generator.generate(queryUpdate, { origSource: query });
53
+ expect(roundTripped, 'round-tripped generation').toEqual(query.trim());
54
+ const replaceLoc = F.sourceLocationNodeReplaceUnsafe(queryUpdate.loc);
55
+ const autoGenAst = F.forcedAutoGenTree(queryUpdate);
56
+ autoGenAst.loc = replaceLoc;
57
+ const selfGenerated = generator.generate(autoGenAst);
58
+ // _sinkGenerated('sparql-1-2', name, selfGenerated);
59
+ expect(selfGenerated, 'auto generated').toEqual(autoGen.trim());
60
+ });
61
+ }
62
+ });
63
+ });
64
+ //# 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,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtE,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,CAAC,GAAG,IAAI,UAAU,EAAE,CAAC;IAE3B,SAAS,cAAc,CAAC,KAAa,EAAE,I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AAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,EAAE,CAAC;gBAChD,MAAM,WAAW,GAA2B,GAAG,CAAC;gBAEhD,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;gBAC5E,MAAM,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;gBAEvE,MAAM,UAAU,GAAG,CAAC,CAAC,+BAA+B,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;gBACtE,MAAM,UAAU,GAAG,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;gBACpD,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC;gBAC5B,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACrD,qDAAqD;gBACrD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAClE,CAAC,CAAC,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 T12 from '@traqula/rules-sparql-1-1';\nimport { AstFactory } from '@traqula/rules-sparql-1-2';\nimport { getStaticFilePath, positiveTest } from '@traqula/test-utils';\nimport { describe, it } from 'vitest';\nimport { Generator } from '../lib/index.js';\n\ndescribe('a SPARQL 1.2 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 parse ${name}`, async({ expect }) => {\n const { query, ast, autoGen } = await statics();\n const path = <T12.Path>ast;\n\n const generated = generator.generatePath(path, { origSource: query });\n expect(generated, 'round tripped 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 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 parse ${name}`, async({ expect }) => {\n const { query, ast, autoGen } = await statics();\n const queryUpdate = <T12.Query | T12.Update>ast;\n\n const roundTripped = generator.generate(queryUpdate, { origSource: query });\n expect(roundTripped, 'round-tripped 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 describe('positive sparql 1.2', () => {\n for (const { name, statics } of positiveTest('sparql-1-2')) {\n it(`can parse ${name}`, async({ expect }) => {\n const { query, ast, autoGen } = await statics();\n const queryUpdate = <T12.Query | T12.Update>ast;\n\n const roundTripped = generator.generate(queryUpdate, { origSource: query });\n expect(roundTripped, 'round-tripped 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-2', 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-2",
3
3
  "type": "module",
4
- "version": "0.0.21",
4
+ "version": "0.0.22",
5
5
  "description": "SPARQL 1.2 generator",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -17,39 +17,37 @@
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"
34
33
  ],
35
34
  "engines": {
36
35
  "node": "^20.19.0 || >=22.12.0"
37
36
  },
38
- "typings": "lib/index",
39
37
  "scripts": {
40
38
  "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"
39
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\" -b",
40
+ "build:transpile": "esbuild \"dist/esm/**/*.js\" --outdir=dist/cjs --platform=node --format=cjs"
43
41
  },
44
42
  "dependencies": {
45
- "@traqula/core": "^0.0.21",
46
- "@traqula/generator-sparql-1-1": "^0.0.21",
47
- "@traqula/rules-sparql-1-1": "^0.0.21",
48
- "@traqula/rules-sparql-1-2": "^0.0.21"
43
+ "@traqula/core": "^0.0.22",
44
+ "@traqula/generator-sparql-1-1": "^0.0.22",
45
+ "@traqula/rules-sparql-1-1": "^0.0.22",
46
+ "@traqula/rules-sparql-1-2": "^0.0.22"
49
47
  },
50
48
  "devDependencies": {
51
- "@traqula/parser-sparql-1-2": "^0.0.21",
52
- "@traqula/test-utils": "^0.0.21"
49
+ "@traqula/parser-sparql-1-2": "^0.0.22",
50
+ "@traqula/test-utils": "^0.0.22"
53
51
  },
54
- "gitHead": "6e27b4bab942e473c11576196320bd52894ea5a4"
52
+ "gitHead": "e0cf04a50b3558229ebcc5992cf9562b14f9a077"
55
53
  }