@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
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { afterEach, describe, expect, test } from "vitest";
|
|
5
|
-
import {
|
|
6
|
-
FINALIZED_KEY,
|
|
7
|
-
SKIP_PATCHES_ENV,
|
|
8
|
-
applyRfc6902Files,
|
|
9
|
-
danglingTargets,
|
|
10
|
-
finalizeConvert,
|
|
11
|
-
listRfc6902PatchFiles,
|
|
12
|
-
syncServiceOperations,
|
|
13
|
-
} from "./patches.ts";
|
|
14
|
-
|
|
15
|
-
const model = () => ({
|
|
16
|
-
smithy: "2.0",
|
|
17
|
-
shapes: {
|
|
18
|
-
"ns#Svc": {
|
|
19
|
-
type: "service",
|
|
20
|
-
operations: [{ target: "ns#AppsList" }, { target: "ns#AppsGet" }],
|
|
21
|
-
},
|
|
22
|
-
"ns#AppsList": {
|
|
23
|
-
type: "operation",
|
|
24
|
-
input: { target: "ns#AppsListRequest" },
|
|
25
|
-
output: { target: "smithy.api#Unit" },
|
|
26
|
-
},
|
|
27
|
-
"ns#AppsListRequest": { type: "structure", members: {} },
|
|
28
|
-
"ns#AppsGet": {
|
|
29
|
-
type: "operation",
|
|
30
|
-
input: { target: "smithy.api#Unit" },
|
|
31
|
-
output: { target: "smithy.api#Unit" },
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const scaffold = (patches?: Record<string, unknown>) => {
|
|
37
|
-
const root = mkdtempSync(join(tmpdir(), "finalize-"));
|
|
38
|
-
mkdirSync(join(root, ".generated-specs"));
|
|
39
|
-
writeFileSync(join(root, ".generated-specs", "svc.json"), JSON.stringify(model()));
|
|
40
|
-
if (patches) {
|
|
41
|
-
mkdirSync(join(root, "patches", "svc"), { recursive: true });
|
|
42
|
-
writeFileSync(join(root, "patches", "svc", "a.json"), JSON.stringify(patches));
|
|
43
|
-
}
|
|
44
|
-
return root;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const read = (root: string) =>
|
|
48
|
-
JSON.parse(readFileSync(join(root, ".generated-specs", "svc.json"), "utf8"));
|
|
49
|
-
|
|
50
|
-
describe("finalizeConvert", () => {
|
|
51
|
-
test("renames, syncs the service list, stamps the marker", async () => {
|
|
52
|
-
const root = scaffold();
|
|
53
|
-
await finalizeConvert({ root });
|
|
54
|
-
const m = read(root);
|
|
55
|
-
expect(Object.keys(m.shapes).sort()).toEqual(
|
|
56
|
-
["ns#Svc", "ns#ListApps", "ns#ListAppsRequest", "ns#GetApp"].sort(),
|
|
57
|
-
);
|
|
58
|
-
expect(m.shapes["ns#Svc"].operations).toEqual([
|
|
59
|
-
{ target: "ns#ListApps" },
|
|
60
|
-
{ target: "ns#GetApp" },
|
|
61
|
-
]);
|
|
62
|
-
expect(m.metadata[FINALIZED_KEY]).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("refuses a second pass", async () => {
|
|
66
|
-
const root = scaffold();
|
|
67
|
-
await finalizeConvert({ root });
|
|
68
|
-
await expect(finalizeConvert({ root })).rejects.toThrow(/already finalized/);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("applies Smithy patches and repairs the service list after a move", async () => {
|
|
72
|
-
const root = scaffold({
|
|
73
|
-
patches: [{ op: "move", from: "/shapes/ns#AppsGet", path: "/shapes/ns#FetchApp" }],
|
|
74
|
-
});
|
|
75
|
-
await finalizeConvert({ root });
|
|
76
|
-
const m = read(root);
|
|
77
|
-
expect(m.shapes["ns#FetchApp"]).toBeDefined();
|
|
78
|
-
expect(m.shapes["ns#Svc"].operations.map((o: any) => o.target)).toEqual([
|
|
79
|
-
"ns#ListApps",
|
|
80
|
-
"ns#FetchApp",
|
|
81
|
-
]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("rejects a patch that edits the spec", async () => {
|
|
85
|
-
const root = scaffold({
|
|
86
|
-
patches: [{ op: "add", path: "/paths/~1apps/get/responses/404", value: {} }],
|
|
87
|
-
});
|
|
88
|
-
await expect(finalizeConvert({ root })).rejects.toThrow(/target the Smithy model/);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("fails on a stale patch pointer by default", async () => {
|
|
92
|
-
const root = scaffold({
|
|
93
|
-
patches: [{ op: "remove", path: "/shapes/ns#Missing" }],
|
|
94
|
-
});
|
|
95
|
-
await expect(finalizeConvert({ root })).rejects.toThrow(/failed/);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test("fails on dangling targets and leaves the model unstamped", async () => {
|
|
99
|
-
const root = scaffold({
|
|
100
|
-
patches: [
|
|
101
|
-
{
|
|
102
|
-
op: "replace",
|
|
103
|
-
path: "/shapes/ns#AppsList/output/target",
|
|
104
|
-
value: "ns#Nope",
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
});
|
|
108
|
-
await expect(finalizeConvert({ root })).rejects.toThrow(/do not exist/);
|
|
109
|
-
expect(read(root).metadata?.[FINALIZED_KEY]).toBeUndefined();
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe("danglingTargets", () => {
|
|
114
|
-
test("ignores prelude ids", () => {
|
|
115
|
-
expect(danglingTargets(model())).toEqual([]);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe("syncServiceOperations", () => {
|
|
120
|
-
test("drops missing and appends unlisted, keeping order", () => {
|
|
121
|
-
const m = model();
|
|
122
|
-
delete (m.shapes as any)["ns#AppsGet"];
|
|
123
|
-
(m.shapes as any)["ns#Zed"] = { type: "operation" };
|
|
124
|
-
expect(syncServiceOperations(m)).toBe(1);
|
|
125
|
-
expect((m.shapes as any)["ns#Svc"].operations).toEqual([
|
|
126
|
-
{ target: "ns#AppsList" },
|
|
127
|
-
{ target: "ns#Zed" },
|
|
128
|
-
]);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe(SKIP_PATCHES_ENV, () => {
|
|
133
|
-
afterEach(() => {
|
|
134
|
-
delete process.env[SKIP_PATCHES_ENV];
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const patchDir = () => {
|
|
138
|
-
const dir = mkdtempSync(join(tmpdir(), "skip-"));
|
|
139
|
-
mkdirSync(join(dir, "svc"));
|
|
140
|
-
writeFileSync(
|
|
141
|
-
join(dir, "svc", "a.json"),
|
|
142
|
-
JSON.stringify({
|
|
143
|
-
patches: [
|
|
144
|
-
{ op: "add", path: "/x", value: 1 },
|
|
145
|
-
{ op: "add", path: "/y", value: 2 },
|
|
146
|
-
],
|
|
147
|
-
}),
|
|
148
|
-
);
|
|
149
|
-
writeFileSync(
|
|
150
|
-
join(dir, "svc", "b.json"),
|
|
151
|
-
JSON.stringify({ patches: [{ op: "add", path: "/z", value: 3 }] }),
|
|
152
|
-
);
|
|
153
|
-
return join(dir, "svc");
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
test("unset applies everything", async () => {
|
|
157
|
-
const target: Record<string, unknown> = {};
|
|
158
|
-
const files = await listRfc6902PatchFiles(patchDir());
|
|
159
|
-
expect(files.map((f) => f.split("/").pop())).toEqual(["a.json", "b.json"]);
|
|
160
|
-
expect((await applyRfc6902Files(target, files)).applied).toBe(3);
|
|
161
|
-
expect(target).toEqual({ x: 1, y: 2, z: 3 });
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("all lists no files", async () => {
|
|
165
|
-
process.env[SKIP_PATCHES_ENV] = "all";
|
|
166
|
-
expect(await listRfc6902PatchFiles(patchDir())).toEqual([]);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test("a basename or a path suffix drops that file", async () => {
|
|
170
|
-
const dir = patchDir();
|
|
171
|
-
process.env[SKIP_PATCHES_ENV] = "a.json";
|
|
172
|
-
expect((await listRfc6902PatchFiles(dir)).map((f) => f.split("/").pop())).toEqual(["b.json"]);
|
|
173
|
-
process.env[SKIP_PATCHES_ENV] = "svc/b.json";
|
|
174
|
-
expect((await listRfc6902PatchFiles(dir)).map((f) => f.split("/").pop())).toEqual(["a.json"]);
|
|
175
|
-
process.env[SKIP_PATCHES_ENV] = "other/b.json";
|
|
176
|
-
expect((await listRfc6902PatchFiles(dir)).length).toBe(2);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test("<file>:<index> drops one op and keeps the rest of the file", async () => {
|
|
180
|
-
const dir = patchDir();
|
|
181
|
-
const files = await listRfc6902PatchFiles(dir);
|
|
182
|
-
process.env[SKIP_PATCHES_ENV] = "a.json:1";
|
|
183
|
-
const target: Record<string, unknown> = {};
|
|
184
|
-
const result = await applyRfc6902Files(target, files);
|
|
185
|
-
expect(result.applied).toBe(2);
|
|
186
|
-
expect(target).toEqual({ x: 1, z: 3 });
|
|
187
|
-
});
|
|
188
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { generateService } from "./generator.ts";
|
|
3
|
-
|
|
4
|
-
test("imports only the pagination protocol when every operation uses it", () => {
|
|
5
|
-
const { code } = generateService(
|
|
6
|
-
{
|
|
7
|
-
smithy: "2.0",
|
|
8
|
-
shapes: {
|
|
9
|
-
"example#Service": {
|
|
10
|
-
type: "service",
|
|
11
|
-
version: "1",
|
|
12
|
-
operations: [{ target: "example#List" }],
|
|
13
|
-
},
|
|
14
|
-
"example#List": {
|
|
15
|
-
type: "operation",
|
|
16
|
-
input: { target: "example#Request" },
|
|
17
|
-
output: { target: "example#Response" },
|
|
18
|
-
traits: { "smithy.api#paginated": { mode: "single", items: "items" } },
|
|
19
|
-
},
|
|
20
|
-
"example#Request": { type: "structure", members: {} },
|
|
21
|
-
"example#Response": { type: "structure", members: { items: { target: "example#Items" } } },
|
|
22
|
-
"example#Items": { type: "list", member: { target: "smithy.api#String" } },
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
operationDecl: {
|
|
27
|
-
contextType: "OpContext",
|
|
28
|
-
commonErrorType: "OpError",
|
|
29
|
-
commonErrorClasses: [],
|
|
30
|
-
protocol: "DefaultProtocol",
|
|
31
|
-
retry: "Retry.Retry",
|
|
32
|
-
},
|
|
33
|
-
paginationProfiles: { default: { protocol: "PaginatedProtocol", itemsFallback: "items" } },
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
expect(code).toContain("protocol: PaginatedProtocol");
|
|
37
|
-
expect(code).toContain(" PaginatedProtocol,");
|
|
38
|
-
expect(code).not.toContain("DefaultProtocol");
|
|
39
|
-
});
|