@ir-kit/fn-schema-loader 0.1.0

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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ahmed Rowaihi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @ir-kit/fn-schema-loader
2
+
3
+ Type-safe reader over a fn-schema bundle. Generic over the bundle type so signature ids and definition names land as literal-typed unions.
4
+
5
+ Zero runtime dependencies — works in any JS runtime that can read JSON.
6
+
7
+ ## When to use it
8
+
9
+ You have a fn-schema bundle (produced by the CLI or programmatically — doesn't matter which) and want ergonomic access from your app:
10
+
11
+ - server endpoints looking up schemas by id
12
+ - frontend form builders resolving `$ref` pointers
13
+ - canvas tools matching types nominally via `findByIdentity`
14
+
15
+ If you're loading the JSON in one place and reading it once, the helper is overkill — just `JSON.parse` it.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pnpm add @ir-kit/fn-schema-loader
21
+ ```
22
+
23
+ ## Producing a bundle
24
+
25
+ Pick whichever fits your build chain — both produce the same JSON:
26
+
27
+ ### Programmatically
28
+
29
+ ```ts
30
+ import { extract } from "@ir-kit/fn-schema-typescript";
31
+ import { emit } from "@ir-kit/fn-schema-core";
32
+ import { writeFile } from "node:fs/promises";
33
+
34
+ const result = await extract({
35
+ files: ["src/api/**/*.ts"],
36
+ schema: { identity: "x-fn-schema-ts" },
37
+ });
38
+ await writeFile(
39
+ "generated/schemas.json",
40
+ emit.toBundle(result, { pretty: true }),
41
+ );
42
+ await writeFile(
43
+ "generated/schemas.ts",
44
+ emit.toBundleTypesModule(result, { jsonImport: "./schemas.json" }),
45
+ );
46
+ ```
47
+
48
+ ### Via CLI
49
+
50
+ ```bash
51
+ npx fn-schema extract 'src/api/**/*.ts' --bundle generated/schemas.json --bundle-types --pretty
52
+ ```
53
+
54
+ The `.ts` wrapper next to `schemas.json` is what unlocks literal-typed lookups in the reader.
55
+
56
+ ## Reading
57
+
58
+ ```ts
59
+ import { createReader } from "@ir-kit/fn-schema-loader";
60
+ import schemas from "./generated/schemas"; // the typed wrapper
61
+
62
+ const reader = createReader(schemas);
63
+
64
+ reader.get("createUser"); // ✅ typed
65
+ reader.get("createUserx"); // ❌ TS error
66
+ reader.has("listUsers"); // type predicate
67
+
68
+ reader.inputOf("createUser"); // resolved (top-level $ref chased)
69
+ reader.outputOf("createUser");
70
+ reader.resolveRef("#/definitions/User");
71
+
72
+ // canvas-style nominal-type matching (only when bundle was extracted with `identity`)
73
+ reader.findByIdentity("User", "x-fn-schema-ts");
74
+ // → [{ signatureId: "createUser", position: "output", schema: {...} }, ...]
75
+ ```
76
+
77
+ ## API
78
+
79
+ ```ts
80
+ interface Reader<T extends Bundle> {
81
+ readonly bundle: T;
82
+ get<K extends SignatureId<T>>(id: K): T["signatures"][K] | undefined;
83
+ has<K extends string>(id: K): id is K & SignatureId<T>;
84
+ resolve<K extends DefinitionName<T>>(
85
+ name: K,
86
+ ): T["definitions"][K] | undefined;
87
+ resolveRef(ref: string): Record<string, unknown> | undefined;
88
+ inputOf<K extends SignatureId<T>>(id: K): unknown;
89
+ outputOf<K extends SignatureId<T>>(id: K): unknown;
90
+ findByIdentity(name: string, identityKey?: string): Match[];
91
+ listSignatures(): SignatureId<T>[];
92
+ listDefinitions(): DefinitionName<T>[];
93
+ }
94
+ ```
95
+
96
+ `identityKey` defaults to `"x-fn-schema-ts"`.
97
+
98
+ ## Without the typed wrapper
99
+
100
+ Works on any plain object too — you just lose autocomplete:
101
+
102
+ ```ts
103
+ import { readFileSync } from "node:fs";
104
+ import { createReader, type Bundle } from "@ir-kit/fn-schema-loader";
105
+
106
+ const raw = JSON.parse(readFileSync("./schemas.json", "utf-8")) as Bundle;
107
+ const reader = createReader(raw);
108
+ ```
109
+
110
+ ## $ref resolution
111
+
112
+ `inputOf` / `outputOf` chase a single top-level `$ref`. Nested `$ref`s inside the schema body are left intact — call `resolveRef` yourself if you need to chase further. Keeps the helper predictable; no cycle handling.
@@ -0,0 +1,3 @@
1
+ export { createReader, type Reader } from "./reader.js";
2
+ export { type Bundle, type BundleSignature, DEFAULT_IDENTITY_KEY, DEFINITIONS_PREFIX, type DefinitionName, type Match, type SignatureId, } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { createReader } from "./reader.js";
2
+ export { DEFAULT_IDENTITY_KEY, DEFINITIONS_PREFIX, } from "./types.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAGL,oBAAoB,EACpB,kBAAkB,GAInB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type Bundle, type DefinitionName, type Match, type SignatureId } from "./types.js";
2
+ export interface Reader<T extends Bundle> {
3
+ readonly bundle: T;
4
+ get<K extends SignatureId<T>>(id: K): T["signatures"][K] | undefined;
5
+ has<K extends string>(id: K): id is K & SignatureId<T>;
6
+ resolve<K extends DefinitionName<T>>(name: K): T["definitions"][K] | undefined;
7
+ resolveRef(ref: string): Record<string, unknown> | undefined;
8
+ inputOf<K extends SignatureId<T>>(id: K): unknown;
9
+ outputOf<K extends SignatureId<T>>(id: K): unknown;
10
+ findByIdentity(name: string, identityKey?: string): Match[];
11
+ listSignatures(): SignatureId<T>[];
12
+ listDefinitions(): DefinitionName<T>[];
13
+ }
14
+ export declare function createReader<T extends Bundle>(bundle: T): Reader<T>;
15
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAIX,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,MAAM,CAAC,CAAC,SAAS,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,GAAG,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACrE,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,EACjC,IAAI,EAAE,CAAC,GACN,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7D,OAAO,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC;IAClD,QAAQ,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC;IACnD,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IAC5D,cAAc,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,eAAe,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;CACxC;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CA2FnE"}
package/dist/reader.js ADDED
@@ -0,0 +1,96 @@
1
+ import { DEFAULT_IDENTITY_KEY, DEFINITIONS_PREFIX, } from "./types.js";
2
+ export function createReader(bundle) {
3
+ const signatures = bundle.signatures;
4
+ const definitions = bundle.definitions;
5
+ const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
6
+ const resolveRef = (ref) => {
7
+ if (!ref.startsWith(DEFINITIONS_PREFIX))
8
+ return undefined;
9
+ const name = ref.slice(DEFINITIONS_PREFIX.length);
10
+ return hasOwn(definitions, name) ? definitions[name] : undefined;
11
+ };
12
+ const followRef = (schema) => {
13
+ if (!schema || typeof schema !== "object")
14
+ return schema;
15
+ const ref = schema.$ref;
16
+ if (typeof ref === "string") {
17
+ const resolved = resolveRef(ref);
18
+ if (resolved !== undefined)
19
+ return resolved;
20
+ }
21
+ return schema;
22
+ };
23
+ return {
24
+ bundle,
25
+ get(id) {
26
+ return hasOwn(signatures, id)
27
+ ? signatures[id]
28
+ : undefined;
29
+ },
30
+ has(id) {
31
+ return hasOwn(signatures, id);
32
+ },
33
+ resolve(name) {
34
+ return hasOwn(definitions, name)
35
+ ? definitions[name]
36
+ : undefined;
37
+ },
38
+ resolveRef,
39
+ inputOf(id) {
40
+ if (!hasOwn(signatures, id))
41
+ return undefined;
42
+ const sig = signatures[id];
43
+ if (Array.isArray(sig.input))
44
+ return sig.input.map(followRef);
45
+ return followRef(sig.input);
46
+ },
47
+ outputOf(id) {
48
+ if (!hasOwn(signatures, id))
49
+ return undefined;
50
+ const sig = signatures[id];
51
+ return followRef(sig.output);
52
+ },
53
+ findByIdentity(name, identityKey = DEFAULT_IDENTITY_KEY) {
54
+ const out = [];
55
+ const matchesIdentity = (schema) => {
56
+ if (!schema || typeof schema !== "object")
57
+ return false;
58
+ const direct = schema[identityKey] === name;
59
+ if (direct)
60
+ return true;
61
+ const ref = schema.$ref;
62
+ if (typeof ref === "string") {
63
+ const resolved = resolveRef(ref);
64
+ if (resolved &&
65
+ resolved[identityKey] === name) {
66
+ return true;
67
+ }
68
+ }
69
+ return false;
70
+ };
71
+ for (const [id, sig] of Object.entries(signatures)) {
72
+ if (Array.isArray(sig.input)) {
73
+ for (const part of sig.input) {
74
+ if (matchesIdentity(part)) {
75
+ out.push({ signatureId: id, position: "input", schema: part });
76
+ }
77
+ }
78
+ }
79
+ else if (matchesIdentity(sig.input)) {
80
+ out.push({ signatureId: id, position: "input", schema: sig.input });
81
+ }
82
+ if (matchesIdentity(sig.output)) {
83
+ out.push({ signatureId: id, position: "output", schema: sig.output });
84
+ }
85
+ }
86
+ return out;
87
+ },
88
+ listSignatures() {
89
+ return Object.keys(signatures);
90
+ },
91
+ listDefinitions() {
92
+ return Object.keys(definitions);
93
+ },
94
+ };
95
+ }
96
+ //# sourceMappingURL=reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EACpB,kBAAkB,GAInB,MAAM,YAAY,CAAC;AAiBpB,MAAM,UAAU,YAAY,CAAmB,MAAS;IACtD,MAAM,UAAU,GAAG,MAAM,CAAC,UAA6C,CAAC;IACxE,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACvC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,GAAW,EAAW,EAAE,CACnD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,MAAM,UAAU,GAAG,CAAC,GAAW,EAAuC,EAAE;QACtE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC;YAAE,OAAO,SAAS,CAAC;QAC1D,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,MAAe,EAAW,EAAE;QAC7C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC;QACzD,MAAM,GAAG,GAAI,MAA6B,CAAC,IAAI,CAAC;QAChD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OA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BAChC,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,cAAc;YACZ,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAqB,CAAC;QACrD,CAAC;QACD,eAAe;YACb,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAwB,CAAC;QACzD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ export interface BundleSignature {
2
+ /** Original TS function name (independent of the `id` it's keyed by). */
3
+ name?: string;
4
+ /** Absolute path of the source file the signature was extracted from. */
5
+ file?: string;
6
+ input: unknown;
7
+ output: unknown;
8
+ }
9
+ /**
10
+ * Bundles carry vendor-extension keywords (`x-fn-schema-ts`, etc.), so
11
+ * definition values are typed as plain objects rather than `JSONSchema7` —
12
+ * the strict @types/json-schema type rejects unknown keys at construction.
13
+ */
14
+ export interface Bundle {
15
+ $schema?: string;
16
+ signatures: Record<string, BundleSignature>;
17
+ definitions: Record<string, Record<string, unknown>>;
18
+ }
19
+ export type SignatureId<T extends Bundle> = keyof T["signatures"] & string;
20
+ export type DefinitionName<T extends Bundle> = keyof T["definitions"] & string;
21
+ export interface Match {
22
+ signatureId: string;
23
+ position: "input" | "output";
24
+ schema: unknown;
25
+ }
26
+ export declare const DEFAULT_IDENTITY_KEY = "x-fn-schema-ts";
27
+ export declare const DEFINITIONS_PREFIX = "#/definitions/";
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACtD;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;AAE/E,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,kBAAkB,mBAAmB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export const DEFAULT_IDENTITY_KEY = "x-fn-schema-ts";
2
+ export const DEFINITIONS_PREFIX = "#/definitions/";
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@ir-kit/fn-schema-loader",
3
+ "version": "0.1.0",
4
+ "description": "Type-safe reader for fn-schema bundles. Resolves $ref pointers, indexes signatures by id and named types by identity keyword. Zero runtime dependencies — works in any JS runtime that can read JSON.",
5
+ "keywords": [
6
+ "json-schema",
7
+ "function-signature",
8
+ "reader",
9
+ "loader"
10
+ ],
11
+ "homepage": "https://github.com/ir-kit/ir-kit/tree/main/packages/fn-schema/loader",
12
+ "bugs": {
13
+ "url": "https://github.com/ir-kit/ir-kit/issues"
14
+ },
15
+ "license": "MIT",
16
+ "author": {
17
+ "name": "Ahmed Rowaihi",
18
+ "email": "ahmedrowaihi@gmail.com"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/ir-kit/ir-kit.git",
23
+ "directory": "packages/fn-schema/loader"
24
+ },
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "LICENSE.md"
39
+ ],
40
+ "publishConfig": {
41
+ "access": "public",
42
+ "provenance": true
43
+ },
44
+ "dependencies": {
45
+ "@ir-kit/fn-schema-core": "0.1.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22",
49
+ "vitest": "^4.0.0",
50
+ "@ir-kit/tsconfig": "0.0.0"
51
+ },
52
+ "engines": {
53
+ "node": ">=20.19.0"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc -p tsconfig.build.json",
57
+ "dev": "tsc -p tsconfig.build.json --watch",
58
+ "typecheck": "tsc --noEmit",
59
+ "test": "vitest run --passWithNoTests"
60
+ }
61
+ }