@pattern-stack/codegen 0.4.3 → 0.4.4

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.
@@ -1573,7 +1573,7 @@ var init_entity_definition_schema = __esm({
1573
1573
 
1574
1574
  // src/schema/event-definition.schema.ts
1575
1575
  import { z as z2 } from "zod";
1576
- var EVENT_DIRECTIONS, EVENT_FIELD_TYPES, RESERVED_EVENT_POOLS, EVENT_BACKOFF_STRATEGIES, DIRECTION_TO_POOL, EventDirectionSchema, EventFieldTypeSchema, EventPoolSchema, EventPayloadFieldSchema, RetrySchema, SNAKE_CASE_RE, EventDefinitionSchemaCore, EventDefinitionSchemaRefined, EventDefinitionSchema;
1576
+ var EVENT_DIRECTIONS, EVENT_FIELD_TYPES, EVENT_ARRAY_ITEM_TYPES, RESERVED_EVENT_POOLS, EVENT_BACKOFF_STRATEGIES, DIRECTION_TO_POOL, EventDirectionSchema, EventFieldTypeSchema, EventArrayItemTypeSchema, EventPoolSchema, EventPayloadFieldSchema, RetrySchema, SNAKE_CASE_RE, EventDefinitionSchemaCore, EventDefinitionSchemaRefined, EventDefinitionSchema;
1577
1577
  var init_event_definition_schema = __esm({
1578
1578
  "src/schema/event-definition.schema.ts"() {
1579
1579
  "use strict";
@@ -1584,7 +1584,15 @@ var init_event_definition_schema = __esm({
1584
1584
  "number",
1585
1585
  "boolean",
1586
1586
  "date",
1587
- "json"
1587
+ "json",
1588
+ "array"
1589
+ ];
1590
+ EVENT_ARRAY_ITEM_TYPES = [
1591
+ "uuid",
1592
+ "string",
1593
+ "number",
1594
+ "boolean",
1595
+ "date"
1588
1596
  ];
1589
1597
  RESERVED_EVENT_POOLS = [
1590
1598
  "events_inbound",
@@ -1599,12 +1607,29 @@ var init_event_definition_schema = __esm({
1599
1607
  };
1600
1608
  EventDirectionSchema = z2.enum(EVENT_DIRECTIONS);
1601
1609
  EventFieldTypeSchema = z2.enum(EVENT_FIELD_TYPES);
1610
+ EventArrayItemTypeSchema = z2.enum(EVENT_ARRAY_ITEM_TYPES);
1602
1611
  EventPoolSchema = z2.enum(RESERVED_EVENT_POOLS);
1603
1612
  EventPayloadFieldSchema = z2.object({
1604
1613
  type: EventFieldTypeSchema,
1614
+ items: EventArrayItemTypeSchema.optional(),
1605
1615
  nullable: z2.boolean().optional().default(false),
1606
1616
  description: z2.string().optional()
1607
- }).strict();
1617
+ }).strict().superRefine((data, ctx) => {
1618
+ if (data.type === "array" && data.items === void 0) {
1619
+ ctx.addIssue({
1620
+ code: z2.ZodIssueCode.custom,
1621
+ message: "'items' is required when type is 'array'",
1622
+ path: ["items"]
1623
+ });
1624
+ }
1625
+ if (data.type !== "array" && data.items !== void 0) {
1626
+ ctx.addIssue({
1627
+ code: z2.ZodIssueCode.custom,
1628
+ message: `'items' is only valid when type is 'array' (got '${data.type}')`,
1629
+ path: ["items"]
1630
+ });
1631
+ }
1632
+ });
1608
1633
  RetrySchema = z2.object({
1609
1634
  attempts: z2.number().int().min(0).max(20),
1610
1635
  backoff: z2.enum(EVENT_BACKOFF_STRATEGIES)
@@ -216755,11 +216780,23 @@ function toPascalCase2(input) {
216755
216780
  return input.split("_").filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
216756
216781
  }
216757
216782
  function tsTypeForField(field) {
216758
- const base = TS_TYPE_BY_FIELD[field.type];
216783
+ let base;
216784
+ if (field.type === "array") {
216785
+ const itemType = field.items;
216786
+ base = `${TS_TYPE_BY_FIELD[itemType]}[]`;
216787
+ } else {
216788
+ base = TS_TYPE_BY_FIELD[field.type];
216789
+ }
216759
216790
  return field.nullable ? `${base} | null` : base;
216760
216791
  }
216761
216792
  function zodExprForField(field) {
216762
- const base = ZOD_EXPR_BY_FIELD[field.type];
216793
+ let base;
216794
+ if (field.type === "array") {
216795
+ const itemType = field.items;
216796
+ base = `z.array(${ZOD_EXPR_BY_FIELD[itemType]})`;
216797
+ } else {
216798
+ base = ZOD_EXPR_BY_FIELD[field.type];
216799
+ }
216763
216800
  return field.nullable ? `${base}.nullable()` : base;
216764
216801
  }
216765
216802
  function aggregateTypeLiteral(ev) {