stringent 0.0.1 → 0.0.4

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 (54) hide show
  1. package/README.md +96 -0
  2. package/dist/context.d.ts +45 -0
  3. package/dist/context.d.ts.map +1 -0
  4. package/dist/context.js +14 -0
  5. package/dist/context.js.map +1 -0
  6. package/dist/createParser.d.ts +159 -0
  7. package/dist/createParser.d.ts.map +1 -0
  8. package/dist/createParser.js +118 -0
  9. package/dist/createParser.js.map +1 -0
  10. package/dist/errors.d.ts +121 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +186 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/grammar/index.d.ts +48 -0
  15. package/dist/grammar/index.d.ts.map +1 -0
  16. package/dist/grammar/index.js +13 -0
  17. package/dist/grammar/index.js.map +1 -0
  18. package/dist/index.d.ts +27 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +31 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/parse/index.d.ts +211 -0
  23. package/dist/parse/index.d.ts.map +1 -0
  24. package/dist/parse/index.js +16 -0
  25. package/dist/parse/index.js.map +1 -0
  26. package/dist/performance.bench.d.ts +10 -0
  27. package/dist/performance.bench.d.ts.map +1 -0
  28. package/dist/performance.bench.js +379 -0
  29. package/dist/performance.bench.js.map +1 -0
  30. package/dist/primitive/index.d.ts +96 -0
  31. package/dist/primitive/index.d.ts.map +1 -0
  32. package/dist/primitive/index.js +102 -0
  33. package/dist/primitive/index.js.map +1 -0
  34. package/dist/runtime/eval.d.ts +157 -0
  35. package/dist/runtime/eval.d.ts.map +1 -0
  36. package/dist/runtime/eval.js +206 -0
  37. package/dist/runtime/eval.js.map +1 -0
  38. package/dist/runtime/infer.d.ts +27 -0
  39. package/dist/runtime/infer.d.ts.map +1 -0
  40. package/dist/runtime/infer.js +35 -0
  41. package/dist/runtime/infer.js.map +1 -0
  42. package/dist/runtime/parser.d.ts +115 -0
  43. package/dist/runtime/parser.d.ts.map +1 -0
  44. package/dist/runtime/parser.js +746 -0
  45. package/dist/runtime/parser.js.map +1 -0
  46. package/dist/schema/index.d.ts +476 -0
  47. package/dist/schema/index.d.ts.map +1 -0
  48. package/dist/schema/index.js +137 -0
  49. package/dist/schema/index.js.map +1 -0
  50. package/dist/static/infer.d.ts +27 -0
  51. package/dist/static/infer.d.ts.map +1 -0
  52. package/dist/static/infer.js +10 -0
  53. package/dist/static/infer.js.map +1 -0
  54. package/package.json +62 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6GH,gDAAgD;AAChD,SAAS,MAAM,CACb,MAAe;IAEf,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,EAAE,CAAuB,IAAW;YAClC,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,IAAa,EAAE,IAAI,EAAE,CAAC;QACrD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,4BAA4B;AAC5B,gFAAgF;AAEhF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAErE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,MAAM,GAAG,CAA0C,MAAe,EAAE,EAAE,CACjF,MAAM,CAAwB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAE5D,2CAA2C;AAC3C,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAElE,sDAAsD;AACtD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAA8B,KAAa,EAAE,EAAE,CACrE,MAAM,CAAsB,EAAE,IAAI,EAAE,OAA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AST.
5
+ *
6
+ * With the new architecture, nodes carry their outputSchema directly,
7
+ * so inference is simpler - just extract the outputSchema field.
8
+ */
9
+ import type { Context } from '../context.js';
10
+ /**
11
+ * Infer the result type of an AST node.
12
+ *
13
+ * Nodes now carry their outputSchema directly:
14
+ * - NumberNode has outputSchema: "number"
15
+ * - BinaryNode<Name, Left, Right, OutputSchema> has outputSchema: OutputSchema
16
+ * - IdentNode<Name, OutputSchema> has outputSchema: OutputSchema
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * type Num = Infer<NumberNode<"42">, {}>; // "number"
21
+ * type Add = Infer<BinaryNode<"add", NumberNode<"1">, NumberNode<"2">, "number">, {}>; // "number"
22
+ * ```
23
+ */
24
+ export type Infer<AST, _$ extends Context> = AST extends {
25
+ outputSchema: infer R;
26
+ } ? R : never;
27
+ //# sourceMappingURL=infer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer.d.ts","sourceRoot":"","sources":["../../src/static/infer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,OAAO,IAEvC,GAAG,SAAS;IAAE,YAAY,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type-Level Inference
3
+ *
4
+ * Infer<AST, Context> computes the result type of a parsed AST.
5
+ *
6
+ * With the new architecture, nodes carry their outputSchema directly,
7
+ * so inference is simpler - just extract the outputSchema field.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=infer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer.js","sourceRoot":"","sources":["../../src/static/infer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
package/package.json CHANGED
@@ -1,25 +1,79 @@
1
1
  {
2
2
  "name": "stringent",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "description": "A smart and type-safe expression parser",
5
5
  "keywords": [
6
6
  "parser",
7
7
  "expression",
8
- "typescript"
8
+ "typescript",
9
+ "type-safe",
10
+ "compile-time",
11
+ "type-level",
12
+ "expression-parser",
13
+ "dsl",
14
+ "ast",
15
+ "grammar",
16
+ "validation",
17
+ "inference"
9
18
  ],
10
- "homepage": "https://github.com/eralmansouri/stringent#readme",
19
+ "homepage": "https://github.com/formeddable/stringent#readme",
11
20
  "bugs": {
12
- "url": "https://github.com/eralmansouri/stringent/issues"
21
+ "url": "https://github.com/formeddable/stringent/issues"
13
22
  },
14
23
  "repository": {
15
24
  "type": "git",
16
- "url": "git+https://github.com/eralmansouri/stringent.git"
25
+ "url": "git+https://github.com/formeddable/stringent.git"
17
26
  },
18
27
  "license": "MIT",
19
28
  "author": "Essam Almansouri",
20
29
  "type": "module",
21
- "main": "index.js",
30
+ "engines": {
31
+ "node": ">=18.0.0"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "main": "dist/index.js",
37
+ "types": "dist/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "import": "./dist/index.js",
41
+ "types": "./dist/index.d.ts"
42
+ }
43
+ },
44
+ "packageManager": "pnpm@10.28.1",
22
45
  "scripts": {
23
- "test": "echo \"Error: no test specified\" && exit 1"
46
+ "build": "tsc -p tsconfig.build.json",
47
+ "typecheck": "tsc --noEmit",
48
+ "lint": "eslint src/",
49
+ "lint:fix": "eslint src/ --fix",
50
+ "format": "prettier --write \"src/**/*.ts\" \"examples/**/*.ts\"",
51
+ "format:check": "prettier --check \"src/**/*.ts\" \"examples/**/*.ts\"",
52
+ "test": "vitest run",
53
+ "test:watch": "vitest",
54
+ "test:coverage": "vitest run --coverage",
55
+ "bench": "vitest bench",
56
+ "docs": "typedoc",
57
+ "docs:watch": "typedoc --watch",
58
+ "prepublishOnly": "pnpm build"
59
+ },
60
+ "dependencies": {
61
+ "@sinclair/parsebox": "^0.11.1",
62
+ "arktype": "^2.1.29"
63
+ },
64
+ "devDependencies": {
65
+ "@eslint/js": "^9.39.2",
66
+ "@types/node": "^22.10.5",
67
+ "@vitest/coverage-v8": "^4.0.17",
68
+ "eslint": "^9.39.2",
69
+ "eslint-config-prettier": "^10.1.8",
70
+ "eslint-plugin-prettier": "^5.5.5",
71
+ "hotscript": "^1.0.13",
72
+ "prettier": "^3.8.0",
73
+ "tsx": "^4.21.0",
74
+ "typedoc": "^0.28.16",
75
+ "typescript": "^5.7.2",
76
+ "typescript-eslint": "^8.53.0",
77
+ "vitest": "^4.0.17"
24
78
  }
25
- }
79
+ }