swagger-sdk-generator 0.0.0-stage → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -2
- package/dist/cli/commands/generate.d.ts +2 -0
- package/dist/cli/commands/generate.js +196 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.js +130 -0
- package/dist/cli/commands/inspect.d.ts +2 -0
- package/dist/cli/commands/inspect.js +164 -0
- package/dist/cli/commands/templates.d.ts +2 -0
- package/dist/cli/commands/templates.js +126 -0
- package/dist/cli/context.d.ts +16 -0
- package/dist/cli/context.js +85 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +25 -0
- package/dist/config/dotenv.d.ts +2 -0
- package/dist/config/dotenv.js +82 -0
- package/dist/config/interpolate.d.ts +8 -0
- package/dist/config/interpolate.js +85 -0
- package/dist/config/load.d.ts +11 -0
- package/dist/config/load.js +182 -0
- package/dist/config/migrate-v3.d.ts +5 -0
- package/dist/config/migrate-v3.js +6 -0
- package/dist/config/mode-compatibility.d.ts +9 -0
- package/dist/config/mode-compatibility.js +17 -0
- package/dist/config/modes.d.ts +13 -0
- package/dist/config/modes.js +27 -0
- package/dist/config/preset-definitions.d.ts +2 -0
- package/dist/config/preset-definitions.js +4 -0
- package/dist/config/presets.d.ts +25 -0
- package/dist/config/presets.js +36 -0
- package/dist/config/resolve.d.ts +32 -0
- package/dist/config/resolve.js +288 -0
- package/dist/config/schema.d.ts +93 -0
- package/dist/config/schema.js +173 -0
- package/dist/config/types.d.ts +42 -0
- package/dist/config/types.js +2 -0
- package/dist/config/workspace.d.ts +30 -0
- package/dist/config/workspace.js +95 -0
- package/dist/core/case-align.d.ts +5 -0
- package/dist/core/case-align.js +90 -0
- package/dist/core/deep-merge.d.ts +2 -0
- package/dist/core/deep-merge.js +21 -0
- package/dist/core/file-set.d.ts +10 -0
- package/dist/core/file-set.js +31 -0
- package/dist/core/import-module.d.ts +1 -0
- package/dist/core/import-module.js +61 -0
- package/dist/core/log.d.ts +9 -0
- package/dist/core/log.js +24 -0
- package/dist/core/manifest.d.ts +17 -0
- package/dist/core/manifest.js +195 -0
- package/dist/core/overlaps.d.ts +6 -0
- package/dist/core/overlaps.js +67 -0
- package/dist/core/package-version.d.ts +1 -0
- package/dist/core/package-version.js +44 -0
- package/dist/core/pipeline.d.ts +30 -0
- package/dist/core/pipeline.js +335 -0
- package/dist/core/plugin.d.ts +72 -0
- package/dist/core/plugin.js +2 -0
- package/dist/core/targets.d.ts +14 -0
- package/dist/core/targets.js +120 -0
- package/dist/core/unmanaged.d.ts +3 -0
- package/dist/core/unmanaged.js +101 -0
- package/dist/core/writer.d.ts +28 -0
- package/dist/core/writer.js +148 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +37 -0
- package/dist/ir/casing.d.ts +5 -0
- package/dist/ir/casing.js +22 -0
- package/dist/ir/graph.d.ts +8 -0
- package/dist/ir/graph.js +95 -0
- package/dist/ir/operations/grouping.d.ts +17 -0
- package/dist/ir/operations/grouping.js +39 -0
- package/dist/ir/operations/legacy-naming.d.ts +2 -0
- package/dist/ir/operations/legacy-naming.js +8 -0
- package/dist/ir/operations/naming.d.ts +6 -0
- package/dist/ir/operations/naming.js +54 -0
- package/dist/ir/option-errors.d.ts +3 -0
- package/dist/ir/option-errors.js +68 -0
- package/dist/ir/transforms/builtins.d.ts +2 -0
- package/dist/ir/transforms/builtins.js +4 -0
- package/dist/ir/transforms/index.d.ts +10 -0
- package/dist/ir/transforms/index.js +39 -0
- package/dist/ir/transforms/types.d.ts +9 -0
- package/dist/ir/transforms/types.js +2 -0
- package/dist/ir/types.d.ts +140 -0
- package/dist/ir/types.js +2 -0
- package/dist/runtime/axios.d.ts +28 -0
- package/dist/runtime/axios.js +132 -0
- package/dist/runtime/fetch.d.ts +6 -0
- package/dist/runtime/fetch.js +38 -0
- package/dist/runtime/index.d.ts +54 -0
- package/dist/runtime/index.js +167 -0
- package/dist/runtime/rtk.d.ts +35 -0
- package/dist/runtime/rtk.js +36 -0
- package/dist/runtime/transport.d.ts +38 -0
- package/dist/runtime/transport.js +30 -0
- package/dist/runtime/wire.d.ts +27 -0
- package/dist/runtime/wire.js +148 -0
- package/dist/spec/html-entities.d.ts +1 -0
- package/dist/spec/html-entities.js +25 -0
- package/dist/spec/load.d.ts +26 -0
- package/dist/spec/load.js +130 -0
- package/dist/spec/openapi/all-of.d.ts +3 -0
- package/dist/spec/openapi/all-of.js +9 -0
- package/dist/spec/openapi/normalize.d.ts +4 -0
- package/dist/spec/openapi/normalize.js +31 -0
- package/dist/spec/openapi/operations.d.ts +4 -0
- package/dist/spec/openapi/operations.js +173 -0
- package/dist/spec/openapi/schema.d.ts +51 -0
- package/dist/spec/openapi/schema.js +307 -0
- package/dist/targets/declarative/config.d.ts +533 -0
- package/dist/targets/declarative/config.js +280 -0
- package/dist/targets/declarative/extensions.d.ts +45 -0
- package/dist/targets/declarative/extensions.js +123 -0
- package/dist/targets/declarative/files.d.ts +13 -0
- package/dist/targets/declarative/files.js +127 -0
- package/dist/targets/declarative/format.d.ts +4 -0
- package/dist/targets/declarative/format.js +104 -0
- package/dist/targets/declarative/index.d.ts +9 -0
- package/dist/targets/declarative/index.js +170 -0
- package/dist/targets/declarative/liquid.d.ts +8 -0
- package/dist/targets/declarative/liquid.js +57 -0
- package/dist/targets/declarative/naming-case.d.ts +3 -0
- package/dist/targets/declarative/naming-case.js +31 -0
- package/dist/targets/declarative/naming.d.ts +42 -0
- package/dist/targets/declarative/naming.js +174 -0
- package/dist/targets/declarative/scaffold.d.ts +5 -0
- package/dist/targets/declarative/scaffold.js +146 -0
- package/dist/targets/declarative/types.d.ts +52 -0
- package/dist/targets/declarative/types.js +287 -0
- package/dist/targets/declarative/views.d.ts +180 -0
- package/dist/targets/declarative/views.js +447 -0
- package/dist/targets/python/extensions.js +152 -0
- package/dist/targets/python/target.json +549 -0
- package/dist/targets/python/templates/client/client.liquid +114 -0
- package/dist/targets/python/templates/client/httpx_transport.liquid +172 -0
- package/dist/targets/python/templates/client/init.liquid +20 -0
- package/dist/targets/python/templates/client/partials/operation_method.liquid +41 -0
- package/dist/targets/python/templates/client/resource.liquid +28 -0
- package/dist/targets/python/templates/client/runtime.liquid +133 -0
- package/dist/targets/python/templates/client/transport.liquid +62 -0
- package/dist/targets/python/templates/models/module.liquid +48 -0
- package/dist/targets/python/templates/models/partials/docstring.liquid +5 -0
- package/dist/targets/python/templates/models/partials/enum_class.liquid +11 -0
- package/dist/targets/python/templates/models/partials/field_line.liquid +5 -0
- package/dist/targets/python/templates/models/partials/model_class.liquid +17 -0
- package/dist/targets/typescript/compatibility-naming.d.ts +6 -0
- package/dist/targets/typescript/compatibility-naming.js +28 -0
- package/dist/targets/typescript/compatibility-options.d.ts +5 -0
- package/dist/targets/typescript/compatibility-options.js +8 -0
- package/dist/targets/typescript/compatibility-target.d.ts +5 -0
- package/dist/targets/typescript/compatibility-target.js +10 -0
- package/dist/targets/typescript/http-operations.d.ts +34 -0
- package/dist/targets/typescript/http-operations.js +155 -0
- package/dist/targets/typescript/imports.d.ts +43 -0
- package/dist/targets/typescript/imports.js +154 -0
- package/dist/targets/typescript/index.d.ts +7 -0
- package/dist/targets/typescript/index.js +52 -0
- package/dist/targets/typescript/mock-compatibility.d.ts +4 -0
- package/dist/targets/typescript/mock-compatibility.js +6 -0
- package/dist/targets/typescript/mock-hints.d.ts +13 -0
- package/dist/targets/typescript/mock-hints.js +75 -0
- package/dist/targets/typescript/mock-reachability.d.ts +12 -0
- package/dist/targets/typescript/mock-reachability.js +87 -0
- package/dist/targets/typescript/model-compatibility.d.ts +14 -0
- package/dist/targets/typescript/model-compatibility.js +16 -0
- package/dist/targets/typescript/naming.d.ts +13 -0
- package/dist/targets/typescript/naming.js +50 -0
- package/dist/targets/typescript/options.d.ts +124 -0
- package/dist/targets/typescript/options.js +90 -0
- package/dist/targets/typescript/outputs/client.d.ts +67 -0
- package/dist/targets/typescript/outputs/client.js +187 -0
- package/dist/targets/typescript/outputs/mocks.d.ts +32 -0
- package/dist/targets/typescript/outputs/mocks.js +371 -0
- package/dist/targets/typescript/outputs/models.d.ts +85 -0
- package/dist/targets/typescript/outputs/models.js +246 -0
- package/dist/targets/typescript/outputs/rtk-query.d.ts +69 -0
- package/dist/targets/typescript/outputs/rtk-query.js +266 -0
- package/dist/targets/typescript/prettier.d.ts +7 -0
- package/dist/targets/typescript/prettier.js +44 -0
- package/dist/targets/typescript/templates/client/client.liquid +30 -0
- package/dist/targets/typescript/templates/client/partials/api-member.liquid +13 -0
- package/dist/targets/typescript/templates/client/partials/jsdoc.liquid +10 -0
- package/dist/targets/typescript/templates/client/partials/method.liquid +26 -0
- package/dist/targets/typescript/templates/client/partials/query-type.liquid +10 -0
- package/dist/targets/typescript/templates/client/resource.liquid +34 -0
- package/dist/targets/typescript/templates/mocks/mock.liquid +15 -0
- package/dist/targets/typescript/templates/mocks/partials/factory.liquid +12 -0
- package/dist/targets/typescript/templates/mocks/partials/imports.liquid +7 -0
- package/dist/targets/typescript/templates/models/alias.liquid +16 -0
- package/dist/targets/typescript/templates/models/enum.liquid +27 -0
- package/dist/targets/typescript/templates/models/index.liquid +14 -0
- package/dist/targets/typescript/templates/models/model.liquid +25 -0
- package/dist/targets/typescript/templates/models/partials/const.liquid +10 -0
- package/dist/targets/typescript/templates/models/partials/imports.liquid +9 -0
- package/dist/targets/typescript/templates/models/partials/jsdoc.liquid +9 -0
- package/dist/targets/typescript/templates/models/partials/property.liquid +7 -0
- package/dist/targets/typescript/templates/rtk-query/api.liquid +16 -0
- package/dist/targets/typescript/templates/rtk-query/partials/arg-types.liquid +6 -0
- package/dist/targets/typescript/templates/rtk-query/partials/endpoint-mutation.liquid +13 -0
- package/dist/targets/typescript/templates/rtk-query/partials/endpoint-query.liquid +13 -0
- package/dist/targets/typescript/templates/rtk-query/partials/file-warning.liquid +7 -0
- package/dist/targets/typescript/templates/rtk-query/partials/hooks.liquid +9 -0
- package/dist/targets/typescript/templates/rtk-query/partials/imports.liquid +7 -0
- package/dist/targets/typescript/templates/rtk-query/partials/request-config.liquid +9 -0
- package/dist/targets/typescript/templates/rtk-query/resource.liquid +40 -0
- package/dist/targets/typescript/ts-type.d.ts +70 -0
- package/dist/targets/typescript/ts-type.js +62 -0
- package/dist/targets/typescript/type-printer.d.ts +21 -0
- package/dist/targets/typescript/type-printer.js +115 -0
- package/dist/templates/engine.d.ts +20 -0
- package/dist/templates/engine.js +161 -0
- package/dist/templates/inspect.d.ts +27 -0
- package/dist/templates/inspect.js +331 -0
- package/package.json +65 -4
- package/schema/sdk-gen.local.schema.json +75 -0
- package/schema/sdk-gen.schema.json +980 -0
- package/schema/sdk-gen.target.schema.json +1384 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COMPATIBILITY_MODES = exports.HAS_COMPATIBILITY_OUTPUTS = void 0;
|
|
4
|
+
exports.compatibilityOutputs = compatibilityOutputs;
|
|
5
|
+
exports.compatibilityModeOptions = compatibilityModeOptions;
|
|
6
|
+
exports.sourceModeOptions = sourceModeOptions;
|
|
7
|
+
exports.HAS_COMPATIBILITY_OUTPUTS = false;
|
|
8
|
+
exports.COMPATIBILITY_MODES = [];
|
|
9
|
+
function compatibilityOutputs() {
|
|
10
|
+
throw new Error('Unsupported TypeScript SDK mode');
|
|
11
|
+
}
|
|
12
|
+
function compatibilityModeOptions(_mode) {
|
|
13
|
+
return { outputOptions: {}, normalize: undefined, transforms: undefined };
|
|
14
|
+
}
|
|
15
|
+
function sourceModeOptions(_mode, _sourceName, _sourceFolder) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SourceSettings, UserConfig } from './schema';
|
|
2
|
+
export declare const GENERATION_MODES: readonly ["default", "future"];
|
|
3
|
+
export type GenerationMode = typeof GENERATION_MODES[number];
|
|
4
|
+
export declare function defaultTypeScriptOutputs(mode: GenerationMode, sourceFolder?: string): NonNullable<SourceSettings['outputs']>;
|
|
5
|
+
export declare function typeScriptModeOptions(config: UserConfig): {
|
|
6
|
+
normalize: undefined;
|
|
7
|
+
transforms: undefined;
|
|
8
|
+
outputOptions: {
|
|
9
|
+
rtkQuery?: {
|
|
10
|
+
runtime: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GENERATION_MODES = void 0;
|
|
4
|
+
exports.defaultTypeScriptOutputs = defaultTypeScriptOutputs;
|
|
5
|
+
exports.typeScriptModeOptions = typeScriptModeOptions;
|
|
6
|
+
const mode_compatibility_1 = require("./mode-compatibility");
|
|
7
|
+
exports.GENERATION_MODES = [...mode_compatibility_1.COMPATIBILITY_MODES, 'default', 'future'];
|
|
8
|
+
function defaultTypeScriptOutputs(mode, sourceFolder) {
|
|
9
|
+
const apiDir = sourceFolder ? `./src/api/${sourceFolder}` : './src/api';
|
|
10
|
+
switch (mode) {
|
|
11
|
+
case 'default': return {
|
|
12
|
+
models: { dir: `${apiDir}/models` },
|
|
13
|
+
rtkQuery: { dir: `${apiDir}/rtk` },
|
|
14
|
+
};
|
|
15
|
+
case 'future': return {
|
|
16
|
+
models: { dir: `${apiDir}/models` },
|
|
17
|
+
client: { dir: `${apiDir}/client` },
|
|
18
|
+
};
|
|
19
|
+
default: return (0, mode_compatibility_1.compatibilityOutputs)();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function typeScriptModeOptions(config) {
|
|
23
|
+
var _a;
|
|
24
|
+
const mode = (_a = config.mode) !== null && _a !== void 0 ? _a : 'default';
|
|
25
|
+
const compatibility = (0, mode_compatibility_1.compatibilityModeOptions)(mode);
|
|
26
|
+
return Object.assign(Object.assign({}, compatibility), { outputOptions: Object.assign(Object.assign({}, compatibility.outputOptions), (mode === 'default' && { rtkQuery: { runtime: 'toolkit' } })) });
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HostsConfig, SourceConfig, UserConfig, WorkspaceRule } from './schema';
|
|
2
|
+
export interface PresetBaseConfig {
|
|
3
|
+
sources?: SourceConfig[];
|
|
4
|
+
workspace?: string | WorkspaceRule;
|
|
5
|
+
hosts?: HostsConfig;
|
|
6
|
+
envFile?: string | string[];
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export interface Preset {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
normalize?: {
|
|
13
|
+
allOf?: 'merge' | 'intersection';
|
|
14
|
+
};
|
|
15
|
+
transforms?: Record<string, boolean | Record<string, unknown>>;
|
|
16
|
+
outputOptions: Record<string, Record<string, unknown>>;
|
|
17
|
+
targetOptions?: Record<string, unknown>;
|
|
18
|
+
config?: PresetBaseConfig;
|
|
19
|
+
}
|
|
20
|
+
export declare function getPreset(name: string): Preset | undefined;
|
|
21
|
+
export declare function listPresets(): Preset[];
|
|
22
|
+
export type ExpandedUserConfig = UserConfig & {
|
|
23
|
+
sources: SourceConfig[];
|
|
24
|
+
};
|
|
25
|
+
export declare function applyPresetBase(config: UserConfig): ExpandedUserConfig;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPreset = getPreset;
|
|
4
|
+
exports.listPresets = listPresets;
|
|
5
|
+
exports.applyPresetBase = applyPresetBase;
|
|
6
|
+
const preset_definitions_1 = require("./preset-definitions");
|
|
7
|
+
const deep_merge_1 = require("../core/deep-merge");
|
|
8
|
+
function getPreset(name) {
|
|
9
|
+
return preset_definitions_1.PRESETS[name];
|
|
10
|
+
}
|
|
11
|
+
function listPresets() {
|
|
12
|
+
return Object.values(preset_definitions_1.PRESETS);
|
|
13
|
+
}
|
|
14
|
+
function applyPresetBase(config) {
|
|
15
|
+
var _a;
|
|
16
|
+
var _b, _c;
|
|
17
|
+
const base = config.preset ? (_a = getPreset(config.preset)) === null || _a === void 0 ? void 0 : _a.config : undefined;
|
|
18
|
+
const own = (_b = config.sources) !== null && _b !== void 0 ? _b : [];
|
|
19
|
+
if (!base) {
|
|
20
|
+
if (!own.length)
|
|
21
|
+
throw new Error(config.preset ? `"sources" is required: preset "${config.preset}" provides none` : 'At least one source is required ("sources")');
|
|
22
|
+
return Object.assign(Object.assign({}, config), { sources: own });
|
|
23
|
+
}
|
|
24
|
+
const presetSources = (_c = base.sources) !== null && _c !== void 0 ? _c : [];
|
|
25
|
+
if (!own.length && !presetSources.length)
|
|
26
|
+
throw new Error(`"sources" is required: preset "${config.preset}" provides none`);
|
|
27
|
+
const sources = [
|
|
28
|
+
...presetSources.map((source) => {
|
|
29
|
+
const override = own.find((s) => s.name === source.name);
|
|
30
|
+
return override ? (0, deep_merge_1.deepMerge)(source, override) : source;
|
|
31
|
+
}),
|
|
32
|
+
...own.filter((source) => !presetSources.some((p) => p.name === source.name)),
|
|
33
|
+
];
|
|
34
|
+
const env = base.env || config.env ? Object.assign(Object.assign({}, base.env), config.env) : undefined;
|
|
35
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, config), (config.envFile === undefined && base.envFile !== undefined ? { envFile: base.envFile } : {})), (config.hosts === undefined && base.hosts !== undefined ? { hosts: base.hosts } : {})), (config.workspace === undefined && base.workspace !== undefined ? { workspace: base.workspace } : {})), (env ? { env } : {})), { sources });
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ResolvedConfig } from './types';
|
|
2
|
+
import type { UserConfig } from './schema';
|
|
3
|
+
import { type GenerationMode } from './modes';
|
|
4
|
+
import { type AskFn, type WorkspaceChoice } from './workspace';
|
|
5
|
+
export interface ResolveOptions {
|
|
6
|
+
cwd: string;
|
|
7
|
+
workspace?: string;
|
|
8
|
+
enableOutputs?: string[];
|
|
9
|
+
outputDirs?: Record<string, string>;
|
|
10
|
+
prune?: boolean;
|
|
11
|
+
format?: boolean;
|
|
12
|
+
templates?: string[];
|
|
13
|
+
only?: string[];
|
|
14
|
+
promptable?: boolean;
|
|
15
|
+
promptedWorkspace?: WorkspaceChoice;
|
|
16
|
+
}
|
|
17
|
+
export interface AsyncResolveOptions extends ResolveOptions {
|
|
18
|
+
ask?: AskFn;
|
|
19
|
+
isInteractive?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function resolveConfigAsync(config: UserConfig, opts: AsyncResolveOptions): Promise<ResolvedConfig>;
|
|
22
|
+
export declare function resolveConfig(userConfig: UserConfig, opts: ResolveOptions): ResolvedConfig;
|
|
23
|
+
export declare function adHocConfig(flags: {
|
|
24
|
+
url?: string;
|
|
25
|
+
file?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
preset?: string;
|
|
28
|
+
mode?: GenerationMode;
|
|
29
|
+
outputs?: Record<string, {
|
|
30
|
+
dir?: string;
|
|
31
|
+
}>;
|
|
32
|
+
}): UserConfig;
|
|
@@ -0,0 +1,288 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.resolveConfigAsync = resolveConfigAsync;
|
|
57
|
+
exports.resolveConfig = resolveConfig;
|
|
58
|
+
exports.adHocConfig = adHocConfig;
|
|
59
|
+
const mode_compatibility_1 = require("./mode-compatibility");
|
|
60
|
+
const all_of_1 = require("../spec/openapi/all-of");
|
|
61
|
+
const path = __importStar(require("path"));
|
|
62
|
+
const deep_merge_1 = require("../core/deep-merge");
|
|
63
|
+
const presets_1 = require("./presets");
|
|
64
|
+
const modes_1 = require("./modes");
|
|
65
|
+
const interpolate_1 = require("./interpolate");
|
|
66
|
+
const dotenv_1 = require("./dotenv");
|
|
67
|
+
const workspace_1 = require("./workspace");
|
|
68
|
+
function resolveConfigAsync(config, opts) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const { ask, isInteractive } = opts, sync = __rest(opts, ["ask", "isInteractive"]);
|
|
71
|
+
if (!ask || !isInteractive)
|
|
72
|
+
return resolveConfig(config, sync);
|
|
73
|
+
try {
|
|
74
|
+
return resolveConfig(config, Object.assign(Object.assign({}, sync), { promptable: true }));
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (!(error instanceof workspace_1.WorkspacePromptNeeded))
|
|
78
|
+
throw error;
|
|
79
|
+
const promptedWorkspace = yield (0, workspace_1.promptWorkspace)(error.inputs, ask);
|
|
80
|
+
return resolveConfig(config, Object.assign(Object.assign({}, sync), { promptedWorkspace }));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function resolveConfig(userConfig, opts) {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
87
|
+
const preset = userConfig.preset ? (0, presets_1.getPreset)(userConfig.preset) : undefined;
|
|
88
|
+
if (userConfig.preset && !preset) {
|
|
89
|
+
throw new Error(`Unknown preset "${userConfig.preset}"`);
|
|
90
|
+
}
|
|
91
|
+
const config = (0, presets_1.applyPresetBase)(userConfig);
|
|
92
|
+
if (config.mode && ((_c = config.target) !== null && _c !== void 0 ? _c : 'typescript') !== 'typescript')
|
|
93
|
+
throw new Error('SDK modes apply to the TypeScript target');
|
|
94
|
+
const env = Object.assign(Object.assign(Object.assign({}, (0, dotenv_1.loadEnvFiles)(config.envFile, opts.cwd)), config.env), process.env);
|
|
95
|
+
const workspaceInputs = {
|
|
96
|
+
cli: opts.workspace,
|
|
97
|
+
configured: typeof config.workspace === 'string' ? config.workspace : undefined,
|
|
98
|
+
rule: (_d = ruleOf(config.workspace)) !== null && _d !== void 0 ? _d : ruleOf((_a = preset === null || preset === void 0 ? void 0 : preset.config) === null || _a === void 0 ? void 0 : _a.workspace),
|
|
99
|
+
hosts: config.hosts,
|
|
100
|
+
envFile: config.envFile,
|
|
101
|
+
env,
|
|
102
|
+
};
|
|
103
|
+
let choice;
|
|
104
|
+
const workspaceChoice = () => (choice !== null && choice !== void 0 ? choice : (choice = (0, workspace_1.chooseWorkspace)(workspaceInputs, { promptable: opts.promptable, prompted: opts.promptedWorkspace })));
|
|
105
|
+
const interpolation = {
|
|
106
|
+
env,
|
|
107
|
+
workspace: () => {
|
|
108
|
+
const chosen = workspaceChoice();
|
|
109
|
+
if (chosen.production)
|
|
110
|
+
throw new Error('production has no workspace; use {host}');
|
|
111
|
+
return chosen.name;
|
|
112
|
+
},
|
|
113
|
+
host: () => {
|
|
114
|
+
if (!config.hosts)
|
|
115
|
+
throw new Error('"{host}" needs "hosts" in the config ({ "workspace": "{workspace}.dev.example.com", "production": "example.com" })');
|
|
116
|
+
const chosen = workspaceChoice();
|
|
117
|
+
if (chosen.production)
|
|
118
|
+
return config.hosts.production;
|
|
119
|
+
if ((0, workspace_1.isOrigin)(chosen.name))
|
|
120
|
+
return (0, workspace_1.stripTrailingSlashes)(chosen.name);
|
|
121
|
+
return config.hosts.workspace.split('{workspace}').join(chosen.name);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const skipped = [];
|
|
125
|
+
const sources = [];
|
|
126
|
+
for (const source of selectSources(config, opts.only)) {
|
|
127
|
+
try {
|
|
128
|
+
const skip = source.skip !== undefined ? (0, interpolate_1.interpolateString)(source.skip, interpolation) : '';
|
|
129
|
+
if (skip) {
|
|
130
|
+
skipped.push({ name: source.name, reason: source.skip });
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
sources.push(resolveSource(source, config, opts, interpolation));
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (error instanceof workspace_1.WorkspacePromptNeeded)
|
|
137
|
+
throw error;
|
|
138
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
139
|
+
const hint = config.sources.length > 1 && !((_b = opts.only) === null || _b === void 0 ? void 0 : _b.length) ? ' (run other sources with -s <name>)' : '';
|
|
140
|
+
throw new Error(`Source "${source.name}": ${message}${hint}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const targetOptions = (0, deep_merge_1.deepMerge)((_e = preset === null || preset === void 0 ? void 0 : preset.targetOptions) !== null && _e !== void 0 ? _e : {}, config.targetOptions, opts.format === false ? { prettier: false, biome: false } : undefined);
|
|
144
|
+
return Object.assign({ cwd: opts.cwd, target: resolveTarget((_f = config.target) !== null && _f !== void 0 ? _f : 'typescript', opts.cwd), targetOptions, plugins: ((_g = config.plugins) !== null && _g !== void 0 ? _g : []).map((plugin) => resolvePath(plugin, opts.cwd)), templates: [...((_h = opts.templates) !== null && _h !== void 0 ? _h : []), ...templateList(config.templates)].map((template) => resolvePath(template, opts.cwd)), prune: (_k = (_j = opts.prune) !== null && _j !== void 0 ? _j : config.prune) !== null && _k !== void 0 ? _k : true, sources, sourceNames: config.sources.map((source) => source.name) }, (skipped.length ? { skipped } : {}));
|
|
145
|
+
}
|
|
146
|
+
function ruleOf(workspace) {
|
|
147
|
+
return typeof workspace === 'object' ? workspace : undefined;
|
|
148
|
+
}
|
|
149
|
+
function selectSources(config, only) {
|
|
150
|
+
if (!(only === null || only === void 0 ? void 0 : only.length))
|
|
151
|
+
return config.sources;
|
|
152
|
+
const known = config.sources.map((s) => s.name);
|
|
153
|
+
const unknown = only.filter((name) => !known.includes(name));
|
|
154
|
+
if (unknown.length)
|
|
155
|
+
throw new Error(`Unknown source(s): ${unknown.join(', ')}. Configured: ${known.join(', ')}`);
|
|
156
|
+
return config.sources.filter((s) => only.includes(s.name));
|
|
157
|
+
}
|
|
158
|
+
function adHocConfig(flags) {
|
|
159
|
+
var _a;
|
|
160
|
+
if (Number(flags.url !== undefined) + Number(flags.file !== undefined) !== 1) {
|
|
161
|
+
throw new Error('Ad-hoc config must set exactly one of url or file');
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
version: 4,
|
|
165
|
+
preset: flags.preset,
|
|
166
|
+
mode: flags.mode,
|
|
167
|
+
sources: [
|
|
168
|
+
Object.assign(Object.assign({ name: (_a = flags.name) !== null && _a !== void 0 ? _a : 'api' }, (flags.url !== undefined ? { url: flags.url } : { file: flags.file })), { outputs: flags.outputs }),
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function resolveSource(source, config, opts, interpolation) {
|
|
173
|
+
var _a;
|
|
174
|
+
var _b, _c, _d, _e;
|
|
175
|
+
const preset = config.preset ? (0, presets_1.getPreset)(config.preset) : undefined;
|
|
176
|
+
const typeScript = ((_b = config.target) !== null && _b !== void 0 ? _b : 'typescript') === 'typescript';
|
|
177
|
+
const mode = typeScript && (!preset || config.mode) ? (0, modes_1.typeScriptModeOptions)(config) : undefined;
|
|
178
|
+
const sourceFolder = config.sources.length > 1 ? `source-${source.name}` : undefined;
|
|
179
|
+
const defaults = typeScript && !source.outputs && !((_a = config.defaults) === null || _a === void 0 ? void 0 : _a.outputs) && (!preset || config.mode)
|
|
180
|
+
? Object.assign(Object.assign({}, config.defaults), { outputs: (0, modes_1.defaultTypeScriptOutputs)((_c = config.mode) !== null && _c !== void 0 ? _c : 'default', sourceFolder) }) : config.defaults;
|
|
181
|
+
const outputOptions = (0, deep_merge_1.deepMerge)((_d = preset === null || preset === void 0 ? void 0 : preset.outputOptions) !== null && _d !== void 0 ? _d : {}, mode === null || mode === void 0 ? void 0 : mode.outputOptions, (0, mode_compatibility_1.sourceModeOptions)(config.mode, source.name, sourceFolder));
|
|
182
|
+
return Object.assign({ name: source.name, input: resolveInput(source, opts.cwd, interpolation), normalize: resolveNormalize((0, deep_merge_1.deepMerge)((_e = mode === null || mode === void 0 ? void 0 : mode.normalize) !== null && _e !== void 0 ? _e : {}, preset === null || preset === void 0 ? void 0 : preset.normalize), defaults, source), transforms: resolveTransforms(mode === null || mode === void 0 ? void 0 : mode.transforms, preset === null || preset === void 0 ? void 0 : preset.transforms, defaults === null || defaults === void 0 ? void 0 : defaults.transforms, source.transforms), configuredTransforms: [
|
|
183
|
+
...new Set([mode === null || mode === void 0 ? void 0 : mode.transforms, preset === null || preset === void 0 ? void 0 : preset.transforms, defaults === null || defaults === void 0 ? void 0 : defaults.transforms, source.transforms].flatMap((m) => Object.keys(m !== null && m !== void 0 ? m : {}))),
|
|
184
|
+
], outputs: resolveOutputs(outputOptions, defaults, source, opts) }, (source.onError ? { onError: source.onError } : {}));
|
|
185
|
+
}
|
|
186
|
+
function resolveInput(source, cwd, interpolation) {
|
|
187
|
+
const file = source.file !== undefined ? (0, interpolate_1.interpolateString)(source.file, interpolation) : '';
|
|
188
|
+
if (file || source.url === undefined) {
|
|
189
|
+
if (!file)
|
|
190
|
+
throw new Error(`Source "${source.name}": "file" resolved to an empty path`);
|
|
191
|
+
return { kind: 'file', path: resolvePath(file, cwd) };
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
kind: 'url',
|
|
195
|
+
url: (0, interpolate_1.interpolateString)(source.url, interpolation),
|
|
196
|
+
headers: resolveHeaders(source.headers, interpolation),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function resolveHeaders(headers, interpolation) {
|
|
200
|
+
const out = {};
|
|
201
|
+
for (const [key, header] of Object.entries(headers !== null && headers !== void 0 ? headers : {})) {
|
|
202
|
+
if (typeof header === 'string') {
|
|
203
|
+
out[key] = (0, interpolate_1.interpolateString)(header, interpolation);
|
|
204
|
+
}
|
|
205
|
+
else if ((0, interpolate_1.interpolateString)(header.when, interpolation)) {
|
|
206
|
+
out[key] = (0, interpolate_1.interpolateString)(header.value, interpolation);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
function resolveNormalize(presetNormalize, defaults, source) {
|
|
212
|
+
return (0, deep_merge_1.deepMerge)({ allOf: all_of_1.DEFAULT_ALLOF_MODE }, presetNormalize, defaults === null || defaults === void 0 ? void 0 : defaults.normalize, source.normalize);
|
|
213
|
+
}
|
|
214
|
+
function resolveTransforms(...maps) {
|
|
215
|
+
const order = [];
|
|
216
|
+
const resolved = new Map();
|
|
217
|
+
for (const map of maps) {
|
|
218
|
+
if (!map)
|
|
219
|
+
continue;
|
|
220
|
+
for (const [name, value] of Object.entries(map)) {
|
|
221
|
+
if (!order.includes(name)) {
|
|
222
|
+
order.push(name);
|
|
223
|
+
}
|
|
224
|
+
resolved.set(name, value === false ? false : value === true ? {} : value);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return order.flatMap((name) => {
|
|
228
|
+
const options = resolved.get(name);
|
|
229
|
+
return options === undefined || options === false ? [] : [{ name, options }];
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function resolveOutputs(presetOptions, defaults, source, opts) {
|
|
233
|
+
var _a, _b, _c, _d;
|
|
234
|
+
var _e, _f;
|
|
235
|
+
const names = firstSeenOutputNames(presetOptions, defaults === null || defaults === void 0 ? void 0 : defaults.outputs, source.outputs, opts.enableOutputs, opts.outputDirs);
|
|
236
|
+
const outputs = {};
|
|
237
|
+
for (const name of names) {
|
|
238
|
+
const defaultsValue = (_a = defaults === null || defaults === void 0 ? void 0 : defaults.outputs) === null || _a === void 0 ? void 0 : _a[name];
|
|
239
|
+
const sourceValue = (_b = source.outputs) === null || _b === void 0 ? void 0 : _b[name];
|
|
240
|
+
const enabledByConfig = isOutputEnabled(defaultsValue, sourceValue);
|
|
241
|
+
const enabledByCli = (_e = (_c = opts.enableOutputs) === null || _c === void 0 ? void 0 : _c.includes(name)) !== null && _e !== void 0 ? _e : false;
|
|
242
|
+
if (!enabledByConfig && !enabledByCli)
|
|
243
|
+
continue;
|
|
244
|
+
const merged = (0, deep_merge_1.deepMerge)((_f = presetOptions[name]) !== null && _f !== void 0 ? _f : {}, objectOrUndefined(defaultsValue), objectOrUndefined(sourceValue));
|
|
245
|
+
if ((_d = opts.outputDirs) === null || _d === void 0 ? void 0 : _d[name]) {
|
|
246
|
+
merged.dir = opts.outputDirs[name];
|
|
247
|
+
}
|
|
248
|
+
if (typeof merged.dir === 'string') {
|
|
249
|
+
merged.dir = resolvePath(merged.dir, opts.cwd);
|
|
250
|
+
}
|
|
251
|
+
outputs[name] = merged;
|
|
252
|
+
}
|
|
253
|
+
return outputs;
|
|
254
|
+
}
|
|
255
|
+
function firstSeenOutputNames(...sources) {
|
|
256
|
+
const names = [];
|
|
257
|
+
for (const source of sources) {
|
|
258
|
+
if (!source)
|
|
259
|
+
continue;
|
|
260
|
+
const keys = Array.isArray(source) ? source : Object.keys(source);
|
|
261
|
+
for (const key of keys) {
|
|
262
|
+
if (!names.includes(key))
|
|
263
|
+
names.push(key);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return names;
|
|
267
|
+
}
|
|
268
|
+
function isOutputEnabled(defaultsValue, sourceValue) {
|
|
269
|
+
const value = sourceValue !== undefined ? sourceValue : defaultsValue;
|
|
270
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
271
|
+
}
|
|
272
|
+
function objectOrUndefined(value) {
|
|
273
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
|
|
274
|
+
}
|
|
275
|
+
function resolveTarget(target, cwd) {
|
|
276
|
+
return looksLikePath(target) ? resolvePath(target, cwd) : target;
|
|
277
|
+
}
|
|
278
|
+
function resolvePath(value, cwd) {
|
|
279
|
+
return path.isAbsolute(value) ? value : path.resolve(cwd, value);
|
|
280
|
+
}
|
|
281
|
+
function templateList(templates) {
|
|
282
|
+
if (templates === undefined)
|
|
283
|
+
return [];
|
|
284
|
+
return Array.isArray(templates) ? templates : [templates];
|
|
285
|
+
}
|
|
286
|
+
function looksLikePath(value) {
|
|
287
|
+
return value.startsWith('.') || value.startsWith('/');
|
|
288
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const headerValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
3
|
+
value: z.ZodString;
|
|
4
|
+
when: z.ZodString;
|
|
5
|
+
}, z.core.$strict>]>;
|
|
6
|
+
declare const workspaceRuleSchema: z.ZodObject<{
|
|
7
|
+
default: z.ZodOptional<z.ZodString>;
|
|
8
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
9
|
+
prompt: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
production: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
declare const hostsSchema: z.ZodObject<{
|
|
13
|
+
workspace: z.ZodString;
|
|
14
|
+
production: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export declare const UserConfigSchema: z.ZodObject<{
|
|
17
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
18
|
+
version: z.ZodLiteral<4>;
|
|
19
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
default: "default";
|
|
21
|
+
future: "future";
|
|
22
|
+
}>>;
|
|
23
|
+
preset: z.ZodOptional<z.ZodString>;
|
|
24
|
+
target: z.ZodOptional<z.ZodString>;
|
|
25
|
+
targetOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
templates: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
28
|
+
workspace: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
29
|
+
default: z.ZodOptional<z.ZodString>;
|
|
30
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
31
|
+
prompt: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
production: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strict>]>>;
|
|
34
|
+
hosts: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
workspace: z.ZodString;
|
|
36
|
+
production: z.ZodString;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
envFile: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
39
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
40
|
+
prune: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
defaults: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
normalize: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
allOf: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
intersection: "intersection";
|
|
45
|
+
}>>;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
transforms: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
|
|
48
|
+
outputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
normalize: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
allOf: z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
intersection: "intersection";
|
|
54
|
+
}>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
transforms: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
|
|
57
|
+
outputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
url: z.ZodOptional<z.ZodString>;
|
|
60
|
+
file: z.ZodOptional<z.ZodString>;
|
|
61
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
62
|
+
value: z.ZodString;
|
|
63
|
+
when: z.ZodString;
|
|
64
|
+
}, z.core.$strict>]>>>;
|
|
65
|
+
skip: z.ZodOptional<z.ZodString>;
|
|
66
|
+
onError: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strict>>>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
export type UserConfig = z.infer<typeof UserConfigSchema>;
|
|
70
|
+
export type SourceSettings = NonNullable<UserConfig['defaults']>;
|
|
71
|
+
export type SourceConfig = NonNullable<UserConfig['sources']>[number];
|
|
72
|
+
export type WorkspaceRule = z.infer<typeof workspaceRuleSchema>;
|
|
73
|
+
export type HostsConfig = z.infer<typeof hostsSchema>;
|
|
74
|
+
export type HeaderValue = z.infer<typeof headerValueSchema>;
|
|
75
|
+
export declare function formatConfigError(error: z.ZodError): string;
|
|
76
|
+
export declare function parseUserConfig(raw: unknown): UserConfig;
|
|
77
|
+
export declare function defineConfig(c: UserConfig): UserConfig;
|
|
78
|
+
export declare const LocalConfigSchema: z.ZodObject<{
|
|
79
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
80
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
81
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
82
|
+
sources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
83
|
+
url: z.ZodOptional<z.ZodString>;
|
|
84
|
+
file: z.ZodOptional<z.ZodString>;
|
|
85
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
86
|
+
value: z.ZodString;
|
|
87
|
+
when: z.ZodString;
|
|
88
|
+
}, z.core.$strict>]>>>;
|
|
89
|
+
}, z.core.$strict>>>;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
export type LocalConfig = z.infer<typeof LocalConfigSchema>;
|
|
92
|
+
export declare function parseLocalConfig(input: unknown): LocalConfig;
|
|
93
|
+
export {};
|