@alagoni97/cli 0.72.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +336 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.mjs +3 -0
- package/bin/run.cmd +3 -0
- package/bin/run.mjs +4 -0
- package/dist/LoggingInterface.d.ts +123 -0
- package/dist/LoggingInterface.js +300 -0
- package/dist/PersistedConfig.d.ts +46 -0
- package/dist/PersistedConfig.js +94 -0
- package/dist/browser/adapters/output.d.ts +69 -0
- package/dist/browser/adapters/output.js +91 -0
- package/dist/browser/config.d.ts +18 -0
- package/dist/browser/config.js +59 -0
- package/dist/browser/generate.d.ts +20 -0
- package/dist/browser/generate.js +129 -0
- package/dist/browser/index.d.ts +17 -0
- package/dist/browser/index.js +26 -0
- package/dist/browser/parser.d.ts +9 -0
- package/dist/browser/parser.js +61 -0
- package/dist/browser/shims/asyncapi-parser.d.ts +30 -0
- package/dist/browser/shims/asyncapi-parser.js +52 -0
- package/dist/browser/shims/fs.d.ts +190 -0
- package/dist/browser/shims/fs.js +188 -0
- package/dist/browser/shims/json-schema-ref-parser.d.ts +73 -0
- package/dist/browser/shims/json-schema-ref-parser.js +246 -0
- package/dist/browser/shims/swagger-parser.d.ts +20 -0
- package/dist/browser/shims/swagger-parser.js +40 -0
- package/dist/codegen/configurationSchemaBuilder.d.ts +15 -0
- package/dist/codegen/configurationSchemaBuilder.js +48 -0
- package/dist/codegen/configurations.d.ts +29 -0
- package/dist/codegen/configurations.js +260 -0
- package/dist/codegen/detection.d.ts +19 -0
- package/dist/codegen/detection.js +174 -0
- package/dist/codegen/errors.d.ts +111 -0
- package/dist/codegen/errors.js +352 -0
- package/dist/codegen/generators/generic/custom.d.ts +75 -0
- package/dist/codegen/generators/generic/custom.js +66 -0
- package/dist/codegen/generators/index.d.ts +14 -0
- package/dist/codegen/generators/index.js +42 -0
- package/dist/codegen/generators/typescript/channels/asyncapi.d.ts +10 -0
- package/dist/codegen/generators/typescript/channels/asyncapi.js +131 -0
- package/dist/codegen/generators/typescript/channels/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/channels/index.js +142 -0
- package/dist/codegen/generators/typescript/channels/openapi.d.ts +9 -0
- package/dist/codegen/generators/typescript/channels/openapi.js +168 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/index.js +149 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.d.ts +5 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.js +106 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.js +102 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.js +133 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.js +100 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.d.ts +5 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.js +144 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.js +132 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/client.d.ts +10 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/client.js +224 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/common-types.d.ts +14 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/common-types.js +800 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/index.js +96 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/security.d.ts +48 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/security.js +491 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/index.js +127 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.js +108 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.js +154 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.d.ts +11 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.js +58 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.js +113 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.js +99 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.js +186 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.js +90 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.js +142 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.js +100 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.js +143 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/index.d.ts +11 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/index.js +224 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.js +89 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.js +146 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.js +149 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/utils.d.ts +35 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/utils.js +120 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/index.js +152 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.js +64 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/register.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/register.js +115 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.js +151 -0
- package/dist/codegen/generators/typescript/channels/types.d.ts +181 -0
- package/dist/codegen/generators/typescript/channels/types.js +131 -0
- package/dist/codegen/generators/typescript/channels/utils.d.ts +64 -0
- package/dist/codegen/generators/typescript/channels/utils.js +163 -0
- package/dist/codegen/generators/typescript/client/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/client/index.js +61 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.js +53 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.js +90 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.js +83 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.js +54 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.js +82 -0
- package/dist/codegen/generators/typescript/client/protocols/nats.d.ts +2 -0
- package/dist/codegen/generators/typescript/client/protocols/nats.js +182 -0
- package/dist/codegen/generators/typescript/client/types.d.ts +49 -0
- package/dist/codegen/generators/typescript/client/types.js +37 -0
- package/dist/codegen/generators/typescript/headers.d.ts +54 -0
- package/dist/codegen/generators/typescript/headers.js +138 -0
- package/dist/codegen/generators/typescript/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/index.js +38 -0
- package/dist/codegen/generators/typescript/models.d.ts +21761 -0
- package/dist/codegen/generators/typescript/models.js +64 -0
- package/dist/codegen/generators/typescript/parameters.d.ts +37 -0
- package/dist/codegen/generators/typescript/parameters.js +101 -0
- package/dist/codegen/generators/typescript/payloads.d.ts +73 -0
- package/dist/codegen/generators/typescript/payloads.js +250 -0
- package/dist/codegen/generators/typescript/types.d.ts +34 -0
- package/dist/codegen/generators/typescript/types.js +70 -0
- package/dist/codegen/generators/typescript/utils.d.ts +38 -0
- package/dist/codegen/generators/typescript/utils.js +195 -0
- package/dist/codegen/index.d.ts +7 -0
- package/dist/codegen/index.js +38 -0
- package/dist/codegen/inputs/asyncapi/generators/headers.d.ts +3 -0
- package/dist/codegen/inputs/asyncapi/generators/headers.js +41 -0
- package/dist/codegen/inputs/asyncapi/generators/parameters.d.ts +14 -0
- package/dist/codegen/inputs/asyncapi/generators/parameters.js +120 -0
- package/dist/codegen/inputs/asyncapi/generators/payloads.d.ts +16 -0
- package/dist/codegen/inputs/asyncapi/generators/payloads.js +124 -0
- package/dist/codegen/inputs/asyncapi/generators/types.d.ts +9 -0
- package/dist/codegen/inputs/asyncapi/generators/types.js +61 -0
- package/dist/codegen/inputs/asyncapi/index.d.ts +1 -0
- package/dist/codegen/inputs/asyncapi/index.js +7 -0
- package/dist/codegen/inputs/asyncapi/parser.d.ts +4 -0
- package/dist/codegen/inputs/asyncapi/parser.js +90 -0
- package/dist/codegen/inputs/index.d.ts +3 -0
- package/dist/codegen/inputs/index.js +19 -0
- package/dist/codegen/inputs/jsonschema/generators/index.d.ts +1 -0
- package/dist/codegen/inputs/jsonschema/generators/index.js +5 -0
- package/dist/codegen/inputs/jsonschema/generators/models.d.ts +7 -0
- package/dist/codegen/inputs/jsonschema/generators/models.js +26 -0
- package/dist/codegen/inputs/jsonschema/index.d.ts +1 -0
- package/dist/codegen/inputs/jsonschema/index.js +7 -0
- package/dist/codegen/inputs/jsonschema/parser.d.ts +31 -0
- package/dist/codegen/inputs/jsonschema/parser.js +128 -0
- package/dist/codegen/inputs/openapi/generators/headers.d.ts +3 -0
- package/dist/codegen/inputs/openapi/generators/headers.js +101 -0
- package/dist/codegen/inputs/openapi/generators/parameters.d.ts +10 -0
- package/dist/codegen/inputs/openapi/generators/parameters.js +852 -0
- package/dist/codegen/inputs/openapi/generators/payloads.d.ts +3 -0
- package/dist/codegen/inputs/openapi/generators/payloads.js +231 -0
- package/dist/codegen/inputs/openapi/generators/types.d.ts +9 -0
- package/dist/codegen/inputs/openapi/generators/types.js +86 -0
- package/dist/codegen/inputs/openapi/index.d.ts +2 -0
- package/dist/codegen/inputs/openapi/index.js +8 -0
- package/dist/codegen/inputs/openapi/parser.d.ts +4 -0
- package/dist/codegen/inputs/openapi/parser.js +115 -0
- package/dist/codegen/inputs/openapi/security.d.ts +56 -0
- package/dist/codegen/inputs/openapi/security.js +193 -0
- package/dist/codegen/modelina/index.d.ts +2 -0
- package/dist/codegen/modelina/index.js +20 -0
- package/dist/codegen/modelina/presets/index.d.ts +3 -0
- package/dist/codegen/modelina/presets/index.js +14 -0
- package/dist/codegen/modelina/presets/primitives.d.ts +34 -0
- package/dist/codegen/modelina/presets/primitives.js +211 -0
- package/dist/codegen/modelina/presets/union.d.ts +33 -0
- package/dist/codegen/modelina/presets/union.js +197 -0
- package/dist/codegen/modelina/presets/validation.d.ts +66 -0
- package/dist/codegen/modelina/presets/validation.js +183 -0
- package/dist/codegen/modelina/types.d.ts +61845 -0
- package/dist/codegen/modelina/types.js +412 -0
- package/dist/codegen/output/filesystem.d.ts +30 -0
- package/dist/codegen/output/filesystem.js +61 -0
- package/dist/codegen/output/index.d.ts +16 -0
- package/dist/codegen/output/index.js +57 -0
- package/dist/codegen/output/memory.d.ts +54 -0
- package/dist/codegen/output/memory.js +81 -0
- package/dist/codegen/output/modelina.d.ts +30 -0
- package/dist/codegen/output/modelina.js +30 -0
- package/dist/codegen/output/types.d.ts +47 -0
- package/dist/codegen/output/types.js +6 -0
- package/dist/codegen/renderer.d.ts +13 -0
- package/dist/codegen/renderer.js +309 -0
- package/dist/codegen/schemaPostProcess.d.ts +25 -0
- package/dist/codegen/schemaPostProcess.js +38 -0
- package/dist/codegen/types.d.ts +285187 -0
- package/dist/codegen/types.js +177 -0
- package/dist/codegen/utils.d.ts +126 -0
- package/dist/codegen/utils.js +373 -0
- package/dist/commands/base.d.ts +18 -0
- package/dist/commands/base.js +59 -0
- package/dist/commands/generate.d.ts +46 -0
- package/dist/commands/generate.js +305 -0
- package/dist/commands/init.d.ts +55 -0
- package/dist/commands/init.js +544 -0
- package/dist/commands/telemetry.d.ts +25 -0
- package/dist/commands/telemetry.js +115 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +35 -0
- package/dist/telemetry/anonymize.d.ts +19 -0
- package/dist/telemetry/anonymize.js +73 -0
- package/dist/telemetry/collector.d.ts +26 -0
- package/dist/telemetry/collector.js +57 -0
- package/dist/telemetry/config.d.ts +32 -0
- package/dist/telemetry/config.js +97 -0
- package/dist/telemetry/events.d.ts +72 -0
- package/dist/telemetry/events.js +5 -0
- package/dist/telemetry/index.d.ts +46 -0
- package/dist/telemetry/index.js +91 -0
- package/dist/telemetry/notice.d.ts +8 -0
- package/dist/telemetry/notice.js +50 -0
- package/dist/telemetry/sender.d.ts +14 -0
- package/dist/telemetry/sender.js +125 -0
- package/dist/utils/gitignore.d.ts +66 -0
- package/dist/utils/gitignore.js +111 -0
- package/dist/utils/inputSource.d.ts +3 -0
- package/dist/utils/inputSource.js +26 -0
- package/dist/utils/refResolvers.d.ts +29 -0
- package/dist/utils/refResolvers.js +83 -0
- package/dist/utils/remoteFetch.d.ts +18 -0
- package/dist/utils/remoteFetch.js +64 -0
- package/oclif.manifest.json +510 -0
- package/package.json +155 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zodTypeScriptPresets = exports.zodPresetItem = exports.zodPresetWithOptions = exports.zodTypeScriptPreset = exports.zodTypePreset = exports.zodEnumPreset = exports.zodInterfacePreset = exports.zodClassPreset = exports.zodPresetFunctionArgs = exports.zodConstrainedMetaModel = exports.zodTypeScriptRenderer = exports.zodTypeScriptOptions = exports.zodTypeScriptDependencyManager = exports.zodIndentationConfig = exports.zodTypeScriptExportType = exports.zodTypeScriptModuleSystemType = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* TypeScript module system types
|
|
7
|
+
*/
|
|
8
|
+
exports.zodTypeScriptModuleSystemType = zod_1.z
|
|
9
|
+
.enum(['ESM', 'CJS'])
|
|
10
|
+
.describe('TypeScript module system to target: "ESM" for ES modules or "CJS" for CommonJS modules. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)');
|
|
11
|
+
/**
|
|
12
|
+
* TypeScript export types
|
|
13
|
+
*/
|
|
14
|
+
exports.zodTypeScriptExportType = zod_1.z
|
|
15
|
+
.enum(['named', 'default'])
|
|
16
|
+
.describe('How generated TypeScript modules expose their primary symbol: "named" for named exports or "default" for a default export. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)');
|
|
17
|
+
/**
|
|
18
|
+
* Indentation configuration
|
|
19
|
+
*/
|
|
20
|
+
exports.zodIndentationConfig = zod_1.z
|
|
21
|
+
.object({
|
|
22
|
+
type: zod_1.z
|
|
23
|
+
.enum(['spaces', 'tabs'])
|
|
24
|
+
.describe('Whether to indent the generated code with spaces or tabs. [Read more about Modelina common options here](https://github.com/asyncapi/modelina/blob/master/src/generators/AbstractGenerator.ts)'),
|
|
25
|
+
size: zod_1.z
|
|
26
|
+
.number()
|
|
27
|
+
.min(1)
|
|
28
|
+
.max(8)
|
|
29
|
+
.default(2)
|
|
30
|
+
.describe('Number of indentation characters per indent level (1-8). Defaults to 2. [Read more about Modelina common options here](https://github.com/asyncapi/modelina/blob/master/src/generators/AbstractGenerator.ts)')
|
|
31
|
+
})
|
|
32
|
+
.describe('Controls how generated code is indented, including indentation type (spaces/tabs) and size (1-8). [Read more about Modelina common options here](https://github.com/asyncapi/modelina/blob/master/src/generators/AbstractGenerator.ts)');
|
|
33
|
+
/**
|
|
34
|
+
* TypeScript dependency manager properties
|
|
35
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptDependencyManager.ts
|
|
36
|
+
*/
|
|
37
|
+
exports.zodTypeScriptDependencyManager = zod_1.z
|
|
38
|
+
.object({
|
|
39
|
+
dependencies: zod_1.z
|
|
40
|
+
.array(zod_1.z.string())
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('Array of import statements/dependency names tracked by the dependency manager. [Read more about the Modelina TypeScript dependency manager here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptDependencyManager.ts)')
|
|
43
|
+
})
|
|
44
|
+
.partial()
|
|
45
|
+
.describe('Modelina TypeScriptDependencyManager configuration that controls imports and dependencies in generated TypeScript code. [Read more about the Modelina TypeScript dependency manager here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptDependencyManager.ts)');
|
|
46
|
+
/**
|
|
47
|
+
* TypeScript generator options
|
|
48
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts
|
|
49
|
+
*/
|
|
50
|
+
exports.zodTypeScriptOptions = zod_1.z
|
|
51
|
+
.object({
|
|
52
|
+
// From CommonGeneratorOptions
|
|
53
|
+
indentation: exports.zodIndentationConfig
|
|
54
|
+
.optional()
|
|
55
|
+
.describe('Indentation configuration applied to generated TypeScript code. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
56
|
+
dependencyManager: exports.zodTypeScriptDependencyManager
|
|
57
|
+
.optional()
|
|
58
|
+
.describe('Dependency manager configuration that controls how imports are tracked and rendered. [Read more about the Modelina TypeScript dependency manager here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptDependencyManager.ts)'),
|
|
59
|
+
// TypeScript-specific options
|
|
60
|
+
renderTypes: zod_1.z
|
|
61
|
+
.boolean()
|
|
62
|
+
.optional()
|
|
63
|
+
.default(true)
|
|
64
|
+
.describe('When true (default), TypeScript type annotations are rendered alongside the generated structures. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
65
|
+
modelType: zod_1.z
|
|
66
|
+
.enum(['class', 'interface'])
|
|
67
|
+
.optional()
|
|
68
|
+
.default('class')
|
|
69
|
+
.describe('Whether object models are generated as TypeScript classes (default) or interfaces. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
70
|
+
enumType: zod_1.z
|
|
71
|
+
.enum(['enum', 'union'])
|
|
72
|
+
.optional()
|
|
73
|
+
.default('enum')
|
|
74
|
+
.describe('How enum models are rendered: "enum" for TypeScript enums (default) or "union" for string/number union types. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
75
|
+
mapType: zod_1.z
|
|
76
|
+
.enum(['indexedObject', 'map', 'record'])
|
|
77
|
+
.optional()
|
|
78
|
+
.default('record')
|
|
79
|
+
.describe('How dictionary/map types are rendered: "record" for Record<K, V> (default), "map" for the Map class, or "indexedObject" for index signatures. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
80
|
+
moduleSystem: exports.zodTypeScriptModuleSystemType
|
|
81
|
+
.optional()
|
|
82
|
+
.default('ESM')
|
|
83
|
+
.describe('Module system the generated code targets. Defaults to "ESM". [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
84
|
+
useJavascriptReservedKeywords: zod_1.z
|
|
85
|
+
.boolean()
|
|
86
|
+
.optional()
|
|
87
|
+
.default(false)
|
|
88
|
+
.describe('When true, JavaScript reserved keywords are permitted as identifiers. Defaults to false to keep generated code valid in transpiled JavaScript output. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
89
|
+
rawPropertyNames: zod_1.z
|
|
90
|
+
.boolean()
|
|
91
|
+
.optional()
|
|
92
|
+
.default(false)
|
|
93
|
+
.describe('When true, properties keep their raw names from the input schema with no naming constraints applied. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
94
|
+
// Complex options - using any for practical reasons
|
|
95
|
+
typeMapping: zod_1.z
|
|
96
|
+
.any()
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Custom type mappings that override how Modelina maps schema types to TypeScript types (complex Modelina type). [Read more about Modelina type mapping here](https://github.com/asyncapi/modelina/blob/master/docs/custom_type_mapping.md)'),
|
|
99
|
+
constraints: zod_1.z
|
|
100
|
+
.any()
|
|
101
|
+
.optional()
|
|
102
|
+
.describe('Custom naming and validation constraints applied during constraining (complex Modelina type). [Read more about Modelina constraints here](https://github.com/asyncapi/modelina/blob/master/docs/constraints.md)'),
|
|
103
|
+
presets: zod_1.z
|
|
104
|
+
.any()
|
|
105
|
+
.optional()
|
|
106
|
+
.default([])
|
|
107
|
+
.describe('Array of Modelina presets that customize how the TypeScript code is rendered. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
108
|
+
defaultPreset: zod_1.z
|
|
109
|
+
.any()
|
|
110
|
+
.optional()
|
|
111
|
+
.describe('Override the default preset used by the TypeScript generator (complex Modelina type). [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
112
|
+
processorOptions: zod_1.z
|
|
113
|
+
.any()
|
|
114
|
+
.optional()
|
|
115
|
+
.describe('Options forwarded to the schema processor (e.g. AsyncAPI/JSON Schema processor) used to convert input documents into Modelina meta models (complex Modelina type). [Read more about Modelina input processors here](https://github.com/asyncapi/modelina/blob/master/docs/input_processing.md)')
|
|
116
|
+
})
|
|
117
|
+
.partial()
|
|
118
|
+
.describe('Modelina TypeScriptOptions used to configure TypeScript code generation, including model types, enums, modules, and constraints. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)');
|
|
119
|
+
/**
|
|
120
|
+
* TypeScript renderer properties
|
|
121
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts
|
|
122
|
+
*/
|
|
123
|
+
exports.zodTypeScriptRenderer = zod_1.z
|
|
124
|
+
.object({
|
|
125
|
+
// Essential renderer properties
|
|
126
|
+
dependencyManager: exports.zodTypeScriptDependencyManager
|
|
127
|
+
.optional()
|
|
128
|
+
.describe('Dependency manager that tracks and renders imports for the model currently being generated. [Read more about the Modelina TypeScript dependency manager here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptDependencyManager.ts)'),
|
|
129
|
+
// Common renderer methods
|
|
130
|
+
renderComments: zod_1.z
|
|
131
|
+
.function()
|
|
132
|
+
.optional()
|
|
133
|
+
.describe('Render JSDoc-style comments for the current content. [Read more about the Modelina TypeScript renderer here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts)'),
|
|
134
|
+
renderLine: zod_1.z
|
|
135
|
+
.function()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("Render a single line of code with the renderer's current indentation applied. [Read more about the Modelina TypeScript renderer here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts)"),
|
|
138
|
+
renderBlock: zod_1.z
|
|
139
|
+
.function()
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('Render multiple lines of code as an indented block. [Read more about the Modelina TypeScript renderer here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts)'),
|
|
142
|
+
indent: zod_1.z
|
|
143
|
+
.function()
|
|
144
|
+
.optional()
|
|
145
|
+
.describe('Apply the configured indentation to a piece of content. [Read more about the Modelina TypeScript renderer here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts)'),
|
|
146
|
+
runSelfPreset: zod_1.z
|
|
147
|
+
.function()
|
|
148
|
+
.optional()
|
|
149
|
+
.describe('Execute the "self" preset function for the model currently being rendered. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
150
|
+
runAdditionalContentPreset: zod_1.z
|
|
151
|
+
.function()
|
|
152
|
+
.optional()
|
|
153
|
+
.describe('Execute the "additionalContent" preset hook to append custom content to the rendered model. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
154
|
+
runPreset: zod_1.z
|
|
155
|
+
.function()
|
|
156
|
+
.optional()
|
|
157
|
+
.describe('Execute a specific preset function by name. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
158
|
+
// Complex internal properties
|
|
159
|
+
options: exports.zodTypeScriptOptions
|
|
160
|
+
.optional()
|
|
161
|
+
.describe('The TypeScriptOptions in effect for this renderer. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
162
|
+
generator: zod_1.z
|
|
163
|
+
.any()
|
|
164
|
+
.optional()
|
|
165
|
+
.describe('The TypeScriptGenerator instance that owns this renderer (complex Modelina type). [Read more about the Modelina TypeScript generator here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)'),
|
|
166
|
+
presets: zod_1.z
|
|
167
|
+
.any()
|
|
168
|
+
.optional()
|
|
169
|
+
.describe('The array of presets active for this renderer. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
170
|
+
model: zod_1.z
|
|
171
|
+
.any()
|
|
172
|
+
.optional()
|
|
173
|
+
.describe('The ConstrainedMetaModel that is currently being rendered. [Read more about the Modelina internal model here](https://github.com/asyncapi/modelina/blob/master/docs/internal-model.md)'),
|
|
174
|
+
inputModel: zod_1.z
|
|
175
|
+
.any()
|
|
176
|
+
.optional()
|
|
177
|
+
.describe('The original InputMetaModel (complex Modelina type) that produced the current model. [Read more about the Modelina internal model here](https://github.com/asyncapi/modelina/blob/master/docs/internal-model.md)')
|
|
178
|
+
})
|
|
179
|
+
.partial()
|
|
180
|
+
.describe('Modelina TypeScriptRenderer used to provide rendering helpers for TypeScript code generation inside preset functions. [Read more about the Modelina TypeScript renderer here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts)');
|
|
181
|
+
/**
|
|
182
|
+
* ConstrainedMetaModel properties
|
|
183
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts
|
|
184
|
+
* @see https://github.com/asyncapi/modelina/blob/master/docs/internal-model.md
|
|
185
|
+
*/
|
|
186
|
+
exports.zodConstrainedMetaModel = zod_1.z
|
|
187
|
+
.object({
|
|
188
|
+
// Common properties
|
|
189
|
+
originalInput: zod_1.z
|
|
190
|
+
.any()
|
|
191
|
+
.optional()
|
|
192
|
+
.describe('The original schema fragment that produced this model before any transformations were applied. [Read more about the Modelina internal model here](https://github.com/asyncapi/modelina/blob/master/docs/internal-model.md)'),
|
|
193
|
+
type: zod_1.z
|
|
194
|
+
.string()
|
|
195
|
+
.optional()
|
|
196
|
+
.describe('The kind of model this represents (e.g. "object", "string", "enum"). [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)'),
|
|
197
|
+
name: zod_1.z
|
|
198
|
+
.string()
|
|
199
|
+
.optional()
|
|
200
|
+
.describe('The constrained (rendered) name of the model after naming constraints have been applied. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)'),
|
|
201
|
+
// For object models
|
|
202
|
+
properties: zod_1.z
|
|
203
|
+
.record(zod_1.z.any())
|
|
204
|
+
.optional()
|
|
205
|
+
.describe('The properties of an object model, keyed by constrained property name. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)'),
|
|
206
|
+
// For enum models
|
|
207
|
+
values: zod_1.z
|
|
208
|
+
.array(zod_1.z.any())
|
|
209
|
+
.optional()
|
|
210
|
+
.describe('The enum values when this model represents an enum. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)'),
|
|
211
|
+
// Complex properties
|
|
212
|
+
options: zod_1.z
|
|
213
|
+
.any()
|
|
214
|
+
.optional()
|
|
215
|
+
.describe('Model-specific options carried through from the input schema. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)'),
|
|
216
|
+
constraints: zod_1.z
|
|
217
|
+
.any()
|
|
218
|
+
.optional()
|
|
219
|
+
.describe('The constraints and transformations that have been applied to produce this constrained model. [Read more about Modelina constraints here](https://github.com/asyncapi/modelina/blob/master/docs/constraints.md)')
|
|
220
|
+
})
|
|
221
|
+
.partial()
|
|
222
|
+
.describe('Modelina ConstrainedMetaModel that represents a processed schema model with naming and other constraints applied. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts) and [read more about the Modelina internal model here](https://github.com/asyncapi/modelina/blob/master/docs/internal-model.md)');
|
|
223
|
+
/**
|
|
224
|
+
* Preset function parameters
|
|
225
|
+
* @see https://github.com/asyncapi/modelina/blob/master/docs/presets.md
|
|
226
|
+
*/
|
|
227
|
+
exports.zodPresetFunctionArgs = zod_1.z
|
|
228
|
+
.object({
|
|
229
|
+
content: zod_1.z
|
|
230
|
+
.string()
|
|
231
|
+
.describe('The current rendered content for this hook, which the preset function may transform or extend. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
232
|
+
model: exports.zodConstrainedMetaModel.describe('The ConstrainedMetaModel currently being processed by the preset. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)'),
|
|
233
|
+
renderer: exports.zodTypeScriptRenderer.describe('The TypeScriptRenderer instance providing helper methods for generating code. [Read more about the Modelina TypeScript renderer here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptRenderer.ts)'),
|
|
234
|
+
options: exports.zodTypeScriptOptions
|
|
235
|
+
.optional()
|
|
236
|
+
.describe('The TypeScriptOptions in effect for this generation run. [Read more about Modelina TypeScript options here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptGenerator.ts)')
|
|
237
|
+
})
|
|
238
|
+
.describe('Standard parameters passed to Modelina preset functions: content (current code), model (schema model), renderer (helper methods), and options (generator config). [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)');
|
|
239
|
+
/**
|
|
240
|
+
* TypeScript class preset methods
|
|
241
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts
|
|
242
|
+
*/
|
|
243
|
+
exports.zodClassPreset = zod_1.z
|
|
244
|
+
.object({
|
|
245
|
+
self: zod_1.z
|
|
246
|
+
.function()
|
|
247
|
+
.args(exports.zodPresetFunctionArgs)
|
|
248
|
+
.returns(zod_1.z.string())
|
|
249
|
+
.optional()
|
|
250
|
+
.describe('Customize the entire rendered class. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)'),
|
|
251
|
+
ctor: zod_1.z
|
|
252
|
+
.function()
|
|
253
|
+
.args(exports.zodPresetFunctionArgs)
|
|
254
|
+
.returns(zod_1.z.string())
|
|
255
|
+
.optional()
|
|
256
|
+
.describe('Customize the rendered class constructor. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)'),
|
|
257
|
+
property: zod_1.z
|
|
258
|
+
.function()
|
|
259
|
+
.args(exports.zodPresetFunctionArgs.extend({
|
|
260
|
+
property: zod_1.z
|
|
261
|
+
.any()
|
|
262
|
+
.describe('The ConstrainedObjectPropertyModel currently being rendered. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)')
|
|
263
|
+
}))
|
|
264
|
+
.returns(zod_1.z.string())
|
|
265
|
+
.optional()
|
|
266
|
+
.describe('Customize how individual properties are rendered on the class. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)'),
|
|
267
|
+
getter: zod_1.z
|
|
268
|
+
.function()
|
|
269
|
+
.args(exports.zodPresetFunctionArgs.extend({
|
|
270
|
+
property: zod_1.z
|
|
271
|
+
.any()
|
|
272
|
+
.describe('The ConstrainedObjectPropertyModel that the getter is being rendered for. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)')
|
|
273
|
+
}))
|
|
274
|
+
.returns(zod_1.z.string())
|
|
275
|
+
.optional()
|
|
276
|
+
.describe('Customize property getter methods on the class. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)'),
|
|
277
|
+
setter: zod_1.z
|
|
278
|
+
.function()
|
|
279
|
+
.args(exports.zodPresetFunctionArgs.extend({
|
|
280
|
+
property: zod_1.z
|
|
281
|
+
.any()
|
|
282
|
+
.describe('The ConstrainedObjectPropertyModel that the setter is being rendered for. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)')
|
|
283
|
+
}))
|
|
284
|
+
.returns(zod_1.z.string())
|
|
285
|
+
.optional()
|
|
286
|
+
.describe('Customize property setter methods on the class. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)'),
|
|
287
|
+
additionalContent: zod_1.z
|
|
288
|
+
.function()
|
|
289
|
+
.args(exports.zodPresetFunctionArgs)
|
|
290
|
+
.returns(zod_1.z.string())
|
|
291
|
+
.optional()
|
|
292
|
+
.describe('Append custom methods or other content to the rendered class. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)')
|
|
293
|
+
})
|
|
294
|
+
.partial()
|
|
295
|
+
.describe('Modelina TypeScript class preset hooks used to customize class generation, including self, constructor, properties, getters, setters, and additional content. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)');
|
|
296
|
+
/**
|
|
297
|
+
* TypeScript interface preset methods
|
|
298
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/InterfaceRenderer.ts
|
|
299
|
+
*/
|
|
300
|
+
exports.zodInterfacePreset = zod_1.z
|
|
301
|
+
.object({
|
|
302
|
+
self: zod_1.z
|
|
303
|
+
.function()
|
|
304
|
+
.args(exports.zodPresetFunctionArgs)
|
|
305
|
+
.returns(zod_1.z.string())
|
|
306
|
+
.optional()
|
|
307
|
+
.describe('Customize the entire rendered interface. [Read more about Modelina interface presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/InterfaceRenderer.ts)'),
|
|
308
|
+
property: zod_1.z
|
|
309
|
+
.function()
|
|
310
|
+
.args(exports.zodPresetFunctionArgs.extend({
|
|
311
|
+
property: zod_1.z
|
|
312
|
+
.any()
|
|
313
|
+
.describe('The ConstrainedObjectPropertyModel currently being rendered on the interface. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)')
|
|
314
|
+
}))
|
|
315
|
+
.returns(zod_1.z.string())
|
|
316
|
+
.optional()
|
|
317
|
+
.describe('Customize how individual properties are rendered on the interface. [Read more about Modelina interface presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/InterfaceRenderer.ts)'),
|
|
318
|
+
additionalContent: zod_1.z
|
|
319
|
+
.function()
|
|
320
|
+
.args(exports.zodPresetFunctionArgs)
|
|
321
|
+
.returns(zod_1.z.string())
|
|
322
|
+
.optional()
|
|
323
|
+
.describe('Append custom content to the rendered interface. [Read more about Modelina interface presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/InterfaceRenderer.ts)')
|
|
324
|
+
})
|
|
325
|
+
.partial()
|
|
326
|
+
.describe('Modelina TypeScript interface preset hooks used to customize interface generation, including self, properties, and additional content. [Read more about Modelina interface presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/InterfaceRenderer.ts)');
|
|
327
|
+
/**
|
|
328
|
+
* TypeScript enum preset methods
|
|
329
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/EnumRenderer.ts
|
|
330
|
+
*/
|
|
331
|
+
exports.zodEnumPreset = zod_1.z
|
|
332
|
+
.object({
|
|
333
|
+
self: zod_1.z
|
|
334
|
+
.function()
|
|
335
|
+
.args(exports.zodPresetFunctionArgs)
|
|
336
|
+
.returns(zod_1.z.string())
|
|
337
|
+
.optional()
|
|
338
|
+
.describe('Customize the entire rendered enum. [Read more about Modelina enum presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/EnumRenderer.ts)'),
|
|
339
|
+
item: zod_1.z
|
|
340
|
+
.function()
|
|
341
|
+
.args(exports.zodPresetFunctionArgs.extend({
|
|
342
|
+
item: zod_1.z
|
|
343
|
+
.any()
|
|
344
|
+
.describe('The ConstrainedEnumValueModel currently being rendered as an enum item. [Read more about the Modelina ConstrainedMetaModel here](https://github.com/asyncapi/modelina/blob/master/src/models/ConstrainedMetaModel.ts)')
|
|
345
|
+
}))
|
|
346
|
+
.returns(zod_1.z.string())
|
|
347
|
+
.optional()
|
|
348
|
+
.describe('Customize the rendering of individual enum items. [Read more about Modelina enum presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/EnumRenderer.ts)')
|
|
349
|
+
})
|
|
350
|
+
.partial()
|
|
351
|
+
.describe('Modelina TypeScript enum preset hooks used to customize enum generation, including self and individual enum items. [Read more about Modelina enum presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/EnumRenderer.ts)');
|
|
352
|
+
/**
|
|
353
|
+
* TypeScript type preset methods
|
|
354
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/TypeRenderer.ts
|
|
355
|
+
*/
|
|
356
|
+
exports.zodTypePreset = zod_1.z
|
|
357
|
+
.object({
|
|
358
|
+
self: zod_1.z
|
|
359
|
+
.function()
|
|
360
|
+
.args(exports.zodPresetFunctionArgs)
|
|
361
|
+
.returns(zod_1.z.string())
|
|
362
|
+
.optional()
|
|
363
|
+
.describe('Customize the entire rendered type alias. [Read more about Modelina type presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/TypeRenderer.ts)')
|
|
364
|
+
})
|
|
365
|
+
.partial()
|
|
366
|
+
.describe('Modelina TypeScript type preset hooks used to customize type alias generation. [Read more about Modelina type presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/TypeRenderer.ts)');
|
|
367
|
+
/**
|
|
368
|
+
* Complete TypeScript preset object
|
|
369
|
+
* @see https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptPreset.ts
|
|
370
|
+
*/
|
|
371
|
+
exports.zodTypeScriptPreset = zod_1.z
|
|
372
|
+
.object({
|
|
373
|
+
class: exports.zodClassPreset
|
|
374
|
+
.optional()
|
|
375
|
+
.describe('Hooks for customizing class rendering. [Read more about Modelina class presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/ClassRenderer.ts)'),
|
|
376
|
+
interface: exports.zodInterfacePreset
|
|
377
|
+
.optional()
|
|
378
|
+
.describe('Hooks for customizing interface rendering. [Read more about Modelina interface presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/InterfaceRenderer.ts)'),
|
|
379
|
+
enum: exports.zodEnumPreset
|
|
380
|
+
.optional()
|
|
381
|
+
.describe('Hooks for customizing enum rendering. [Read more about Modelina enum presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/EnumRenderer.ts)'),
|
|
382
|
+
type: exports.zodTypePreset
|
|
383
|
+
.optional()
|
|
384
|
+
.describe('Hooks for customizing type alias rendering. [Read more about Modelina type presets here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/renderers/TypeRenderer.ts)')
|
|
385
|
+
})
|
|
386
|
+
.partial()
|
|
387
|
+
.describe('Complete Modelina TypeScript preset that bundles class, interface, enum, and type hooks together. [Read more about the Modelina TypeScript preset here](https://github.com/asyncapi/modelina/blob/master/src/generators/typescript/TypeScriptPreset.ts)');
|
|
388
|
+
/**
|
|
389
|
+
* Preset with options pattern
|
|
390
|
+
*/
|
|
391
|
+
exports.zodPresetWithOptions = zod_1.z
|
|
392
|
+
.object({
|
|
393
|
+
preset: exports.zodTypeScriptPreset.describe('The Modelina preset whose hooks will be applied. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)'),
|
|
394
|
+
options: zod_1.z
|
|
395
|
+
.record(zod_1.z.any())
|
|
396
|
+
.optional()
|
|
397
|
+
.describe('Options forwarded to the preset (e.g. enabling marshalling on TS_COMMON_PRESET). [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)')
|
|
398
|
+
})
|
|
399
|
+
.describe('Modelina preset paired with options. Used for reusable presets such as TS_COMMON_PRESET that accept configuration. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)');
|
|
400
|
+
/**
|
|
401
|
+
* Preset array items
|
|
402
|
+
*/
|
|
403
|
+
exports.zodPresetItem = zod_1.z
|
|
404
|
+
.union([exports.zodTypeScriptPreset, exports.zodPresetWithOptions])
|
|
405
|
+
.describe('An entry in the Modelina presets array. Either a direct preset object or a preset paired with options. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)');
|
|
406
|
+
/**
|
|
407
|
+
* Array of TypeScript presets
|
|
408
|
+
*/
|
|
409
|
+
exports.zodTypeScriptPresets = zod_1.z
|
|
410
|
+
.array(exports.zodPresetItem)
|
|
411
|
+
.describe('Array of Modelina TypeScript presets passed to TypeScriptFileGenerator. Presets act as middleware that customizes the generated code. [Read more about Modelina presets here](https://github.com/asyncapi/modelina/blob/master/docs/presets.md)')
|
|
412
|
+
.default([]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OutputAdapter, OutputAdapterOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* FileSystemAdapter writes files to disk using Node.js fs APIs.
|
|
4
|
+
* Used in CLI context for actual file generation.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileSystemAdapter implements OutputAdapter {
|
|
7
|
+
private writtenFiles;
|
|
8
|
+
private basePath;
|
|
9
|
+
constructor(options?: OutputAdapterOptions);
|
|
10
|
+
/**
|
|
11
|
+
* Write content to a file on disk.
|
|
12
|
+
* Creates parent directories if they don't exist.
|
|
13
|
+
*/
|
|
14
|
+
write(filePath: string, content: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a directory on disk.
|
|
17
|
+
*/
|
|
18
|
+
mkdir(dirPath: string, options?: {
|
|
19
|
+
recursive?: boolean;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Get all file paths that were written.
|
|
23
|
+
*/
|
|
24
|
+
getWrittenFiles(): string[];
|
|
25
|
+
/**
|
|
26
|
+
* FileSystemAdapter doesn't keep content in memory.
|
|
27
|
+
* Returns empty object - use getWrittenFiles() for paths.
|
|
28
|
+
*/
|
|
29
|
+
getAllFiles(): Record<string, string>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FileSystemAdapter = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* FileSystemAdapter - Output adapter for CLI/Node.js environments.
|
|
9
|
+
* Writes files to the local filesystem.
|
|
10
|
+
*/
|
|
11
|
+
const promises_1 = require("node:fs/promises");
|
|
12
|
+
const node_process_1 = require("node:process");
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
/**
|
|
15
|
+
* FileSystemAdapter writes files to disk using Node.js fs APIs.
|
|
16
|
+
* Used in CLI context for actual file generation.
|
|
17
|
+
*/
|
|
18
|
+
class FileSystemAdapter {
|
|
19
|
+
writtenFiles = [];
|
|
20
|
+
basePath;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.basePath = options?.basePath ?? (0, node_process_1.cwd)();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Write content to a file on disk.
|
|
26
|
+
* Creates parent directories if they don't exist.
|
|
27
|
+
*/
|
|
28
|
+
async write(filePath, content) {
|
|
29
|
+
const resolvedPath = node_path_1.default.isAbsolute(filePath)
|
|
30
|
+
? filePath
|
|
31
|
+
: node_path_1.default.resolve(this.basePath, filePath);
|
|
32
|
+
// Ensure parent directory exists
|
|
33
|
+
const parentDir = node_path_1.default.dirname(resolvedPath);
|
|
34
|
+
await (0, promises_1.mkdir)(parentDir, { recursive: true });
|
|
35
|
+
await (0, promises_1.writeFile)(resolvedPath, content);
|
|
36
|
+
this.writtenFiles.push(resolvedPath);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a directory on disk.
|
|
40
|
+
*/
|
|
41
|
+
async mkdir(dirPath, options) {
|
|
42
|
+
const resolvedPath = node_path_1.default.isAbsolute(dirPath)
|
|
43
|
+
? dirPath
|
|
44
|
+
: node_path_1.default.resolve(this.basePath, dirPath);
|
|
45
|
+
await (0, promises_1.mkdir)(resolvedPath, options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get all file paths that were written.
|
|
49
|
+
*/
|
|
50
|
+
getWrittenFiles() {
|
|
51
|
+
return [...this.writtenFiles];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* FileSystemAdapter doesn't keep content in memory.
|
|
55
|
+
* Returns empty object - use getWrittenFiles() for paths.
|
|
56
|
+
*/
|
|
57
|
+
getAllFiles() {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.FileSystemAdapter = FileSystemAdapter;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GeneratedFile } from '../types';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export { FileSystemAdapter } from './filesystem';
|
|
4
|
+
export { MemoryAdapter } from './memory';
|
|
5
|
+
export { generateModels } from './modelina';
|
|
6
|
+
export type { GenerateModelsArgs, GenerateModelsResult } from './modelina';
|
|
7
|
+
export type { GeneratedFile } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Write generated files to disk.
|
|
10
|
+
* This is the I/O boundary - called by CLI after pure generation.
|
|
11
|
+
*
|
|
12
|
+
* @param files - The generated files with path and content
|
|
13
|
+
* @param basePath - The base path to resolve relative paths from
|
|
14
|
+
* @returns Array of absolute paths that were written
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeGeneratedFiles(files: GeneratedFile[], basePath: string): Promise<string[]>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.writeGeneratedFiles = exports.generateModels = exports.MemoryAdapter = exports.FileSystemAdapter = void 0;
|
|
21
|
+
/**
|
|
22
|
+
* Output adapter module.
|
|
23
|
+
* Provides abstractions for file output operations that work in both
|
|
24
|
+
* CLI (filesystem) and browser (memory) environments.
|
|
25
|
+
*/
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const filesystem_1 = require("./filesystem");
|
|
28
|
+
__exportStar(require("./types"), exports);
|
|
29
|
+
var filesystem_2 = require("./filesystem");
|
|
30
|
+
Object.defineProperty(exports, "FileSystemAdapter", { enumerable: true, get: function () { return filesystem_2.FileSystemAdapter; } });
|
|
31
|
+
var memory_1 = require("./memory");
|
|
32
|
+
Object.defineProperty(exports, "MemoryAdapter", { enumerable: true, get: function () { return memory_1.MemoryAdapter; } });
|
|
33
|
+
var modelina_1 = require("./modelina");
|
|
34
|
+
Object.defineProperty(exports, "generateModels", { enumerable: true, get: function () { return modelina_1.generateModels; } });
|
|
35
|
+
/**
|
|
36
|
+
* Write generated files to disk.
|
|
37
|
+
* This is the I/O boundary - called by CLI after pure generation.
|
|
38
|
+
*
|
|
39
|
+
* @param files - The generated files with path and content
|
|
40
|
+
* @param basePath - The base path to resolve relative paths from
|
|
41
|
+
* @returns Array of absolute paths that were written
|
|
42
|
+
*/
|
|
43
|
+
async function writeGeneratedFiles(files, basePath) {
|
|
44
|
+
const adapter = new filesystem_1.FileSystemAdapter({ basePath });
|
|
45
|
+
const writtenPaths = [];
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
// Ensure directory exists
|
|
48
|
+
const dirPath = path_1.default.dirname(file.path);
|
|
49
|
+
if (dirPath && dirPath !== '.') {
|
|
50
|
+
await adapter.mkdir(dirPath, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
await adapter.write(file.path, file.content);
|
|
53
|
+
writtenPaths.push(path_1.default.resolve(basePath, file.path));
|
|
54
|
+
}
|
|
55
|
+
return writtenPaths;
|
|
56
|
+
}
|
|
57
|
+
exports.writeGeneratedFiles = writeGeneratedFiles;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryAdapter - Output adapter for browser environments.
|
|
3
|
+
* Stores files in memory instead of writing to disk.
|
|
4
|
+
*/
|
|
5
|
+
import { OutputAdapter, OutputAdapterOptions } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* MemoryAdapter stores files in memory using a Map.
|
|
8
|
+
* Used in browser context for in-memory code generation.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MemoryAdapter implements OutputAdapter {
|
|
11
|
+
private files;
|
|
12
|
+
private basePath;
|
|
13
|
+
constructor(options?: OutputAdapterOptions);
|
|
14
|
+
/**
|
|
15
|
+
* Write content to memory.
|
|
16
|
+
*/
|
|
17
|
+
write(filePath: string, content: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* No-op for memory adapter - directories are virtual.
|
|
20
|
+
*/
|
|
21
|
+
mkdir(_dirPath: string, _options?: {
|
|
22
|
+
recursive?: boolean;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get all file paths that were written.
|
|
26
|
+
*/
|
|
27
|
+
getWrittenFiles(): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Get all files with their content.
|
|
30
|
+
*/
|
|
31
|
+
getAllFiles(): Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Read a file from memory.
|
|
34
|
+
* @param filePath - The file path
|
|
35
|
+
* @returns The file content, or undefined if not found
|
|
36
|
+
*/
|
|
37
|
+
read(filePath: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Clear all files from memory.
|
|
40
|
+
*/
|
|
41
|
+
clear(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a file exists.
|
|
44
|
+
*/
|
|
45
|
+
has(filePath: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the number of files.
|
|
48
|
+
*/
|
|
49
|
+
get size(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve a file path with the base path.
|
|
52
|
+
*/
|
|
53
|
+
private resolvePath;
|
|
54
|
+
}
|