@sdk-it/vite 0.47.0 → 0.47.2
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 +22 -3
- package/dist/disk-sdk.d.ts +14 -0
- package/dist/disk-sdk.d.ts.map +1 -0
- package/dist/document-imports.d.ts +11 -0
- package/dist/document-imports.d.ts.map +1 -0
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +261 -143
- package/dist/index.js.map +4 -4
- package/dist/output-folder.d.ts +12 -0
- package/dist/output-folder.d.ts.map +1 -0
- package/dist/project.d.ts +8 -2
- package/dist/project.d.ts.map +1 -1
- package/dist/spec-source.d.ts +35 -0
- package/dist/spec-source.d.ts.map +1 -0
- package/package.json +12 -7
package/README.md
CHANGED
|
@@ -8,6 +8,25 @@ Generate a TypeScript SDK during Vite development and builds.
|
|
|
8
8
|
npm install --save-dev @sdk-it/vite @sdk-it/spec @sdk-it/typescript
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Import an OpenAPI document
|
|
12
|
+
|
|
13
|
+
`sdkIt.imports()` serves an imported OpenAPI document as its SDK, with no SDK on disk:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// vite.config.ts
|
|
17
|
+
import sdkIt from '@sdk-it/vite';
|
|
18
|
+
|
|
19
|
+
export default { plugins: [sdkIt.imports()] };
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { createStore, store } from './store.openapi.yaml';
|
|
24
|
+
|
|
25
|
+
const pet = await store.request('GET /pets/{petId}', { petId: 'p1' });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
It handles imports that end with `.openapi.yaml`, and `.openapi` for a JSON document. `@sdk-it/content-mapper` renders the module, the same way it gives the import its types in `tsc` and the editor (see its README for the tsconfig `contentMappers` entry), so the types and the running code come from one render. The module's id is the document's path with `.ts` added, so Vite strips its types, in dev and in a build. An edit to the document, or to a file it references through `$ref`, reloads the module. A document referenced over http(s) is read each time the module loads, and is not watched. A document that does not render fails the import with its first diagnostic, at its line and column.
|
|
29
|
+
|
|
11
30
|
## Use an OpenAPI file
|
|
12
31
|
|
|
13
32
|
```typescript
|
|
@@ -17,7 +36,7 @@ import sdkIt from '@sdk-it/vite';
|
|
|
17
36
|
|
|
18
37
|
export default defineConfig({
|
|
19
38
|
plugins: [
|
|
20
|
-
sdkIt('./openapi.yaml', {
|
|
39
|
+
sdkIt.file('./openapi.yaml', {
|
|
21
40
|
output: './src/sdk',
|
|
22
41
|
name: 'Example',
|
|
23
42
|
packageName: '@acme/example-client',
|
|
@@ -53,11 +72,11 @@ import { defineConfig } from 'vite';
|
|
|
53
72
|
import sdkIt from '@sdk-it/vite';
|
|
54
73
|
|
|
55
74
|
export default defineConfig({
|
|
56
|
-
plugins: [sdkIt()],
|
|
75
|
+
plugins: [sdkIt.project({})],
|
|
57
76
|
});
|
|
58
77
|
```
|
|
59
78
|
|
|
60
79
|
Project mode loads the SDK-IT project config and uses the same generation
|
|
61
80
|
path as the CLI. Install `@sdk-it/cli` alongside the plugin for this mode.
|
|
62
|
-
Pass `sdkIt({ config: 'config/sdk-it.ts' })` to use a non-default config
|
|
81
|
+
Pass `sdkIt.project({ config: 'config/sdk-it.ts' })` to use a non-default config
|
|
63
82
|
location.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Plugin } from 'vite';
|
|
2
|
+
import { generate } from '@sdk-it/typescript';
|
|
3
|
+
import type { SpecSource } from './spec-source.ts';
|
|
4
|
+
export type DiskSdkSettings = Parameters<typeof generate>[1];
|
|
5
|
+
/**
|
|
6
|
+
* Generates an SDK into a folder on disk at the start of a build or a dev
|
|
7
|
+
* server, and again in dev when a local document of the spec changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DiskSdk {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(source: SpecSource, settings: DiskSdkSettings);
|
|
12
|
+
toPlugin(): Plugin;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=disk-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk-sdk.d.ts","sources":["../src/disk-sdk.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,MAAM,EAA8B,MAAM,MAAM,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAI7D;;;GAGG;AACH,qBAAa,OAAO;;IAWlB,YAAY,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAIxD;IAED,QAAQ,IAAI,MAAM,CAyCjB;CA2BF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Serves an imported OpenAPI document as its SDK module, rendered by
|
|
4
|
+
* `@sdk-it/content-mapper` as the TypeScript content mapper renders it:
|
|
5
|
+
* `import { store } from './store.openapi.yaml'`. The module's id is the
|
|
6
|
+
* document's path with `.ts` added, so Vite strips its types.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DocumentImports {
|
|
9
|
+
toPlugin(): Plugin;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=document-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-imports.d.ts","sources":["../src/document-imports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,MAAM,CAAC;AAalD;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,QAAQ,IAAI,MAAM,CA2CjB;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { type
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
import { type DiskSdkSettings } from './disk-sdk.ts';
|
|
4
|
+
import { type ProjectSdkOptions } from './project.ts';
|
|
5
|
+
export type { DiskSdkSettings } from './disk-sdk.ts';
|
|
6
|
+
export type { ProjectSdkOptions } from './project.ts';
|
|
7
|
+
/** The sdk-it Vite plugins, one factory for each way an SDK comes to the app. */
|
|
8
|
+
export declare const sdkIt: {
|
|
9
|
+
/** Generates an SDK on disk from the spec at `location`: a path relative to the Vite root, or a URL. */
|
|
10
|
+
file(location: string, settings: DiskSdkSettings): Plugin;
|
|
11
|
+
/** Generates an SDK on disk from a spec object. */
|
|
12
|
+
document(document: OpenAPIObject, settings: DiskSdkSettings): Plugin;
|
|
13
|
+
/** Generates an SDK on disk from the location or object `resolve` gives once Vite resolves its config. */
|
|
14
|
+
lazy(resolve: () => string | OpenAPIObject | Promise<string | OpenAPIObject>, settings: DiskSdkSettings): Plugin;
|
|
15
|
+
/** Generates every client of an sdk-it project config. */
|
|
16
|
+
project(options: ProjectSdkOptions): Plugin;
|
|
17
|
+
/** Serves `import { store } from './store.openapi.yaml'` as the document's SDK, with no SDK on disk. */
|
|
18
|
+
imports(): Plugin;
|
|
19
|
+
};
|
|
20
|
+
export default sdkIt;
|
|
11
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOlE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,iFAAiF;AACjF,eAAO,MAAM,KAAK;IAChB,wGAAwG;IACxG,IAAI,WAAW,MAAM,YAAY,eAAe,GAAG,MAAM;IAGzD,mDAAmD;IACnD,QAAQ,WAAW,aAAa,YAAY,eAAe,GAAG,MAAM;IAGpE,0GAA0G;IAC1G,IAAI,UACO,MAAM,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,aAAa,CAAC,YAC7D,eAAe,GACxB,MAAM;IAGT,0DAA0D;IAC1D,OAAO,UAAU,iBAAiB,GAAG,MAAM;IAG3C,wGAAwG;IACxG,OAAO,IAAI,MAAM;CAGlB,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,172 +1,290 @@
|
|
|
1
|
-
// packages/vite/src/
|
|
1
|
+
// packages/vite/src/disk-sdk.ts
|
|
2
|
+
import { Future } from "@zukhruf/async";
|
|
2
3
|
import crypto from "node:crypto";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { styleText } from "node:util";
|
|
6
|
-
import {
|
|
7
|
-
normalizePath
|
|
8
|
-
} from "vite";
|
|
9
|
-
import { loadSpec } from "@sdk-it/spec";
|
|
6
|
+
import { normalizePath } from "vite";
|
|
10
7
|
import { generate } from "@sdk-it/typescript";
|
|
11
8
|
|
|
12
|
-
// packages/vite/src/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
async
|
|
9
|
+
// packages/vite/src/output-folder.ts
|
|
10
|
+
import { Mutex } from "@zukhruf/mutex";
|
|
11
|
+
import { SqliteStore } from "@zukhruf/mutex/sqlite";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join, resolve } from "node:path";
|
|
14
|
+
var OutputFolder = class _OutputFolder {
|
|
15
|
+
static #mutex = new Mutex(
|
|
16
|
+
new SqliteStore(join(tmpdir(), "sdk-it", "output-locks"), {
|
|
17
|
+
clock: globalThis
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
/** The hash of the spec this process last wrote into each folder. */
|
|
21
|
+
static #written = /* @__PURE__ */ new Map();
|
|
22
|
+
#path;
|
|
23
|
+
constructor(output) {
|
|
24
|
+
this.#path = resolve(output);
|
|
25
|
+
}
|
|
26
|
+
generate(hash, generate2) {
|
|
27
|
+
return _OutputFolder.#mutex.acquire(this.#path, async () => {
|
|
28
|
+
if (_OutputFolder.#written.get(this.#path) === hash) return;
|
|
31
29
|
await generate2();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
30
|
+
_OutputFolder.#written.set(this.#path, hash);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
35
34
|
|
|
36
|
-
// packages/vite/src/
|
|
35
|
+
// packages/vite/src/disk-sdk.ts
|
|
37
36
|
var sdkit = styleText("blue", "SDKIT");
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
var DiskSdk = class {
|
|
38
|
+
#source;
|
|
39
|
+
#settings;
|
|
40
|
+
#output;
|
|
41
|
+
#configured = new Future();
|
|
42
|
+
/** The dev server's watcher; a build never has one. */
|
|
43
|
+
#watcher = new Future();
|
|
44
|
+
/** Every local file the spec was read from; an edit to any of them regenerates. */
|
|
45
|
+
#watched = /* @__PURE__ */ new Set();
|
|
46
|
+
#loads = 0;
|
|
47
|
+
constructor(source, settings) {
|
|
48
|
+
this.#source = source;
|
|
49
|
+
this.#settings = settings;
|
|
50
|
+
this.#output = new OutputFolder(settings.output);
|
|
51
|
+
}
|
|
52
|
+
toPlugin() {
|
|
53
|
+
const configure = async (root) => {
|
|
54
|
+
try {
|
|
55
|
+
this.#configured.resolve(await this.#source.configure(root));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
this.#configured.reject(error);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const serve = async (watcher) => {
|
|
62
|
+
this.#watcher.resolve(watcher);
|
|
63
|
+
return (await this.#configured.wait()).watchPath;
|
|
64
|
+
};
|
|
65
|
+
const generate2 = (context) => this.#generate(context);
|
|
66
|
+
const watches = (id) => this.#watched.has(normalizePath(id));
|
|
40
67
|
return {
|
|
41
68
|
name: "sdk-it",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
async configResolved(config) {
|
|
60
|
-
const resolved = await openapi();
|
|
61
|
-
delegatePlugin = typeof resolved === "string" ? filePlugin(resolved, settings) : specPlugin(resolved, settings);
|
|
62
|
-
return delegatePlugin.configResolved(config);
|
|
63
|
-
},
|
|
64
|
-
configureServer(server) {
|
|
65
|
-
return delegatePlugin.configureServer(server);
|
|
66
|
-
},
|
|
67
|
-
async buildStart() {
|
|
68
|
-
return delegatePlugin.buildStart();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function filePlugin(openapi, settings) {
|
|
73
|
-
const source = Promise.withResolvers();
|
|
74
|
-
const devWatcher = Promise.withResolvers();
|
|
75
|
-
let watched = /* @__PURE__ */ new Set();
|
|
76
|
-
let loads = 0;
|
|
77
|
-
const watch = (documents) => {
|
|
78
|
-
watched = new Set(
|
|
79
|
-
documents.filter((document) => document.startsWith("file:")).map((document) => normalizePath(fileURLToPath(document)))
|
|
80
|
-
);
|
|
81
|
-
void devWatcher.promise.then((watcher) => watcher.add([...watched]));
|
|
82
|
-
};
|
|
83
|
-
const generateIfNeeded = async (ref) => {
|
|
84
|
-
const load = ++loads;
|
|
85
|
-
const { spec, documents } = await loadSpec(ref);
|
|
86
|
-
if (load === loads) watch(documents);
|
|
87
|
-
return cachedGeneration(settings.output, hashSpec(spec), async () => {
|
|
88
|
-
console.log(`${sdkit}: Generating SDK.`);
|
|
89
|
-
await generate(spec, settings);
|
|
90
|
-
console.log(`${sdkit}: SDK generated successfully.`);
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
return {
|
|
94
|
-
async configureServer(server) {
|
|
95
|
-
const { ref, watchPath } = await source.promise;
|
|
96
|
-
if (!watchPath) return;
|
|
97
|
-
console.log(`${sdkit}: Watching for spec changes in`, watchPath);
|
|
98
|
-
server.watcher.add([...watched]);
|
|
99
|
-
devWatcher.resolve(server.watcher);
|
|
100
|
-
const regenerate = (file) => {
|
|
101
|
-
if (!watched.has(normalizePath(file))) return;
|
|
102
|
-
console.log(`${sdkit}: OpenAPI spec changed`, file);
|
|
103
|
-
generateIfNeeded(ref).catch(
|
|
69
|
+
async configResolved(config) {
|
|
70
|
+
await configure(config.root);
|
|
71
|
+
},
|
|
72
|
+
async configureServer(server) {
|
|
73
|
+
const watchPath = await serve(server.watcher);
|
|
74
|
+
if (watchPath) {
|
|
75
|
+
console.log(`${sdkit}: Watching for spec changes in`, watchPath);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
async buildStart() {
|
|
79
|
+
await generate2(this);
|
|
80
|
+
},
|
|
81
|
+
watchChange(id, { event }) {
|
|
82
|
+
if (event === "delete" || !watches(id)) return;
|
|
83
|
+
console.log(`${sdkit}: OpenAPI spec changed`, id);
|
|
84
|
+
generate2(this).catch(
|
|
104
85
|
(error) => console.error(
|
|
105
86
|
`${styleText("red", "SDKIT", { stream: process.stderr })}: SDK generation failed.`,
|
|
106
87
|
error
|
|
107
88
|
)
|
|
108
89
|
);
|
|
109
|
-
};
|
|
110
|
-
server.watcher.on("change", regenerate);
|
|
111
|
-
server.watcher.on("add", regenerate);
|
|
112
|
-
},
|
|
113
|
-
async buildStart() {
|
|
114
|
-
const { ref } = await source.promise;
|
|
115
|
-
await generateIfNeeded(ref);
|
|
116
|
-
},
|
|
117
|
-
async configResolved(config) {
|
|
118
|
-
const ref = startsWithProtocol(openapi) ? openapi : join(config.root, openapi);
|
|
119
|
-
let watchPath;
|
|
120
|
-
if (!startsWithProtocol(openapi)) {
|
|
121
|
-
watchPath = ref;
|
|
122
|
-
} else if (openapi.startsWith("file:")) {
|
|
123
|
-
watchPath = fileURLToPath(openapi);
|
|
124
90
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const spec = structuredClone(document);
|
|
133
|
-
return cachedGeneration(settings.output, hashSpec(spec), async () => {
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async #generate(context) {
|
|
94
|
+
const load = ++this.#loads;
|
|
95
|
+
const { spec, documents } = await (await this.#configured.wait()).load();
|
|
96
|
+
if (load === this.#loads) this.#watch(context, documents);
|
|
97
|
+
return this.#output.generate(hashSpec(spec), async () => {
|
|
134
98
|
console.log(`${sdkit}: Generating SDK.`);
|
|
135
|
-
await generate(spec, settings);
|
|
99
|
+
await generate(spec, this.#settings);
|
|
136
100
|
console.log(`${sdkit}: SDK generated successfully.`);
|
|
137
101
|
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
await generateIfNeeded(openapi);
|
|
102
|
+
}
|
|
103
|
+
#watch(context, documents) {
|
|
104
|
+
this.#watched = new Set(
|
|
105
|
+
documents.filter((document) => document.startsWith("file:")).map((document) => normalizePath(fileURLToPath(document)))
|
|
106
|
+
);
|
|
107
|
+
for (const file of this.#watched) {
|
|
108
|
+
context.addWatchFile(file);
|
|
109
|
+
void this.#watcher.wait().then((watcher) => watcher.add(file));
|
|
147
110
|
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
var generationCache = /* @__PURE__ */ new Map();
|
|
151
|
-
function cachedGeneration(output, hash, fn) {
|
|
152
|
-
const key = resolve(output);
|
|
153
|
-
const existing = generationCache.get(key);
|
|
154
|
-
if (existing?.hash === hash) return existing.promise;
|
|
155
|
-
const promise = (existing ? existing.promise.then(fn, fn) : fn()).catch((err) => {
|
|
156
|
-
if (generationCache.get(key)?.promise === promise)
|
|
157
|
-
generationCache.delete(key);
|
|
158
|
-
throw err;
|
|
159
|
-
});
|
|
160
|
-
generationCache.set(key, { hash, promise });
|
|
161
|
-
return promise;
|
|
162
|
-
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
163
113
|
function hashSpec(spec) {
|
|
164
114
|
return crypto.hash("sha256", JSON.stringify(spec));
|
|
165
115
|
}
|
|
116
|
+
|
|
117
|
+
// packages/vite/src/document-imports.ts
|
|
118
|
+
import { readFile } from "node:fs/promises";
|
|
119
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
120
|
+
import { normalizePath as normalizePath2 } from "vite";
|
|
121
|
+
import {
|
|
122
|
+
renderDocument
|
|
123
|
+
} from "@sdk-it/content-mapper";
|
|
124
|
+
var extensions = [".openapi.yaml", ".openapi"];
|
|
125
|
+
var isDocument = (path) => extensions.some((extension) => path.endsWith(extension));
|
|
126
|
+
var DocumentImports = class {
|
|
127
|
+
toPlugin() {
|
|
128
|
+
return {
|
|
129
|
+
name: "sdk-it:imports",
|
|
130
|
+
enforce: "pre",
|
|
131
|
+
async resolveId(source, importer, options) {
|
|
132
|
+
if (!isDocument(source)) return null;
|
|
133
|
+
const resolved = await this.resolve(source, importer, {
|
|
134
|
+
...options,
|
|
135
|
+
skipSelf: true
|
|
136
|
+
});
|
|
137
|
+
return resolved && !resolved.external ? `${resolved.id}.ts` : null;
|
|
138
|
+
},
|
|
139
|
+
async load(id) {
|
|
140
|
+
const file = id.slice(0, -".ts".length);
|
|
141
|
+
if (!id.endsWith(".ts") || !isDocument(file)) return null;
|
|
142
|
+
const content = await readFile(file, "utf8");
|
|
143
|
+
const document = await renderDocument(file, content);
|
|
144
|
+
for (const uri of document.documents) {
|
|
145
|
+
if (uri.startsWith("file:")) this.addWatchFile(fileURLToPath2(uri));
|
|
146
|
+
}
|
|
147
|
+
const fail = (problem) => this.error({
|
|
148
|
+
message: problem.message,
|
|
149
|
+
id: file,
|
|
150
|
+
loc: { file, ...position(content, problem.range.start) }
|
|
151
|
+
});
|
|
152
|
+
if (document.kind === "failed") return fail(document.diagnostics[0]);
|
|
153
|
+
const [yamlError] = document.diagnostics;
|
|
154
|
+
if (yamlError) return fail(yamlError);
|
|
155
|
+
return document.text;
|
|
156
|
+
},
|
|
157
|
+
// A change to a file the document references reloads the module through
|
|
158
|
+
// addWatchFile, but the module's id is not the document's own path, so
|
|
159
|
+
// Vite does not tie a change of the document itself to it.
|
|
160
|
+
hotUpdate({ file, modules }) {
|
|
161
|
+
if (!isDocument(file)) return;
|
|
162
|
+
const module = this.environment.moduleGraph.getModuleById(
|
|
163
|
+
`${normalizePath2(file)}.ts`
|
|
164
|
+
);
|
|
165
|
+
return module ? [...modules, module] : modules;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
function position(text, index) {
|
|
171
|
+
const before = text.slice(0, index);
|
|
172
|
+
const lineStart = before.lastIndexOf("\n") + 1;
|
|
173
|
+
return { line: before.split("\n").length, column: index - lineStart };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// packages/vite/src/project.ts
|
|
177
|
+
var ProjectSdk = class {
|
|
178
|
+
#options;
|
|
179
|
+
#root = process.cwd();
|
|
180
|
+
constructor(options) {
|
|
181
|
+
this.#options = options;
|
|
182
|
+
}
|
|
183
|
+
toPlugin() {
|
|
184
|
+
const configure = (root) => {
|
|
185
|
+
this.#root = root;
|
|
186
|
+
};
|
|
187
|
+
const generate2 = () => this.#generate();
|
|
188
|
+
return {
|
|
189
|
+
name: "sdk-it",
|
|
190
|
+
configResolved(config) {
|
|
191
|
+
configure(config.root);
|
|
192
|
+
},
|
|
193
|
+
async configureServer() {
|
|
194
|
+
await generate2();
|
|
195
|
+
},
|
|
196
|
+
async buildStart() {
|
|
197
|
+
await generate2();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async #generate() {
|
|
202
|
+
const { generateProject, loadProjectConfig } = await import("@sdk-it/cli");
|
|
203
|
+
const config = await loadProjectConfig({
|
|
204
|
+
cwd: this.#root,
|
|
205
|
+
config: this.#options.config
|
|
206
|
+
});
|
|
207
|
+
await generateProject(config);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// packages/vite/src/spec-source.ts
|
|
212
|
+
import { join as join2 } from "node:path";
|
|
213
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
214
|
+
import { loadSpec } from "@sdk-it/spec";
|
|
215
|
+
var FileSpecSource = class {
|
|
216
|
+
#location;
|
|
217
|
+
constructor(location) {
|
|
218
|
+
this.#location = location;
|
|
219
|
+
}
|
|
220
|
+
async configure(root) {
|
|
221
|
+
const location = this.#location;
|
|
222
|
+
if (!startsWithProtocol(location)) {
|
|
223
|
+
const path = join2(root, location);
|
|
224
|
+
return { watchPath: path, load: () => loadSpec(path) };
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
watchPath: location.startsWith("file:") ? fileURLToPath3(location) : void 0,
|
|
228
|
+
load: () => loadSpec(location)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
var DocumentSpecSource = class {
|
|
233
|
+
#document;
|
|
234
|
+
constructor(document) {
|
|
235
|
+
this.#document = document;
|
|
236
|
+
}
|
|
237
|
+
async configure() {
|
|
238
|
+
return {
|
|
239
|
+
watchPath: void 0,
|
|
240
|
+
load: async () => ({
|
|
241
|
+
spec: structuredClone(this.#document),
|
|
242
|
+
documents: []
|
|
243
|
+
})
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var LazySpecSource = class {
|
|
248
|
+
#resolve;
|
|
249
|
+
constructor(resolve2) {
|
|
250
|
+
this.#resolve = resolve2;
|
|
251
|
+
}
|
|
252
|
+
async configure(root) {
|
|
253
|
+
const resolved = await this.#resolve();
|
|
254
|
+
const source = typeof resolved === "string" ? new FileSpecSource(resolved) : new DocumentSpecSource(resolved);
|
|
255
|
+
return source.configure(root);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
166
258
|
function startsWithProtocol(url) {
|
|
167
259
|
return /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(url);
|
|
168
260
|
}
|
|
261
|
+
|
|
262
|
+
// packages/vite/src/index.ts
|
|
263
|
+
var sdkIt = {
|
|
264
|
+
/** Generates an SDK on disk from the spec at `location`: a path relative to the Vite root, or a URL. */
|
|
265
|
+
file(location, settings) {
|
|
266
|
+
return new DiskSdk(new FileSpecSource(location), settings).toPlugin();
|
|
267
|
+
},
|
|
268
|
+
/** Generates an SDK on disk from a spec object. */
|
|
269
|
+
document(document, settings) {
|
|
270
|
+
return new DiskSdk(new DocumentSpecSource(document), settings).toPlugin();
|
|
271
|
+
},
|
|
272
|
+
/** Generates an SDK on disk from the location or object `resolve` gives once Vite resolves its config. */
|
|
273
|
+
lazy(resolve2, settings) {
|
|
274
|
+
return new DiskSdk(new LazySpecSource(resolve2), settings).toPlugin();
|
|
275
|
+
},
|
|
276
|
+
/** Generates every client of an sdk-it project config. */
|
|
277
|
+
project(options) {
|
|
278
|
+
return new ProjectSdk(options).toPlugin();
|
|
279
|
+
},
|
|
280
|
+
/** Serves `import { store } from './store.openapi.yaml'` as the document's SDK, with no SDK on disk. */
|
|
281
|
+
imports() {
|
|
282
|
+
return new DocumentImports().toPlugin();
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
var index_default = sdkIt;
|
|
169
286
|
export {
|
|
170
|
-
|
|
287
|
+
index_default as default,
|
|
288
|
+
sdkIt
|
|
171
289
|
};
|
|
172
290
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/
|
|
4
|
-
"sourcesContent": ["import crypto from 'node:crypto';\nimport { join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { styleText } from 'node:util';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\nimport {\n type FSWatcher,\n type Plugin,\n type ResolvedConfig,\n type ViteDevServer,\n normalizePath,\n} from 'vite';\n\nimport { loadSpec } from '@sdk-it/spec';\nimport { generate } from '@sdk-it/typescript';\n\nimport { type ProjectPluginOptions, projectPlugin } from './project.ts';\n\nconst sdkit = styleText('blue', 'SDKIT');\n\ntype Settings = Parameters<typeof generate>[1];\ninterface SourcePlugin {\n configResolved(config: ResolvedConfig): Promise<void>;\n configureServer(server: ViteDevServer): Promise<void>;\n buildStart(): Promise<void>;\n}\ntype OpenapiFunction = () =>\n string | OpenAPIObject | Promise<string | OpenAPIObject>;\nexport default function sdkIt(): Plugin;\nexport default function sdkIt(options: ProjectPluginOptions): Plugin;\nexport default function sdkIt(\n openapi: OpenAPIObject | string | OpenapiFunction,\n settings: Settings,\n): Plugin;\nexport default function sdkIt(\n openapi?: OpenAPIObject | string | OpenapiFunction | ProjectPluginOptions,\n settings?: Settings,\n): Plugin {\n if (openapi === undefined || isProjectPluginOptions(openapi)) {\n return {\n name: 'sdk-it',\n ...projectPlugin(openapi),\n };\n }\n if (typeof openapi === 'function') {\n return { name: 'sdk-it', ...functionPlugin(openapi, settings!) };\n }\n if (typeof openapi === 'string') {\n return { name: 'sdk-it', ...filePlugin(openapi, settings!) };\n }\n return { name: 'sdk-it', ...specPlugin(openapi, settings!) };\n}\n\nfunction isProjectPluginOptions(\n input: OpenAPIObject | string | OpenapiFunction | ProjectPluginOptions,\n): input is ProjectPluginOptions {\n return typeof input === 'object' && input !== null && !('openapi' in input);\n}\n\nfunction functionPlugin(\n openapi: OpenapiFunction,\n settings: Settings,\n): Omit<Plugin, 'name'> {\n let delegatePlugin!: SourcePlugin;\n\n return {\n async configResolved(config) {\n const resolved = await openapi();\n delegatePlugin =\n typeof resolved === 'string'\n ? filePlugin(resolved, settings)\n : specPlugin(resolved, settings);\n\n return delegatePlugin.configResolved(config);\n },\n configureServer(server) {\n return delegatePlugin.configureServer(server);\n },\n async buildStart() {\n return delegatePlugin.buildStart();\n },\n };\n}\n\nfunction filePlugin(openapi: string, settings: Settings): SourcePlugin {\n // Vite resolves the config before it starts a dev server or a build.\n const source = Promise.withResolvers<{ ref: string; watchPath?: string }>();\n // Only a dev server has a watcher; a build never resolves this.\n const devWatcher = Promise.withResolvers<FSWatcher>();\n // Every local file the spec was read from; an edit to any of them regenerates.\n let watched = new Set<string>();\n let loads = 0;\n\n const watch = (documents: string[]) => {\n watched = new Set(\n documents\n .filter((document) => document.startsWith('file:'))\n .map((document) => normalizePath(fileURLToPath(document))),\n );\n void devWatcher.promise.then((watcher) => watcher.add([...watched]));\n };\n\n const generateIfNeeded = async (ref: string) => {\n const load = ++loads;\n const { spec, documents } = await loadSpec(ref);\n if (load === loads) watch(documents);\n return cachedGeneration(settings.output, hashSpec(spec), async () => {\n console.log(`${sdkit}: Generating SDK.`);\n await generate(spec, settings);\n console.log(`${sdkit}: SDK generated successfully.`);\n });\n };\n\n return {\n async configureServer(server) {\n const { ref, watchPath } = await source.promise;\n if (!watchPath) return;\n console.log(`${sdkit}: Watching for spec changes in`, watchPath);\n server.watcher.add([...watched]);\n devWatcher.resolve(server.watcher);\n const regenerate = (file: string) => {\n if (!watched.has(normalizePath(file))) return;\n console.log(`${sdkit}: OpenAPI spec changed`, file);\n // A half-saved file fails to load; the next save tries again.\n generateIfNeeded(ref).catch((error: unknown) =>\n console.error(\n `${styleText('red', 'SDKIT', { stream: process.stderr })}: SDK generation failed.`,\n error,\n ),\n );\n };\n server.watcher.on('change', regenerate);\n server.watcher.on('add', regenerate);\n },\n async buildStart() {\n const { ref } = await source.promise;\n await generateIfNeeded(ref);\n },\n async configResolved(config) {\n const ref = startsWithProtocol(openapi)\n ? openapi\n : join(config.root, openapi);\n let watchPath: string | undefined;\n if (!startsWithProtocol(openapi)) {\n watchPath = ref;\n } else if (openapi.startsWith('file:')) {\n watchPath = fileURLToPath(openapi);\n }\n if (watchPath) watched = new Set([normalizePath(watchPath)]);\n source.resolve({ ref, watchPath });\n },\n };\n}\n\nfunction specPlugin(openapi: OpenAPIObject, settings: Settings): SourcePlugin {\n const generateIfNeeded = async (document: OpenAPIObject) => {\n const spec = structuredClone(document);\n return cachedGeneration(settings.output, hashSpec(spec), async () => {\n console.log(`${sdkit}: Generating SDK.`);\n await generate(spec, settings);\n console.log(`${sdkit}: SDK generated successfully.`);\n });\n };\n return {\n async configResolved() {},\n async configureServer() {\n await generateIfNeeded(openapi);\n },\n async buildStart() {\n await generateIfNeeded(openapi);\n },\n };\n}\n\nconst generationCache = new Map<\n string,\n { hash: string; promise: Promise<void> }\n>();\n\nfunction cachedGeneration(\n output: string,\n hash: string,\n fn: () => Promise<void>,\n): Promise<void> {\n const key = resolve(output);\n const existing = generationCache.get(key);\n // Only the latest queued generation can represent this output directory.\n if (existing?.hash === hash) return existing.promise;\n\n // A failed predecessor still releases the queue; its own caller keeps the error.\n const promise: Promise<void> = (\n existing ? existing.promise.then(fn, fn) : fn()\n ).catch((err) => {\n if (generationCache.get(key)?.promise === promise)\n generationCache.delete(key);\n throw err;\n });\n generationCache.set(key, { hash, promise });\n return promise;\n}\n\nfunction hashSpec(spec: OpenAPIObject): string {\n return crypto.hash('sha256', JSON.stringify(spec));\n}\n\nfunction startsWithProtocol(url: string): boolean {\n return /^[a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\//.test(url);\n}\n", "import type { Plugin } from 'vite';\n\nexport interface ProjectPluginOptions {\n config?: string;\n}\n\nexport function projectPlugin(\n options: ProjectPluginOptions = {},\n): Omit<Plugin, 'name'> {\n let root = process.cwd();\n\n const generate = async () => {\n const { generateProject, loadProjectConfig } = await import('@sdk-it/cli');\n const config = await loadProjectConfig({\n cwd: root,\n config: options.config,\n });\n await generateProject(config);\n };\n\n return {\n configResolved(config) {\n root = config.root;\n },\n async configureServer() {\n await generate();\n },\n async buildStart() {\n await generate();\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,YAAY;AACnB,SAAS,
|
|
6
|
-
"names": ["generate"]
|
|
3
|
+
"sources": ["../src/disk-sdk.ts", "../src/output-folder.ts", "../src/document-imports.ts", "../src/project.ts", "../src/spec-source.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { Future } from '@zukhruf/async';\nimport crypto from 'node:crypto';\nimport { fileURLToPath } from 'node:url';\nimport { styleText } from 'node:util';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\nimport { type FSWatcher, type Plugin, type Rollup, normalizePath } from 'vite';\n\nimport { generate } from '@sdk-it/typescript';\n\nimport { OutputFolder } from './output-folder.ts';\nimport type { ConfiguredSpec, SpecSource } from './spec-source.ts';\n\nexport type DiskSdkSettings = Parameters<typeof generate>[1];\n\nconst sdkit = styleText('blue', 'SDKIT');\n\n/**\n * Generates an SDK into a folder on disk at the start of a build or a dev\n * server, and again in dev when a local document of the spec changes.\n */\nexport class DiskSdk {\n readonly #source: SpecSource;\n readonly #settings: DiskSdkSettings;\n readonly #output: OutputFolder;\n readonly #configured = new Future<ConfiguredSpec>();\n /** The dev server's watcher; a build never has one. */\n readonly #watcher = new Future<FSWatcher>();\n /** Every local file the spec was read from; an edit to any of them regenerates. */\n #watched = new Set<string>();\n #loads = 0;\n\n constructor(source: SpecSource, settings: DiskSdkSettings) {\n this.#source = source;\n this.#settings = settings;\n this.#output = new OutputFolder(settings.output);\n }\n\n toPlugin(): Plugin {\n const configure = async (root: string) => {\n try {\n this.#configured.resolve(await this.#source.configure(root));\n } catch (error) {\n this.#configured.reject(error);\n throw error;\n }\n };\n const serve = async (watcher: FSWatcher) => {\n this.#watcher.resolve(watcher);\n return (await this.#configured.wait()).watchPath;\n };\n const generate = (context: Rollup.PluginContext) => this.#generate(context);\n const watches = (id: string) => this.#watched.has(normalizePath(id));\n return {\n name: 'sdk-it',\n async configResolved(config) {\n await configure(config.root);\n },\n async configureServer(server) {\n const watchPath = await serve(server.watcher);\n if (watchPath) {\n console.log(`${sdkit}: Watching for spec changes in`, watchPath);\n }\n },\n async buildStart() {\n await generate(this);\n },\n watchChange(id, { event }) {\n if (event === 'delete' || !watches(id)) return;\n console.log(`${sdkit}: OpenAPI spec changed`, id);\n // A half-saved file fails to load; the next save tries again.\n generate(this).catch((error: unknown) =>\n console.error(\n `${styleText('red', 'SDKIT', { stream: process.stderr })}: SDK generation failed.`,\n error,\n ),\n );\n },\n };\n }\n\n async #generate(context: Rollup.PluginContext) {\n const load = ++this.#loads;\n const { spec, documents } = await (await this.#configured.wait()).load();\n if (load === this.#loads) this.#watch(context, documents);\n return this.#output.generate(hashSpec(spec), async () => {\n console.log(`${sdkit}: Generating SDK.`);\n await generate(spec, this.#settings);\n console.log(`${sdkit}: SDK generated successfully.`);\n });\n }\n\n #watch(context: Rollup.PluginContext, documents: readonly string[]) {\n this.#watched = new Set(\n documents\n .filter((document) => document.startsWith('file:'))\n .map((document) => normalizePath(fileURLToPath(document))),\n );\n for (const file of this.#watched) {\n context.addWatchFile(file);\n // Vite watches a file outside its root only when the file exists\n // (ensureWatchedFile), so a referenced file that does not exist yet is\n // added to the dev server's watcher here, and creating it regenerates.\n void this.#watcher.wait().then((watcher) => watcher.add(file));\n }\n }\n}\n\nfunction hashSpec(spec: OpenAPIObject): string {\n return crypto.hash('sha256', JSON.stringify(spec));\n}\n", "import { Mutex } from '@zukhruf/mutex';\nimport { SqliteStore } from '@zukhruf/mutex/sqlite';\nimport { tmpdir } from 'node:os';\nimport { join, resolve } from 'node:path';\n\n/**\n * The folder an SDK is generated into. Every process on the host that\n * generates into it, such as a dev server and a build at once, holds one lock\n * for it, so no two generations write its files at the same time. A process\n * does not generate again the spec it last wrote there.\n */\nexport class OutputFolder {\n static readonly #mutex = new Mutex(\n new SqliteStore(join(tmpdir(), 'sdk-it', 'output-locks'), {\n clock: globalThis,\n }),\n );\n /** The hash of the spec this process last wrote into each folder. */\n static readonly #written = new Map<string, string>();\n readonly #path: string;\n\n constructor(output: string) {\n this.#path = resolve(output);\n }\n\n generate(hash: string, generate: () => Promise<void>): Promise<void> {\n return OutputFolder.#mutex.acquire(this.#path, async () => {\n if (OutputFolder.#written.get(this.#path) === hash) return;\n await generate();\n OutputFolder.#written.set(this.#path, hash);\n });\n }\n}\n", "import { readFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\nimport { type Plugin, normalizePath } from 'vite';\n\nimport {\n type DocumentDiagnostic,\n renderDocument,\n} from '@sdk-it/content-mapper';\n\n/** The extensions an imported OpenAPI document ends with: YAML, and JSON under a name TypeScript accepts for a mapped file. */\nconst extensions = ['.openapi.yaml', '.openapi'];\n\nconst isDocument = (path: string) =>\n extensions.some((extension) => path.endsWith(extension));\n\n/**\n * Serves an imported OpenAPI document as its SDK module, rendered by\n * `@sdk-it/content-mapper` as the TypeScript content mapper renders it:\n * `import { store } from './store.openapi.yaml'`. The module's id is the\n * document's path with `.ts` added, so Vite strips its types.\n */\nexport class DocumentImports {\n toPlugin(): Plugin {\n return {\n name: 'sdk-it:imports',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!isDocument(source)) return null;\n const resolved = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n return resolved && !resolved.external ? `${resolved.id}.ts` : null;\n },\n async load(id) {\n const file = id.slice(0, -'.ts'.length);\n if (!id.endsWith('.ts') || !isDocument(file)) return null;\n const content = await readFile(file, 'utf8');\n const document = await renderDocument(file, content);\n for (const uri of document.documents) {\n if (uri.startsWith('file:')) this.addWatchFile(fileURLToPath(uri));\n }\n const fail = (problem: DocumentDiagnostic) =>\n this.error({\n message: problem.message,\n id: file,\n loc: { file, ...position(content, problem.range.start) },\n });\n if (document.kind === 'failed') return fail(document.diagnostics[0]);\n // A document with YAML errors can still render; it does not run until it is fixed.\n const [yamlError] = document.diagnostics;\n if (yamlError) return fail(yamlError);\n return document.text;\n },\n // A change to a file the document references reloads the module through\n // addWatchFile, but the module's id is not the document's own path, so\n // Vite does not tie a change of the document itself to it.\n hotUpdate({ file, modules }) {\n if (!isDocument(file)) return;\n const module = this.environment.moduleGraph.getModuleById(\n `${normalizePath(file)}.ts`,\n );\n return module ? [...modules, module] : modules;\n },\n };\n }\n}\n\n/** The line (from 1) and column (from 0) of `index` in `text`, as Rollup reports a location. */\nfunction position(text: string, index: number) {\n const before = text.slice(0, index);\n const lineStart = before.lastIndexOf('\\n') + 1;\n return { line: before.split('\\n').length, column: index - lineStart };\n}\n", "import type { Plugin } from 'vite';\n\nexport interface ProjectSdkOptions {\n /** The project config file; the CLI finds it from the Vite root without one. */\n config?: string;\n}\n\n/** Generates every client of an sdk-it project, as `sdk-it generate` does. */\nexport class ProjectSdk {\n readonly #options: ProjectSdkOptions;\n #root = process.cwd();\n\n constructor(options: ProjectSdkOptions) {\n this.#options = options;\n }\n\n toPlugin(): Plugin {\n const configure = (root: string) => {\n this.#root = root;\n };\n const generate = () => this.#generate();\n return {\n name: 'sdk-it',\n configResolved(config) {\n configure(config.root);\n },\n async configureServer() {\n await generate();\n },\n async buildStart() {\n await generate();\n },\n };\n }\n\n async #generate() {\n const { generateProject, loadProjectConfig } = await import('@sdk-it/cli');\n const config = await loadProjectConfig({\n cwd: this.#root,\n config: this.#options.config,\n });\n await generateProject(config);\n }\n}\n", "import { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\n\nimport { loadSpec } from '@sdk-it/spec';\n\n/** A spec read for one generation, and the URI of every document it was read from. */\nexport interface LoadedSpec {\n spec: OpenAPIObject;\n documents: readonly string[];\n}\n\n/** A source bound to a Vite root, ready to load. */\nexport interface ConfiguredSpec {\n /** The local file the spec starts from, when it is one. */\n readonly watchPath: string | undefined;\n load(): Promise<LoadedSpec>;\n}\n\n/** Where the spec of a generated SDK comes from. */\nexport interface SpecSource {\n configure(root: string): Promise<ConfiguredSpec>;\n}\n\n/** A spec at a path relative to the Vite root, or at a URL. */\nexport class FileSpecSource implements SpecSource {\n readonly #location: string;\n\n constructor(location: string) {\n this.#location = location;\n }\n\n async configure(root: string): Promise<ConfiguredSpec> {\n const location = this.#location;\n if (!startsWithProtocol(location)) {\n const path = join(root, location);\n return { watchPath: path, load: () => loadSpec(path) };\n }\n return {\n watchPath: location.startsWith('file:')\n ? fileURLToPath(location)\n : undefined,\n load: () => loadSpec(location),\n };\n }\n}\n\n/** A spec the Vite config holds as an object. */\nexport class DocumentSpecSource implements SpecSource {\n readonly #document: OpenAPIObject;\n\n constructor(document: OpenAPIObject) {\n this.#document = document;\n }\n\n async configure(): Promise<ConfiguredSpec> {\n return {\n watchPath: undefined,\n load: async () => ({\n spec: structuredClone(this.#document),\n documents: [],\n }),\n };\n }\n}\n\n/** A spec a function gives once Vite resolves its config: a location or an object. */\nexport class LazySpecSource implements SpecSource {\n readonly #resolve: () =>\n string | OpenAPIObject | Promise<string | OpenAPIObject>;\n\n constructor(\n resolve: () => string | OpenAPIObject | Promise<string | OpenAPIObject>,\n ) {\n this.#resolve = resolve;\n }\n\n async configure(root: string): Promise<ConfiguredSpec> {\n const resolved = await this.#resolve();\n const source =\n typeof resolved === 'string'\n ? new FileSpecSource(resolved)\n : new DocumentSpecSource(resolved);\n return source.configure(root);\n }\n}\n\nfunction startsWithProtocol(url: string): boolean {\n return /^[a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\//.test(url);\n}\n", "import type { OpenAPIObject } from 'openapi3-ts/oas31';\nimport type { Plugin } from 'vite';\n\nimport { DiskSdk, type DiskSdkSettings } from './disk-sdk.ts';\nimport { DocumentImports } from './document-imports.ts';\nimport { ProjectSdk, type ProjectSdkOptions } from './project.ts';\nimport {\n DocumentSpecSource,\n FileSpecSource,\n LazySpecSource,\n} from './spec-source.ts';\n\nexport type { DiskSdkSettings } from './disk-sdk.ts';\nexport type { ProjectSdkOptions } from './project.ts';\n\n/** The sdk-it Vite plugins, one factory for each way an SDK comes to the app. */\nexport const sdkIt = {\n /** Generates an SDK on disk from the spec at `location`: a path relative to the Vite root, or a URL. */\n file(location: string, settings: DiskSdkSettings): Plugin {\n return new DiskSdk(new FileSpecSource(location), settings).toPlugin();\n },\n /** Generates an SDK on disk from a spec object. */\n document(document: OpenAPIObject, settings: DiskSdkSettings): Plugin {\n return new DiskSdk(new DocumentSpecSource(document), settings).toPlugin();\n },\n /** Generates an SDK on disk from the location or object `resolve` gives once Vite resolves its config. */\n lazy(\n resolve: () => string | OpenAPIObject | Promise<string | OpenAPIObject>,\n settings: DiskSdkSettings,\n ): Plugin {\n return new DiskSdk(new LazySpecSource(resolve), settings).toPlugin();\n },\n /** Generates every client of an sdk-it project config. */\n project(options: ProjectSdkOptions): Plugin {\n return new ProjectSdk(options).toPlugin();\n },\n /** Serves `import { store } from './store.openapi.yaml'` as the document's SDK, with no SDK on disk. */\n imports(): Plugin {\n return new DocumentImports().toPlugin();\n },\n};\n\nexport default sdkIt;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,cAAc;AACvB,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAE1B,SAAmD,qBAAqB;AAExE,SAAS,gBAAgB;;;ACPzB,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,MAAM,eAAe;AAQvB,IAAM,eAAN,MAAM,cAAa;AAAA,EACx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AAW,MAAM,KAAK,SAAS;AACrC,UAAM,SACJ,OAAO,aAAa,WAChB,IAAI,eAAe,QAAQ,IAC3B,IAAI,mBAAmB,QAAQ;AACrC,WAAO,OAAO,UAAU,IAAI;AAAA,EAC9B;AACF;AAEA,SAAS,mBAAmB,KAAsB;AAChD,SAAO,iCAAiC,KAAK,GAAG;AAClD;;;ACzEO,IAAM,QAAQ;AAAA;AAAA,EAEnB,KAAK,UAAkB,UAAmC;AACxD,WAAO,IAAI,QAAQ,IAAI,eAAe,QAAQ,GAAG,QAAQ,EAAE,SAAS;AAAA,EACtE;AAAA;AAAA,EAEA,SAAS,UAAyB,UAAmC;AACnE,WAAO,IAAI,QAAQ,IAAI,mBAAmB,QAAQ,GAAG,QAAQ,EAAE,SAAS;AAAA,EAC1E;AAAA;AAAA,EAEA,KACEC,UACA,UACQ;AACR,WAAO,IAAI,QAAQ,IAAI,eAAeA,QAAO,GAAG,QAAQ,EAAE,SAAS;AAAA,EACrE;AAAA;AAAA,EAEA,QAAQ,SAAoC;AAC1C,WAAO,IAAI,WAAW,OAAO,EAAE,SAAS;AAAA,EAC1C;AAAA;AAAA,EAEA,UAAkB;AAChB,WAAO,IAAI,gBAAgB,EAAE,SAAS;AAAA,EACxC;AACF;AAEA,IAAO,gBAAQ;",
|
|
6
|
+
"names": ["generate", "generate", "fileURLToPath", "normalizePath", "generate", "join", "fileURLToPath", "resolve", "resolve"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The folder an SDK is generated into. Every process on the host that
|
|
3
|
+
* generates into it, such as a dev server and a build at once, holds one lock
|
|
4
|
+
* for it, so no two generations write its files at the same time. A process
|
|
5
|
+
* does not generate again the spec it last wrote there.
|
|
6
|
+
*/
|
|
7
|
+
export declare class OutputFolder {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(output: string);
|
|
10
|
+
generate(hash: string, generate: () => Promise<void>): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=output-folder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-folder.d.ts","sources":["../src/output-folder.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,qBAAa,YAAY;;IAUvB,YAAY,MAAM,EAAE,MAAM,EAEzB;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnE;CACF"}
|
package/dist/project.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
export interface
|
|
2
|
+
export interface ProjectSdkOptions {
|
|
3
|
+
/** The project config file; the CLI finds it from the Vite root without one. */
|
|
3
4
|
config?: string;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
/** Generates every client of an sdk-it project, as `sdk-it generate` does. */
|
|
7
|
+
export declare class ProjectSdk {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options: ProjectSdkOptions);
|
|
10
|
+
toPlugin(): Plugin;
|
|
11
|
+
}
|
|
6
12
|
//# sourceMappingURL=project.d.ts.map
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,8EAA8E;AAC9E,qBAAa,UAAU;;IAIrB,YAAY,OAAO,EAAE,iBAAiB,EAErC;IAED,QAAQ,IAAI,MAAM,CAiBjB;CAUF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
+
/** A spec read for one generation, and the URI of every document it was read from. */
|
|
3
|
+
export interface LoadedSpec {
|
|
4
|
+
spec: OpenAPIObject;
|
|
5
|
+
documents: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** A source bound to a Vite root, ready to load. */
|
|
8
|
+
export interface ConfiguredSpec {
|
|
9
|
+
/** The local file the spec starts from, when it is one. */
|
|
10
|
+
readonly watchPath: string | undefined;
|
|
11
|
+
load(): Promise<LoadedSpec>;
|
|
12
|
+
}
|
|
13
|
+
/** Where the spec of a generated SDK comes from. */
|
|
14
|
+
export interface SpecSource {
|
|
15
|
+
configure(root: string): Promise<ConfiguredSpec>;
|
|
16
|
+
}
|
|
17
|
+
/** A spec at a path relative to the Vite root, or at a URL. */
|
|
18
|
+
export declare class FileSpecSource implements SpecSource {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(location: string);
|
|
21
|
+
configure(root: string): Promise<ConfiguredSpec>;
|
|
22
|
+
}
|
|
23
|
+
/** A spec the Vite config holds as an object. */
|
|
24
|
+
export declare class DocumentSpecSource implements SpecSource {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(document: OpenAPIObject);
|
|
27
|
+
configure(): Promise<ConfiguredSpec>;
|
|
28
|
+
}
|
|
29
|
+
/** A spec a function gives once Vite resolves its config: a location or an object. */
|
|
30
|
+
export declare class LazySpecSource implements SpecSource {
|
|
31
|
+
#private;
|
|
32
|
+
constructor(resolve: () => string | OpenAPIObject | Promise<string | OpenAPIObject>);
|
|
33
|
+
configure(root: string): Promise<ConfiguredSpec>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=spec-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-source.d.ts","sources":["../src/spec-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,sFAAsF;AACtF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;CAC7B;AAED,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAClD;AAED,+DAA+D;AAC/D,qBAAa,cAAe,YAAW,UAAU;;IAG/C,YAAY,QAAQ,EAAE,MAAM,EAE3B;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAYrD;CACF;AAED,iDAAiD;AACjD,qBAAa,kBAAmB,YAAW,UAAU;;IAGnD,YAAY,QAAQ,EAAE,aAAa,EAElC;IAEK,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC,CAQzC;CACF;AAED,sFAAsF;AACtF,qBAAa,cAAe,YAAW,UAAU;;IAI/C,YACE,OAAO,EAAE,MAAM,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,aAAa,CAAC,EAGxE;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOrD;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdk-it/vite",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/JanuaryLabs/sdk-it",
|
|
@@ -36,20 +36,25 @@
|
|
|
36
36
|
"!**/*.test.*"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@sdk-it/core": "0.47.
|
|
39
|
+
"@sdk-it/core": "0.47.2",
|
|
40
40
|
"@sdk-it/testing": "*",
|
|
41
|
-
"@zukhruf/fs": "^0.8.
|
|
41
|
+
"@zukhruf/fs": "^0.8.33"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@sdk-it/cli": "0.47.
|
|
44
|
+
"@sdk-it/cli": "0.47.2",
|
|
45
|
+
"@sdk-it/content-mapper": "0.47.2",
|
|
46
|
+
"@sdk-it/spec": "0.47.2",
|
|
47
|
+
"@sdk-it/typescript": "0.47.2",
|
|
45
48
|
"openapi3-ts": "4.6.2",
|
|
46
|
-
"vite": "^7.0.0 || ^8.0.0"
|
|
47
|
-
"@sdk-it/spec": "0.47.0",
|
|
48
|
-
"@sdk-it/typescript": "0.47.0"
|
|
49
|
+
"vite": "^7.0.0 || ^8.0.0"
|
|
49
50
|
},
|
|
50
51
|
"peerDependenciesMeta": {
|
|
51
52
|
"@sdk-it/cli": {
|
|
52
53
|
"optional": true
|
|
53
54
|
}
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@zukhruf/mutex": "^0.8.43",
|
|
58
|
+
"@zukhruf/async": "^0.8.33"
|
|
54
59
|
}
|
|
55
60
|
}
|