@distilled.cloud/core 1.0.0-rc.15 → 1.0.0-rc.17
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/lib/_bundle/aws.js +2 -0
- package/lib/_bundle/aws.js.map +1 -0
- package/lib/_bundle/base.js +5 -0
- package/lib/_bundle/base.js.map +1 -0
- package/lib/_bundle/graphql.js +3 -0
- package/lib/_bundle/graphql.js.map +1 -0
- package/lib/_bundle/rest.js +2 -0
- package/lib/_bundle/rest.js.map +1 -0
- package/lib/_bundle/xml.js +4 -0
- package/lib/_bundle/xml.js.map +1 -0
- package/lib/api.d.ts +118 -13
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -188
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +1 -278
- package/lib/chunks.d.ts +3 -0
- package/lib/chunks.d.ts.map +1 -0
- package/lib/chunks.js +1 -0
- package/lib/codegen/boolean-string-enums.js +36 -36
- package/lib/codegen/chunk.d.ts +7 -0
- package/lib/codegen/chunk.d.ts.map +1 -0
- package/lib/codegen/chunk.js +139 -0
- package/lib/codegen/chunk.js.map +1 -0
- package/lib/codegen/cli.d.ts.map +1 -1
- package/lib/codegen/cli.js +28 -14
- package/lib/codegen/cli.js.map +1 -1
- package/lib/codegen/datafy.d.ts +14 -0
- package/lib/codegen/datafy.d.ts.map +1 -0
- package/lib/codegen/datafy.js +853 -0
- package/lib/codegen/datafy.js.map +1 -0
- package/lib/codegen/dedupe.d.ts +5 -0
- package/lib/codegen/dedupe.d.ts.map +1 -0
- package/lib/codegen/dedupe.js +153 -0
- package/lib/codegen/dedupe.js.map +1 -0
- package/lib/codegen/emit.js +56 -56
- package/lib/codegen/format.js +18 -18
- package/lib/codegen/generated-at.js +29 -29
- package/lib/codegen/generator.d.ts.map +1 -1
- package/lib/codegen/generator.js +92 -84
- package/lib/codegen/generator.js.map +1 -1
- package/lib/codegen/graph.js +36 -36
- package/lib/codegen/graphql-client.d.ts +2 -0
- package/lib/codegen/graphql-client.d.ts.map +1 -1
- package/lib/codegen/graphql-client.js +55 -26
- package/lib/codegen/graphql-client.js.map +1 -1
- package/lib/codegen/graphql.js +113 -113
- package/lib/codegen/latin1.d.ts +3 -0
- package/lib/codegen/latin1.d.ts.map +1 -0
- package/lib/codegen/latin1.js +126 -0
- package/lib/codegen/latin1.js.map +1 -0
- package/lib/codegen/members.d.ts +7 -0
- package/lib/codegen/members.d.ts.map +1 -1
- package/lib/codegen/members.js +26 -19
- package/lib/codegen/members.js.map +1 -1
- package/lib/codegen/model-diff.js +6 -6
- package/lib/codegen/naming.js +19 -19
- package/lib/codegen/openapi-cli.js +15 -15
- package/lib/codegen/openapi.d.ts +17 -0
- package/lib/codegen/openapi.d.ts.map +1 -1
- package/lib/codegen/openapi.js +323 -169
- package/lib/codegen/openapi.js.map +1 -1
- package/lib/codegen/operations.js +14 -14
- package/lib/codegen/pagination.js +11 -11
- package/lib/codegen/patch-audit.js +57 -57
- package/lib/codegen/patches.js +79 -79
- package/lib/codegen/prelude.js +19 -19
- package/lib/codegen/privatize.d.ts +21 -0
- package/lib/codegen/privatize.d.ts.map +1 -0
- package/lib/codegen/privatize.js +176 -0
- package/lib/codegen/privatize.js.map +1 -0
- package/lib/codegen/proto.js +25 -25
- package/lib/codegen/pure.d.ts +6 -0
- package/lib/codegen/pure.d.ts.map +1 -0
- package/lib/codegen/pure.js +91 -0
- package/lib/codegen/pure.js.map +1 -0
- package/lib/codegen/rewrite-operation-ids.js +108 -108
- package/lib/codegen/spec-path.js +57 -57
- package/lib/codegen/table.d.ts +5 -0
- package/lib/codegen/table.d.ts.map +1 -0
- package/lib/codegen/table.js +249 -0
- package/lib/codegen/table.js.map +1 -0
- package/lib/config.d.ts +27 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +1 -0
- package/lib/crypto.d.ts +76 -0
- package/lib/crypto.d.ts.map +1 -0
- package/lib/crypto.js +1 -0
- package/lib/debug.d.ts +2 -0
- package/lib/debug.d.ts.map +1 -0
- package/lib/debug.js +1 -0
- package/lib/error-category.d.ts +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +1 -46
- package/lib/errors.d.ts +62 -62
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -195
- package/lib/graphql.d.ts +31 -20
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.js +1 -1027
- package/lib/graphql.types.js +1 -5
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -15
- package/lib/json-patch.d.ts +2 -2
- package/lib/json-patch.js +1 -226
- package/lib/json-patch.js.map +1 -1
- package/lib/pagination.d.ts +9 -25
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -266
- package/lib/plain-values.d.ts +10 -0
- package/lib/plain-values.d.ts.map +1 -0
- package/lib/plain-values.js +2 -0
- package/lib/plain-values.js.map +1 -0
- package/lib/protocol-http.d.ts +50 -14
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -639
- package/lib/protocol-rest.d.ts +38 -25
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -267
- package/lib/query.js +1 -27
- package/lib/response-validation-strict.d.ts +48 -0
- package/lib/response-validation-strict.d.ts.map +1 -0
- package/lib/response-validation-strict.js +1 -0
- package/lib/response-validation.d.ts +43 -25
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/response-validation.js +1 -76
- package/lib/retry-after.d.ts +3 -3
- package/lib/retry-after.js +1 -112
- package/lib/retry.d.ts +48 -29
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -209
- package/lib/schema-lite-impl.d.ts +158 -0
- package/lib/schema-lite-impl.d.ts.map +1 -0
- package/lib/schema-lite-impl.js +1 -0
- package/lib/schema-lite-typed.d.ts +41 -0
- package/lib/schema-lite-typed.d.ts.map +1 -0
- package/lib/schema-lite-typed.js +2 -0
- package/lib/schema-lite-typed.js.map +1 -0
- package/lib/schema-lite.d.ts +40 -0
- package/lib/schema-lite.d.ts.map +1 -0
- package/lib/schema-lite.js +1 -0
- package/lib/schema.d.ts +20 -6
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +1 -48
- package/lib/testing.d.ts +3 -2
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +1 -40
- package/lib/testing.js.map +1 -1
- package/lib/trait.d.ts +13 -13
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +1 -131
- package/lib/xml.d.ts +1 -1
- package/lib/xml.d.ts.map +1 -1
- package/lib/xml.js +1 -311
- package/package.json +9 -7
- package/src/api.ts +1080 -180
- package/src/category.ts +33 -33
- package/src/chunks.ts +30 -0
- package/src/codegen/chunk.ts +147 -0
- package/src/codegen/cli.ts +27 -1
- package/src/codegen/datafy.ts +874 -0
- package/src/codegen/dedupe.ts +173 -0
- package/src/codegen/generator.ts +10 -3
- package/src/codegen/graphql-client.ts +49 -15
- package/src/codegen/latin1.ts +131 -0
- package/src/codegen/members.ts +8 -0
- package/src/codegen/openapi.ts +194 -3
- package/src/codegen/privatize.ts +200 -0
- package/src/codegen/pure.ts +94 -0
- package/src/codegen/table.ts +254 -0
- package/src/config.ts +216 -0
- package/src/crypto.ts +202 -0
- package/src/debug.ts +8 -0
- package/src/error-category.ts +2 -1
- package/src/errors.ts +65 -56
- package/src/graphql.ts +109 -62
- package/src/graphql.types.ts +9 -7
- package/src/index.ts +3 -2
- package/src/json-patch.ts +2 -2
- package/src/pagination.ts +37 -18
- package/src/plain-values.ts +41 -0
- package/src/protocol-http.ts +378 -145
- package/src/protocol-rest.ts +337 -169
- package/src/response-validation-strict.ts +327 -0
- package/src/response-validation.ts +101 -50
- package/src/retry-after.ts +3 -3
- package/src/retry.ts +94 -93
- package/src/schema-lite-impl.ts +550 -0
- package/src/schema-lite-typed.ts +44 -0
- package/src/schema-lite.ts +44 -0
- package/src/schema.ts +258 -14
- package/src/testing.ts +4 -2
- package/src/trait.ts +36 -28
- package/src/xml.ts +31 -17
- package/lib/api.js.map +0 -1
- package/lib/category.js.map +0 -1
- package/lib/codegen/boolean-string-enums.test.d.ts +0 -2
- package/lib/codegen/boolean-string-enums.test.d.ts.map +0 -1
- package/lib/codegen/boolean-string-enums.test.js +0 -275
- package/lib/codegen/boolean-string-enums.test.js.map +0 -1
- package/lib/codegen/defer-naming.test.d.ts +0 -2
- package/lib/codegen/defer-naming.test.d.ts.map +0 -1
- package/lib/codegen/defer-naming.test.js +0 -105
- package/lib/codegen/defer-naming.test.js.map +0 -1
- package/lib/codegen/generated-at.test.d.ts +0 -2
- package/lib/codegen/generated-at.test.d.ts.map +0 -1
- package/lib/codegen/generated-at.test.js +0 -81
- package/lib/codegen/generated-at.test.js.map +0 -1
- package/lib/codegen/generator.test.d.ts +0 -2
- package/lib/codegen/generator.test.d.ts.map +0 -1
- package/lib/codegen/generator.test.js +0 -121
- package/lib/codegen/generator.test.js.map +0 -1
- package/lib/codegen/graphql-client.test.d.ts +0 -2
- package/lib/codegen/graphql-client.test.d.ts.map +0 -1
- package/lib/codegen/graphql-client.test.js +0 -171
- package/lib/codegen/graphql-client.test.js.map +0 -1
- package/lib/codegen/openapi-binary.test.d.ts +0 -2
- package/lib/codegen/openapi-binary.test.d.ts.map +0 -1
- package/lib/codegen/openapi-binary.test.js +0 -67
- package/lib/codegen/openapi-binary.test.js.map +0 -1
- package/lib/codegen/patch-audit.test.d.ts +0 -2
- package/lib/codegen/patch-audit.test.d.ts.map +0 -1
- package/lib/codegen/patch-audit.test.js +0 -141
- package/lib/codegen/patch-audit.test.js.map +0 -1
- package/lib/codegen/patches.test.d.ts +0 -2
- package/lib/codegen/patches.test.d.ts.map +0 -1
- package/lib/codegen/patches.test.js +0 -155
- package/lib/codegen/patches.test.js.map +0 -1
- package/lib/codegen/protocol-imports.test.d.ts +0 -2
- package/lib/codegen/protocol-imports.test.d.ts.map +0 -1
- package/lib/codegen/protocol-imports.test.js +0 -36
- package/lib/codegen/protocol-imports.test.js.map +0 -1
- package/lib/codegen/rewrite-operation-ids.test.d.ts +0 -2
- package/lib/codegen/rewrite-operation-ids.test.d.ts.map +0 -1
- package/lib/codegen/rewrite-operation-ids.test.js +0 -451
- package/lib/codegen/rewrite-operation-ids.test.js.map +0 -1
- package/lib/codegen/untagged-unions.test.d.ts +0 -2
- package/lib/codegen/untagged-unions.test.d.ts.map +0 -1
- package/lib/codegen/untagged-unions.test.js +0 -80
- package/lib/codegen/untagged-unions.test.js.map +0 -1
- package/lib/error-category.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/fixtures/xml/upstream-validator.json +0 -397
- package/lib/graphql.js.map +0 -1
- package/lib/graphql.test.d.ts +0 -2
- package/lib/graphql.test.d.ts.map +0 -1
- package/lib/graphql.test.js +0 -151
- package/lib/graphql.test.js.map +0 -1
- package/lib/graphql.types.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/json-patch.test.d.ts +0 -2
- package/lib/json-patch.test.d.ts.map +0 -1
- package/lib/json-patch.test.js +0 -65
- package/lib/json-patch.test.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/pagination.test.d.ts +0 -2
- package/lib/pagination.test.d.ts.map +0 -1
- package/lib/pagination.test.js +0 -131
- package/lib/pagination.test.js.map +0 -1
- package/lib/protocol-http.js.map +0 -1
- package/lib/protocol-http.test.d.ts +0 -2
- package/lib/protocol-http.test.d.ts.map +0 -1
- package/lib/protocol-http.test.js +0 -228
- package/lib/protocol-http.test.js.map +0 -1
- package/lib/protocol-rest.js.map +0 -1
- package/lib/protocol-rest.test.d.ts +0 -2
- package/lib/protocol-rest.test.d.ts.map +0 -1
- package/lib/protocol-rest.test.js +0 -498
- package/lib/protocol-rest.test.js.map +0 -1
- package/lib/query.js.map +0 -1
- package/lib/response-validation.js.map +0 -1
- package/lib/response-validation.test.d.ts +0 -2
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -72
- package/lib/response-validation.test.js.map +0 -1
- package/lib/retry-after.js.map +0 -1
- package/lib/retry-after.test.d.ts +0 -2
- package/lib/retry-after.test.d.ts.map +0 -1
- package/lib/retry-after.test.js +0 -204
- package/lib/retry-after.test.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/retry.test.d.ts +0 -2
- package/lib/retry.test.d.ts.map +0 -1
- package/lib/retry.test.js +0 -407
- package/lib/retry.test.js.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/sdks.test.d.ts +0 -2
- package/lib/sdks.test.d.ts.map +0 -1
- package/lib/sdks.test.js +0 -76
- package/lib/sdks.test.js.map +0 -1
- package/lib/trait.js.map +0 -1
- package/lib/xml.js.map +0 -1
- package/lib/xml.test.d.ts +0 -2
- package/lib/xml.test.d.ts.map +0 -1
- package/lib/xml.test.js +0 -210
- package/lib/xml.test.js.map +0 -1
- package/src/codegen/boolean-string-enums.test.ts +0 -299
- package/src/codegen/defer-naming.test.ts +0 -113
- package/src/codegen/generated-at.test.ts +0 -89
- package/src/codegen/generator.test.ts +0 -137
- package/src/codegen/graphql-client.test.ts +0 -189
- package/src/codegen/openapi-binary.test.ts +0 -91
- package/src/codegen/patch-audit.test.ts +0 -160
- package/src/codegen/patches.test.ts +0 -188
- package/src/codegen/protocol-imports.test.ts +0 -39
- package/src/codegen/rewrite-operation-ids.test.ts +0 -472
- package/src/codegen/untagged-unions.test.ts +0 -85
- package/src/fixtures/xml/upstream-validator.json +0 -397
- package/src/graphql.test.ts +0 -198
- package/src/json-patch.test.ts +0 -77
- package/src/pagination.test.ts +0 -169
- package/src/protocol-http.test.ts +0 -276
- package/src/protocol-rest.test.ts +0 -703
- package/src/response-validation.test.ts +0 -89
- package/src/retry-after.test.ts +0 -267
- package/src/retry.test.ts +0 -566
- package/src/sdks.test.ts +0 -87
- package/src/xml.test.ts +0 -251
package/lib/codegen/patches.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
8
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
9
|
import * as fs from "node:fs/promises";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { applyOperation, isStaleTargetError, } from "../json-patch.js";
|
|
12
12
|
import { diffModels } from "./model-diff.js";
|
|
13
13
|
import { applyDeferredRename, RENAME_METADATA_KEY, verbNounSmithyModel, } from "./rewrite-operation-ids.js";
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
export const isSmithyPatchPath = (pointer) => pointer.startsWith("/shapes") || pointer.startsWith("/metadata") || pointer.startsWith("/smithy");
|
|
16
16
|
const exists = async (p) => {
|
|
17
17
|
try {
|
|
@@ -22,19 +22,19 @@ const exists = async (p) => {
|
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
38
|
export const SKIP_PATCHES_ENV = "DISTILLED_SKIP_PATCHES";
|
|
39
39
|
const parseSkipList = () => {
|
|
40
40
|
const raw = (process.env[SKIP_PATCHES_ENV] ?? "").trim();
|
|
@@ -81,11 +81,11 @@ const skipsOp = (list, file, index) => {
|
|
|
81
81
|
}
|
|
82
82
|
return false;
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
89
|
export const listRfc6902PatchFiles = async (dir) => {
|
|
90
90
|
if (!(await exists(dir)))
|
|
91
91
|
return [];
|
|
@@ -140,12 +140,12 @@ export const applyRfc6902Files = async (target, files, opts = {}) => {
|
|
|
140
140
|
}
|
|
141
141
|
return result;
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
149
|
export const syncServiceOperations = (model) => {
|
|
150
150
|
const shapes = model.shapes ?? {};
|
|
151
151
|
const opIds = Object.keys(shapes).filter((id) => shapes[id]?.type === "operation");
|
|
@@ -164,12 +164,12 @@ export const syncServiceOperations = (model) => {
|
|
|
164
164
|
}
|
|
165
165
|
return changed;
|
|
166
166
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
173
|
export const danglingTargets = (model) => {
|
|
174
174
|
const shapes = model.shapes ?? {};
|
|
175
175
|
const ids = new Set(Object.keys(shapes));
|
|
@@ -214,12 +214,12 @@ const loadSmithyPatches = async (patchesDir, dir) => {
|
|
|
214
214
|
}
|
|
215
215
|
return out;
|
|
216
216
|
};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
223
|
const finalizeModel = (model, resource, patches, o, skip, quiet) => {
|
|
224
224
|
const log = quiet ? () => { } : console.log;
|
|
225
225
|
const deferred = model.metadata?.[RENAME_METADATA_KEY];
|
|
@@ -316,20 +316,20 @@ const finalizeModel = (model, resource, patches, o, skip, quiet) => {
|
|
|
316
316
|
return { ok: true, model };
|
|
317
317
|
};
|
|
318
318
|
const modelText = (model) => `${JSON.stringify(model, null, 2)}\n`;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
333
|
export const finalizeConvert = async (o) => {
|
|
334
334
|
const specsRoot = path.resolve(o.root, ".generated-specs");
|
|
335
335
|
const specsDir = path.resolve(o.root, o.outDir ?? ".generated-specs");
|
|
@@ -389,12 +389,12 @@ export const finalizeConvert = async (o) => {
|
|
|
389
389
|
throw new Error(`finalizeConvert: ${broken.length} model(s) reference shapes that do not exist:\n ${broken.join("\n ")}`);
|
|
390
390
|
}
|
|
391
391
|
};
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
398
|
export const RENAME_MAP_ENV = "DISTILLED_RENAME_MAP";
|
|
399
399
|
const recordRename = (resource, rename) => {
|
|
400
400
|
const file = process.env[RENAME_MAP_ENV];
|
|
@@ -406,17 +406,17 @@ const recordRename = (resource, rename) => {
|
|
|
406
406
|
};
|
|
407
407
|
// ---------------------------------------------------------------------------
|
|
408
408
|
// in-memory patch audit
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
420
|
export const PATCH_AUDIT_ENV = "DISTILLED_PATCH_AUDIT";
|
|
421
421
|
export const PATCH_AUDIT_MARKER = "@@distilled-patch-audit ";
|
|
422
422
|
const readAuditRequest = async () => {
|
|
@@ -464,9 +464,9 @@ const auditModel = (audit, model, resource, text, patches, o, baseline) => {
|
|
|
464
464
|
emitVerdict({ key: p.key, model, verdict, deadOps });
|
|
465
465
|
}
|
|
466
466
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
471
|
export const FINALIZED_KEY = "distilled.finalized";
|
|
472
472
|
//# sourceMappingURL=patches.js.map
|
package/lib/codegen/prelude.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { isForwardRef } from "./graph.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
11
|
import { isPrelude, local } from "./naming.js";
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
export const JSON_PRELUDE = {
|
|
14
14
|
String: "S.String",
|
|
15
15
|
Boolean: "S.Boolean",
|
|
@@ -24,7 +24,7 @@ export const JSON_PRELUDE = {
|
|
|
24
24
|
Document: "S.Unknown",
|
|
25
25
|
Unit: "S.Struct({})",
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
export const TS_JSON_PRELUDE = {
|
|
29
29
|
String: "string",
|
|
30
30
|
Boolean: "boolean",
|
|
@@ -39,10 +39,10 @@ export const TS_JSON_PRELUDE = {
|
|
|
39
39
|
Document: "unknown",
|
|
40
40
|
Unit: "{}",
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
46
|
export const makeSchemaRef = (prelude, indexOf) => (target, selfIdx) => {
|
|
47
47
|
if (isPrelude(target))
|
|
48
48
|
return prelude[local(target)] ?? "S.Unknown";
|
|
@@ -52,9 +52,9 @@ export const makeSchemaRef = (prelude, indexOf) => (target, selfIdx) => {
|
|
|
52
52
|
}
|
|
53
53
|
return name;
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
59
|
export const makeTsRef = (tsPrelude) => (target) => isPrelude(target) ? (tsPrelude[local(target)] ?? "unknown") : local(target);
|
|
60
60
|
//# sourceMappingURL=prelude.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Node = {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly start: number;
|
|
4
|
+
readonly end: number;
|
|
5
|
+
} & Record<string, unknown>;
|
|
6
|
+
/** Value-position identifier names under `node` (type annotations, keys and member names excluded). */
|
|
7
|
+
export declare const valueRefs: (node: unknown, out: Set<string>, parent?: Node, parentKey?: string) => Set<string>;
|
|
8
|
+
export declare const privatizeSchemas: (code: string, filename?: string) => {
|
|
9
|
+
code: string;
|
|
10
|
+
privatized: number;
|
|
11
|
+
removed: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* `import * as X` whose namespace is used only in type positions becomes
|
|
15
|
+
* `import type * as X`. The generator's `oxlint --fix` otherwise deletes it
|
|
16
|
+
* as unused once the schema consts that used it as a value are gone, and the
|
|
17
|
+
* types that still name it stop compiling.
|
|
18
|
+
*/
|
|
19
|
+
export declare const typeOnlyNamespaceImports: (code: string, filename?: string) => string;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=privatize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privatize.d.ts","sourceRoot":"","sources":["../../src/codegen/privatize.ts"],"names":[],"mappings":"AAiBA,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAC1F,MAAM,EACN,OAAO,CACR,CAAC;AAKF,uGAAuG;AACvG,eAAO,MAAM,SAAS,SACd,OAAO,OACR,GAAG,CAAC,MAAM,CAAC,WACP,IAAI,cACD,MAAM,KACjB,GAAG,CAAC,MAAM,CAsCZ,CAAC;AAKF,eAAO,MAAM,gBAAgB,SACrB,MAAM,wBAEX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAkGrD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,wBAA8B,MAgBlF,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import { parseAst } from "rolldown/parseAst";
|
|
17
|
+
const isNode = (value) => value !== null && typeof value === "object" && typeof value.type === "string";
|
|
18
|
+
|
|
19
|
+
export const valueRefs = (node, out, parent, parentKey) => {
|
|
20
|
+
if (Array.isArray(node)) {
|
|
21
|
+
for (const child of node)
|
|
22
|
+
valueRefs(child, out, parent, parentKey);
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
if (!isNode(node))
|
|
26
|
+
return out;
|
|
27
|
+
if (node.type.startsWith("TS")) {
|
|
28
|
+
// Only the expression side of a cast or assertion is a value.
|
|
29
|
+
if (node.type === "TSAsExpression" ||
|
|
30
|
+
node.type === "TSSatisfiesExpression" ||
|
|
31
|
+
node.type === "TSNonNullExpression")
|
|
32
|
+
valueRefs(node.expression, out, node, "expression");
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
if (node.type === "Identifier") {
|
|
36
|
+
const isKey = parent?.type === "Property" && parentKey === "key" && !parent.computed && !parent.shorthand;
|
|
37
|
+
const isMember = parent?.type === "MemberExpression" && parentKey === "property" && !parent.computed;
|
|
38
|
+
if (!isKey && !isMember)
|
|
39
|
+
out.add(node.name);
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
for (const [key, value] of Object.entries(node)) {
|
|
43
|
+
if (key === "type" ||
|
|
44
|
+
key === "start" ||
|
|
45
|
+
key === "end" ||
|
|
46
|
+
key === "typeAnnotation" ||
|
|
47
|
+
key === "typeArguments" ||
|
|
48
|
+
key === "typeParameters" ||
|
|
49
|
+
key === "returnType")
|
|
50
|
+
continue;
|
|
51
|
+
if (value !== null && typeof value === "object")
|
|
52
|
+
valueRefs(value, out, node, key);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
};
|
|
56
|
+
const isOperation = (init, code) => /\bAPI\.make(Paginated)?\(/.test(code.slice(init.start, init.end));
|
|
57
|
+
export const privatizeSchemas = (code, filename = "generated.ts") => {
|
|
58
|
+
const program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
|
|
59
|
+
const schemaDecls = new Map();
|
|
60
|
+
const roots = new Set();
|
|
61
|
+
// Operation names, so an operation alias (`export const listObjects =
|
|
62
|
+
// listBucketObjects`) stays an exported operation and is not taken for a schema.
|
|
63
|
+
const operations = new Set();
|
|
64
|
+
for (const raw of program.body) {
|
|
65
|
+
if (raw.type !== "ExportNamedDeclaration" || !isNode(raw.declaration))
|
|
66
|
+
continue;
|
|
67
|
+
const stmt = raw.declaration;
|
|
68
|
+
if (stmt.type !== "VariableDeclaration")
|
|
69
|
+
continue;
|
|
70
|
+
for (const d of stmt.declarations) {
|
|
71
|
+
const id = d.id;
|
|
72
|
+
if (id.type === "Identifier" && isNode(d.init) && isOperation(d.init, code))
|
|
73
|
+
operations.add(id.name);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const isOperationAlias = (init) => init.type === "Identifier" && operations.has(init.name);
|
|
77
|
+
for (const raw of program.body) {
|
|
78
|
+
const exported = raw.type === "ExportNamedDeclaration" && isNode(raw.declaration);
|
|
79
|
+
const stmt = exported ? raw.declaration : raw;
|
|
80
|
+
if (exported &&
|
|
81
|
+
stmt.type === "VariableDeclaration" &&
|
|
82
|
+
stmt.declarations.length === 1) {
|
|
83
|
+
const d = stmt.declarations[0];
|
|
84
|
+
const id = d.id;
|
|
85
|
+
if (id.type === "Identifier" &&
|
|
86
|
+
isNode(d.init) &&
|
|
87
|
+
!isOperation(d.init, code) &&
|
|
88
|
+
!isOperationAlias(d.init)) {
|
|
89
|
+
schemaDecls.set(id.name, {
|
|
90
|
+
name: id.name,
|
|
91
|
+
stmt: raw,
|
|
92
|
+
exportStart: raw.start,
|
|
93
|
+
refs: valueRefs(d.init, new Set()),
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Everything else (operations, classes, imports, plain statements) keeps what it references alive.
|
|
99
|
+
if (stmt.type === "ImportDeclaration" ||
|
|
100
|
+
stmt.type === "TSInterfaceDeclaration" ||
|
|
101
|
+
stmt.type === "TSTypeAliasDeclaration")
|
|
102
|
+
continue;
|
|
103
|
+
if (raw.type === "ExportNamedDeclaration" && !isNode(raw.declaration)) {
|
|
104
|
+
// `export { A, B }` / `export type { ... }`
|
|
105
|
+
if (raw.exportKind !== "type")
|
|
106
|
+
for (const s of raw.specifiers)
|
|
107
|
+
roots.add(s.local.name ?? "");
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
for (const r of valueRefs(stmt, new Set()))
|
|
111
|
+
roots.add(r);
|
|
112
|
+
}
|
|
113
|
+
// Reachability from the roots through schema references.
|
|
114
|
+
const live = new Set();
|
|
115
|
+
const stack = [...roots].filter((n) => schemaDecls.has(n));
|
|
116
|
+
while (stack.length) {
|
|
117
|
+
const n = stack.pop();
|
|
118
|
+
if (live.has(n))
|
|
119
|
+
continue;
|
|
120
|
+
live.add(n);
|
|
121
|
+
for (const r of schemaDecls.get(n).refs)
|
|
122
|
+
if (schemaDecls.has(r) && !live.has(r))
|
|
123
|
+
stack.push(r);
|
|
124
|
+
}
|
|
125
|
+
// Rewrite back to front: drop dead consts (with their leading doc comment), un-export live ones.
|
|
126
|
+
const decls = [...schemaDecls.values()].sort((a, b) => b.stmt.start - a.stmt.start);
|
|
127
|
+
let out = code;
|
|
128
|
+
let removed = 0;
|
|
129
|
+
for (const d of decls) {
|
|
130
|
+
if (live.has(d.name)) {
|
|
131
|
+
out = out.slice(0, d.stmt.start) + out.slice(d.stmt.start).replace(/^export\s+/, "");
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
let start = d.stmt.start;
|
|
135
|
+
const before = out.slice(0, start);
|
|
136
|
+
const doc = /\/\*\*(?:(?!\*\/)[\s\S])*\*\/\s*$/.exec(before);
|
|
137
|
+
if (doc)
|
|
138
|
+
start = doc.index;
|
|
139
|
+
let end = d.stmt.end;
|
|
140
|
+
while (out[end] === "\n")
|
|
141
|
+
end++;
|
|
142
|
+
out = out.slice(0, start) + out.slice(end);
|
|
143
|
+
removed++;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { code: out, privatized: live.size, removed };
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
export const typeOnlyNamespaceImports = (code, filename = "generated.ts") => {
|
|
155
|
+
const program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
|
|
156
|
+
const body = program.body;
|
|
157
|
+
const used = new Set();
|
|
158
|
+
for (const st of body)
|
|
159
|
+
if (st.type !== "ImportDeclaration")
|
|
160
|
+
valueRefs(st, used);
|
|
161
|
+
let out = code;
|
|
162
|
+
for (const st of [...body].reverse()) {
|
|
163
|
+
if (st.type !== "ImportDeclaration" || st.importKind === "type")
|
|
164
|
+
continue;
|
|
165
|
+
const specs = st.specifiers;
|
|
166
|
+
if (specs.length !== 1 || specs[0].type !== "ImportNamespaceSpecifier")
|
|
167
|
+
continue;
|
|
168
|
+
const name = specs[0].local.name;
|
|
169
|
+
if (used.has(name))
|
|
170
|
+
continue;
|
|
171
|
+
const text = code.slice(st.start, st.end).replace(/^import \*/, "import type *");
|
|
172
|
+
out = out.slice(0, st.start) + text + out.slice(st.end);
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=privatize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privatize.js","sourceRoot":"","sources":["../../src/codegen/privatize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAC/C,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE1F,uGAAuG;AACvG,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAa,EACb,GAAgB,EAChB,MAAa,EACb,SAAkB,EACL,EAAE;IACf,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,MAAM,KAAK,IAAI,IAAI;YAAE,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACn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GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/lib/codegen/proto.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
24
|
import { SENSITIVE_FIELD_PATTERNS } from "./openapi.js";
|
|
25
25
|
// ============================================================================
|
|
26
26
|
// Prelude
|
|
@@ -551,7 +551,7 @@ class Parser {
|
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
|
-
|
|
554
|
+
|
|
555
555
|
export const parseProto = (text, filename = "input.proto") => {
|
|
556
556
|
const file = new Parser(text, filename).parseFile();
|
|
557
557
|
if (file.syntax !== "proto3") {
|
|
@@ -847,7 +847,7 @@ const copyIo = (ctx, rpcName, side, typeName) => {
|
|
|
847
847
|
},
|
|
848
848
|
});
|
|
849
849
|
};
|
|
850
|
-
|
|
850
|
+
|
|
851
851
|
export const rpcGroupName = (rpcName) => {
|
|
852
852
|
const m = rpcName.match(/^([A-Z][a-z]+|[A-Z]+(?![a-z]))/);
|
|
853
853
|
return m?.[1] ?? rpcName;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `code` with a PURE marker before every unmarked call in a
|
|
3
|
+
* top-level `const`/`let`/`var` initializer or class `extends` clause.
|
|
4
|
+
*/
|
|
5
|
+
export declare const annotateNestedCalls: (code: string, filename?: string) => string;
|
|
6
|
+
//# sourceMappingURL=pure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../../src/codegen/pure.ts"],"names":[],"mappings":"AAoEA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,SAAU,MAAM,wBAA8B,MAqB7E,CAAC"}
|