@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.
- 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/lib/api.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as S from "effect/Schema";
|
|
5
|
+
import type * as AST from "effect/SchemaAST";
|
|
6
|
+
import type * as Stream from "effect/Stream";
|
|
7
|
+
import * as Pagination from "./pagination.ts";
|
|
8
|
+
import { type Policy as RetryPolicy } from "./retry.ts";
|
|
9
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
10
|
+
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
11
|
+
import type * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
12
|
+
import type * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
|
|
13
|
+
/**
|
|
14
|
+
* The view of an operation's config that protocols receive on every
|
|
15
|
+
* encode/decode call. The object is the same memoized config instance for
|
|
16
|
+
* every call to a given operation, so protocols can key per-operation
|
|
17
|
+
* preprocessing (handler construction, error maps) off its identity in a
|
|
18
|
+
* WeakMap.
|
|
19
|
+
*/
|
|
20
|
+
export interface ProtocolOperationConfig {
|
|
21
|
+
readonly input?: S.Top;
|
|
22
|
+
readonly output?: S.Top;
|
|
23
|
+
readonly errors?: ReadonlyArray<ApiErrorClass>;
|
|
24
|
+
/**
|
|
25
|
+
* The wire operation name (e.g. the Smithy operation shape name). RPC-style
|
|
26
|
+
* protocols address operations by name (AWS JSON's `X-Amz-Target`, AWS
|
|
27
|
+
* Query's `Action=`) and unwrap responses by it; REST protocols ignore it.
|
|
28
|
+
*/
|
|
29
|
+
readonly operationName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The smithy `smithy.api#endpoint` hostPrefix (e.g. `sync-` for Step
|
|
32
|
+
* Functions' StartSyncExecution). Protocols prepend it to the resolved
|
|
33
|
+
* endpoint host, substituting `{memberName}` labels from the input.
|
|
34
|
+
*/
|
|
35
|
+
readonly endpointHostPrefix?: string;
|
|
36
|
+
readonly pagination?: Pagination.PaginatedTrait;
|
|
37
|
+
}
|
|
38
|
+
declare const Protocol_base: Context.ServiceClass<Protocol, "Protocol", {
|
|
39
|
+
readonly encode: (args: {
|
|
40
|
+
readonly input: unknown;
|
|
41
|
+
readonly inputAst: AST.AST;
|
|
42
|
+
/** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
|
|
43
|
+
readonly config: ProtocolOperationConfig;
|
|
44
|
+
}) => Effect.Effect<HttpClientRequest.HttpClientRequest>;
|
|
45
|
+
readonly decode: (args: {
|
|
46
|
+
readonly response: HttpClientResponse.HttpClientResponse;
|
|
47
|
+
readonly outputAst: AST.AST;
|
|
48
|
+
/**
|
|
49
|
+
* The operation's declared error classes (from `OperationConfig.errors`).
|
|
50
|
+
* Protocols use these to surface wire failures as the operation's typed
|
|
51
|
+
* errors — e.g. by consulting matcher metadata stamped on the class.
|
|
52
|
+
*/
|
|
53
|
+
readonly errors: ReadonlyArray<ApiErrorClass>;
|
|
54
|
+
/** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
|
|
55
|
+
readonly config: ProtocolOperationConfig;
|
|
56
|
+
}) => Effect.Effect<unknown>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* The Protocol service knows how to turn a value into an HTTP request using
|
|
60
|
+
* only the input schema's trait annotations, and how to turn a response back
|
|
61
|
+
* into an output value using the output schema's trait annotations.
|
|
62
|
+
*
|
|
63
|
+
* Swap implementations by providing a different `Layer<Protocol>`.
|
|
64
|
+
*/
|
|
65
|
+
export declare class Protocol extends Protocol_base {
|
|
66
|
+
}
|
|
67
|
+
export type ApiErrorClass = {
|
|
68
|
+
new (...args: any[]): {
|
|
69
|
+
readonly _tag: string;
|
|
70
|
+
readonly message: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The shape of a generated SDK operation — usable two ways (mirrors the
|
|
75
|
+
* distilled repo's OperationMethod):
|
|
76
|
+
*
|
|
77
|
+
* 1. Direct call: `yield* operation(input)` — an Effect with requirements.
|
|
78
|
+
* 2. Yield first: `const fn = yield* operation` — captures the current
|
|
79
|
+
* context and returns a requirement-free call function.
|
|
80
|
+
*
|
|
81
|
+
* Generated service files annotate every exported operation with this type
|
|
82
|
+
* explicitly (against their hand-emitted interfaces), so the compiler never
|
|
83
|
+
* has to infer it back out of the schema generics.
|
|
84
|
+
*/
|
|
85
|
+
export type OperationMethod<I, O, E, R> = Effect.Effect<(input: I) => Effect.Effect<O, E, never>, never, R> & ((input: I) => Effect.Effect<O, E, R>);
|
|
86
|
+
export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> {
|
|
87
|
+
input?: I;
|
|
88
|
+
output?: O;
|
|
89
|
+
errors?: E;
|
|
90
|
+
/**
|
|
91
|
+
* The protocol layer that knows how to encode/decode this operation's wire
|
|
92
|
+
* format. Built once per process and shared across all operations that
|
|
93
|
+
* reference the same layer value — it must resolve call-dependent services
|
|
94
|
+
* (credentials etc.) inside encode/decode, not at build time.
|
|
95
|
+
*/
|
|
96
|
+
protocol: Layer.Layer<Protocol, PE, PR>;
|
|
97
|
+
/**
|
|
98
|
+
* SDK-specific retry service tag (see `core/retry`). When provided and the
|
|
99
|
+
* caller's context carries a policy under this tag, every call is retried
|
|
100
|
+
* per that policy (e.g. `Layer.succeed(Cloudflare.Retry.Retry, factory)`).
|
|
101
|
+
*/
|
|
102
|
+
retry?: Context.Key<any, RetryPolicy>;
|
|
103
|
+
/**
|
|
104
|
+
* The wire operation name for RPC-style protocols (see
|
|
105
|
+
* {@link ProtocolOperationConfig.operationName}).
|
|
106
|
+
*/
|
|
107
|
+
operationName?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Host prefix from the smithy endpoint trait (see
|
|
110
|
+
* {@link ProtocolOperationConfig.endpointHostPrefix}).
|
|
111
|
+
*/
|
|
112
|
+
endpointHostPrefix?: string;
|
|
113
|
+
}
|
|
114
|
+
export declare function make<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E>): OperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, InstanceType<E[number]> | PE | HttpClientError.HttpClientError, PR | HttpClient.HttpClient>;
|
|
115
|
+
/**
|
|
116
|
+
* STRUCTURAL fallback for the element type `.items()` yields: the array
|
|
117
|
+
* element of the page response itself, or of its `result` member.
|
|
118
|
+
*
|
|
119
|
+
* It can only see shapes it was taught, so any other envelope
|
|
120
|
+
* (`{ branches: […] }`, `{ data: […] }`, …) lands on `unknown` — which is
|
|
121
|
+
* why generators pass the item type EXPLICITLY as
|
|
122
|
+
* {@link PaginatedOperationMethod}'s `Item` argument, resolved from the
|
|
123
|
+
* pagination trait's `items` path against the response shape. This default
|
|
124
|
+
* only applies to hand-written operations.
|
|
125
|
+
*/
|
|
126
|
+
export type PaginatedItem<A> = A extends ReadonlyArray<infer Item> ? Item : A extends {
|
|
127
|
+
result: ReadonlyArray<infer Item>;
|
|
128
|
+
} ? Item : A extends {
|
|
129
|
+
result?: ReadonlyArray<infer Item> | null | undefined;
|
|
130
|
+
} ? Item : unknown;
|
|
131
|
+
/**
|
|
132
|
+
* The callable half of a paginated operation: the operation call itself, plus
|
|
133
|
+
* `.pages(input)` streaming every page response and `.items(input)` streaming
|
|
134
|
+
* the individual items across pages.
|
|
135
|
+
*
|
|
136
|
+
* Used twice in {@link PaginatedOperationMethod} — once with the operation's
|
|
137
|
+
* requirements (`R`) for the direct-call style, once with `R = never` for the
|
|
138
|
+
* value `yield* operation` hands back, which has the caller's context baked in.
|
|
139
|
+
*/
|
|
140
|
+
export interface PaginatedCall<I, O, E, R, Item> {
|
|
141
|
+
(input: I): Effect.Effect<O, E, R>;
|
|
142
|
+
readonly pages: (input: I) => Stream.Stream<O, E, R>;
|
|
143
|
+
readonly items: (input: I) => Stream.Stream<Item, E, R>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A paginated operation: usable both ways an {@link OperationMethod} is, with
|
|
147
|
+
* `.pages` / `.items` on BOTH — the operation object for
|
|
148
|
+
* `yield* op.items(input)`, and the requirement-free call function for
|
|
149
|
+
* `const op = yield* operation; yield* op.items(input)` (distilled #145).
|
|
150
|
+
*/
|
|
151
|
+
export type PaginatedOperationMethod<I, O, E, R, Item = PaginatedItem<O>> = Effect.Effect<PaginatedCall<I, O, E, never, Item>, never, R> & PaginatedCall<I, O, E, R, Item>;
|
|
152
|
+
export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, PE, PR, E> {
|
|
153
|
+
/** How to advance between pages (mirrors the `smithy.api#paginated` trait). */
|
|
154
|
+
pagination: Pagination.PaginatedTrait;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Like {@link make}, plus `.pages()` / `.items()` streaming built on the
|
|
158
|
+
* operation's pagination trait. The SDK can pass a provider-specific
|
|
159
|
+
* {@link Pagination.PaginationStrategy} (e.g. Cloudflare stops page-mode
|
|
160
|
+
* traversal on the first empty page); the default dispatches on
|
|
161
|
+
* `pagination.mode`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function makePaginated<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, PE, PR, E>, strategy?: Pagination.PaginationStrategy): PaginatedOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, InstanceType<E[number]> | PE | HttpClientError.HttpClientError, PR | HttpClient.HttpClient>;
|
|
164
|
+
export {};
|
|
165
|
+
//# sourceMappingURL=api.d.ts.map
|
package/lib/api.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAI7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAe,KAAK,MAAM,IAAI,WAAW,EAAE,MAAM,YAAY,C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C,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC,eAAe,EAC9D,EAAE,GAAG,UAAU,CAAC,UAAU,CAC3B,CAsCA"}
|
package/lib/api.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as S from "effect/Schema";
|
|
6
|
+
import { pipeArguments } from "effect/Pipeable";
|
|
7
|
+
import * as Ref from "effect/Ref";
|
|
8
|
+
import * as Scope from "effect/Scope";
|
|
9
|
+
import { SingleShotGen } from "effect/Utils";
|
|
10
|
+
import * as Pagination from "./pagination.js";
|
|
11
|
+
import { makeDefault } from "./retry.js";
|
|
12
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
13
|
+
/**
|
|
14
|
+
* The Protocol service knows how to turn a value into an HTTP request using
|
|
15
|
+
* only the input schema's trait annotations, and how to turn a response back
|
|
16
|
+
* into an output value using the output schema's trait annotations.
|
|
17
|
+
*
|
|
18
|
+
* Swap implementations by providing a different `Layer<Protocol>`.
|
|
19
|
+
*/
|
|
20
|
+
export class Protocol extends Context.Service()("Protocol") {
|
|
21
|
+
}
|
|
22
|
+
// NOTE: request/response ASTs are handed to the protocol RAW (Suspend nodes
|
|
23
|
+
// included). Pre-resolving Suspends here would drop annotations that sit on
|
|
24
|
+
// intermediate nodes — e.g. a bare-payload response whose payload type is
|
|
25
|
+
// itself a suspended schema carries its EnvelopePayloadRoot marker on the
|
|
26
|
+
// inner Suspend, and unwrapping it silently degrades decode to the struct
|
|
27
|
+
// path. The protocol helpers (core/protocol-http getAnn/getProps) descend
|
|
28
|
+
// Suspends themselves, and `Suspend.thunk` memoizes, so raw ASTs cost
|
|
29
|
+
// nothing extra.
|
|
30
|
+
/**
|
|
31
|
+
* Protocol layers are built once per process and shared by every operation
|
|
32
|
+
* call (keyed by layer value identity — generated operations all reference the
|
|
33
|
+
* same module-level layer const). The build runs against a process-lifetime
|
|
34
|
+
* scope, and concurrent first calls are deduplicated through a private
|
|
35
|
+
* MemoMap.
|
|
36
|
+
*
|
|
37
|
+
* Contract for protocol implementations: the layer build must not capture
|
|
38
|
+
* per-call context. Anything call-dependent — credentials, per-request
|
|
39
|
+
* options — must be resolved inside `encode`/`decode`, which execute on the
|
|
40
|
+
* calling fiber and therefore see the caller's services on every request.
|
|
41
|
+
*/
|
|
42
|
+
const protocolMemoMap = Layer.makeMemoMapUnsafe();
|
|
43
|
+
const protocolScope = Scope.makeUnsafe();
|
|
44
|
+
const protocolContexts = new WeakMap();
|
|
45
|
+
const protocolContext = (layer) => {
|
|
46
|
+
const cached = protocolContexts.get(layer);
|
|
47
|
+
if (cached)
|
|
48
|
+
return Effect.succeed(cached);
|
|
49
|
+
return Effect.map(Layer.buildWithMemoMap(layer, protocolMemoMap, protocolScope), (ctx) => {
|
|
50
|
+
protocolContexts.set(layer, ctx);
|
|
51
|
+
return ctx;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Wrap one operation call with the caller-provided retry policy, if the
|
|
56
|
+
* operation declares a retry tag and the context carries a policy for it.
|
|
57
|
+
*/
|
|
58
|
+
const applyRetry = (base, retryKey) => retryKey === undefined
|
|
59
|
+
? base
|
|
60
|
+
: Effect.flatMap(Effect.serviceOption(retryKey), (opt) => Effect.gen(function* () {
|
|
61
|
+
const lastError = yield* Ref.make(undefined);
|
|
62
|
+
// No policy in context → makeDefault (transient/throttling/server
|
|
63
|
+
// errors, capped exponential backoff + jitter, honors server
|
|
64
|
+
// retryAfter hints). Mirrors the distilled client.
|
|
65
|
+
const policy = Option.isSome(opt) ? opt.value : makeDefault;
|
|
66
|
+
const opts = typeof policy === "function" ? policy(lastError) : policy;
|
|
67
|
+
if (!opts.while)
|
|
68
|
+
return yield* base;
|
|
69
|
+
return yield* base.pipe(Effect.tapError((e) => Ref.set(lastError, e)), Effect.retry({
|
|
70
|
+
while: (e) => opts.while(e),
|
|
71
|
+
...(opts.schedule ? { schedule: opts.schedule } : {}),
|
|
72
|
+
}));
|
|
73
|
+
}));
|
|
74
|
+
export function make(configFn) {
|
|
75
|
+
let prepared;
|
|
76
|
+
const prepare = () => {
|
|
77
|
+
if (prepared)
|
|
78
|
+
return prepared;
|
|
79
|
+
const cfg = configFn();
|
|
80
|
+
prepared = {
|
|
81
|
+
cfg,
|
|
82
|
+
inputAst: cfg.input.ast,
|
|
83
|
+
outputAst: cfg.output.ast,
|
|
84
|
+
};
|
|
85
|
+
return prepared;
|
|
86
|
+
};
|
|
87
|
+
const fn = (input) => Effect.suspend(() => {
|
|
88
|
+
const { cfg, inputAst, outputAst } = prepare();
|
|
89
|
+
const call = Effect.flatMap(protocolContext(cfg.protocol), (protocolCtx) => Effect.gen(function* () {
|
|
90
|
+
const protocol = yield* Protocol;
|
|
91
|
+
const client = yield* HttpClient.HttpClient;
|
|
92
|
+
const request = yield* protocol.encode({
|
|
93
|
+
input,
|
|
94
|
+
inputAst,
|
|
95
|
+
config: cfg,
|
|
96
|
+
});
|
|
97
|
+
const response = yield* client.execute(request);
|
|
98
|
+
return yield* protocol.decode({
|
|
99
|
+
response,
|
|
100
|
+
outputAst,
|
|
101
|
+
errors: cfg.errors ?? [],
|
|
102
|
+
config: cfg,
|
|
103
|
+
});
|
|
104
|
+
}).pipe(Effect.provideContext(protocolCtx)));
|
|
105
|
+
return applyRetry(call, cfg.retry);
|
|
106
|
+
});
|
|
107
|
+
// Make the operation itself yieldable: `yield* operation` captures the
|
|
108
|
+
// current context and returns a requirement-free call function (mirrors
|
|
109
|
+
// the distilled repo's OperationMethod).
|
|
110
|
+
const Proto = {
|
|
111
|
+
[Symbol.iterator]() {
|
|
112
|
+
return new SingleShotGen(this.asEffect());
|
|
113
|
+
},
|
|
114
|
+
pipe() {
|
|
115
|
+
return pipeArguments(this.asEffect(), arguments);
|
|
116
|
+
},
|
|
117
|
+
asEffect() {
|
|
118
|
+
return Effect.map(Effect.context(), (context) => (input) => Effect.provideContext(fn(input), context));
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
Object.assign(fn, Proto);
|
|
122
|
+
// Debug/introspection surface carried over from the distilled client:
|
|
123
|
+
// the operation's metadata is readable off the exported callable
|
|
124
|
+
// (e.g. `iam.listRoles.input` / `.output` / `.errors` / `.operationName`
|
|
125
|
+
// / `.pagination`). Lazy getters, so importing a service module doesn't
|
|
126
|
+
// force its suspended schemas.
|
|
127
|
+
Object.defineProperties(fn, {
|
|
128
|
+
input: { get: () => prepare().cfg.input, configurable: true },
|
|
129
|
+
output: { get: () => prepare().cfg.output, configurable: true },
|
|
130
|
+
errors: { get: () => prepare().cfg.errors ?? [], configurable: true },
|
|
131
|
+
operationName: {
|
|
132
|
+
get: () => prepare().cfg.operationName,
|
|
133
|
+
configurable: true,
|
|
134
|
+
},
|
|
135
|
+
pagination: {
|
|
136
|
+
get: () => prepare().cfg.pagination,
|
|
137
|
+
configurable: true,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
return fn;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Like {@link make}, plus `.pages()` / `.items()` streaming built on the
|
|
144
|
+
* operation's pagination trait. The SDK can pass a provider-specific
|
|
145
|
+
* {@link Pagination.PaginationStrategy} (e.g. Cloudflare stops page-mode
|
|
146
|
+
* traversal on the first empty page); the default dispatches on
|
|
147
|
+
* `pagination.mode`.
|
|
148
|
+
*/
|
|
149
|
+
export function makePaginated(configFn, strategy) {
|
|
150
|
+
const fn = make(configFn);
|
|
151
|
+
// configFn is a cheap object literal over already-constructed consts —
|
|
152
|
+
// re-invoking it here just reads the pagination trait (memoized).
|
|
153
|
+
let pagination;
|
|
154
|
+
const pag = () => (pagination ??= configFn().pagination);
|
|
155
|
+
const paginate = strategy ?? Pagination.paginateWithDefaults;
|
|
156
|
+
// The streams are built over a CALL FUNCTION, so the same code serves both
|
|
157
|
+
// call styles: the operation itself (requirements intact), and the
|
|
158
|
+
// context-bound function `yield* operation` hands back — whose streams
|
|
159
|
+
// inherit that captured context and so need nothing after the yield.
|
|
160
|
+
const withStreams = (call) => {
|
|
161
|
+
const pages = (input) => paginate(call, input, pag());
|
|
162
|
+
const items = (input) => {
|
|
163
|
+
const p = pag();
|
|
164
|
+
return p.items
|
|
165
|
+
? Pagination.extractItems(pages(input), p.items)
|
|
166
|
+
: pages(input);
|
|
167
|
+
};
|
|
168
|
+
return Object.assign(call, { pages, items });
|
|
169
|
+
};
|
|
170
|
+
// `yield* operation` runs through `make`'s Proto.asEffect, which builds a
|
|
171
|
+
// fresh arrow and would drop `.pages` / `.items` (distilled #145). Override
|
|
172
|
+
// it here — Proto's `[Symbol.iterator]`/`pipe` dispatch on `this`, so both
|
|
173
|
+
// pick this up. Only paginated operations pay for it.
|
|
174
|
+
fn.asEffect = () => Effect.map(Effect.context(), (context) => withStreams((input) => Effect.provideContext(fn(input), context)));
|
|
175
|
+
return withStreams(fn);
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//# sourceMappingURL=api.js.map
|
package/lib/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,K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AAc,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAC1C,CACF,CAAC;IAEJ,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC;AAED,YAAY"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type SdkSpec } from "./generator.ts";
|
|
2
|
+
export interface GeneratorCliOptions {
|
|
3
|
+
/** Command description shown in --help. */
|
|
4
|
+
readonly description: string;
|
|
5
|
+
/** Absolute package root (usually `path.resolve(import.meta.dir, "..")`). */
|
|
6
|
+
readonly root: string;
|
|
7
|
+
/** Model directory default (relative to root). Default `.generated-specs`. */
|
|
8
|
+
readonly smithyDir?: string;
|
|
9
|
+
/** Output directory default (relative to root). Default `src/services`. */
|
|
10
|
+
readonly outDir?: string;
|
|
11
|
+
/** Model files to skip (e.g. a shared protocols model). */
|
|
12
|
+
readonly excludeModel?: (file: string) => boolean;
|
|
13
|
+
/** Directory of hand-authored models merged after the generated ones. */
|
|
14
|
+
readonly manualSpecsDir?: string;
|
|
15
|
+
/** RFC-6902 patch chain root. Default `patches`; `false` disables. */
|
|
16
|
+
readonly patchesDir?: string | false;
|
|
17
|
+
/**
|
|
18
|
+
* Model transform applied AFTER the patch chain, before generation —
|
|
19
|
+
* for whole-model rewrites that must see post-patch shape names (e.g.
|
|
20
|
+
* cloudflare's scope-twin structural dedup). May mutate the model;
|
|
21
|
+
* a returned log line is printed.
|
|
22
|
+
*/
|
|
23
|
+
readonly transformModel?: (model: any, resource: string) => string | void;
|
|
24
|
+
/** The provider spec — built per model (metadata may vary per model). */
|
|
25
|
+
readonly spec: (model: any) => SdkSpec;
|
|
26
|
+
}
|
|
27
|
+
/** Run the generator CLI (BunRuntime main — call at module top level). */
|
|
28
|
+
export declare const runGeneratorCli: (options: GeneratorCliOptions) => void;
|
|
29
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/codegen/cli.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAClD,yEAAyE;IACzE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC1E,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;CACxC;AAED,0EAA0E;AAC1E,eAAO,MAAM,eAAe,YAAa,mBAAmB,KAAG,IAoN9D,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generic generator CLI harness (dev-time only).
|
|
3
|
+
*
|
|
4
|
+
* Owns the smithy-model pipeline every SDK package shares: scan the model
|
|
5
|
+
* directory (plus optional hand-authored manual specs), apply the RFC-6902
|
|
6
|
+
* patch chain (`patches/<resource>/*.json`, `*.manual.json` last; stale
|
|
7
|
+
* targets warn, malformed patches fail the run), compile each model through
|
|
8
|
+
* {@link generateService} with the provider's {@link SdkSpec}, write the
|
|
9
|
+
* service modules and the namespaced barrel.
|
|
10
|
+
*
|
|
11
|
+
* A provider's `scripts/generate.ts` is: trait consts + an SdkSpec + a
|
|
12
|
+
* `runGeneratorCli` call.
|
|
13
|
+
*/
|
|
14
|
+
import { BunRuntime, BunServices } from "@effect/platform-bun";
|
|
15
|
+
import { Console, Effect } from "effect";
|
|
16
|
+
import * as FileSystem from "effect/FileSystem";
|
|
17
|
+
import * as Path from "effect/Path";
|
|
18
|
+
import { Flag } from "effect/unstable/cli";
|
|
19
|
+
import { Command } from "effect/unstable/cli";
|
|
20
|
+
import { applyOperation, isStaleTargetError, } from "../json-patch.js";
|
|
21
|
+
import { barrel } from "./emit.js";
|
|
22
|
+
import { formatGenerated } from "./format.js";
|
|
23
|
+
import { generateService } from "./generator.js";
|
|
24
|
+
/** Run the generator CLI (BunRuntime main — call at module top level). */
|
|
25
|
+
export const runGeneratorCli = (options) => {
|
|
26
|
+
const command = Command.make("generate", {
|
|
27
|
+
smithy: Flag.string("smithy").pipe(Flag.withDefault(options.smithyDir ?? ".generated-specs"), Flag.withDescription("Directory of Smithy JSON models")),
|
|
28
|
+
out: Flag.string("out").pipe(Flag.withDefault(options.outDir ?? "src/services"), Flag.withDescription("Output directory for generated service modules")),
|
|
29
|
+
resource: Flag.string("resource").pipe(Flag.withDefault(""), Flag.withDescription("Only generate this resource (e.g. ai)")),
|
|
30
|
+
}, (config) => Effect.gen(function* () {
|
|
31
|
+
const fs = yield* FileSystem.FileSystem;
|
|
32
|
+
const path = yield* Path.Path;
|
|
33
|
+
const root = options.root;
|
|
34
|
+
const smithyDir = path.resolve(root, config.smithy);
|
|
35
|
+
const outDir = path.resolve(root, config.out);
|
|
36
|
+
yield* Console.log("⚙️ generate");
|
|
37
|
+
yield* Console.log(` Smithy: ${smithyDir}`);
|
|
38
|
+
yield* Console.log(` Output: ${outDir}`);
|
|
39
|
+
// Generated models plus optional manual-specs (hand-authored models
|
|
40
|
+
// for APIs the provider's spec source doesn't cover). A manual model
|
|
41
|
+
// must not shadow a generated one.
|
|
42
|
+
const generated = (yield* fs.readDirectory(smithyDir))
|
|
43
|
+
.filter((f) => f.endsWith(".json") && !(options.excludeModel?.(f) ?? false))
|
|
44
|
+
.map((f) => ({ file: f, dir: smithyDir }));
|
|
45
|
+
const manualDir = options.manualSpecsDir
|
|
46
|
+
? path.resolve(root, options.manualSpecsDir)
|
|
47
|
+
: undefined;
|
|
48
|
+
const manual = manualDir && (yield* fs.exists(manualDir))
|
|
49
|
+
? (yield* fs.readDirectory(manualDir))
|
|
50
|
+
.filter((f) => f.endsWith(".json"))
|
|
51
|
+
.map((f) => ({ file: f, dir: manualDir }))
|
|
52
|
+
: [];
|
|
53
|
+
for (const m of manual) {
|
|
54
|
+
if (generated.some((g) => g.file === m.file)) {
|
|
55
|
+
return yield* Effect.die(new Error(`${options.manualSpecsDir}/${m.file} shadows a generated model — rename or delete it`));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const entries = [...generated, ...manual].sort((a, b) => a.file.localeCompare(b.file));
|
|
59
|
+
yield* fs.makeDirectory(outDir, { recursive: true });
|
|
60
|
+
const written = [];
|
|
61
|
+
let totalOps = 0;
|
|
62
|
+
let totalPatches = 0;
|
|
63
|
+
let staleOps = 0;
|
|
64
|
+
const badPatches = [];
|
|
65
|
+
// Orphan check: a patch directory matching no smithy model would be
|
|
66
|
+
// silently dropped — flag it instead.
|
|
67
|
+
const patchRoot = options.patchesDir === false
|
|
68
|
+
? undefined
|
|
69
|
+
: path.join(root, options.patchesDir ?? "patches");
|
|
70
|
+
if (patchRoot && (yield* fs.exists(patchRoot))) {
|
|
71
|
+
const resources = new Set(entries.map((e) => e.file.replace(/\.json$/, "")));
|
|
72
|
+
for (const dir of yield* fs.readDirectory(patchRoot)) {
|
|
73
|
+
if (!resources.has(dir)) {
|
|
74
|
+
yield* Console.warn(`⚠️ patches/${dir}/ matches no smithy model — orphaned?`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const { file, dir } of entries) {
|
|
79
|
+
const resource = file.replace(/\.json$/, "");
|
|
80
|
+
if (config.resource && resource !== config.resource)
|
|
81
|
+
continue;
|
|
82
|
+
const model = JSON.parse(yield* fs.readFileString(path.join(dir, file)));
|
|
83
|
+
// Apply the RFC-6902 patch chain before generating. Hand-written
|
|
84
|
+
// *.manual.json patches apply after the generated ones — they
|
|
85
|
+
// usually target post-rename shape names.
|
|
86
|
+
const patchDir = patchRoot && path.join(patchRoot, resource);
|
|
87
|
+
if (patchDir && (yield* fs.exists(patchDir))) {
|
|
88
|
+
const patchFiles = (yield* fs.readDirectory(patchDir))
|
|
89
|
+
.filter((f) => f.endsWith(".json"))
|
|
90
|
+
.sort((a, b) => Number(a.endsWith(".manual.json")) -
|
|
91
|
+
Number(b.endsWith(".manual.json")) || a.localeCompare(b));
|
|
92
|
+
for (const pf of patchFiles) {
|
|
93
|
+
const parsed = JSON.parse(yield* fs.readFileString(path.join(patchDir, pf)));
|
|
94
|
+
for (const patchOp of parsed.patches ?? []) {
|
|
95
|
+
try {
|
|
96
|
+
applyOperation(model, patchOp);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
100
|
+
if (isStaleTargetError(msg)) {
|
|
101
|
+
staleOps++;
|
|
102
|
+
yield* Console.warn(` ⚠️ stale: ${resource}/${pf} [${patchOp.op} ${patchOp.path}]`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
badPatches.push(`${resource}/${pf} [${patchOp.op} ${patchOp.path}]: ${msg}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
totalPatches++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (options.transformModel) {
|
|
113
|
+
const note = options.transformModel(model, resource);
|
|
114
|
+
if (note)
|
|
115
|
+
yield* Console.log(` ${note}`);
|
|
116
|
+
}
|
|
117
|
+
const { code, operations } = generateService(model, options.spec(model));
|
|
118
|
+
if (operations === 0)
|
|
119
|
+
continue;
|
|
120
|
+
yield* fs.writeFileString(path.join(outDir, `${resource}.ts`), code);
|
|
121
|
+
written.push(resource);
|
|
122
|
+
totalOps += operations;
|
|
123
|
+
}
|
|
124
|
+
if (badPatches.length) {
|
|
125
|
+
for (const b of badPatches) {
|
|
126
|
+
yield* Console.error(`❌ bad patch: ${b}`);
|
|
127
|
+
}
|
|
128
|
+
return yield* Effect.die(new Error(`${badPatches.length} malformed patch operation(s) — fix or remove them`));
|
|
129
|
+
}
|
|
130
|
+
// Barrel — namespace per resource to avoid op-name collisions.
|
|
131
|
+
//
|
|
132
|
+
// A FULL run is authoritative: the barrel is exactly what was
|
|
133
|
+
// generated, so a resource whose model went away drops out of it.
|
|
134
|
+
//
|
|
135
|
+
// A `--resource` run only knows about the resource it generated, so
|
|
136
|
+
// rewriting the barrel from that would delete every other export —
|
|
137
|
+
// which is how #397 shipped a cloudflare barrel exporting `workers`
|
|
138
|
+
// and nothing else, silently dropping 119 services. Merge into the
|
|
139
|
+
// existing barrel instead, so `--resource` can still ADD a brand-new
|
|
140
|
+
// resource without removing anything.
|
|
141
|
+
const barrelPath = path.join(outDir, "index.ts");
|
|
142
|
+
const filtered = config.resource !== "";
|
|
143
|
+
let resources = written;
|
|
144
|
+
if (filtered && (yield* fs.exists(barrelPath))) {
|
|
145
|
+
const existing = (yield* fs.readFileString(barrelPath))
|
|
146
|
+
.split("\n")
|
|
147
|
+
.map((line) => /^export \* as (\S+) from/.exec(line)?.[1])
|
|
148
|
+
.filter((name) => name !== undefined);
|
|
149
|
+
// Ordered exactly as a full run orders it: by MODEL FILENAME, so
|
|
150
|
+
// the `.json` takes part in the collation (`ai_gateway.json` sorts
|
|
151
|
+
// before `ai.json`, where the bare names sort the other way).
|
|
152
|
+
// Otherwise a filtered run reshuffles the barrel into diff noise.
|
|
153
|
+
resources = [...new Set([...existing, ...written])].sort((a, b) => `${a}.json`.localeCompare(`${b}.json`));
|
|
154
|
+
}
|
|
155
|
+
yield* fs.writeFileString(barrelPath, barrel(`// AUTO-GENERATED by scripts/generate.ts. Do not edit.\n`, resources.map((r) => ({ name: r, path: `./${r}.ts` }))));
|
|
156
|
+
yield* formatGenerated(outDir);
|
|
157
|
+
yield* Console.log(`\n✅ Generated ${totalOps} operations across ${written.length} resource modules` +
|
|
158
|
+
(totalPatches
|
|
159
|
+
? ` (${totalPatches} patch files applied${staleOps ? `, ${staleOps} stale op(s) skipped` : ""}).`
|
|
160
|
+
: "."));
|
|
161
|
+
yield* Console.log(` ${path.join(outDir, "index.ts")}`);
|
|
162
|
+
})).pipe(Command.withDescription(options.description));
|
|
163
|
+
BunRuntime.runMain(Effect.provide(Command.run(command, { version: "1.0.0" }), BunServices.layer));
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/codegen/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,kBAAkB,GAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAgB,MAAM,gBAAgB,CAAC;AA4B/D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,eAAe,GAAG,CAA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