@wildo-ai/zod-decorators 1.1.9 → 1.1.11

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 (45) hide show
  1. package/dist/esm/index.d.ts +1 -0
  2. package/dist/esm/index.d.ts.map +1 -1
  3. package/dist/esm/index.js +1 -0
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/testing/decorated-test-schemas.d.ts +1 -1
  6. package/dist/esm/zod-bigdecimal.d.ts +16 -7
  7. package/dist/esm/zod-bigdecimal.d.ts.map +1 -1
  8. package/dist/esm/zod-bigdecimal.js.map +1 -1
  9. package/dist/esm/zod-code.d.ts +17 -8
  10. package/dist/esm/zod-code.d.ts.map +1 -1
  11. package/dist/esm/zod-code.js.map +1 -1
  12. package/dist/esm/zod-decorators.types.d.ts +339 -39
  13. package/dist/esm/zod-decorators.types.d.ts.map +1 -1
  14. package/dist/esm/zod-decorators.types.js +155 -13
  15. package/dist/esm/zod-decorators.types.js.map +1 -1
  16. package/dist/esm/zod-document-sequence.d.ts +119 -0
  17. package/dist/esm/zod-document-sequence.d.ts.map +1 -0
  18. package/dist/esm/zod-document-sequence.js +212 -0
  19. package/dist/esm/zod-document-sequence.js.map +1 -0
  20. package/dist/esm/zod-duration.d.ts +22 -13
  21. package/dist/esm/zod-duration.d.ts.map +1 -1
  22. package/dist/esm/zod-duration.js.map +1 -1
  23. package/dist/esm/zod-file.d.ts +0 -4
  24. package/dist/esm/zod-file.d.ts.map +1 -1
  25. package/dist/esm/zod-file.js +9 -20
  26. package/dist/esm/zod-file.js.map +1 -1
  27. package/dist/esm/zod-money.d.ts +22 -13
  28. package/dist/esm/zod-money.d.ts.map +1 -1
  29. package/dist/esm/zod-money.js.map +1 -1
  30. package/dist/esm/zod-phone.d.ts +22 -14
  31. package/dist/esm/zod-phone.d.ts.map +1 -1
  32. package/dist/esm/zod-phone.js.map +1 -1
  33. package/dist/esm/zod-range.d.ts.map +1 -1
  34. package/dist/esm/zod-range.js +5 -1
  35. package/dist/esm/zod-range.js.map +1 -1
  36. package/dist/esm/zod-utils.shared.d.ts +108 -2
  37. package/dist/esm/zod-utils.shared.d.ts.map +1 -1
  38. package/dist/esm/zod-utils.shared.js +228 -10
  39. package/dist/esm/zod-utils.shared.js.map +1 -1
  40. package/dist/esm/zod.module-override.d.ts +179 -53
  41. package/dist/esm/zod.module-override.d.ts.map +1 -1
  42. package/dist/esm/zod.module-override.js +473 -56
  43. package/dist/esm/zod.module-override.js.map +1 -1
  44. package/dist/tsconfig.build.tsbuildinfo +1 -0
  45. package/package.json +1 -1
@@ -12,6 +12,7 @@ export * from './zod-address';
12
12
  export * from './zod-code';
13
13
  export * from './zod-file';
14
14
  export * from './zod-versioned';
15
+ export * from './zod-document-sequence';
15
16
  export * from './currencies.shared.schemas';
16
17
  export * from './zod-utils.shared';
17
18
  export * from './zod-decorators.types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,wBAAgB,iBAAiB,CAAC,WAAW,GAAE,OAAO,CAAK,GAAG,OAAO,CAAC,CAErE;AAED,cAAc,WAAW,CAAC;AAE1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAIzC;;;;;;GAMG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,wBAAgB,iBAAiB,CAAC,WAAW,GAAE,OAAO,CAAK,GAAG,OAAO,CAAC,CAErE;AAED,cAAc,WAAW,CAAC;AAE1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAIzC;;;;;;GAMG"}
package/dist/esm/index.js CHANGED
@@ -27,6 +27,7 @@ export * from './zod-address.js';
27
27
  export * from './zod-code.js';
28
28
  export * from './zod-file.js';
29
29
  export * from './zod-versioned.js';
30
+ export * from './zod-document-sequence.js';
30
31
  export * from './currencies.shared.schemas.js';
31
32
  export * from './zod-utils.shared.js';
32
33
  export * from './zod-decorators.types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,uEAAuE;AACvE,4FAA4F;AAC5F,0FAA0F;AAC1F,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAE7B,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,kFAAkF;AAClF,mFAAmF;AACnF,kFAAkF;AAClF,yBAAyB,EAAE,CAAC;AAE5B,MAAM,UAAU,iBAAiB,CAAC,cAAwB,CAAC;IACzD,OAAO,yBAAyB,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,cAAc,WAAW,CAAC;AAE1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAIzC;;;;;;GAMG","sourcesContent":["import { z } from 'zod';\nimport { ensureZodDecoratorsLoaded } from './zod.module-override';\nimport { installBigIntJsonEncoding } from './install-bigint-json-encoding';\n\n// CRITICAL: Apply decorators immediately when this module is imported.\n// This ensures z.string().isUnique() etc. work without needing to call initZodDecorators().\n// The bundler may tree-shake the call in zod.module-override.ts, so we duplicate it here.\nensureZodDecoratorsLoaded(z);\n\n// Install the type-level `bigint → decimal string` JSON encoding at the SAME\n// bootstrap. `z_money` (owned by this package) stores `amount` as a `bigint`,\n// which `JSON.stringify` cannot serialize (it has no `toJSON`, unlike `Date`).\n// Installing it here — the earliest point, before any schema or serializer runs —\n// makes every JSON boundary (res.json, socket.io, queue, redis, HMAC, third-party)\n// bigint-safe with no per-boundary opt-in. See `install-bigint-json-encoding.ts`.\ninstallBigIntJsonEncoding();\n\nexport function initZodDecorators(zodInstance: typeof z = z): typeof z {\n return ensureZodDecoratorsLoaded(zodInstance);\n}\n\nexport * from './commons';\n\nexport * from './install-bigint-json-encoding';\nexport * from './zod-color';\nexport * from './zod-range';\nexport * from './zod-money';\nexport * from './zod-bigdecimal';\nexport * from './zod-duration';\nexport * from './zod-phone';\nexport * from './zod-address';\nexport * from './zod-code';\nexport * from './zod-file';\nexport * from './zod-versioned';\nexport * from './currencies.shared.schemas';\nexport * from './zod-utils.shared';\nexport * from './zod-decorators.types';\nexport * from './zod.module-override';\nexport * from './files/file-extensions.enum';\nexport * from './files/extension-nature-map';\nexport * from './files/mime-registry';\nexport * from './files/agent-file-formats';\nexport * from './files/unified-registry';\n\n\n\n/**\n * Initialize Zod decorators for the current Zod instance.\n * Safe to call multiple times - will only apply decorators once.\n *\n * This function should be called early in your application startup,\n * especially when using custom-shared-lib or custom-backend-lib packages.\n */\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,uEAAuE;AACvE,4FAA4F;AAC5F,0FAA0F;AAC1F,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAE7B,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,kFAAkF;AAClF,mFAAmF;AACnF,kFAAkF;AAClF,yBAAyB,EAAE,CAAC;AAE5B,MAAM,UAAU,iBAAiB,CAAC,cAAwB,CAAC;IACzD,OAAO,yBAAyB,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,cAAc,WAAW,CAAC;AAE1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAIzC;;;;;;GAMG","sourcesContent":["import { z } from 'zod';\nimport { ensureZodDecoratorsLoaded } from './zod.module-override';\nimport { installBigIntJsonEncoding } from './install-bigint-json-encoding';\n\n// CRITICAL: Apply decorators immediately when this module is imported.\n// This ensures z.string().isUnique() etc. work without needing to call initZodDecorators().\n// The bundler may tree-shake the call in zod.module-override.ts, so we duplicate it here.\nensureZodDecoratorsLoaded(z);\n\n// Install the type-level `bigint → decimal string` JSON encoding at the SAME\n// bootstrap. `z_money` (owned by this package) stores `amount` as a `bigint`,\n// which `JSON.stringify` cannot serialize (it has no `toJSON`, unlike `Date`).\n// Installing it here — the earliest point, before any schema or serializer runs —\n// makes every JSON boundary (res.json, socket.io, queue, redis, HMAC, third-party)\n// bigint-safe with no per-boundary opt-in. See `install-bigint-json-encoding.ts`.\ninstallBigIntJsonEncoding();\n\nexport function initZodDecorators(zodInstance: typeof z = z): typeof z {\n return ensureZodDecoratorsLoaded(zodInstance);\n}\n\nexport * from './commons';\n\nexport * from './install-bigint-json-encoding';\nexport * from './zod-color';\nexport * from './zod-range';\nexport * from './zod-money';\nexport * from './zod-bigdecimal';\nexport * from './zod-duration';\nexport * from './zod-phone';\nexport * from './zod-address';\nexport * from './zod-code';\nexport * from './zod-file';\nexport * from './zod-versioned';\nexport * from './zod-document-sequence';\nexport * from './currencies.shared.schemas';\nexport * from './zod-utils.shared';\nexport * from './zod-decorators.types';\nexport * from './zod.module-override';\nexport * from './files/file-extensions.enum';\nexport * from './files/extension-nature-map';\nexport * from './files/mime-registry';\nexport * from './files/agent-file-formats';\nexport * from './files/unified-registry';\n\n\n\n/**\n * Initialize Zod decorators for the current Zod instance.\n * Safe to call multiple times - will only apply decorators once.\n *\n * This function should be called early in your application startup,\n * especially when using custom-shared-lib or custom-backend-lib packages.\n */\n"]}
@@ -19,8 +19,8 @@ export declare const decoratedTestEntitySchema: z.ZodObject<{
19
19
  */
20
20
  export declare const decoratedTestVariantSchema: z.ZodObject<{
21
21
  kind: import("..").DecoratedPrimitiveZodType<z.ZodEnum<{
22
- B: "B";
23
22
  A: "A";
23
+ B: "B";
24
24
  }>>;
25
25
  label: import("..").DecoratedPrimitiveZodType<z.ZodString>;
26
26
  }, z.core.$strip>;
@@ -60,18 +60,27 @@ export declare const BigDecimalValueSchema: z.ZodString;
60
60
  * ```
61
61
  */
62
62
  export declare function createBigDecimalSchema(options?: BigDecimalSchemaOptions): DecoratedBigDecimalSchema;
63
+ /**
64
+ * The chainable methods of `DecoratedBigDecimalSchema`, returning `this` so a chain of several decorations keeps
65
+ * the type it reached: `.isSummaryField()` turns the field into a `DecoratedPrimitiveZodType<DecoratedBigDecimalSchema>`,
66
+ * and a spec or UI method called after it must return that, not the bare factory type. A method
67
+ * returning `DecoratedBigDecimalSchema` itself won that overload inside the intersection, so a resource
68
+ * specification's field map rejected `schemaShape.x.<factory>Spec(...)` on a decorated field.
69
+ */
70
+ export interface DecoratedBigDecimalSchemaMethods {
71
+ [ZodDecorator.IS_DB_INDEXED](): this;
72
+ [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): this;
73
+ [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): this;
74
+ [ZodDecorator.BIGDECIMAL_UI](params?: ZodDecorator_ParamsType[ZodDecorator.BIGDECIMAL_UI]): this;
75
+ [ZodDecorator.BIGDECIMAL_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.BIGDECIMAL_SPEC]): this;
76
+ addDecorators(decorators: DecoratorInput[]): this;
77
+ }
63
78
  /**
64
79
  * Return type for bigdecimal schemas - includes decorator methods.
65
80
  * Note: IS_FOREIGN_KEY is not applicable to bigdecimal values.
66
81
  * IS_DB_INDEXED indexes the string value directly for query optimization.
67
82
  */
68
- export type DecoratedBigDecimalSchema = z.ZodString & {
69
- [ZodDecorator.IS_DB_INDEXED](): DecoratedBigDecimalSchema;
70
- [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedBigDecimalSchema;
71
- [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedBigDecimalSchema;
72
- [ZodDecorator.BIGDECIMAL_UI](params?: ZodDecorator_ParamsType[ZodDecorator.BIGDECIMAL_UI]): DecoratedBigDecimalSchema;
73
- addDecorators(decorators: DecoratorInput[]): DecoratedBigDecimalSchema;
74
- };
83
+ export type DecoratedBigDecimalSchema = z.ZodString & DecoratedBigDecimalSchemaMethods;
75
84
  /**
76
85
  * Creates a bigdecimal schema for precise decimal numbers stored as strings.
77
86
  * Named z_bigdecimal to indicate it's a Zod helper function exported standalone.
@@ -1 +1 @@
1
- {"version":3,"file":"zod-bigdecimal.d.ts","sourceRo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MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IACzD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IACzD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAsB;IACnD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["\n// ============================================================================\n// BIGDECIMAL SCHEMA HELPER\n// ============================================================================\n\nimport { DecoratorInput, SCHEMA_METADATA, CustomFieldMetadata, BigDecimalSchemaMetadata, BigDecimalSchemaOptions, ZodDecorator, ZodDecorator_ParamsType } from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods } from \"./zod.module-override\";\nimport Big from \"big.js\";\n\n/**\n * BigDecimal value type - represents a precise decimal number as a string.\n *\n * Using strings to store decimal values avoids JavaScript's floating-point\n * precision issues. The big.js library is used for precise arithmetic operations.\n *\n * Example: \"19.99\", \"0.00000001\", \"123456789.123456789\"\n */\nexport type BigDecimalValue = string;\n\n/**\n * Validates that a string represents a valid big decimal number.\n */\nfunction isValidBigDecimal(value: string): boolean {\n try {\n new Big(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Zod schema for BigDecimalValue.\n * Validates that the string represents a valid decimal number.\n */\nexport const BigDecimalValueSchema: z.ZodString = z.string().refine(\n isValidBigDecimal,\n { message: \"Invalid decimal number format\" }\n) as z.ZodString;\n\n/**\n * z_bigdecimal() - Creates bigdecimal schemas for precise decimal numbers.\n *\n * BigDecimal values are stored as strings to avoid floating-point precision issues.\n * The big.js library is used for arithmetic operations.\n *\n * @example\n * ```typescript\n * import { z_bigdecimal } from '@wildo-ai/zod-decorators';\n *\n * const price = z_bigdecimal();\n * const quantity = z_bigdecimal({ precision: 8 });\n * const percentage = z_bigdecimal({ min: '0', max: '100' });\n *\n * // With decorators (chainable)\n * z_bigdecimal().bigDecimalUI({ display: { decimalPlaces: 4 } })\n * z_bigdecimal({ precision: 2 }).isHidden({ edit: true })\n * ```\n */\n\n/**\n * @wildo_source:part:start zod.factories.bigdecimal facet:layer:shared facet:family:schema-factory\n *\n * Creates a bigdecimal schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for bigdecimal field\n * @returns A Zod string schema with metadata for bigdecimal detection\n *\n * @example\n * ```typescript\n * // Simple bigdecimal\n * const price = z_bigdecimal();\n * // Infers: string\n *\n * // With precision constraint\n * const btcAmount = z_bigdecimal({ precision: 8 });\n *\n * // With min/max constraints\n * const percentage = z_bigdecimal({\n * min: '0',\n * max: '100',\n * precision: 2\n * });\n * ```\n */\nexport function createBigDecimalSchema(\n options: BigDecimalSchemaOptions = {}\n): DecoratedBigDecimalSchema {\n const {\n precision,\n min,\n max,\n } = options;\n\n // Create the base schema with validation\n let bigDecimalSchema = z.string().refine(\n (value) => {\n if (!isValidBigDecimal(value)) return false;\n\n try {\n const bigValue = new Big(value);\n\n // Check precision (decimal places)\n if (precision !== undefined) {\n const decimalPlaces = value.includes('.')\n ? value.split('.')[1]?.length ?? 0\n : 0;\n if (decimalPlaces > precision) return false;\n }\n\n // Check min\n if (min !== undefined) {\n const minValue = new Big(min);\n if (bigValue.lt(minValue)) return false;\n }\n\n // Check max\n if (max !== undefined) {\n const maxValue = new Big(max);\n if (bigValue.gt(maxValue)) return false;\n }\n\n return true;\n } catch {\n return false;\n }\n },\n {\n message: precision !== undefined\n ? `Invalid decimal number (max ${precision} decimal places${min !== undefined ? `, min: ${min}` : ''}${max !== undefined ? `, max: ${max}` : ''})`\n : `Invalid decimal number${min !== undefined ? ` (min: ${min}` : ''}${max !== undefined ? `${min !== undefined ? ', ' : ' ('}max: ${max})` : min !== undefined ? ')' : ''}`\n }\n );\n\n const bigDecimalMetadata: BigDecimalSchemaMetadata = {\n isBigDecimal: true,\n ...(precision !== undefined && { precision }),\n ...(min !== undefined && { min }),\n ...(max !== undefined && { max }),\n };\n\n // Initialize or extend SCHEMA_METADATA with bigdecimal config\n const existingMetadata: CustomFieldMetadata = (bigDecimalSchema as any)[SCHEMA_METADATA] || {};\n (bigDecimalSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n bigDecimalConfig: bigDecimalMetadata,\n };\n\n // Add chainable decorator methods to the bigdecimal schema instance\n // This allows: z_bigdecimal().bigDecimalUI({ display: { decimalPlaces: 4 } }).isHidden()\n addChainableMethods(bigDecimalSchema);\n\n return bigDecimalSchema as unknown as DecoratedBigDecimalSchema;\n}\n\n/**\n * Return type for bigdecimal schemas - includes decorator methods.\n * Note: IS_FOREIGN_KEY is not applicable to bigdecimal values.\n * IS_DB_INDEXED indexes the string value directly for query optimization.\n */\nexport type DecoratedBigDecimalSchema = z.ZodString & {\n [ZodDecorator.IS_DB_INDEXED](): DecoratedBigDecimalSchema;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedBigDecimalSchema;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedBigDecimalSchema;\n [ZodDecorator.BIGDECIMAL_UI](params?: ZodDecorator_ParamsType[ZodDecorator.BIGDECIMAL_UI]): DecoratedBigDecimalSchema;\n addDecorators(decorators: DecoratorInput[]): DecoratedBigDecimalSchema;\n};\n\n/**\n * Creates a bigdecimal schema for precise decimal numbers stored as strings.\n * Named z_bigdecimal to indicate it's a Zod helper function exported standalone.\n *\n * BigDecimal values are stored as strings to avoid floating-point precision issues.\n * Use big.js for arithmetic operations on these values.\n *\n * @example\n * ```typescript\n * import { z_bigdecimal } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage\n * z_bigdecimal() // Any valid decimal number as string\n *\n * // With options\n * z_bigdecimal({ precision: 2 }) // Max 2 decimal places\n * z_bigdecimal({ min: '0', max: '100' }) // Range constraint\n * z_bigdecimal({ precision: 8, min: '0' }) // Crypto amount\n *\n * // With decorators (chainable)\n * z_bigdecimal().bigDecimalUI({ display: { decimalPlaces: 4 } })\n * z_bigdecimal({ precision: 2 }).isHidden({ edit: true })\n *\n * // Usage example\n * const price: BigDecimalValue = \"19.99\";\n * const btcAmount: BigDecimalValue = \"0.00000001\";\n *\n * // Arithmetic with big.js\n * import Big from 'big.js';\n * const total = new Big(price).plus(\"10.01\").toString(); // \"30.00\"\n * ```\n */\nexport function z_bigdecimal(\n options?: BigDecimalSchemaOptions\n): DecoratedBigDecimalSchema {\n return createBigDecimalSchema(options) as DecoratedBigDecimalSchema;\n}\n/** @wildo_source:part:end zod.factories.bigdecimal */\n\n// ============================================================================\n// BIGDECIMAL UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Add two bigdecimal values.\n * @param a - First value\n * @param b - Second value\n * @returns Sum as string\n */\nexport function bigDecimalAdd(a: BigDecimalValue, b: BigDecimalValue): BigDecimalValue {\n return new Big(a).plus(b).toString();\n}\n\n/**\n * Subtract two bigdecimal values.\n * @param a - Value to subtract from\n * @param b - Value to subtract\n * @returns Difference as string\n */\nexport function bigDecimalSubtract(a: BigDecimalValue, b: BigDecimalValue): BigDecimalValue {\n return new Big(a).minus(b).toString();\n}\n\n/**\n * Multiply two bigdecimal values.\n * @param a - First value\n * @param b - Second value\n * @returns Product as string\n */\nexport function bigDecimalMultiply(a: BigDecimalValue, b: BigDecimalValue): BigDecimalValue {\n return new Big(a).times(b).toString();\n}\n\n/**\n * Divide two bigdecimal values.\n * @param a - Dividend\n * @param b - Divisor\n * @param precision - Number of decimal places for result (default: 20)\n * @returns Quotient as string\n */\nexport function bigDecimalDivide(a: BigDecimalValue, b: BigDecimalValue, precision: number = 20): BigDecimalValue {\n return new Big(a).div(b).round(precision).toString();\n}\n\n/**\n * Compare two bigdecimal values.\n * @param a - First value\n * @param b - Second value\n * @returns -1 if a < b, 0 if a === b, 1 if a > b\n */\nexport function bigDecimalCompare(a: BigDecimalValue, b: BigDecimalValue): -1 | 0 | 1 {\n return new Big(a).cmp(b) as -1 | 0 | 1;\n}\n\n/**\n * Round a bigdecimal value to specified precision.\n * @param value - Value to round\n * @param precision - Number of decimal places\n * @param roundingMode - big.js rounding mode (default: ROUND_HALF_UP)\n * @returns Rounded value as string\n */\nexport function bigDecimalRound(\n value: BigDecimalValue,\n precision: number,\n roundingMode: Big.RoundingMode = Big.roundHalfUp\n): BigDecimalValue {\n return new Big(value).round(precision, roundingMode).toString();\n}\n\n/**\n * Format a bigdecimal value for display with fixed decimal places.\n * @param value - Value to format\n * @param decimalPlaces - Number of decimal places to show\n * @returns Formatted string with trailing zeros if needed\n */\nexport function bigDecimalFormat(value: BigDecimalValue, decimalPlaces: number): string {\n return new Big(value).toFixed(decimalPlaces);\n}\n\n/**\n * Check if a bigdecimal value is zero.\n * @param value - Value to check\n * @returns true if value equals zero\n */\nexport function bigDecimalIsZero(value: BigDecimalValue): boolean {\n return new Big(value).eq(0);\n}\n\n/**\n * Check if a bigdecimal value is positive (> 0).\n * @param value - Value to check\n * @returns true if value is greater than zero\n */\nexport function bigDecimalIsPositive(value: BigDecimalValue): boolean {\n return new Big(value).gt(0);\n}\n\n/**\n * Check if a bigdecimal value is negative (< 0).\n * @param value - Value to check\n * @returns true if value is less than zero\n */\nexport function bigDecimalIsNegative(value: BigDecimalValue): boolean {\n return new Big(value).lt(0);\n}\n\n/**\n * Get the absolute value of a bigdecimal.\n * @param value - Value\n * @returns Absolute value as string\n */\nexport function bigDecimalAbs(value: BigDecimalValue): BigDecimalValue {\n return new Big(value).abs().toString();\n}\n\n/**\n * Convert a number to bigdecimal string.\n * @param value - Number to convert\n * @returns String representation\n */\nexport function toBigDecimal(value: number): BigDecimalValue {\n return new Big(value).toString();\n}\n\n/**\n * Convert a bigdecimal string to number.\n * Warning: May lose precision for very large or very precise numbers.\n * @param value - BigDecimal string\n * @returns Number value\n */\nexport function fromBigDecimal(value: BigDecimalValue): number {\n return new Big(value).toNumber();\n}\n\n"]}
1
+ {"version":3,"file":"zod-bigdecimal.js","sourceRoot":"","sources":["../../../src/zod-bigdecimal.ts"],"names":[],"mappings":"AACA,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,OAAO,EAAkB,eAAe,EAA0E,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AACxL,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,GAAG,MAAM,QAAQ,CAAC;AAYzB;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAgB,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CACjE,iBAAiB,EACjB,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAC9B,CAAC;AAEjB;;;;;;;;;;;;;;;;;;GAkBG;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YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAsB,EAAE,aAAqB;IAC5E,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IACzD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IACzD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAsB;IACnD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC","sourcesContent":["\n// ============================================================================\n// BIGDECIMAL SCHEMA HELPER\n// ============================================================================\n\nimport { DecoratorInput, SCHEMA_METADATA, CustomFieldMetadata, BigDecimalSchemaMetadata, BigDecimalSchemaOptions, ZodDecorator, ZodDecorator_ParamsType } from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods } from \"./zod.module-override\";\nimport Big from \"big.js\";\n\n/**\n * BigDecimal value type - represents a precise decimal number as a string.\n *\n * Using strings to store decimal values avoids JavaScript's floating-point\n * precision issues. The big.js library is used for precise arithmetic operations.\n *\n * Example: \"19.99\", \"0.00000001\", \"123456789.123456789\"\n */\nexport type BigDecimalValue = string;\n\n/**\n * Validates that a string represents a valid big decimal number.\n */\nfunction isValidBigDecimal(value: string): boolean {\n try {\n new Big(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Zod schema for BigDecimalValue.\n * Validates that the string represents a valid decimal number.\n */\nexport const BigDecimalValueSchema: z.ZodString = z.string().refine(\n isValidBigDecimal,\n { message: \"Invalid decimal number format\" }\n) as z.ZodString;\n\n/**\n * z_bigdecimal() - Creates bigdecimal schemas for precise decimal numbers.\n *\n * BigDecimal values are stored as strings to avoid floating-point precision issues.\n * The big.js library is used for arithmetic operations.\n *\n * @example\n * ```typescript\n * import { z_bigdecimal } from '@wildo-ai/zod-decorators';\n *\n * const price = z_bigdecimal();\n * const quantity = z_bigdecimal({ precision: 8 });\n * const percentage = z_bigdecimal({ min: '0', max: '100' });\n *\n * // With decorators (chainable)\n * z_bigdecimal().bigDecimalUI({ display: { decimalPlaces: 4 } })\n * z_bigdecimal({ precision: 2 }).isHidden({ edit: true })\n * ```\n */\n\n/**\n * @wildo_source:part:start zod.factories.bigdecimal facet:layer:shared facet:family:schema-factory\n *\n * Creates a bigdecimal schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for bigdecimal field\n * @returns A Zod string schema with metadata for bigdecimal detection\n *\n * @example\n * ```typescript\n * // Simple bigdecimal\n * const price = z_bigdecimal();\n * // Infers: string\n *\n * // With precision constraint\n * const btcAmount = z_bigdecimal({ precision: 8 });\n *\n * // With min/max constraints\n * const percentage = z_bigdecimal({\n * min: '0',\n * max: '100',\n * precision: 2\n * });\n * ```\n */\nexport function createBigDecimalSchema(\n options: BigDecimalSchemaOptions = {}\n): DecoratedBigDecimalSchema {\n const {\n precision,\n min,\n max,\n } = options;\n\n // Create the base schema with validation\n let bigDecimalSchema = z.string().refine(\n (value) => {\n if (!isValidBigDecimal(value)) return false;\n\n try {\n const bigValue = new Big(value);\n\n // Check precision (decimal places)\n if (precision !== undefined) {\n const decimalPlaces = value.includes('.')\n ? value.split('.')[1]?.length ?? 0\n : 0;\n if (decimalPlaces > precision) return false;\n }\n\n // Check min\n if (min !== undefined) {\n const minValue = new Big(min);\n if (bigValue.lt(minValue)) return false;\n }\n\n // Check max\n if (max !== undefined) {\n const maxValue = new Big(max);\n if (bigValue.gt(maxValue)) return false;\n }\n\n return true;\n } catch {\n return false;\n }\n },\n {\n message: precision !== undefined\n ? `Invalid decimal number (max ${precision} decimal places${min !== undefined ? `, min: ${min}` : ''}${max !== undefined ? `, max: ${max}` : ''})`\n : `Invalid decimal number${min !== undefined ? ` (min: ${min}` : ''}${max !== undefined ? `${min !== undefined ? ', ' : ' ('}max: ${max})` : min !== undefined ? ')' : ''}`\n }\n );\n\n const bigDecimalMetadata: BigDecimalSchemaMetadata = {\n isBigDecimal: true,\n ...(precision !== undefined && { precision }),\n ...(min !== undefined && { min }),\n ...(max !== undefined && { max }),\n };\n\n // Initialize or extend SCHEMA_METADATA with bigdecimal config\n const existingMetadata: CustomFieldMetadata = (bigDecimalSchema as any)[SCHEMA_METADATA] || {};\n (bigDecimalSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n bigDecimalConfig: bigDecimalMetadata,\n };\n\n // Add chainable decorator methods to the bigdecimal schema instance\n // This allows: z_bigdecimal().bigDecimalUI({ display: { decimalPlaces: 4 } }).isHidden()\n addChainableMethods(bigDecimalSchema);\n\n return bigDecimalSchema as unknown as DecoratedBigDecimalSchema;\n}\n\n/**\n * The chainable methods of `DecoratedBigDecimalSchema`, returning `this` so a chain of several decorations keeps\n * the type it reached: `.isSummaryField()` turns the field into a `DecoratedPrimitiveZodType<DecoratedBigDecimalSchema>`,\n * and a spec or UI method called after it must return that, not the bare factory type. A method\n * returning `DecoratedBigDecimalSchema` itself won that overload inside the intersection, so a resource\n * specification's field map rejected `schemaShape.x.<factory>Spec(...)` on a decorated field.\n */\nexport interface DecoratedBigDecimalSchemaMethods {\n [ZodDecorator.IS_DB_INDEXED](): this;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): this;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): this;\n [ZodDecorator.BIGDECIMAL_UI](params?: ZodDecorator_ParamsType[ZodDecorator.BIGDECIMAL_UI]): this;\n [ZodDecorator.BIGDECIMAL_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.BIGDECIMAL_SPEC]): this;\n addDecorators(decorators: DecoratorInput[]): this;\n}\n\n/**\n * Return type for bigdecimal schemas - includes decorator methods.\n * Note: IS_FOREIGN_KEY is not applicable to bigdecimal values.\n * IS_DB_INDEXED indexes the string value directly for query optimization.\n */\nexport type DecoratedBigDecimalSchema = z.ZodString & DecoratedBigDecimalSchemaMethods;\n\n/**\n * Creates a bigdecimal schema for precise decimal numbers stored as strings.\n * Named z_bigdecimal to indicate it's a Zod helper function exported standalone.\n *\n * BigDecimal values are stored as strings to avoid floating-point precision issues.\n * Use big.js for arithmetic operations on these values.\n *\n * @example\n * ```typescript\n * import { z_bigdecimal } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage\n * z_bigdecimal() // Any valid decimal number as string\n *\n * // With options\n * z_bigdecimal({ precision: 2 }) // Max 2 decimal places\n * z_bigdecimal({ min: '0', max: '100' }) // Range constraint\n * z_bigdecimal({ precision: 8, min: '0' }) // Crypto amount\n *\n * // With decorators (chainable)\n * z_bigdecimal().bigDecimalUI({ display: { decimalPlaces: 4 } })\n * z_bigdecimal({ precision: 2 }).isHidden({ edit: true })\n *\n * // Usage example\n * const price: BigDecimalValue = \"19.99\";\n * const btcAmount: BigDecimalValue = \"0.00000001\";\n *\n * // Arithmetic with big.js\n * import Big from 'big.js';\n * const total = new Big(price).plus(\"10.01\").toString(); // \"30.00\"\n * ```\n */\nexport function z_bigdecimal(\n options?: BigDecimalSchemaOptions\n): DecoratedBigDecimalSchema {\n return createBigDecimalSchema(options) as DecoratedBigDecimalSchema;\n}\n/** @wildo_source:part:end zod.factories.bigdecimal */\n\n// ============================================================================\n// BIGDECIMAL UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Add two bigdecimal values.\n * @param a - First value\n * @param b - Second value\n * @returns Sum as string\n */\nexport function bigDecimalAdd(a: BigDecimalValue, b: BigDecimalValue): BigDecimalValue {\n return new Big(a).plus(b).toString();\n}\n\n/**\n * Subtract two bigdecimal values.\n * @param a - Value to subtract from\n * @param b - Value to subtract\n * @returns Difference as string\n */\nexport function bigDecimalSubtract(a: BigDecimalValue, b: BigDecimalValue): BigDecimalValue {\n return new Big(a).minus(b).toString();\n}\n\n/**\n * Multiply two bigdecimal values.\n * @param a - First value\n * @param b - Second value\n * @returns Product as string\n */\nexport function bigDecimalMultiply(a: BigDecimalValue, b: BigDecimalValue): BigDecimalValue {\n return new Big(a).times(b).toString();\n}\n\n/**\n * Divide two bigdecimal values.\n * @param a - Dividend\n * @param b - Divisor\n * @param precision - Number of decimal places for result (default: 20)\n * @returns Quotient as string\n */\nexport function bigDecimalDivide(a: BigDecimalValue, b: BigDecimalValue, precision: number = 20): BigDecimalValue {\n return new Big(a).div(b).round(precision).toString();\n}\n\n/**\n * Compare two bigdecimal values.\n * @param a - First value\n * @param b - Second value\n * @returns -1 if a < b, 0 if a === b, 1 if a > b\n */\nexport function bigDecimalCompare(a: BigDecimalValue, b: BigDecimalValue): -1 | 0 | 1 {\n return new Big(a).cmp(b) as -1 | 0 | 1;\n}\n\n/**\n * Round a bigdecimal value to specified precision.\n * @param value - Value to round\n * @param precision - Number of decimal places\n * @param roundingMode - big.js rounding mode (default: ROUND_HALF_UP)\n * @returns Rounded value as string\n */\nexport function bigDecimalRound(\n value: BigDecimalValue,\n precision: number,\n roundingMode: Big.RoundingMode = Big.roundHalfUp\n): BigDecimalValue {\n return new Big(value).round(precision, roundingMode).toString();\n}\n\n/**\n * Format a bigdecimal value for display with fixed decimal places.\n * @param value - Value to format\n * @param decimalPlaces - Number of decimal places to show\n * @returns Formatted string with trailing zeros if needed\n */\nexport function bigDecimalFormat(value: BigDecimalValue, decimalPlaces: number): string {\n return new Big(value).toFixed(decimalPlaces);\n}\n\n/**\n * Check if a bigdecimal value is zero.\n * @param value - Value to check\n * @returns true if value equals zero\n */\nexport function bigDecimalIsZero(value: BigDecimalValue): boolean {\n return new Big(value).eq(0);\n}\n\n/**\n * Check if a bigdecimal value is positive (> 0).\n * @param value - Value to check\n * @returns true if value is greater than zero\n */\nexport function bigDecimalIsPositive(value: BigDecimalValue): boolean {\n return new Big(value).gt(0);\n}\n\n/**\n * Check if a bigdecimal value is negative (< 0).\n * @param value - Value to check\n * @returns true if value is less than zero\n */\nexport function bigDecimalIsNegative(value: BigDecimalValue): boolean {\n return new Big(value).lt(0);\n}\n\n/**\n * Get the absolute value of a bigdecimal.\n * @param value - Value\n * @returns Absolute value as string\n */\nexport function bigDecimalAbs(value: BigDecimalValue): BigDecimalValue {\n return new Big(value).abs().toString();\n}\n\n/**\n * Convert a number to bigdecimal string.\n * @param value - Number to convert\n * @returns String representation\n */\nexport function toBigDecimal(value: number): BigDecimalValue {\n return new Big(value).toString();\n}\n\n/**\n * Convert a bigdecimal string to number.\n * Warning: May lose precision for very large or very precise numbers.\n * @param value - BigDecimal string\n * @returns Number value\n */\nexport function fromBigDecimal(value: BigDecimalValue): number {\n return new Big(value).toNumber();\n}\n\n"]}
@@ -48,6 +48,22 @@ export declare const CodeValueSchema: z.ZodObject<{
48
48
  * @returns A Zod object schema with metadata for code detection
49
49
  */
50
50
  export declare function createCodeSchema(options?: CodeSchemaOptions): DecoratedCodeSchema;
51
+ /**
52
+ * The chainable methods of `DecoratedCodeSchema`, returning `this` so a chain of several decorations keeps
53
+ * the type it reached: `.isSummaryField()` turns the field into a `DecoratedPrimitiveZodType<DecoratedCodeSchema>`,
54
+ * and a spec or UI method called after it must return that, not the bare factory type. A method
55
+ * returning `DecoratedCodeSchema` itself won that overload inside the intersection, so a resource
56
+ * specification's field map rejected `schemaShape.x.<factory>Spec(...)` on a decorated field.
57
+ */
58
+ export interface DecoratedCodeSchemaMethods {
59
+ [ZodDecorator.IS_DB_INDEXED](): this;
60
+ /** Installed at runtime with the other chainable methods; declared here so an authored `.codeUI(…)` typechecks. */
61
+ [ZodDecorator.CODE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.CODE_UI]): this;
62
+ [ZodDecorator.CODE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.CODE_SPEC]): this;
63
+ [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): this;
64
+ [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): this;
65
+ addDecorators(decorators: DecoratorInput[]): this;
66
+ }
51
67
  /**
52
68
  * Return type for code schemas - includes decorator methods.
53
69
  * IS_DB_INDEXED will index internal fields (content, language) for query optimization.
@@ -55,14 +71,7 @@ export declare function createCodeSchema(options?: CodeSchemaOptions): Decorated
55
71
  export type DecoratedCodeSchema = z.ZodObject<{
56
72
  content: z.ZodString;
57
73
  language: z.ZodString;
58
- }> & {
59
- [ZodDecorator.IS_DB_INDEXED](): DecoratedCodeSchema;
60
- /** Installed at runtime with the other chainable methods; declared here so an authored `.codeUI(…)` typechecks. */
61
- [ZodDecorator.CODE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.CODE_UI]): DecoratedCodeSchema;
62
- [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedCodeSchema;
63
- [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedCodeSchema;
64
- addDecorators(decorators: DecoratorInput[]): DecoratedCodeSchema;
65
- };
74
+ }> & DecoratedCodeSchemaMethods;
66
75
  /**
67
76
  * Creates a code schema for code snippets with language information.
68
77
  * Named z_code to indicate it's a Zod helper function exported standalone.
@@ -1 +1 @@
1
- {"version":3,"file":"zod-code.d.ts","sourceRoot":"","sources":["../../../src/zod-code.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAA4D,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC1L,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,ySAOtB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAA;CAAE,CAGvF,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,iBAAsB,GAC9B,mBAAmB,CA6CrB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,SAAS,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC;CACvB,CAAC,GAAG;IACH,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,mBAAmB,CAAC;IACpD,mHAAmH;IACnH,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC,YAAY,C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ChD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AACD,gDAAgD;AAEhD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAsB;IAC3D,MAAM,YAAY,GAA2B;QAC3C,UAAU,EAAE,YAAY;QACxB,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,KAAK;QACV,CAAC,EAAE,GAAG;QACN,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,KAAK;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,YAAY;QACxB,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;KACxB,CAAC;IAEF,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,mBAAmB,CAAC,QAAQ,CAAC,QAAe,CAAC,CAAC;AACvD,CAAC","sourcesContent":["\n// ============================================================================\n// CODE SCHEMA HELPER\n// ============================================================================\n\nimport { DecoratorInput, SCHEMA_METADATA, CustomFieldMetadata, CodeSchemaMetadata, CodeSchemaOptions, CodeLanguage, ZodDecorator, ZodDecorator_ParamsType } from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods } from \"./zod.module-override\";\n\n/**\n * Code value type - represents a code snippet with language information.\n */\nexport interface CodeValue {\n /** The code content */\n content: string;\n /** Programming language for syntax highlighting and validation */\n language: string;\n}\n\n/**\n * Common programming languages for code schema language field.\n * Can be extended with any string value.\n */\nexport const CommonCodeLanguages = [\n 'javascript', 'typescript', 'python', 'java', 'csharp', 'cpp', 'c',\n 'go', 'rust', 'ruby', 'php', 'swift', 'kotlin', 'scala',\n 'html', 'css', 'scss', 'less', 'json', 'yaml', 'xml', 'markdown',\n 'sql', 'graphql', 'bash', 'shell', 'powershell',\n 'dockerfile', 'nginx', 'apache',\n 'plaintext'\n] as const;\n\n/**\n * Zod schema for CodeValue.\n */\nexport const CodeValueSchema: z.ZodObject<{ content: z.ZodString; language: z.ZodString }> = z.object({\n content: z.string().describe(\"The code itself.\"),\n language: z.string().describe(\"The language the code is written in, for highlighting and validation.\"),\n});\n\n/**\n * @wildo_source:part:start zod.factories.code facet:layer:shared facet:family:schema-factory\n *\n * z_code() - Creates code schemas for code snippets with language.\n *\n * @example\n * ```typescript\n * import { z_code } from '@wildo-ai/zod-decorators';\n *\n * const snippet = z_code();\n * const restrictedCode = z_code({\n * allowedLanguages: ['javascript', 'typescript', 'python'],\n * maxLength: 10000\n * });\n *\n * // UI props are now set via .codeUI():\n * z_code().codeUI({ defaultLanguage: 'javascript', syntaxHighlighting: true })\n * z_code().codeUI({ display: { showLineNumbers: true }, edit: { showLineNumbers: false } })\n * ```\n */\n\n/**\n * Creates a code schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for code field\n * @returns A Zod object schema with metadata for code detection\n */\nexport function createCodeSchema(\n options: CodeSchemaOptions = {}\n): DecoratedCodeSchema {\n const {\n allowedLanguages,\n maxLength,\n minLength,\n } = options;\n\n // Create the content schema with optional length constraints\n let contentSchema = z.string();\n if (minLength !== undefined) {\n contentSchema = contentSchema.min(minLength);\n }\n if (maxLength !== undefined) {\n contentSchema = contentSchema.max(maxLength);\n }\n\n // Language is stored as a string. Allowed languages restriction is enforced\n // through codeConfig.allowedLanguages metadata - UI components read this\n // to filter available options, same pattern as money currencies.\n const languageSchema = z.string();\n\n // Create the code object schema\n const codeSchema = z.object({\n content: contentSchema.describe(\"The code itself.\"),\n language: languageSchema.describe(\"The language the code is written in, for highlighting and validation.\"),\n });\n\n const codeMetadata: CodeSchemaMetadata = {\n isCode: true,\n ...(allowedLanguages !== undefined && { allowedLanguages }),\n ...(maxLength !== undefined && { maxLength }),\n ...(minLength !== undefined && { minLength }),\n };\n\n // Initialize or extend SCHEMA_METADATA with code config\n const existingMetadata: CustomFieldMetadata = (codeSchema as any)[SCHEMA_METADATA] || {};\n (codeSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n codeConfig: codeMetadata,\n };\n\n // Add chainable decorator methods to the code schema instance\n addChainableMethods(codeSchema);\n\n return codeSchema as unknown as DecoratedCodeSchema;\n}\n\n/**\n * Return type for code schemas - includes decorator methods.\n * IS_DB_INDEXED will index internal fields (content, language) for query optimization.\n */\nexport type DecoratedCodeSchema = z.ZodObject<{\n content: z.ZodString;\n language: z.ZodString;\n}> & {\n [ZodDecorator.IS_DB_INDEXED](): DecoratedCodeSchema;\n /** Installed at runtime with the other chainable methods; declared here so an authored `.codeUI(…)` typechecks. */\n [ZodDecorator.CODE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.CODE_UI]): DecoratedCodeSchema;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): DecoratedCodeSchema;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): DecoratedCodeSchema;\n addDecorators(decorators: DecoratorInput[]): DecoratedCodeSchema;\n};\n\n/**\n * Creates a code schema for code snippets with language information.\n * Named z_code to indicate it's a Zod helper function exported standalone.\n *\n * Code values are stored as: { content: string, language: string }\n * - content: The actual code text\n * - language: Programming language identifier for syntax highlighting\n *\n * @example\n * ```typescript\n * import { z_code } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage\n * z_code() // All languages, default 'plaintext'\n *\n * // With options (structural only)\n * z_code({ allowedLanguages: ['javascript', 'typescript'] })\n * z_code({ maxLength: 5000 })\n *\n * // UI props via .codeUI()\n * z_code().codeUI({ defaultLanguage: 'typescript' })\n * z_code().codeUI({ display: { showLineNumbers: false } })\n * ```\n */\nexport function z_code(options?: CodeSchemaOptions): DecoratedCodeSchema {\n return createCodeSchema(options);\n}\n/** @wildo_source:part:end zod.factories.code */\n\n// ============================================================================\n// UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Get the display name for a code language.\n */\nexport function getLanguageDisplayName(language: CodeLanguage): string {\n const displayNames: Record<string, string> = {\n javascript: 'JavaScript',\n typescript: 'TypeScript',\n python: 'Python',\n java: 'Java',\n csharp: 'C#',\n cpp: 'C++',\n c: 'C',\n go: 'Go',\n rust: 'Rust',\n ruby: 'Ruby',\n php: 'PHP',\n swift: 'Swift',\n kotlin: 'Kotlin',\n scala: 'Scala',\n html: 'HTML',\n css: 'CSS',\n scss: 'SCSS',\n less: 'Less',\n json: 'JSON',\n yaml: 'YAML',\n xml: 'XML',\n markdown: 'Markdown',\n sql: 'SQL',\n graphql: 'GraphQL',\n bash: 'Bash',\n shell: 'Shell',\n powershell: 'PowerShell',\n dockerfile: 'Dockerfile',\n nginx: 'Nginx',\n apache: 'Apache',\n plaintext: 'Plain Text',\n };\n\n return displayNames[language] || language;\n}\n\n/**\n * Check if a language is in the common languages list.\n */\nexport function isCommonLanguage(language: string): language is typeof CommonCodeLanguages[number] {\n return CommonCodeLanguages.includes(language as any);\n}\n\n"]}
1
+ {"version":3,"file":"zod-code.js","sourceRoot":"","sources":["../../../src/zod-code.ts"],"names":[],"mappings":"AACA,+EAA+E;AAC/E,qBAAqB;A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AAU,EAAE,YAAY;QACxB,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,KAAK;QACV,CAAC,EAAE,GAAG;QACN,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,KAAK;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,YAAY;QACxB,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;KACxB,CAAC;IAEF,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,mBAAmB,CAAC,QAAQ,CAAC,QAAe,CAAC,CAAC;AACvD,CAAC","sourcesContent":["\n// ============================================================================\n// CODE SCHEMA HELPER\n// ============================================================================\n\nimport { DecoratorInput, SCHEMA_METADATA, CustomFieldMetadata, CodeSchemaMetadata, CodeSchemaOptions, CodeLanguage, ZodDecorator, ZodDecorator_ParamsType } from \"./zod-decorators.types\";\nimport { z } from \"zod\";\nimport { addChainableMethods } from \"./zod.module-override\";\n\n/**\n * Code value type - represents a code snippet with language information.\n */\nexport interface CodeValue {\n /** The code content */\n content: string;\n /** Programming language for syntax highlighting and validation */\n language: string;\n}\n\n/**\n * Common programming languages for code schema language field.\n * Can be extended with any string value.\n */\nexport const CommonCodeLanguages = [\n 'javascript', 'typescript', 'python', 'java', 'csharp', 'cpp', 'c',\n 'go', 'rust', 'ruby', 'php', 'swift', 'kotlin', 'scala',\n 'html', 'css', 'scss', 'less', 'json', 'yaml', 'xml', 'markdown',\n 'sql', 'graphql', 'bash', 'shell', 'powershell',\n 'dockerfile', 'nginx', 'apache',\n 'plaintext'\n] as const;\n\n/**\n * Zod schema for CodeValue.\n */\nexport const CodeValueSchema: z.ZodObject<{ content: z.ZodString; language: z.ZodString }> = z.object({\n content: z.string().describe(\"The code itself.\"),\n language: z.string().describe(\"The language the code is written in, for highlighting and validation.\"),\n});\n\n/**\n * @wildo_source:part:start zod.factories.code facet:layer:shared facet:family:schema-factory\n *\n * z_code() - Creates code schemas for code snippets with language.\n *\n * @example\n * ```typescript\n * import { z_code } from '@wildo-ai/zod-decorators';\n *\n * const snippet = z_code();\n * const restrictedCode = z_code({\n * allowedLanguages: ['javascript', 'typescript', 'python'],\n * maxLength: 10000\n * });\n *\n * // UI props are now set via .codeUI():\n * z_code().codeUI({ defaultLanguage: 'javascript', syntaxHighlighting: true })\n * z_code().codeUI({ display: { showLineNumbers: true }, edit: { showLineNumbers: false } })\n * ```\n */\n\n/**\n * Creates a code schema with metadata for detection and form component rendering.\n *\n * @param options - Configuration options for code field\n * @returns A Zod object schema with metadata for code detection\n */\nexport function createCodeSchema(\n options: CodeSchemaOptions = {}\n): DecoratedCodeSchema {\n const {\n allowedLanguages,\n maxLength,\n minLength,\n } = options;\n\n // Create the content schema with optional length constraints\n let contentSchema = z.string();\n if (minLength !== undefined) {\n contentSchema = contentSchema.min(minLength);\n }\n if (maxLength !== undefined) {\n contentSchema = contentSchema.max(maxLength);\n }\n\n // Language is stored as a string. Allowed languages restriction is enforced\n // through codeConfig.allowedLanguages metadata - UI components read this\n // to filter available options, same pattern as money currencies.\n const languageSchema = z.string();\n\n // Create the code object schema\n const codeSchema = z.object({\n content: contentSchema.describe(\"The code itself.\"),\n language: languageSchema.describe(\"The language the code is written in, for highlighting and validation.\"),\n });\n\n const codeMetadata: CodeSchemaMetadata = {\n isCode: true,\n ...(allowedLanguages !== undefined && { allowedLanguages }),\n ...(maxLength !== undefined && { maxLength }),\n ...(minLength !== undefined && { minLength }),\n };\n\n // Initialize or extend SCHEMA_METADATA with code config\n const existingMetadata: CustomFieldMetadata = (codeSchema as any)[SCHEMA_METADATA] || {};\n (codeSchema as any)[SCHEMA_METADATA] = {\n ...existingMetadata,\n codeConfig: codeMetadata,\n };\n\n // Add chainable decorator methods to the code schema instance\n addChainableMethods(codeSchema);\n\n return codeSchema as unknown as DecoratedCodeSchema;\n}\n\n/**\n * The chainable methods of `DecoratedCodeSchema`, returning `this` so a chain of several decorations keeps\n * the type it reached: `.isSummaryField()` turns the field into a `DecoratedPrimitiveZodType<DecoratedCodeSchema>`,\n * and a spec or UI method called after it must return that, not the bare factory type. A method\n * returning `DecoratedCodeSchema` itself won that overload inside the intersection, so a resource\n * specification's field map rejected `schemaShape.x.<factory>Spec(...)` on a decorated field.\n */\nexport interface DecoratedCodeSchemaMethods {\n [ZodDecorator.IS_DB_INDEXED](): this;\n /** Installed at runtime with the other chainable methods; declared here so an authored `.codeUI(…)` typechecks. */\n [ZodDecorator.CODE_UI](params?: ZodDecorator_ParamsType[ZodDecorator.CODE_UI]): this;\n [ZodDecorator.CODE_SPEC](params?: ZodDecorator_ParamsType[ZodDecorator.CODE_SPEC]): this;\n [ZodDecorator.IS_HIDDEN](params?: ZodDecorator_ParamsType[ZodDecorator.IS_HIDDEN]): this;\n [ZodDecorator.IS_NOT_EDITABLE](params?: ZodDecorator_ParamsType[ZodDecorator.IS_NOT_EDITABLE]): this;\n addDecorators(decorators: DecoratorInput[]): this;\n}\n\n/**\n * Return type for code schemas - includes decorator methods.\n * IS_DB_INDEXED will index internal fields (content, language) for query optimization.\n */\nexport type DecoratedCodeSchema = z.ZodObject<{\n content: z.ZodString;\n language: z.ZodString;\n}> & DecoratedCodeSchemaMethods;\n\n/**\n * Creates a code schema for code snippets with language information.\n * Named z_code to indicate it's a Zod helper function exported standalone.\n *\n * Code values are stored as: { content: string, language: string }\n * - content: The actual code text\n * - language: Programming language identifier for syntax highlighting\n *\n * @example\n * ```typescript\n * import { z_code } from '@wildo-ai/zod-decorators';\n *\n * // Simple usage\n * z_code() // All languages, default 'plaintext'\n *\n * // With options (structural only)\n * z_code({ allowedLanguages: ['javascript', 'typescript'] })\n * z_code({ maxLength: 5000 })\n *\n * // UI props via .codeUI()\n * z_code().codeUI({ defaultLanguage: 'typescript' })\n * z_code().codeUI({ display: { showLineNumbers: false } })\n * ```\n */\nexport function z_code(options?: CodeSchemaOptions): DecoratedCodeSchema {\n return createCodeSchema(options);\n}\n/** @wildo_source:part:end zod.factories.code */\n\n// ============================================================================\n// UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Get the display name for a code language.\n */\nexport function getLanguageDisplayName(language: CodeLanguage): string {\n const displayNames: Record<string, string> = {\n javascript: 'JavaScript',\n typescript: 'TypeScript',\n python: 'Python',\n java: 'Java',\n csharp: 'C#',\n cpp: 'C++',\n c: 'C',\n go: 'Go',\n rust: 'Rust',\n ruby: 'Ruby',\n php: 'PHP',\n swift: 'Swift',\n kotlin: 'Kotlin',\n scala: 'Scala',\n html: 'HTML',\n css: 'CSS',\n scss: 'SCSS',\n less: 'Less',\n json: 'JSON',\n yaml: 'YAML',\n xml: 'XML',\n markdown: 'Markdown',\n sql: 'SQL',\n graphql: 'GraphQL',\n bash: 'Bash',\n shell: 'Shell',\n powershell: 'PowerShell',\n dockerfile: 'Dockerfile',\n nginx: 'Nginx',\n apache: 'Apache',\n plaintext: 'Plain Text',\n };\n\n return displayNames[language] || language;\n}\n\n/**\n * Check if a language is in the common languages list.\n */\nexport function isCommonLanguage(language: string): language is typeof CommonCodeLanguages[number] {\n return CommonCodeLanguages.includes(language as any);\n}\n\n"]}