@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
package/lib/schema.js CHANGED
@@ -2,16 +2,15 @@
2
2
  * `any`-collapsing re-export of `effect/Schema` for generated service files.
3
3
  *
4
4
  * This is the single, shared definition consumed by every code-generated
5
- * provider package (AWS, Azure, Cloudflare, GCP, Kubernetes, …) via
6
- * `@distilled.cloud/core/schema`. Do not copy it into individual packages.
5
+ * provider package via `@distilled.cloud/core/schema`. Do not copy it into
6
+ * individual packages.
7
7
  *
8
8
  * Every real TYPE (`Schema`, `Codec`, `Top`, …) is re-exported untouched, so
9
- * the `Schema.Schema<Foo>` / `Schema.Codec<Foo>` annotations on generated
10
- * consts (and the public `.d.ts`) stay precise. The schema *construction
11
- * surface* (`Struct`, `optional`, `suspend`, …) and the leaf scalar schemas are
12
- * retyped to `any`, so the compiler instantiates none of the heavy Schema
13
- * generics while building a service file — the explicit annotations carry the
14
- * real types.
9
+ * the `Schema.Schema<Foo>` annotations on generated consts (and the public
10
+ * `.d.ts`) stay precise. The schema *construction surface* (`Struct`,
11
+ * `optional`, `suspend`, …) and the leaf scalar schemas are retyped to `any`,
12
+ * so the compiler instantiates none of the heavy Schema generics while
13
+ * building a service file — the explicit annotations carry the real types.
15
14
  *
16
15
  * Overriding a *value* export never affects the same-named *type* export (they
17
16
  * live in separate namespaces and continue to flow through `export *`), so
package/lib/schema.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,cAAc,eAAe,CAAC;AAE9B,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAInC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAU,CAAC,CAAC,QAAiB,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAU,CAAC,CAAC,MAAe,CAAC;AAC/C,MAAM,CAAC,MAAM,OAAO,GAAU,CAAC,CAAC,OAAgB,CAAC;AACjD,MAAM,CAAC,MAAM,KAAK,GAAU,CAAC,CAA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ationMetaSymbol: unique symbol;
2
+ type Annotatable = {
3
+ annotate(annotations: any): Annotatable;
4
+ };
5
+ export interface Annotation {
6
+ <A extends Annotatable>(schema: A): A;
7
+ readonly [annotationMetaSymbol]: Array<{
8
+ symbol: symbol | string;
9
+ value: unknown;
10
+ }>;
11
+ readonly [key: symbol]: unknown;
12
+ readonly [key: string]: unknown;
13
+ }
14
+ /**
15
+ * Build a pipeable schema annotation carrying `value` under `sym`. Exported
16
+ * so SDK packages can define their own protocol traits (e.g. cloudflare's
17
+ * envelope traits, aws's smithy traits) with the same mechanics as the
18
+ * generic ones here. Keys may be symbols or plain strings — effect Schema
19
+ * annotation dictionaries accept both.
20
+ */
21
+ export declare function makeAnnotation<T>(sym: symbol | string, value: T): Annotation;
22
+ /**
23
+ * Combine several annotations into one — needed where only a single
24
+ * annotations object can be supplied (e.g. the second argument of
25
+ * `S.Class`).
26
+ */
27
+ export declare function all(...annotations: Annotation[]): Annotation;
28
+ export interface HttpTrait {
29
+ readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
30
+ /** URI template relative to the service base URL, e.g. `/accounts/{account_id}/foo`. */
31
+ readonly uri: string;
32
+ /** Default success status code (a `ResponseCode()` member can still read the actual code). */
33
+ readonly code?: number;
34
+ /**
35
+ * Request body encoding. Default is JSON; `"multipart"` sends
36
+ * multipart/form-data — body members become form parts (objects
37
+ * JSON-encoded) and members marked `FormDataFile()` append their files.
38
+ * `"form-urlencoded"` sends application/x-www-form-urlencoded with
39
+ * Stripe-style bracket notation for nested objects and arrays (see
40
+ * `buildRequest`).
41
+ */
42
+ readonly contentType?: "multipart" | "form-urlencoded";
43
+ /**
44
+ * Explicit `Content-Type` for a whole-body (`HttpBody()`) member carrying a
45
+ * preserialized payload, when the API requires a specific media type rather
46
+ * than JSON (e.g. `application/x-ndjson` for Vectorize insert/upsert). The
47
+ * member value is sent verbatim (string/bytes) under this media type.
48
+ */
49
+ readonly bodyMediaType?: string;
50
+ /**
51
+ * Explicit `Accept` for the operation, when the API serves more than one
52
+ * response media type. Atlas pins an API version this way (e.g.
53
+ * `application/vnd.atlas.2024-05-30+json` — `application/json` alone is a
54
+ * 406). Protocols that don't read it fall back to their own default.
55
+ */
56
+ readonly accept?: string;
57
+ }
58
+ export declare const httpSymbol: unique symbol;
59
+ /**
60
+ * Operation-level HTTP binding: the request method + URI template. Stamped on
61
+ * the input schema so the protocol can build the request line. URI `{labels}`
62
+ * are filled from members marked with `Label()`.
63
+ */
64
+ export declare const Http: (trait: HttpTrait) => Annotation;
65
+ export declare const labelSymbol: unique symbol;
66
+ /** Bind a member to a `{name}` placeholder in the operation's URI template. */
67
+ export declare const Label: (name?: string) => Annotation;
68
+ export declare const responseCodeSymbol: unique symbol;
69
+ export declare const ResponseCode: () => Annotation;
70
+ export declare const headerSymbol: unique symbol;
71
+ export declare const Header: (name?: string) => Annotation;
72
+ export declare const bodySymbol: unique symbol;
73
+ export declare const Body: (name?: string) => Annotation;
74
+ export declare const querySymbol: unique symbol;
75
+ export declare const Query: (name?: string) => Annotation;
76
+ export declare const deepQuerySymbol: unique symbol;
77
+ /**
78
+ * Binds a struct-valued input member to a family of DOTTED query parameters:
79
+ * `{ account: { id, name } }` with `DeepQuery("account")` serializes as
80
+ * `?account.id=…&account.name=…` (null/undefined entries skipped). This is
81
+ * how several list endpoints model their filters on the wire (e.g.
82
+ * Cloudflare zones list `account.id` / `account.name`) while the TS surface
83
+ * keeps the nested-object shape (v0 parity).
84
+ */
85
+ export declare const DeepQuery: (name?: string) => Annotation;
86
+ export declare const httpBodySymbol: unique symbol;
87
+ /**
88
+ * Marks the input member whose value IS the entire request body (raw arrays/
89
+ * scalars — e.g. endpoints that POST a bare JSON array). Mirrors
90
+ * `smithy.api#httpPayload`.
91
+ */
92
+ export declare const HttpBody: () => Annotation;
93
+ export declare const formDataFileSymbol: unique symbol;
94
+ /**
95
+ * Marks an input member holding `File`/`Blob` parts for a multipart upload
96
+ * (`Http({ contentType: "multipart" })`). Each file is appended to the form
97
+ * under its own filename.
98
+ */
99
+ export declare const FormDataFile: () => Annotation;
100
+ export declare const keyDictionarySymbol: unique symbol;
101
+ /**
102
+ * Deep TS-name→wire-name key dictionary for members whose full structure is
103
+ * not modeled (opaque `Document` content). The protocol renames any matching
104
+ * key at any depth on encode (and the reverse on decode); keys not in the
105
+ * dictionary pass through verbatim.
106
+ *
107
+ * A value may be an array of wire names when the API itself is inconsistent
108
+ * (e.g. queues consumer responses name the worker script `script_name` on
109
+ * create/update but `script` on get/list): the first entry is the canonical
110
+ * wire name used on encode; decode maps every listed spelling back to the
111
+ * TS name.
112
+ */
113
+ export type KeyDictionaryEntries = Record<string, string | ReadonlyArray<string>>;
114
+ export declare const KeyDictionary: (dict: KeyDictionaryEntries) => Annotation;
115
+ export declare const unionCasesSymbol: unique symbol;
116
+ /**
117
+ * Marks an opaque schema standing in for a discriminated union of object
118
+ * cases, carrying each case's TS-facing key set. For APIs that return every
119
+ * case's keys with `null` for the inactive ones, the protocol uses these key
120
+ * sets to pick the active case and drop the others, so consumers' `"key" in
121
+ * value` discrimination works.
122
+ */
123
+ export declare const UnionCases: (cases: ReadonlyArray<ReadonlyArray<string>>) => Annotation;
124
+ export declare const errorMatchersSymbol: unique symbol;
125
+ /**
126
+ * One wire-matching rule for a typed error class. A matcher matches a wire
127
+ * failure when every present field matches: `code` equals the wire error's
128
+ * code, `status` equals the HTTP status, and `message` either equals the
129
+ * error message (string form) or satisfies `includes` (substring) /
130
+ * `matches` (regex). A matcher with no fields matches nothing.
131
+ */
132
+ export interface ErrorMatcher {
133
+ readonly code?: number;
134
+ readonly status?: number;
135
+ readonly message?: string | {
136
+ readonly includes?: string;
137
+ readonly matches?: string;
138
+ };
139
+ }
140
+ /**
141
+ * Stamp wire-matching rules onto a generated error class. Protocols consult
142
+ * these to decide which of an operation's declared error classes a failed
143
+ * response should surface as (most specific matcher wins; ties break by
144
+ * declaration order — see `matchTypedError` in `core/protocol-http`).
145
+ */
146
+ export declare const applyErrorMatchers: <C>(cls: C, matchers: ReadonlyArray<ErrorMatcher>) => C;
147
+ /** Read the matchers stamped on an error class, if any. */
148
+ export declare const getErrorMatchers: (cls: unknown) => ReadonlyArray<ErrorMatcher> | undefined;
149
+ export {};
150
+ //# sourceMappingURL=trait.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trait.d.ts","sourceRoot":"","sources":["../src/trait.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,WAAW,EAAE,GAAG,GAAG,WAAW,CAAC;CACzC,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACtC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC;QACrC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC,CAAC;IACH,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAM5E;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,GAAG,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,CAe5D;AAOD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EACX,KAAK,GACL,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;IACd,wFAAwF;IACxF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAA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AO,MAAM,aAAa,SAAU,oBAAoB,eACb,CAAC;AAE5C,eAAO,MAAM,gBAAgB,eAAkD,CAAC;AAChF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,eAC7B,CAAC;AAK1C,eAAO,MAAM,mBAAmB,eAE/B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EACb,MAAM,GACN;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/D;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,OAC7B,CAAC,YACI,aAAa,CAAC,YAAY,CAAC,KACpC,CAGF,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,QACtB,OAAO,KACX,aAAa,CAAC,YAAY,CAAC,GAAG,SACI,CAAC"}
package/lib/trait.js ADDED
@@ -0,0 +1,107 @@
1
+ export const annotationMetaSymbol = Symbol.for("@distilled.cloud/core/annotation-meta");
2
+ /**
3
+ * Build a pipeable schema annotation carrying `value` under `sym`. Exported
4
+ * so SDK packages can define their own protocol traits (e.g. cloudflare's
5
+ * envelope traits, aws's smithy traits) with the same mechanics as the
6
+ * generic ones here. Keys may be symbols or plain strings — effect Schema
7
+ * annotation dictionaries accept both.
8
+ */
9
+ export function makeAnnotation(sym, value) {
10
+ const fn = (schema) => schema.annotate({ [sym]: value });
11
+ fn[annotationMetaSymbol] = [{ symbol: sym, value }];
12
+ fn[sym] = value;
13
+ return fn;
14
+ }
15
+ /**
16
+ * Combine several annotations into one — needed where only a single
17
+ * annotations object can be supplied (e.g. the second argument of
18
+ * `S.Class`).
19
+ */
20
+ export function all(...annotations) {
21
+ const entries = [];
22
+ const raw = {};
23
+ for (const a of annotations) {
24
+ for (const entry of a[annotationMetaSymbol]) {
25
+ entries.push(entry);
26
+ raw[entry.symbol] = entry.value;
27
+ }
28
+ }
29
+ const fn = (schema) => schema.annotate(raw);
30
+ fn[annotationMetaSymbol] = entries;
31
+ for (const { symbol: sym, value } of entries) {
32
+ fn[sym] = value;
33
+ }
34
+ return fn;
35
+ }
36
+ export const httpSymbol = Symbol.for("@distilled.cloud/core/http");
37
+ /**
38
+ * Operation-level HTTP binding: the request method + URI template. Stamped on
39
+ * the input schema so the protocol can build the request line. URI `{labels}`
40
+ * are filled from members marked with `Label()`.
41
+ */
42
+ export const Http = (trait) => makeAnnotation(httpSymbol, trait);
43
+ export const labelSymbol = Symbol.for("@distilled.cloud/core/http/label");
44
+ /** Bind a member to a `{name}` placeholder in the operation's URI template. */
45
+ export const Label = (name) => makeAnnotation(labelSymbol, name ?? true);
46
+ export const responseCodeSymbol = Symbol.for("@distilled.cloud/core/http/response-code");
47
+ export const ResponseCode = () => makeAnnotation(responseCodeSymbol, true);
48
+ export const headerSymbol = Symbol.for("@distilled.cloud/core/http/header");
49
+ export const Header = (name) => makeAnnotation(headerSymbol, name ?? true);
50
+ export const bodySymbol = Symbol.for("@distilled.cloud/core/http/body");
51
+ export const Body = (name) => makeAnnotation(bodySymbol, name ?? true);
52
+ export const querySymbol = Symbol.for("@distilled.cloud/core/http/query");
53
+ export const Query = (name) => makeAnnotation(querySymbol, name ?? true);
54
+ export const deepQuerySymbol = Symbol.for("@distilled.cloud/core/http/deep-query");
55
+ /**
56
+ * Binds a struct-valued input member to a family of DOTTED query parameters:
57
+ * `{ account: { id, name } }` with `DeepQuery("account")` serializes as
58
+ * `?account.id=…&account.name=…` (null/undefined entries skipped). This is
59
+ * how several list endpoints model their filters on the wire (e.g.
60
+ * Cloudflare zones list `account.id` / `account.name`) while the TS surface
61
+ * keeps the nested-object shape (v0 parity).
62
+ */
63
+ export const DeepQuery = (name) => makeAnnotation(deepQuerySymbol, name ?? true);
64
+ export const httpBodySymbol = Symbol.for("@distilled.cloud/core/http-body");
65
+ /**
66
+ * Marks the input member whose value IS the entire request body (raw arrays/
67
+ * scalars — e.g. endpoints that POST a bare JSON array). Mirrors
68
+ * `smithy.api#httpPayload`.
69
+ */
70
+ export const HttpBody = () => makeAnnotation(httpBodySymbol, true);
71
+ export const formDataFileSymbol = Symbol.for("@distilled.cloud/core/form-data-file");
72
+ /**
73
+ * Marks an input member holding `File`/`Blob` parts for a multipart upload
74
+ * (`Http({ contentType: "multipart" })`). Each file is appended to the form
75
+ * under its own filename.
76
+ */
77
+ export const FormDataFile = () => makeAnnotation(formDataFileSymbol, true);
78
+ //#endregion
79
+ //#region Generic JSON traits
80
+ export const keyDictionarySymbol = Symbol.for("@distilled.cloud/core/key-dictionary");
81
+ export const KeyDictionary = (dict) => makeAnnotation(keyDictionarySymbol, dict);
82
+ export const unionCasesSymbol = Symbol.for("@distilled.cloud/core/union-cases");
83
+ /**
84
+ * Marks an opaque schema standing in for a discriminated union of object
85
+ * cases, carrying each case's TS-facing key set. For APIs that return every
86
+ * case's keys with `null` for the inactive ones, the protocol uses these key
87
+ * sets to pick the active case and drop the others, so consumers' `"key" in
88
+ * value` discrimination works.
89
+ */
90
+ export const UnionCases = (cases) => makeAnnotation(unionCasesSymbol, cases);
91
+ //#endregion
92
+ //#region Error matcher traits
93
+ export const errorMatchersSymbol = Symbol.for("@distilled.cloud/core/error-matchers");
94
+ /**
95
+ * Stamp wire-matching rules onto a generated error class. Protocols consult
96
+ * these to decide which of an operation's declared error classes a failed
97
+ * response should surface as (most specific matcher wins; ties break by
98
+ * declaration order — see `matchTypedError` in `core/protocol-http`).
99
+ */
100
+ export const applyErrorMatchers = (cls, matchers) => {
101
+ cls[errorMatchersSymbol] = matchers;
102
+ return cls;
103
+ };
104
+ /** Read the matchers stamped on an error class, if any. */
105
+ export const getErrorMatchers = (cls) => cls?.[err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C3C,sCAAsC,CACvC,CAAC;AAiBF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAAM,EACN,QAAqC,EAClC,EAAE;IACJ,GAAW,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC;IAC7C,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,GAAY,EAC6B,EAAE,CAC1C,GAAW,EAAE,CAAC,mBAAmB,CAAC,CAAC;AACtC,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/core",
3
- "version": "0.30.3",
3
+ "version": "1.0.0-rc.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -14,86 +14,29 @@
14
14
  "src"
15
15
  ],
16
16
  "exports": {
17
- "./category": {
18
- "types": "./lib/category.d.ts",
19
- "bun": "./src/category.ts",
20
- "default": "./lib/category.js"
21
- },
22
- "./client": {
23
- "types": "./lib/client.d.ts",
24
- "bun": "./src/client.ts",
25
- "default": "./lib/client.js"
26
- },
27
- "./errors": {
28
- "types": "./lib/errors.d.ts",
29
- "bun": "./src/errors.ts",
30
- "default": "./lib/errors.js"
31
- },
32
- "./json-patch": {
33
- "types": "./lib/json-patch.d.ts",
34
- "bun": "./src/json-patch.ts",
35
- "default": "./lib/json-patch.js"
36
- },
37
- "./pagination": {
38
- "types": "./lib/pagination.d.ts",
39
- "bun": "./src/pagination.ts",
40
- "default": "./lib/pagination.js"
41
- },
42
- "./retry": {
43
- "types": "./lib/retry.d.ts",
44
- "bun": "./src/retry.ts",
45
- "default": "./lib/retry.js"
46
- },
47
- "./retry-after": {
48
- "types": "./lib/retry-after.d.ts",
49
- "bun": "./src/retry-after.ts",
50
- "default": "./lib/retry-after.js"
51
- },
52
- "./schema": {
53
- "types": "./lib/schema.d.ts",
54
- "bun": "./src/schema.ts",
55
- "default": "./lib/schema.js"
56
- },
57
- "./schemas": {
58
- "types": "./lib/schemas.d.ts",
59
- "bun": "./src/schemas.ts",
60
- "default": "./lib/schemas.js"
61
- },
62
- "./sensitive": {
63
- "types": "./lib/sensitive.d.ts",
64
- "bun": "./src/sensitive.ts",
65
- "default": "./lib/sensitive.js"
66
- },
67
- "./traits": {
68
- "types": "./lib/traits.d.ts",
69
- "bun": "./src/traits.ts",
70
- "default": "./lib/traits.js"
71
- },
72
- "./openapi/generate": {
73
- "bun": "./scripts/generate-openapi.ts",
74
- "default": "./scripts/generate-openapi.ts"
75
- },
76
- "./graphql/generate": {
77
- "bun": "./scripts/generate-graphql.ts",
78
- "default": "./scripts/generate-graphql.ts"
17
+ ".": {
18
+ "types": "./lib/index.d.ts",
19
+ "bun": "./src/index.ts",
20
+ "worker": "./src/index.ts",
21
+ "import": "./lib/index.js"
22
+ },
23
+ "./*": {
24
+ "types": "./lib/*.d.ts",
25
+ "bun": "./src/*.ts",
26
+ "worker": "./src/*.ts",
27
+ "import": "./lib/*.js"
79
28
  }
80
29
  },
81
30
  "scripts": {
82
- "typecheck": "tsc",
83
- "build": "tsc -b",
84
- "fmt": "oxfmt --write src",
85
- "lint": "oxlint --fix src",
86
- "check": "tsc && oxlint src && oxfmt --check src",
87
- "test": "bunx vitest run test --exclude specs --passWithNoTests",
88
- "publish:npm": "bun run build && bun publish --access public"
31
+ "build": "tsc -b"
89
32
  },
90
33
  "devDependencies": {
91
- "@types/bun": "^1.3.0",
92
- "@types/node": "^25.3.5",
93
- "dotenv": "^16.5.0",
94
- "vitest": "^3.2.3"
34
+ "@effect/platform-bun": ">=4.0.0-beta.102 || >=4.0.0",
35
+ "@types/bun": "latest",
36
+ "@types/node": "latest",
37
+ "effect": ">=4.0.0-beta.102 || >=4.0.0"
95
38
  },
96
39
  "peerDependencies": {
97
- "effect": ">=4.0.0-beta.100 || >=4.0.0"
40
+ "effect": ">=4.0.0-beta.102 || >=4.0.0"
98
41
  }
99
42
  }