@zipbul/baker 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/index.js +1 -10
  3. package/dist/src/collect.js +1 -26
  4. package/dist/src/configure.js +1 -43
  5. package/dist/src/create-rule.js +1 -41
  6. package/dist/src/decorators/field.js +1 -277
  7. package/dist/src/decorators/index.js +1 -2
  8. package/dist/src/decorators/recipe.js +1 -23
  9. package/dist/src/errors.js +1 -52
  10. package/dist/src/functions/check-call-options.js +1 -51
  11. package/dist/src/functions/deserialize.js +1 -57
  12. package/dist/src/functions/serialize.js +1 -52
  13. package/dist/src/functions/validate.js +1 -49
  14. package/dist/src/interfaces.js +0 -4
  15. package/dist/src/meta-access.js +1 -75
  16. package/dist/src/registry.js +1 -8
  17. package/dist/src/rule-metadata.js +1 -17
  18. package/dist/src/rule-plan.js +1 -117
  19. package/dist/src/rules/array.js +1 -96
  20. package/dist/src/rules/binary.js +3 -51
  21. package/dist/src/rules/combinators.js +1 -111
  22. package/dist/src/rules/common.js +1 -77
  23. package/dist/src/rules/date.js +1 -35
  24. package/dist/src/rules/index.js +1 -10
  25. package/dist/src/rules/locales.js +1 -249
  26. package/dist/src/rules/number.js +1 -79
  27. package/dist/src/rules/object.js +1 -49
  28. package/dist/src/rules/string.js +10 -2033
  29. package/dist/src/rules/typechecker.js +5 -171
  30. package/dist/src/seal/circular-analyzer.js +1 -63
  31. package/dist/src/seal/codegen-utils.js +1 -18
  32. package/dist/src/seal/deserialize-builder.js +265 -1564
  33. package/dist/src/seal/expose-validator.js +1 -65
  34. package/dist/src/seal/seal-state.js +1 -18
  35. package/dist/src/seal/seal.js +1 -431
  36. package/dist/src/seal/serialize-builder.js +66 -370
  37. package/dist/src/seal/validate-meta.js +1 -61
  38. package/dist/src/symbols.js +1 -13
  39. package/dist/src/transformers/collection.transformer.js +1 -25
  40. package/dist/src/transformers/date.transformer.js +1 -18
  41. package/dist/src/transformers/index.js +1 -6
  42. package/dist/src/transformers/luxon.transformer.js +1 -34
  43. package/dist/src/transformers/moment.transformer.js +1 -32
  44. package/dist/src/transformers/number.transformer.js +1 -8
  45. package/dist/src/transformers/string.transformer.js +1 -12
  46. package/dist/src/types.js +0 -1
  47. package/dist/src/utils.js +1 -10
  48. package/package.json +2 -2
@@ -1,32 +1 @@
1
- import { BakerError } from '../errors.js';
2
- const MOMENT_MISSING = "momentTransformer requires the optional peer dependency 'moment'. Install it with: bun add moment";
3
- async function momentTransformer(opts) {
4
- let moment;
5
- try {
6
- moment = (await import('moment')).default;
7
- }
8
- catch (e) {
9
- throw new BakerError(MOMENT_MISSING, { cause: e });
10
- }
11
- // Hoist format option once so the serialize closure doesn't re-read opts per call
12
- const format = opts?.format;
13
- return {
14
- deserialize: ({ value }) => {
15
- if (typeof value === 'string' || value instanceof Date) {
16
- return moment(value);
17
- }
18
- return value;
19
- },
20
- serialize: ({ value }) => {
21
- if (value &&
22
- typeof value === 'object' &&
23
- typeof value.toISOString === 'function' &&
24
- typeof value.format === 'function') {
25
- const v = value;
26
- return format ? v.format(format) : v.toISOString();
27
- }
28
- return value;
29
- },
30
- };
31
- }
32
- export { momentTransformer };
1
+ import{BakerError as x}from"../errors.js";const y="momentTransformer requires the optional peer dependency 'moment'. Install it with: bun add moment";async function momentTransformer(w){let g;try{g=(await import("moment")).default}catch(b){throw new x(y,{cause:b})}const j=w?.format;return{deserialize:({value:b})=>{if(typeof b==="string"||b instanceof Date)return g(b);return b},serialize:({value:b})=>{if(b&&typeof b==="object"&&typeof b.toISOString==="function"&&typeof b.format==="function"){const q=b;return j?q.format(j):q.toISOString()}return b}}}export{momentTransformer};
@@ -1,8 +1 @@
1
- export function roundTransformer(precision = 0) {
2
- const factor = Math.pow(10, precision);
3
- const round = (v) => (typeof v === 'number' && Number.isFinite(v) ? Math.round(v * factor) / factor : v);
4
- return {
5
- deserialize: ({ value }) => round(value),
6
- serialize: ({ value }) => round(value),
7
- };
8
- }
1
+ export function roundTransformer(o=0){const e=Math.pow(10,o),n=(r)=>typeof r==="number"&&Number.isFinite(r)?Math.round(r*e)/e:r;return{deserialize:({value:r})=>n(r),serialize:({value:r})=>n(r)}}
@@ -1,12 +1 @@
1
- export const trimTransformer = {
2
- deserialize: ({ value }) => (typeof value === 'string' ? value.trim() : value),
3
- serialize: ({ value }) => (typeof value === 'string' ? value.trim() : value),
4
- };
5
- export const toLowerCaseTransformer = {
6
- deserialize: ({ value }) => (typeof value === 'string' ? value.toLowerCase() : value),
7
- serialize: ({ value }) => (typeof value === 'string' ? value.toLowerCase() : value),
8
- };
9
- export const toUpperCaseTransformer = {
10
- deserialize: ({ value }) => (typeof value === 'string' ? value.toUpperCase() : value),
11
- serialize: ({ value }) => (typeof value === 'string' ? value.toUpperCase() : value),
12
- };
1
+ export const trimTransformer={deserialize:({value:r})=>typeof r==="string"?r.trim():r,serialize:({value:r})=>typeof r==="string"?r.trim():r};export const toLowerCaseTransformer={deserialize:({value:r})=>typeof r==="string"?r.toLowerCase():r,serialize:({value:r})=>typeof r==="string"?r.toLowerCase():r};export const toUpperCaseTransformer={deserialize:({value:r})=>typeof r==="string"?r.toUpperCase():r,serialize:({value:r})=>typeof r==="string"?r.toUpperCase():r};
package/dist/src/types.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/dist/src/utils.js CHANGED
@@ -1,10 +1 @@
1
- /** minification-safe async function detection — uses Object.prototype.toString brand instead of constructor.name */
2
- export function isAsyncFunction(fn) {
3
- return Object.prototype.toString.call(fn) === '[object AsyncFunction]';
4
- }
5
- /** Promise-like detection used to enforce sync/async contract at runtime */
6
- export function isPromiseLike(value) {
7
- return ((typeof value === 'object' || typeof value === 'function') &&
8
- value !== null &&
9
- typeof value.then === 'function');
10
- }
1
+ export function isAsyncFunction(b){return Object.prototype.toString.call(b)==="[object AsyncFunction]"}export function isPromiseLike(b){return(typeof b==="object"||typeof b==="function")&&b!==null&&typeof b.then==="function"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipbul/baker",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Bun-only AOT decorator-based DTO validation & serialization. class-validator DX, sealed code generation, zero reflect-metadata.",
5
5
  "keywords": [
6
6
  "aot",
@@ -71,7 +71,7 @@
71
71
  "provenance": true
72
72
  },
73
73
  "scripts": {
74
- "build": "rm -rf dist && tsc -p tsconfig.build.json && bun scripts/add-js-extensions.ts",
74
+ "build": "bash scripts/build.sh",
75
75
  "changeset": "changeset",
76
76
  "deps:check": "dpdm --no-warning --no-tree --no-output -T index.ts src/",
77
77
  "format": "oxfmt",