@distilled.cloud/core 1.0.0-rc.16 → 1.0.0-rc.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/lib/_bundle/aws.js +2 -0
  2. package/lib/_bundle/aws.js.map +1 -0
  3. package/lib/_bundle/base.js +5 -0
  4. package/lib/_bundle/base.js.map +1 -0
  5. package/lib/_bundle/graphql.js +3 -0
  6. package/lib/_bundle/graphql.js.map +1 -0
  7. package/lib/_bundle/rest.js +2 -0
  8. package/lib/_bundle/rest.js.map +1 -0
  9. package/lib/_bundle/xml.js +4 -0
  10. package/lib/_bundle/xml.js.map +1 -0
  11. package/lib/api.d.ts.map +1 -1
  12. package/lib/api.js +1 -796
  13. package/lib/category.js +1 -278
  14. package/lib/chunks.js +1 -11
  15. package/lib/config.js +1 -161
  16. package/lib/crypto.js +1 -130
  17. package/lib/debug.js +1 -8
  18. package/lib/error-category.js +1 -47
  19. package/lib/errors.js +1 -198
  20. package/lib/graphql.js +1 -1058
  21. package/lib/graphql.types.js +1 -6
  22. package/lib/index.js +0 -15
  23. package/lib/json-patch.js +1 -226
  24. package/lib/json-patch.js.map +1 -1
  25. package/lib/pagination.js +1 -271
  26. package/lib/plain-values.js +1 -39
  27. package/lib/plain-values.js.map +1 -1
  28. package/lib/protocol-http.js +1 -812
  29. package/lib/protocol-rest.js +1 -375
  30. package/lib/query.js +1 -27
  31. package/lib/response-validation-strict.js +1 -284
  32. package/lib/response-validation.js +1 -118
  33. package/lib/retry-after.js +1 -112
  34. package/lib/retry.js +1 -197
  35. package/lib/schema-lite-impl.js +1 -341
  36. package/lib/schema-lite-typed.js +1 -26
  37. package/lib/schema-lite-typed.js.map +1 -1
  38. package/lib/schema-lite.js +1 -31
  39. package/lib/schema.js +1 -220
  40. package/lib/testing.js +1 -41
  41. package/lib/testing.js.map +1 -1
  42. package/lib/trait.js +1 -131
  43. package/lib/xml.js +1 -323
  44. package/package.json +1 -1
  45. package/src/api.ts +7 -6
  46. package/lib/api.js.map +0 -1
  47. package/lib/category.js.map +0 -1
  48. package/lib/chunks.js.map +0 -1
  49. package/lib/config.js.map +0 -1
  50. package/lib/crypto.js.map +0 -1
  51. package/lib/debug.js.map +0 -1
  52. package/lib/error-category.js.map +0 -1
  53. package/lib/errors.js.map +0 -1
  54. package/lib/graphql.js.map +0 -1
  55. package/lib/graphql.types.js.map +0 -1
  56. package/lib/index.js.map +0 -1
  57. package/lib/pagination.js.map +0 -1
  58. package/lib/protocol-http.js.map +0 -1
  59. package/lib/protocol-rest.js.map +0 -1
  60. package/lib/query.js.map +0 -1
  61. package/lib/response-validation-strict.js.map +0 -1
  62. package/lib/response-validation.js.map +0 -1
  63. package/lib/retry-after.js.map +0 -1
  64. package/lib/retry.js.map +0 -1
  65. package/lib/schema-lite-impl.js.map +0 -1
  66. package/lib/schema-lite.js.map +0 -1
  67. package/lib/schema.js.map +0 -1
  68. package/lib/trait.js.map +0 -1
  69. package/lib/xml.js.map +0 -1
@@ -1,341 +1 @@
1
- import * as Data from "effect/Data";
2
- import { pipeArguments } from "effect/Pipeable";
3
-
4
- export const liteKey = "~lite";
5
- const node = (n) => Object.assign(n, { [liteKey]: true });
6
- const Proto = {
7
- "~lite": true,
8
- pipe() {
9
- return pipeArguments(this, arguments);
10
- },
11
- annotate(annotations) {
12
- return make({ ...this.ast, annotations: { ...this.ast.annotations, ...annotations } }, this);
13
- },
14
- };
15
- const make = (ast, from) => {
16
- const self = Object.create(Proto);
17
- self.ast = ast;
18
- // Struct `.fields` and record `.key`/`.value` travel with annotate.
19
- if (from)
20
- for (const k of ["fields", "key", "value"])
21
- if (k in from)
22
- self[k] = from[k];
23
- return self;
24
- };
25
-
26
- export const fromNode = (n) => make(node(n));
27
- export const isLite = (u) => (typeof u === "object" || typeof u === "function") && u !== null && u["~lite"] === true;
28
- const astOf = (s) => s.ast;
29
- //#region primitives
30
- export const String = /*@__PURE__*/ make(node({ _tag: "String" }));
31
- export const Number = /*@__PURE__*/ make(node({ _tag: "Number" }));
32
- export const Boolean = /*@__PURE__*/ make(node({ _tag: "Boolean" }));
33
- export const Unknown = /*@__PURE__*/ make(node({ _tag: "Unknown" }));
34
- export const Any = /*@__PURE__*/ make(node({ _tag: "Any" }));
35
- export const Null = /*@__PURE__*/ make(node({ _tag: "Null" }));
36
- export const Void = /*@__PURE__*/ make(node({ _tag: "Void" }));
37
- export const Undefined = /*@__PURE__*/ make(node({ _tag: "Undefined" }));
38
- //#endregion
39
- //#region combinators
40
- export const Literal = (value) => make(node({ _tag: "Literal", literal: value }));
41
- export const Literals = (values) => make(node({ _tag: "Union", types: values.map((v) => node({ _tag: "Literal", literal: v })) }));
42
- export const optional = (s) => {
43
- const inner = astOf(s);
44
- return make(node({
45
- _tag: "Union",
46
- types: [inner, node({ _tag: "Undefined" })],
47
- context: { isOptional: true },
48
- }));
49
- };
50
- export const NullOr = (s) => make(node({ _tag: "Union", types: [astOf(s), node({ _tag: "Null" })] }));
51
- export const Union = (members) => make(node({ _tag: "Union", types: members.map(astOf) }));
52
- export const Array = (item) => make(node({ _tag: "Arrays", elements: [], rest: [astOf(item)] }));
53
- export const Tuple = (elements) => make(node({ _tag: "Arrays", elements: elements.map(astOf), rest: [] }));
54
- export const Record = (key, value) => {
55
- const s = make(node({
56
- _tag: "Objects",
57
- propertySignatures: [],
58
- indexSignatures: [{ parameter: astOf(key), type: astOf(value) }],
59
- }));
60
- s.key = key;
61
- s.value = value;
62
- return s;
63
- };
64
- export const Struct = (fields) => {
65
- const s = make(node({
66
- _tag: "Objects",
67
- propertySignatures: Object.keys(fields).map((name) => {
68
- const type = astOf(fields[name]);
69
- return { name, type };
70
- }),
71
- indexSignatures: [],
72
- }));
73
- s.fields = fields;
74
- return s;
75
- };
76
-
77
-
78
-
79
-
80
-
81
-
82
- export const StructWithRest = (struct, records) => {
83
- const base = resolveObjects(astOf(struct));
84
- const s = make(node({
85
- _tag: "Objects",
86
- propertySignatures: base.propertySignatures ?? [],
87
- indexSignatures: [
88
- ...(base.indexSignatures ?? []),
89
- ...records.flatMap((r) => resolveObjects(astOf(r)).indexSignatures ?? []),
90
- ],
91
- }));
92
- s.fields = struct.fields;
93
- return s;
94
- };
95
- const resolveObjects = (n) => (n._tag === "Suspend" ? resolveObjects(n.thunk()) : n);
96
-
97
- export const suspend = (f) => {
98
- let resolved;
99
- return make(node({ _tag: "Suspend", thunk: () => (resolved ??= astOf(f())) }));
100
- };
101
-
102
- export const encodeKeys = (mapping) => (s) => s.annotate({ [encodeKeysKey]: mapping });
103
- export const encodeKeysKey = "@distilled.cloud/core/schema-lite/encodeKeys";
104
- //#endregion
105
- //#region declarations and errors
106
- const declaration = (identifier) => make(node({ _tag: "Declaration", typeParameters: [], annotations: { identifier } }));
107
- export const Date = /*@__PURE__*/ declaration("Date");
108
- export const Duration = /*@__PURE__*/ declaration("Duration");
109
- export const Redacted = (value) => make(node({
110
- _tag: "Declaration",
111
- typeParameters: [astOf(value)],
112
- annotations: { identifier: "Redacted" },
113
- }));
114
- export const instanceOf = (cls, annotations) => make(node({
115
- _tag: "Declaration",
116
- typeParameters: [],
117
- annotations: { identifier: cls.name, ...annotations },
118
- }));
119
- export const declare = (_is, annotations) => make(node({ _tag: "Declaration", typeParameters: [], annotations: { ...annotations } }));
120
-
121
-
122
-
123
-
124
-
125
-
126
- const tagKey = "~distilled/tag";
127
- const keysKey = "~distilled/keys";
128
- const astKey = "~distilled/ast";
129
- const annotationsKey = "~distilled/annotations";
130
- const annotationMetaKey = /*@__PURE__*/ Symbol.for("@distilled.cloud/core/annotation-meta");
131
-
132
-
133
-
134
-
135
- const ownAnnotations = (from) => {
136
- const out = {};
137
- for (const k of Reflect.ownKeys(from))
138
- if (k !== annotationMetaKey && Object.prototype.propertyIsEnumerable.call(from, k))
139
- out[k] = from[k];
140
- return out;
141
- };
142
-
143
-
144
-
145
-
146
-
147
-
148
- let liteErrorBase;
149
- const LiteErrorBase = () => (liteErrorBase ??= class LiteError extends Data.Error {
150
- constructor(props) {
151
- const keys = new.target[keysKey];
152
- const picked = {};
153
- if (props)
154
- for (const k of keys)
155
- if (props[k] !== undefined)
156
- picked[k] = props[k];
157
- super(picked);
158
- this._tag = new.target[tagKey];
159
- }
160
-
161
- static get ast() {
162
- const C = this;
163
- if (Object.hasOwn(C, astKey))
164
- return C[astKey];
165
- const fields = C.fields;
166
- return (C[astKey] = node({
167
- _tag: "Objects",
168
- propertySignatures: Object.keys(fields).map((name) => ({
169
- name,
170
- type: astOf(fields[name]),
171
- })),
172
- indexSignatures: [],
173
- annotations: { identifier: C[tagKey], ...C[annotationsKey] },
174
- }));
175
- }
176
- static pipe() {
177
- return pipeArguments(this, arguments);
178
- }
179
-
180
- static make(props) {
181
- return new this(props);
182
- }
183
-
184
-
185
-
186
-
187
- static is(u) {
188
- return typeof u === "object" && u !== null && u._tag === this[tagKey];
189
- }
190
- });
191
-
192
-
193
-
194
-
195
-
196
- export const TaggedError = (_identifier) => (tag, fields = {}, annotations) => {
197
- const C = class extends LiteErrorBase() {
198
- };
199
- C[tagKey] = tag;
200
- C[keysKey] = Object.keys(fields);
201
- if (annotations)
202
- C[annotationsKey] = ownAnnotations(annotations);
203
- C.fields = fields;
204
- C.identifier = tag;
205
- C.prototype.name = tag;
206
- return C;
207
- };
208
-
209
-
210
-
211
-
212
-
213
- export const at = (build, j) => {
214
- const self = Object.create(AtProto);
215
- self.b = build;
216
- self.j = j;
217
- return self;
218
- };
219
- const resolveAt = (self) => (self.s ??= self.b(self.j));
220
- const AtProto = /*@__PURE__*/ Object.create(Proto, {
221
- ast: {
222
- get() {
223
- return resolveAt(this).ast;
224
- },
225
- },
226
- fields: {
227
- get() {
228
- return resolveAt(this).fields;
229
- },
230
- },
231
- key: {
232
- get() {
233
- return resolveAt(this).key;
234
- },
235
- },
236
- value: {
237
- get() {
238
- return resolveAt(this).value;
239
- },
240
- },
241
- });
242
- export const toEffect = (S, ast) => {
243
- const memo = new Map();
244
- // Whether a lite node sits anywhere under `n` (cycles count as no).
245
- const liteBelow = new Map();
246
- const hasLite = (n) => {
247
- const known = liteBelow.get(n);
248
- if (known !== undefined)
249
- return known;
250
- liteBelow.set(n, false);
251
- const kids = [
252
- ...(n.types ?? []),
253
- ...(n.elements ?? []),
254
- ...(n.rest ?? []),
255
- ...(n.typeParameters ?? []),
256
- ...(n.propertySignatures ?? []).map((p) => p.type),
257
- ...(n.indexSignatures ?? []).flatMap((i) => [i.parameter, i.type]),
258
- ...(n.encoding ?? []).map((l) => l.to),
259
- ...(n._tag === "Suspend" && n.thunk ? [n.thunk()] : []),
260
- ];
261
- const r = !!n[liteKey] || kids.some(hasLite);
262
- liteBelow.set(n, r);
263
- return r;
264
- };
265
- const build = (n) => {
266
- const hit = memo.get(n);
267
- if (hit)
268
- return hit;
269
- // A real Effect subtree with nothing lite below keeps its exact schema.
270
- if (!n[liteKey] && !hasLite(n)) {
271
- const real = S.make(n);
272
- memo.set(n, real);
273
- return real;
274
- }
275
- let out;
276
- switch (n._tag) {
277
- case "String":
278
- out = S.String;
279
- break;
280
- case "Number":
281
- out = S.Number;
282
- break;
283
- case "Boolean":
284
- out = S.Boolean;
285
- break;
286
- case "Null":
287
- out = S.Null;
288
- break;
289
- case "Undefined":
290
- out = S.Undefined;
291
- break;
292
- case "Void":
293
- out = S.Void;
294
- break;
295
- case "Any":
296
- out = S.Any;
297
- break;
298
- case "Literal":
299
- out = S.Literal(n.literal);
300
- break;
301
- case "Union":
302
- out = n.context?.isOptional
303
- ? S.optional(build(n.types[0]))
304
- : S.Union(n.types.map(build));
305
- break;
306
- case "Arrays":
307
- out = n.rest.length ? S.Array(build(n.rest[0])) : S.Tuple(n.elements.map(build));
308
- break;
309
- case "Objects": {
310
- const props = n.propertySignatures ?? [];
311
- const records = (n.indexSignatures ?? []).map((i) => S.Record(build(i.parameter), build(i.type)));
312
- if (props.length === 0 && records.length === 1) {
313
- out = records[0];
314
- break;
315
- }
316
- const struct = S.Struct(Object.fromEntries(props.map((p) => [p.name, build(p.type)])));
317
- out = records.length ? S.StructWithRest(struct, records) : struct;
318
- break;
319
- }
320
- case "Suspend": {
321
- const thunk = n.thunk;
322
- out = S.suspend(() => build(thunk()));
323
- break;
324
- }
325
- case "Declaration":
326
- out = n.check ? S.declare(n.check) : S.Unknown;
327
- break;
328
- case "Unknown":
329
- out = S.Unknown;
330
- break;
331
- default:
332
- // A lite tag with no case maps to Unknown; a real node keeps its schema.
333
- out = n[liteKey] ? S.Unknown : S.make(n);
334
- }
335
- memo.set(n, out);
336
- return out;
337
- };
338
- return build(ast);
339
- };
340
- //#endregion
341
- //# sourceMappingURL=schema-lite-impl.js.map
1
+ export { schema_lite_impl$Any as Any, schema_lite_impl$Array as Array, schema_lite_impl$Boolean as Boolean, schema_lite_impl$Date as Date, schema_lite_impl$Duration as Duration, schema_lite_impl$Literal as Literal, schema_lite_impl$Literals as Literals, schema_lite_impl$Null as Null, schema_lite_impl$NullOr as NullOr, schema_lite_impl$Number as Number, schema_lite_impl$Record as Record, schema_lite_impl$Redacted as Redacted, schema_lite_impl$String as String, schema_lite_impl$Struct as Struct, schema_lite_impl$StructWithRest as StructWithRest, schema_lite_impl$TaggedError as TaggedError, schema_lite_impl$Tuple as Tuple, schema_lite_impl$Undefined as Undefined, schema_lite_impl$Union as Union, schema_lite_impl$Unknown as Unknown, schema_lite_impl$Void as Void, schema_lite_impl$at as at, schema_lite_impl$declare as declare, schema_lite_impl$encodeKeys as encodeKeys, schema_lite_impl$encodeKeysKey as encodeKeysKey, schema_lite_impl$fromNode as fromNode, schema_lite_impl$instanceOf as instanceOf, schema_lite_impl$isLite as isLite, schema_lite_impl$liteKey as liteKey, schema_lite_impl$optional as optional, schema_lite_impl$suspend as suspend, schema_lite_impl$toEffect as toEffect } from "./_bundle/base.js";
@@ -1,27 +1,2 @@
1
- import * as L from "./schema-lite-impl.js";
2
- export const optional = L.optional;
3
- export const Struct = L.Struct;
4
- export const StructWithRest = L.StructWithRest;
5
- export const suspend = L.suspend;
6
- export const Array = L.Array;
7
- export const Record = L.Record;
8
- export const Union = L.Union;
9
- export const Literal = L.Literal;
10
- export const Literals = L.Literals;
11
- export const NullOr = L.NullOr;
12
- export const Tuple = L.Tuple;
13
- export const declare = L.declare;
14
- export const instanceOf = L.instanceOf;
15
- export const Redacted = L.Redacted;
16
- export const String = L.String;
17
- export const Number = L.Number;
18
- export const Int = L.Number;
19
- export const Boolean = L.Boolean;
20
- export const Date = L.Date;
21
- export const Duration = L.Duration;
22
- export const Unknown = L.Unknown;
23
- export const Null = L.Null;
24
- export const Void = L.Void;
25
- export const Any = L.Any;
26
- export const TaggedError = L.TaggedError;
1
+ import{schema_lite_impl$Any as e,schema_lite_impl$Array as t,schema_lite_impl$Boolean as n,schema_lite_impl$Date as r,schema_lite_impl$Duration as i,schema_lite_impl$Literal as a,schema_lite_impl$Literals as o,schema_lite_impl$Null as s,schema_lite_impl$NullOr as c,schema_lite_impl$Number as l,schema_lite_impl$Record as u,schema_lite_impl$Redacted as d,schema_lite_impl$String as f,schema_lite_impl$Struct as p,schema_lite_impl$StructWithRest as m,schema_lite_impl$TaggedError as h,schema_lite_impl$Tuple as g,schema_lite_impl$Union as _,schema_lite_impl$Unknown as v,schema_lite_impl$Void as y,schema_lite_impl$declare as b,schema_lite_impl$instanceOf as x,schema_lite_impl$optional as S,schema_lite_impl$suspend as C}from"./_bundle/base.js";const w=S;const T=p;const E=m;const D=C;const O=t;const k=u;const A=_;const j=a;const M=o;const N=c;const P=g;const F=b;const I=x;const L=d;const R=f;const z=l;const B=l;const V=n;const H=r;const U=i;const W=v;const G=s;const K=y;const q=e;const J=h;export{q as Any,O as Array,V as Boolean,H as Date,U as Duration,B as Int,j as Literal,M as Literals,G as Null,N as NullOr,z as Number,k as Record,L as Redacted,R as String,T as Struct,E as StructWithRest,J as TaggedError,P as Tuple,A as Union,W as Unknown,K as Void,F as declare,I as instanceOf,w as optional,D as suspend};
27
2
  //# sourceMappingURL=schema-lite-typed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-lite-typed.js","sourceRoot":"","sources":["../src/schema-lite-typed.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,CAAC,MAAM,uBAAuB,CAAC;AAI3C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAwC,CAAC;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAoC,CAAC;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,cAAoD,CAAC;AACrF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAsC,CAAC;AAChE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAoC,CAAC;AAC7D,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAsC,CAAC;AAChE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAwC,CAAC;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAoC,CAAC;AAC7D,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAsC,CAAC;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,UAA4C,CAAC;AACzE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAwC,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAoC,CAAC;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAoC,CAAC;AAC7D,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,MAAiC,CAAC;AACvD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAsC,CAAC;AAChE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAgC,CAAC;AACvD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAwC,CAAC;AACnE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAsC,CAAC;AAChE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAgC,CAAC;AACvD,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAgC,CAAC;AACvD,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,GAA8B,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,WAA8C,CAAC"}
1
+ {"version":3,"file":"schema-lite-typed.js","names":["L.optional","L.Struct","L.StructWithRest","L.suspend","L.Array","L.Record","L.Union","L.Literal","L.Literals","L.NullOr","L.Tuple","L.declare","L.instanceOf","L.Redacted","L.String","L.Number","L.Boolean","L.Date","L.Duration","L.Unknown","L.Null","L.Void","L.Any","L.TaggedError","Any$1","Array$1","Boolean$1","Date$1","Duration$1","Literal$1","Literals$1","Null$1","NullOr$1","Number$1","Record$1","Redacted$1","String$1","Struct$1","StructWithRest$1","TaggedError$1","Tuple$1","Union$1","Unknown$1","Void$1","declare$1","instanceOf$1","optional$1","suspend$1","optional","Struct","StructWithRest","suspend","Array","Record","Union","Literal","Literals","NullOr","Tuple","declare","instanceOf","Redacted","String","Number","Int","Boolean","Date","Duration","Unknown","Null","Void","Any","TaggedError"],"sources":["../src/schema-lite-typed.ts"],"mappings":"yuBAgBA,MAAagD,EAAWhD,EACxB,MAAaiD,EAAShD,EACtB,MAAaiD,EAAiBhD,EAC9B,MAAaiD,EAAUhD,EACvB,MAAaiD,EAAQhD,EACrB,MAAaiD,EAAShD,EACtB,MAAaiD,EAAQhD,EACrB,MAAaiD,EAAUhD,EACvB,MAAaiD,EAAWhD,EACxB,MAAaiD,EAAShD,EACtB,MAAaiD,EAAQhD,EACrB,MAAaiD,EAAUhD,EACvB,MAAaiD,EAAahD,EAC1B,MAAaiD,EAAWhD,EAExB,MAAaiD,EAAShD,EACtB,MAAaiD,EAAShD,EACtB,MAAaiD,EAAMjD,EACnB,MAAakD,EAAUjD,EACvB,MAAakD,EAAOjD,EACpB,MAAakD,EAAWjD,EACxB,MAAakD,EAAUjD,EACvB,MAAakD,EAAOjD,EACpB,MAAakD,EAAOjD,EACpB,MAAakD,EAAMjD,EAEnB,MAAakD,EAAcjD"}
@@ -1,31 +1 @@
1
- import * as L from "./schema-lite-impl.js";
2
- export const optional = L.optional;
3
- export const Struct = L.Struct;
4
- export const StructWithRest = L.StructWithRest;
5
- export const suspend = L.suspend;
6
- export const Array = L.Array;
7
- export const Record = L.Record;
8
- export const Union = L.Union;
9
- export const Literal = L.Literal;
10
- export const Literals = L.Literals;
11
- export const NullOr = L.NullOr;
12
- export const Tuple = L.Tuple;
13
- export const encodeKeys = L.encodeKeys;
14
- export const declare = L.declare;
15
- export const instanceOf = L.instanceOf;
16
- export const Redacted = L.Redacted;
17
- export const String = L.String;
18
- export const Number = L.Number;
19
- export const Int = L.Number;
20
- export const Boolean = L.Boolean;
21
- export const Date = L.Date;
22
- export const Duration = L.Duration;
23
- export const Unknown = L.Unknown;
24
- export const Null = L.Null;
25
- export const Void = L.Void;
26
- export const Any = L.Any;
27
- export const TaggedError = L.TaggedError;
28
-
29
- export const at = L.at;
30
- export { liteKey, toEffect } from "./schema-lite-impl.js";
31
- //# sourceMappingURL=schema-lite.js.map
1
+ export { schema_lite$Any as Any, schema_lite$Array as Array, schema_lite$Boolean as Boolean, schema_lite$Date as Date, schema_lite$Duration as Duration, schema_lite$Int as Int, schema_lite$Literal as Literal, schema_lite$Literals as Literals, schema_lite$Null as Null, schema_lite$NullOr as NullOr, schema_lite$Number as Number, schema_lite$Record as Record, schema_lite$Redacted as Redacted, schema_lite$String as String, schema_lite$Struct as Struct, schema_lite$StructWithRest as StructWithRest, schema_lite$TaggedError as TaggedError, schema_lite$Tuple as Tuple, schema_lite$Union as Union, schema_lite$Unknown as Unknown, schema_lite$Void as Void, schema_lite$at as at, schema_lite$declare as declare, schema_lite$encodeKeys as encodeKeys, schema_lite$instanceOf as instanceOf, schema_lite$liteKey as liteKey, schema_lite$optional as optional, schema_lite$suspend as suspend, schema_lite$toEffect as toEffect } from "./_bundle/rest.js";
package/lib/schema.js CHANGED
@@ -1,220 +1 @@
1
- export { declare, Duration, instanceOf, Redacted } from "effect/Schema";
2
- import { pipeArguments } from "effect/Pipeable";
3
- import * as S from "effect/Schema";
4
- // Construction surface -- collapse to `any` so generics are never instantiated.
5
- export const optional = S.optional;
6
- export const Struct = S.Struct;
7
- export const StructWithRest = S.StructWithRest;
8
- export const suspend = (f) => lazySuspend(f);
9
- export const Array = (item) => lazyArray(item);
10
- export const Record = (key, value) => lazyRecord(key, value);
11
- export const Union = S.Union;
12
- export const Literal = S.Literal;
13
- export const Literals = S.Literals;
14
- export const NullOr = S.NullOr;
15
- export const Tuple = S.Tuple;
16
- export const encodeKeys = S.encodeKeys;
17
- // Leaf schemas -- collapse to `any` so `.pipe(...)` on them is free.
18
- export const String = S.String;
19
- export const Number = S.Number;
20
- export const Boolean = S.Boolean;
21
- export const Date = S.Date;
22
- export const Unknown = S.Unknown;
23
- export const Null = S.Null;
24
- export const Void = S.Void;
25
- export const Any = S.Any;
26
- // NOTE: `Schema` / `Codec` (types) are intentionally NOT overridden -- they
27
- // flow through `export *` with real types so cast targets stay precise.
28
- // `TaggedError` is overridden with the same type (see "Lazy error classes").
29
- //#region Lazy schemas
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
- const SchemaProto = /*@__PURE__*/ Object.getPrototypeOf(S.String);
52
- const buildKey = /*@__PURE__*/ Symbol.for("@distilled.cloud/core/schema/build");
53
- const annotationsKey = /*@__PURE__*/ Symbol.for("@distilled.cloud/core/schema/annotations");
54
- const dataKey = /*@__PURE__*/ Symbol.for("@distilled.cloud/core/schema/data");
55
-
56
- const force = (self) => {
57
- const build = self[buildKey];
58
- if (!build)
59
- return;
60
- const annotations = self[annotationsKey];
61
- const built = typeof build === "function" ? build() : build.build(self[dataKey]);
62
- const real = annotations ? built.annotate(annotations) : built;
63
- delete self[buildKey];
64
- delete self[dataKey];
65
- delete self[annotationsKey];
66
- Object.defineProperties(self, Object.getOwnPropertyDescriptors(real));
67
- };
68
-
69
- const forwarded = (name) => ({
70
- configurable: true,
71
- get() {
72
- if (!this[buildKey])
73
- return undefined;
74
- force(this);
75
- return this[name];
76
- },
77
- });
78
- const LazyProto = /*@__PURE__*/ Object.create(SchemaProto, {
79
- ast: /*@__PURE__*/ forwarded("ast"),
80
- value: /*@__PURE__*/ forwarded("value"),
81
- key: /*@__PURE__*/ forwarded("key"),
82
- annotate: {
83
- configurable: true,
84
- writable: true,
85
- value(annotations) {
86
- const build = this[buildKey];
87
- // Once built, annotate like any schema (a rebuilt copy).
88
- if (!build)
89
- return SchemaProto.annotate.call(this, annotations);
90
- const previous = this[annotationsKey];
91
- return lazy(build, previous ? { ...previous, ...annotations } : annotations, this[dataKey]);
92
- },
93
- },
94
- });
95
- // Effect detects schemas by this key on the prototype; if a future Effect
96
- // moves it, build eagerly.
97
- const supported = SchemaProto["~effect/Schema/Schema"] !== undefined;
98
- const lazy = (build, annotations, data) => {
99
- if (!supported) {
100
- const built = typeof build === "function" ? build() : build.build(data);
101
- return annotations ? built.annotate(annotations) : built;
102
- }
103
- const self = Object.create(LazyProto);
104
- self[buildKey] = build;
105
- if (data !== undefined)
106
- self[dataKey] = data;
107
- if (annotations)
108
- self[annotationsKey] = annotations;
109
- return self;
110
- };
111
-
112
- export const lazyFrom = (builder, data) => lazy(builder, undefined, data);
113
- const lazySuspend = (f) => lazy(() => S.suspend(f));
114
- const lazyArray = (item) => lazy(() => S.Array(item));
115
- const lazyRecord = (key, value) => lazy(() => S.Record(key, value));
116
- //#endregion
117
- //#region Lazy error classes
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
- const lazyErrorKey = /*@__PURE__*/ Symbol.for("@distilled.cloud/core/schema/lazyError");
137
- const SchemaTypeId = "~effect/Schema/Schema";
138
- // The base every Effect error class extends (`core.Error`, a yieldable
139
- // Error). Found on first use, so bundles without error classes do not keep
140
- // Effect's class machinery.
141
- let errorBase;
142
- const ErrorBase = () => (errorBase ??= Object.getPrototypeOf(S.TaggedError()("Probe", {})));
143
- const realErrorClass = (cls) => {
144
- const state = cls[lazyErrorKey];
145
- if (!state.real) {
146
- const real = S.TaggedError(state.identifier)(...state.args);
147
- state.real = real;
148
- Object.setPrototypeOf(state.lazy.prototype, real.prototype);
149
- }
150
- return state.real;
151
- };
152
-
153
- const FORWARDED_STATICS = [
154
- "ast",
155
- "fields",
156
- "make",
157
- "makeOption",
158
- "makeEffect",
159
- "annotate",
160
- "annotateKey",
161
- "check",
162
- "rebuild",
163
- "extend",
164
- "mapFields",
165
- ];
166
- let lazyErrorStatics;
167
- const LazyErrorStatics = () => (lazyErrorStatics ??= Object.create(ErrorBase(), {
168
- [SchemaTypeId]: { value: SchemaTypeId, configurable: true },
169
- identifier: {
170
- configurable: true,
171
- get() {
172
- const state = this[lazyErrorKey];
173
- return state.identifier ?? state.args[0];
174
- },
175
- },
176
- pipe: {
177
- configurable: true,
178
- writable: true,
179
- value() {
180
- return pipeArguments(this, arguments);
181
- },
182
- },
183
- ...Object.fromEntries(FORWARDED_STATICS.map((name) => [
184
- name,
185
- {
186
- configurable: true,
187
- get() {
188
- let owner = realErrorClass(this);
189
- let descriptor;
190
- while (owner && !(descriptor = Object.getOwnPropertyDescriptor(owner, name))) {
191
- owner = Object.getPrototypeOf(owner);
192
- }
193
- if (!descriptor)
194
- return undefined;
195
- if (descriptor.get)
196
- return descriptor.get.call(this);
197
- return typeof descriptor.value === "function"
198
- ? descriptor.value.bind(this)
199
- : descriptor.value;
200
- },
201
- },
202
- ])),
203
- }));
204
- const lazyTaggedError = (identifier) => (...args) => {
205
- function LazyTaggedError(input, options) {
206
- if (!new.target)
207
- throw new TypeError("Class constructor cannot be invoked without 'new'");
208
- return Reflect.construct(realErrorClass(new.target), [input, options], new.target);
209
- }
210
- Object.setPrototypeOf(LazyTaggedError, LazyErrorStatics());
211
- LazyTaggedError.prototype = Object.create(ErrorBase().prototype, {
212
- constructor: { value: LazyTaggedError, writable: true, configurable: true },
213
- });
214
- const state = { identifier, args, lazy: LazyTaggedError };
215
- Object.defineProperty(LazyTaggedError, lazyErrorKey, { value: state });
216
- return LazyTaggedError;
217
- };
218
- export const TaggedError = lazyTaggedError;
219
- //#endregion
220
- //# sourceMappingURL=schema.js.map
1
+ export { schema$Any as Any, schema$Array as Array, schema$Boolean as Boolean, schema$Date as Date, schema$Duration as Duration, schema$Literal as Literal, schema$Literals as Literals, schema$Null as Null, schema$NullOr as NullOr, schema$Number as Number, schema$Record as Record, schema$Redacted as Redacted, schema$String as String, schema$Struct as Struct, schema$StructWithRest as StructWithRest, schema$TaggedError as TaggedError, schema$Tuple as Tuple, schema$Union as Union, schema$Unknown as Unknown, schema$Void as Void, schema$declare as declare, schema$encodeKeys as encodeKeys, schema$instanceOf as instanceOf, schema$lazyFrom as lazyFrom, schema$optional as optional, schema$suspend as suspend } from "./_bundle/aws.js";
package/lib/testing.js CHANGED
@@ -1,42 +1,2 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
- import * as Effect from "effect/Effect";
15
- import * as HttpClient from "effect/http/HttpClient";
16
- import * as HttpClientResponse from "effect/http/HttpClientResponse";
17
- import * as Layer from "effect/Layer";
18
- import * as ResponseValidation from "./response-validation.js";
19
-
20
-
21
-
22
-
23
- export const mockHttpClient = (response) => Layer.succeed(HttpClient.HttpClient, HttpClient.make((request) => Effect.sync(() => {
24
- const r = typeof response === "function" ? response(request) : response;
25
- return HttpClientResponse.fromWeb(request, new Response(r.body, {
26
- status: r.status ?? 200,
27
- headers: r.headers ?? { "content-type": "application/json" },
28
- }));
29
- })));
30
-
31
-
32
-
33
-
34
- export const runValidationModes = (effect, response) => {
35
- const run = (mode) => effect.pipe(Effect.provide(mockHttpClient(response)), Effect.provide(mode), Effect.result);
36
- return Effect.runPromise(Effect.all({
37
- lenient: run(ResponseValidation.lenient),
38
- additionalProperties: run(ResponseValidation.additionalProperties),
39
- strict: run(ResponseValidation.strict),
40
- }));
41
- };
1
+ import{response_validation$additionalProperties as e,response_validation$lenient as t,response_validation$strict as n}from"./_bundle/base.js";import*as r from"effect/Effect";import*as i from"effect/http/HttpClient";import*as a from"effect/Layer";import*as o from"effect/http/HttpClientResponse";const mockHttpClient=e=>a.succeed(i.HttpClient,i.make(t=>r.sync(()=>{const n=typeof e===`function`?e(t):e;return o.fromWeb(t,new Response(n.body,{status:n.status??200,headers:n.headers??{"content-type":`application/json`}}))})));const runValidationModes=(i,a)=>{const run=e=>i.pipe(r.provide(mockHttpClient(a)),r.provide(e),r.result);return r.runPromise(r.all({lenient:run(t),additionalProperties:run(e),strict:run(n)}))};export{mockHttpClient,runValidationModes};
42
2
  //# sourceMappingURL=testing.js.map