@distilled.cloud/core 0.0.0 → 0.2.0
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 +66 -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/retry.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry Policy System
|
|
3
|
+
*
|
|
4
|
+
* Provides configurable retry policies for API operations.
|
|
5
|
+
* Each SDK creates its own Retry service tag but uses these shared utilities
|
|
6
|
+
* for building retry schedules and policies.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as Retry from "@distilled.cloud/sdk-core/retry";
|
|
11
|
+
*
|
|
12
|
+
* // Use the default retry policy
|
|
13
|
+
* myEffect.pipe(Retry.policy(myRetryService, Retry.makeDefault()))
|
|
14
|
+
*
|
|
15
|
+
* // Disable retries
|
|
16
|
+
* myEffect.pipe(Retry.none(myRetryService))
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import * as Duration from "effect/Duration";
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import * as Ref from "effect/Ref";
|
|
22
|
+
import * as Schedule from "effect/Schedule";
|
|
23
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
24
|
+
/**
|
|
25
|
+
* Retry policy options that match the Effect.retry contract.
|
|
26
|
+
*/
|
|
27
|
+
export interface Options {
|
|
28
|
+
/**
|
|
29
|
+
* Predicate to determine if an error should trigger a retry.
|
|
30
|
+
*/
|
|
31
|
+
readonly while?: (error: unknown) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The schedule to use for retrying.
|
|
34
|
+
*/
|
|
35
|
+
readonly schedule?: Schedule.Schedule<unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A factory function that creates retry policy options with access to the last error ref.
|
|
39
|
+
* This allows dynamic policies that can inspect the last error for retry-after headers, etc.
|
|
40
|
+
*/
|
|
41
|
+
export type Factory = (lastError: Ref.Ref<unknown>) => Options;
|
|
42
|
+
/**
|
|
43
|
+
* A retry policy can be either static options or a factory that receives the last error ref.
|
|
44
|
+
*/
|
|
45
|
+
export type Policy = Options | Factory;
|
|
46
|
+
/**
|
|
47
|
+
* Create a typed Retry service class for an SDK.
|
|
48
|
+
* Each SDK should create its own Retry service using this factory.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // In planetscale-sdk/src/retry.ts
|
|
53
|
+
* export class Retry extends makeRetryService("PlanetScaleRetry") {}
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const makeRetryService: (name: string) => ServiceMap.ServiceClass<any, string, Policy>;
|
|
57
|
+
/**
|
|
58
|
+
* Provides a custom retry policy for API calls.
|
|
59
|
+
*/
|
|
60
|
+
export declare const policy: (Service: any, optionsOrFactory: Policy) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, unknown, unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* Disables all automatic retries.
|
|
63
|
+
*/
|
|
64
|
+
export declare const none: (Service: any) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, unknown, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom jittered schedule helper.
|
|
67
|
+
* Adds random jitter between 0-50ms to avoid thundering herd.
|
|
68
|
+
*/
|
|
69
|
+
export declare const jittered: <Input, Error, Env>(self: Schedule.Schedule<unknown, Input, Error, Env>) => Schedule.Schedule<unknown, Input, Error, Env>;
|
|
70
|
+
/**
|
|
71
|
+
* Cap delay at a maximum duration.
|
|
72
|
+
*/
|
|
73
|
+
export declare const capped: (max: Duration.Duration) => <Input, Error, Env>(self: Schedule.Schedule<Duration.Duration, Input, Error, Env>) => Schedule.Schedule<Duration.Duration, Input, Error, Env>;
|
|
74
|
+
/**
|
|
75
|
+
* Creates the default retry policy.
|
|
76
|
+
*
|
|
77
|
+
* This policy:
|
|
78
|
+
* - Retries transient errors (throttling, server, network, locked errors)
|
|
79
|
+
* - Uses exponential backoff starting at 100ms with a factor of 2
|
|
80
|
+
* - Ensures at least 500ms delay for throttling errors
|
|
81
|
+
* - Limits to 5 retry attempts
|
|
82
|
+
* - Applies jitter to avoid thundering herd
|
|
83
|
+
*/
|
|
84
|
+
export declare const makeDefault: Factory;
|
|
85
|
+
/**
|
|
86
|
+
* Retry options that retries all throttling errors indefinitely.
|
|
87
|
+
*/
|
|
88
|
+
export declare const throttlingOptions: Options;
|
|
89
|
+
/**
|
|
90
|
+
* Retry options that retries all transient errors indefinitely.
|
|
91
|
+
*
|
|
92
|
+
* This includes:
|
|
93
|
+
* 1. Throttling errors
|
|
94
|
+
* 2. Server errors
|
|
95
|
+
* 3. Network errors
|
|
96
|
+
* 4. Locked errors (423)
|
|
97
|
+
*/
|
|
98
|
+
export declare const transientOptions: Options;
|
|
99
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAOhD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAChD;AAED;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAMvC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gEACY,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,MAAM,+CAEhB,CAAC,EAAE,CAAC,EAAE,CAAC,uEACiE,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,IAAI,qBAEd,CAAC,EAAE,CAAC,EAAE,CAAC,uEAIL,CAAC;AAMN;;;GAGG;AACH,eAAO,MAAM,QAAQ,2HAEpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,2KAKhB,CAAC;AAMJ;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,EAAE,OAkBxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAO/B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAO9B,CAAC"}
|
package/lib/retry.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry Policy System
|
|
3
|
+
*
|
|
4
|
+
* Provides configurable retry policies for API operations.
|
|
5
|
+
* Each SDK creates its own Retry service tag but uses these shared utilities
|
|
6
|
+
* for building retry schedules and policies.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as Retry from "@distilled.cloud/sdk-core/retry";
|
|
11
|
+
*
|
|
12
|
+
* // Use the default retry policy
|
|
13
|
+
* myEffect.pipe(Retry.policy(myRetryService, Retry.makeDefault()))
|
|
14
|
+
*
|
|
15
|
+
* // Disable retries
|
|
16
|
+
* myEffect.pipe(Retry.none(myRetryService))
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import * as Duration from "effect/Duration";
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import { pipe } from "effect/Function";
|
|
22
|
+
import * as Layer from "effect/Layer";
|
|
23
|
+
import * as Ref from "effect/Ref";
|
|
24
|
+
import * as Schedule from "effect/Schedule";
|
|
25
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
26
|
+
import { isThrottling, isTransientError } from "./category.js";
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Retry Service Factory
|
|
29
|
+
// ============================================================================
|
|
30
|
+
/**
|
|
31
|
+
* Create a typed Retry service class for an SDK.
|
|
32
|
+
* Each SDK should create its own Retry service using this factory.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // In planetscale-sdk/src/retry.ts
|
|
37
|
+
* export class Retry extends makeRetryService("PlanetScaleRetry") {}
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const makeRetryService = (name) => ServiceMap.Service()(name);
|
|
41
|
+
/**
|
|
42
|
+
* Provides a custom retry policy for API calls.
|
|
43
|
+
*/
|
|
44
|
+
export const policy = (Service, optionsOrFactory) => (effect) => Effect.provide(effect, Layer.succeed(Service, optionsOrFactory));
|
|
45
|
+
/**
|
|
46
|
+
* Disables all automatic retries.
|
|
47
|
+
*/
|
|
48
|
+
export const none = (Service) => (effect) => Effect.provide(effect, Layer.succeed(Service, { while: () => false }));
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// Retry Schedule Utilities
|
|
51
|
+
// ============================================================================
|
|
52
|
+
/**
|
|
53
|
+
* Custom jittered schedule helper.
|
|
54
|
+
* Adds random jitter between 0-50ms to avoid thundering herd.
|
|
55
|
+
*/
|
|
56
|
+
export const jittered = Schedule.addDelay(() => Effect.succeed(Duration.millis(Math.random() * 50)));
|
|
57
|
+
/**
|
|
58
|
+
* Cap delay at a maximum duration.
|
|
59
|
+
*/
|
|
60
|
+
export const capped = (max) => Schedule.modifyDelay((duration) => Effect.succeed(Duration.isGreaterThan(duration, max) ? Duration.millis(5000) : duration));
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Default Retry Policies
|
|
63
|
+
// ============================================================================
|
|
64
|
+
/**
|
|
65
|
+
* Creates the default retry policy.
|
|
66
|
+
*
|
|
67
|
+
* This policy:
|
|
68
|
+
* - Retries transient errors (throttling, server, network, locked errors)
|
|
69
|
+
* - Uses exponential backoff starting at 100ms with a factor of 2
|
|
70
|
+
* - Ensures at least 500ms delay for throttling errors
|
|
71
|
+
* - Limits to 5 retry attempts
|
|
72
|
+
* - Applies jitter to avoid thundering herd
|
|
73
|
+
*/
|
|
74
|
+
export const makeDefault = (lastError) => ({
|
|
75
|
+
while: (error) => isTransientError(error),
|
|
76
|
+
schedule: pipe(Schedule.exponential(100, 2), Schedule.modifyDelay(Effect.fnUntraced(function* (duration) {
|
|
77
|
+
const error = yield* Ref.get(lastError);
|
|
78
|
+
if (isThrottling(error)) {
|
|
79
|
+
if (Duration.toMillis(duration) < 500) {
|
|
80
|
+
return Duration.toMillis(Duration.millis(500));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return Duration.toMillis(duration);
|
|
84
|
+
})), Schedule.both(Schedule.recurs(5)), jittered),
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Retry options that retries all throttling errors indefinitely.
|
|
88
|
+
*/
|
|
89
|
+
export const throttlingOptions = {
|
|
90
|
+
while: (error) => isThrottling(error),
|
|
91
|
+
schedule: pipe(Schedule.exponential(1000, 2), capped(Duration.seconds(5)), jittered),
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Retry options that retries all transient errors indefinitely.
|
|
95
|
+
*
|
|
96
|
+
* This includes:
|
|
97
|
+
* 1. Throttling errors
|
|
98
|
+
* 2. Server errors
|
|
99
|
+
* 3. Network errors
|
|
100
|
+
* 4. Locked errors (423)
|
|
101
|
+
*/
|
|
102
|
+
export const transientOptions = {
|
|
103
|
+
while: isTransientError,
|
|
104
|
+
schedule: pipe(Schedule.exponential(1000, 2), capped(Duration.seconds(5)), jittered),
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=retry.js.map
|
package/lib/retry.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,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,CAAC,YAAY,CAAC,KAAK,CAAC;IACrC,QAAQ,EAAE,IAAI,CACZ,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EAC7B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAC3B,QAAQ,CACT;CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAY;IACvC,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,IAAI,CACZ,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EAC7B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAC3B,QAAQ,CACT;CACF,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 } from "@distilled.cloud/sdk-core/sensitive";
|
|
10
|
+
*
|
|
11
|
+
* const Password = Schema.Struct({ plain_text: SensitiveString });
|
|
12
|
+
*
|
|
13
|
+
* // Users can pass raw strings (convenient):
|
|
14
|
+
* API.createPassword({ plain_text: "my-secret" })
|
|
15
|
+
*
|
|
16
|
+
* // Or Redacted values (explicit):
|
|
17
|
+
* API.createPassword({ plain_text: Redacted.make("my-secret") })
|
|
18
|
+
*
|
|
19
|
+
* // Response values are always Redacted (safe):
|
|
20
|
+
* console.log(result.plain_text); // logs "<redacted>"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import * as Redacted from "effect/Redacted";
|
|
24
|
+
import * as S from "effect/Schema";
|
|
25
|
+
/**
|
|
26
|
+
* Sensitive - Marks data as sensitive, wrapping in Effect's Redacted type.
|
|
27
|
+
*
|
|
28
|
+
* This schema provides a convenient way to handle sensitive data:
|
|
29
|
+
* - TypeScript type: `A | Redacted.Redacted<A>` (accepts both for inputs)
|
|
30
|
+
* - Decode (responses): Always wraps wire value in Redacted
|
|
31
|
+
* - Encode (requests): Accepts BOTH raw values and Redacted, extracts the raw value
|
|
32
|
+
*
|
|
33
|
+
* The union type allows users to conveniently pass plain values for inputs while
|
|
34
|
+
* still getting proper Redacted types for outputs. Response values will always
|
|
35
|
+
* be Redacted, which prevents accidental logging.
|
|
36
|
+
*/
|
|
37
|
+
export declare const Sensitive: <A>(schema: S.Schema<A>) => S.Schema<A | Redacted.Redacted<A>>;
|
|
38
|
+
/**
|
|
39
|
+
* Sensitive string - a string marked as sensitive.
|
|
40
|
+
* Wire format is plain string, TypeScript type is string | Redacted<string>.
|
|
41
|
+
* At runtime, decoded values are always Redacted<string>.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SensitiveString: S.Schema<string | Redacted.Redacted<string>>;
|
|
44
|
+
/**
|
|
45
|
+
* Sensitive nullable string - a nullable string marked as sensitive.
|
|
46
|
+
* Wire format is plain string | null, TypeScript type is string | null | Redacted<string>.
|
|
47
|
+
* At runtime, decoded non-null values are always Redacted<string>.
|
|
48
|
+
*/
|
|
49
|
+
export declare const SensitiveNullableString: S.NullOr<S.Schema<string | Redacted.Redacted<string>>>;
|
|
50
|
+
//# sourceMappingURL=sensitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive.d.ts","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAGnC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,4DAiBrB,CAAC;AAEP;;;;GAIG;AACH,eAAO,MAAM,eAAe,8CAE1B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,wDAElC,CAAC"}
|
package/lib/sensitive.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 } from "@distilled.cloud/sdk-core/sensitive";
|
|
10
|
+
*
|
|
11
|
+
* const Password = Schema.Struct({ plain_text: SensitiveString });
|
|
12
|
+
*
|
|
13
|
+
* // Users can pass raw strings (convenient):
|
|
14
|
+
* API.createPassword({ plain_text: "my-secret" })
|
|
15
|
+
*
|
|
16
|
+
* // Or Redacted values (explicit):
|
|
17
|
+
* API.createPassword({ plain_text: Redacted.make("my-secret") })
|
|
18
|
+
*
|
|
19
|
+
* // Response values are always Redacted (safe):
|
|
20
|
+
* console.log(result.plain_text); // logs "<redacted>"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import * as Redacted from "effect/Redacted";
|
|
24
|
+
import * as S from "effect/Schema";
|
|
25
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
26
|
+
/**
|
|
27
|
+
* Sensitive - Marks data as sensitive, wrapping in Effect's Redacted type.
|
|
28
|
+
*
|
|
29
|
+
* This schema provides a convenient way to handle sensitive data:
|
|
30
|
+
* - TypeScript type: `A | Redacted.Redacted<A>` (accepts both for inputs)
|
|
31
|
+
* - Decode (responses): Always wraps wire value in Redacted
|
|
32
|
+
* - Encode (requests): Accepts BOTH raw values and Redacted, extracts the raw value
|
|
33
|
+
*
|
|
34
|
+
* The union type allows users to conveniently pass plain values for inputs while
|
|
35
|
+
* still getting proper Redacted types for outputs. Response values will always
|
|
36
|
+
* be Redacted, which prevents accidental logging.
|
|
37
|
+
*/
|
|
38
|
+
export const Sensitive = (schema) => schema
|
|
39
|
+
.pipe(S.decodeTo(S.Union([S.toType(schema), S.Redacted(S.toType(schema))]), SchemaTransformation.transform({
|
|
40
|
+
// Decode: wire format -> always wrap in Redacted
|
|
41
|
+
decode: (a) => Redacted.make(a),
|
|
42
|
+
// Encode: accept both raw and Redacted -> extract raw value
|
|
43
|
+
encode: (v) => (Redacted.isRedacted(v) ? Redacted.value(v) : v),
|
|
44
|
+
})))
|
|
45
|
+
.annotate({
|
|
46
|
+
identifier: `Sensitive<${schema.ast.annotations?.identifier ?? "unknown"}>`,
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Sensitive string - a string marked as sensitive.
|
|
50
|
+
* Wire format is plain string, TypeScript type is string | Redacted<string>.
|
|
51
|
+
* At runtime, decoded values are always Redacted<string>.
|
|
52
|
+
*/
|
|
53
|
+
export const SensitiveString = Sensitive(S.String).annotate({
|
|
54
|
+
identifier: "SensitiveString",
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Sensitive nullable string - a nullable string marked as sensitive.
|
|
58
|
+
* Wire format is plain string | null, TypeScript type is string | null | Redacted<string>.
|
|
59
|
+
* At runtime, decoded non-null values are always Redacted<string>.
|
|
60
|
+
*/
|
|
61
|
+
export const SensitiveNullableString = S.NullOr(SensitiveString).annotate({
|
|
62
|
+
identifier: "SensitiveNullableString",
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=sensitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,oBAAoB,MAAM,6BAA6B,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAmB,EACiB,EAAE,CACtC,MAAM;KACH,IAAI,CACH,CAAC,CAAC,QAAQ,CACR,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACzD,oBAAoB,CAAC,SAAS,CAAC;IAC7B,iDAAiD;IACjD,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAQ;IACtC,4DAA4D;IAC5D,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC,CACH,CACF;KACA,QAAQ,CAAC;IACR,UAAU,EAAE,aAAa,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,IAAI,SAAS,GAAG;CAC5E,CAAC,CAAC;AAEP;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC;IAC1D,UAAU,EAAE,iBAAiB;CAC9B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC;IACxE,UAAU,EAAE,yBAAyB;CACtC,CAAC,CAAC"}
|
package/lib/traits.d.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import * as AST from "effect/SchemaAST";
|
|
2
|
+
/**
|
|
3
|
+
* Internal symbol for annotation metadata storage.
|
|
4
|
+
*/
|
|
5
|
+
declare const annotationMetaSymbol: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Any type that has an .annotate() method returning itself.
|
|
8
|
+
* This includes Schema.Schema and Schema.PropertySignature.
|
|
9
|
+
*/
|
|
10
|
+
type Annotatable = {
|
|
11
|
+
annotate(annotations: unknown): Annotatable;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* An Annotation is a callable that can be used with .pipe() AND
|
|
15
|
+
* has symbol properties so it works directly with Schema.Struct/Class.
|
|
16
|
+
*
|
|
17
|
+
* The index signatures allow TypeScript to accept this as a valid annotations object.
|
|
18
|
+
*/
|
|
19
|
+
export interface Annotation {
|
|
20
|
+
<A extends Annotatable>(schema: A): A;
|
|
21
|
+
readonly [annotationMetaSymbol]: Array<{
|
|
22
|
+
symbol: symbol;
|
|
23
|
+
value: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
readonly [key: symbol]: unknown;
|
|
26
|
+
readonly [key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create an annotation builder for a given symbol and value.
|
|
30
|
+
* This is the core primitive used to build all trait annotations.
|
|
31
|
+
*/
|
|
32
|
+
export declare function makeAnnotation<T>(sym: symbol, value: T): Annotation;
|
|
33
|
+
/**
|
|
34
|
+
* Combine multiple annotations into one.
|
|
35
|
+
* Use when you need multiple annotations on the same schema.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const MyInput = Schema.Struct({
|
|
40
|
+
* id: Schema.String.pipe(T.all(T.PathParam(), T.Required())),
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function all(...annotations: Annotation[]): Annotation;
|
|
45
|
+
/** Symbol for HTTP operation metadata (method + path template) */
|
|
46
|
+
export declare const httpSymbol: unique symbol;
|
|
47
|
+
/** HTTP method type */
|
|
48
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
|
|
49
|
+
/** HTTP trait configuration */
|
|
50
|
+
export interface HttpTrait {
|
|
51
|
+
/** HTTP method */
|
|
52
|
+
method: HttpMethod;
|
|
53
|
+
/** Path template with {param} placeholders */
|
|
54
|
+
path: string;
|
|
55
|
+
/** Content type override (e.g., "multipart") */
|
|
56
|
+
contentType?: string;
|
|
57
|
+
/** Whether the request has a body (used by GCP generator) */
|
|
58
|
+
hasBody?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Http trait - defines the HTTP method and path template for an operation.
|
|
62
|
+
* Path parameters are specified using {paramName} syntax.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const GetDatabaseInput = Schema.Struct({
|
|
67
|
+
* organization: Schema.String.pipe(T.PathParam()),
|
|
68
|
+
* database: Schema.String.pipe(T.PathParam()),
|
|
69
|
+
* }).pipe(
|
|
70
|
+
* T.Http({ method: "GET", path: "/organizations/{organization}/databases/{database}" })
|
|
71
|
+
* );
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare const Http: (trait: HttpTrait) => Annotation;
|
|
75
|
+
/** Symbol for path parameter annotation */
|
|
76
|
+
export declare const pathParamSymbol: unique symbol;
|
|
77
|
+
/**
|
|
78
|
+
* PathParam trait - marks a field as a path parameter.
|
|
79
|
+
* The field name is used as the placeholder name in the path template.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const Input = Schema.Struct({
|
|
84
|
+
* organization: Schema.String.pipe(T.PathParam()),
|
|
85
|
+
* }).pipe(
|
|
86
|
+
* T.Http({ method: "GET", path: "/organizations/{organization}" })
|
|
87
|
+
* );
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare const PathParam: () => Annotation;
|
|
91
|
+
/** Symbol for query parameter annotation */
|
|
92
|
+
export declare const queryParamSymbol: unique symbol;
|
|
93
|
+
/**
|
|
94
|
+
* QueryParam trait - marks a field as a query parameter.
|
|
95
|
+
* Optionally specify a different wire name.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const Input = Schema.Struct({
|
|
100
|
+
* perPage: Schema.optional(Schema.Number).pipe(T.QueryParam("per_page")),
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare const QueryParam: (name?: string | undefined) => Annotation;
|
|
105
|
+
/** Symbol for header parameter annotation */
|
|
106
|
+
export declare const headerParamSymbol: unique symbol;
|
|
107
|
+
/**
|
|
108
|
+
* HeaderParam trait - marks a field as a header parameter.
|
|
109
|
+
* Specify the header name.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const Input = Schema.Struct({
|
|
114
|
+
* apiToken: Schema.String.pipe(T.HeaderParam("X-API-Token")),
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare const HeaderParam: (name: string) => Annotation;
|
|
119
|
+
/**
|
|
120
|
+
* HttpPath - alias for PathParam that also carries the wire name.
|
|
121
|
+
* Used in generated code: `Schema.String.pipe(T.HttpPath("account_id"))`
|
|
122
|
+
*/
|
|
123
|
+
export declare const HttpPath: (name: string) => Annotation;
|
|
124
|
+
/**
|
|
125
|
+
* HttpQuery - alias for QueryParam with an explicit wire name.
|
|
126
|
+
* Used in generated code: `Schema.optional(Schema.String).pipe(T.HttpQuery("per_page"))`
|
|
127
|
+
*/
|
|
128
|
+
export declare const HttpQuery: (name: string) => Annotation;
|
|
129
|
+
/**
|
|
130
|
+
* HttpHeader - alias for HeaderParam.
|
|
131
|
+
* Used in generated code: `Schema.String.pipe(T.HttpHeader("X-Custom-Header"))`
|
|
132
|
+
*/
|
|
133
|
+
export declare const HttpHeader: (name: string) => Annotation;
|
|
134
|
+
/** Symbol for HTTP body annotation */
|
|
135
|
+
export declare const httpBodySymbol: unique symbol;
|
|
136
|
+
/**
|
|
137
|
+
* HttpBody - marks a field as the raw HTTP body.
|
|
138
|
+
* Used for operations where a field IS the entire request body
|
|
139
|
+
* (not a named field within a JSON body).
|
|
140
|
+
*/
|
|
141
|
+
export declare const HttpBody: () => Annotation;
|
|
142
|
+
/** Symbol for form data file annotation */
|
|
143
|
+
export declare const httpFormDataFileSymbol: unique symbol;
|
|
144
|
+
/**
|
|
145
|
+
* HttpFormDataFile - marks a field as a file upload in multipart form data.
|
|
146
|
+
*/
|
|
147
|
+
export declare const HttpFormDataFile: () => Annotation;
|
|
148
|
+
/** Symbol for API error code mapping */
|
|
149
|
+
export declare const apiErrorCodeSymbol: unique symbol;
|
|
150
|
+
/**
|
|
151
|
+
* ApiErrorCode trait - maps an error class to an API error code.
|
|
152
|
+
* Used to match API error responses to typed error classes.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* class NotFoundError extends Schema.TaggedErrorClass<NotFoundError>()(
|
|
157
|
+
* "NotFoundError",
|
|
158
|
+
* { message: Schema.String },
|
|
159
|
+
* ).pipe(T.ApiErrorCode("not_found")) {}
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export declare const ApiErrorCode: (code: string) => Annotation;
|
|
163
|
+
/** Symbol for service metadata */
|
|
164
|
+
export declare const serviceSymbol: unique symbol;
|
|
165
|
+
/** Service metadata */
|
|
166
|
+
export interface ServiceTrait {
|
|
167
|
+
name: string;
|
|
168
|
+
version?: string;
|
|
169
|
+
baseUrl?: string;
|
|
170
|
+
/** GCP-specific: Root URL for the service */
|
|
171
|
+
rootUrl?: string;
|
|
172
|
+
/** GCP-specific: Service path appended to root URL */
|
|
173
|
+
servicePath?: string;
|
|
174
|
+
/** Allow additional properties for provider-specific metadata */
|
|
175
|
+
[key: string]: unknown;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Service trait - attaches service metadata to a schema.
|
|
179
|
+
*/
|
|
180
|
+
export declare const Service: (trait: ServiceTrait) => Annotation;
|
|
181
|
+
/**
|
|
182
|
+
* Get annotation value from an AST node, following encoding chain if needed.
|
|
183
|
+
*/
|
|
184
|
+
export declare const getAnnotation: <T>(ast: AST.AST, symbol: symbol) => T | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Get HTTP trait from a schema's AST.
|
|
187
|
+
*/
|
|
188
|
+
export declare const getHttpTrait: (ast: AST.AST) => HttpTrait | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Check if a PropertySignature has the pathParam annotation.
|
|
191
|
+
* Works for both PathParam() (annotation value = true) and HttpPath("wire_name") (annotation value = string).
|
|
192
|
+
*/
|
|
193
|
+
export declare const isPathParam: (prop: AST.PropertySignature) => boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Get query param name from a PropertySignature (returns true if unnamed, string if named).
|
|
196
|
+
*/
|
|
197
|
+
export declare const getQueryParam: (prop: AST.PropertySignature) => string | boolean | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Get header param name from a PropertySignature.
|
|
200
|
+
*/
|
|
201
|
+
export declare const getHeaderParam: (prop: AST.PropertySignature) => string | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Get API error code from an error class AST.
|
|
204
|
+
*/
|
|
205
|
+
export declare const getApiErrorCode: (ast: AST.AST) => string | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* Get service metadata from a schema's AST.
|
|
208
|
+
*/
|
|
209
|
+
export declare const getServiceTrait: (ast: AST.AST) => ServiceTrait | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Extract path parameters from a schema's struct properties.
|
|
212
|
+
* Returns an array of field names that have the PathParam annotation.
|
|
213
|
+
*/
|
|
214
|
+
export declare const getPathParams: (ast: AST.AST) => string[];
|
|
215
|
+
/**
|
|
216
|
+
* Build the request path by substituting path parameters into the template.
|
|
217
|
+
* Simple version that assumes input keys match template placeholders.
|
|
218
|
+
* For schema-aware path building (with camelCase → wire_name mapping), use buildPathFromSchema.
|
|
219
|
+
*/
|
|
220
|
+
export declare const buildPath: (template: string, input: Record<string, unknown>) => string;
|
|
221
|
+
/**
|
|
222
|
+
* Extract AST property signatures from a schema AST, following encoding chain and suspends.
|
|
223
|
+
*/
|
|
224
|
+
export declare const getStructProps: (ast: AST.AST) => AST.PropertySignature[];
|
|
225
|
+
/**
|
|
226
|
+
* Get the path parameter wire name from a PropertySignature.
|
|
227
|
+
* - For HttpPath("wire_name"), returns the wire name string.
|
|
228
|
+
* - For PathParam(), returns the property name (since annotation is `true`).
|
|
229
|
+
* - Returns undefined if not a path param.
|
|
230
|
+
*/
|
|
231
|
+
export declare const getPathParamWireName: (prop: AST.PropertySignature) => string | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* Result of categorizing a schema's input properties by their HTTP binding.
|
|
234
|
+
*/
|
|
235
|
+
export interface RequestParts {
|
|
236
|
+
/** Resolved path with all parameters substituted */
|
|
237
|
+
path: string;
|
|
238
|
+
/** Query parameters: wire_name → string value */
|
|
239
|
+
query: Record<string, string | string[]>;
|
|
240
|
+
/** Header parameters: header-name → string value */
|
|
241
|
+
headers: Record<string, string>;
|
|
242
|
+
/** Body: remaining non-path/query/header properties, with wire-name keys where applicable */
|
|
243
|
+
body: Record<string, unknown> | undefined;
|
|
244
|
+
/** Whether the body should use multipart/form-data */
|
|
245
|
+
isMultipart: boolean;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Schema-aware request builder. Categorizes input properties into path, query, header,
|
|
249
|
+
* and body parts using annotations on the schema AST.
|
|
250
|
+
*
|
|
251
|
+
* Handles camelCase → wire_name mapping for path params (HttpPath), query params (HttpQuery),
|
|
252
|
+
* and header params (HttpHeader).
|
|
253
|
+
*
|
|
254
|
+
* When `inputSchema` is provided, uses `Schema.encodeSync` to encode the input through the
|
|
255
|
+
* schema's encoding pipeline (e.g., `encodeKeys` for camelCase → snake_case mapping).
|
|
256
|
+
* The encoded output is used for body construction, ensuring wire-format key names.
|
|
257
|
+
*/
|
|
258
|
+
export declare const buildRequestParts: (ast: AST.AST, httpTrait: HttpTrait, input: Record<string, unknown>, inputSchema?: any) => RequestParts;
|
|
259
|
+
/**
|
|
260
|
+
* Helper to get a value from an object using a dot-separated path.
|
|
261
|
+
* Used for pagination traits and nested property access.
|
|
262
|
+
*/
|
|
263
|
+
export declare const getPath: (obj: unknown, path: string) => unknown;
|
|
264
|
+
export {};
|
|
265
|
+
//# sourceMappingURL=traits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAMxC;;GAEG;AACH,QAAA,MAAM,oBAAoB,eAAiD,CAAC;AAE5E;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,CAAC;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACtC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAE3E,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAQnE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CAAC,GAAG,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,CAoB5D;AAMD,kEAAkE;AAClE,eAAO,MAAM,UAAU,eAAsC,CAAC;AAE9D,uBAAuB;AACvB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MA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