@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,472 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
isMechanicalOperationId,
|
|
4
|
-
isVerbatimRouteId,
|
|
5
|
-
pathToVerbNoun,
|
|
6
|
-
singularize,
|
|
7
|
-
toVerbNoun,
|
|
8
|
-
verbNounSmithyModel,
|
|
9
|
-
} from "./rewrite-operation-ids.ts";
|
|
10
|
-
|
|
11
|
-
const cases: ReadonlyArray<readonly [string, string]> = [
|
|
12
|
-
// go-swagger (Fly Machines)
|
|
13
|
-
["Apps_list", "listApps"],
|
|
14
|
-
["Apps_show", "getApp"],
|
|
15
|
-
["Apps_create", "createApp"],
|
|
16
|
-
["Apps_delete", "deleteApp"],
|
|
17
|
-
["App_Certificates_show", "getAppCertificate"],
|
|
18
|
-
["Machines_list_events", "listMachineEvents"],
|
|
19
|
-
["Machines_delete_metadata", "deleteMachineMetadata"],
|
|
20
|
-
["Postgres_users_create", "createPostgresUser"],
|
|
21
|
-
["Volumes_list", "listVolumes"],
|
|
22
|
-
["Platform_regions_get", "getPlatformRegion"],
|
|
23
|
-
["Secretkeys_set", "setSecretKey"],
|
|
24
|
-
["App_Certificates_acme_create", "createAppAcmeCertificate"],
|
|
25
|
-
["App_Certificates_acme_delete", "deleteAppAcmeCertificate"],
|
|
26
|
-
["App_Certificates_list", "listAppCertificates"],
|
|
27
|
-
// Azure autorest `Resource_action`
|
|
28
|
-
["addsServices_list", "listAddsServices"],
|
|
29
|
-
["addsServices_get", "getAddsService"],
|
|
30
|
-
["ServiceMembers_getMetrics", "getServiceMemberMetrics"],
|
|
31
|
-
["ServiceMembers_listGlobalConfiguration", "listServiceMemberGlobalConfiguration"],
|
|
32
|
-
["VirtualMachines_start", "startVirtualMachine"],
|
|
33
|
-
["OpenIdConnectProvider_get", "getOpenIdConnectProvider"],
|
|
34
|
-
["Report_verify", "verifyReport"],
|
|
35
|
-
["Deployments_whatIf", "deployments_whatIf"],
|
|
36
|
-
["get_apps", "getApps"],
|
|
37
|
-
["list_all_users", "listAllUsers"],
|
|
38
|
-
["Get_Apps_list", "getAppsList"],
|
|
39
|
-
["VirtualMachines_listAll", "listVirtualMachineAll"],
|
|
40
|
-
["VirtualMachines_createOrUpdate", "virtualMachines_createOrUpdate"],
|
|
41
|
-
["VirtualMachines_powerOff", "virtualMachines_powerOff"],
|
|
42
|
-
["ip_address_aggregate_settings_update", "updateIpAddressAggregateSettings"],
|
|
43
|
-
// REST trailing verb
|
|
44
|
-
["ConfigsList", "listConfigs"],
|
|
45
|
-
["ContainerCreate", "createContainer"],
|
|
46
|
-
["PlansGet", "getPlan"],
|
|
47
|
-
["IssueGet", "getIssue"],
|
|
48
|
-
["EnvironmentVersionsGet", "getEnvironmentVersion"],
|
|
49
|
-
["MonitorsList", "listMonitors"],
|
|
50
|
-
["SitesAppConfigurationList", "listSitesAppConfiguration"],
|
|
51
|
-
["ExperimentHoldoutsPartialUpdate", "updateExperimentHoldoutPartial"],
|
|
52
|
-
["SchemaPropertyGroupsList", "listSchemaPropertyGroups"],
|
|
53
|
-
["QueueList", "listQueue"],
|
|
54
|
-
["ImageListTags", "imageListTags"],
|
|
55
|
-
// GraphQL nounVerb
|
|
56
|
-
["projectCreate", "createProject"],
|
|
57
|
-
// Swagger tag-prefixed (Forgejo/Gitea)
|
|
58
|
-
["orgDelete", "deleteOrg"],
|
|
59
|
-
["orgGetAll", "orgGetAll"],
|
|
60
|
-
["issueListIssues", "listIssues"],
|
|
61
|
-
["issueCreateIssue", "createIssue"],
|
|
62
|
-
["repoGetRepo", "getRepo"],
|
|
63
|
-
["issueGetRepoComments", "issueGetRepoComments"],
|
|
64
|
-
["userGetCurrent", "userGetCurrent"],
|
|
65
|
-
["environmentPatchCommit", "environmentPatchCommit"],
|
|
66
|
-
["adminCreateOrg", "adminCreateOrg"],
|
|
67
|
-
["activitypubInstanceActor", "activitypubInstanceActor"],
|
|
68
|
-
["serviceDelete", "deleteService"],
|
|
69
|
-
["projectTokenCreate", "createProjectToken"],
|
|
70
|
-
["volumeInstanceUpdate", "updateVolumeInstance"],
|
|
71
|
-
["accountById", "accountById"],
|
|
72
|
-
["tcpProxies", "tcpProxies"],
|
|
73
|
-
// already verb-first: untouched apart from aliasing
|
|
74
|
-
["GetObject", "getObject"],
|
|
75
|
-
["listSprites", "listSprites"],
|
|
76
|
-
["showContact", "getContact"],
|
|
77
|
-
["index", "list"],
|
|
78
|
-
["RetrieveAccount", "getAccount"],
|
|
79
|
-
["WatchCoreV1PersistentVolumeList", "watchCoreV1PersistentVolumeList"],
|
|
80
|
-
["ReadAppsV1NamespacedReplicaSetStatus", "readAppsV1NamespacedReplicaSetStatus"],
|
|
81
|
-
["ReplaceAppsV1NamespacedStatefulSetScale", "replaceAppsV1NamespacedStatefulSetScale"],
|
|
82
|
-
[
|
|
83
|
-
"ConnectCoreV1DeleteNamespacedPodProxyWithPath",
|
|
84
|
-
"connectCoreV1DeleteNamespacedPodProxyWithPath",
|
|
85
|
-
],
|
|
86
|
-
["DeleteStorageV1CSIDriver", "deleteStorageV1CSIDriver"],
|
|
87
|
-
["GetSchedulingAPIGroup", "getSchedulingAPIGroup"],
|
|
88
|
-
["BulkDeleteMessages", "bulkDeleteMessages"],
|
|
89
|
-
["BulkUpdateGuildRoles", "bulkUpdateGuildRoles"],
|
|
90
|
-
["AddStatusCheckContexts", "addStatusCheckContexts"],
|
|
91
|
-
["UploadReleaseAsset", "uploadReleaseAsset"],
|
|
92
|
-
["PostRadarValueListItems", "postRadarValueListItems"],
|
|
93
|
-
["PostSetupIntentsIntentVerifyMicrodeposits", "postSetupIntentsIntentVerifyMicrodeposits"],
|
|
94
|
-
["InsertCalendarList", "insertCalendarList"],
|
|
95
|
-
["FetchThreatListUpdates", "fetchThreatListUpdates"],
|
|
96
|
-
["StreamGenerateContent", "streamGenerateContent"],
|
|
97
|
-
["QueryCreate", "createQuery"],
|
|
98
|
-
["ReleaseGet", "getRelease"],
|
|
99
|
-
["RequestGet", "getRequest"],
|
|
100
|
-
["SetGet", "getSet"],
|
|
101
|
-
["CheckGet", "getCheck"],
|
|
102
|
-
["CheckRunsList", "listCheckRuns"],
|
|
103
|
-
["QueryRun", "queryRun"],
|
|
104
|
-
["ReportVerify", "verifyReport"],
|
|
105
|
-
["ReportList", "listReport"],
|
|
106
|
-
// compounds and non-verb ids: untouched
|
|
107
|
-
["AppGetOrCreate", "appGetOrCreate"],
|
|
108
|
-
["AddOrUpdateMembershipForUserInOrg", "addOrUpdateMembershipForUserInOrg"],
|
|
109
|
-
["DnsRecordsBatch", "dnsRecordsBatch"],
|
|
110
|
-
["DnsTimeseriesGroupsResponseCode", "dnsTimeseriesGroupsResponseCode"],
|
|
111
|
-
["Root", "root"],
|
|
112
|
-
["V1GetProjectFunctionCombinedStats", "v1GetProjectFunctionCombinedStats"],
|
|
113
|
-
["PullRequestStacksAdd", "addPullRequestStack"],
|
|
114
|
-
["TeamsControllerCreateTeam", "teamsControllerCreateTeam"],
|
|
115
|
-
// singularisation
|
|
116
|
-
["AddressesGet", "getAddress"],
|
|
117
|
-
["AliasesList", "listAliases"],
|
|
118
|
-
["AliasGet", "getAlias"],
|
|
119
|
-
["AnalyticsGet", "getAnalytics"],
|
|
120
|
-
["TimeseriesGet", "getTimeseries"],
|
|
121
|
-
["SeriesGet", "getSeries"],
|
|
122
|
-
["SettingsUpdate", "updateSettings"],
|
|
123
|
-
["CredentialsGet", "getCredentials"],
|
|
124
|
-
["MetricsGet", "getMetrics"],
|
|
125
|
-
["StatusesGet", "getStatus"],
|
|
126
|
-
["CanvasGet", "getCanvas"],
|
|
127
|
-
["LensGet", "getLens"],
|
|
128
|
-
["CategoriesGet", "getCategory"],
|
|
129
|
-
["DatabasesGet", "getDatabase"],
|
|
130
|
-
["ResponsesGet", "getResponse"],
|
|
131
|
-
["IndexesList", "listIndexes"],
|
|
132
|
-
// `index` is the Rails verb only on its own or as a whole `_` segment;
|
|
133
|
-
// joined into a camel id it names the index entity.
|
|
134
|
-
["Apps_index", "listApps"],
|
|
135
|
-
["InfoIndex", "infoIndex"],
|
|
136
|
-
["QueryIndex", "queryIndex"],
|
|
137
|
-
["IndexCreate", "createIndex"],
|
|
138
|
-
["IndexDocument", "indexDocument"],
|
|
139
|
-
["GetIndexInfo", "getIndexInfo"],
|
|
140
|
-
["MetadataIndexList", "listMetadataIndex"],
|
|
141
|
-
["ProxiesList", "listProxies"],
|
|
142
|
-
["ProcessesGet", "getProcess"],
|
|
143
|
-
["Ec2AddressesGet", "getEc2Address"],
|
|
144
|
-
["IPsList", "listIPs"],
|
|
145
|
-
["IPsGet", "getIP"],
|
|
146
|
-
];
|
|
147
|
-
|
|
148
|
-
describe("toVerbNoun", () => {
|
|
149
|
-
for (const [input, expected] of cases) {
|
|
150
|
-
test(`${input} → ${expected}`, () => {
|
|
151
|
-
expect(toVerbNoun(input)).toBe(expected);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
describe("singularize", () => {
|
|
157
|
-
test.each([
|
|
158
|
-
["Apps", "App"],
|
|
159
|
-
["Machines", "Machine"],
|
|
160
|
-
["Addresses", "Address"],
|
|
161
|
-
["Aliases", "Alias"],
|
|
162
|
-
["Analytics", "Analytics"],
|
|
163
|
-
["Series", "Series"],
|
|
164
|
-
["Status", "Status"],
|
|
165
|
-
["Statuses", "Status"],
|
|
166
|
-
["Canvas", "Canvas"],
|
|
167
|
-
["Categories", "Category"],
|
|
168
|
-
["Boxes", "Box"],
|
|
169
|
-
["Branches", "Branch"],
|
|
170
|
-
["Releases", "Release"],
|
|
171
|
-
["Databases", "Database"],
|
|
172
|
-
["Postgres", "Postgres"],
|
|
173
|
-
["Kubernetes", "Kubernetes"],
|
|
174
|
-
["DNS", "DNS"],
|
|
175
|
-
["IPs", "IP"],
|
|
176
|
-
["Data", "Data"],
|
|
177
|
-
["Ips", "Ips"],
|
|
178
|
-
["Keys", "Key"],
|
|
179
|
-
["Days", "Day"],
|
|
180
|
-
["Toys", "Toy"],
|
|
181
|
-
])("%s → %s", (input, expected) => {
|
|
182
|
-
expect(singularize(input)).toBe(expected);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe("verbNounSmithyModel", () => {
|
|
187
|
-
test("renames operations, companions, and every reference", () => {
|
|
188
|
-
const model = {
|
|
189
|
-
shapes: {
|
|
190
|
-
"ns#Svc": {
|
|
191
|
-
type: "service",
|
|
192
|
-
operations: [{ target: "ns#AppsList" }, { target: "ns#AppsGet" }],
|
|
193
|
-
},
|
|
194
|
-
"ns#AppsList": {
|
|
195
|
-
type: "operation",
|
|
196
|
-
input: { target: "ns#AppsListRequest" },
|
|
197
|
-
output: { target: "ns#AppsListResponse" },
|
|
198
|
-
},
|
|
199
|
-
"ns#AppsListRequest": { type: "structure", members: {} },
|
|
200
|
-
"ns#AppsListResponse": {
|
|
201
|
-
type: "structure",
|
|
202
|
-
members: { items: { target: "ns#AppsListResponseItemsList" } },
|
|
203
|
-
},
|
|
204
|
-
"ns#AppsListResponseItemsList": {
|
|
205
|
-
type: "list",
|
|
206
|
-
member: { target: "smithy.api#String" },
|
|
207
|
-
},
|
|
208
|
-
"ns#AppsGet": {
|
|
209
|
-
type: "operation",
|
|
210
|
-
input: { target: "ns#AppsGetRequest" },
|
|
211
|
-
output: { target: "smithy.api#Unit" },
|
|
212
|
-
},
|
|
213
|
-
"ns#AppsGetRequest": { type: "structure", members: {} },
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
const r = verbNounSmithyModel(model);
|
|
217
|
-
expect(r.renamed).toBe(2);
|
|
218
|
-
expect(r.collisions).toEqual([]);
|
|
219
|
-
expect(Object.keys(model.shapes).sort()).toEqual(
|
|
220
|
-
[
|
|
221
|
-
"ns#Svc",
|
|
222
|
-
"ns#ListApps",
|
|
223
|
-
"ns#ListAppsRequest",
|
|
224
|
-
"ns#ListAppsResponse",
|
|
225
|
-
"ns#ListAppsResponseItemsList",
|
|
226
|
-
"ns#GetApp",
|
|
227
|
-
"ns#GetAppRequest",
|
|
228
|
-
].sort(),
|
|
229
|
-
);
|
|
230
|
-
const shapes = model.shapes as Record<string, any>;
|
|
231
|
-
expect(shapes["ns#Svc"].operations).toEqual([
|
|
232
|
-
{ target: "ns#ListApps" },
|
|
233
|
-
{ target: "ns#GetApp" },
|
|
234
|
-
]);
|
|
235
|
-
expect(shapes["ns#ListApps"].output.target).toBe("ns#ListAppsResponse");
|
|
236
|
-
expect(shapes["ns#ListAppsResponse"].members.items.target).toBe("ns#ListAppsResponseItemsList");
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
test("is idempotent", () => {
|
|
240
|
-
const model = {
|
|
241
|
-
shapes: {
|
|
242
|
-
"ns#AppsList": {
|
|
243
|
-
type: "operation",
|
|
244
|
-
input: { target: "ns#AppsListRequest" },
|
|
245
|
-
output: { target: "smithy.api#Unit" },
|
|
246
|
-
},
|
|
247
|
-
"ns#AppsListRequest": { type: "structure", members: {} },
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
verbNounSmithyModel(model);
|
|
251
|
-
const once = JSON.stringify(model);
|
|
252
|
-
const second = verbNounSmithyModel(model);
|
|
253
|
-
expect(second.renamed).toBe(0);
|
|
254
|
-
expect(JSON.stringify(model)).toBe(once);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("reports collisions and keeps the original", () => {
|
|
258
|
-
const model = {
|
|
259
|
-
shapes: {
|
|
260
|
-
"ns#ListApps": { type: "operation" },
|
|
261
|
-
"ns#AppsList": { type: "operation" },
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
const r = verbNounSmithyModel(model);
|
|
265
|
-
expect(r.renamed).toBe(0);
|
|
266
|
-
expect(r.collisions).toEqual(["AppsList → ListApps"]);
|
|
267
|
-
expect(Object.keys(model.shapes).sort()).toEqual(["ns#AppsList", "ns#ListApps"]);
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
describe("isMechanicalOperationId", () => {
|
|
272
|
-
test.each([
|
|
273
|
-
[undefined, "get", "/users", true],
|
|
274
|
-
["get-api-card", "get", "/api/card", true],
|
|
275
|
-
["post_v1_users_id", "post", "/v1/users/{id}", true],
|
|
276
|
-
["getApiV1AnnotationLayer", "get", "/api/v1/annotation_layer", true],
|
|
277
|
-
["get-database-by-uuid", "get", "/databases/{uuid}", true],
|
|
278
|
-
["getEvents", "get", "/events", true],
|
|
279
|
-
["getMauUsage", "get", "/api/v2/usage/mau", false],
|
|
280
|
-
["getExperimentSnapshot", "get", "/v1/snapshots/{id}", false],
|
|
281
|
-
["deleteBranches", "post", "/api/v2/code-refs/repositories/{repo}/branch-delete-tasks", false],
|
|
282
|
-
["post-applePay-sessions", "post", "/applePay/sessions", true],
|
|
283
|
-
["Apps_list", "get", "/apps", false],
|
|
284
|
-
["listUsers", "get", "/users", false],
|
|
285
|
-
["delete-artifact", "delete", "/repos/{owner}/{repo}/actions/artifacts/{artifact_id}", false],
|
|
286
|
-
["get_pricing", "get", "/pricing", true],
|
|
287
|
-
["get_actions", "get", "/actions", true],
|
|
288
|
-
["deletePolicy", "delete", "/v2/policies/{policyId}", true],
|
|
289
|
-
["getCustomerById", "get", "/v2/customers/{customerId}", true],
|
|
290
|
-
["getBalanceByAsset", "get", "/accounts/{account_id}/balances/{asset}", false],
|
|
291
|
-
])("%s %s %s → %s", (id, method, path, expected) => {
|
|
292
|
-
expect(isMechanicalOperationId(id, { method, path })).toBe(expected);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe("pathToVerbNoun with a mechanical id", () => {
|
|
297
|
-
test.each([
|
|
298
|
-
["get", "/feeds", "activity/get-feeds", false, "getFeeds"],
|
|
299
|
-
["get", "/actions", "get_actions", undefined, "getActions"],
|
|
300
|
-
["get", "/pricing", "get_pricing", false, "getPricing"],
|
|
301
|
-
[
|
|
302
|
-
"get",
|
|
303
|
-
"/load_balancers/{id}/metrics",
|
|
304
|
-
"get_load_balancer_metrics",
|
|
305
|
-
false,
|
|
306
|
-
"getLoadBalancerMetrics",
|
|
307
|
-
],
|
|
308
|
-
["delete", "/v2/policies/{policyId}", "deletePolicy", undefined, "deletePolicy"],
|
|
309
|
-
["get", "/v2/customers/{customerId}", "getCustomerById", undefined, "getCustomer"],
|
|
310
|
-
["post", "/api/action", "post-api-action", undefined, "createAction"],
|
|
311
|
-
[
|
|
312
|
-
"get",
|
|
313
|
-
"/orgs/{org}/rulesets/{ruleset_id}",
|
|
314
|
-
"repos/get-org-ruleset",
|
|
315
|
-
undefined,
|
|
316
|
-
"getOrgRuleset",
|
|
317
|
-
],
|
|
318
|
-
["get", "/orgs/{org}/rulesets", "repos/get-org-rulesets", true, "listOrgRulesets"],
|
|
319
|
-
[
|
|
320
|
-
"delete",
|
|
321
|
-
"/api/jobs/{namespace}/scheduled/{id}",
|
|
322
|
-
"deleteScheduledJob",
|
|
323
|
-
undefined,
|
|
324
|
-
"deleteScheduledJob",
|
|
325
|
-
],
|
|
326
|
-
[
|
|
327
|
-
"get",
|
|
328
|
-
"/v2/payments/{session_id}/authorizations/{authorization_id}",
|
|
329
|
-
"getPaymentSessionAuthorization",
|
|
330
|
-
undefined,
|
|
331
|
-
"getPaymentSessionAuthorization",
|
|
332
|
-
],
|
|
333
|
-
])("%s %s (%s) → %s", (method, path, id, coll, expected) => {
|
|
334
|
-
expect(pathToVerbNoun({ method, path }, { returnsCollection: coll, nouns: id })).toBe(expected);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
describe("pathToVerbNoun with a verbatim id", () => {
|
|
339
|
-
test.each([
|
|
340
|
-
["post", "/v1/apps/{appId}/promote", "postV1AppsByAppIdPromote", "createAppPromote"],
|
|
341
|
-
["get", "/v1/apps", "getV1Apps", "getApps"],
|
|
342
|
-
["get", "/v1/apps/{appId}", "getV1AppsByAppId", "getApp"],
|
|
343
|
-
["post", "/v1/accounts/{account}", "PostAccountsAccount", "updateAccount"],
|
|
344
|
-
["post", "/v1/accounts", "PostAccounts", "createAccount"],
|
|
345
|
-
["get", "/v1/accounts/{account}", "GetAccountsAccount", "getAccount"],
|
|
346
|
-
["delete", "/v1/accounts/{account}", "DeleteAccountsAccount", "deleteAccount"],
|
|
347
|
-
[
|
|
348
|
-
"delete",
|
|
349
|
-
"/v1/customers/{customer}/discount",
|
|
350
|
-
"DeleteCustomersCustomerDiscount",
|
|
351
|
-
"deleteCustomerDiscount",
|
|
352
|
-
],
|
|
353
|
-
[
|
|
354
|
-
"get",
|
|
355
|
-
"/v1/customers/{customer}/balance_transactions/{transaction}",
|
|
356
|
-
"GetCustomersCustomerBalanceTransactionsTransaction",
|
|
357
|
-
"getCustomerBalanceTransaction",
|
|
358
|
-
],
|
|
359
|
-
[
|
|
360
|
-
"delete",
|
|
361
|
-
"/organizations/{organization}/teams/{team}",
|
|
362
|
-
"delete_organization_team",
|
|
363
|
-
"deleteOrganizationTeam",
|
|
364
|
-
],
|
|
365
|
-
[
|
|
366
|
-
"get",
|
|
367
|
-
"/organizations/{organization}/teams/{team}/members/{id}",
|
|
368
|
-
"get_organization_team_member",
|
|
369
|
-
"getOrganizationTeamMember",
|
|
370
|
-
],
|
|
371
|
-
[
|
|
372
|
-
"delete",
|
|
373
|
-
"/projects/{project_id}/branches/{branch_id}/custom-domains/{domain}",
|
|
374
|
-
"deleteProjectBranchCustomDomain",
|
|
375
|
-
"deleteProjectBranchCustomDomain",
|
|
376
|
-
],
|
|
377
|
-
[
|
|
378
|
-
"delete",
|
|
379
|
-
"/v1/buckets/{bucketId}/keys/{keyId}",
|
|
380
|
-
"deleteV1BucketsByBucketIdKeysByKeyId",
|
|
381
|
-
"deleteBucketKey",
|
|
382
|
-
],
|
|
383
|
-
["get", "/v1/users/{id}", "get_v1_users_id", "getUser"],
|
|
384
|
-
["delete", "/projects/{project_id}/jwks/{jwks_id}", "deleteProjectJWKS", "deleteProjectJWKS"],
|
|
385
|
-
[
|
|
386
|
-
"get",
|
|
387
|
-
"/projects/{project_id}/branches/{branch_id}/data-api/{database_name}",
|
|
388
|
-
"getProjectBranchDataAPI",
|
|
389
|
-
"getProjectBranchDataAPI",
|
|
390
|
-
],
|
|
391
|
-
["get", "/v2/customers/{customerId}", "getCustomerById", "getCustomer"],
|
|
392
|
-
[
|
|
393
|
-
"get",
|
|
394
|
-
"/{teamSlug}/{projectSlug}/{repositoryName}/blobs/{digest}",
|
|
395
|
-
"getByTeamSlugByProjectSlugByRepositoryNameBlobsByDigest",
|
|
396
|
-
"getBlob",
|
|
397
|
-
],
|
|
398
|
-
[
|
|
399
|
-
"delete",
|
|
400
|
-
"/v1/security/firewall/config/{configVersion}",
|
|
401
|
-
"deleteSecurityFirewallConfigByConfigVersion",
|
|
402
|
-
"deleteSecurityFirewallConfig",
|
|
403
|
-
],
|
|
404
|
-
])("%s %s (%s) → %s", (method, path, id, expected) => {
|
|
405
|
-
expect(pathToVerbNoun({ method, path }, { nouns: id, verbatim: true })).toBe(expected);
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
describe("pathToVerbNoun", () => {
|
|
410
|
-
test.each([
|
|
411
|
-
["get", "/users", "listUsers"],
|
|
412
|
-
["get", "/users/{id}", "getUser"],
|
|
413
|
-
["post", "/users", "createUser"],
|
|
414
|
-
["put", "/users/{id}", "putUser"],
|
|
415
|
-
["post", "/users/{id}", "updateUser"],
|
|
416
|
-
["patch", "/users/{id}", "updateUser"],
|
|
417
|
-
["delete", "/users/{id}", "deleteUser"],
|
|
418
|
-
["post", "/users/{id}/reset", "resetUser"],
|
|
419
|
-
["post", "/emails/{email_id}/cancel", "cancelEmail"],
|
|
420
|
-
["post", "/api/papers/index", "createPaperIndex"],
|
|
421
|
-
["get", "/orgs/{org}/repos", "listOrgRepos"],
|
|
422
|
-
["get", "/api/v1/annotation_layer", "listAnnotationLayer"],
|
|
423
|
-
["get", "/api/card", "listCard"],
|
|
424
|
-
[
|
|
425
|
-
"get",
|
|
426
|
-
"/api/public/dashboard/{uuid}/dashcard/{dashcard-id}/card/{card-id}",
|
|
427
|
-
"getDashboardDashcardCard",
|
|
428
|
-
],
|
|
429
|
-
["post", "/applePay/sessions", "createApplePaySession"],
|
|
430
|
-
["post", "/cancels", "createCancel"],
|
|
431
|
-
["get", "/v1/benefit-offers/country-summaries", "listBenefitOfferCountrySummaries"],
|
|
432
|
-
["get", "/v1/contractor-invoices/{id}", "getContractorInvoice"],
|
|
433
|
-
["post", "/auth/oauth2/token", "createAuthOauth2Token"],
|
|
434
|
-
["post", "/login", "login"],
|
|
435
|
-
["get", "/", "getRoot"],
|
|
436
|
-
["get", "/api/v2/usage/mau", "listUsageMau"],
|
|
437
|
-
["post", "/api/ee/action-v2/execute-bulk", "executeEeActionV2Bulk"],
|
|
438
|
-
["get", "/api/collections/{namespace}/{slug}-{id}", "getCollection"],
|
|
439
|
-
["get", "/zen", "getZen"],
|
|
440
|
-
["get", "/feeds", "getFeeds"],
|
|
441
|
-
["get", "/guilds/{guild_id}/webhooks", "getGuildWebhooks"],
|
|
442
|
-
["delete", "/api/notifications", "deleteNotifications"],
|
|
443
|
-
])("%s %s → %s", (method, path, expected) => {
|
|
444
|
-
expect(
|
|
445
|
-
pathToVerbNoun({ method, path }, { returnsCollection: expected.startsWith("list") }),
|
|
446
|
-
).toBe(expected);
|
|
447
|
-
});
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
describe("isVerbatimRouteId", () => {
|
|
451
|
-
test.each([
|
|
452
|
-
[undefined, "get", "/apps", true],
|
|
453
|
-
["postV1AppsByAppIdPromote", "post", "/v1/apps/{appId}/promote", true],
|
|
454
|
-
["getV1Apps", "get", "/v1/apps", true],
|
|
455
|
-
["get_v1_users_id", "get", "/v1/users/{id}", true],
|
|
456
|
-
["get-api-card", "get", "/api/card", true],
|
|
457
|
-
[
|
|
458
|
-
"getByTeamSlugByProjectSlugByRepositoryNameBlobsByDigest",
|
|
459
|
-
"get",
|
|
460
|
-
"/{teamSlug}/{projectSlug}/{repositoryName}/blobs/{digest}",
|
|
461
|
-
true,
|
|
462
|
-
],
|
|
463
|
-
["activity/get-feeds", "get", "/feeds", true],
|
|
464
|
-
["get_actions", "get", "/actions", true],
|
|
465
|
-
["deleteScheduledJob", "delete", "/api/jobs/{namespace}/scheduled/{id}", false],
|
|
466
|
-
["getCustomerById", "get", "/v2/customers/{customerId}", true],
|
|
467
|
-
["get_webhook_by_token", "get", "/webhooks/{webhook_id}/{webhook_token}", false],
|
|
468
|
-
["getFirewallConfig", "get", "/v1/security/firewall/config/{configVersion}", false],
|
|
469
|
-
])("%s %s %s → %s", (id, method, path, expected) => {
|
|
470
|
-
expect(isVerbatimRouteId(id, { method, path })).toBe(expected);
|
|
471
|
-
});
|
|
472
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { generateService } from "./generator.ts";
|
|
3
|
-
|
|
4
|
-
const model = {
|
|
5
|
-
smithy: "2.0",
|
|
6
|
-
shapes: {
|
|
7
|
-
"com.example#Service": {
|
|
8
|
-
type: "service",
|
|
9
|
-
version: "1",
|
|
10
|
-
operations: [{ target: "com.example#GetValue" }],
|
|
11
|
-
},
|
|
12
|
-
"com.example#GetValue": {
|
|
13
|
-
type: "operation",
|
|
14
|
-
input: { target: "com.example#Input" },
|
|
15
|
-
output: { target: "com.example#Output" },
|
|
16
|
-
traits: {
|
|
17
|
-
"smithy.api#http": { method: "GET", uri: "/value", code: 200 },
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
"com.example#Input": { type: "structure", members: {} },
|
|
21
|
-
"com.example#Output": {
|
|
22
|
-
type: "structure",
|
|
23
|
-
members: { value: { target: "com.example#Choice" } },
|
|
24
|
-
},
|
|
25
|
-
"com.example#Choice": {
|
|
26
|
-
type: "union",
|
|
27
|
-
members: {
|
|
28
|
-
boolean: { target: "smithy.api#Boolean" },
|
|
29
|
-
paths: { target: "com.example#Paths" },
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
"com.example#Paths": {
|
|
33
|
-
type: "list",
|
|
34
|
-
member: { target: "smithy.api#String" },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const operationDecl = {
|
|
40
|
-
contextType: "ExampleOpContext",
|
|
41
|
-
commonErrorType: "ExampleOpError",
|
|
42
|
-
commonErrorClasses: [],
|
|
43
|
-
protocol: "ExampleProtocol",
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
test("untagged unions validate primitive and collection alternatives", () => {
|
|
47
|
-
const { code } = generateService(model, {
|
|
48
|
-
unionStyle: "untagged",
|
|
49
|
-
operationDecl,
|
|
50
|
-
});
|
|
51
|
-
expect(code).toContain("export type Choice = boolean | Paths;");
|
|
52
|
-
expect(code).toContain("S.Union([S.Boolean, Paths])");
|
|
53
|
-
expect(code).not.toContain("S.Unknown as any as S.Schema<Choice>");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test("untagged unions honor the configured schema type", () => {
|
|
57
|
-
for (const schemaType of ["Schema", "Codec"] as const) {
|
|
58
|
-
const { code } = generateService(model, {
|
|
59
|
-
unionStyle: "untagged",
|
|
60
|
-
schemaType,
|
|
61
|
-
operationDecl,
|
|
62
|
-
});
|
|
63
|
-
expect(code).toContain(`S.Union([S.Boolean, Paths]) as any as S.${schemaType}<Choice>`);
|
|
64
|
-
expect(code).toContain(`S.Array(S.String) as any as S.${schemaType}<Paths>`);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("omitting a retry policy emits neither a retry import nor an operation setting", () => {
|
|
69
|
-
const { code } = generateService(model, {
|
|
70
|
-
unionStyle: "untagged",
|
|
71
|
-
operationDecl,
|
|
72
|
-
});
|
|
73
|
-
expect(code).not.toContain("../retry.ts");
|
|
74
|
-
expect(code).not.toContain("retry:");
|
|
75
|
-
expect(code).not.toContain('import { } from "../errors.ts"');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("an explicit retry policy retains the existing import and operation setting", () => {
|
|
79
|
-
const { code } = generateService(model, {
|
|
80
|
-
unionStyle: "untagged",
|
|
81
|
-
operationDecl: { ...operationDecl, retry: "Retry.Retry" },
|
|
82
|
-
});
|
|
83
|
-
expect(code).toContain('import * as Retry from "../retry.ts"');
|
|
84
|
-
expect(code).toContain("retry: Retry.Retry");
|
|
85
|
-
});
|