@sdk-it/content-mapper 0.0.0-stage → 0.47.3

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/README.md CHANGED
@@ -1,3 +1,97 @@
1
- # Temporary Holding Version
1
+ # @sdk-it/content-mapper
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A TypeScript 7.1 content mapper. When a TypeScript file imports an OpenAPI document, TypeScript runs this package, sends it the document's text, and gets back the SDK of that document as one TypeScript module. The import is typed in `tsc` and in the editor, and go to definition on a model, an endpoint or the client lands in the document.
4
+
5
+ ```ts
6
+ import { type StoreEndpoints, createStore, store } from './store.openapi.yaml';
7
+
8
+ const pet = await store.request('GET /pets/{petId}', { petId: 'p1' });
9
+ ```
10
+
11
+ It gives types only: TypeScript never emits JavaScript for a mapped file. To run the import, the host that runs the code loads the document too: the Vite plugin `sdkIt.imports()` from `@sdk-it/vite`, and in Node this package's loader:
12
+
13
+ ```bash
14
+ node --import @sdk-it/content-mapper/register main.ts
15
+ ```
16
+
17
+ The loader renders a `file:` import that ends with `.openapi.yaml` or `.openapi` and gives Node the module as TypeScript, which Node strips. A document that does not render fails the import with `<file>:<line>:<column>: <message>`. Node's load hook is synchronous, so a worker thread renders while the hook waits (zukhruf #4966 will own that bridge). Each host renders the document with this package's `renderDocument`, so the types and the running code come from one render.
18
+
19
+ ## Render a document in another host
20
+
21
+ ```ts
22
+ import { renderDocument } from '@sdk-it/content-mapper';
23
+
24
+ const rendered = await renderDocument(fileName, content);
25
+ if (rendered.kind === 'failed') {
26
+ // rendered.diagnostics: at least one; each has a code (DiagnosticCode), a message and a range of `content`
27
+ } else {
28
+ // rendered.text: the SDK as one TypeScript module; rendered.mappings: each name and where the document declares it
29
+ }
30
+ // rendered.documents: the URI of each document read, `fileName` first, also when rendering failed
31
+ ```
32
+
33
+ ## Set up a project
34
+
35
+ ```jsonc
36
+ // tsconfig.json
37
+ {
38
+ "compilerOptions": { "module": "nodenext" },
39
+ "contentMappers": [
40
+ { "package": "@sdk-it/content-mapper", "extensions": [".openapi.yaml"] },
41
+ ],
42
+ }
43
+ ```
44
+
45
+ ```bash
46
+ npx tsc --runExternalCode
47
+ ```
48
+
49
+ In the editor, the TypeScript 7.1 language server runs content mappers when its initialization options set `runExternalCode`.
50
+
51
+ The mapper takes no options. The names come from the file name before its first `.`: `store.openapi.yaml` exports `store`, `createStore`, `StoreClient`, `StoreSettings` and `StoreEndpoints`, the names `generate` gives an SDK named `store`.
52
+
53
+ A JSON document needs an extension that does not end in `.json`, such as `.openapi`: TypeScript refuses a mapped extension that ends in `.json` (TS18066). YAML reads JSON text.
54
+
55
+ ## What happens on each import
56
+
57
+ | TypeScript does | the mapper does underneath |
58
+ | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59
+ | starts the mapper with the manifest's `exec`, `node ./dist/server.js` | `runContentMapper` from `ts-content-mapper` answers `initialize` with the position encoding TypeScript offers and the diagnostic source `sdk-it` |
60
+ | sends `transform(fileName, content)`; `content` is the editor's text, unsaved edits included | `parseDocument(content)` from `yaml` keeps each node's range |
61
+ | | `new SpecLoader(Documents.standard([[fileUrl, document]])).load(fileUrl)` from `@sdk-it/spec`: the files the document references through `$ref` are read from disk or http, the document itself is never read again |
62
+ | | `renderModule(spec, { name })` from `@sdk-it/typescript` |
63
+ | | `MappedCodeBuilder` maps each span of the module to the range of what the document declares there: the endpoint key to its method key, a model to its `components.schemas` key, the client and the default instance to the `info.title` value |
64
+ | gets `{ text, extension: '.ts', mappings, diagnostics }` | a span whose location is in another document has no mapping |
65
+
66
+ Mappings are for navigation only: definition, type definition, references, hover and document highlights. A rename never edits the document.
67
+
68
+ ## Diagnostics
69
+
70
+ Each diagnostic is in the document, with the source `sdk-it`, as `error sdk-it<code>`.
71
+
72
+ | code | when | where |
73
+ | ---- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
74
+ | 1 | the YAML does not parse | the range the YAML parser reports, kept inside the text |
75
+ | 2 | a `$ref` does not resolve, or a document it names cannot be read | the `$ref` value when the reference is in this document, else the start of the document |
76
+ | 3 | the SDK cannot be rendered: the file name is not an identifier, a spec name clashes, a security requirement names no scheme | the start of the document |
77
+
78
+ YAML that still parses into a document keeps rendering while you type, with its YAML errors. When a step fails, the module is `export {};`, so each importer sees the missing names until the document is fixed; when the YAML has errors, only they are reported, since the later failure follows from them. `tsc` reports no semantic error of any file while a mapped document has a diagnostic, so the missing names show in the editor, which checks each file on its own.
79
+
80
+ ## Other content mappers
81
+
82
+ | package | maps | built on |
83
+ | -------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------- |
84
+ | `@vue/content-mapper` | `.vue` | Volar language core |
85
+ | `@astrojs/ts-content-mapper` | `.astro` | `vscode-jsonrpc` |
86
+ | `@gql.tada/content-mapper` | `.graphql` (a schema file named in options, `dynamicConfig: true`) | `vscode-jsonrpc` |
87
+ | `@tsrx/content-mapper` | `.tsrx` | its own JSON-RPC |
88
+ | `css-modules-content-mapper`, `mdx-content-mapper`, `ember-content-mapper` | CSS modules, MDX, `.gts`/`.gjs` | `vscode-jsonrpc` |
89
+
90
+ No published content mapper reads OpenAPI (npm search, 2026-11-20). The protocol is `ts-content-mapper`'s: protocol types, the server runner, cancellation and position encodings. TypeScript 7.1 ships the `contentMappers` option and `--runExternalCode`, and no server helper.
91
+
92
+ ## Limits
93
+
94
+ - A change to a file that the document references through `$ref` does not re-type the import until the document itself changes: the protocol has no per-transform dependencies, and `watchedFiles` is read only when a project opens.
95
+ - The module holds every operation of the document, so a bundle ships the whole endpoint table.
96
+ - On a 1,300-operation document an edit takes about 2.5 to 3.5 s to reach the importers (YAML parse about 0.8 s, from the spike).
97
+ - A string argument of `request('GET /pets/{petId}', …)` has no definition (TypeScript gives none for a string literal argument); the same key in a type position, `StoreEndpoints['GET /pets/{petId}']`, lands on the method key.
@@ -0,0 +1,2 @@
1
+ export * from './render-document.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./render-document.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export * from './render-document.js';\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ import { type Document } from 'yaml';
2
+ /** A range of the document's text: JavaScript string indices, `end` exclusive. */
3
+ export interface Range {
4
+ start: number;
5
+ end: number;
6
+ }
7
+ /**
8
+ * Where the document writes what `tokens` (RFC 6901, unescaped) name: a scalar
9
+ * names itself, a map or a list is named by the key that holds it. Undefined
10
+ * when the document has no such value, as for a value another document holds.
11
+ */
12
+ export declare function locate(document: Document, tokens: readonly string[]): Range | undefined;
13
+ //# sourceMappingURL=locate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate.d.ts","sources":["../src/locate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,MAAM,CAAC;AAE7D,kFAAkF;AAClF,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,SAAS,MAAM,EAAE,GACxB,KAAK,GAAG,SAAS,CAyBnB"}
package/dist/locate.js ADDED
@@ -0,0 +1,31 @@
1
+ import { isMap, isScalar, isSeq } from "yaml";
2
+ function locate(document, tokens) {
3
+ let node = document.contents;
4
+ let name;
5
+ for (const token of tokens) {
6
+ if (isMap(node)) {
7
+ const pair = node.items.find(
8
+ (item) => isScalar(item.key) && String(item.key.value) === token
9
+ );
10
+ if (!pair) {
11
+ return void 0;
12
+ }
13
+ name = pair.key;
14
+ node = pair.value;
15
+ } else if (isSeq(node)) {
16
+ name = void 0;
17
+ node = node.items[Number(token)];
18
+ } else {
19
+ return void 0;
20
+ }
21
+ }
22
+ const target = isScalar(node) ? node : name;
23
+ if (!isScalar(target) || !target.range) {
24
+ return void 0;
25
+ }
26
+ return { start: target.range[0], end: target.range[1] };
27
+ }
28
+ export {
29
+ locate
30
+ };
31
+ //# sourceMappingURL=locate.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/locate.ts"],
4
+ "sourcesContent": ["import { type Document, isMap, isScalar, isSeq } from 'yaml';\n\n/** A range of the document's text: JavaScript string indices, `end` exclusive. */\nexport interface Range {\n start: number;\n end: number;\n}\n\n/**\n * Where the document writes what `tokens` (RFC 6901, unescaped) name: a scalar\n * names itself, a map or a list is named by the key that holds it. Undefined\n * when the document has no such value, as for a value another document holds.\n */\nexport function locate(\n document: Document,\n tokens: readonly string[],\n): Range | undefined {\n let node: unknown = document.contents;\n let name: unknown;\n for (const token of tokens) {\n if (isMap(node)) {\n const pair = node.items.find(\n (item) => isScalar(item.key) && String(item.key.value) === token,\n );\n if (!pair) {\n return undefined;\n }\n name = pair.key;\n node = pair.value;\n } else if (isSeq(node)) {\n name = undefined;\n node = node.items[Number(token)];\n } else {\n return undefined;\n }\n }\n const target = isScalar(node) ? node : name;\n if (!isScalar(target) || !target.range) {\n return undefined;\n }\n return { start: target.range[0], end: target.range[1] };\n}\n"],
5
+ "mappings": "AAAA,SAAwB,OAAO,UAAU,aAAa;AAa/C,SAAS,OACd,UACA,QACmB;AACnB,MAAI,OAAgB,SAAS;AAC7B,MAAI;AACJ,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,IAAI,GAAG;AACf,YAAM,OAAO,KAAK,MAAM;AAAA,QACtB,CAAC,SAAS,SAAS,KAAK,GAAG,KAAK,OAAO,KAAK,IAAI,KAAK,MAAM;AAAA,MAC7D;AACA,UAAI,CAAC,MAAM;AACT,eAAO;AAAA,MACT;AACA,aAAO,KAAK;AACZ,aAAO,KAAK;AAAA,IACd,WAAW,MAAM,IAAI,GAAG;AACtB,aAAO;AACP,aAAO,KAAK,MAAM,OAAO,KAAK,CAAC;AAAA,IACjC,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,SAAS,SAAS,IAAI,IAAI,OAAO;AACvC,MAAI,CAAC,SAAS,MAAM,KAAK,CAAC,OAAO,OAAO;AACtC,WAAO;AAAA,EACT;AACA,SAAO,EAAE,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,OAAO,MAAM,CAAC,EAAE;AACxD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sources":["../src/register.ts"],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { registerHooks } from "node:module";
3
+ import { fileURLToPath } from "node:url";
4
+ import {
5
+ MessageChannel,
6
+ Worker,
7
+ receiveMessageOnPort
8
+ } from "node:worker_threads";
9
+ const signal = new Int32Array(new SharedArrayBuffer(4));
10
+ const { port1, port2 } = new MessageChannel();
11
+ const worker = new Worker(new URL("./render-worker.js", import.meta.url), {
12
+ // Without this the worker inherits --import and registers itself again.
13
+ execArgv: [],
14
+ workerData: { signal, port: port2 },
15
+ transferList: [port2]
16
+ });
17
+ worker.unref();
18
+ port1.unref();
19
+ const isDocument = (path) => path.endsWith(".openapi.yaml") || path.endsWith(".openapi");
20
+ function render(fileName) {
21
+ const content = readFileSync(fileName, "utf8");
22
+ Atomics.store(signal, 0, 0);
23
+ port1.postMessage({ fileName, content });
24
+ Atomics.wait(signal, 0, 0);
25
+ const reply = receiveMessageOnPort(port1)?.message;
26
+ if ("error" in reply) {
27
+ throw new Error(`${fileName}: ${reply.error}`);
28
+ }
29
+ const { rendered } = reply;
30
+ const [problem] = rendered.diagnostics;
31
+ if (problem) {
32
+ const before = content.slice(0, problem.range.start);
33
+ const line = before.split("\n").length;
34
+ const column = problem.range.start - (before.lastIndexOf("\n") + 1) + 1;
35
+ throw new SyntaxError(`${fileName}:${line}:${column}: ${problem.message}`);
36
+ }
37
+ if (rendered.kind === "failed") {
38
+ throw new Error(`${fileName}: the document did not render`);
39
+ }
40
+ return rendered.text;
41
+ }
42
+ registerHooks({
43
+ load(url, context, nextLoad) {
44
+ if (!url.startsWith("file:") || !isDocument(fileURLToPath(url))) {
45
+ return nextLoad(url, context);
46
+ }
47
+ return {
48
+ format: "module-typescript",
49
+ source: render(fileURLToPath(url)),
50
+ shortCircuit: true
51
+ };
52
+ }
53
+ });
54
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/register.ts"],
4
+ "sourcesContent": ["import { readFileSync } from 'node:fs';\nimport { registerHooks } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport {\n MessageChannel,\n Worker,\n receiveMessageOnPort,\n} from 'node:worker_threads';\n\nimport type { RenderedDocument } from './render-document.js';\n\n// Node's load hook is synchronous and renderDocument is async, so a worker\n// renders while this thread waits (zukhruf #4966 will own this bridge, sdk-it #4967).\nconst signal = new Int32Array(new SharedArrayBuffer(4));\nconst { port1, port2 } = new MessageChannel();\nconst worker = new Worker(new URL('./render-worker.js', import.meta.url), {\n // Without this the worker inherits --import and registers itself again.\n execArgv: [],\n workerData: { signal, port: port2 },\n transferList: [port2],\n});\nworker.unref();\nport1.unref();\n\nconst isDocument = (path: string) =>\n path.endsWith('.openapi.yaml') || path.endsWith('.openapi');\n\nfunction render(fileName: string) {\n const content = readFileSync(fileName, 'utf8');\n Atomics.store(signal, 0, 0);\n port1.postMessage({ fileName, content });\n Atomics.wait(signal, 0, 0);\n const reply: { rendered: RenderedDocument } | { error: string } =\n receiveMessageOnPort(port1)?.message;\n if ('error' in reply) {\n throw new Error(`${fileName}: ${reply.error}`);\n }\n const { rendered } = reply;\n const [problem] = rendered.diagnostics;\n if (problem) {\n const before = content.slice(0, problem.range.start);\n const line = before.split('\\n').length;\n const column = problem.range.start - (before.lastIndexOf('\\n') + 1) + 1;\n throw new SyntaxError(`${fileName}:${line}:${column}: ${problem.message}`);\n }\n if (rendered.kind === 'failed') {\n throw new Error(`${fileName}: the document did not render`);\n }\n return rendered.text;\n}\n\nregisterHooks({\n load(url, context, nextLoad) {\n if (!url.startsWith('file:') || !isDocument(fileURLToPath(url))) {\n return nextLoad(url, context);\n }\n return {\n format: 'module-typescript',\n source: render(fileURLToPath(url)),\n shortCircuit: true,\n };\n },\n});\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,MAAM,SAAS,IAAI,WAAW,IAAI,kBAAkB,CAAC,CAAC;AACtD,MAAM,EAAE,OAAO,MAAM,IAAI,IAAI,eAAe;AAC5C,MAAM,SAAS,IAAI,OAAO,IAAI,IAAI,sBAAsB,YAAY,GAAG,GAAG;AAAA;AAAA,EAExE,UAAU,CAAC;AAAA,EACX,YAAY,EAAE,QAAQ,MAAM,MAAM;AAAA,EAClC,cAAc,CAAC,KAAK;AACtB,CAAC;AACD,OAAO,MAAM;AACb,MAAM,MAAM;AAEZ,MAAM,aAAa,CAAC,SAClB,KAAK,SAAS,eAAe,KAAK,KAAK,SAAS,UAAU;AAE5D,SAAS,OAAO,UAAkB;AAChC,QAAM,UAAU,aAAa,UAAU,MAAM;AAC7C,UAAQ,MAAM,QAAQ,GAAG,CAAC;AAC1B,QAAM,YAAY,EAAE,UAAU,QAAQ,CAAC;AACvC,UAAQ,KAAK,QAAQ,GAAG,CAAC;AACzB,QAAM,QACJ,qBAAqB,KAAK,GAAG;AAC/B,MAAI,WAAW,OAAO;AACpB,UAAM,IAAI,MAAM,GAAG,QAAQ,KAAK,MAAM,KAAK,EAAE;AAAA,EAC/C;AACA,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,CAAC,OAAO,IAAI,SAAS;AAC3B,MAAI,SAAS;AACX,UAAM,SAAS,QAAQ,MAAM,GAAG,QAAQ,MAAM,KAAK;AACnD,UAAM,OAAO,OAAO,MAAM,IAAI,EAAE;AAChC,UAAM,SAAS,QAAQ,MAAM,SAAS,OAAO,YAAY,IAAI,IAAI,KAAK;AACtE,UAAM,IAAI,YAAY,GAAG,QAAQ,IAAI,IAAI,IAAI,MAAM,KAAK,QAAQ,OAAO,EAAE;AAAA,EAC3E;AACA,MAAI,SAAS,SAAS,UAAU;AAC9B,UAAM,IAAI,MAAM,GAAG,QAAQ,+BAA+B;AAAA,EAC5D;AACA,SAAO,SAAS;AAClB;AAEA,cAAc;AAAA,EACZ,KAAK,KAAK,SAAS,UAAU;AAC3B,QAAI,CAAC,IAAI,WAAW,OAAO,KAAK,CAAC,WAAW,cAAc,GAAG,CAAC,GAAG;AAC/D,aAAO,SAAS,KAAK,OAAO;AAAA,IAC9B;AACA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ,OAAO,cAAc,GAAG,CAAC;AAAA,MACjC,cAAc;AAAA,IAChB;AAAA,EACF;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,52 @@
1
+ import { type Range } from './locate.js';
2
+ export type { Range } from './locate.js';
3
+ /** The code of each diagnostic a document can have. */
4
+ export declare const DiagnosticCode: {
5
+ /** The text is not YAML. */
6
+ readonly Yaml: 1;
7
+ /** A `$ref` does not resolve, or a document it names cannot be read. */
8
+ readonly Load: 2;
9
+ /** The SDK cannot be rendered from the spec. */
10
+ readonly Render: 3;
11
+ };
12
+ type Code = (typeof DiagnosticCode)[keyof typeof DiagnosticCode];
13
+ /** A problem in the document, at `range` of its text. */
14
+ export interface DocumentDiagnostic {
15
+ readonly code: Code;
16
+ readonly message: string;
17
+ readonly range: Range;
18
+ }
19
+ /** A name of the module, at `generated` of its text, and what the document declares there, at `original` of the document's text. */
20
+ export interface DocumentMapping {
21
+ readonly generated: Range;
22
+ readonly original: Range;
23
+ }
24
+ /**
25
+ * The SDK an OpenAPI document renders to. `documents` is the URI of each
26
+ * document read, the document first, also when rendering failed, so a host
27
+ * can watch a referenced file that does not exist yet.
28
+ */
29
+ export type RenderedDocument = {
30
+ readonly kind: 'module';
31
+ /** One TypeScript module: the SDK's root exports, the runtime embedded. */
32
+ readonly text: string;
33
+ readonly mappings: readonly DocumentMapping[];
34
+ readonly documents: readonly string[];
35
+ /** YAML errors of a document that still parsed into a spec. */
36
+ readonly diagnostics: readonly DocumentDiagnostic[];
37
+ } | {
38
+ readonly kind: 'failed';
39
+ readonly documents: readonly string[];
40
+ readonly diagnostics: readonly [
41
+ DocumentDiagnostic,
42
+ ...DocumentDiagnostic[]
43
+ ];
44
+ };
45
+ /**
46
+ * Renders the OpenAPI document `content`, the text of `fileName`, to its SDK.
47
+ * The names come from the file name before its first `.`: `store.openapi.yaml`
48
+ * exports `store`, `createStore`, `StoreClient`, …. Files the document
49
+ * references through `$ref` are read; the document itself is not.
50
+ */
51
+ export declare function renderDocument(fileName: string, content: string): Promise<RenderedDocument>;
52
+ //# sourceMappingURL=render-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-document.d.ts","sources":["../src/render-document.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAU,MAAM,aAAa,CAAC;AAEjD,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,uDAAuD;AACvD,eAAO,MAAM,cAAc;IACzB,4BAA4B;aAC5B,IAAI,EAAE,CAAC;IACP,wEAAwE;aACxE,IAAI,EAAE,CAAC;IACP,gDAAgD;aAChD,MAAM,EAAE,CAAC;CACD,CAAC;AAEX,KAAK,IAAI,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEjE,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED,oIAAoI;AACpI,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACrD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,SAAS;QAC7B,kBAAkB;QAClB,GAAG,kBAAkB,EAAE;KACxB,CAAC;CACH,CAAC;AAIN;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CA2D3B"}
@@ -0,0 +1,93 @@
1
+ import { basename } from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+ import { parseDocument } from "yaml";
4
+ import { Documents, SpecLoader, UnresolvedReferenceError } from "@sdk-it/spec";
5
+ import { renderModule } from "@sdk-it/typescript";
6
+ import { locate } from "./locate.js";
7
+ const DiagnosticCode = {
8
+ /** The text is not YAML. */
9
+ Yaml: 1,
10
+ /** A `$ref` does not resolve, or a document it names cannot be read. */
11
+ Load: 2,
12
+ /** The SDK cannot be rendered from the spec. */
13
+ Render: 3
14
+ };
15
+ const fileStart = { start: 0, end: 0 };
16
+ async function renderDocument(fileName, content) {
17
+ const document = parseDocument(content);
18
+ const yamlErrors = document.errors.map(
19
+ (error) => diagnostic(content, DiagnosticCode.Yaml, error.message, {
20
+ start: error.pos[0],
21
+ end: error.pos[1]
22
+ })
23
+ );
24
+ const url = pathToFileURL(fileName);
25
+ const documents = Documents.standard([[url, document.toJS()]]);
26
+ const fail = (code, error, range) => {
27
+ const [first, ...rest] = yamlErrors;
28
+ return {
29
+ kind: "failed",
30
+ documents: documents.uris(),
31
+ // A later step that fails on YAML with errors fails because of them.
32
+ diagnostics: first ? [first, ...rest] : [diagnostic(content, code, reason(error), range)]
33
+ };
34
+ };
35
+ let spec;
36
+ try {
37
+ spec = await new SpecLoader(documents).load(url);
38
+ } catch (error) {
39
+ return fail(
40
+ DiagnosticCode.Load,
41
+ error,
42
+ referenceRange(error, url, document)
43
+ );
44
+ }
45
+ let module;
46
+ try {
47
+ module = await renderModule(spec, { name: clientName(fileName) });
48
+ } catch (error) {
49
+ return fail(DiagnosticCode.Render, error, fileStart);
50
+ }
51
+ const mappings = [];
52
+ let cursor = 0;
53
+ for (const span of module.spans.toSorted((a, b) => a.start - b.start)) {
54
+ const original = span.start >= cursor ? locate(document, span.location) : void 0;
55
+ if (original) {
56
+ mappings.push({
57
+ generated: { start: span.start, end: span.end },
58
+ original
59
+ });
60
+ cursor = span.end;
61
+ }
62
+ }
63
+ return {
64
+ kind: "module",
65
+ text: module.text,
66
+ mappings,
67
+ documents: documents.uris(),
68
+ diagnostics: yamlErrors
69
+ };
70
+ }
71
+ function clientName(fileName) {
72
+ const [name = ""] = basename(fileName).split(".");
73
+ return name;
74
+ }
75
+ function referenceRange(error, url, document) {
76
+ if (error instanceof UnresolvedReferenceError && error.location.document === url.href) {
77
+ return locate(document, [...error.location.tokens, "$ref"]) ?? fileStart;
78
+ }
79
+ return fileStart;
80
+ }
81
+ function diagnostic(content, code, message, range) {
82
+ const start = Math.min(range.start, content.length);
83
+ const end = Math.min(Math.max(range.end, start), content.length);
84
+ return { code, message, range: { start, end } };
85
+ }
86
+ function reason(error) {
87
+ return Error.isError(error) ? error.message : String(error);
88
+ }
89
+ export {
90
+ DiagnosticCode,
91
+ renderDocument
92
+ };
93
+ //# sourceMappingURL=render-document.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/render-document.ts"],
4
+ "sourcesContent": ["import { basename } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type Document, parseDocument } from 'yaml';\n\nimport { Documents, SpecLoader, UnresolvedReferenceError } from '@sdk-it/spec';\nimport { renderModule } from '@sdk-it/typescript';\n\nimport { type Range, locate } from './locate.js';\n\nexport type { Range } from './locate.js';\n\n/** The code of each diagnostic a document can have. */\nexport const DiagnosticCode = {\n /** The text is not YAML. */\n Yaml: 1,\n /** A `$ref` does not resolve, or a document it names cannot be read. */\n Load: 2,\n /** The SDK cannot be rendered from the spec. */\n Render: 3,\n} as const;\n\ntype Code = (typeof DiagnosticCode)[keyof typeof DiagnosticCode];\n\n/** A problem in the document, at `range` of its text. */\nexport interface DocumentDiagnostic {\n readonly code: Code;\n readonly message: string;\n readonly range: Range;\n}\n\n/** A name of the module, at `generated` of its text, and what the document declares there, at `original` of the document's text. */\nexport interface DocumentMapping {\n readonly generated: Range;\n readonly original: Range;\n}\n\n/**\n * The SDK an OpenAPI document renders to. `documents` is the URI of each\n * document read, the document first, also when rendering failed, so a host\n * can watch a referenced file that does not exist yet.\n */\nexport type RenderedDocument =\n | {\n readonly kind: 'module';\n /** One TypeScript module: the SDK's root exports, the runtime embedded. */\n readonly text: string;\n readonly mappings: readonly DocumentMapping[];\n readonly documents: readonly string[];\n /** YAML errors of a document that still parsed into a spec. */\n readonly diagnostics: readonly DocumentDiagnostic[];\n }\n | {\n readonly kind: 'failed';\n readonly documents: readonly string[];\n readonly diagnostics: readonly [\n DocumentDiagnostic,\n ...DocumentDiagnostic[],\n ];\n };\n\nconst fileStart: Range = { start: 0, end: 0 };\n\n/**\n * Renders the OpenAPI document `content`, the text of `fileName`, to its SDK.\n * The names come from the file name before its first `.`: `store.openapi.yaml`\n * exports `store`, `createStore`, `StoreClient`, \u2026. Files the document\n * references through `$ref` are read; the document itself is not.\n */\nexport async function renderDocument(\n fileName: string,\n content: string,\n): Promise<RenderedDocument> {\n const document = parseDocument(content);\n const yamlErrors = document.errors.map((error) =>\n diagnostic(content, DiagnosticCode.Yaml, error.message, {\n start: error.pos[0],\n end: error.pos[1],\n }),\n );\n const url = pathToFileURL(fileName);\n const documents = Documents.standard([[url, document.toJS()]]);\n const fail = (code: Code, error: unknown, range: Range): RenderedDocument => {\n const [first, ...rest] = yamlErrors;\n return {\n kind: 'failed',\n documents: documents.uris(),\n // A later step that fails on YAML with errors fails because of them.\n diagnostics: first\n ? [first, ...rest]\n : [diagnostic(content, code, reason(error), range)],\n };\n };\n\n let spec;\n try {\n spec = await new SpecLoader(documents).load(url);\n } catch (error) {\n return fail(\n DiagnosticCode.Load,\n error,\n referenceRange(error, url, document),\n );\n }\n let module;\n try {\n module = await renderModule(spec, { name: clientName(fileName) });\n } catch (error) {\n return fail(DiagnosticCode.Render, error, fileStart);\n }\n\n const mappings: DocumentMapping[] = [];\n let cursor = 0;\n for (const span of module.spans.toSorted((a, b) => a.start - b.start)) {\n const original =\n span.start >= cursor ? locate(document, span.location) : undefined;\n if (original) {\n mappings.push({\n generated: { start: span.start, end: span.end },\n original,\n });\n cursor = span.end;\n }\n }\n return {\n kind: 'module',\n text: module.text,\n mappings,\n documents: documents.uris(),\n diagnostics: yamlErrors,\n };\n}\n\nfunction clientName(fileName: string) {\n const [name = ''] = basename(fileName).split('.');\n return name;\n}\n\nfunction referenceRange(error: unknown, url: URL, document: Document): Range {\n if (\n error instanceof UnresolvedReferenceError &&\n error.location.document === url.href\n ) {\n return locate(document, [...error.location.tokens, '$ref']) ?? fileStart;\n }\n return fileStart;\n}\n\nfunction diagnostic(\n content: string,\n code: Code,\n message: string,\n range: Range,\n): DocumentDiagnostic {\n // A parser can report a range past the end of the text, which TypeScript refuses.\n const start = Math.min(range.start, content.length);\n const end = Math.min(Math.max(range.end, start), content.length);\n return { code, message, range: { start, end } };\n}\n\nfunction reason(error: unknown) {\n return Error.isError(error) ? error.message : String(error);\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-worker.d.ts","sources":["../src/render-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { workerData } from "node:worker_threads";
2
+ import { renderDocument } from "./render-document.js";
3
+ const { signal, port } = workerData;
4
+ async function answer({
5
+ fileName,
6
+ content
7
+ }) {
8
+ try {
9
+ port.postMessage({ rendered: await renderDocument(fileName, content) });
10
+ } catch (error) {
11
+ port.postMessage({
12
+ error: Error.isError(error) ? error.message : String(error)
13
+ });
14
+ }
15
+ Atomics.store(signal, 0, 1);
16
+ Atomics.notify(signal, 0);
17
+ }
18
+ port.on("message", (request) => void answer(request));
19
+ //# sourceMappingURL=render-worker.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/render-worker.ts"],
4
+ "sourcesContent": ["import { type MessagePort, workerData } from 'node:worker_threads';\n\nimport { renderDocument } from './render-document.js';\n\nconst { signal, port }: { signal: Int32Array; port: MessagePort } = workerData;\n\nasync function answer({\n fileName,\n content,\n}: {\n fileName: string;\n content: string;\n}) {\n try {\n port.postMessage({ rendered: await renderDocument(fileName, content) });\n } catch (error) {\n port.postMessage({\n error: Error.isError(error) ? error.message : String(error),\n });\n }\n Atomics.store(signal, 0, 1);\n Atomics.notify(signal, 0);\n}\n\nport.on('message', (request) => void answer(request));\n"],
5
+ "mappings": "AAAA,SAA2B,kBAAkB;AAE7C,SAAS,sBAAsB;AAE/B,MAAM,EAAE,QAAQ,KAAK,IAA+C;AAEpE,eAAe,OAAO;AAAA,EACpB;AAAA,EACA;AACF,GAGG;AACD,MAAI;AACF,SAAK,YAAY,EAAE,UAAU,MAAM,eAAe,UAAU,OAAO,EAAE,CAAC;AAAA,EACxE,SAAS,OAAO;AACd,SAAK,YAAY;AAAA,MACf,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,UAAU,OAAO,KAAK;AAAA,IAC5D,CAAC;AAAA,EACH;AACA,UAAQ,MAAM,QAAQ,GAAG,CAAC;AAC1B,UAAQ,OAAO,QAAQ,CAAC;AAC1B;AAEA,KAAK,GAAG,WAAW,CAAC,YAAY,KAAK,OAAO,OAAO,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sources":["../src/server.ts"],"names":[],"mappings":""}
package/dist/server.js ADDED
@@ -0,0 +1,7 @@
1
+ import { runContentMapper } from "ts-content-mapper";
2
+ import { transform } from "./transform.js";
3
+ runContentMapper({
4
+ diagnosticSource: "sdk-it",
5
+ transform: ({ fileName, content }, context) => transform(fileName, content, context.positionEncoding)
6
+ });
7
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/server.ts"],
4
+ "sourcesContent": ["import { runContentMapper } from 'ts-content-mapper';\n\nimport { transform } from './transform.js';\n\nrunContentMapper({\n diagnosticSource: 'sdk-it',\n transform: ({ fileName, content }, context) =>\n transform(fileName, content, context.positionEncoding),\n});\n"],
5
+ "mappings": "AAAA,SAAS,wBAAwB;AAEjC,SAAS,iBAAiB;AAE1B,iBAAiB;AAAA,EACf,kBAAkB;AAAA,EAClB,WAAW,CAAC,EAAE,UAAU,QAAQ,GAAG,YACjC,UAAU,UAAU,SAAS,QAAQ,gBAAgB;AACzD,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ import { type PositionEncoding, type TransformResult } from 'ts-content-mapper';
2
+ /**
3
+ * The content mapper's answer for the OpenAPI document `content`, the text of
4
+ * `fileName`: its SDK module with each name mapped to the document, or an
5
+ * empty module, and the document's diagnostics, in the negotiated encoding.
6
+ */
7
+ export declare function transform(fileName: string, content: string, encoding: PositionEncoding): Promise<TransformResult>;
8
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EAErB,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAW3B;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC,CAyB1B"}
@@ -0,0 +1,45 @@
1
+ import {
2
+ MappedCodeBuilder,
3
+ SpanMapFeature,
4
+ stringIndexToPosition
5
+ } from "ts-content-mapper";
6
+ import { renderDocument } from "./render-document.js";
7
+ const navigation = SpanMapFeature.Definition | SpanMapFeature.TypeDefinition | SpanMapFeature.References | SpanMapFeature.Hover | SpanMapFeature.DocumentHighlights;
8
+ async function transform(fileName, content, encoding) {
9
+ const rendered = await renderDocument(fileName, content);
10
+ const diagnostics = rendered.diagnostics.map(
11
+ (diagnostic) => encode(content, encoding, diagnostic)
12
+ );
13
+ if (rendered.kind === "failed") {
14
+ return { text: "export {};\n", extension: ".ts", diagnostics };
15
+ }
16
+ const builder = new MappedCodeBuilder(content, {
17
+ positionEncoding: encoding
18
+ });
19
+ let cursor = 0;
20
+ for (const { generated, original } of rendered.mappings) {
21
+ builder.append(rendered.text.slice(cursor, generated.start));
22
+ builder.appendAtom(
23
+ rendered.text.slice(generated.start, generated.end),
24
+ original.start,
25
+ original.end,
26
+ navigation
27
+ );
28
+ cursor = generated.end;
29
+ }
30
+ builder.append(rendered.text.slice(cursor));
31
+ return { ...builder.build(".ts"), diagnostics };
32
+ }
33
+ function encode(content, encoding, { code, message, range }) {
34
+ const start = stringIndexToPosition(content, range.start, encoding);
35
+ return {
36
+ code,
37
+ messageText: message,
38
+ start,
39
+ length: stringIndexToPosition(content, range.end, encoding) - start
40
+ };
41
+ }
42
+ export {
43
+ transform
44
+ };
45
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/transform.ts"],
4
+ "sourcesContent": ["import {\n type ContentMapperDiagnostic,\n MappedCodeBuilder,\n type PositionEncoding,\n SpanMapFeature,\n type TransformResult,\n stringIndexToPosition,\n} from 'ts-content-mapper';\n\nimport { type DocumentDiagnostic, renderDocument } from './render-document.js';\n\nconst navigation =\n SpanMapFeature.Definition |\n SpanMapFeature.TypeDefinition |\n SpanMapFeature.References |\n SpanMapFeature.Hover |\n SpanMapFeature.DocumentHighlights;\n\n/**\n * The content mapper's answer for the OpenAPI document `content`, the text of\n * `fileName`: its SDK module with each name mapped to the document, or an\n * empty module, and the document's diagnostics, in the negotiated encoding.\n */\nexport async function transform(\n fileName: string,\n content: string,\n encoding: PositionEncoding,\n): Promise<TransformResult> {\n const rendered = await renderDocument(fileName, content);\n const diagnostics = rendered.diagnostics.map((diagnostic) =>\n encode(content, encoding, diagnostic),\n );\n if (rendered.kind === 'failed') {\n return { text: 'export {};\\n', extension: '.ts', diagnostics };\n }\n\n const builder = new MappedCodeBuilder(content, {\n positionEncoding: encoding,\n });\n let cursor = 0;\n for (const { generated, original } of rendered.mappings) {\n builder.append(rendered.text.slice(cursor, generated.start));\n builder.appendAtom(\n rendered.text.slice(generated.start, generated.end),\n original.start,\n original.end,\n navigation,\n );\n cursor = generated.end;\n }\n builder.append(rendered.text.slice(cursor));\n return { ...builder.build('.ts'), diagnostics };\n}\n\nfunction encode(\n content: string,\n encoding: PositionEncoding,\n { code, message, range }: DocumentDiagnostic,\n): ContentMapperDiagnostic {\n const start = stringIndexToPosition(content, range.start, encoding);\n return {\n code,\n messageText: message,\n start,\n length: stringIndexToPosition(content, range.end, encoding) - start,\n };\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEE;AAAA,EAEA;AAAA,EAEA;AAAA,OACK;AAEP,SAAkC,sBAAsB;AAExD,MAAM,aACJ,eAAe,aACf,eAAe,iBACf,eAAe,aACf,eAAe,QACf,eAAe;AAOjB,eAAsB,UACpB,UACA,SACA,UAC0B;AAC1B,QAAM,WAAW,MAAM,eAAe,UAAU,OAAO;AACvD,QAAM,cAAc,SAAS,YAAY;AAAA,IAAI,CAAC,eAC5C,OAAO,SAAS,UAAU,UAAU;AAAA,EACtC;AACA,MAAI,SAAS,SAAS,UAAU;AAC9B,WAAO,EAAE,MAAM,gBAAgB,WAAW,OAAO,YAAY;AAAA,EAC/D;AAEA,QAAM,UAAU,IAAI,kBAAkB,SAAS;AAAA,IAC7C,kBAAkB;AAAA,EACpB,CAAC;AACD,MAAI,SAAS;AACb,aAAW,EAAE,WAAW,SAAS,KAAK,SAAS,UAAU;AACvD,YAAQ,OAAO,SAAS,KAAK,MAAM,QAAQ,UAAU,KAAK,CAAC;AAC3D,YAAQ;AAAA,MACN,SAAS,KAAK,MAAM,UAAU,OAAO,UAAU,GAAG;AAAA,MAClD,SAAS;AAAA,MACT,SAAS;AAAA,MACT;AAAA,IACF;AACA,aAAS,UAAU;AAAA,EACrB;AACA,UAAQ,OAAO,SAAS,KAAK,MAAM,MAAM,CAAC;AAC1C,SAAO,EAAE,GAAG,QAAQ,MAAM,KAAK,GAAG,YAAY;AAChD;AAEA,SAAS,OACP,SACA,UACA,EAAE,MAAM,SAAS,MAAM,GACE;AACzB,QAAM,QAAQ,sBAAsB,SAAS,MAAM,OAAO,QAAQ;AAClE,SAAO;AAAA,IACL;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA,QAAQ,sBAAsB,SAAS,MAAM,KAAK,QAAQ,IAAI;AAAA,EAChE;AACF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@sdk-it/content-mapper",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.47.3",
4
+ "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/JanuaryLabs/sdk-it",
8
+ "directory": "packages/content-mapper"
9
+ },
10
+ "homepage": "https://github.com/JanuaryLabs/sdk-it/tree/main/packages/content-mapper#readme",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "exports": {
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./register": {
22
+ "types": "./dist/register.d.ts",
23
+ "import": "./dist/register.js",
24
+ "default": "./dist/register.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "!**/*.tsbuildinfo",
30
+ "!**/*.test.*"
31
+ ],
32
+ "typescript": {
33
+ "contentMapper": {
34
+ "exec": [
35
+ "node",
36
+ "./dist/server.js"
37
+ ],
38
+ "dynamicConfig": false,
39
+ "compilerOptions": []
40
+ }
41
+ },
42
+ "dependencies": {
43
+ "@sdk-it/spec": "0.47.3",
44
+ "@sdk-it/typescript": "0.47.3",
45
+ "ts-content-mapper": "^0.1.1",
46
+ "yaml": "^2.9.1"
47
+ },
48
+ "devDependencies": {
49
+ "@sdk-it/testing": "*",
50
+ "vscode-jsonrpc": "^10.0.0"
51
+ }
52
+ }