@stndrds/schema 1.0.0-alpha.276 → 1.0.0-alpha.278

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 (73) hide show
  1. package/dist/{all-D5zeUllO.d.mts → all-BSeTO0fj.d.mts} +20 -3
  2. package/dist/{all--B2_3ksI.d.ts → all-DoYgTt64.d.ts} +20 -3
  3. package/dist/{attributes-_b3Db8vT.d.ts → attributes-Da15v-sw.d.ts} +1 -1
  4. package/dist/{attributes-lBLiOIY3.d.mts → attributes-VsYmgI0A.d.mts} +1 -1
  5. package/dist/{chunk-4USPA67J.mjs → chunk-5PLJHYSL.mjs} +139 -26
  6. package/dist/{chunk-T7BST4JS.js → chunk-DEHBEFGO.js} +3 -3
  7. package/dist/{chunk-RAF6K6VG.js → chunk-NELH4AXI.js} +30 -18
  8. package/dist/{chunk-U7QUIEFF.mjs → chunk-PQEOIDXD.mjs} +1 -1
  9. package/dist/{chunk-EDOEX3O7.js → chunk-QMAVKX3Y.js} +178 -55
  10. package/dist/{chunk-QLU5QR7M.mjs → chunk-V2WJFUZW.mjs} +16 -8
  11. package/dist/{chunk-RBG2YMF2.mjs → chunk-YCWGUPSI.mjs} +26 -16
  12. package/dist/{chunk-F3YPU2N6.js → chunk-ZBWTAKZO.js} +16 -8
  13. package/dist/exceptions.d.mts +15 -10
  14. package/dist/exceptions.d.ts +15 -10
  15. package/dist/exceptions.js +39 -39
  16. package/dist/exceptions.mjs +1 -1
  17. package/dist/{helpers-C1VVEAOO.d.mts → helpers-BYhVd4Gw.d.mts} +3 -3
  18. package/dist/{helpers-vQ6kp8ET.d.ts → helpers-D2cL7hI2.d.ts} +3 -3
  19. package/dist/index-CixTESyP.d.mts +790 -0
  20. package/dist/index-dJ6fAwcG.d.ts +790 -0
  21. package/dist/index.d.mts +2662 -433
  22. package/dist/index.d.ts +2662 -433
  23. package/dist/index.js +641 -391
  24. package/dist/index.mjs +416 -223
  25. package/dist/{migrations-BXd2ZGfM.d.mts → migrations-Dy9K8kJ0.d.mts} +1 -1
  26. package/dist/{migrations-DcuJZ8qO.d.ts → migrations-hbZHm8Tm.d.ts} +1 -1
  27. package/dist/{objects-BCaBw2ef.d.mts → objects-Cvt2T2Q5.d.mts} +19 -3
  28. package/dist/{objects-A1ED9af-.d.ts → objects-_6M6ngH3.d.ts} +19 -3
  29. package/dist/{types-DNz3ITS-.d.mts → types-CX7S3Fhh.d.mts} +1 -1
  30. package/dist/{types-DqLi1tx1.d.ts → types-DseDsbMu.d.ts} +1 -1
  31. package/dist/validation/all.d.mts +7 -7
  32. package/dist/validation/all.d.ts +7 -7
  33. package/dist/validation/all.js +33 -33
  34. package/dist/validation/all.mjs +8 -8
  35. package/dist/validation/complex/currency.d.mts +2 -2
  36. package/dist/validation/complex/currency.d.ts +2 -2
  37. package/dist/validation/complex/location.d.mts +2 -2
  38. package/dist/validation/complex/location.d.ts +2 -2
  39. package/dist/validation/complex/phone.d.mts +2 -2
  40. package/dist/validation/complex/phone.d.ts +2 -2
  41. package/dist/validation/complex/relation.d.mts +2 -2
  42. package/dist/validation/complex/relation.d.ts +2 -2
  43. package/dist/validation/complex/richtext.d.mts +2 -2
  44. package/dist/validation/complex/richtext.d.ts +2 -2
  45. package/dist/validation/complex/select.d.mts +2 -2
  46. package/dist/validation/complex/select.d.ts +2 -2
  47. package/dist/validation/complex/user.d.mts +2 -2
  48. package/dist/validation/complex/user.d.ts +2 -2
  49. package/dist/validation/computed/formula.d.mts +2 -2
  50. package/dist/validation/computed/formula.d.ts +2 -2
  51. package/dist/validation/computed/rollup.d.mts +2 -2
  52. package/dist/validation/computed/rollup.d.ts +2 -2
  53. package/dist/validation/config/index.d.mts +4 -4
  54. package/dist/validation/config/index.d.ts +4 -4
  55. package/dist/validation/config/index.js +11 -11
  56. package/dist/validation/config/index.mjs +2 -2
  57. package/dist/validation/core/index.d.mts +3 -3
  58. package/dist/validation/core/index.d.ts +3 -3
  59. package/dist/validation/object/index.d.mts +5 -5
  60. package/dist/validation/object/index.d.ts +5 -5
  61. package/dist/validation/object/index.js +18 -18
  62. package/dist/validation/object/index.mjs +6 -6
  63. package/dist/validation/primitives/checkbox.d.mts +2 -2
  64. package/dist/validation/primitives/checkbox.d.ts +2 -2
  65. package/dist/validation/primitives/date.d.mts +2 -2
  66. package/dist/validation/primitives/date.d.ts +2 -2
  67. package/dist/validation/primitives/number.d.mts +2 -2
  68. package/dist/validation/primitives/number.d.ts +2 -2
  69. package/dist/validation/primitives/text.d.mts +2 -2
  70. package/dist/validation/primitives/text.d.ts +2 -2
  71. package/package.json +2 -2
  72. package/dist/index-Bq1KrQkR.d.ts +0 -2413
  73. package/dist/index-DtxtOBYT.d.mts +0 -2413
@@ -1,5 +1,5 @@
1
- import { SCHEMA_LIMITS, iconNameSchema } from './chunk-U7QUIEFF.mjs';
2
- import { ValidationError } from './chunk-QLU5QR7M.mjs';
1
+ import { SCHEMA_LIMITS, iconNameSchema } from './chunk-PQEOIDXD.mjs';
2
+ import { ValidationError } from './chunk-V2WJFUZW.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  // src/types/system-attributes.ts
@@ -311,19 +311,19 @@ function isAttributeGroupable(attribute) {
311
311
  function isAttributeKanbanGroupable(attribute) {
312
312
  return getAttributeCapabilities(attribute).query.kanbanGroupable;
313
313
  }
314
- function getRollupFilterOperators(attr) {
315
- const fn = attr.function;
316
- if (fn === "earliest" || fn === "latest") {
317
- return ATTRIBUTE_FILTER_OPERATORS.date;
318
- }
319
- if (fn === "original") {
320
- const targetType = attr.targetAttributeType;
321
- if (targetType && hasFilterOperatorEntry(targetType)) {
322
- return ATTRIBUTE_FILTER_OPERATORS[targetType];
323
- }
324
- return ATTRIBUTE_FILTER_OPERATORS.number;
314
+ function resolveEffectiveFilterType(attribute) {
315
+ if (attribute.type !== "rollup") return attribute.type;
316
+ const rollup = attribute;
317
+ if (rollup.function === "earliest" || rollup.function === "latest") return "date";
318
+ if (rollup.function === "original") {
319
+ const targetType = rollup.targetAttributeType;
320
+ if (targetType && hasFilterOperatorEntry(targetType)) return targetType;
325
321
  }
326
- return ATTRIBUTE_FILTER_OPERATORS.number;
322
+ return "number";
323
+ }
324
+ function getRollupFilterOperators(attr) {
325
+ const effectiveType = resolveEffectiveFilterType(attr);
326
+ return hasFilterOperatorEntry(effectiveType) ? ATTRIBUTE_FILTER_OPERATORS[effectiveType] : ATTRIBUTE_FILTER_OPERATORS.number;
327
327
  }
328
328
  function getRawFilterOperators(attribute) {
329
329
  if (attribute.type === "rollup") {
@@ -422,6 +422,90 @@ function now() {
422
422
  return { dynamic: "date", anchor: "now" };
423
423
  }
424
424
 
425
+ // src/filters/extract-filter-value.ts
426
+ function toAmount(value) {
427
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
428
+ if (typeof value === "string" && value.trim() !== "") {
429
+ const parsed = Number(value);
430
+ return Number.isFinite(parsed) ? parsed : null;
431
+ }
432
+ return null;
433
+ }
434
+ function extractCurrencyFilterValue(value) {
435
+ if (value !== null && typeof value === "object") {
436
+ return "value" in value ? toAmount(value.value) : null;
437
+ }
438
+ return toAmount(value);
439
+ }
440
+ function extractFilterValue(value) {
441
+ if (value === null || value === void 0) return null;
442
+ if (typeof value === "object" && "value" in value) {
443
+ return value.value ?? null;
444
+ }
445
+ return value;
446
+ }
447
+
448
+ // src/filters/polarity.ts
449
+ var NEGATIVE_OPERATORS = /* @__PURE__ */ new Set([
450
+ "is_not",
451
+ "not_contains",
452
+ "none_of",
453
+ "is_empty"
454
+ ]);
455
+ var NEGATIVE_TO_POSITIVE = {
456
+ is_not: "is",
457
+ not_contains: "contains",
458
+ none_of: "any_of",
459
+ is_empty: "is_not_empty"
460
+ };
461
+ function getOperatorPolarity(op) {
462
+ return NEGATIVE_OPERATORS.has(op) ? "none" : "any";
463
+ }
464
+ function normalizeForEdgeRpc(op) {
465
+ return NEGATIVE_TO_POSITIVE[op] ?? op;
466
+ }
467
+ var SINGLE_TO_MULTI = {
468
+ is: "any_of",
469
+ is_not: "none_of"
470
+ };
471
+ function toMultiValueOperator(op) {
472
+ return SINGLE_TO_MULTI[op] ?? op;
473
+ }
474
+ var SET_MEMBERSHIP_OPERATORS = new Set(
475
+ Object.values(SINGLE_TO_MULTI).filter((op) => op !== void 0)
476
+ );
477
+ function isSetMembershipOperator(op) {
478
+ return SET_MEMBERSHIP_OPERATORS.has(op);
479
+ }
480
+
481
+ // src/filters/canonicalize-value.ts
482
+ function canonicalizeFilterValue(rule, effectiveType) {
483
+ const value = rule.value;
484
+ if (isNoValueOperator(rule.operator)) return;
485
+ if (value === null || value === void 0) return;
486
+ if (isDynamicValue(value)) return;
487
+ if (isSetMembershipOperator(rule.operator)) {
488
+ if (!Array.isArray(value)) rule.value = [value];
489
+ return;
490
+ }
491
+ if (effectiveType !== "currency") return;
492
+ const amount = extractCurrencyFilterValue(value);
493
+ if (amount !== null) {
494
+ rule.value = amount;
495
+ return;
496
+ }
497
+ if (!hasCurrencyAmount(value)) return;
498
+ const message = `Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(
499
+ value
500
+ )}`;
501
+ throw new ValidationError(message, [{ path: ["value"], message }]);
502
+ }
503
+ function hasCurrencyAmount(value) {
504
+ if (typeof value !== "object") return true;
505
+ if (!("value" in value)) return false;
506
+ return value.value != null;
507
+ }
508
+
425
509
  // src/filters/normalize-operator.ts
426
510
  var SYNONYM_ALIASES = {
427
511
  // equality
@@ -505,6 +589,12 @@ function resolveIsWithinBounds(value, now2 = /* @__PURE__ */ new Date()) {
505
589
  if (!(Number.isFinite(bounds.startMs) && Number.isFinite(bounds.endMs))) return null;
506
590
  return bounds;
507
591
  }
592
+ function resolveUtcDayBounds(ms) {
593
+ if (!Number.isFinite(ms)) return null;
594
+ const startMs = utcDayStart(new Date(ms));
595
+ if (!Number.isFinite(startMs)) return null;
596
+ return { startMs, endMs: startMs + MS_PER_DAY };
597
+ }
508
598
  function toUtcDayString(ms) {
509
599
  return new Date(ms).toISOString().slice(0, 10);
510
600
  }
@@ -601,6 +691,11 @@ function assertRelativeDateValue(rule) {
601
691
  throw new ValidationError(m, [{ path: ["value"], message: m }]);
602
692
  }
603
693
  }
694
+ function applyCanonicalForm(rule, operator, effectiveType) {
695
+ rule.operator = operator;
696
+ canonicalizeFilterValue(rule, effectiveType);
697
+ assertRelativeDateValue(rule);
698
+ }
604
699
  function assertDynamicValueForAttribute(rule, attrType) {
605
700
  if (!isDynamicValue(rule.value)) return;
606
701
  const v = rule.value;
@@ -641,26 +736,24 @@ function validateQualifiedRule(rule, context) {
641
736
  ]);
642
737
  }
643
738
  const effectiveType = SYSTEM_FILTER_ATTRIBUTE_TYPES[rule.attribute] ?? "text";
644
- const normalizedOperator = resolveCanonicalOperator(rule.operator, effectiveType);
645
- if (!systemOps.includes(normalizedOperator)) {
739
+ const normalizedOperator2 = resolveCanonicalOperator(rule.operator, effectiveType);
740
+ if (!systemOps.includes(normalizedOperator2)) {
646
741
  const summary = `Operator "${rule.operator}" is not valid for system attribute "${rule.attribute}". Valid operators: ${systemOps.join(", ")}.`;
647
742
  throw new ValidationError(summary, [{ path: ["operator"], message: summary }]);
648
743
  }
649
- rule.operator = normalizedOperator;
650
- assertRelativeDateValue(rule);
744
+ applyCanonicalForm(rule, normalizedOperator2, effectiveType);
651
745
  return;
652
746
  }
653
747
  if (!rule.property) {
654
748
  assertDynamicValueForAttribute(rule, rootAttr.type);
655
749
  const ops = getAttributeFilterOperators(rootAttr);
656
- const normalizedOperator = resolveCanonicalOperator(rule.operator, rootAttr.type);
657
- if (!ops.includes(normalizedOperator)) {
750
+ const normalizedOperator2 = resolveCanonicalOperator(rule.operator, rootAttr.type);
751
+ if (!ops.includes(normalizedOperator2)) {
658
752
  const validList = ops.length ? ops.join(", ") : "(not filterable)";
659
753
  const summary = `Operator "${rule.operator}" is not valid for attribute "${rootAttr.name}". Valid operators: ${validList}.`;
660
754
  throw new ValidationError(summary, [{ path: ["operator"], message: summary }]);
661
755
  }
662
- rule.operator = normalizedOperator;
663
- assertRelativeDateValue(rule);
756
+ applyCanonicalForm(rule, normalizedOperator2, resolveEffectiveFilterType(rootAttr));
664
757
  return;
665
758
  }
666
759
  if (!REFERENCE_TYPES.has(rootAttr.type)) {
@@ -681,13 +774,22 @@ function validateQualifiedRule(rule, context) {
681
774
  [{ path: ["property"], message: `Unknown property: ${rule.property}` }]
682
775
  );
683
776
  }
684
- rule.operator = assertOperatorForType(rule.operator, propDef.type, "property");
685
- assertRelativeDateValue(rule);
777
+ const normalizedOperator = assertOperatorForType(rule.operator, propDef.type, "property");
778
+ applyCanonicalForm(rule, normalizedOperator, propDef.type);
686
779
  }
687
780
 
688
781
  // src/types/objects.ts
689
782
  var RESOURCE_VISIBILITIES = ["workspace", "private"];
690
783
  var LIST_VIEW_TAB_VISIBILITIES = ["all", ...RESOURCE_VISIBILITIES];
784
+ function parseResourceVisibility(value) {
785
+ if (typeof value === "string" && RESOURCE_VISIBILITIES.includes(value)) {
786
+ return value;
787
+ }
788
+ throw new ValidationError(
789
+ `visibility must be one of: ${RESOURCE_VISIBILITIES.join(", ")} (received: ${String(value)})`,
790
+ []
791
+ );
792
+ }
691
793
  var SYSTEM_FIELD_NAMES = [
692
794
  "id",
693
795
  "createdAt",
@@ -746,6 +848,10 @@ var dynamicFilterValueSchema = z.discriminatedUnion("dynamic", [
746
848
  anchor: z.enum(["today", "now"])
747
849
  }).strict()
748
850
  ]);
851
+ var dayMonthValueSchema = z.object({
852
+ month: z.number(),
853
+ day: z.number()
854
+ }).strict();
749
855
  var filterValueSchema = z.union([
750
856
  z.string(),
751
857
  z.number(),
@@ -754,6 +860,7 @@ var filterValueSchema = z.union([
754
860
  relativeDateValueSchema,
755
861
  currencyFilterValueSchema,
756
862
  phoneFilterValueSchema,
863
+ dayMonthValueSchema,
757
864
  dynamicFilterValueSchema,
758
865
  z.null()
759
866
  ]);
@@ -1115,6 +1222,11 @@ var emailsTabSchema = z.object({
1115
1222
  type: z.literal("emails"),
1116
1223
  emailAttributeIds: z.array(z.string()).max(SCHEMA_LIMITS.emailAttributesPerTab)
1117
1224
  }).strict();
1225
+ var meetingsTabSchema = z.object({
1226
+ ...baseTabShape,
1227
+ type: z.literal("meetings"),
1228
+ emailAttributeIds: z.array(z.string()).max(SCHEMA_LIMITS.emailAttributesPerTab)
1229
+ }).strict();
1118
1230
  var detailTabSchema = z.discriminatedUnion("type", [
1119
1231
  formTabWriteSchema,
1120
1232
  tableTabSchema,
@@ -1123,7 +1235,8 @@ var detailTabSchema = z.discriminatedUnion("type", [
1123
1235
  richtextTabSchema,
1124
1236
  documentsTabSchema,
1125
1237
  formsTabSchema,
1126
- emailsTabSchema
1238
+ emailsTabSchema,
1239
+ meetingsTabSchema
1127
1240
  ]);
1128
1241
  var listTabCommonShape = {
1129
1242
  id: z.string(),
@@ -1212,4 +1325,4 @@ function parseViewConfig(type, input) {
1212
1325
  }
1213
1326
  }
1214
1327
 
1215
- export { ATTRIBUTE_FILTER_OPERATORS, LIST_VIEW_TAB_VISIBILITIES, NO_VALUE_OPERATORS, OPERATORS_BY_TYPE, REMOVED_OPERATOR_REPLACEMENTS, RESERVED_ATTRIBUTE_NAMES, RESERVED_OBJECT_NAMES, RESOURCE_VISIBILITIES, SYNONYM_ALIASES, SYSTEM_ATTRIBUTES, SYSTEM_ATTRIBUTE_I18N_KEYS, SYSTEM_FIELD_NAMES, SYSTEM_FILTER_ATTRIBUTE_TYPES, collectQualifiedRuleIssues, currentActor, detailTabSchema, detailViewConfigSchema, getAttributeCapabilities, getAttributeFilterOperators, getRollupFilterOperators2 as getRollupFilterOperators, getSystemAttributeI18nKey, getSystemAttributeList, inverseSourceSchema, isAttributeFilterable, isAttributeGroupable, isAttributeKanbanGroupable, isAttributeSearchable, isAttributeSortable, isDynamicValue, isManagedSystemAttribute, isNoValueOperator, isRelativeDateValue, listViewConfigSchema, listViewTabSchema, normalizeFilterRule, normalizeOperator, now, parseViewConfig, relationSourceSchema, resolveIsWithinBounds, tableSourceSchema, toUtcDayString, today, validateQualifiedRule, viewConfigByTypeSchema, viewTypeSchema };
1328
+ export { ATTRIBUTE_FILTER_OPERATORS, LIST_VIEW_TAB_VISIBILITIES, NO_VALUE_OPERATORS, OPERATORS_BY_TYPE, REMOVED_OPERATOR_REPLACEMENTS, RESERVED_ATTRIBUTE_NAMES, RESERVED_OBJECT_NAMES, RESOURCE_VISIBILITIES, SYNONYM_ALIASES, SYSTEM_ATTRIBUTES, SYSTEM_ATTRIBUTE_I18N_KEYS, SYSTEM_FIELD_NAMES, SYSTEM_FILTER_ATTRIBUTE_TYPES, canonicalizeFilterValue, collectQualifiedRuleIssues, currentActor, detailTabSchema, detailViewConfigSchema, extractCurrencyFilterValue, extractFilterValue, getAttributeCapabilities, getAttributeFilterOperators, getOperatorPolarity, getRollupFilterOperators2 as getRollupFilterOperators, getSystemAttributeI18nKey, getSystemAttributeList, inverseSourceSchema, isAttributeFilterable, isAttributeGroupable, isAttributeKanbanGroupable, isAttributeSearchable, isAttributeSortable, isDynamicValue, isManagedSystemAttribute, isNoValueOperator, isRelativeDateValue, isSetMembershipOperator, listViewConfigSchema, listViewTabSchema, normalizeFilterRule, normalizeForEdgeRpc, normalizeOperator, now, parseResourceVisibility, parseViewConfig, relationSourceSchema, resolveEffectiveFilterType, resolveIsWithinBounds, resolveUtcDayBounds, tableSourceSchema, toMultiValueOperator, toUtcDayString, today, validateQualifiedRule, viewConfigByTypeSchema, viewTypeSchema };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkF3YPU2N6_js = require('./chunk-F3YPU2N6.js');
3
+ var chunkZBWTAKZO_js = require('./chunk-ZBWTAKZO.js');
4
4
  var zod = require('zod');
5
5
  var constants = require('@stndrds/constants');
6
6
 
@@ -571,7 +571,7 @@ function getAttributeConfigWriteSchema(type) {
571
571
  }
572
572
  }
573
573
  function validationErrorFromIssues(issues) {
574
- return chunkF3YPU2N6_js.ValidationError.fromZodErrors(
574
+ return chunkZBWTAKZO_js.ValidationError.fromZodErrors(
575
575
  issues.map((issue) => ({
576
576
  path: issue.path.map((segment) => typeof segment === "symbol" ? String(segment) : segment),
577
577
  message: issue.message
@@ -594,7 +594,7 @@ function validatePatchedIcon(patch) {
594
594
  }
595
595
  const result = iconNameSchema.optional().safeParse(patch.icon);
596
596
  if (!result.success) {
597
- throw chunkF3YPU2N6_js.ValidationError.fromZodErrors(
597
+ throw chunkZBWTAKZO_js.ValidationError.fromZodErrors(
598
598
  result.error.issues.map((issue) => ({
599
599
  path: [
600
600
  "icon",
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
+ var chunkQ4SZAMJT_js = require('./chunk-Q4SZAMJT.js');
4
+ var chunkEEH4XQ7W_js = require('./chunk-EEH4XQ7W.js');
3
5
  var chunkEW5XR2X3_js = require('./chunk-EW5XR2X3.js');
4
6
  var chunkQWKLQRBX_js = require('./chunk-QWKLQRBX.js');
5
7
  var chunkKNGWHQLR_js = require('./chunk-KNGWHQLR.js');
6
- var chunkHTSTPTNZ_js = require('./chunk-HTSTPTNZ.js');
7
- var chunkV2UA2D4E_js = require('./chunk-V2UA2D4E.js');
8
8
  var chunk5WATIVCA_js = require('./chunk-5WATIVCA.js');
9
9
  var chunkSI34M4IC_js = require('./chunk-SI34M4IC.js');
10
10
  var chunkYIP5FJ5H_js = require('./chunk-YIP5FJ5H.js');
11
11
  var chunkZPFOKBIN_js = require('./chunk-ZPFOKBIN.js');
12
- var chunkF3YPU2N6_js = require('./chunk-F3YPU2N6.js');
12
+ var chunkZBWTAKZO_js = require('./chunk-ZBWTAKZO.js');
13
+ var chunkHTSTPTNZ_js = require('./chunk-HTSTPTNZ.js');
14
+ var chunkV2UA2D4E_js = require('./chunk-V2UA2D4E.js');
13
15
  var chunkACKMC6FL_js = require('./chunk-ACKMC6FL.js');
14
16
  var chunkE6JUYGJX_js = require('./chunk-E6JUYGJX.js');
15
- var chunkQ4SZAMJT_js = require('./chunk-Q4SZAMJT.js');
16
- var chunkEEH4XQ7W_js = require('./chunk-EEH4XQ7W.js');
17
17
  var chunkYKWSHBT5_js = require('./chunk-YKWSHBT5.js');
18
18
  var zod = require('zod');
19
19
 
@@ -76,6 +76,19 @@ function createFormAttributeValidator(attr, messages = chunkYKWSHBT5_js.DEFAULT_
76
76
  }
77
77
  return validator;
78
78
  }
79
+
80
+ // src/lib/empty.ts
81
+ function isNullishOrEmptyString(value) {
82
+ return value === null || value === void 0 || value === "";
83
+ }
84
+ function isValuePresent(value) {
85
+ if (value === null || value === void 0) return false;
86
+ if (typeof value === "string") return value.trim() !== "";
87
+ if (Array.isArray(value)) return value.length > 0;
88
+ return true;
89
+ }
90
+
91
+ // src/validation/object/object-validator.ts
79
92
  var objectValidatorCache = /* @__PURE__ */ new WeakMap();
80
93
  var draftValidatorCache = /* @__PURE__ */ new WeakMap();
81
94
  function createObjectValidator(objectDef) {
@@ -84,7 +97,13 @@ function createObjectValidator(objectDef) {
84
97
  const shape = {};
85
98
  for (const attr of objectDef.attributes) {
86
99
  const validator = createAttributeValidator(attr);
87
- shape[attr.name] = attr.required ? validator : withEmptyToNull(validator);
100
+ if (attr.required) {
101
+ shape[attr.name] = validator.refine(isValuePresent, {
102
+ message: chunkYKWSHBT5_js.DEFAULT_VALIDATION_MESSAGES.required(attr)
103
+ });
104
+ } else {
105
+ shape[attr.name] = withEmptyToNull(validator);
106
+ }
88
107
  }
89
108
  const schema = zod.z.object(shape).passthrough();
90
109
  objectValidatorCache.set(objectDef, schema);
@@ -143,7 +162,7 @@ function validateObjectOrThrow(objectDef, data) {
143
162
  if (!result.success) {
144
163
  const errors = result.errors ?? [];
145
164
  const detail = errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
146
- throw new chunkF3YPU2N6_js.ValidationError(
165
+ throw new chunkZBWTAKZO_js.ValidationError(
147
166
  `Validation failed for ${objectDef.label}:
148
167
  ${detail}`,
149
168
  errors.map((err) => ({ path: err.path, message: err.message }))
@@ -170,7 +189,7 @@ function validateDraftOrThrow(objectDef, data) {
170
189
  if (!result.success) {
171
190
  const errors = result.errors ?? [];
172
191
  const detail = errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
173
- throw new chunkF3YPU2N6_js.ValidationError(
192
+ throw new chunkZBWTAKZO_js.ValidationError(
174
193
  `Draft validation failed for ${objectDef.label}:
175
194
  ${detail}`,
176
195
  errors.map((err) => ({ path: err.path, message: err.message }))
@@ -182,21 +201,12 @@ function rejectUnknownAttributesOrThrow(objectDef, data) {
182
201
  const knownNames = new Set(objectDef.attributes.map((a) => a.name));
183
202
  const unknownKeys = Object.keys(data).filter((key) => !knownNames.has(key));
184
203
  if (unknownKeys.length > 0) {
185
- throw new chunkF3YPU2N6_js.ValidationError(
204
+ throw new chunkZBWTAKZO_js.ValidationError(
186
205
  `Unknown attribute${unknownKeys.length > 1 ? "s" : ""} for ${objectDef.label}: ${unknownKeys.join(", ")}`,
187
206
  unknownKeys.map((key) => ({ path: [key], message: "Unknown attribute" }))
188
207
  );
189
208
  }
190
209
  }
191
- function isValuePresent(value) {
192
- if (value === void 0 || value === null) {
193
- return false;
194
- }
195
- if (typeof value === "string" && value.trim() === "") {
196
- return false;
197
- }
198
- return true;
199
- }
200
210
  function getMissingRequiredAttributes(objectDef, data) {
201
211
  const missing = [];
202
212
  for (const attr of objectDef.attributes) {
@@ -220,7 +230,9 @@ exports.createDraftValidator = createDraftValidator;
220
230
  exports.createFormAttributeValidator = createFormAttributeValidator;
221
231
  exports.createObjectValidator = createObjectValidator;
222
232
  exports.getMissingRequiredAttributes = getMissingRequiredAttributes;
233
+ exports.isNullishOrEmptyString = isNullishOrEmptyString;
223
234
  exports.isRecordComplete = isRecordComplete;
235
+ exports.isValuePresent = isValuePresent;
224
236
  exports.rejectUnknownAttributesOrThrow = rejectUnknownAttributesOrThrow;
225
237
  exports.validateAttribute = validateAttribute;
226
238
  exports.validateDraft = validateDraft;
@@ -1,4 +1,4 @@
1
- import { ValidationError } from './chunk-QLU5QR7M.mjs';
1
+ import { ValidationError } from './chunk-V2WJFUZW.mjs';
2
2
  import { z } from 'zod';
3
3
  import { ICONS, COLORS } from '@stndrds/constants';
4
4