@distilled.cloud/core 0.0.0 → 0.2.0-alpha
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/category.d.ts +260 -0
- package/lib/category.d.ts.map +1 -0
- package/lib/category.js +264 -0
- package/lib/category.js.map +1 -0
- package/lib/client.d.ts +123 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +268 -0
- package/lib/client.js.map +1 -0
- package/lib/errors.d.ts +181 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +122 -0
- package/lib/errors.js.map +1 -0
- package/lib/json-patch.d.ts +44 -0
- package/lib/json-patch.d.ts.map +1 -0
- package/lib/json-patch.js +208 -0
- package/lib/json-patch.js.map +1 -0
- package/lib/pagination.d.ts +74 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +130 -0
- package/lib/pagination.js.map +1 -0
- package/lib/retry.d.ts +99 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +106 -0
- package/lib/retry.js.map +1 -0
- package/lib/sensitive.d.ts +50 -0
- package/lib/sensitive.d.ts.map +1 -0
- package/lib/sensitive.js +64 -0
- package/lib/sensitive.js.map +1 -0
- package/lib/traits.d.ts +265 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +470 -0
- package/lib/traits.js.map +1 -0
- package/package.json +72 -5
- package/src/category.ts +406 -0
- package/src/client.ts +511 -0
- package/src/errors.ts +156 -0
- package/src/json-patch.ts +261 -0
- package/src/pagination.ts +222 -0
- package/src/retry.ts +177 -0
- package/src/sensitive.ts +74 -0
- package/src/traits.ts +627 -0
- package/README.md +0 -15
- package/bun.lock +0 -26
- package/index.ts +0 -1
- package/tsconfig.json +0 -29
package/lib/traits.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation-based traits for declarative operation definitions.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a type-safe annotation system for defining HTTP operations
|
|
5
|
+
* using Schema annotations. Traits can be applied via `.pipe()` or composed with `all()`.
|
|
6
|
+
*
|
|
7
|
+
* The annotation system is shared across all SDKs. Individual SDKs can extend it
|
|
8
|
+
* with provider-specific traits (e.g., AWS Smithy traits, Cloudflare-specific traits).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import * as T from "@distilled.cloud/core/traits";
|
|
13
|
+
*
|
|
14
|
+
* const GetDatabaseInput = Schema.Struct({
|
|
15
|
+
* organization: Schema.String.pipe(T.PathParam()),
|
|
16
|
+
* database: Schema.String.pipe(T.PathParam()),
|
|
17
|
+
* }).pipe(
|
|
18
|
+
* T.Http({ method: "GET", path: "/organizations/{organization}/databases/{database}" })
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import * as Schema from "effect/Schema";
|
|
23
|
+
import * as AST from "effect/SchemaAST";
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Annotation Primitives
|
|
26
|
+
// ============================================================================
|
|
27
|
+
/**
|
|
28
|
+
* Internal symbol for annotation metadata storage.
|
|
29
|
+
*/
|
|
30
|
+
const annotationMetaSymbol = Symbol.for("@distilled.cloud/annotation-meta");
|
|
31
|
+
/**
|
|
32
|
+
* Create an annotation builder for a given symbol and value.
|
|
33
|
+
* This is the core primitive used to build all trait annotations.
|
|
34
|
+
*/
|
|
35
|
+
export function makeAnnotation(sym, value) {
|
|
36
|
+
const fn = (schema) => schema.annotate({ [sym]: value });
|
|
37
|
+
fn[annotationMetaSymbol] = [{ symbol: sym, value }];
|
|
38
|
+
fn[sym] = value;
|
|
39
|
+
return fn;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Combine multiple annotations into one.
|
|
43
|
+
* Use when you need multiple annotations on the same schema.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const MyInput = Schema.Struct({
|
|
48
|
+
* id: Schema.String.pipe(T.all(T.PathParam(), T.Required())),
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function all(...annotations) {
|
|
53
|
+
const entries = [];
|
|
54
|
+
const raw = {};
|
|
55
|
+
for (const a of annotations) {
|
|
56
|
+
for (const entry of a[annotationMetaSymbol]) {
|
|
57
|
+
entries.push(entry);
|
|
58
|
+
raw[entry.symbol] = entry.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const fn = (schema) => schema.annotate(raw);
|
|
62
|
+
fn[annotationMetaSymbol] = entries;
|
|
63
|
+
for (const { symbol, value } of entries) {
|
|
64
|
+
fn[symbol] = value;
|
|
65
|
+
}
|
|
66
|
+
return fn;
|
|
67
|
+
}
|
|
68
|
+
// =============================================================================
|
|
69
|
+
// HTTP Operation Traits
|
|
70
|
+
// =============================================================================
|
|
71
|
+
/** Symbol for HTTP operation metadata (method + path template) */
|
|
72
|
+
export const httpSymbol = Symbol.for("@distilled.cloud/http");
|
|
73
|
+
/**
|
|
74
|
+
* Http trait - defines the HTTP method and path template for an operation.
|
|
75
|
+
* Path parameters are specified using {paramName} syntax.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const GetDatabaseInput = Schema.Struct({
|
|
80
|
+
* organization: Schema.String.pipe(T.PathParam()),
|
|
81
|
+
* database: Schema.String.pipe(T.PathParam()),
|
|
82
|
+
* }).pipe(
|
|
83
|
+
* T.Http({ method: "GET", path: "/organizations/{organization}/databases/{database}" })
|
|
84
|
+
* );
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export const Http = (trait) => makeAnnotation(httpSymbol, trait);
|
|
88
|
+
// =============================================================================
|
|
89
|
+
// Path Parameter Traits
|
|
90
|
+
// =============================================================================
|
|
91
|
+
/** Symbol for path parameter annotation */
|
|
92
|
+
export const pathParamSymbol = Symbol.for("@distilled.cloud/path-param");
|
|
93
|
+
/**
|
|
94
|
+
* PathParam trait - marks a field as a path parameter.
|
|
95
|
+
* The field name is used as the placeholder name in the path template.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const Input = Schema.Struct({
|
|
100
|
+
* organization: Schema.String.pipe(T.PathParam()),
|
|
101
|
+
* }).pipe(
|
|
102
|
+
* T.Http({ method: "GET", path: "/organizations/{organization}" })
|
|
103
|
+
* );
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export const PathParam = () => makeAnnotation(pathParamSymbol, true);
|
|
107
|
+
// =============================================================================
|
|
108
|
+
// Query Parameter Traits
|
|
109
|
+
// =============================================================================
|
|
110
|
+
/** Symbol for query parameter annotation */
|
|
111
|
+
export const queryParamSymbol = Symbol.for("@distilled.cloud/query-param");
|
|
112
|
+
/**
|
|
113
|
+
* QueryParam trait - marks a field as a query parameter.
|
|
114
|
+
* Optionally specify a different wire name.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const Input = Schema.Struct({
|
|
119
|
+
* perPage: Schema.optional(Schema.Number).pipe(T.QueryParam("per_page")),
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export const QueryParam = (name) => makeAnnotation(queryParamSymbol, name ?? true);
|
|
124
|
+
// =============================================================================
|
|
125
|
+
// Header Parameter Traits
|
|
126
|
+
// =============================================================================
|
|
127
|
+
/** Symbol for header parameter annotation */
|
|
128
|
+
export const headerParamSymbol = Symbol.for("@distilled.cloud/header-param");
|
|
129
|
+
/**
|
|
130
|
+
* HeaderParam trait - marks a field as a header parameter.
|
|
131
|
+
* Specify the header name.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const Input = Schema.Struct({
|
|
136
|
+
* apiToken: Schema.String.pipe(T.HeaderParam("X-API-Token")),
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export const HeaderParam = (name) => makeAnnotation(headerParamSymbol, name);
|
|
141
|
+
// =============================================================================
|
|
142
|
+
// Convenience Aliases (used by Cloudflare/GCP generators)
|
|
143
|
+
// =============================================================================
|
|
144
|
+
/**
|
|
145
|
+
* HttpPath - alias for PathParam that also carries the wire name.
|
|
146
|
+
* Used in generated code: `Schema.String.pipe(T.HttpPath("account_id"))`
|
|
147
|
+
*/
|
|
148
|
+
export const HttpPath = (name) => makeAnnotation(pathParamSymbol, name);
|
|
149
|
+
/**
|
|
150
|
+
* HttpQuery - alias for QueryParam with an explicit wire name.
|
|
151
|
+
* Used in generated code: `Schema.optional(Schema.String).pipe(T.HttpQuery("per_page"))`
|
|
152
|
+
*/
|
|
153
|
+
export const HttpQuery = (name) => makeAnnotation(queryParamSymbol, name);
|
|
154
|
+
/**
|
|
155
|
+
* HttpHeader - alias for HeaderParam.
|
|
156
|
+
* Used in generated code: `Schema.String.pipe(T.HttpHeader("X-Custom-Header"))`
|
|
157
|
+
*/
|
|
158
|
+
export const HttpHeader = (name) => makeAnnotation(headerParamSymbol, name);
|
|
159
|
+
/** Symbol for HTTP body annotation */
|
|
160
|
+
export const httpBodySymbol = Symbol.for("@distilled.cloud/http-body");
|
|
161
|
+
/**
|
|
162
|
+
* HttpBody - marks a field as the raw HTTP body.
|
|
163
|
+
* Used for operations where a field IS the entire request body
|
|
164
|
+
* (not a named field within a JSON body).
|
|
165
|
+
*/
|
|
166
|
+
export const HttpBody = () => makeAnnotation(httpBodySymbol, true);
|
|
167
|
+
/** Symbol for form data file annotation */
|
|
168
|
+
export const httpFormDataFileSymbol = Symbol.for("@distilled.cloud/http-form-data-file");
|
|
169
|
+
/**
|
|
170
|
+
* HttpFormDataFile - marks a field as a file upload in multipart form data.
|
|
171
|
+
*/
|
|
172
|
+
export const HttpFormDataFile = () => makeAnnotation(httpFormDataFileSymbol, true);
|
|
173
|
+
// =============================================================================
|
|
174
|
+
// API Error Code Trait
|
|
175
|
+
// =============================================================================
|
|
176
|
+
/** Symbol for API error code mapping */
|
|
177
|
+
export const apiErrorCodeSymbol = Symbol.for("@distilled.cloud/api-error-code");
|
|
178
|
+
/**
|
|
179
|
+
* ApiErrorCode trait - maps an error class to an API error code.
|
|
180
|
+
* Used to match API error responses to typed error classes.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* class NotFoundError extends Schema.TaggedErrorClass<NotFoundError>()(
|
|
185
|
+
* "NotFoundError",
|
|
186
|
+
* { message: Schema.String },
|
|
187
|
+
* ).pipe(T.ApiErrorCode("not_found")) {}
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export const ApiErrorCode = (code) => makeAnnotation(apiErrorCodeSymbol, code);
|
|
191
|
+
// =============================================================================
|
|
192
|
+
// Service Metadata Trait
|
|
193
|
+
// =============================================================================
|
|
194
|
+
/** Symbol for service metadata */
|
|
195
|
+
export const serviceSymbol = Symbol.for("@distilled.cloud/service");
|
|
196
|
+
/**
|
|
197
|
+
* Service trait - attaches service metadata to a schema.
|
|
198
|
+
*/
|
|
199
|
+
export const Service = (trait) => makeAnnotation(serviceSymbol, trait);
|
|
200
|
+
// =============================================================================
|
|
201
|
+
// Annotation Retrieval Helpers
|
|
202
|
+
// =============================================================================
|
|
203
|
+
/**
|
|
204
|
+
* Get annotation value from an AST node, following encoding chain if needed.
|
|
205
|
+
*/
|
|
206
|
+
export const getAnnotation = (ast, symbol) => {
|
|
207
|
+
// Direct annotation
|
|
208
|
+
const annotations = ast.annotations;
|
|
209
|
+
const direct = annotations?.[symbol];
|
|
210
|
+
if (direct !== undefined)
|
|
211
|
+
return direct;
|
|
212
|
+
// Follow encoding chain (replaces v3 Transformation handling)
|
|
213
|
+
if (ast.encoding && ast.encoding.length > 0) {
|
|
214
|
+
return getAnnotation(ast.encoding[0].to, symbol);
|
|
215
|
+
}
|
|
216
|
+
return undefined;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Get HTTP trait from a schema's AST.
|
|
220
|
+
*/
|
|
221
|
+
export const getHttpTrait = (ast) => getAnnotation(ast, httpSymbol);
|
|
222
|
+
/**
|
|
223
|
+
* Check if a PropertySignature has the pathParam annotation.
|
|
224
|
+
* Works for both PathParam() (annotation value = true) and HttpPath("wire_name") (annotation value = string).
|
|
225
|
+
*/
|
|
226
|
+
export const isPathParam = (prop) => {
|
|
227
|
+
const value = getAnnotation(prop.type, pathParamSymbol);
|
|
228
|
+
return value !== undefined;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Get query param name from a PropertySignature (returns true if unnamed, string if named).
|
|
232
|
+
*/
|
|
233
|
+
export const getQueryParam = (prop) => {
|
|
234
|
+
return getAnnotation(prop.type, queryParamSymbol);
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Get header param name from a PropertySignature.
|
|
238
|
+
*/
|
|
239
|
+
export const getHeaderParam = (prop) => {
|
|
240
|
+
return getAnnotation(prop.type, headerParamSymbol);
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Get API error code from an error class AST.
|
|
244
|
+
*/
|
|
245
|
+
export const getApiErrorCode = (ast) => getAnnotation(ast, apiErrorCodeSymbol);
|
|
246
|
+
/**
|
|
247
|
+
* Get service metadata from a schema's AST.
|
|
248
|
+
*/
|
|
249
|
+
export const getServiceTrait = (ast) => getAnnotation(ast, serviceSymbol);
|
|
250
|
+
/**
|
|
251
|
+
* Extract path parameters from a schema's struct properties.
|
|
252
|
+
* Returns an array of field names that have the PathParam annotation.
|
|
253
|
+
*/
|
|
254
|
+
export const getPathParams = (ast) => {
|
|
255
|
+
// Handle Objects (struct) - v4 renamed from TypeLiteral
|
|
256
|
+
if (ast._tag === "Objects") {
|
|
257
|
+
return ast.propertySignatures
|
|
258
|
+
.filter((prop) => isPathParam(prop))
|
|
259
|
+
.map((prop) => String(prop.name));
|
|
260
|
+
}
|
|
261
|
+
// Follow encoding chain (replaces v3 Transformation handling)
|
|
262
|
+
if (ast.encoding && ast.encoding.length > 0) {
|
|
263
|
+
return getPathParams(ast.encoding[0].to);
|
|
264
|
+
}
|
|
265
|
+
return [];
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Build the request path by substituting path parameters into the template.
|
|
269
|
+
* Simple version that assumes input keys match template placeholders.
|
|
270
|
+
* For schema-aware path building (with camelCase → wire_name mapping), use buildPathFromSchema.
|
|
271
|
+
*/
|
|
272
|
+
export const buildPath = (template, input) => {
|
|
273
|
+
return template.replace(/\{(\w+)\}/g, (_, name) => {
|
|
274
|
+
const value = input[name];
|
|
275
|
+
if (value === undefined || value === null) {
|
|
276
|
+
throw new Error(`Missing path parameter: ${name}`);
|
|
277
|
+
}
|
|
278
|
+
return encodeURIComponent(String(value));
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Extract AST property signatures from a schema AST, following encoding chain and suspends.
|
|
283
|
+
*/
|
|
284
|
+
export const getStructProps = (ast) => {
|
|
285
|
+
if (ast.encoding && ast.encoding.length > 0) {
|
|
286
|
+
return getStructProps(ast.encoding[0].to);
|
|
287
|
+
}
|
|
288
|
+
if (ast._tag === "Suspend") {
|
|
289
|
+
return getStructProps(ast.thunk());
|
|
290
|
+
}
|
|
291
|
+
if (ast._tag === "Objects") {
|
|
292
|
+
return [...ast.propertySignatures];
|
|
293
|
+
}
|
|
294
|
+
return [];
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Get the path parameter wire name from a PropertySignature.
|
|
298
|
+
* - For HttpPath("wire_name"), returns the wire name string.
|
|
299
|
+
* - For PathParam(), returns the property name (since annotation is `true`).
|
|
300
|
+
* - Returns undefined if not a path param.
|
|
301
|
+
*/
|
|
302
|
+
export const getPathParamWireName = (prop) => {
|
|
303
|
+
const value = getAnnotation(prop.type, pathParamSymbol);
|
|
304
|
+
if (value === undefined)
|
|
305
|
+
return undefined;
|
|
306
|
+
if (typeof value === "string")
|
|
307
|
+
return value;
|
|
308
|
+
// PathParam() stores `true` — use property name as wire name
|
|
309
|
+
return String(prop.name);
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Schema-aware request builder. Categorizes input properties into path, query, header,
|
|
313
|
+
* and body parts using annotations on the schema AST.
|
|
314
|
+
*
|
|
315
|
+
* Handles camelCase → wire_name mapping for path params (HttpPath), query params (HttpQuery),
|
|
316
|
+
* and header params (HttpHeader).
|
|
317
|
+
*
|
|
318
|
+
* When `inputSchema` is provided, uses `Schema.encodeSync` to encode the input through the
|
|
319
|
+
* schema's encoding pipeline (e.g., `encodeKeys` for camelCase → snake_case mapping).
|
|
320
|
+
* The encoded output is used for body construction, ensuring wire-format key names.
|
|
321
|
+
*/
|
|
322
|
+
export const buildRequestParts = (ast, httpTrait, input,
|
|
323
|
+
// biome-ignore lint: using any for generic schema parameter
|
|
324
|
+
inputSchema) => {
|
|
325
|
+
let path = httpTrait.path;
|
|
326
|
+
const query = {};
|
|
327
|
+
const headers = {};
|
|
328
|
+
let rawBody = undefined;
|
|
329
|
+
let hasRawBody = false;
|
|
330
|
+
const isMultipart = httpTrait.contentType === "multipart";
|
|
331
|
+
// Track which TS property names are path/query/header params (not body)
|
|
332
|
+
const nonBodyKeys = new Set();
|
|
333
|
+
const props = getStructProps(ast);
|
|
334
|
+
for (const prop of props) {
|
|
335
|
+
const tsName = String(prop.name);
|
|
336
|
+
const value = input[tsName];
|
|
337
|
+
if (value === undefined || value === null) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
// Path parameter
|
|
341
|
+
const pathWireName = getPathParamWireName(prop);
|
|
342
|
+
if (pathWireName !== undefined) {
|
|
343
|
+
nonBodyKeys.add(tsName);
|
|
344
|
+
path = path.replace(`{${pathWireName}}`, encodeURIComponent(String(value)));
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
// Query parameter
|
|
348
|
+
const queryParam = getQueryParam(prop);
|
|
349
|
+
if (queryParam !== undefined) {
|
|
350
|
+
nonBodyKeys.add(tsName);
|
|
351
|
+
const wireName = typeof queryParam === "string" ? queryParam : tsName;
|
|
352
|
+
if (Array.isArray(value)) {
|
|
353
|
+
query[wireName] = value.map(String);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
query[wireName] = String(value);
|
|
357
|
+
}
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
// Header parameter
|
|
361
|
+
const headerParam = getHeaderParam(prop);
|
|
362
|
+
if (headerParam !== undefined) {
|
|
363
|
+
nonBodyKeys.add(tsName);
|
|
364
|
+
headers[headerParam] = String(value);
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
// Body field (HttpBody annotation means this IS the entire body)
|
|
368
|
+
const isBodyField = getAnnotation(prop.type, httpBodySymbol);
|
|
369
|
+
if (isBodyField) {
|
|
370
|
+
rawBody = value;
|
|
371
|
+
hasRawBody = true;
|
|
372
|
+
nonBodyKeys.add(tsName);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// Build body from remaining (non-path/query/header) properties
|
|
377
|
+
let finalBody;
|
|
378
|
+
if (hasRawBody) {
|
|
379
|
+
// For HttpBody fields, encode through the schema to get wire-format keys
|
|
380
|
+
// (e.g., camelCase → snake_case via encodeKeys on nested schemas)
|
|
381
|
+
if (inputSchema) {
|
|
382
|
+
const encoded = Schema.encodeSync(inputSchema)(input);
|
|
383
|
+
const encodedRecord = encoded;
|
|
384
|
+
// Find the body field name in the encoded output
|
|
385
|
+
for (const prop of props) {
|
|
386
|
+
const tsName = String(prop.name);
|
|
387
|
+
const isBody = getAnnotation(prop.type, httpBodySymbol);
|
|
388
|
+
if (isBody && encodedRecord[tsName] !== undefined) {
|
|
389
|
+
finalBody = encodedRecord[tsName];
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
// Fallback to raw body if encoding didn't produce it
|
|
394
|
+
if (finalBody === undefined) {
|
|
395
|
+
finalBody = rawBody;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
finalBody = rawBody;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
// Encode the input through the schema to get wire-format keys
|
|
404
|
+
// This handles encodeKeys (camelCase → snake_case) and any other encoding transforms
|
|
405
|
+
if (inputSchema) {
|
|
406
|
+
const encoded = Schema.encodeSync(inputSchema)(input);
|
|
407
|
+
const encodedRecord = encoded;
|
|
408
|
+
// Build a mapping from tsName → encoded key name
|
|
409
|
+
// by encoding a minimal test object to discover key mappings
|
|
410
|
+
const bodyFromEncoded = {};
|
|
411
|
+
let hasBodyFields = false;
|
|
412
|
+
for (const [key, value] of Object.entries(encodedRecord)) {
|
|
413
|
+
// Check if this encoded key corresponds to a non-body TS property
|
|
414
|
+
// by seeing if any non-body prop encodes to this key
|
|
415
|
+
let isNonBody = false;
|
|
416
|
+
for (const nbKey of nonBodyKeys) {
|
|
417
|
+
// Simple heuristic: if the encoded key matches the non-body key or its encoding
|
|
418
|
+
if (key === nbKey) {
|
|
419
|
+
isNonBody = true;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (!isNonBody && value !== undefined) {
|
|
424
|
+
bodyFromEncoded[key] = value;
|
|
425
|
+
hasBodyFields = true;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
finalBody = hasBodyFields ? bodyFromEncoded : undefined;
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
// Fallback: no schema encoding, use TS property names as-is (for backwards compat)
|
|
432
|
+
const body = {};
|
|
433
|
+
let hasBody = false;
|
|
434
|
+
for (const prop of props) {
|
|
435
|
+
const tsName = String(prop.name);
|
|
436
|
+
if (nonBodyKeys.has(tsName))
|
|
437
|
+
continue;
|
|
438
|
+
const value = input[tsName];
|
|
439
|
+
if (value === undefined || value === null)
|
|
440
|
+
continue;
|
|
441
|
+
body[tsName] = value;
|
|
442
|
+
hasBody = true;
|
|
443
|
+
}
|
|
444
|
+
finalBody = hasBody ? body : undefined;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
path,
|
|
449
|
+
query,
|
|
450
|
+
headers,
|
|
451
|
+
body: finalBody,
|
|
452
|
+
isMultipart,
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Helper to get a value from an object using a dot-separated path.
|
|
457
|
+
* Used for pagination traits and nested property access.
|
|
458
|
+
*/
|
|
459
|
+
export const getPath = (obj, path) => {
|
|
460
|
+
const parts = path.split(".");
|
|
461
|
+
let current = obj;
|
|
462
|
+
for (const part of parts) {
|
|
463
|
+
if (current == null || typeof current !== "object") {
|
|
464
|
+
return undefined;
|
|
465
|
+
}
|
|
466
|
+
current = current[part];
|
|
467
|
+
}
|
|
468
|
+
return current;
|
|
469
|
+
};
|
|
470
|
+
//# sourceMappingURL=traits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAExC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAwB5E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAI,GAAW,EAAE,KAAQ;IACrD,MAAM,EAAE,GAAG,CAAwB,MAAS,EAAK,EAAE,CACjD,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAM,CAAC;IAExC,EAAU,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,EAAU,CAAC,GAAG,CAAC,GAAG,K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G,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK;QACL,OAAO;QACP,IAAI,EAAE,SAAS;QACf,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,IAAY,EAAW,EAAE;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,OAAO,GAAY,GAAG,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.2.0-alpha",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/alchemy-run/distilled",
|
|
7
|
+
"directory": "packages/core"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
6
|
-
"
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"files": [
|
|
12
|
+
"lib",
|
|
13
|
+
"src"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
"./category": {
|
|
17
|
+
"types": "./lib/category.d.ts",
|
|
18
|
+
"bun": "./src/category.ts",
|
|
19
|
+
"default": "./lib/category.js"
|
|
20
|
+
},
|
|
21
|
+
"./client": {
|
|
22
|
+
"types": "./lib/client.d.ts",
|
|
23
|
+
"bun": "./src/client.ts",
|
|
24
|
+
"default": "./lib/client.js"
|
|
25
|
+
},
|
|
26
|
+
"./errors": {
|
|
27
|
+
"types": "./lib/errors.d.ts",
|
|
28
|
+
"bun": "./src/errors.ts",
|
|
29
|
+
"default": "./lib/errors.js"
|
|
30
|
+
},
|
|
31
|
+
"./json-patch": {
|
|
32
|
+
"types": "./lib/json-patch.d.ts",
|
|
33
|
+
"bun": "./src/json-patch.ts",
|
|
34
|
+
"default": "./lib/json-patch.js"
|
|
35
|
+
},
|
|
36
|
+
"./pagination": {
|
|
37
|
+
"types": "./lib/pagination.d.ts",
|
|
38
|
+
"bun": "./src/pagination.ts",
|
|
39
|
+
"default": "./lib/pagination.js"
|
|
40
|
+
},
|
|
41
|
+
"./retry": {
|
|
42
|
+
"types": "./lib/retry.d.ts",
|
|
43
|
+
"bun": "./src/retry.ts",
|
|
44
|
+
"default": "./lib/retry.js"
|
|
45
|
+
},
|
|
46
|
+
"./sensitive": {
|
|
47
|
+
"types": "./lib/sensitive.d.ts",
|
|
48
|
+
"bun": "./src/sensitive.ts",
|
|
49
|
+
"default": "./lib/sensitive.js"
|
|
50
|
+
},
|
|
51
|
+
"./traits": {
|
|
52
|
+
"types": "./lib/traits.d.ts",
|
|
53
|
+
"bun": "./src/traits.ts",
|
|
54
|
+
"default": "./lib/traits.js"
|
|
55
|
+
},
|
|
56
|
+
"./openapi/generate": {
|
|
57
|
+
"bun": "./scripts/generate-openapi.ts",
|
|
58
|
+
"default": "./scripts/generate-openapi.ts"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"typecheck": "tsgo",
|
|
63
|
+
"build": "tsgo -b",
|
|
64
|
+
"fmt": "oxfmt --write src",
|
|
65
|
+
"lint": "oxlint --fix src",
|
|
66
|
+
"check": "tsgo && oxlint src && oxfmt --check src",
|
|
67
|
+
"test": "bunx vitest run test",
|
|
68
|
+
"publish:npm": "bun run build && bun publish --access public"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"effect": "4.0.0-beta.25"
|
|
72
|
+
},
|
|
7
73
|
"devDependencies": {
|
|
8
|
-
"@types/bun": "
|
|
74
|
+
"@types/bun": "^1.3.0",
|
|
75
|
+
"@types/node": "^25.3.5"
|
|
9
76
|
},
|
|
10
77
|
"peerDependencies": {
|
|
11
|
-
"
|
|
78
|
+
"effect": "4.0.0-beta.25"
|
|
12
79
|
}
|
|
13
80
|
}
|