@ir-kit/fn-schema-typescript 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 +21 -0
- package/README.md +85 -0
- package/dist/aliases.d.ts +37 -0
- package/dist/aliases.d.ts.map +1 -0
- package/dist/aliases.js +468 -0
- package/dist/aliases.js.map +1 -0
- package/dist/discover.d.ts +24 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +284 -0
- package/dist/discover.js.map +1 -0
- package/dist/extractor.d.ts +9 -0
- package/dist/extractor.d.ts.map +1 -0
- package/dist/extractor.js +94 -0
- package/dist/extractor.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/jsdoc.d.ts +4 -0
- package/dist/jsdoc.d.ts.map +1 -0
- package/dist/jsdoc.js +22 -0
- package/dist/jsdoc.js.map +1 -0
- package/dist/schema.d.ts +17 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +344 -0
- package/dist/schema.js.map +1 -0
- package/dist/well-known.d.ts +17 -0
- package/dist/well-known.d.ts.map +1 -0
- package/dist/well-known.js +50 -0
- package/dist/well-known.js.map +1 -0
- package/package.json +68 -0
package/dist/schema.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createFormatter, createParser, DEFAULT_CONFIG, SchemaGenerator, } from "ts-json-schema-generator";
|
|
3
|
+
import { renderImports, } from "./aliases.js";
|
|
4
|
+
import { detectSentinel, renderSentinelDeclaration, WELL_KNOWN_SCHEMAS, WELL_KNOWN_TRANSPORT, } from "./well-known.js";
|
|
5
|
+
export const VIRTUAL_DIR = "__fn_schema_virtual__";
|
|
6
|
+
const INPUT_PREFIX = "__In_";
|
|
7
|
+
const OUTPUT_NAME = "__Out__";
|
|
8
|
+
export class SignatureSkipped extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "SignatureSkipped";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function virtualDirFor(sourceFile) {
|
|
15
|
+
return path.join(path.dirname(sourceFile), VIRTUAL_DIR);
|
|
16
|
+
}
|
|
17
|
+
export function buildSchemas(fn, ctx) {
|
|
18
|
+
if (fn.generic && ctx.signature.generics === "skip") {
|
|
19
|
+
throw new SignatureSkipped(`Generic function "${fn.name}" skipped (set signature.generics to "erase" to coerce type parameters to unknown)`);
|
|
20
|
+
}
|
|
21
|
+
if (fn.generic && ctx.signature.generics === "error") {
|
|
22
|
+
throw new Error(`Generic function "${fn.name}" not supported`);
|
|
23
|
+
}
|
|
24
|
+
const overloads = pickOverloads(fn.overloads, ctx.signature.overloads);
|
|
25
|
+
const skip = ctx.signature.skipParameter;
|
|
26
|
+
const filteredOverloads = overloads.map((o) => ({
|
|
27
|
+
parameters: skip ? o.parameters.filter((p) => !skip(p)) : o.parameters,
|
|
28
|
+
returnAlias: o.returnAlias,
|
|
29
|
+
}));
|
|
30
|
+
const allNotes = filteredOverloads.flatMap((o) => [
|
|
31
|
+
...o.parameters.flatMap((p) => p.alias.notes),
|
|
32
|
+
...o.returnAlias.notes,
|
|
33
|
+
]);
|
|
34
|
+
const allSources = {};
|
|
35
|
+
for (const o of filteredOverloads) {
|
|
36
|
+
for (const p of o.parameters)
|
|
37
|
+
Object.assign(allSources, p.alias.sources);
|
|
38
|
+
Object.assign(allSources, o.returnAlias.sources);
|
|
39
|
+
}
|
|
40
|
+
const wellKnownNames = uniqueNames(allNotes, "well-known");
|
|
41
|
+
const inferredDefaults = {};
|
|
42
|
+
for (const n of allNotes) {
|
|
43
|
+
if (n.kind === "well-known" && n.defaultSchema) {
|
|
44
|
+
inferredDefaults[n.name] = n.defaultSchema;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const mappers = {
|
|
48
|
+
...inferredDefaults,
|
|
49
|
+
...WELL_KNOWN_SCHEMAS,
|
|
50
|
+
...(ctx.typeMappers ?? {}),
|
|
51
|
+
};
|
|
52
|
+
const maxArity = filteredOverloads.reduce((max, o) => Math.max(max, o.parameters.length), 0);
|
|
53
|
+
const virtualPath = virtualFileFor(fn);
|
|
54
|
+
const source = renderVirtualSource(filteredOverloads, maxArity, ctx.signature, wellKnownNames);
|
|
55
|
+
ctx.project.createSourceFile(virtualPath, source, { overwrite: true });
|
|
56
|
+
const config = buildGeneratorConfig(virtualPath, ctx.schema);
|
|
57
|
+
/** ts-morph bundles its own `typescript`; runtime shape matches but module identities differ. */
|
|
58
|
+
const program = ctx.project.getProgram().compilerObject;
|
|
59
|
+
const parser = createParser(program, config);
|
|
60
|
+
const formatter = createFormatter(config);
|
|
61
|
+
const generator = new SchemaGenerator(program, parser, formatter, config);
|
|
62
|
+
const definitions = {};
|
|
63
|
+
const inputSchemas = [];
|
|
64
|
+
for (let i = 0; i < maxArity; i++) {
|
|
65
|
+
const raw = generator.createSchema(`${INPUT_PREFIX}${i}`);
|
|
66
|
+
mergeDefinitions(definitions, raw.definitions);
|
|
67
|
+
inputSchemas.push(stripWrapper(raw));
|
|
68
|
+
}
|
|
69
|
+
const rawOutput = generator.createSchema(OUTPUT_NAME);
|
|
70
|
+
mergeDefinitions(definitions, rawOutput.definitions);
|
|
71
|
+
const output = stripWrapper(rawOutput);
|
|
72
|
+
const annotations = {
|
|
73
|
+
identity: ctx.schema.identity,
|
|
74
|
+
transport: ctx.schema.transport,
|
|
75
|
+
sourceLocations: ctx.schema.sourceLocations,
|
|
76
|
+
sources: allSources,
|
|
77
|
+
};
|
|
78
|
+
for (let i = 0; i < inputSchemas.length; i++) {
|
|
79
|
+
inputSchemas[i] = applyTypeMappers(inputSchemas[i], mappers, annotations);
|
|
80
|
+
}
|
|
81
|
+
const mappedOutput = applyTypeMappers(output, mappers, annotations);
|
|
82
|
+
for (const k of Object.keys(definitions)) {
|
|
83
|
+
const mapped = applyTypeMappers(definitions[k], mappers, annotations);
|
|
84
|
+
definitions[k] = annotateNamedDefinition(mapped, k, annotations);
|
|
85
|
+
}
|
|
86
|
+
const primary = filteredOverloads[filteredOverloads.length - 1];
|
|
87
|
+
const input = (() => {
|
|
88
|
+
switch (ctx.signature.parameters) {
|
|
89
|
+
case "first-only":
|
|
90
|
+
return inputSchemas[0] ?? { type: "null" };
|
|
91
|
+
case "object":
|
|
92
|
+
return objectFromParams(primary.parameters, inputSchemas);
|
|
93
|
+
case "array":
|
|
94
|
+
default:
|
|
95
|
+
return inputSchemas;
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
return {
|
|
99
|
+
input,
|
|
100
|
+
output: mappedOutput,
|
|
101
|
+
definitions,
|
|
102
|
+
coverage: buildCoverageReport(filteredOverloads),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function buildCoverageReport(overloads) {
|
|
106
|
+
const buckets = {
|
|
107
|
+
mapped: new Map(),
|
|
108
|
+
lossy: new Map(),
|
|
109
|
+
notRepresentable: new Map(),
|
|
110
|
+
};
|
|
111
|
+
const recordMapped = (name, occ) => {
|
|
112
|
+
const list = buckets.mapped.get(name);
|
|
113
|
+
if (list)
|
|
114
|
+
list.push(occ);
|
|
115
|
+
else
|
|
116
|
+
buckets.mapped.set(name, [occ]);
|
|
117
|
+
};
|
|
118
|
+
const recordLossy = (name, reason, occ) => {
|
|
119
|
+
const cur = buckets.lossy.get(name);
|
|
120
|
+
if (cur)
|
|
121
|
+
cur.occurrences.push(occ);
|
|
122
|
+
else
|
|
123
|
+
buckets.lossy.set(name, { reason, occurrences: [occ] });
|
|
124
|
+
};
|
|
125
|
+
const recordNotRepresentable = (name, occ) => {
|
|
126
|
+
const list = buckets.notRepresentable.get(name);
|
|
127
|
+
if (list)
|
|
128
|
+
list.push(occ);
|
|
129
|
+
else
|
|
130
|
+
buckets.notRepresentable.set(name, [occ]);
|
|
131
|
+
};
|
|
132
|
+
const dispatch = (note, occ) => {
|
|
133
|
+
if (note.kind === "well-known")
|
|
134
|
+
recordMapped(note.name, occ);
|
|
135
|
+
else if (note.kind === "lossy")
|
|
136
|
+
recordLossy(note.name, note.reason, occ);
|
|
137
|
+
else
|
|
138
|
+
recordNotRepresentable(note.name, occ);
|
|
139
|
+
};
|
|
140
|
+
for (let oi = 0; oi < overloads.length; oi++) {
|
|
141
|
+
const o = overloads[oi];
|
|
142
|
+
for (let pi = 0; pi < o.parameters.length; pi++) {
|
|
143
|
+
const p = o.parameters[pi];
|
|
144
|
+
const occ = {
|
|
145
|
+
side: "input",
|
|
146
|
+
overloadIndex: oi,
|
|
147
|
+
paramIndex: pi,
|
|
148
|
+
paramName: p.name,
|
|
149
|
+
};
|
|
150
|
+
for (const n of p.alias.notes)
|
|
151
|
+
dispatch(n, occ);
|
|
152
|
+
}
|
|
153
|
+
const occ = { side: "output", overloadIndex: oi };
|
|
154
|
+
for (const n of o.returnAlias.notes)
|
|
155
|
+
dispatch(n, occ);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
mapped: [...buckets.mapped].map(([name, occurrences]) => ({
|
|
159
|
+
name,
|
|
160
|
+
count: occurrences.length,
|
|
161
|
+
occurrences,
|
|
162
|
+
})),
|
|
163
|
+
lossy: [...buckets.lossy].map(([name, v]) => ({
|
|
164
|
+
name,
|
|
165
|
+
reason: v.reason,
|
|
166
|
+
count: v.occurrences.length,
|
|
167
|
+
occurrences: v.occurrences,
|
|
168
|
+
})),
|
|
169
|
+
notRepresentable: [...buckets.notRepresentable].map(([name, occurrences]) => ({
|
|
170
|
+
name,
|
|
171
|
+
count: occurrences.length,
|
|
172
|
+
occurrences,
|
|
173
|
+
})),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function uniqueNames(notes, kind) {
|
|
177
|
+
const seen = new Set();
|
|
178
|
+
for (const n of notes)
|
|
179
|
+
if (n.kind === kind)
|
|
180
|
+
seen.add(n.name);
|
|
181
|
+
return [...seen];
|
|
182
|
+
}
|
|
183
|
+
function applyTypeMappers(schema, mappers, ann) {
|
|
184
|
+
if (Array.isArray(schema)) {
|
|
185
|
+
return schema.map((s) => applyTypeMappers(s, mappers, ann));
|
|
186
|
+
}
|
|
187
|
+
if (!schema || typeof schema !== "object")
|
|
188
|
+
return schema;
|
|
189
|
+
const sentinel = detectSentinel(schema);
|
|
190
|
+
if (sentinel && mappers[sentinel]) {
|
|
191
|
+
return decorateMappedNode(sentinel, mappers[sentinel], ann);
|
|
192
|
+
}
|
|
193
|
+
const out = {};
|
|
194
|
+
for (const [k, v] of Object.entries(schema)) {
|
|
195
|
+
out[k] = applyTypeMappers(v, mappers, ann);
|
|
196
|
+
}
|
|
197
|
+
return out;
|
|
198
|
+
}
|
|
199
|
+
function decorateMappedNode(name, base, ann) {
|
|
200
|
+
const out = { ...base };
|
|
201
|
+
if (ann.identity)
|
|
202
|
+
out[ann.identity] = name;
|
|
203
|
+
if (ann.transport) {
|
|
204
|
+
const hint = WELL_KNOWN_TRANSPORT[name];
|
|
205
|
+
if (hint)
|
|
206
|
+
out[ann.transport] = hint;
|
|
207
|
+
}
|
|
208
|
+
if (ann.sourceLocations) {
|
|
209
|
+
const src = ann.sources[name];
|
|
210
|
+
if (src)
|
|
211
|
+
out[ann.sourceLocations] = formatSource(src);
|
|
212
|
+
}
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
function annotateNamedDefinition(schema, name, ann) {
|
|
216
|
+
if (!ann.identity && !ann.sourceLocations)
|
|
217
|
+
return schema;
|
|
218
|
+
const out = { ...schema };
|
|
219
|
+
if (ann.identity && out[ann.identity] === undefined) {
|
|
220
|
+
out[ann.identity] = name;
|
|
221
|
+
}
|
|
222
|
+
if (ann.sourceLocations) {
|
|
223
|
+
const src = ann.sources[name];
|
|
224
|
+
if (src && out[ann.sourceLocations] === undefined) {
|
|
225
|
+
out[ann.sourceLocations] = formatSource(src);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
function formatSource(src) {
|
|
231
|
+
return `${src.file}:${src.line}:${src.column}`;
|
|
232
|
+
}
|
|
233
|
+
function pickOverloads(overloads, strategy) {
|
|
234
|
+
if (overloads.length === 0)
|
|
235
|
+
return overloads;
|
|
236
|
+
switch (strategy) {
|
|
237
|
+
case "first":
|
|
238
|
+
return [overloads[0]];
|
|
239
|
+
case "last":
|
|
240
|
+
return [overloads[overloads.length - 1]];
|
|
241
|
+
case "all":
|
|
242
|
+
case "merge":
|
|
243
|
+
return overloads;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function virtualFileFor(fn) {
|
|
247
|
+
const dir = virtualDirFor(fn.sourceFilePath);
|
|
248
|
+
const baseName = path.basename(fn.sourceFilePath, path.extname(fn.sourceFilePath));
|
|
249
|
+
const member = fn.kind === "method" && fn.className
|
|
250
|
+
? `${fn.className}_${fn.name}`
|
|
251
|
+
: fn.name;
|
|
252
|
+
return path.join(dir, `${baseName}_${member}.virtual.ts`);
|
|
253
|
+
}
|
|
254
|
+
function renderVirtualSource(overloads, maxArity, signature, wellKnownNames) {
|
|
255
|
+
const allImports = overloads.flatMap((o) => [
|
|
256
|
+
...o.parameters.flatMap((p) => p.alias.imports),
|
|
257
|
+
...o.returnAlias.imports,
|
|
258
|
+
]);
|
|
259
|
+
const importBlock = renderImports(allImports);
|
|
260
|
+
const lines = [];
|
|
261
|
+
if (importBlock)
|
|
262
|
+
lines.push(importBlock);
|
|
263
|
+
for (const name of wellKnownNames) {
|
|
264
|
+
lines.push(renderSentinelDeclaration(name));
|
|
265
|
+
}
|
|
266
|
+
for (let i = 0; i < maxArity; i++) {
|
|
267
|
+
const variants = overloads.map((o) => paramExpr(o.parameters[i], signature));
|
|
268
|
+
lines.push(`export type ${INPUT_PREFIX}${i} = ${union(variants)};`);
|
|
269
|
+
}
|
|
270
|
+
const outVariants = overloads.map((o) => signature.unwrapPromise
|
|
271
|
+
? `Awaited<${o.returnAlias.text}>`
|
|
272
|
+
: o.returnAlias.text);
|
|
273
|
+
lines.push(`export type ${OUTPUT_NAME} = ${union(outVariants)};`);
|
|
274
|
+
return `${lines.join("\n")}\n`;
|
|
275
|
+
}
|
|
276
|
+
function paramExpr(p, _signature) {
|
|
277
|
+
if (!p)
|
|
278
|
+
return "undefined";
|
|
279
|
+
const base = p.alias.text;
|
|
280
|
+
if (p.optional)
|
|
281
|
+
return `(${base}) | undefined`;
|
|
282
|
+
return `(${base})`;
|
|
283
|
+
}
|
|
284
|
+
function union(parts) {
|
|
285
|
+
const unique = Array.from(new Set(parts));
|
|
286
|
+
if (unique.length === 1)
|
|
287
|
+
return unique[0];
|
|
288
|
+
return unique.join(" | ");
|
|
289
|
+
}
|
|
290
|
+
function buildGeneratorConfig(virtualPath, schema) {
|
|
291
|
+
return {
|
|
292
|
+
...DEFAULT_CONFIG,
|
|
293
|
+
path: virtualPath,
|
|
294
|
+
type: "*",
|
|
295
|
+
expose: schema.expose,
|
|
296
|
+
topRef: schema.topRef,
|
|
297
|
+
additionalProperties: schema.additionalProperties,
|
|
298
|
+
encodeRefs: schema.encodeRefs,
|
|
299
|
+
schemaId: "",
|
|
300
|
+
jsDoc: "extended",
|
|
301
|
+
sortProps: true,
|
|
302
|
+
strictTuples: false,
|
|
303
|
+
skipTypeCheck: true,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function stripWrapper(schema) {
|
|
307
|
+
const { definitions: _d, $schema: _s, ...rest } = schema;
|
|
308
|
+
return rest;
|
|
309
|
+
}
|
|
310
|
+
function mergeDefinitions(target, source) {
|
|
311
|
+
if (!source)
|
|
312
|
+
return;
|
|
313
|
+
for (const [k, v] of Object.entries(source)) {
|
|
314
|
+
// JSON Schema allows `true`/`false` as a definition shorthand.
|
|
315
|
+
if (typeof v === "boolean") {
|
|
316
|
+
target[k] = v ? {} : { not: {} };
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
target[k] = v;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function objectFromParams(params, schemas) {
|
|
324
|
+
const properties = {};
|
|
325
|
+
const required = [];
|
|
326
|
+
for (let idx = 0; idx < params.length; idx++) {
|
|
327
|
+
const entry = params[idx];
|
|
328
|
+
if (!entry)
|
|
329
|
+
continue;
|
|
330
|
+
const schema = schemas[idx];
|
|
331
|
+
if (!schema)
|
|
332
|
+
continue;
|
|
333
|
+
properties[entry.name] = schema;
|
|
334
|
+
if (!entry.optional)
|
|
335
|
+
required.push(entry.name);
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
type: "object",
|
|
339
|
+
properties,
|
|
340
|
+
required,
|
|
341
|
+
additionalProperties: false,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,cAAc,EAEd,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,aAAa,GAEd,MAAM,cAAc,CAAC;AAMtB,OAAO,EACL,cAAc,EACd,yBAAyB,EAEzB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AACnD,MAAM,YAAY,GAAG,OAAO,CAAC;AAC7B,MAAM,WAAW,GAAG,SAAS,CAAC;AAS9B,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC;AAC1D,CA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AAC;QAC5B,IAAI,CAAC,MAAM;YAAE,SAAS;QACtB,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,QAAQ;QACR,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSONSchema } from "@ir-kit/fn-schema-core";
|
|
2
|
+
export declare const SENTINEL_KEY = "__fn_schema_marker";
|
|
3
|
+
export declare const WELL_KNOWN_SCHEMAS: Record<string, JSONSchema>;
|
|
4
|
+
export declare const WELL_KNOWN_NAMES: ReadonlySet<string>;
|
|
5
|
+
export declare const NOT_REPRESENTABLE: ReadonlySet<string>;
|
|
6
|
+
/** Built-in mappings that lose information — paired with a reason for the diagnostic. */
|
|
7
|
+
export declare const LOSSY_REASONS: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Wire-format hint per TS type. `multipart` = raw upload; `base64` = JSON
|
|
10
|
+
* payload; `json` = already JSON. Drives the `transport` extension keyword.
|
|
11
|
+
*/
|
|
12
|
+
export type TransportHint = "multipart" | "base64" | "json";
|
|
13
|
+
export declare const WELL_KNOWN_TRANSPORT: Record<string, TransportHint>;
|
|
14
|
+
export declare function sentinelTypeAlias(name: string): string;
|
|
15
|
+
export declare function renderSentinelDeclaration(name: string): string;
|
|
16
|
+
export declare function detectSentinel(schema: unknown): string | null;
|
|
17
|
+
//# sourceMappingURL=well-known.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"well-known.d.ts","sourceRoot":"","sources":["../src/well-known.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,eAAO,MAAM,YAAY,uBAAuB,CAAC;AAEjD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAWzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAEhD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAIhD,CAAC;AAEH,yFAAyF;AACzF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGhD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAM9D,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQ7D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const SENTINEL_KEY = "__fn_schema_marker";
|
|
2
|
+
export const WELL_KNOWN_SCHEMAS = {
|
|
3
|
+
Date: { type: "string", format: "date-time" },
|
|
4
|
+
URL: { type: "string", format: "uri" },
|
|
5
|
+
RegExp: { type: "string", format: "regex" },
|
|
6
|
+
File: { type: "string", format: "binary" },
|
|
7
|
+
Blob: { type: "string", format: "binary" },
|
|
8
|
+
Buffer: { type: "string", contentEncoding: "base64" },
|
|
9
|
+
Uint8Array: { type: "string", contentEncoding: "base64" },
|
|
10
|
+
ArrayBuffer: { type: "string", contentEncoding: "base64" },
|
|
11
|
+
bigint: { type: "integer" },
|
|
12
|
+
BigInt: { type: "integer" },
|
|
13
|
+
};
|
|
14
|
+
export const WELL_KNOWN_NAMES = new Set(Object.keys(WELL_KNOWN_SCHEMAS));
|
|
15
|
+
export const NOT_REPRESENTABLE = new Set([
|
|
16
|
+
"symbol",
|
|
17
|
+
"Symbol",
|
|
18
|
+
"unique symbol",
|
|
19
|
+
]);
|
|
20
|
+
/** Built-in mappings that lose information — paired with a reason for the diagnostic. */
|
|
21
|
+
export const LOSSY_REASONS = {
|
|
22
|
+
bigint: "JSON numbers cannot represent the full bigint range",
|
|
23
|
+
BigInt: "JSON numbers cannot represent the full bigint range",
|
|
24
|
+
};
|
|
25
|
+
export const WELL_KNOWN_TRANSPORT = {
|
|
26
|
+
File: "multipart",
|
|
27
|
+
Blob: "multipart",
|
|
28
|
+
Buffer: "base64",
|
|
29
|
+
Uint8Array: "base64",
|
|
30
|
+
ArrayBuffer: "base64",
|
|
31
|
+
};
|
|
32
|
+
export function sentinelTypeAlias(name) {
|
|
33
|
+
return `__FnSchemaMap_${name.replace(/[^A-Za-z0-9_]/g, "_")}`;
|
|
34
|
+
}
|
|
35
|
+
export function renderSentinelDeclaration(name) {
|
|
36
|
+
return `type ${sentinelTypeAlias(name)} = { readonly ${SENTINEL_KEY}: "${name}" };`;
|
|
37
|
+
}
|
|
38
|
+
export function detectSentinel(schema) {
|
|
39
|
+
if (!schema || typeof schema !== "object")
|
|
40
|
+
return null;
|
|
41
|
+
const props = schema.properties;
|
|
42
|
+
if (!props || typeof props !== "object")
|
|
43
|
+
return null;
|
|
44
|
+
const marker = props[SENTINEL_KEY];
|
|
45
|
+
if (!marker || typeof marker !== "object")
|
|
46
|
+
return null;
|
|
47
|
+
const constVal = marker.const;
|
|
48
|
+
return typeof constVal === "string" ? constVal : null;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=well-known.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"well-known.js","sourceRoot":"","sources":["../src/well-known.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAA+B;IAC5D,IAA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AU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,iBAAiB,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,OAAO,QAAQ,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,YAAY,MAAM,IAAI,MAAM,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvD,MAAM,KAAK,GAAI,MAAmD,CAAC,UAAU,CAAC;IAC9E,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACrD,MAAM,MAAM,GAAI,KAAiC,CAAC,YAAY,CAAC,CAAC;IAChE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvD,MAAM,QAAQ,GAAI,MAA8B,CAAC,KAAK,CAAC;IACvD,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ir-kit/fn-schema-typescript",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript extractor for fn-schema. Walks source via ts-morph, synthesizes virtual type aliases for each function's parameters and return, then converts them to JSON Schema via ts-json-schema-generator. Re-exports a pre-wired `extract` for single-language use.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"json-schema",
|
|
7
|
+
"typescript",
|
|
8
|
+
"function-signature",
|
|
9
|
+
"ts-morph",
|
|
10
|
+
"codegen"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/ir-kit/ir-kit/tree/main/packages/fn-schema/typescript",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ir-kit/ir-kit/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Ahmed Rowaihi",
|
|
19
|
+
"email": "ahmedrowaihi@gmail.com"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/ir-kit/ir-kit.git",
|
|
24
|
+
"directory": "packages/fn-schema/typescript"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"LICENSE.md"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"provenance": true
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"ts-json-schema-generator": "^2.9.0",
|
|
47
|
+
"ts-morph": "^28.0.0",
|
|
48
|
+
"@ir-kit/fn-schema-core": "0.1.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"typescript": ">=5.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^22",
|
|
55
|
+
"typescript": "5.9.3",
|
|
56
|
+
"vitest": "^4.0.0",
|
|
57
|
+
"@ir-kit/tsconfig": "0.0.0"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=20.19.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc -p tsconfig.build.json",
|
|
64
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
65
|
+
"typecheck": "tsc --noEmit",
|
|
66
|
+
"test": "vitest run --passWithNoTests"
|
|
67
|
+
}
|
|
68
|
+
}
|