@distilled.cloud/core 0.30.3 → 1.0.0-rc.2

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.
Files changed (132) hide show
  1. package/lib/api.d.ts +165 -0
  2. package/lib/api.d.ts.map +1 -0
  3. package/lib/api.js +178 -0
  4. package/lib/api.js.map +1 -0
  5. package/lib/codegen/cli.d.ts +29 -0
  6. package/lib/codegen/cli.d.ts.map +1 -0
  7. package/lib/codegen/cli.js +165 -0
  8. package/lib/codegen/cli.js.map +1 -0
  9. package/lib/codegen/emit.d.ts +129 -0
  10. package/lib/codegen/emit.d.ts.map +1 -0
  11. package/lib/codegen/emit.js +105 -0
  12. package/lib/codegen/emit.js.map +1 -0
  13. package/lib/codegen/format.d.ts +23 -0
  14. package/lib/codegen/format.d.ts.map +1 -0
  15. package/lib/codegen/format.js +28 -0
  16. package/lib/codegen/format.js.map +1 -0
  17. package/lib/codegen/generator.d.ts +334 -0
  18. package/lib/codegen/generator.d.ts.map +1 -0
  19. package/lib/codegen/generator.js +691 -0
  20. package/lib/codegen/generator.js.map +1 -0
  21. package/lib/codegen/graph.d.ts +36 -0
  22. package/lib/codegen/graph.d.ts.map +1 -0
  23. package/lib/codegen/graph.js +136 -0
  24. package/lib/codegen/graph.js.map +1 -0
  25. package/lib/codegen/members.d.ts +25 -0
  26. package/lib/codegen/members.d.ts.map +1 -0
  27. package/lib/codegen/members.js +55 -0
  28. package/lib/codegen/members.js.map +1 -0
  29. package/lib/codegen/naming.d.ts +29 -0
  30. package/lib/codegen/naming.d.ts.map +1 -0
  31. package/lib/codegen/naming.js +74 -0
  32. package/lib/codegen/naming.js.map +1 -0
  33. package/lib/codegen/openapi-cli.d.ts +38 -0
  34. package/lib/codegen/openapi-cli.d.ts.map +1 -0
  35. package/lib/codegen/openapi-cli.js +107 -0
  36. package/lib/codegen/openapi-cli.js.map +1 -0
  37. package/lib/codegen/openapi.d.ts +115 -0
  38. package/lib/codegen/openapi.d.ts.map +1 -0
  39. package/lib/codegen/openapi.js +1220 -0
  40. package/lib/codegen/openapi.js.map +1 -0
  41. package/lib/codegen/operations.d.ts +24 -0
  42. package/lib/codegen/operations.d.ts.map +1 -0
  43. package/lib/codegen/operations.js +56 -0
  44. package/lib/codegen/operations.js.map +1 -0
  45. package/lib/codegen/pagination.d.ts +39 -0
  46. package/lib/codegen/pagination.d.ts.map +1 -0
  47. package/lib/codegen/pagination.js +33 -0
  48. package/lib/codegen/pagination.js.map +1 -0
  49. package/lib/codegen/prelude.d.ts +15 -0
  50. package/lib/codegen/prelude.d.ts.map +1 -0
  51. package/lib/codegen/prelude.js +60 -0
  52. package/lib/codegen/prelude.js.map +1 -0
  53. package/lib/error-category.d.ts +28 -0
  54. package/lib/error-category.d.ts.map +1 -0
  55. package/lib/error-category.js +46 -0
  56. package/lib/error-category.js.map +1 -0
  57. package/lib/errors.d.ts +1 -0
  58. package/lib/errors.d.ts.map +1 -1
  59. package/lib/errors.js +1 -0
  60. package/lib/errors.js.map +1 -1
  61. package/lib/json-patch.d.ts +25 -32
  62. package/lib/json-patch.d.ts.map +1 -1
  63. package/lib/json-patch.js +23 -95
  64. package/lib/json-patch.js.map +1 -1
  65. package/lib/pagination.d.ts +37 -51
  66. package/lib/pagination.d.ts.map +1 -1
  67. package/lib/pagination.js +72 -90
  68. package/lib/pagination.js.map +1 -1
  69. package/lib/protocol-http.d.ts +74 -0
  70. package/lib/protocol-http.d.ts.map +1 -0
  71. package/lib/protocol-http.js +554 -0
  72. package/lib/protocol-http.js.map +1 -0
  73. package/lib/protocol-rest.d.ts +124 -0
  74. package/lib/protocol-rest.d.ts.map +1 -0
  75. package/lib/protocol-rest.js +242 -0
  76. package/lib/protocol-rest.js.map +1 -0
  77. package/lib/retry.d.ts +8 -2
  78. package/lib/retry.d.ts.map +1 -1
  79. package/lib/retry.js +21 -15
  80. package/lib/retry.js.map +1 -1
  81. package/lib/schema.d.ts +7 -8
  82. package/lib/schema.d.ts.map +1 -1
  83. package/lib/schema.js +7 -8
  84. package/lib/schema.js.map +1 -1
  85. package/lib/trait.d.ts +150 -0
  86. package/lib/trait.d.ts.map +1 -0
  87. package/lib/trait.js +107 -0
  88. package/lib/trait.js.map +1 -0
  89. package/package.json +18 -75
  90. package/src/api.ts +446 -0
  91. package/src/codegen/cli.ts +268 -0
  92. package/src/codegen/emit.ts +207 -0
  93. package/src/codegen/format.ts +47 -0
  94. package/src/codegen/generator.ts +1153 -0
  95. package/src/codegen/graph.ts +151 -0
  96. package/src/codegen/members.ts +71 -0
  97. package/src/codegen/naming.ts +86 -0
  98. package/src/codegen/openapi-cli.ts +166 -0
  99. package/src/codegen/openapi.ts +1450 -0
  100. package/src/codegen/operations.ts +76 -0
  101. package/src/codegen/pagination.ts +71 -0
  102. package/src/codegen/prelude.ts +70 -0
  103. package/src/error-category.ts +84 -0
  104. package/src/errors.ts +2 -0
  105. package/src/json-patch.ts +26 -110
  106. package/src/pagination.ts +86 -142
  107. package/src/protocol-http.ts +699 -0
  108. package/src/protocol-rest.ts +367 -0
  109. package/src/retry.ts +20 -21
  110. package/src/schema.ts +7 -8
  111. package/src/trait.ts +238 -0
  112. package/README.md +0 -30
  113. package/lib/client.d.ts +0 -167
  114. package/lib/client.d.ts.map +0 -1
  115. package/lib/client.js +0 -659
  116. package/lib/client.js.map +0 -1
  117. package/lib/schemas.d.ts +0 -60
  118. package/lib/schemas.d.ts.map +0 -1
  119. package/lib/schemas.js +0 -79
  120. package/lib/schemas.js.map +0 -1
  121. package/lib/sensitive.d.ts +0 -71
  122. package/lib/sensitive.d.ts.map +0 -1
  123. package/lib/sensitive.js +0 -96
  124. package/lib/sensitive.js.map +0 -1
  125. package/lib/traits.d.ts +0 -421
  126. package/lib/traits.d.ts.map +0 -1
  127. package/lib/traits.js +0 -737
  128. package/lib/traits.js.map +0 -1
  129. package/src/client.ts +0 -1177
  130. package/src/schemas.ts +0 -128
  131. package/src/sensitive.ts +0 -119
  132. package/src/traits.ts +0 -996
@@ -0,0 +1,115 @@
1
+ /**
2
+ * OpenAPI → Smithy 2.0 JSON converter (dev-time only, provider-agnostic).
3
+ *
4
+ * Turns a Swagger 2.0 / OAS 3.0 / OAS 3.1 document into the same Smithy JSON
5
+ * model shape the other spec converters produce (`{ smithy: "2.0", metadata,
6
+ * shapes }`), so every OpenAPI-sourced provider flows through the one shared
7
+ * `generateService` compiler. Conversion fidelity follows distilled v0's
8
+ * `generate-openapi.ts` feature matrix:
9
+ *
10
+ * • one operation per (path × get/post/put/patch/delete), deprecated
11
+ * skipped by default; op shape name = PascalCase(operationId)
12
+ * • input `<Op>Request`: path params → `smithy.api#httpLabel` (+required),
13
+ * query params → `smithy.api#httpQuery`, header/cookie params dropped,
14
+ * body properties flattened alongside (labels win, then query, then body);
15
+ * non-object bodies become a sole `body` member with `smithy.api#httpPayload`
16
+ * • `$ref`s become NAMED shapes (`components/schemas/X` → `<ns>#X`), reused
17
+ * across operations; anonymous nested objects synthesize names from the
18
+ * parent + member path
19
+ * • responses: 200 → 201 → 204 precedence, `application/json` only; object
20
+ * results become `<Op>Response` structures (a sole `$ref` reuses the named
21
+ * shape); bare array/scalar results wrap in a structure whose single
22
+ * member carries `com.distilled.openapi#rawResponse` (the SdkSpec maps it
23
+ * to a root pipe); no schema → `smithy.api#Unit`
24
+ * • nullability (3.0 `nullable`, 3.1 `type: [..., "null"]`, 2.0
25
+ * `x-nullable`, `oneOf`/`anyOf` null branches) → member-level
26
+ * `com.distilled.openapi#nullable` trait
27
+ * • sensitive string members (x-sensitive or name-pattern match) →
28
+ * `smithy.api#sensitive` on the member (direction-agnostic; the SdkSpec
29
+ * decides the input/output treatment)
30
+ * • per-op non-2xx statuses (outside `defaultErrorStatuses`) → typed error
31
+ * shapes with `smithy.api#error`/`smithy.api#httpError` and
32
+ * `com.distilled.openapi#errorMatchers` status matchers
33
+ * • v0 pagination detection (`pagination.cursor` / `.next` / `.next_page`,
34
+ * `next_token`/`NextToken`/`nextToken`, `next_page` + input alias lists +
35
+ * first top-level array property) → `smithy.api#paginated` on the op
36
+ * (with the non-standard `mode` member the core runtime dispatches on)
37
+ */
38
+ /** Member-level nullability (`S.NullOr` + `| null` via `SdkSpec.nullableTrait`). */
39
+ export declare const NULLABLE_TRAIT = "com.distilled.openapi#nullable";
40
+ /**
41
+ * Marks the sole member of a synthesized response wrapper for bare
42
+ * array/scalar response bodies. SdkSpecs bind it with a `rootPipe`
43
+ * (`T.RawResponseRoot()` from `core/protocol-rest`), so the emitted response
44
+ * type IS the payload type.
45
+ */
46
+ export declare const RAW_RESPONSE_TRAIT = "com.distilled.openapi#rawResponse";
47
+ /**
48
+ * Wire-matching rules for a generated error class (see
49
+ * `SdkSpec.errorMatchersTrait` + `applyErrorMatchers`). The converter stamps
50
+ * `[{ status }]` from the response status the class was mapped from.
51
+ */
52
+ export declare const ERROR_MATCHERS_TRAIT = "com.distilled.openapi#errorMatchers";
53
+ /**
54
+ * Non-JSON request body encoding chosen by the v0 content-type precedence
55
+ * (json > form-urlencoded > multipart). Value: `"form-urlencoded"` |
56
+ * `"multipart"`. `"multipart"` is also merged into the `smithy.api#http`
57
+ * trait's `contentType` (which core's `buildRequest` understands);
58
+ * form-urlencoded is left to provider SdkSpecs/protocols.
59
+ */
60
+ export declare const CONTENT_TYPE_TRAIT = "com.distilled.openapi#contentType";
61
+ /**
62
+ * The `apiVersion` recorded on every operation when
63
+ * {@link OpenApiConvertOptions.apiVersion} is set (Azure ARM style). The
64
+ * matching `api-version` query parameter is dropped from inputs; the
65
+ * provider's protocol injects it at request time.
66
+ */
67
+ export declare const API_VERSION_TRAIT = "com.distilled.openapi#apiVersion";
68
+ export declare const SENSITIVE_FIELD_PATTERNS: readonly RegExp[];
69
+ export interface OpenApiConvertOptions {
70
+ /** Shape namespace, e.g. `"com.neon.api"`. */
71
+ readonly namespace: string;
72
+ /** Service shape name (PascalCased), e.g. `"Neon"`. */
73
+ readonly serviceName: string;
74
+ /** Service shape `version`. Default: the spec's `info.version`, else "1.0". */
75
+ readonly serviceVersion?: string;
76
+ /**
77
+ * Non-2xx response status → error class name. Statuses in
78
+ * {@link defaultErrorStatuses} never produce per-op errors. Default:
79
+ * `{400: BadRequest, 403: Forbidden, 404: NotFound, 409: Conflict,
80
+ * 422: UnprocessableEntity}` (the v0 default).
81
+ */
82
+ readonly statusToErrorClass?: Readonly<Record<string, string>>;
83
+ /**
84
+ * Statuses covered by the SDK's common errors, excluded from per-op error
85
+ * lists. Default: `{"401","429","500","503"}` (the v0 default).
86
+ */
87
+ readonly defaultErrorStatuses?: Iterable<string>;
88
+ /** Skip operations marked `deprecated: true`. Default true. */
89
+ readonly skipDeprecated?: boolean;
90
+ /**
91
+ * Azure-style fixed `api-version`: drops `api-version` query params and
92
+ * stamps {@link API_VERSION_TRAIT} on every operation.
93
+ */
94
+ readonly apiVersion?: string;
95
+ /**
96
+ * Name patterns marking string members sensitive. Default
97
+ * {@link SENSITIVE_FIELD_PATTERNS}. Pass `[]` to disable name-based
98
+ * detection (explicit `x-sensitive: true` still applies).
99
+ */
100
+ readonly sensitivePatterns?: readonly RegExp[];
101
+ /**
102
+ * Optional full shape-definition overrides for emitted error classes
103
+ * (keyed by class name) — e.g. custom members. The converter's default is
104
+ * an empty structure with `smithy.api#error` + `smithy.api#httpError` +
105
+ * {@link ERROR_MATCHERS_TRAIT} traits; overrides are merged over it.
106
+ */
107
+ readonly errorShapes?: Readonly<Record<string, any>>;
108
+ }
109
+ export interface SmithyModel {
110
+ smithy: "2.0";
111
+ metadata: any;
112
+ shapes: Record<string, any>;
113
+ }
114
+ export declare const convertOpenApiToSmithy: (spec: unknown, options: OpenApiConvertOptions) => SmithyModel;
115
+ //# sourceMappingURL=openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/codegen/openapi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,oFAAoF;AACpF,eAAO,MAAM,cAA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