@distilled.cloud/core 1.0.0-rc.13 → 1.0.0-rc.15
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/api.d.ts +4 -4
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +3 -5
- package/lib/api.js.map +1 -1
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +3 -5
- package/lib/category.js.map +1 -1
- package/lib/codegen/boolean-string-enums.d.ts.map +1 -1
- package/lib/codegen/boolean-string-enums.js +2 -6
- package/lib/codegen/boolean-string-enums.js.map +1 -1
- package/lib/codegen/boolean-string-enums.test.js +3 -5
- package/lib/codegen/boolean-string-enums.test.js.map +1 -1
- package/lib/codegen/cli.d.ts +5 -4
- package/lib/codegen/cli.d.ts.map +1 -1
- package/lib/codegen/cli.js +12 -9
- package/lib/codegen/cli.js.map +1 -1
- package/lib/codegen/defer-naming.test.d.ts +2 -0
- package/lib/codegen/defer-naming.test.d.ts.map +1 -0
- package/lib/codegen/defer-naming.test.js +105 -0
- package/lib/codegen/defer-naming.test.js.map +1 -0
- package/lib/codegen/emit.d.ts.map +1 -1
- package/lib/codegen/emit.js +1 -3
- package/lib/codegen/emit.js.map +1 -1
- package/lib/codegen/format.d.ts +0 -12
- package/lib/codegen/format.d.ts.map +1 -1
- package/lib/codegen/format.js +10 -6
- package/lib/codegen/format.js.map +1 -1
- package/lib/codegen/generated-at.d.ts +29 -0
- package/lib/codegen/generated-at.d.ts.map +1 -0
- package/lib/codegen/generated-at.js +78 -0
- package/lib/codegen/generated-at.js.map +1 -0
- package/lib/codegen/generated-at.test.d.ts +2 -0
- package/lib/codegen/generated-at.test.d.ts.map +1 -0
- package/lib/codegen/generated-at.test.js +81 -0
- package/lib/codegen/generated-at.test.js.map +1 -0
- package/lib/codegen/generator.d.ts +4 -2
- package/lib/codegen/generator.d.ts.map +1 -1
- package/lib/codegen/generator.js +37 -75
- package/lib/codegen/generator.js.map +1 -1
- package/lib/codegen/generator.test.js +4 -9
- package/lib/codegen/generator.test.js.map +1 -1
- package/lib/codegen/graphql-client.d.ts.map +1 -1
- package/lib/codegen/graphql-client.js +12 -33
- package/lib/codegen/graphql-client.js.map +1 -1
- package/lib/codegen/graphql-client.test.js +4 -12
- package/lib/codegen/graphql-client.test.js.map +1 -1
- package/lib/codegen/graphql.d.ts.map +1 -1
- package/lib/codegen/graphql.js +7 -20
- package/lib/codegen/graphql.js.map +1 -1
- package/lib/codegen/model-diff.d.ts +10 -0
- package/lib/codegen/model-diff.d.ts.map +1 -0
- package/lib/codegen/model-diff.js +67 -0
- package/lib/codegen/model-diff.js.map +1 -0
- package/lib/codegen/naming.d.ts.map +1 -1
- package/lib/codegen/naming.js.map +1 -1
- package/lib/codegen/openapi-binary.test.js +1 -1
- package/lib/codegen/openapi-binary.test.js.map +1 -1
- package/lib/codegen/openapi-cli.d.ts +11 -11
- package/lib/codegen/openapi-cli.d.ts.map +1 -1
- package/lib/codegen/openapi-cli.js +26 -51
- package/lib/codegen/openapi-cli.js.map +1 -1
- package/lib/codegen/openapi.d.ts +9 -1
- package/lib/codegen/openapi.d.ts.map +1 -1
- package/lib/codegen/openapi.js +48 -42
- package/lib/codegen/openapi.js.map +1 -1
- package/lib/codegen/operations.d.ts.map +1 -1
- package/lib/codegen/operations.js.map +1 -1
- package/lib/codegen/pagination.d.ts.map +1 -1
- package/lib/codegen/pagination.js +2 -4
- package/lib/codegen/pagination.js.map +1 -1
- package/lib/codegen/patch-audit.d.ts +84 -0
- package/lib/codegen/patch-audit.d.ts.map +1 -0
- package/lib/codegen/patch-audit.js +366 -0
- package/lib/codegen/patch-audit.js.map +1 -0
- package/lib/codegen/patch-audit.test.d.ts +2 -0
- package/lib/codegen/patch-audit.test.d.ts.map +1 -0
- package/lib/codegen/patch-audit.test.js +141 -0
- package/lib/codegen/patch-audit.test.js.map +1 -0
- package/lib/codegen/patches.d.ts +59 -10
- package/lib/codegen/patches.d.ts.map +1 -1
- package/lib/codegen/patches.js +233 -63
- package/lib/codegen/patches.js.map +1 -1
- package/lib/codegen/patches.test.js +8 -4
- package/lib/codegen/patches.test.js.map +1 -1
- package/lib/codegen/prelude.js +1 -1
- package/lib/codegen/prelude.js.map +1 -1
- package/lib/codegen/proto.d.ts.map +1 -1
- package/lib/codegen/proto.js +2 -4
- package/lib/codegen/proto.js.map +1 -1
- package/lib/codegen/protocol-imports.test.d.ts +2 -0
- package/lib/codegen/protocol-imports.test.d.ts.map +1 -0
- package/lib/codegen/protocol-imports.test.js +36 -0
- package/lib/codegen/protocol-imports.test.js.map +1 -0
- package/lib/codegen/rewrite-operation-ids.d.ts +23 -0
- package/lib/codegen/rewrite-operation-ids.d.ts.map +1 -1
- package/lib/codegen/rewrite-operation-ids.js +97 -59
- package/lib/codegen/rewrite-operation-ids.js.map +1 -1
- package/lib/codegen/rewrite-operation-ids.test.js +19 -101
- package/lib/codegen/rewrite-operation-ids.test.js.map +1 -1
- package/lib/codegen/spec-path.d.ts +1 -1
- package/lib/codegen/spec-path.d.ts.map +1 -1
- package/lib/codegen/spec-path.js +1 -1
- package/lib/codegen/spec-path.js.map +1 -1
- package/lib/codegen/untagged-unions.test.js +1 -1
- package/lib/codegen/untagged-unions.test.js.map +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +7 -5
- package/lib/errors.js.map +1 -1
- package/lib/graphql.d.ts +4 -8
- package/lib/graphql.d.ts.map +1 -1
- package/lib/graphql.js +20 -48
- package/lib/graphql.js.map +1 -1
- package/lib/graphql.test.js +6 -6
- package/lib/graphql.test.js.map +1 -1
- package/lib/graphql.types.d.ts.map +1 -1
- package/lib/graphql.types.js.map +1 -1
- package/lib/json-patch.d.ts +13 -6
- package/lib/json-patch.d.ts.map +1 -1
- package/lib/json-patch.js +34 -19
- package/lib/json-patch.js.map +1 -1
- package/lib/json-patch.test.d.ts +2 -0
- package/lib/json-patch.test.d.ts.map +1 -0
- package/lib/json-patch.test.js +65 -0
- package/lib/json-patch.test.js.map +1 -0
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +6 -16
- package/lib/pagination.js.map +1 -1
- package/lib/pagination.test.js +3 -6
- package/lib/pagination.test.js.map +1 -1
- package/lib/protocol-http.d.ts +20 -1
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +41 -47
- package/lib/protocol-http.js.map +1 -1
- package/lib/protocol-http.test.js +20 -10
- package/lib/protocol-http.test.js.map +1 -1
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +9 -18
- package/lib/protocol-rest.js.map +1 -1
- package/lib/protocol-rest.test.d.ts +2 -0
- package/lib/protocol-rest.test.d.ts.map +1 -0
- package/lib/protocol-rest.test.js +498 -0
- package/lib/protocol-rest.test.js.map +1 -0
- package/lib/response-validation.d.ts.map +1 -1
- package/lib/response-validation.js.map +1 -1
- package/lib/response-validation.test.js +10 -5
- package/lib/response-validation.test.js.map +1 -1
- package/lib/retry-after.d.ts.map +1 -1
- package/lib/retry-after.js +1 -1
- package/lib/retry-after.js.map +1 -1
- package/lib/retry-after.test.d.ts +2 -0
- package/lib/retry-after.test.d.ts.map +1 -0
- package/lib/retry-after.test.js +204 -0
- package/lib/retry-after.test.js.map +1 -0
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -2
- package/lib/retry.js.map +1 -1
- package/lib/retry.test.d.ts +2 -0
- package/lib/retry.test.d.ts.map +1 -0
- package/lib/retry.test.js +407 -0
- package/lib/retry.test.js.map +1 -0
- package/lib/sdks.test.d.ts +2 -0
- package/lib/sdks.test.d.ts.map +1 -0
- package/lib/sdks.test.js +76 -0
- package/lib/sdks.test.js.map +1 -0
- package/lib/testing.d.ts +2 -2
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +1 -1
- package/lib/testing.js.map +1 -1
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js.map +1 -1
- package/lib/xml.d.ts.map +1 -1
- package/lib/xml.js +3 -7
- package/lib/xml.js.map +1 -1
- package/lib/xml.test.js +11 -12
- package/lib/xml.test.js.map +1 -1
- package/package.json +7 -10
- package/src/api.ts +38 -55
- package/src/category.ts +21 -50
- package/src/codegen/boolean-string-enums.test.ts +12 -28
- package/src/codegen/boolean-string-enums.ts +2 -10
- package/src/codegen/cli.ts +29 -47
- package/src/codegen/defer-naming.test.ts +113 -0
- package/src/codegen/emit.ts +2 -5
- package/src/codegen/format.ts +12 -10
- package/src/codegen/generated-at.test.ts +89 -0
- package/src/codegen/generated-at.ts +88 -0
- package/src/codegen/generator.test.ts +8 -22
- package/src/codegen/generator.ts +72 -191
- package/src/codegen/graphql-client.test.ts +12 -42
- package/src/codegen/graphql-client.ts +30 -95
- package/src/codegen/graphql.ts +22 -94
- package/src/codegen/model-diff.ts +67 -0
- package/src/codegen/naming.ts +1 -2
- package/src/codegen/openapi-binary.test.ts +5 -12
- package/src/codegen/openapi-cli.ts +38 -79
- package/src/codegen/openapi.ts +79 -136
- package/src/codegen/operations.ts +2 -5
- package/src/codegen/pagination.ts +4 -11
- package/src/codegen/patch-audit.test.ts +160 -0
- package/src/codegen/patch-audit.ts +480 -0
- package/src/codegen/patches.test.ts +14 -21
- package/src/codegen/patches.ts +313 -103
- package/src/codegen/prelude.ts +1 -1
- package/src/codegen/proto.ts +18 -54
- package/src/codegen/protocol-imports.test.ts +39 -0
- package/src/codegen/rewrite-operation-ids.test.ts +23 -114
- package/src/codegen/rewrite-operation-ids.ts +111 -98
- package/src/codegen/spec-path.ts +3 -6
- package/src/codegen/untagged-unions.test.ts +3 -7
- package/src/error-category.ts +5 -17
- package/src/errors.ts +16 -31
- package/src/graphql.test.ts +6 -8
- package/src/graphql.ts +76 -219
- package/src/graphql.types.ts +10 -25
- package/src/json-patch.test.ts +77 -0
- package/src/json-patch.ts +54 -60
- package/src/pagination.test.ts +13 -35
- package/src/pagination.ts +44 -111
- package/src/protocol-http.test.ts +36 -30
- package/src/protocol-http.ts +73 -138
- package/src/protocol-rest.test.ts +703 -0
- package/src/protocol-rest.ts +24 -62
- package/src/response-validation.test.ts +12 -18
- package/src/response-validation.ts +3 -12
- package/src/retry-after.test.ts +267 -0
- package/src/retry-after.ts +4 -10
- package/src/retry.test.ts +566 -0
- package/src/retry.ts +6 -21
- package/src/sdks.test.ts +87 -0
- package/src/testing.ts +4 -10
- package/src/trait.ts +21 -67
- package/src/xml.test.ts +15 -33
- package/src/xml.ts +9 -25
package/src/codegen/proto.ts
CHANGED
|
@@ -272,8 +272,7 @@ class Parser {
|
|
|
272
272
|
ident(): string {
|
|
273
273
|
this.skipTrivia();
|
|
274
274
|
const ch = this.peekChar();
|
|
275
|
-
if (!/[A-Za-z_]/.test(ch))
|
|
276
|
-
this.fail(`expected identifier, got ${JSON.stringify(ch)}`);
|
|
275
|
+
if (!/[A-Za-z_]/.test(ch)) this.fail(`expected identifier, got ${JSON.stringify(ch)}`);
|
|
277
276
|
let out = this.bump();
|
|
278
277
|
while (/[A-Za-z0-9_]/.test(this.peekChar())) out += this.bump();
|
|
279
278
|
return out;
|
|
@@ -313,9 +312,7 @@ class Parser {
|
|
|
313
312
|
expect(ch: string): void {
|
|
314
313
|
this.skipTrivia();
|
|
315
314
|
if (this.peekChar() !== ch) {
|
|
316
|
-
this.fail(
|
|
317
|
-
`expected ${JSON.stringify(ch)}, got ${JSON.stringify(this.peekChar())}`,
|
|
318
|
-
);
|
|
315
|
+
this.fail(`expected ${JSON.stringify(ch)}, got ${JSON.stringify(this.peekChar())}`);
|
|
319
316
|
}
|
|
320
317
|
this.bump();
|
|
321
318
|
}
|
|
@@ -382,8 +379,7 @@ class Parser {
|
|
|
382
379
|
this.expect("=");
|
|
383
380
|
this.skipTrivia();
|
|
384
381
|
let value: unknown;
|
|
385
|
-
if (this.peekChar() === '"' || this.peekChar() === "'")
|
|
386
|
-
value = this.stringLit();
|
|
382
|
+
if (this.peekChar() === '"' || this.peekChar() === "'") value = this.stringLit();
|
|
387
383
|
else if (this.tryIdent("true")) value = true;
|
|
388
384
|
else if (this.tryIdent("false")) value = false;
|
|
389
385
|
else if (/[0-9-]/.test(this.peekChar())) value = this.number();
|
|
@@ -476,11 +472,7 @@ class Parser {
|
|
|
476
472
|
while (true) {
|
|
477
473
|
this.skipTrivia();
|
|
478
474
|
if (this.peekChar() === "}") break;
|
|
479
|
-
if (
|
|
480
|
-
this.tryIdent("option") ||
|
|
481
|
-
this.tryIdent("reserved") ||
|
|
482
|
-
this.tryIdent("extensions")
|
|
483
|
-
) {
|
|
475
|
+
if (this.tryIdent("option") || this.tryIdent("reserved") || this.tryIdent("extensions")) {
|
|
484
476
|
this.skipUntil(";");
|
|
485
477
|
this.expect(";");
|
|
486
478
|
continue;
|
|
@@ -647,15 +639,10 @@ class Parser {
|
|
|
647
639
|
}
|
|
648
640
|
|
|
649
641
|
/** Parse a proto3 source file into an AST. */
|
|
650
|
-
export const parseProto = (
|
|
651
|
-
text: string,
|
|
652
|
-
filename = "input.proto",
|
|
653
|
-
): ProtoFile => {
|
|
642
|
+
export const parseProto = (text: string, filename = "input.proto"): ProtoFile => {
|
|
654
643
|
const file = new Parser(text, filename).parseFile();
|
|
655
644
|
if (file.syntax !== "proto3") {
|
|
656
|
-
throw new Error(
|
|
657
|
-
`${filename}: expected proto3, got ${JSON.stringify(file.syntax)}`,
|
|
658
|
-
);
|
|
645
|
+
throw new Error(`${filename}: expected proto3, got ${JSON.stringify(file.syntax)}`);
|
|
659
646
|
}
|
|
660
647
|
return file;
|
|
661
648
|
};
|
|
@@ -684,8 +671,7 @@ const indexFiles = (files: readonly ProtoFile[]): TypeIndex => {
|
|
|
684
671
|
};
|
|
685
672
|
for (const file of files) {
|
|
686
673
|
for (const msg of file.messages) walkMessage(msg, index);
|
|
687
|
-
for (const en of file.enums)
|
|
688
|
-
index.enums.set(en.fullName, index.enums.get(en.fullName) ?? en);
|
|
674
|
+
for (const en of file.enums) index.enums.set(en.fullName, index.enums.get(en.fullName) ?? en);
|
|
689
675
|
index.services.push(...file.services);
|
|
690
676
|
}
|
|
691
677
|
return index;
|
|
@@ -699,8 +685,7 @@ const resolveName = (
|
|
|
699
685
|
): string => {
|
|
700
686
|
const stripped = name.startsWith(".") ? name.slice(1) : name;
|
|
701
687
|
if (SCALAR_TARGETS[stripped]) return stripped;
|
|
702
|
-
if (WKT_TARGETS[stripped] || stripped.startsWith("google.protobuf."))
|
|
703
|
-
return stripped;
|
|
688
|
+
if (WKT_TARGETS[stripped] || stripped.startsWith("google.protobuf.")) return stripped;
|
|
704
689
|
const candidates: string[] = [];
|
|
705
690
|
if (name.startsWith(".")) {
|
|
706
691
|
candidates.push(stripped);
|
|
@@ -718,9 +703,7 @@ const resolveName = (
|
|
|
718
703
|
for (const c of candidates) {
|
|
719
704
|
if (index.messages.has(c) || index.enums.has(c)) return c;
|
|
720
705
|
}
|
|
721
|
-
throw new Error(
|
|
722
|
-
`unresolved proto type ${JSON.stringify(name)} (package ${pkg}, scope ${scope})`,
|
|
723
|
-
);
|
|
706
|
+
throw new Error(`unresolved proto type ${JSON.stringify(name)} (package ${pkg}, scope ${scope})`);
|
|
724
707
|
};
|
|
725
708
|
|
|
726
709
|
// ============================================================================
|
|
@@ -733,8 +716,7 @@ interface Bag {
|
|
|
733
716
|
namespace: string;
|
|
734
717
|
}
|
|
735
718
|
|
|
736
|
-
const capitalize = (s: string): string =>
|
|
737
|
-
s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
|
719
|
+
const capitalize = (s: string): string => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
|
|
738
720
|
|
|
739
721
|
const ident = (s: string): string => {
|
|
740
722
|
let out = s.replace(/[^A-Za-z0-9_]/g, "_");
|
|
@@ -776,8 +758,7 @@ const oneLineDoc = (s: string | undefined): string | undefined => {
|
|
|
776
758
|
return t ? t : undefined;
|
|
777
759
|
};
|
|
778
760
|
|
|
779
|
-
const isSensitive = (name: string): boolean =>
|
|
780
|
-
SENSITIVE_FIELD_PATTERNS.some((re) => re.test(name));
|
|
761
|
+
const isSensitive = (name: string): boolean => SENSITIVE_FIELD_PATTERNS.some((re) => re.test(name));
|
|
781
762
|
|
|
782
763
|
const EMPTY_STRUCT_ID = "GoogleProtobufEmpty";
|
|
783
764
|
|
|
@@ -875,11 +856,7 @@ const mapOf = (ctx: EmitCtx, value: string): string => {
|
|
|
875
856
|
return id;
|
|
876
857
|
};
|
|
877
858
|
|
|
878
|
-
const fieldTarget = (
|
|
879
|
-
ctx: EmitCtx,
|
|
880
|
-
field: ProtoField,
|
|
881
|
-
scope: string,
|
|
882
|
-
): string => {
|
|
859
|
+
const fieldTarget = (ctx: EmitCtx, field: ProtoField, scope: string): string => {
|
|
883
860
|
if (field.mapKey && field.mapValue) {
|
|
884
861
|
const value = emitType(ctx, field.mapValue, scope, true);
|
|
885
862
|
return mapOf(ctx, value);
|
|
@@ -888,10 +865,7 @@ const fieldTarget = (
|
|
|
888
865
|
return field.repeated ? listOf(ctx, inner) : inner;
|
|
889
866
|
};
|
|
890
867
|
|
|
891
|
-
const memberTraits = (
|
|
892
|
-
field: ProtoField,
|
|
893
|
-
tsName: string,
|
|
894
|
-
): Record<string, any> => {
|
|
868
|
+
const memberTraits = (field: ProtoField, tsName: string): Record<string, any> => {
|
|
895
869
|
const traits: Record<string, any> = {};
|
|
896
870
|
const doc = oneLineDoc(field.documentation);
|
|
897
871
|
if (doc) traits["smithy.api#documentation"] = doc;
|
|
@@ -989,10 +963,7 @@ const copyIo = (
|
|
|
989
963
|
});
|
|
990
964
|
}
|
|
991
965
|
const msg = ctx.index.messages.get(resolved);
|
|
992
|
-
if (!msg)
|
|
993
|
-
throw new Error(
|
|
994
|
-
`rpc ${rpcName}: ${side} type ${typeName} is not a message`,
|
|
995
|
-
);
|
|
966
|
+
if (!msg) throw new Error(`rpc ${rpcName}: ${side} type ${typeName} is not a message`);
|
|
996
967
|
return addShape(ctx.bag, `${rpcName}${side}`, {
|
|
997
968
|
type: "structure",
|
|
998
969
|
members: emitMembers(ctx, msg.fields, msg.fullName),
|
|
@@ -1008,13 +979,9 @@ export const rpcGroupName = (rpcName: string): string => {
|
|
|
1008
979
|
return m?.[1] ?? rpcName;
|
|
1009
980
|
};
|
|
1010
981
|
|
|
1011
|
-
export const convertProtoToSmithy = (
|
|
1012
|
-
options: ProtoConvertOptions,
|
|
1013
|
-
): ProtoConvertResult => {
|
|
982
|
+
export const convertProtoToSmithy = (options: ProtoConvertOptions): ProtoConvertResult => {
|
|
1014
983
|
const index = indexFiles(options.files);
|
|
1015
|
-
const service = index.services.find(
|
|
1016
|
-
(s) => s.fullName === options.protoService,
|
|
1017
|
-
);
|
|
984
|
+
const service = index.services.find((s) => s.fullName === options.protoService);
|
|
1018
985
|
if (!service) {
|
|
1019
986
|
throw new Error(
|
|
1020
987
|
`proto service ${options.protoService} not found (have ${index.services
|
|
@@ -1022,11 +989,8 @@ export const convertProtoToSmithy = (
|
|
|
1022
989
|
.join(", ")})`,
|
|
1023
990
|
);
|
|
1024
991
|
}
|
|
1025
|
-
const file = options.files.find((f) =>
|
|
1026
|
-
|
|
1027
|
-
);
|
|
1028
|
-
const pkg =
|
|
1029
|
-
file?.package ?? service.fullName.split(".").slice(0, -1).join(".");
|
|
992
|
+
const file = options.files.find((f) => f.services.some((s) => s.fullName === service.fullName));
|
|
993
|
+
const pkg = file?.package ?? service.fullName.split(".").slice(0, -1).join(".");
|
|
1030
994
|
|
|
1031
995
|
const bag: Bag = {
|
|
1032
996
|
shapes: {},
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, test } from "
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
2
|
import {
|
|
3
3
|
isMechanicalOperationId,
|
|
4
4
|
isVerbatimRouteId,
|
|
@@ -28,10 +28,7 @@ const cases: ReadonlyArray<readonly [string, string]> = [
|
|
|
28
28
|
["addsServices_list", "listAddsServices"],
|
|
29
29
|
["addsServices_get", "getAddsService"],
|
|
30
30
|
["ServiceMembers_getMetrics", "getServiceMemberMetrics"],
|
|
31
|
-
[
|
|
32
|
-
"ServiceMembers_listGlobalConfiguration",
|
|
33
|
-
"listServiceMemberGlobalConfiguration",
|
|
34
|
-
],
|
|
31
|
+
["ServiceMembers_listGlobalConfiguration", "listServiceMemberGlobalConfiguration"],
|
|
35
32
|
["VirtualMachines_start", "startVirtualMachine"],
|
|
36
33
|
["OpenIdConnectProvider_get", "getOpenIdConnectProvider"],
|
|
37
34
|
["Report_verify", "verifyReport"],
|
|
@@ -80,14 +77,8 @@ const cases: ReadonlyArray<readonly [string, string]> = [
|
|
|
80
77
|
["index", "list"],
|
|
81
78
|
["RetrieveAccount", "getAccount"],
|
|
82
79
|
["WatchCoreV1PersistentVolumeList", "watchCoreV1PersistentVolumeList"],
|
|
83
|
-
[
|
|
84
|
-
|
|
85
|
-
"readAppsV1NamespacedReplicaSetStatus",
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
"ReplaceAppsV1NamespacedStatefulSetScale",
|
|
89
|
-
"replaceAppsV1NamespacedStatefulSetScale",
|
|
90
|
-
],
|
|
80
|
+
["ReadAppsV1NamespacedReplicaSetStatus", "readAppsV1NamespacedReplicaSetStatus"],
|
|
81
|
+
["ReplaceAppsV1NamespacedStatefulSetScale", "replaceAppsV1NamespacedStatefulSetScale"],
|
|
91
82
|
[
|
|
92
83
|
"ConnectCoreV1DeleteNamespacedPodProxyWithPath",
|
|
93
84
|
"connectCoreV1DeleteNamespacedPodProxyWithPath",
|
|
@@ -99,10 +90,7 @@ const cases: ReadonlyArray<readonly [string, string]> = [
|
|
|
99
90
|
["AddStatusCheckContexts", "addStatusCheckContexts"],
|
|
100
91
|
["UploadReleaseAsset", "uploadReleaseAsset"],
|
|
101
92
|
["PostRadarValueListItems", "postRadarValueListItems"],
|
|
102
|
-
[
|
|
103
|
-
"PostSetupIntentsIntentVerifyMicrodeposits",
|
|
104
|
-
"postSetupIntentsIntentVerifyMicrodeposits",
|
|
105
|
-
],
|
|
93
|
+
["PostSetupIntentsIntentVerifyMicrodeposits", "postSetupIntentsIntentVerifyMicrodeposits"],
|
|
106
94
|
["InsertCalendarList", "insertCalendarList"],
|
|
107
95
|
["FetchThreatListUpdates", "fetchThreatListUpdates"],
|
|
108
96
|
["StreamGenerateContent", "streamGenerateContent"],
|
|
@@ -245,9 +233,7 @@ describe("verbNounSmithyModel", () => {
|
|
|
245
233
|
{ target: "ns#GetApp" },
|
|
246
234
|
]);
|
|
247
235
|
expect(shapes["ns#ListApps"].output.target).toBe("ns#ListAppsResponse");
|
|
248
|
-
expect(shapes["ns#ListAppsResponse"].members.items.target).toBe(
|
|
249
|
-
"ns#ListAppsResponseItemsList",
|
|
250
|
-
);
|
|
236
|
+
expect(shapes["ns#ListAppsResponse"].members.items.target).toBe("ns#ListAppsResponseItemsList");
|
|
251
237
|
});
|
|
252
238
|
|
|
253
239
|
test("is idempotent", () => {
|
|
@@ -278,10 +264,7 @@ describe("verbNounSmithyModel", () => {
|
|
|
278
264
|
const r = verbNounSmithyModel(model);
|
|
279
265
|
expect(r.renamed).toBe(0);
|
|
280
266
|
expect(r.collisions).toEqual(["AppsList → ListApps"]);
|
|
281
|
-
expect(Object.keys(model.shapes).sort()).toEqual([
|
|
282
|
-
"ns#AppsList",
|
|
283
|
-
"ns#ListApps",
|
|
284
|
-
]);
|
|
267
|
+
expect(Object.keys(model.shapes).sort()).toEqual(["ns#AppsList", "ns#ListApps"]);
|
|
285
268
|
});
|
|
286
269
|
});
|
|
287
270
|
|
|
@@ -295,31 +278,16 @@ describe("isMechanicalOperationId", () => {
|
|
|
295
278
|
["getEvents", "get", "/events", true],
|
|
296
279
|
["getMauUsage", "get", "/api/v2/usage/mau", false],
|
|
297
280
|
["getExperimentSnapshot", "get", "/v1/snapshots/{id}", false],
|
|
298
|
-
[
|
|
299
|
-
"deleteBranches",
|
|
300
|
-
"post",
|
|
301
|
-
"/api/v2/code-refs/repositories/{repo}/branch-delete-tasks",
|
|
302
|
-
false,
|
|
303
|
-
],
|
|
281
|
+
["deleteBranches", "post", "/api/v2/code-refs/repositories/{repo}/branch-delete-tasks", false],
|
|
304
282
|
["post-applePay-sessions", "post", "/applePay/sessions", true],
|
|
305
283
|
["Apps_list", "get", "/apps", false],
|
|
306
284
|
["listUsers", "get", "/users", false],
|
|
307
|
-
[
|
|
308
|
-
"delete-artifact",
|
|
309
|
-
"delete",
|
|
310
|
-
"/repos/{owner}/{repo}/actions/artifacts/{artifact_id}",
|
|
311
|
-
false,
|
|
312
|
-
],
|
|
285
|
+
["delete-artifact", "delete", "/repos/{owner}/{repo}/actions/artifacts/{artifact_id}", false],
|
|
313
286
|
["get_pricing", "get", "/pricing", true],
|
|
314
287
|
["get_actions", "get", "/actions", true],
|
|
315
288
|
["deletePolicy", "delete", "/v2/policies/{policyId}", true],
|
|
316
289
|
["getCustomerById", "get", "/v2/customers/{customerId}", true],
|
|
317
|
-
[
|
|
318
|
-
"getBalanceByAsset",
|
|
319
|
-
"get",
|
|
320
|
-
"/accounts/{account_id}/balances/{asset}",
|
|
321
|
-
false,
|
|
322
|
-
],
|
|
290
|
+
["getBalanceByAsset", "get", "/accounts/{account_id}/balances/{asset}", false],
|
|
323
291
|
])("%s %s %s → %s", (id, method, path, expected) => {
|
|
324
292
|
expect(isMechanicalOperationId(id, { method, path })).toBe(expected);
|
|
325
293
|
});
|
|
@@ -337,20 +305,8 @@ describe("pathToVerbNoun with a mechanical id", () => {
|
|
|
337
305
|
false,
|
|
338
306
|
"getLoadBalancerMetrics",
|
|
339
307
|
],
|
|
340
|
-
[
|
|
341
|
-
|
|
342
|
-
"/v2/policies/{policyId}",
|
|
343
|
-
"deletePolicy",
|
|
344
|
-
undefined,
|
|
345
|
-
"deletePolicy",
|
|
346
|
-
],
|
|
347
|
-
[
|
|
348
|
-
"get",
|
|
349
|
-
"/v2/customers/{customerId}",
|
|
350
|
-
"getCustomerById",
|
|
351
|
-
undefined,
|
|
352
|
-
"getCustomer",
|
|
353
|
-
],
|
|
308
|
+
["delete", "/v2/policies/{policyId}", "deletePolicy", undefined, "deletePolicy"],
|
|
309
|
+
["get", "/v2/customers/{customerId}", "getCustomerById", undefined, "getCustomer"],
|
|
354
310
|
["post", "/api/action", "post-api-action", undefined, "createAction"],
|
|
355
311
|
[
|
|
356
312
|
"get",
|
|
@@ -359,13 +315,7 @@ describe("pathToVerbNoun with a mechanical id", () => {
|
|
|
359
315
|
undefined,
|
|
360
316
|
"getOrgRuleset",
|
|
361
317
|
],
|
|
362
|
-
[
|
|
363
|
-
"get",
|
|
364
|
-
"/orgs/{org}/rulesets",
|
|
365
|
-
"repos/get-org-rulesets",
|
|
366
|
-
true,
|
|
367
|
-
"listOrgRulesets",
|
|
368
|
-
],
|
|
318
|
+
["get", "/orgs/{org}/rulesets", "repos/get-org-rulesets", true, "listOrgRulesets"],
|
|
369
319
|
[
|
|
370
320
|
"delete",
|
|
371
321
|
"/api/jobs/{namespace}/scheduled/{id}",
|
|
@@ -381,31 +331,19 @@ describe("pathToVerbNoun with a mechanical id", () => {
|
|
|
381
331
|
"getPaymentSessionAuthorization",
|
|
382
332
|
],
|
|
383
333
|
])("%s %s (%s) → %s", (method, path, id, coll, expected) => {
|
|
384
|
-
expect(
|
|
385
|
-
pathToVerbNoun({ method, path }, { returnsCollection: coll, nouns: id }),
|
|
386
|
-
).toBe(expected);
|
|
334
|
+
expect(pathToVerbNoun({ method, path }, { returnsCollection: coll, nouns: id })).toBe(expected);
|
|
387
335
|
});
|
|
388
336
|
});
|
|
389
337
|
|
|
390
338
|
describe("pathToVerbNoun with a verbatim id", () => {
|
|
391
339
|
test.each([
|
|
392
|
-
[
|
|
393
|
-
"post",
|
|
394
|
-
"/v1/apps/{appId}/promote",
|
|
395
|
-
"postV1AppsByAppIdPromote",
|
|
396
|
-
"createAppPromote",
|
|
397
|
-
],
|
|
340
|
+
["post", "/v1/apps/{appId}/promote", "postV1AppsByAppIdPromote", "createAppPromote"],
|
|
398
341
|
["get", "/v1/apps", "getV1Apps", "getApps"],
|
|
399
342
|
["get", "/v1/apps/{appId}", "getV1AppsByAppId", "getApp"],
|
|
400
343
|
["post", "/v1/accounts/{account}", "PostAccountsAccount", "updateAccount"],
|
|
401
344
|
["post", "/v1/accounts", "PostAccounts", "createAccount"],
|
|
402
345
|
["get", "/v1/accounts/{account}", "GetAccountsAccount", "getAccount"],
|
|
403
|
-
[
|
|
404
|
-
"delete",
|
|
405
|
-
"/v1/accounts/{account}",
|
|
406
|
-
"DeleteAccountsAccount",
|
|
407
|
-
"deleteAccount",
|
|
408
|
-
],
|
|
346
|
+
["delete", "/v1/accounts/{account}", "DeleteAccountsAccount", "deleteAccount"],
|
|
409
347
|
[
|
|
410
348
|
"delete",
|
|
411
349
|
"/v1/customers/{customer}/discount",
|
|
@@ -443,12 +381,7 @@ describe("pathToVerbNoun with a verbatim id", () => {
|
|
|
443
381
|
"deleteBucketKey",
|
|
444
382
|
],
|
|
445
383
|
["get", "/v1/users/{id}", "get_v1_users_id", "getUser"],
|
|
446
|
-
[
|
|
447
|
-
"delete",
|
|
448
|
-
"/projects/{project_id}/jwks/{jwks_id}",
|
|
449
|
-
"deleteProjectJWKS",
|
|
450
|
-
"deleteProjectJWKS",
|
|
451
|
-
],
|
|
384
|
+
["delete", "/projects/{project_id}/jwks/{jwks_id}", "deleteProjectJWKS", "deleteProjectJWKS"],
|
|
452
385
|
[
|
|
453
386
|
"get",
|
|
454
387
|
"/projects/{project_id}/branches/{branch_id}/data-api/{database_name}",
|
|
@@ -469,9 +402,7 @@ describe("pathToVerbNoun with a verbatim id", () => {
|
|
|
469
402
|
"deleteSecurityFirewallConfig",
|
|
470
403
|
],
|
|
471
404
|
])("%s %s (%s) → %s", (method, path, id, expected) => {
|
|
472
|
-
expect(
|
|
473
|
-
pathToVerbNoun({ method, path }, { nouns: id, verbatim: true }),
|
|
474
|
-
).toBe(expected);
|
|
405
|
+
expect(pathToVerbNoun({ method, path }, { nouns: id, verbatim: true })).toBe(expected);
|
|
475
406
|
});
|
|
476
407
|
});
|
|
477
408
|
|
|
@@ -497,11 +428,7 @@ describe("pathToVerbNoun", () => {
|
|
|
497
428
|
],
|
|
498
429
|
["post", "/applePay/sessions", "createApplePaySession"],
|
|
499
430
|
["post", "/cancels", "createCancel"],
|
|
500
|
-
[
|
|
501
|
-
"get",
|
|
502
|
-
"/v1/benefit-offers/country-summaries",
|
|
503
|
-
"listBenefitOfferCountrySummaries",
|
|
504
|
-
],
|
|
431
|
+
["get", "/v1/benefit-offers/country-summaries", "listBenefitOfferCountrySummaries"],
|
|
505
432
|
["get", "/v1/contractor-invoices/{id}", "getContractorInvoice"],
|
|
506
433
|
["post", "/auth/oauth2/token", "createAuthOauth2Token"],
|
|
507
434
|
["post", "/login", "login"],
|
|
@@ -515,10 +442,7 @@ describe("pathToVerbNoun", () => {
|
|
|
515
442
|
["delete", "/api/notifications", "deleteNotifications"],
|
|
516
443
|
])("%s %s → %s", (method, path, expected) => {
|
|
517
444
|
expect(
|
|
518
|
-
pathToVerbNoun(
|
|
519
|
-
{ method, path },
|
|
520
|
-
{ returnsCollection: expected.startsWith("list") },
|
|
521
|
-
),
|
|
445
|
+
pathToVerbNoun({ method, path }, { returnsCollection: expected.startsWith("list") }),
|
|
522
446
|
).toBe(expected);
|
|
523
447
|
});
|
|
524
448
|
});
|
|
@@ -538,25 +462,10 @@ describe("isVerbatimRouteId", () => {
|
|
|
538
462
|
],
|
|
539
463
|
["activity/get-feeds", "get", "/feeds", true],
|
|
540
464
|
["get_actions", "get", "/actions", true],
|
|
541
|
-
[
|
|
542
|
-
"deleteScheduledJob",
|
|
543
|
-
"delete",
|
|
544
|
-
"/api/jobs/{namespace}/scheduled/{id}",
|
|
545
|
-
false,
|
|
546
|
-
],
|
|
465
|
+
["deleteScheduledJob", "delete", "/api/jobs/{namespace}/scheduled/{id}", false],
|
|
547
466
|
["getCustomerById", "get", "/v2/customers/{customerId}", true],
|
|
548
|
-
[
|
|
549
|
-
|
|
550
|
-
"get",
|
|
551
|
-
"/webhooks/{webhook_id}/{webhook_token}",
|
|
552
|
-
false,
|
|
553
|
-
],
|
|
554
|
-
[
|
|
555
|
-
"getFirewallConfig",
|
|
556
|
-
"get",
|
|
557
|
-
"/v1/security/firewall/config/{configVersion}",
|
|
558
|
-
false,
|
|
559
|
-
],
|
|
467
|
+
["get_webhook_by_token", "get", "/webhooks/{webhook_id}/{webhook_token}", false],
|
|
468
|
+
["getFirewallConfig", "get", "/v1/security/firewall/config/{configVersion}", false],
|
|
560
469
|
])("%s %s %s → %s", (id, method, path, expected) => {
|
|
561
470
|
expect(isVerbatimRouteId(id, { method, path })).toBe(expected);
|
|
562
471
|
});
|