@skmtc/core 0.0.368 → 0.0.370
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/esm/context/GenerateContext.d.ts +79 -4
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +113 -33
- package/esm/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/types.d.ts +56 -5
- package/esm/deps/jsr.io/@std/io/0.224.8/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.224.8/types.js +15 -0
- package/esm/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/write_all.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.7/file_handler.js +1 -1
- package/esm/oas/array/Array.d.ts +32 -8
- package/esm/oas/array/Array.d.ts.map +1 -1
- package/esm/oas/array/Array.js +60 -30
- package/esm/oas/boolean/Boolean.d.ts +24 -6
- package/esm/oas/boolean/Boolean.d.ts.map +1 -1
- package/esm/oas/boolean/Boolean.js +40 -24
- package/esm/oas/integer/Integer.d.ts +29 -8
- package/esm/oas/integer/Integer.d.ts.map +1 -1
- package/esm/oas/integer/Integer.js +57 -30
- package/esm/oas/number/Number.d.ts +24 -6
- package/esm/oas/number/Number.d.ts.map +1 -1
- package/esm/oas/number/Number.js +40 -24
- package/esm/oas/object/Object.d.ts +56 -12
- package/esm/oas/object/Object.d.ts.map +1 -1
- package/esm/oas/object/Object.js +52 -5
- package/esm/oas/string/String.d.ts +32 -8
- package/esm/oas/string/String.d.ts.map +1 -1
- package/esm/oas/string/String.js +63 -33
- package/esm/oas/union/Union.d.ts +38 -8
- package/esm/oas/union/Union.d.ts.map +1 -1
- package/esm/oas/union/Union.js +66 -30
- package/esm/oas/unknown/Unknown.d.ts +24 -5
- package/esm/oas/unknown/Unknown.d.ts.map +1 -1
- package/esm/oas/unknown/Unknown.js +34 -21
- package/esm/oas/void/Void.d.ts +22 -5
- package/esm/oas/void/Void.d.ts.map +1 -1
- package/esm/oas/void/Void.js +32 -21
- package/esm/server/createServer.d.ts.map +1 -1
- package/esm/server/createServer.js +9 -6
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +79 -4
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +113 -33
- package/script/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/types.d.ts +56 -5
- package/script/deps/jsr.io/@std/io/0.224.8/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.224.8/types.js +18 -0
- package/script/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/write_all.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.7/file_handler.js +1 -1
- package/script/oas/array/Array.d.ts +32 -8
- package/script/oas/array/Array.d.ts.map +1 -1
- package/script/oas/array/Array.js +60 -30
- package/script/oas/boolean/Boolean.d.ts +24 -6
- package/script/oas/boolean/Boolean.d.ts.map +1 -1
- package/script/oas/boolean/Boolean.js +40 -24
- package/script/oas/integer/Integer.d.ts +29 -8
- package/script/oas/integer/Integer.d.ts.map +1 -1
- package/script/oas/integer/Integer.js +57 -30
- package/script/oas/number/Number.d.ts +24 -6
- package/script/oas/number/Number.d.ts.map +1 -1
- package/script/oas/number/Number.js +40 -24
- package/script/oas/object/Object.d.ts +56 -12
- package/script/oas/object/Object.d.ts.map +1 -1
- package/script/oas/object/Object.js +52 -5
- package/script/oas/string/String.d.ts +32 -8
- package/script/oas/string/String.d.ts.map +1 -1
- package/script/oas/string/String.js +63 -33
- package/script/oas/union/Union.d.ts +38 -8
- package/script/oas/union/Union.d.ts.map +1 -1
- package/script/oas/union/Union.js +66 -30
- package/script/oas/unknown/Unknown.d.ts +24 -5
- package/script/oas/unknown/Unknown.d.ts.map +1 -1
- package/script/oas/unknown/Unknown.js +34 -21
- package/script/oas/void/Void.d.ts +22 -5
- package/script/oas/void/Void.d.ts.map +1 -1
- package/script/oas/void/Void.js +32 -21
- package/script/server/createServer.d.ts.map +1 -1
- package/script/server/createServer.js +9 -6
- package/esm/deps/jsr.io/@std/io/0.224.7/types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/io/0.224.7/types.js +0 -3
- package/script/deps/jsr.io/@std/io/0.224.7/types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/io/0.224.7/types.js +0 -4
- /package/esm/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/write_all.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/write_all.js +0 -0
- /package/script/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/write_all.d.ts +0 -0
- /package/script/deps/jsr.io/@std/io/{0.224.7 → 0.224.8}/write_all.js +0 -0
package/esm/oas/void/Void.js
CHANGED
|
@@ -1,41 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _OasVoid_fields;
|
|
1
|
+
/**
|
|
2
|
+
* Object representing a void type in the OpenAPI Specification.
|
|
3
|
+
* It is used to describe an absence of a value such as when no
|
|
4
|
+
* content is returned by an operation.
|
|
5
|
+
*/
|
|
13
6
|
export class OasVoid {
|
|
14
7
|
constructor(fields = {}) {
|
|
8
|
+
/**
|
|
9
|
+
* Object is part the 'schema' set which is used
|
|
10
|
+
* to define data types in an OpenAPI document.
|
|
11
|
+
*/
|
|
15
12
|
Object.defineProperty(this, "oasType", {
|
|
16
13
|
enumerable: true,
|
|
17
14
|
configurable: true,
|
|
18
15
|
writable: true,
|
|
19
16
|
value: 'schema'
|
|
20
17
|
});
|
|
18
|
+
/**
|
|
19
|
+
* Constant value 'void' useful for type narrowing and tagged unions.
|
|
20
|
+
*/
|
|
21
21
|
Object.defineProperty(this, "type", {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
configurable: true,
|
|
24
24
|
writable: true,
|
|
25
25
|
value: 'void'
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A short summary of the value.
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(this, "title", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* A description of the value.
|
|
38
|
+
*/
|
|
39
|
+
Object.defineProperty(this, "description", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
this.title = fields.title;
|
|
46
|
+
this.description = fields.description;
|
|
29
47
|
}
|
|
30
48
|
static empty() {
|
|
31
49
|
return new OasVoid();
|
|
32
50
|
}
|
|
33
|
-
get title() {
|
|
34
|
-
return __classPrivateFieldGet(this, _OasVoid_fields, "f").title;
|
|
35
|
-
}
|
|
36
|
-
get description() {
|
|
37
|
-
return __classPrivateFieldGet(this, _OasVoid_fields, "f").description;
|
|
38
|
-
}
|
|
39
51
|
isRef() {
|
|
40
52
|
return false;
|
|
41
53
|
}
|
|
@@ -46,4 +58,3 @@ export class OasVoid {
|
|
|
46
58
|
return this;
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
|
-
_OasVoid_fields = new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IA0GF,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { clientSettings as settingsSchema } from '../types/Settings.js';
|
|
|
6
6
|
import { transform } from '../transform/transform.js';
|
|
7
7
|
import { CoreContext } from '../context/CoreContext.js';
|
|
8
8
|
const postSettingsBody = z.object({
|
|
9
|
+
defaultSelected: z.boolean().optional(),
|
|
9
10
|
schema: z.string(),
|
|
10
11
|
clientSettings: settingsSchema.optional()
|
|
11
12
|
});
|
|
@@ -44,13 +45,13 @@ export const createServer = (generators) => {
|
|
|
44
45
|
app.post('/settings', async (c) => {
|
|
45
46
|
return await Sentry.startSpan({ name: 'POST /settings' }, async (span) => {
|
|
46
47
|
const body = await c.req.json();
|
|
47
|
-
const { clientSettings } = postSettingsBody.parse(body);
|
|
48
|
+
const { clientSettings, defaultSelected = false } = postSettingsBody.parse(body);
|
|
48
49
|
const oasDocument = toOasDocument({
|
|
49
50
|
schema: body.schema,
|
|
50
51
|
spanId: span.spanContext().spanId
|
|
51
52
|
});
|
|
52
53
|
const out = generators.map(generator => {
|
|
53
|
-
const generatorSettings = clientSettings?.generators
|
|
54
|
+
const generatorSettings = clientSettings?.generators.find(({ id }) => id === generator.id);
|
|
54
55
|
const generatorType = generator.type;
|
|
55
56
|
return match(generatorType)
|
|
56
57
|
.with('operation', () => ({
|
|
@@ -59,6 +60,7 @@ export const createServer = (generators) => {
|
|
|
59
60
|
operations: toOperations({
|
|
60
61
|
generator: generator,
|
|
61
62
|
oasDocument,
|
|
63
|
+
defaultSelected,
|
|
62
64
|
operationsSettings: generatorSettings && 'operations' in generatorSettings
|
|
63
65
|
? generatorSettings.operations
|
|
64
66
|
: undefined
|
|
@@ -69,6 +71,7 @@ export const createServer = (generators) => {
|
|
|
69
71
|
id: generator.id,
|
|
70
72
|
models: toModels({
|
|
71
73
|
oasDocument,
|
|
74
|
+
defaultSelected,
|
|
72
75
|
modelsSettings: generatorSettings && 'models' in generatorSettings
|
|
73
76
|
? generatorSettings.models
|
|
74
77
|
: undefined
|
|
@@ -83,15 +86,15 @@ export const createServer = (generators) => {
|
|
|
83
86
|
});
|
|
84
87
|
return app;
|
|
85
88
|
};
|
|
86
|
-
const toModels = ({ oasDocument, modelsSettings }) => {
|
|
89
|
+
const toModels = ({ defaultSelected, oasDocument, modelsSettings }) => {
|
|
87
90
|
return Object.fromEntries(Object.keys(oasDocument.components?.schemas ?? {}).map(refName => [
|
|
88
91
|
refName,
|
|
89
92
|
modelsSettings?.[refName]
|
|
90
93
|
? modelsSettings?.[refName]
|
|
91
|
-
: { selected:
|
|
94
|
+
: { selected: defaultSelected }
|
|
92
95
|
]));
|
|
93
96
|
};
|
|
94
|
-
const toOperations = ({ generator, oasDocument, operationsSettings }) => {
|
|
97
|
+
const toOperations = ({ generator, oasDocument, operationsSettings, defaultSelected }) => {
|
|
95
98
|
return Object.values(oasDocument.operations)
|
|
96
99
|
.filter(operation => generator.isSupported(operation))
|
|
97
100
|
.reduce((acc, operation) => {
|
|
@@ -99,7 +102,7 @@ const toOperations = ({ generator, oasDocument, operationsSettings }) => {
|
|
|
99
102
|
acc[path] = acc[path] ?? {};
|
|
100
103
|
acc[path][method] = operationsSettings?.[path]?.[method]
|
|
101
104
|
? operationsSettings?.[path]?.[method]
|
|
102
|
-
: { selected:
|
|
105
|
+
: { selected: defaultSelected };
|
|
103
106
|
return acc;
|
|
104
107
|
}, {});
|
|
105
108
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { Definition } from '../dsl/Definition.js';
|
|
|
3
3
|
import type { OasDocument } from '../oas/document/Document.js';
|
|
4
4
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
5
5
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
6
|
-
import type { FileContents
|
|
6
|
+
import type { FileContents } from './types.js';
|
|
7
7
|
import type { BaseSettings, ClientSettings } from '../types/Settings.js';
|
|
8
8
|
import type { Method } from '../types/Method.js';
|
|
9
9
|
import type { OperationInsertable, OperationGateway } from '../dsl/operation/OperationInsertable.js';
|
|
@@ -85,18 +85,93 @@ export declare class GenerateContext {
|
|
|
85
85
|
callback: (generatorKey: GeneratorKey) => void;
|
|
86
86
|
captureCurrentResult: (result: SuccessWarningError) => void;
|
|
87
87
|
constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail }: ConstructorArgs);
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
88
91
|
generate(generatorsMap: Record<string, OperationGateway | ModelGateway>): Map<string, FileContents>;
|
|
89
92
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
90
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Converts schema to value using `schemaToValueFn` and creates definition
|
|
95
|
+
* with the given `identifier` at `destinationPath`.
|
|
96
|
+
*
|
|
97
|
+
* If a definition with the same name already exists, it will be returned
|
|
98
|
+
* instead of creating a new one.
|
|
99
|
+
*
|
|
100
|
+
* @param schema - The schema to create the definition for.
|
|
101
|
+
* @param identifier - The identifier for the definition.
|
|
102
|
+
* @param destinationPath - The path to the file where the definition will be registered.
|
|
103
|
+
* @param schemaToValueFn - A function that converts the schema to a value.
|
|
104
|
+
* @returns The created definition or cached definition if it already exists.
|
|
105
|
+
*/
|
|
91
106
|
createAndRegisterDefinition<Schema extends SchemaType>({ schema, identifier, destinationPath, schemaToValueFn }: CreateAndRegisterDefinition<Schema>): Definition<TypeSystemOutput<Schema['type']>>;
|
|
107
|
+
/**
|
|
108
|
+
* Insert supplied `imports` and `definitions` into file at `destinationPath`.
|
|
109
|
+
*
|
|
110
|
+
* If an import from a specified module already exists in the file, the
|
|
111
|
+
* import names are appended to the existing import.
|
|
112
|
+
*
|
|
113
|
+
* Definitions will only be added if there is not already a definition with
|
|
114
|
+
* the same name in the file.
|
|
115
|
+
*
|
|
116
|
+
* @mutates this.files
|
|
117
|
+
*/
|
|
92
118
|
register({ imports, definitions, destinationPath }: RegisterArgs): void;
|
|
119
|
+
/**
|
|
120
|
+
* Insert operation or model into the output file with path `destinationPath`.
|
|
121
|
+
*
|
|
122
|
+
* Insert will perform the following steps:
|
|
123
|
+
* 1. Generate content settings for the supplied operation or model
|
|
124
|
+
* 2. Look up definition in file with path `destinationPath`
|
|
125
|
+
* 3. If definition is not found, it will create a new one and register it
|
|
126
|
+
* 4. If the definition is defined at a location that is different from
|
|
127
|
+
* the current file, it will add an import to the current file from
|
|
128
|
+
* that location
|
|
129
|
+
* 5. Use the content settings to generate the operation/model using the
|
|
130
|
+
* insertable's driver
|
|
131
|
+
* @mutates this.files
|
|
132
|
+
*/
|
|
93
133
|
insert<V extends GeneratedValue, T extends GenerationType>({ generation, destinationPath, ...rest }: InsertArgs<V, T>): Inserted<V, T>;
|
|
134
|
+
/**
|
|
135
|
+
* Generate and return content settings for operation insertable and
|
|
136
|
+
* operation.
|
|
137
|
+
*
|
|
138
|
+
* Content settings are produced by passing base settings and operation
|
|
139
|
+
* through toIdentifier, toExportPath and isSelected static methods on the
|
|
140
|
+
* insertable.
|
|
141
|
+
* @param { operation, insertable }
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
94
144
|
toOperationContentSettings<V>({ operation, insertable }: ToOperationSettingsArgs<V>): ContentSettings;
|
|
145
|
+
/**
|
|
146
|
+
* Generate and return content settings for model insertable and refName.
|
|
147
|
+
*
|
|
148
|
+
* Content settings are produced by passing base settings and refName
|
|
149
|
+
* through toIdentifier, toExportPath and isSelected static methods on the
|
|
150
|
+
* insertable.
|
|
151
|
+
* @param { refName, insertable }
|
|
152
|
+
* @returns Content settings for model
|
|
153
|
+
*/
|
|
95
154
|
toModelContentSettings<V>({ refName, insertable }: BuildModelSettingsArgs<V>): ContentSettings;
|
|
155
|
+
/**
|
|
156
|
+
* Look up operation settings for a given generatorId, path and method.
|
|
157
|
+
* @param { generatorId, path, method }
|
|
158
|
+
* @returns Base settings for operation
|
|
159
|
+
*/
|
|
96
160
|
toOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
|
|
97
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Perform one lookup of schema by `refName`.
|
|
163
|
+
* @param refName
|
|
164
|
+
* @returns Matching schema or ref
|
|
165
|
+
* @throws if schema is not found
|
|
166
|
+
*/
|
|
98
167
|
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
99
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Check if definition name `name` in file with path `exportPath`
|
|
170
|
+
* has already been created and registered.
|
|
171
|
+
*
|
|
172
|
+
* @param { name, exportPath }
|
|
173
|
+
* @returns Matching definition if found or `undefined` otherwise
|
|
174
|
+
*/
|
|
100
175
|
findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
|
|
101
176
|
}
|
|
102
177
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,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;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;IAWpE;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -33,7 +33,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
33
33
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
35
|
};
|
|
36
|
-
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_toModelBaseSettings;
|
|
36
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_getFile, _GenerateContext_toModelBaseSettings, _GenerateContext_addFile;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.GenerateContext = void 0;
|
|
39
39
|
const mod_js_1 = require("../deps/jsr.io/@std/path/1.0.0/mod.js");
|
|
@@ -89,6 +89,9 @@ class GenerateContext {
|
|
|
89
89
|
__classPrivateFieldSet(this, _GenerateContext_stackTrail, stackTrail, "f");
|
|
90
90
|
this.captureCurrentResult = captureCurrentResult;
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
92
95
|
generate(generatorsMap) {
|
|
93
96
|
Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(generatorsMap)
|
|
94
97
|
.filter(generator => generator.type === 'operation')
|
|
@@ -115,19 +118,19 @@ class GenerateContext {
|
|
|
115
118
|
trace(token, fn) {
|
|
116
119
|
return (0, tracer_js_1.tracer)(__classPrivateFieldGet(this, _GenerateContext_stackTrail, "f"), token, fn);
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Converts schema to value using `schemaToValueFn` and creates definition
|
|
123
|
+
* with the given `identifier` at `destinationPath`.
|
|
124
|
+
*
|
|
125
|
+
* If a definition with the same name already exists, it will be returned
|
|
126
|
+
* instead of creating a new one.
|
|
127
|
+
*
|
|
128
|
+
* @param schema - The schema to create the definition for.
|
|
129
|
+
* @param identifier - The identifier for the definition.
|
|
130
|
+
* @param destinationPath - The path to the file where the definition will be registered.
|
|
131
|
+
* @param schemaToValueFn - A function that converts the schema to a value.
|
|
132
|
+
* @returns The created definition or cached definition if it already exists.
|
|
133
|
+
*/
|
|
131
134
|
createAndRegisterDefinition({ schema, identifier, destinationPath, schemaToValueFn }) {
|
|
132
135
|
const cachedDefinition = this.findDefinition({
|
|
133
136
|
name: identifier.name,
|
|
@@ -155,8 +158,20 @@ class GenerateContext {
|
|
|
155
158
|
});
|
|
156
159
|
return responseDefinition;
|
|
157
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Insert supplied `imports` and `definitions` into file at `destinationPath`.
|
|
163
|
+
*
|
|
164
|
+
* If an import from a specified module already exists in the file, the
|
|
165
|
+
* import names are appended to the existing import.
|
|
166
|
+
*
|
|
167
|
+
* Definitions will only be added if there is not already a definition with
|
|
168
|
+
* the same name in the file.
|
|
169
|
+
*
|
|
170
|
+
* @mutates this.files
|
|
171
|
+
*/
|
|
158
172
|
register({ imports = {}, definitions, destinationPath }) {
|
|
159
|
-
|
|
173
|
+
// TODO deduplicate import names and definition names against each other
|
|
174
|
+
const currentFile = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, destinationPath);
|
|
160
175
|
Object.entries(imports).forEach(([importModule, importNames]) => {
|
|
161
176
|
const module = currentFile.imports.get(importModule);
|
|
162
177
|
const importItem = new Import_js_1.Import({ module: importModule, importNames });
|
|
@@ -167,12 +182,30 @@ class GenerateContext {
|
|
|
167
182
|
currentFile.imports.set(importModule, new Set(importItem.importNames.map(n => `${n}`)));
|
|
168
183
|
}
|
|
169
184
|
});
|
|
170
|
-
definitions
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
185
|
+
definitions?.forEach(definition => {
|
|
186
|
+
if (!definition) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const { name } = definition.identifier;
|
|
190
|
+
if (!currentFile.definitions.has(name)) {
|
|
191
|
+
currentFile.definitions.set(name, definition);
|
|
192
|
+
}
|
|
174
193
|
});
|
|
175
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Insert operation or model into the output file with path `destinationPath`.
|
|
197
|
+
*
|
|
198
|
+
* Insert will perform the following steps:
|
|
199
|
+
* 1. Generate content settings for the supplied operation or model
|
|
200
|
+
* 2. Look up definition in file with path `destinationPath`
|
|
201
|
+
* 3. If definition is not found, it will create a new one and register it
|
|
202
|
+
* 4. If the definition is defined at a location that is different from
|
|
203
|
+
* the current file, it will add an import to the current file from
|
|
204
|
+
* that location
|
|
205
|
+
* 5. Use the content settings to generate the operation/model using the
|
|
206
|
+
* insertable's driver
|
|
207
|
+
* @mutates this.files
|
|
208
|
+
*/
|
|
176
209
|
insert({ generation, destinationPath, ...rest }) {
|
|
177
210
|
const { settings, definition } = (0, ts_pattern_1.match)(rest)
|
|
178
211
|
.with({ operation: ts_pattern_1.P.nonNullable }, ({ insertable, operation }) => {
|
|
@@ -196,6 +229,16 @@ class GenerateContext {
|
|
|
196
229
|
.exhaustive();
|
|
197
230
|
return new Inserted_js_1.Inserted({ settings, definition });
|
|
198
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Generate and return content settings for operation insertable and
|
|
234
|
+
* operation.
|
|
235
|
+
*
|
|
236
|
+
* Content settings are produced by passing base settings and operation
|
|
237
|
+
* through toIdentifier, toExportPath and isSelected static methods on the
|
|
238
|
+
* insertable.
|
|
239
|
+
* @param { operation, insertable }
|
|
240
|
+
* @returns
|
|
241
|
+
*/
|
|
199
242
|
toOperationContentSettings({ operation, insertable }) {
|
|
200
243
|
const baseSettings = this.toOperationBaseSettings({
|
|
201
244
|
generatorId: insertable.id,
|
|
@@ -210,6 +253,15 @@ class GenerateContext {
|
|
|
210
253
|
importFrom: baseSettings.importFrom ?? e
|
|
211
254
|
});
|
|
212
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Generate and return content settings for model insertable and refName.
|
|
258
|
+
*
|
|
259
|
+
* Content settings are produced by passing base settings and refName
|
|
260
|
+
* through toIdentifier, toExportPath and isSelected static methods on the
|
|
261
|
+
* insertable.
|
|
262
|
+
* @param { refName, insertable }
|
|
263
|
+
* @returns Content settings for model
|
|
264
|
+
*/
|
|
213
265
|
toModelContentSettings({ refName, insertable }) {
|
|
214
266
|
const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toModelBaseSettings).call(this, {
|
|
215
267
|
generatorId: insertable.id,
|
|
@@ -223,6 +275,11 @@ class GenerateContext {
|
|
|
223
275
|
importFrom: baseSettings.importFrom ?? e
|
|
224
276
|
});
|
|
225
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Look up operation settings for a given generatorId, path and method.
|
|
280
|
+
* @param { generatorId, path, method }
|
|
281
|
+
* @returns Base settings for operation
|
|
282
|
+
*/
|
|
226
283
|
toOperationBaseSettings({ generatorId, path, method }) {
|
|
227
284
|
const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
228
285
|
const operationSettings = generatorSettings && 'operations' in generatorSettings
|
|
@@ -239,18 +296,12 @@ class GenerateContext {
|
|
|
239
296
|
};
|
|
240
297
|
return baseSettings;
|
|
241
298
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
definitions: new Map(),
|
|
249
|
-
generatorKeys: new Set()
|
|
250
|
-
};
|
|
251
|
-
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
|
|
252
|
-
return newFile;
|
|
253
|
-
}
|
|
299
|
+
/**
|
|
300
|
+
* Perform one lookup of schema by `refName`.
|
|
301
|
+
* @param refName
|
|
302
|
+
* @returns Matching schema or ref
|
|
303
|
+
* @throws if schema is not found
|
|
304
|
+
*/
|
|
254
305
|
resolveSchemaRefOnce(refName) {
|
|
255
306
|
const schema = this.oasDocument.components?.schemas?.[refName]?.resolveOnce();
|
|
256
307
|
if (!schema) {
|
|
@@ -258,9 +309,15 @@ class GenerateContext {
|
|
|
258
309
|
}
|
|
259
310
|
return schema;
|
|
260
311
|
}
|
|
261
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* Check if definition name `name` in file with path `exportPath`
|
|
314
|
+
* has already been created and registered.
|
|
315
|
+
*
|
|
316
|
+
* @param { name, exportPath }
|
|
317
|
+
* @returns Matching definition if found or `undefined` otherwise
|
|
318
|
+
*/
|
|
262
319
|
findDefinition({ name, exportPath }) {
|
|
263
|
-
return this.
|
|
320
|
+
return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, exportPath).definitions.get(name);
|
|
264
321
|
}
|
|
265
322
|
}
|
|
266
323
|
exports.GenerateContext = GenerateContext;
|
|
@@ -323,6 +380,18 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
|
|
|
323
380
|
});
|
|
324
381
|
});
|
|
325
382
|
}
|
|
383
|
+
}, _GenerateContext_getFile = function _GenerateContext_getFile(filePath, { throwIfNotFound = false } = {}) {
|
|
384
|
+
const normalisedPath = (0, mod_js_1.normalize)(filePath);
|
|
385
|
+
const currentFile = __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalisedPath);
|
|
386
|
+
if (!currentFile) {
|
|
387
|
+
if (throwIfNotFound) {
|
|
388
|
+
throw new Error(`File not found: '${normalisedPath}'`);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addFile).call(this, normalisedPath);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return currentFile;
|
|
326
395
|
}, _GenerateContext_toModelBaseSettings = function _GenerateContext_toModelBaseSettings({ generatorId, refName }) {
|
|
327
396
|
const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
328
397
|
const modelSettings = generatorSettings && 'models' in generatorSettings
|
|
@@ -338,4 +407,15 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
|
|
|
338
407
|
importFrom: modelSettings?.importFrom
|
|
339
408
|
};
|
|
340
409
|
return baseSettings;
|
|
410
|
+
}, _GenerateContext_addFile = function _GenerateContext_addFile(normalisedPath) {
|
|
411
|
+
if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
|
|
412
|
+
throw new Error(`File already exists: ${normalisedPath}`);
|
|
413
|
+
}
|
|
414
|
+
const newFile = {
|
|
415
|
+
imports: new Map(),
|
|
416
|
+
definitions: new Map(),
|
|
417
|
+
generatorKeys: new Set()
|
|
418
|
+
};
|
|
419
|
+
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
|
|
420
|
+
return newFile;
|
|
341
421
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* An abstract interface which when implemented provides an interface to read
|
|
2
|
+
* An abstract interface which when implemented provides an interface to read
|
|
3
|
+
* bytes into an array buffer asynchronously.
|
|
3
4
|
*/
|
|
4
5
|
export interface Reader {
|
|
5
6
|
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
|
|
@@ -28,7 +29,8 @@ export interface Reader {
|
|
|
28
29
|
read(p: Uint8Array): Promise<number | null>;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
|
-
* An abstract interface which when implemented provides an interface to read
|
|
32
|
+
* An abstract interface which when implemented provides an interface to read
|
|
33
|
+
* bytes into an array buffer synchronously.
|
|
32
34
|
*/
|
|
33
35
|
export interface ReaderSync {
|
|
34
36
|
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
|
|
@@ -56,7 +58,8 @@ export interface ReaderSync {
|
|
|
56
58
|
readSync(p: Uint8Array): number | null;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
|
-
* An abstract interface which when implemented provides an interface to write
|
|
61
|
+
* An abstract interface which when implemented provides an interface to write
|
|
62
|
+
* bytes from an array buffer to a file/resource asynchronously.
|
|
60
63
|
*/
|
|
61
64
|
export interface Writer {
|
|
62
65
|
/** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
|
|
@@ -71,7 +74,8 @@ export interface Writer {
|
|
|
71
74
|
write(p: Uint8Array): Promise<number>;
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
74
|
-
* An abstract interface which when implemented provides an interface to write
|
|
77
|
+
* An abstract interface which when implemented provides an interface to write
|
|
78
|
+
* bytes from an array buffer to a file/resource synchronously.
|
|
75
79
|
*/
|
|
76
80
|
export interface WriterSync {
|
|
77
81
|
/** Writes `p.byteLength` bytes from `p` to the underlying data
|
|
@@ -86,10 +90,57 @@ export interface WriterSync {
|
|
|
86
90
|
writeSync(p: Uint8Array): number;
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
|
-
* An abstract interface which when implemented provides an interface to close
|
|
93
|
+
* An abstract interface which when implemented provides an interface to close
|
|
94
|
+
* files/resources that were previously opened.
|
|
90
95
|
*/
|
|
91
96
|
export interface Closer {
|
|
92
97
|
/** Closes the resource, "freeing" the backing file/resource. */
|
|
93
98
|
close(): void;
|
|
94
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* A enum which defines the seek mode for IO related APIs that support
|
|
102
|
+
* seeking.
|
|
103
|
+
*/
|
|
104
|
+
export declare enum SeekMode {
|
|
105
|
+
Start = 0,
|
|
106
|
+
Current = 1,
|
|
107
|
+
End = 2
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* An abstract interface which when implemented provides an interface to seek
|
|
111
|
+
* within an open file/resource asynchronously.
|
|
112
|
+
*/
|
|
113
|
+
export interface Seeker {
|
|
114
|
+
/** Seek sets the offset for the next `read()` or `write()` to offset,
|
|
115
|
+
* interpreted according to `whence`: `Start` means relative to the
|
|
116
|
+
* start of the file, `Current` means relative to the current offset,
|
|
117
|
+
* and `End` means relative to the end. Seek resolves to the new offset
|
|
118
|
+
* relative to the start of the file.
|
|
119
|
+
*
|
|
120
|
+
* Seeking to an offset before the start of the file is an error. Seeking to
|
|
121
|
+
* any positive offset is legal, but the behavior of subsequent I/O
|
|
122
|
+
* operations on the underlying object is implementation-dependent.
|
|
123
|
+
*
|
|
124
|
+
* It resolves with the updated offset.
|
|
125
|
+
*/
|
|
126
|
+
seek(offset: number | bigint, whence: SeekMode): Promise<number>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* An abstract interface which when implemented provides an interface to seek
|
|
130
|
+
* within an open file/resource synchronously.
|
|
131
|
+
*/
|
|
132
|
+
export interface SeekerSync {
|
|
133
|
+
/** Seek sets the offset for the next `readSync()` or `writeSync()` to
|
|
134
|
+
* offset, interpreted according to `whence`: `Start` means relative
|
|
135
|
+
* to the start of the file, `Current` means relative to the current
|
|
136
|
+
* offset, and `End` means relative to the end.
|
|
137
|
+
*
|
|
138
|
+
* Seeking to an offset before the start of the file is an error. Seeking to
|
|
139
|
+
* any positive offset is legal, but the behavior of subsequent I/O
|
|
140
|
+
* operations on the underlying object is implementation-dependent.
|
|
141
|
+
*
|
|
142
|
+
* It returns the updated offset.
|
|
143
|
+
*/
|
|
144
|
+
seekSync(offset: number | bigint, whence: SeekMode): number;
|
|
145
|
+
}
|
|
95
146
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.8/types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AACD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,gEAAgE;IAChE,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,oBAAY,QAAQ;IAElB,KAAK,IAAI;IAET,OAAO,IAAI;IAEX,GAAG,IAAI;CACR;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClE;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SeekMode = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* A enum which defines the seek mode for IO related APIs that support
|
|
8
|
+
* seeking.
|
|
9
|
+
*/
|
|
10
|
+
var SeekMode;
|
|
11
|
+
(function (SeekMode) {
|
|
12
|
+
/* Seek from the start of the file/resource. */
|
|
13
|
+
SeekMode[SeekMode["Start"] = 0] = "Start";
|
|
14
|
+
/* Seek from the current position within the file/resource. */
|
|
15
|
+
SeekMode[SeekMode["Current"] = 1] = "Current";
|
|
16
|
+
/* Seek from the end of the current file/resource. */
|
|
17
|
+
SeekMode[SeekMode["End"] = 2] = "End";
|
|
18
|
+
})(SeekMode || (exports.SeekMode = SeekMode = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write_all.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.
|
|
1
|
+
{"version":3,"file":"write_all.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.8/write_all.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAK9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,QAKhE"}
|
|
@@ -34,7 +34,7 @@ exports.FileHandler = void 0;
|
|
|
34
34
|
const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
|
|
35
35
|
const levels_js_1 = require("./levels.js");
|
|
36
36
|
const base_handler_js_1 = require("./base_handler.js");
|
|
37
|
-
const write_all_js_1 = require("../../io/0.224.
|
|
37
|
+
const write_all_js_1 = require("../../io/0.224.8/write_all.js");
|
|
38
38
|
const _file_handler_symbols_js_1 = require("./_file_handler_symbols.js");
|
|
39
39
|
/**
|
|
40
40
|
* This handler will output to a file using an optional mode (default is `a`,
|