@distilled.cloud/core 0.30.3 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.d.ts +165 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +178 -0
- package/lib/api.js.map +1 -0
- package/lib/codegen/cli.d.ts +29 -0
- package/lib/codegen/cli.d.ts.map +1 -0
- package/lib/codegen/cli.js +165 -0
- package/lib/codegen/cli.js.map +1 -0
- package/lib/codegen/emit.d.ts +129 -0
- package/lib/codegen/emit.d.ts.map +1 -0
- package/lib/codegen/emit.js +105 -0
- package/lib/codegen/emit.js.map +1 -0
- package/lib/codegen/format.d.ts +23 -0
- package/lib/codegen/format.d.ts.map +1 -0
- package/lib/codegen/format.js +28 -0
- package/lib/codegen/format.js.map +1 -0
- package/lib/codegen/generator.d.ts +334 -0
- package/lib/codegen/generator.d.ts.map +1 -0
- package/lib/codegen/generator.js +691 -0
- package/lib/codegen/generator.js.map +1 -0
- package/lib/codegen/graph.d.ts +36 -0
- package/lib/codegen/graph.d.ts.map +1 -0
- package/lib/codegen/graph.js +136 -0
- package/lib/codegen/graph.js.map +1 -0
- package/lib/codegen/members.d.ts +25 -0
- package/lib/codegen/members.d.ts.map +1 -0
- package/lib/codegen/members.js +55 -0
- package/lib/codegen/members.js.map +1 -0
- package/lib/codegen/naming.d.ts +29 -0
- package/lib/codegen/naming.d.ts.map +1 -0
- package/lib/codegen/naming.js +74 -0
- package/lib/codegen/naming.js.map +1 -0
- package/lib/codegen/openapi-cli.d.ts +38 -0
- package/lib/codegen/openapi-cli.d.ts.map +1 -0
- package/lib/codegen/openapi-cli.js +107 -0
- package/lib/codegen/openapi-cli.js.map +1 -0
- package/lib/codegen/openapi.d.ts +115 -0
- package/lib/codegen/openapi.d.ts.map +1 -0
- package/lib/codegen/openapi.js +1220 -0
- package/lib/codegen/openapi.js.map +1 -0
- package/lib/codegen/operations.d.ts +24 -0
- package/lib/codegen/operations.d.ts.map +1 -0
- package/lib/codegen/operations.js +56 -0
- package/lib/codegen/operations.js.map +1 -0
- package/lib/codegen/pagination.d.ts +39 -0
- package/lib/codegen/pagination.d.ts.map +1 -0
- package/lib/codegen/pagination.js +33 -0
- package/lib/codegen/pagination.js.map +1 -0
- package/lib/codegen/prelude.d.ts +15 -0
- package/lib/codegen/prelude.d.ts.map +1 -0
- package/lib/codegen/prelude.js +60 -0
- package/lib/codegen/prelude.js.map +1 -0
- package/lib/error-category.d.ts +28 -0
- package/lib/error-category.d.ts.map +1 -0
- package/lib/error-category.js +46 -0
- package/lib/error-category.js.map +1 -0
- package/lib/errors.d.ts +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -0
- package/lib/errors.js.map +1 -1
- package/lib/json-patch.d.ts +25 -32
- package/lib/json-patch.d.ts.map +1 -1
- package/lib/json-patch.js +23 -95
- package/lib/json-patch.js.map +1 -1
- package/lib/pagination.d.ts +37 -51
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +72 -90
- package/lib/pagination.js.map +1 -1
- package/lib/protocol-http.d.ts +74 -0
- package/lib/protocol-http.d.ts.map +1 -0
- package/lib/protocol-http.js +554 -0
- package/lib/protocol-http.js.map +1 -0
- package/lib/protocol-rest.d.ts +124 -0
- package/lib/protocol-rest.d.ts.map +1 -0
- package/lib/protocol-rest.js +242 -0
- package/lib/protocol-rest.js.map +1 -0
- package/lib/retry.d.ts +8 -2
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +21 -15
- package/lib/retry.js.map +1 -1
- package/lib/schema.d.ts +7 -8
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +7 -8
- package/lib/schema.js.map +1 -1
- package/lib/trait.d.ts +150 -0
- package/lib/trait.d.ts.map +1 -0
- package/lib/trait.js +107 -0
- package/lib/trait.js.map +1 -0
- package/package.json +18 -75
- package/src/api.ts +446 -0
- package/src/codegen/cli.ts +268 -0
- package/src/codegen/emit.ts +207 -0
- package/src/codegen/format.ts +47 -0
- package/src/codegen/generator.ts +1153 -0
- package/src/codegen/graph.ts +151 -0
- package/src/codegen/members.ts +71 -0
- package/src/codegen/naming.ts +86 -0
- package/src/codegen/openapi-cli.ts +166 -0
- package/src/codegen/openapi.ts +1450 -0
- package/src/codegen/operations.ts +76 -0
- package/src/codegen/pagination.ts +71 -0
- package/src/codegen/prelude.ts +70 -0
- package/src/error-category.ts +84 -0
- package/src/errors.ts +2 -0
- package/src/json-patch.ts +26 -110
- package/src/pagination.ts +86 -142
- package/src/protocol-http.ts +699 -0
- package/src/protocol-rest.ts +367 -0
- package/src/retry.ts +20 -21
- package/src/schema.ts +7 -8
- package/src/trait.ts +238 -0
- package/README.md +0 -30
- package/lib/client.d.ts +0 -167
- package/lib/client.d.ts.map +0 -1
- package/lib/client.js +0 -659
- package/lib/client.js.map +0 -1
- package/lib/schemas.d.ts +0 -60
- package/lib/schemas.d.ts.map +0 -1
- package/lib/schemas.js +0 -79
- package/lib/schemas.js.map +0 -1
- package/lib/sensitive.d.ts +0 -71
- package/lib/sensitive.d.ts.map +0 -1
- package/lib/sensitive.js +0 -96
- package/lib/sensitive.js.map +0 -1
- package/lib/traits.d.ts +0 -421
- package/lib/traits.d.ts.map +0 -1
- package/lib/traits.js +0 -737
- package/lib/traits.js.map +0 -1
- package/src/client.ts +0 -1177
- package/src/schemas.ts +0 -128
- package/src/sensitive.ts +0 -119
- package/src/traits.ts +0 -996
package/src/schemas.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cloud-agnostic binary HTTP body schemas.
|
|
3
|
-
*
|
|
4
|
-
* These schemas describe the wire-shape of raw byte bodies — request bodies
|
|
5
|
-
* for `application/octet-stream` uploads (e.g. R2 PutObject, S3 PutObject,
|
|
6
|
-
* GCS object insert) and response bodies for the corresponding downloads.
|
|
7
|
-
* They are intentionally cloud-agnostic so every distilled SDK can share a
|
|
8
|
-
* single binary-body contract.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import * as Schema from "effect/Schema";
|
|
12
|
-
import * as Stream from "effect/Stream";
|
|
13
|
-
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Schema for `Blob` request bodies (browser/web standard binary blob).
|
|
17
|
-
*/
|
|
18
|
-
export const BlobSchema = Schema.declare(
|
|
19
|
-
(input): input is Blob =>
|
|
20
|
-
typeof Blob !== "undefined" && input instanceof Blob,
|
|
21
|
-
{
|
|
22
|
-
identifier: "Blob",
|
|
23
|
-
description: "A Blob to send as the raw HTTP request body",
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Schema for `Uint8Array` request bodies.
|
|
29
|
-
*/
|
|
30
|
-
export const Uint8ArraySchema = Schema.declare(
|
|
31
|
-
(input): input is Uint8Array =>
|
|
32
|
-
typeof Uint8Array !== "undefined" && input instanceof Uint8Array,
|
|
33
|
-
{
|
|
34
|
-
identifier: "Uint8Array",
|
|
35
|
-
description: "A Uint8Array to send as the raw HTTP request body",
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Schema for `ArrayBuffer` request bodies.
|
|
41
|
-
*/
|
|
42
|
-
export const ArrayBufferSchema = Schema.declare(
|
|
43
|
-
(input): input is ArrayBuffer =>
|
|
44
|
-
typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer,
|
|
45
|
-
{
|
|
46
|
-
identifier: "ArrayBuffer",
|
|
47
|
-
description: "An ArrayBuffer to send as the raw HTTP request body",
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Schema for `ReadableStream<Uint8Array>` request bodies (web-platform
|
|
53
|
-
* streaming API).
|
|
54
|
-
*/
|
|
55
|
-
export const ReadableStreamSchema = Schema.declare(
|
|
56
|
-
(input): input is ReadableStream<Uint8Array> =>
|
|
57
|
-
typeof ReadableStream !== "undefined" && input instanceof ReadableStream,
|
|
58
|
-
{
|
|
59
|
-
identifier: "ReadableStream",
|
|
60
|
-
description:
|
|
61
|
-
"A ReadableStream<Uint8Array> to send as the raw HTTP request body",
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Schema for Effect `Stream.Stream<Uint8Array>` request bodies. Accepts any
|
|
67
|
-
* Stream regardless of error/requirements channels — the runtime treats it
|
|
68
|
-
* as an opaque source of bytes.
|
|
69
|
-
*/
|
|
70
|
-
export const StreamSchema = Schema.declare(
|
|
71
|
-
(input): input is Stream.Stream<Uint8Array, unknown, unknown> =>
|
|
72
|
-
Stream.isStream(input as Stream.Stream<unknown, unknown, unknown>),
|
|
73
|
-
{
|
|
74
|
-
identifier: "Stream",
|
|
75
|
-
description:
|
|
76
|
-
"An Effect Stream.Stream<Uint8Array> to send as the raw HTTP request body",
|
|
77
|
-
},
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Schema for raw `application/octet-stream` request bodies (e.g. R2
|
|
82
|
-
* `PutObject`, S3 `PutObject`). Inputs are intentionally wide — any
|
|
83
|
-
* standard JS binary source plus Effect `Stream.Stream<Uint8Array>` is
|
|
84
|
-
* accepted. The on-the-wire `Content-Type` is supplied by the caller
|
|
85
|
-
* through the operation's `content-type` header field; the runtime falls
|
|
86
|
-
* back to `application/octet-stream` when none is provided.
|
|
87
|
-
*/
|
|
88
|
-
export const BinaryBodySchema = Schema.Union([
|
|
89
|
-
BlobSchema,
|
|
90
|
-
Uint8ArraySchema,
|
|
91
|
-
ArrayBufferSchema,
|
|
92
|
-
ReadableStreamSchema,
|
|
93
|
-
StreamSchema,
|
|
94
|
-
Schema.String,
|
|
95
|
-
]);
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* TypeScript type for raw HTTP request body content. Inputs are wide;
|
|
99
|
-
* outputs (downloads) are always Effect `Stream.Stream<Uint8Array>`.
|
|
100
|
-
*/
|
|
101
|
-
export type BinaryBody =
|
|
102
|
-
| Blob
|
|
103
|
-
| Uint8Array
|
|
104
|
-
| ArrayBuffer
|
|
105
|
-
| ReadableStream<Uint8Array>
|
|
106
|
-
| Stream.Stream<Uint8Array, unknown, unknown>
|
|
107
|
-
| string;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Marker schema for raw `application/octet-stream` download responses (e.g.
|
|
111
|
-
* R2 `GetObject`). The runtime never decodes through this schema — it
|
|
112
|
-
* detects `responseContentType: "binary"` on the operation's HTTP trait and
|
|
113
|
-
* surfaces the response body directly as an Effect
|
|
114
|
-
* `Stream.Stream<Uint8Array, HttpClientError.HttpClientError>`. This schema
|
|
115
|
-
* is exported solely so generated service files have something to assign
|
|
116
|
-
* to the operation's output schema slot.
|
|
117
|
-
*/
|
|
118
|
-
export const BinaryStreamResponseSchema = Schema.declare(
|
|
119
|
-
(
|
|
120
|
-
input,
|
|
121
|
-
): input is Stream.Stream<Uint8Array, HttpClientError.HttpClientError> =>
|
|
122
|
-
Stream.isStream(input as Stream.Stream<unknown, unknown, unknown>),
|
|
123
|
-
{
|
|
124
|
-
identifier: "BinaryStreamResponse",
|
|
125
|
-
description:
|
|
126
|
-
"An Effect Stream.Stream<Uint8Array> surfacing a raw octet-stream download response",
|
|
127
|
-
},
|
|
128
|
-
);
|
package/src/sensitive.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sensitive data schemas for handling credentials and secrets.
|
|
3
|
-
*
|
|
4
|
-
* This module provides schemas that wrap sensitive data in Effect's Redacted type,
|
|
5
|
-
* preventing accidental logging of secrets like passwords and tokens.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { SensitiveString, SensitiveOutputString } from "@distilled.cloud/core/sensitive";
|
|
10
|
-
*
|
|
11
|
-
* // Inputs: use Sensitive* — accepts plain string OR Redacted (convenience).
|
|
12
|
-
* const CreateInput = Schema.Struct({ plain_text: SensitiveString });
|
|
13
|
-
* API.create({ plain_text: "my-secret" }); // ok
|
|
14
|
-
* API.create({ plain_text: Redacted.make("my-secret") }); // also ok
|
|
15
|
-
*
|
|
16
|
-
* // Outputs: use SensitiveOutput* — decoded type is strictly Redacted, so
|
|
17
|
-
* // consumers never need to coerce.
|
|
18
|
-
* const CreateOutput = Schema.Struct({ plain_text: SensitiveOutputString });
|
|
19
|
-
* console.log(result.plain_text); // Redacted<string>, logs "<redacted>"
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
import * as Redacted from "effect/Redacted";
|
|
23
|
-
import * as S from "effect/Schema";
|
|
24
|
-
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Sensitive (input-friendly) - Marks data as sensitive, wrapping in Redacted.
|
|
28
|
-
*
|
|
29
|
-
* Use for **request body** / **input** fields. The decoded TypeScript type is
|
|
30
|
-
* `A | Redacted<A>` so callers can pass either a plain value or a Redacted one.
|
|
31
|
-
* On the wire, plain values are sent through and Redacted values are unwrapped
|
|
32
|
-
* back to their underlying value. Decoded responses are always Redacted.
|
|
33
|
-
*
|
|
34
|
-
* For **output** / **response** fields use {@link SensitiveOutput} instead —
|
|
35
|
-
* its decoded type is strictly `Redacted<A>`, removing the need for callers to
|
|
36
|
-
* narrow / coerce on every read site.
|
|
37
|
-
*/
|
|
38
|
-
export const Sensitive = <A>(
|
|
39
|
-
schema: S.Schema<A>,
|
|
40
|
-
): S.Schema<A | Redacted.Redacted<A>> =>
|
|
41
|
-
schema
|
|
42
|
-
.pipe(
|
|
43
|
-
S.decodeTo(
|
|
44
|
-
S.Union([S.toType(schema), S.Redacted(S.toType(schema))]),
|
|
45
|
-
SchemaTransformation.transform({
|
|
46
|
-
// Decode: wire format -> always wrap in Redacted
|
|
47
|
-
decode: (a) => Redacted.make(a) as any,
|
|
48
|
-
// Encode: accept both raw and Redacted -> extract raw value
|
|
49
|
-
encode: (v) => (Redacted.isRedacted(v) ? Redacted.value(v) : v),
|
|
50
|
-
}),
|
|
51
|
-
),
|
|
52
|
-
)
|
|
53
|
-
.annotate({
|
|
54
|
-
identifier: `Sensitive<${schema.ast.annotations?.identifier ?? "unknown"}>`,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Sensitive string (input-friendly).
|
|
59
|
-
* Wire format: plain string. Decoded TypeScript type: `string | Redacted<string>`.
|
|
60
|
-
* Decoded runtime values are always `Redacted<string>`.
|
|
61
|
-
*
|
|
62
|
-
* Prefer {@link SensitiveOutputString} on response schemas — its static type
|
|
63
|
-
* matches the runtime (strict `Redacted<string>`).
|
|
64
|
-
*/
|
|
65
|
-
export const SensitiveString = Sensitive(S.String).annotate({
|
|
66
|
-
identifier: "SensitiveString",
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Sensitive nullable string (input-friendly).
|
|
71
|
-
* Wire format: `string | null`. Decoded type: `string | null | Redacted<string>`.
|
|
72
|
-
* Prefer {@link SensitiveOutputNullableString} on response schemas.
|
|
73
|
-
*/
|
|
74
|
-
export const SensitiveNullableString = S.NullOr(SensitiveString).annotate({
|
|
75
|
-
identifier: "SensitiveNullableString",
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* SensitiveOutput - strict variant of {@link Sensitive} for response fields.
|
|
80
|
-
*
|
|
81
|
-
* Decoded TypeScript type is `Redacted<A>` (no union). Wire format is the
|
|
82
|
-
* underlying `A`. Use on response schemas so consumers don't have to narrow
|
|
83
|
-
* `string | Redacted<string>` at every read site.
|
|
84
|
-
*/
|
|
85
|
-
export const SensitiveOutput = <A>(
|
|
86
|
-
schema: S.Schema<A>,
|
|
87
|
-
): S.Schema<Redacted.Redacted<A>> =>
|
|
88
|
-
schema
|
|
89
|
-
.pipe(
|
|
90
|
-
S.decodeTo(
|
|
91
|
-
S.Redacted(S.toType(schema)),
|
|
92
|
-
SchemaTransformation.transform({
|
|
93
|
-
decode: (a) => Redacted.make(a),
|
|
94
|
-
encode: (v) => Redacted.value(v),
|
|
95
|
-
}),
|
|
96
|
-
),
|
|
97
|
-
)
|
|
98
|
-
.annotate({
|
|
99
|
-
identifier: `SensitiveOutput<${schema.ast.annotations?.identifier ?? "unknown"}>`,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* SensitiveOutput string - strict variant of {@link SensitiveString} for
|
|
104
|
-
* response fields. Decoded type is `Redacted<string>`.
|
|
105
|
-
*/
|
|
106
|
-
export const SensitiveOutputString = SensitiveOutput(S.String).annotate({
|
|
107
|
-
identifier: "SensitiveOutputString",
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* SensitiveOutput nullable string - strict variant of
|
|
112
|
-
* {@link SensitiveNullableString} for response fields. Decoded type is
|
|
113
|
-
* `Redacted<string> | null`.
|
|
114
|
-
*/
|
|
115
|
-
export const SensitiveOutputNullableString = S.NullOr(
|
|
116
|
-
SensitiveOutputString,
|
|
117
|
-
).annotate({
|
|
118
|
-
identifier: "SensitiveOutputNullableString",
|
|
119
|
-
});
|