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,195 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.MANIFEST_FILENAME = void 0;
|
|
46
|
+
exports.readManifest = readManifest;
|
|
47
|
+
exports.writeManifest = writeManifest;
|
|
48
|
+
exports.pruneOrphans = pruneOrphans;
|
|
49
|
+
const fs = __importStar(require("fs-extra"));
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const package_version_1 = require("./package-version");
|
|
52
|
+
exports.MANIFEST_FILENAME = '.sdk-gen-manifest.json';
|
|
53
|
+
function toPosix(relPath) {
|
|
54
|
+
return relPath.split(path.sep).join('/');
|
|
55
|
+
}
|
|
56
|
+
function manifestPath(outputDir) {
|
|
57
|
+
return path.join(outputDir, exports.MANIFEST_FILENAME);
|
|
58
|
+
}
|
|
59
|
+
function readManifest(outputDir) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
try {
|
|
62
|
+
const raw = yield fs.readFile(manifestPath(outputDir), 'utf8');
|
|
63
|
+
const parsed = JSON.parse(raw);
|
|
64
|
+
if (parsed && Array.isArray(parsed.files)) {
|
|
65
|
+
let bySource;
|
|
66
|
+
if (parsed.bySource && typeof parsed.bySource === 'object' && !Array.isArray(parsed.bySource)) {
|
|
67
|
+
bySource = {};
|
|
68
|
+
for (const [key, value] of Object.entries(parsed.bySource)) {
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
bySource[key] = value.filter((f) => typeof f === 'string');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return Object.assign({ version: typeof parsed.version === 'string' ? parsed.version : 'unknown', files: parsed.files.filter((f) => typeof f === 'string') }, (bySource ? { bySource } : {}));
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
catch (_a) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function writeManifestFile(outputDir, manifest) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
yield fs.ensureDir(outputDir);
|
|
86
|
+
yield fs.writeFile(manifestPath(outputDir), JSON.stringify(manifest, null, 2) + '\n', 'utf8');
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function writeManifest(outputDir, relativeFiles) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const files = Array.from(new Set(relativeFiles.map(toPosix))).sort();
|
|
92
|
+
yield writeManifestFile(outputDir, { version: (0, package_version_1.getPackageVersion)(), files });
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function removeEmptyDirChain(dir, stopAt, deletedDirs) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const normalizedStop = path.normalize(stopAt);
|
|
98
|
+
let current = path.normalize(dir);
|
|
99
|
+
while (current !== normalizedStop && (current + path.sep).startsWith(normalizedStop + path.sep)) {
|
|
100
|
+
if (deletedDirs.has(current)) {
|
|
101
|
+
current = path.dirname(current);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let entries;
|
|
105
|
+
try {
|
|
106
|
+
entries = yield fs.readdir(current);
|
|
107
|
+
}
|
|
108
|
+
catch (_a) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (entries.length > 0) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
yield fs.remove(current);
|
|
115
|
+
deletedDirs.add(current);
|
|
116
|
+
current = path.dirname(current);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function pruneOrphans(outputDir_1, newRelativeFiles_1) {
|
|
121
|
+
return __awaiter(this, arguments, void 0, function* (outputDir, newRelativeFiles, options = {}) {
|
|
122
|
+
var _a, _b, _c;
|
|
123
|
+
const prior = yield readManifest(outputDir);
|
|
124
|
+
const result = { deletedFiles: [], deletedDirs: [] };
|
|
125
|
+
const newFiles = Array.from(new Set(newRelativeFiles.map(toPosix))).sort();
|
|
126
|
+
let orphans;
|
|
127
|
+
let filesToWrite;
|
|
128
|
+
let bySourceToWrite;
|
|
129
|
+
if (options.sourceKey) {
|
|
130
|
+
const key = options.sourceKey;
|
|
131
|
+
let priorBySource = prior === null || prior === void 0 ? void 0 : prior.bySource;
|
|
132
|
+
if (priorBySource && options.isAliasKey) {
|
|
133
|
+
const folded = {};
|
|
134
|
+
for (const [k, files] of Object.entries(priorBySource)) {
|
|
135
|
+
const target = k !== key && options.isAliasKey(k) ? key : k;
|
|
136
|
+
folded[target] = Array.from(new Set([...((_a = folded[target]) !== null && _a !== void 0 ? _a : []), ...files])).sort();
|
|
137
|
+
}
|
|
138
|
+
priorBySource = folded;
|
|
139
|
+
}
|
|
140
|
+
if (priorBySource) {
|
|
141
|
+
const priorOwned = (_b = priorBySource[key]) !== null && _b !== void 0 ? _b : [];
|
|
142
|
+
const newSet = new Set(newFiles);
|
|
143
|
+
orphans = priorOwned.filter((f) => !newSet.has(f));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
orphans = [];
|
|
147
|
+
}
|
|
148
|
+
bySourceToWrite = Object.assign(Object.assign({}, (priorBySource !== null && priorBySource !== void 0 ? priorBySource : {})), { [key]: newFiles });
|
|
149
|
+
const union = new Set();
|
|
150
|
+
Object.values(bySourceToWrite).forEach((files) => files.forEach((f) => union.add(f)));
|
|
151
|
+
const orphanSet = new Set(orphans);
|
|
152
|
+
((_c = prior === null || prior === void 0 ? void 0 : prior.files) !== null && _c !== void 0 ? _c : []).forEach((f) => {
|
|
153
|
+
if (!orphanSet.has(f))
|
|
154
|
+
union.add(f);
|
|
155
|
+
});
|
|
156
|
+
filesToWrite = Array.from(union).sort();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
filesToWrite = newFiles;
|
|
160
|
+
if (prior && !prior.bySource) {
|
|
161
|
+
const newSet = new Set(newFiles);
|
|
162
|
+
orphans = prior.files.filter((f) => !newSet.has(f));
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
orphans = [];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
yield writeManifestFile(outputDir, Object.assign({ version: (0, package_version_1.getPackageVersion)(), files: filesToWrite }, (bySourceToWrite ? { bySource: bySourceToWrite } : {})));
|
|
169
|
+
if (!prior || options.noPrune) {
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
const deletedDirs = new Set();
|
|
173
|
+
const parentDirs = new Set();
|
|
174
|
+
for (const rel of orphans) {
|
|
175
|
+
const absPath = path.join(outputDir, ...rel.split('/'));
|
|
176
|
+
try {
|
|
177
|
+
if (yield fs.pathExists(absPath)) {
|
|
178
|
+
yield fs.remove(absPath);
|
|
179
|
+
result.deletedFiles.push(rel);
|
|
180
|
+
}
|
|
181
|
+
parentDirs.add(path.dirname(absPath));
|
|
182
|
+
}
|
|
183
|
+
catch (_d) {
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const sortedParents = Array.from(parentDirs).sort((a, b) => b.split(path.sep).length - a.split(path.sep).length);
|
|
187
|
+
for (const dir of sortedParents) {
|
|
188
|
+
yield removeEmptyDirChain(dir, outputDir, deletedDirs);
|
|
189
|
+
}
|
|
190
|
+
result.deletedDirs = Array.from(deletedDirs)
|
|
191
|
+
.map((d) => toPosix(path.relative(outputDir, d)))
|
|
192
|
+
.sort();
|
|
193
|
+
return result;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.OverlapTracker = void 0;
|
|
37
|
+
const crypto_1 = require("crypto");
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
class OverlapTracker {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.claims = new Map();
|
|
42
|
+
}
|
|
43
|
+
check(runs, log) {
|
|
44
|
+
var _a;
|
|
45
|
+
var _b, _c;
|
|
46
|
+
const conflicts = new Map();
|
|
47
|
+
for (const run of runs) {
|
|
48
|
+
for (const file of run.files) {
|
|
49
|
+
const abs = path.join(run.dir, ...file.path.split('/'));
|
|
50
|
+
const digest = (0, crypto_1.createHash)('sha1').update(file.content).digest('hex');
|
|
51
|
+
const previous = this.claims.get(abs);
|
|
52
|
+
if (previous && previous.source !== run.source.name && previous.digest !== digest) {
|
|
53
|
+
const key = `${previous.source}|${run.output}`;
|
|
54
|
+
conflicts.set(key, [...((_b = conflicts.get(key)) !== null && _b !== void 0 ? _b : []), file.path]);
|
|
55
|
+
}
|
|
56
|
+
this.claims.set(abs, { source: run.source.name, digest });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const [key, files] of conflicts) {
|
|
60
|
+
const [other, output] = key.split('|');
|
|
61
|
+
const runs0 = (_c = (_a = runs[0]) === null || _a === void 0 ? void 0 : _a.source.name) !== null && _c !== void 0 ? _c : '?';
|
|
62
|
+
log.warn(` ⚠️ ${runs0}/${output} overwrites ${files.length} file(s) that ${other} emitted with different content ` +
|
|
63
|
+
`(last source wins), e.g. ${files.slice(0, 3).join(', ')}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.OverlapTracker = OverlapTracker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPackageVersion(): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getPackageVersion = getPackageVersion;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
function getPackageVersion() {
|
|
40
|
+
var _a;
|
|
41
|
+
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
42
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
43
|
+
return (_a = packageJson.version) !== null && _a !== void 0 ? _a : 'unknown';
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ResolvedConfig, ResolvedSource } from '../config/types';
|
|
2
|
+
import type { ApiSpec } from '../ir/types';
|
|
3
|
+
import { type OpenApiDocument } from '../spec/load';
|
|
4
|
+
import type { Logger } from './log';
|
|
5
|
+
import type { SourceInfo, Target } from './plugin';
|
|
6
|
+
import { type OutputRun, type WriteReport } from './writer';
|
|
7
|
+
export interface RunOptions {
|
|
8
|
+
log: Logger;
|
|
9
|
+
dryRun?: boolean;
|
|
10
|
+
only?: string[];
|
|
11
|
+
outputs?: string[];
|
|
12
|
+
documents?: Record<string, OpenApiDocument>;
|
|
13
|
+
pruneUnmanaged?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SourceResult {
|
|
16
|
+
source: string;
|
|
17
|
+
ok: boolean;
|
|
18
|
+
error?: Error;
|
|
19
|
+
skipped?: boolean;
|
|
20
|
+
reports: WriteReport[];
|
|
21
|
+
planned?: OutputRun[];
|
|
22
|
+
emitted?: Map<string, string[]>;
|
|
23
|
+
}
|
|
24
|
+
export declare function runPipeline(config: ResolvedConfig, options: RunOptions): Promise<SourceResult[]>;
|
|
25
|
+
export declare function buildApi(document: OpenApiDocument, source: Pick<ResolvedSource, 'normalize' | 'transforms' | 'configuredTransforms'>, targetTransforms?: Target['transforms']): ApiSpec;
|
|
26
|
+
export interface GenerateHooks {
|
|
27
|
+
onRender?: (output: string, template: string, data: object) => void;
|
|
28
|
+
outputs?: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function generateOutputs(api: ApiSpec, source: ResolvedSource, info: SourceInfo, target: Target, config: ResolvedConfig, log: Logger, hooks?: GenerateHooks): Promise<OutputRun[]>;
|