elysia 2.0.0-beta.20 → 2.0.0-beta.21

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 (50) hide show
  1. package/dist/compile/aot.d.ts +8 -8
  2. package/dist/compile/aot.js +16 -14
  3. package/dist/compile/aot.mjs +14 -14
  4. package/dist/compile/handler/descriptor.js +2 -3
  5. package/dist/compile/handler/descriptor.mjs +2 -3
  6. package/dist/compile/handler/index.d.ts +2 -1
  7. package/dist/compile/handler/index.js +144 -24
  8. package/dist/compile/handler/index.mjs +146 -27
  9. package/dist/compile/handler/jit.d.ts +2 -0
  10. package/dist/compile/handler/jit.js +3 -2
  11. package/dist/compile/handler/jit.mjs +3 -2
  12. package/dist/compile/handler/reconstruct.js +3 -2
  13. package/dist/compile/handler/reconstruct.mjs +3 -2
  14. package/dist/cookie/config.d.ts +6 -2
  15. package/dist/cookie/config.js +68 -8
  16. package/dist/cookie/config.mjs +69 -10
  17. package/dist/cookie/utils.js +3 -3
  18. package/dist/cookie/utils.mjs +4 -4
  19. package/dist/package.js +1 -1
  20. package/dist/package.mjs +1 -1
  21. package/dist/plugin/aot/core.d.ts +5 -0
  22. package/dist/plugin/aot/core.js +37 -1
  23. package/dist/plugin/aot/core.mjs +37 -1
  24. package/dist/plugin/aot/source.js +24 -9
  25. package/dist/plugin/aot/source.mjs +24 -9
  26. package/dist/schema-snapshot.js +4 -3
  27. package/dist/schema-snapshot.mjs +4 -3
  28. package/dist/type/coerce.d.ts +1 -1
  29. package/dist/type/constants.d.ts +1 -1
  30. package/dist/type/elysia/keep-config.d.ts +14 -0
  31. package/dist/type/elysia/keep-config.js +62 -0
  32. package/dist/type/elysia/keep-config.mjs +53 -0
  33. package/dist/type/exports.d.ts +3 -2
  34. package/dist/type/exports.js +10 -0
  35. package/dist/type/exports.mjs +2 -1
  36. package/dist/type/index.js +10 -0
  37. package/dist/type/index.mjs +10 -0
  38. package/dist/type/typebox-type-live.d.ts +2 -2
  39. package/dist/type/typebox-type-live.js +8 -0
  40. package/dist/type/typebox-type-live.mjs +2 -2
  41. package/dist/type/typebox-type.d.ts +10 -2
  42. package/dist/type/typebox-type.js +64 -0
  43. package/dist/type/typebox-type.mjs +17 -1
  44. package/dist/types.d.ts +3 -2
  45. package/dist/utils.d.ts +3 -1
  46. package/dist/utils.js +23 -0
  47. package/dist/utils.mjs +22 -1
  48. package/dist/ws/route.js +33 -5
  49. package/dist/ws/route.mjs +35 -7
  50. package/package.json +1 -1
@@ -225,6 +225,10 @@ const OVERRIDE_MAP = {
225
225
  leaf: "boolean-string",
226
226
  export: "BooleanString"
227
227
  },
228
+ Composite: {
229
+ leaf: "keep-config",
230
+ export: "CompositeType"
231
+ },
228
232
  Cookie: {
229
233
  leaf: "cookie",
230
234
  export: "Cookie"
@@ -233,6 +237,10 @@ const OVERRIDE_MAP = {
233
237
  leaf: "date",
234
238
  export: "DateType"
235
239
  },
240
+ Evaluate: {
241
+ leaf: "keep-config",
242
+ export: "EvaluateType"
243
+ },
236
244
  File: {
237
245
  leaf: "file",
238
246
  export: "File"
@@ -253,10 +261,18 @@ const OVERRIDE_MAP = {
253
261
  leaf: "integer-string",
254
262
  export: "IntegerString"
255
263
  },
264
+ Interface: {
265
+ leaf: "keep-config",
266
+ export: "InterfaceType"
267
+ },
256
268
  Intersect: {
257
269
  leaf: "intersect",
258
270
  export: "Intersect"
259
271
  },
272
+ Mapped: {
273
+ leaf: "keep-config",
274
+ export: "MappedType"
275
+ },
260
276
  MaybeEmpty: {
261
277
  leaf: "maybe-empty",
262
278
  export: "MaybeEmpty"
@@ -289,14 +305,34 @@ const OVERRIDE_MAP = {
289
305
  leaf: "object-string",
290
306
  export: "ObjectString"
291
307
  },
308
+ Omit: {
309
+ leaf: "keep-config",
310
+ export: "OmitType"
311
+ },
292
312
  Optional: {
293
313
  leaf: "optional",
294
314
  export: "Optional"
295
315
  },
316
+ Partial: {
317
+ leaf: "keep-config",
318
+ export: "PartialType"
319
+ },
320
+ Pick: {
321
+ leaf: "keep-config",
322
+ export: "PickType"
323
+ },
296
324
  Problem: {
297
325
  leaf: "problem",
298
326
  export: "Problem"
299
327
  },
328
+ ReadonlyObject: {
329
+ leaf: "keep-config",
330
+ export: "ReadonlyObjectType"
331
+ },
332
+ Required: {
333
+ leaf: "keep-config",
334
+ export: "RequiredType"
335
+ },
300
336
  String: {
301
337
  leaf: "string",
302
338
  export: "StringType"
@@ -509,7 +545,7 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
509
545
  }
510
546
  if (typedApp["~config"]?.normalize === "typebox") routesForbidSeal = true;
511
547
  const validatorSlotsMatch = validatorSlotSetsMatch(expectedSlots, artifacts.validators);
512
- const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, (artifacts.handlers.length > 0 || artifacts.validators.length > 0) && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), artifacts.handlers.length === 0 && artifacts.validators.length === 0, adapterStub, productionStub, wsCookie, exactMirror);
548
+ const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, (artifacts.handlers.some((h) => h.code) || artifacts.validators.length > 0) && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), !artifacts.handlers.some((h) => h.code) && artifacts.validators.length === 0, adapterStub, productionStub, wsCookie, exactMirror);
513
549
  if (options?.target === "workerd") {
514
550
  if (!report.jit) throw new Error(`[elysia-aot] target 'workerd' but handler JIT is still reachable (${report.reasons.join(", ") || "unknown"}). Every route must be captured into the AOT manifest.`);
515
551
  if (!validatorSlotsMatch) console.warn("[elysia-aot] target 'workerd': captured validator slots do not exactly match declared slots; unfrozen slots compile at runtime and will fail on workerd.");
@@ -223,6 +223,10 @@ const OVERRIDE_MAP = {
223
223
  leaf: "boolean-string",
224
224
  export: "BooleanString"
225
225
  },
226
+ Composite: {
227
+ leaf: "keep-config",
228
+ export: "CompositeType"
229
+ },
226
230
  Cookie: {
227
231
  leaf: "cookie",
228
232
  export: "Cookie"
@@ -231,6 +235,10 @@ const OVERRIDE_MAP = {
231
235
  leaf: "date",
232
236
  export: "DateType"
233
237
  },
238
+ Evaluate: {
239
+ leaf: "keep-config",
240
+ export: "EvaluateType"
241
+ },
234
242
  File: {
235
243
  leaf: "file",
236
244
  export: "File"
@@ -251,10 +259,18 @@ const OVERRIDE_MAP = {
251
259
  leaf: "integer-string",
252
260
  export: "IntegerString"
253
261
  },
262
+ Interface: {
263
+ leaf: "keep-config",
264
+ export: "InterfaceType"
265
+ },
254
266
  Intersect: {
255
267
  leaf: "intersect",
256
268
  export: "Intersect"
257
269
  },
270
+ Mapped: {
271
+ leaf: "keep-config",
272
+ export: "MappedType"
273
+ },
258
274
  MaybeEmpty: {
259
275
  leaf: "maybe-empty",
260
276
  export: "MaybeEmpty"
@@ -287,14 +303,34 @@ const OVERRIDE_MAP = {
287
303
  leaf: "object-string",
288
304
  export: "ObjectString"
289
305
  },
306
+ Omit: {
307
+ leaf: "keep-config",
308
+ export: "OmitType"
309
+ },
290
310
  Optional: {
291
311
  leaf: "optional",
292
312
  export: "Optional"
293
313
  },
314
+ Partial: {
315
+ leaf: "keep-config",
316
+ export: "PartialType"
317
+ },
318
+ Pick: {
319
+ leaf: "keep-config",
320
+ export: "PickType"
321
+ },
294
322
  Problem: {
295
323
  leaf: "problem",
296
324
  export: "Problem"
297
325
  },
326
+ ReadonlyObject: {
327
+ leaf: "keep-config",
328
+ export: "ReadonlyObjectType"
329
+ },
330
+ Required: {
331
+ leaf: "keep-config",
332
+ export: "RequiredType"
333
+ },
298
334
  String: {
299
335
  leaf: "string",
300
336
  export: "StringType"
@@ -507,7 +543,7 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
507
543
  }
508
544
  if (typedApp["~config"]?.normalize === "typebox") routesForbidSeal = true;
509
545
  const validatorSlotsMatch = validatorSlotSetsMatch(expectedSlots, artifacts.validators);
510
- const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, (artifacts.handlers.length > 0 || artifacts.validators.length > 0) && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), artifacts.handlers.length === 0 && artifacts.validators.length === 0, adapterStub, productionStub, wsCookie, exactMirror);
546
+ const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, (artifacts.handlers.some((h) => h.code) || artifacts.validators.length > 0) && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), !artifacts.handlers.some((h) => h.code) && artifacts.validators.length === 0, adapterStub, productionStub, wsCookie, exactMirror);
511
547
  if (options?.target === "workerd") {
512
548
  if (!report.jit) throw new Error(`[elysia-aot] target 'workerd' but handler JIT is still reachable (${report.reasons.join(", ") || "unknown"}). Every route must be captured into the AOT manifest.`);
513
549
  if (!validatorSlotsMatch) console.warn("[elysia-aot] target 'workerd': captured validator slots do not exactly match declared slots; unfrozen slots compile at runtime and will fail on workerd.");
@@ -40,10 +40,14 @@ async function captureArtifacts(app, options) {
40
40
  }
41
41
  const materialiseHandlersForReplay = (captured) => {
42
42
  const manifest = {};
43
- for (const h of captured) (manifest[h.method] ??= {})[h.path] = {
44
- a: h.alias ? h.alias.split(",") : [],
45
- f: new Function(`return ${require_compile_aot_emit.Source.handlerFactory(h.alias, h.code)}`)()
46
- };
43
+ for (const h of captured) {
44
+ if (!h.code) continue;
45
+ (manifest[h.method] ??= {})[h.path] = {
46
+ a: h.alias ? h.alias.split(",") : [],
47
+ f: new Function(`return ${require_compile_aot_emit.Source.handlerFactory(h.alias, h.code)}`)(),
48
+ k: h.k
49
+ };
50
+ }
47
51
  return manifest;
48
52
  };
49
53
  function replayStubbability(app, handlers) {
@@ -353,23 +357,34 @@ function emitModule(captured, handlers, fingerprint, options) {
353
357
  validatorExport = `const validators = ${treeToSource(tree)}\n`;
354
358
  }
355
359
  const aliasRef = /* @__PURE__ */ new Map();
360
+ const factoryRef = /* @__PURE__ */ new Map();
356
361
  const handlerRef = /* @__PURE__ */ new Map();
357
362
  let handlerDecls = "";
358
363
  const handlerTree = require_utils.nullObject();
359
364
  for (const h of handlers) {
365
+ const k = h.k === void 0 ? "" : `k: ${JSON.stringify(h.k)}`;
366
+ if (!h.code) {
367
+ (handlerTree[h.method] ??= {})[h.path] = `{ ${k} }`;
368
+ continue;
369
+ }
360
370
  const src = require_compile_aot_emit.Source.handlerFactory(h.alias, h.code);
361
- let wref = handlerRef.get(src);
371
+ let fref = factoryRef.get(src);
372
+ if (fref === void 0) {
373
+ fref = `_h${factoryRef.size}`;
374
+ factoryRef.set(src, fref);
375
+ handlerDecls += `const ${fref} = ${src}\n`;
376
+ }
377
+ let wref = handlerRef.get(fref + k);
362
378
  if (wref === void 0) {
363
- const n = handlerRef.size;
364
379
  let aref = aliasRef.get(h.alias);
365
380
  if (aref === void 0) {
366
381
  aref = `_a${aliasRef.size}`;
367
382
  aliasRef.set(h.alias, aref);
368
383
  handlerDecls += `const ${aref} = ${JSON.stringify(h.alias ? h.alias.split(",") : [])}\n`;
369
384
  }
370
- wref = `_w${n}`;
371
- handlerRef.set(src, wref);
372
- handlerDecls += `const _h${n} = ${src}\nconst ${wref} = { a: ${aref}, f: _h${n} }\n`;
385
+ wref = `_w${handlerRef.size}`;
386
+ handlerRef.set(fref + k, wref);
387
+ handlerDecls += `const ${wref} = { a: ${aref}, f: ${fref}, ${k} }\n`;
373
388
  }
374
389
  (handlerTree[h.method] ??= {})[h.path] = wref;
375
390
  }
@@ -39,10 +39,14 @@ async function captureArtifacts(app, options) {
39
39
  }
40
40
  const materialiseHandlersForReplay = (captured) => {
41
41
  const manifest = {};
42
- for (const h of captured) (manifest[h.method] ??= {})[h.path] = {
43
- a: h.alias ? h.alias.split(",") : [],
44
- f: new Function(`return ${Source.handlerFactory(h.alias, h.code)}`)()
45
- };
42
+ for (const h of captured) {
43
+ if (!h.code) continue;
44
+ (manifest[h.method] ??= {})[h.path] = {
45
+ a: h.alias ? h.alias.split(",") : [],
46
+ f: new Function(`return ${Source.handlerFactory(h.alias, h.code)}`)(),
47
+ k: h.k
48
+ };
49
+ }
46
50
  return manifest;
47
51
  };
48
52
  function replayStubbability(app, handlers) {
@@ -352,23 +356,34 @@ function emitModule(captured, handlers, fingerprint, options) {
352
356
  validatorExport = `const validators = ${treeToSource(tree)}\n`;
353
357
  }
354
358
  const aliasRef = /* @__PURE__ */ new Map();
359
+ const factoryRef = /* @__PURE__ */ new Map();
355
360
  const handlerRef = /* @__PURE__ */ new Map();
356
361
  let handlerDecls = "";
357
362
  const handlerTree = nullObject();
358
363
  for (const h of handlers) {
364
+ const k = h.k === void 0 ? "" : `k: ${JSON.stringify(h.k)}`;
365
+ if (!h.code) {
366
+ (handlerTree[h.method] ??= {})[h.path] = `{ ${k} }`;
367
+ continue;
368
+ }
359
369
  const src = Source.handlerFactory(h.alias, h.code);
360
- let wref = handlerRef.get(src);
370
+ let fref = factoryRef.get(src);
371
+ if (fref === void 0) {
372
+ fref = `_h${factoryRef.size}`;
373
+ factoryRef.set(src, fref);
374
+ handlerDecls += `const ${fref} = ${src}\n`;
375
+ }
376
+ let wref = handlerRef.get(fref + k);
361
377
  if (wref === void 0) {
362
- const n = handlerRef.size;
363
378
  let aref = aliasRef.get(h.alias);
364
379
  if (aref === void 0) {
365
380
  aref = `_a${aliasRef.size}`;
366
381
  aliasRef.set(h.alias, aref);
367
382
  handlerDecls += `const ${aref} = ${JSON.stringify(h.alias ? h.alias.split(",") : [])}\n`;
368
383
  }
369
- wref = `_w${n}`;
370
- handlerRef.set(src, wref);
371
- handlerDecls += `const _h${n} = ${src}\nconst ${wref} = { a: ${aref}, f: _h${n} }\n`;
384
+ wref = `_w${handlerRef.size}`;
385
+ handlerRef.set(fref + k, wref);
386
+ handlerDecls += `const ${wref} = { a: ${aref}, f: ${fref}, ${k} }\n`;
372
387
  }
373
388
  (handlerTree[h.method] ??= {})[h.path] = wref;
374
389
  }
@@ -76,7 +76,7 @@ function deepCloneSchema(value, freeze, seen, canShare = true) {
76
76
  const property = value[key];
77
77
  if (!allEnumerable && !isEnumerable.call(value, key)) {
78
78
  Object.defineProperty(out, key, {
79
- value: property,
79
+ value: key === "~cookieFrom" ? deepCloneSchema(property, freeze, seen) : property,
80
80
  enumerable: false,
81
81
  writable: true,
82
82
  configurable: true
@@ -119,7 +119,7 @@ function fingerprint(value, seen, state, canShare = true) {
119
119
  const type = typeof value;
120
120
  if (type !== "object") switch (type) {
121
121
  case "string": return "s" + value.length + ":" + value;
122
- case "number": return "n" + value + ";";
122
+ case "number": return "n" + (Object.is(value, -0) ? "-0" : value) + ";";
123
123
  case "boolean": return value ? "T;" : "F;";
124
124
  case "function": return refKey(value);
125
125
  case "undefined": return "u;";
@@ -149,7 +149,8 @@ function fingerprint(value, seen, state, canShare = true) {
149
149
  const key = keys[i];
150
150
  const property = value[key];
151
151
  out += "k" + key.length + ":" + key;
152
- out += !allEnumerable && !isEnumerable.call(value, key) ? "!" + byRefKey(property, state) : "=" + fingerprint(property, seen, state);
152
+ const hidden = !allEnumerable && !isEnumerable.call(value, key);
153
+ out += hidden && key !== "~cookieFrom" ? "!" + byRefKey(property, state) : (hidden ? "~" : "=") + fingerprint(property, seen, state);
153
154
  }
154
155
  if (Object.getOwnPropertySymbols(value).length) state.bail = true;
155
156
  return out + "};";
@@ -75,7 +75,7 @@ function deepCloneSchema(value, freeze, seen, canShare = true) {
75
75
  const property = value[key];
76
76
  if (!allEnumerable && !isEnumerable.call(value, key)) {
77
77
  Object.defineProperty(out, key, {
78
- value: property,
78
+ value: key === "~cookieFrom" ? deepCloneSchema(property, freeze, seen) : property,
79
79
  enumerable: false,
80
80
  writable: true,
81
81
  configurable: true
@@ -118,7 +118,7 @@ function fingerprint(value, seen, state, canShare = true) {
118
118
  const type = typeof value;
119
119
  if (type !== "object") switch (type) {
120
120
  case "string": return "s" + value.length + ":" + value;
121
- case "number": return "n" + value + ";";
121
+ case "number": return "n" + (Object.is(value, -0) ? "-0" : value) + ";";
122
122
  case "boolean": return value ? "T;" : "F;";
123
123
  case "function": return refKey(value);
124
124
  case "undefined": return "u;";
@@ -148,7 +148,8 @@ function fingerprint(value, seen, state, canShare = true) {
148
148
  const key = keys[i];
149
149
  const property = value[key];
150
150
  out += "k" + key.length + ":" + key;
151
- out += !allEnumerable && !isEnumerable.call(value, key) ? "!" + byRefKey(property, state) : "=" + fingerprint(property, seen, state);
151
+ const hidden = !allEnumerable && !isEnumerable.call(value, key);
152
+ out += hidden && key !== "~cookieFrom" ? "!" + byRefKey(property, state) : (hidden ? "~" : "=") + fingerprint(property, seen, state);
152
153
  }
153
154
  if (Object.getOwnPropertySymbols(value).length) state.bail = true;
154
155
  return out + "};";
@@ -30,7 +30,7 @@ declare const coerceQuery: () => CoerceOption[];
30
30
  declare const coerceBody: () => CoerceOption[];
31
31
  declare const coerceFormData: () => CoerceOption[];
32
32
  declare const coerceStringToStructure: () => CoerceOption[];
33
- declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): BaseSchema | TSchema;
33
+ declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): TSchema | BaseSchema;
34
34
  declare function captureCoercePlan(original: any, coerced: any): CoerceNode | null;
35
35
  /** Full rebuild: scalar leaves + ObjectString/ArrayString sites (wired path). */
36
36
  declare const buildCoercedFromPlan: (original: any, plan: CoerceNode, seen?: Set<string>) => any;
@@ -17,7 +17,7 @@ declare const ELYSIA_TYPES: {
17
17
  readonly NoValidate: 15;
18
18
  };
19
19
  type ELYSIA_TYPES = typeof ELYSIA_TYPES;
20
- declare const primitiveElysiaTypes: Set<2 | 1 | 6 | 3 | 10 | 11 | 13 | 14>;
20
+ declare const primitiveElysiaTypes: Set<1 | 2 | 6 | 3 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -0,0 +1,14 @@
1
+ import { Composite, Evaluate, Interface, Mapped, Omit, Partial, Pick, ReadonlyObject, Required } from "../typebox-type.js";
2
+
3
+ //#region src/type/elysia/keep-config.d.ts
4
+ declare const CompositeType: typeof Composite;
5
+ declare const EvaluateType: typeof Evaluate;
6
+ declare const InterfaceType: typeof Interface;
7
+ declare const MappedType: typeof Mapped;
8
+ declare const OmitType: typeof Omit;
9
+ declare const PartialType: typeof Partial;
10
+ declare const PickType: typeof Pick;
11
+ declare const ReadonlyObjectType: typeof ReadonlyObject;
12
+ declare const RequiredType: typeof Required;
13
+ //#endregion
14
+ export { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType };
@@ -0,0 +1,62 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_utils = require('../../utils.js');
3
+ const require_type_typebox_type = require('../typebox-type.js');
4
+
5
+ //#region src/type/elysia/keep-config.ts
6
+ const carries = (schema, field = false, seen = /* @__PURE__ */ new Set()) => {
7
+ if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
8
+ seen.add(schema);
9
+ if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || require_utils.compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => carries(member, field, seen)))) return true;
10
+ if (!field) {
11
+ for (const name in schema.properties) if (carries(schema.properties[name], true)) return true;
12
+ }
13
+ return false;
14
+ };
15
+ const from = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
16
+ value: sources,
17
+ writable: true,
18
+ configurable: true
19
+ });
20
+ const keep = (build, sourcesOf) => ((...args) => {
21
+ const sources = sourcesOf(...args);
22
+ const result = build(...args);
23
+ if (!sources.some((source) => carries(source))) return result;
24
+ const built = from(result, sources);
25
+ const ref = built.$ref;
26
+ const replaced = sources[0]?.$defs?.[ref];
27
+ if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
28
+ ...built.$defs,
29
+ [ref]: from(built.$defs[ref], [replaced])
30
+ };
31
+ return built;
32
+ });
33
+ const operand = (type, options) => [type, options];
34
+ const indexed = (type, _, options) => [type, options];
35
+ const CompositeType = /* @__PURE__ */ keep(require_type_typebox_type.Composite, (left, right) => [left, right]);
36
+ const EvaluateType = /* @__PURE__ */ keep(require_type_typebox_type.Evaluate, operand);
37
+ const InterfaceType = /* @__PURE__ */ keep(require_type_typebox_type.Interface, (heritage, properties, options) => [
38
+ ...heritage,
39
+ { properties },
40
+ options
41
+ ]);
42
+ const MappedType = /* @__PURE__ */ keep(require_type_typebox_type.Mapped, (_, type, __, property, options) => [
43
+ type,
44
+ property,
45
+ options
46
+ ]);
47
+ const OmitType = /* @__PURE__ */ keep(require_type_typebox_type.Omit, indexed);
48
+ const PartialType = /* @__PURE__ */ keep(require_type_typebox_type.Partial, operand);
49
+ const PickType = /* @__PURE__ */ keep(require_type_typebox_type.Pick, indexed);
50
+ const ReadonlyObjectType = /* @__PURE__ */ keep(require_type_typebox_type.ReadonlyObject, operand);
51
+ const RequiredType = /* @__PURE__ */ keep(require_type_typebox_type.Required, operand);
52
+
53
+ //#endregion
54
+ exports.CompositeType = CompositeType;
55
+ exports.EvaluateType = EvaluateType;
56
+ exports.InterfaceType = InterfaceType;
57
+ exports.MappedType = MappedType;
58
+ exports.OmitType = OmitType;
59
+ exports.PartialType = PartialType;
60
+ exports.PickType = PickType;
61
+ exports.ReadonlyObjectType = ReadonlyObjectType;
62
+ exports.RequiredType = RequiredType;
@@ -0,0 +1,53 @@
1
+ import { compositionKeys } from "../../utils.mjs";
2
+ import { Composite, Evaluate, Interface, Mapped, Omit, Partial, Pick, ReadonlyObject, Required } from "../typebox-type.mjs";
3
+
4
+ //#region src/type/elysia/keep-config.ts
5
+ const carries = (schema, field = false, seen = /* @__PURE__ */ new Set()) => {
6
+ if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
7
+ seen.add(schema);
8
+ if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => carries(member, field, seen)))) return true;
9
+ if (!field) {
10
+ for (const name in schema.properties) if (carries(schema.properties[name], true)) return true;
11
+ }
12
+ return false;
13
+ };
14
+ const from = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
15
+ value: sources,
16
+ writable: true,
17
+ configurable: true
18
+ });
19
+ const keep = (build, sourcesOf) => ((...args) => {
20
+ const sources = sourcesOf(...args);
21
+ const result = build(...args);
22
+ if (!sources.some((source) => carries(source))) return result;
23
+ const built = from(result, sources);
24
+ const ref = built.$ref;
25
+ const replaced = sources[0]?.$defs?.[ref];
26
+ if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
27
+ ...built.$defs,
28
+ [ref]: from(built.$defs[ref], [replaced])
29
+ };
30
+ return built;
31
+ });
32
+ const operand = (type, options) => [type, options];
33
+ const indexed = (type, _, options) => [type, options];
34
+ const CompositeType = /* @__PURE__ */ keep(Composite, (left, right) => [left, right]);
35
+ const EvaluateType = /* @__PURE__ */ keep(Evaluate, operand);
36
+ const InterfaceType = /* @__PURE__ */ keep(Interface, (heritage, properties, options) => [
37
+ ...heritage,
38
+ { properties },
39
+ options
40
+ ]);
41
+ const MappedType = /* @__PURE__ */ keep(Mapped, (_, type, __, property, options) => [
42
+ type,
43
+ property,
44
+ options
45
+ ]);
46
+ const OmitType = /* @__PURE__ */ keep(Omit, indexed);
47
+ const PartialType = /* @__PURE__ */ keep(Partial, operand);
48
+ const PickType = /* @__PURE__ */ keep(Pick, indexed);
49
+ const ReadonlyObjectType = /* @__PURE__ */ keep(ReadonlyObject, operand);
50
+ const RequiredType = /* @__PURE__ */ keep(Required, operand);
51
+
52
+ //#endregion
53
+ export { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType };
@@ -4,6 +4,7 @@ import { ArrayBufferType } from "./elysia/array-buffer.js";
4
4
  import { ArrayString } from "./elysia/array-string.js";
5
5
  import { BooleanType } from "./elysia/boolean.js";
6
6
  import { BooleanString } from "./elysia/boolean-string.js";
7
+ import { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType } from "./elysia/keep-config.js";
7
8
  import { Cookie } from "./elysia/cookie.js";
8
9
  import { DateType } from "./elysia/date.js";
9
10
  import { File } from "./elysia/file.js";
@@ -30,8 +31,8 @@ export * from "typebox/type";
30
31
 
31
32
  //#region src/type/exports.d.ts
32
33
  declare namespace exports_d_exports {
33
- export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, Cookie, DateType as Date, File, Files, Form, Integer, IntegerString, Intersect, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, Optional, Problem, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum };
34
+ export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, CompositeType as Composite, Cookie, DateType as Date, EvaluateType as Evaluate, File, Files, Form, Integer, IntegerString, InterfaceType as Interface, Intersect, MappedType as Mapped, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, OmitType as Omit, Optional, PartialType as Partial, PickType as Pick, Problem, ReadonlyObjectType as ReadonlyObject, RequiredType as Required, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum };
34
35
  }
35
36
  import * as import_typebox_type from "typebox/type";
36
37
  //#endregion
37
- export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, Cookie, DateType as Date, File, Files, Form, Integer, IntegerString, Intersect, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, Optional, Problem, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum, exports_d_exports };
38
+ export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, CompositeType as Composite, Cookie, DateType as Date, EvaluateType as Evaluate, File, Files, Form, Integer, IntegerString, InterfaceType as Interface, Intersect, MappedType as Mapped, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, OmitType as Omit, Optional, PartialType as Partial, PickType as Pick, Problem, ReadonlyObjectType as ReadonlyObject, RequiredType as Required, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum, exports_d_exports };
@@ -22,6 +22,7 @@ const require_type_elysia_date = require('./elysia/date.js');
22
22
  const require_type_elysia_file = require('./elysia/file.js');
23
23
  const require_type_elysia_files = require('./elysia/files.js');
24
24
  const require_type_elysia_form = require('./elysia/form.js');
25
+ const require_type_elysia_keep_config = require('./elysia/keep-config.js');
25
26
  const require_type_elysia_maybe_empty = require('./elysia/maybe-empty.js');
26
27
  const require_type_elysia_no_validate = require('./elysia/no-validate.js');
27
28
  const require_type_elysia_nullable = require('./elysia/nullable.js');
@@ -49,14 +50,18 @@ exports.ArrayBuffer = require_type_elysia_array_buffer.ArrayBufferType;
49
50
  exports.ArrayString = require_type_elysia_array_string.ArrayString;
50
51
  exports.Boolean = require_type_elysia_boolean.BooleanType;
51
52
  exports.BooleanString = require_type_elysia_boolean_string.BooleanString;
53
+ exports.Composite = require_type_elysia_keep_config.CompositeType;
52
54
  exports.Cookie = require_type_elysia_cookie.Cookie;
53
55
  exports.Date = require_type_elysia_date.DateType;
56
+ exports.Evaluate = require_type_elysia_keep_config.EvaluateType;
54
57
  exports.File = require_type_elysia_file.File;
55
58
  exports.Files = require_type_elysia_files.Files;
56
59
  exports.Form = require_type_elysia_form.Form;
57
60
  exports.Integer = require_type_elysia_integer.Integer;
58
61
  exports.IntegerString = require_type_elysia_integer_string.IntegerString;
62
+ exports.Interface = require_type_elysia_keep_config.InterfaceType;
59
63
  exports.Intersect = require_type_elysia_intersect.Intersect;
64
+ exports.Mapped = require_type_elysia_keep_config.MappedType;
60
65
  exports.MaybeEmpty = require_type_elysia_maybe_empty.MaybeEmpty;
61
66
  exports.NoValidate = require_type_elysia_no_validate.NoValidate;
62
67
  exports.Nullable = require_type_elysia_nullable.Nullable;
@@ -65,8 +70,13 @@ exports.Numeric = require_type_elysia_numeric.Numeric;
65
70
  exports.NumericEnum = require_type_elysia_numeric_enum.NumericEnum;
66
71
  exports.Object = require_type_elysia_object.ObjectType;
67
72
  exports.ObjectString = require_type_elysia_object_string.ObjectString;
73
+ exports.Omit = require_type_elysia_keep_config.OmitType;
68
74
  exports.Optional = require_type_elysia_optional.Optional;
75
+ exports.Partial = require_type_elysia_keep_config.PartialType;
76
+ exports.Pick = require_type_elysia_keep_config.PickType;
69
77
  exports.Problem = require_type_elysia_problem.Problem;
78
+ exports.ReadonlyObject = require_type_elysia_keep_config.ReadonlyObjectType;
79
+ exports.Required = require_type_elysia_keep_config.RequiredType;
70
80
  exports.String = require_type_elysia_string.StringType;
71
81
  exports.Uint8Array = require_type_elysia_uint8_array.Uint8ArrayType;
72
82
  exports.Union = require_type_elysia_union.Union;
@@ -20,6 +20,7 @@ import { DateType } from "./elysia/date.mjs";
20
20
  import { File } from "./elysia/file.mjs";
21
21
  import { Files } from "./elysia/files.mjs";
22
22
  import { Form } from "./elysia/form.mjs";
23
+ import { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType } from "./elysia/keep-config.mjs";
23
24
  import { MaybeEmpty } from "./elysia/maybe-empty.mjs";
24
25
  import { NoValidate } from "./elysia/no-validate.mjs";
25
26
  import { Nullable } from "./elysia/nullable.mjs";
@@ -41,4 +42,4 @@ injectTypeboxType({
41
42
  setupTypebox();
42
43
 
43
44
  //#endregion
44
- export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, Cookie, DateType as Date, File, Files, Form, Integer, IntegerString, Intersect, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, Optional, Problem, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum };
45
+ export { Accelerate, ArrayType as Array, ArrayBufferType as ArrayBuffer, ArrayString, BooleanType as Boolean, BooleanString, CompositeType as Composite, Cookie, DateType as Date, EvaluateType as Evaluate, File, Files, Form, Integer, IntegerString, InterfaceType as Interface, Intersect, MappedType as Mapped, MaybeEmpty, NoValidate, Nullable, NumberType as Number, Numeric, NumericEnum, ObjectType as Object, ObjectString, OmitType as Omit, Optional, PartialType as Partial, PickType as Pick, Problem, ReadonlyObjectType as ReadonlyObject, RequiredType as Required, StringType as String, Uint8ArrayType as Uint8Array, Union, UnionEnum };
@@ -24,6 +24,7 @@ const require_type_elysia_date = require('./elysia/date.js');
24
24
  const require_type_elysia_file = require('./elysia/file.js');
25
25
  const require_type_elysia_files = require('./elysia/files.js');
26
26
  const require_type_elysia_form = require('./elysia/form.js');
27
+ const require_type_elysia_keep_config = require('./elysia/keep-config.js');
27
28
  const require_type_elysia_maybe_empty = require('./elysia/maybe-empty.js');
28
29
  const require_type_elysia_no_validate = require('./elysia/no-validate.js');
29
30
  const require_type_elysia_nullable = require('./elysia/nullable.js');
@@ -77,14 +78,18 @@ const t = lazyNamespace(() => require_type_typebox_type.loadTypeNamespace().type
77
78
  ArrayString: require_type_elysia_array_string.ArrayString,
78
79
  Boolean: require_type_elysia_boolean.BooleanType,
79
80
  BooleanString: require_type_elysia_boolean_string.BooleanString,
81
+ Composite: require_type_elysia_keep_config.CompositeType,
80
82
  Cookie: require_type_elysia_cookie.Cookie,
81
83
  Date: require_type_elysia_date.DateType,
84
+ Evaluate: require_type_elysia_keep_config.EvaluateType,
82
85
  File: require_type_elysia_file.File,
83
86
  Files: require_type_elysia_files.Files,
84
87
  Form: require_type_elysia_form.Form,
85
88
  Integer: require_type_elysia_integer.Integer,
89
+ Interface: require_type_elysia_keep_config.InterfaceType,
86
90
  Intersect: require_type_elysia_intersect.Intersect,
87
91
  IntegerString: require_type_elysia_integer_string.IntegerString,
92
+ Mapped: require_type_elysia_keep_config.MappedType,
88
93
  MaybeEmpty: require_type_elysia_maybe_empty.MaybeEmpty,
89
94
  NoValidate: require_type_elysia_no_validate.NoValidate,
90
95
  Nullable: require_type_elysia_nullable.Nullable,
@@ -93,8 +98,13 @@ const t = lazyNamespace(() => require_type_typebox_type.loadTypeNamespace().type
93
98
  NumericEnum: require_type_elysia_numeric_enum.NumericEnum,
94
99
  Object: require_type_elysia_object.ObjectType,
95
100
  ObjectString: require_type_elysia_object_string.ObjectString,
101
+ Omit: require_type_elysia_keep_config.OmitType,
96
102
  Optional: require_type_elysia_optional.Optional,
103
+ Partial: require_type_elysia_keep_config.PartialType,
104
+ Pick: require_type_elysia_keep_config.PickType,
97
105
  Problem: require_type_elysia_problem.Problem,
106
+ ReadonlyObject: require_type_elysia_keep_config.ReadonlyObjectType,
107
+ Required: require_type_elysia_keep_config.RequiredType,
98
108
  String: require_type_elysia_string.StringType,
99
109
  Uint8Array: require_type_elysia_uint8_array.Uint8ArrayType,
100
110
  Union: require_type_elysia_union.Union,
@@ -23,6 +23,7 @@ import { DateType } from "./elysia/date.mjs";
23
23
  import { File } from "./elysia/file.mjs";
24
24
  import { Files } from "./elysia/files.mjs";
25
25
  import { Form } from "./elysia/form.mjs";
26
+ import { CompositeType, EvaluateType, InterfaceType, MappedType, OmitType, PartialType, PickType, ReadonlyObjectType, RequiredType } from "./elysia/keep-config.mjs";
26
27
  import { MaybeEmpty } from "./elysia/maybe-empty.mjs";
27
28
  import { NoValidate } from "./elysia/no-validate.mjs";
28
29
  import { Nullable } from "./elysia/nullable.mjs";
@@ -76,14 +77,18 @@ const t = lazyNamespace(() => loadTypeNamespace().type, {
76
77
  ArrayString,
77
78
  Boolean: BooleanType,
78
79
  BooleanString,
80
+ Composite: CompositeType,
79
81
  Cookie,
80
82
  Date: DateType,
83
+ Evaluate: EvaluateType,
81
84
  File,
82
85
  Files,
83
86
  Form,
84
87
  Integer,
88
+ Interface: InterfaceType,
85
89
  Intersect,
86
90
  IntegerString,
91
+ Mapped: MappedType,
87
92
  MaybeEmpty,
88
93
  NoValidate,
89
94
  Nullable,
@@ -92,8 +97,13 @@ const t = lazyNamespace(() => loadTypeNamespace().type, {
92
97
  NumericEnum,
93
98
  Object: ObjectType,
94
99
  ObjectString,
100
+ Omit: OmitType,
95
101
  Optional,
102
+ Partial: PartialType,
103
+ Pick: PickType,
96
104
  Problem,
105
+ ReadonlyObject: ReadonlyObjectType,
106
+ Required: RequiredType,
97
107
  String: StringType,
98
108
  Uint8Array: Uint8ArrayType,
99
109
  Union,