@stndrds/schema 0.1.0-alpha.57 → 0.1.0-alpha.59

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.
@@ -1,40 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
4
3
 
5
- // src/runtime/auth/workflow-jwt.service.ts
6
- var _jose = require('jose');
7
4
 
8
- // src/utils.ts
9
- function asTenantId(id) {
10
- return id;
11
- }
12
- function asUserId(id) {
13
- return id;
14
- }
15
- function generateId() {
16
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
17
- return crypto.randomUUID();
18
- }
19
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
20
- const r = Math.random() * 16 | 0;
21
- const v = c === "x" ? r : r & 3 | 8;
22
- return v.toString(16);
23
- });
24
- }
25
- function generatePrefixedId(prefix) {
26
- return `${prefix}_${generateId()}`;
27
- }
28
- function slugify(input) {
29
- return input.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9\s_-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
30
- }
31
- function generateTemplateName(label) {
32
- const slug = slugify(label) || "template";
33
- const suffix = generateId().slice(0, 8);
34
- return `${slug}-${suffix}`;
35
- }
5
+ var _chunkNEVERCM3js = require('./chunk-NEVERCM3.js');
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ var _chunkU4AB53AMjs = require('./chunk-U4AB53AM.js');
14
+
15
+
16
+ var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
36
17
 
37
18
  // src/runtime/auth/workflow-jwt.service.ts
19
+ var _jose = require('jose');
38
20
  var WorkflowJwtService = class _WorkflowJwtService {
39
21
  constructor(config) {
40
22
  this.config = config;
@@ -84,7 +66,7 @@ var WorkflowJwtService = class _WorkflowJwtService {
84
66
  typ: "magic_link",
85
67
  instance: params.instanceId,
86
68
  tenant: params.tenantId
87
- }).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuer(this.issuer).setSubject(params.invitationId).setAudience(params.tenantId).setJti(generateId()).setIssuedAt().setExpirationTime(expiresIn).sign(this.privateKey);
69
+ }).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuer(this.issuer).setSubject(params.invitationId).setAudience(params.tenantId).setJti(_chunkNEVERCM3js.generateId.call(void 0, )).setIssuedAt().setExpirationTime(expiresIn).sign(this.privateKey);
88
70
  }
89
71
  /**
90
72
  * Sign an access token JWT (long-lived)
@@ -102,7 +84,7 @@ var WorkflowJwtService = class _WorkflowJwtService {
102
84
  instance: params.instanceId,
103
85
  tenant: params.tenantId,
104
86
  scope: params.scope
105
- }).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuer(this.issuer).setSubject(params.grantId).setAudience(params.tenantId).setJti(generateId()).setIssuedAt().setExpirationTime(expiresIn).sign(this.privateKey);
87
+ }).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuer(this.issuer).setSubject(params.grantId).setAudience(params.tenantId).setJti(_chunkNEVERCM3js.generateId.call(void 0, )).setIssuedAt().setExpirationTime(expiresIn).sign(this.privateKey);
106
88
  }
107
89
  // ============================================================================
108
90
  // VERIFY METHODS
@@ -212,6 +194,26 @@ var WorkflowJwtService = class _WorkflowJwtService {
212
194
  }
213
195
  };
214
196
 
197
+ // src/lib/object-helpers.ts
198
+ function isEmpty(obj) {
199
+ if (obj === null || obj === void 0) {
200
+ return true;
201
+ }
202
+ if (typeof obj !== "object") {
203
+ return false;
204
+ }
205
+ return Object.keys(obj).length === 0;
206
+ }
207
+ function isNotEmpty(obj) {
208
+ return obj !== null && obj !== void 0 && typeof obj === "object" && Object.keys(obj).length > 0;
209
+ }
210
+ function toUndefinedIfEmpty(obj) {
211
+ return isNotEmpty(obj) ? obj : void 0;
212
+ }
213
+ function hasProperties(obj) {
214
+ return isNotEmpty(obj);
215
+ }
216
+
215
217
  // src/runtime/cache.ts
216
218
  function fnv1aHash(str) {
217
219
  let hash = 2166136261;
@@ -222,7 +224,7 @@ function fnv1aHash(str) {
222
224
  return hash.toString(16).padStart(8, "0");
223
225
  }
224
226
  function hashOptions(options) {
225
- if (options === null || options === void 0 || typeof options === "object" && Object.keys(options).length === 0) {
227
+ if (isEmpty(options)) {
226
228
  return "default";
227
229
  }
228
230
  const sortedJson = JSON.stringify(options, (_, value) => {
@@ -1039,7 +1041,7 @@ var QueryBuilder = class _QueryBuilder {
1039
1041
  * ```
1040
1042
  */
1041
1043
  tenant(tenantId) {
1042
- return this.clone({ tenantId: asTenantId(tenantId) });
1044
+ return this.clone({ tenantId: _chunkNEVERCM3js.asTenantId.call(void 0, tenantId) });
1043
1045
  }
1044
1046
  /**
1045
1047
  * Set user ID for audit/permissions (overrides AsyncLocalStorage context).
@@ -1055,7 +1057,7 @@ var QueryBuilder = class _QueryBuilder {
1055
1057
  * ```
1056
1058
  */
1057
1059
  user(userId) {
1058
- return this.clone({ userId: asUserId(userId) });
1060
+ return this.clone({ userId: _chunkNEVERCM3js.asUserId.call(void 0, userId) });
1059
1061
  }
1060
1062
  // ============================================================================
1061
1063
  // TERMINATION METHODS (READ)
@@ -1280,10 +1282,10 @@ var QueryBuilder = class _QueryBuilder {
1280
1282
  function createQueryBuilder(recordService, adapter, objectName, options) {
1281
1283
  const initialState = {};
1282
1284
  if (_optionalChain([options, 'optionalAccess', _25 => _25.tenantId])) {
1283
- initialState.tenantId = asTenantId(options.tenantId);
1285
+ initialState.tenantId = _chunkNEVERCM3js.asTenantId.call(void 0, options.tenantId);
1284
1286
  }
1285
1287
  if (_optionalChain([options, 'optionalAccess', _26 => _26.userId])) {
1286
- initialState.userId = asUserId(options.userId);
1288
+ initialState.userId = _chunkNEVERCM3js.asUserId.call(void 0, options.userId);
1287
1289
  }
1288
1290
  return new QueryBuilder(recordService, adapter, objectName, initialState);
1289
1291
  }
@@ -1345,12 +1347,6 @@ function or(...rules) {
1345
1347
  function inValues(field, values) {
1346
1348
  return { field, operator: "in", value: values };
1347
1349
  }
1348
- function isEmpty(field) {
1349
- return { field, operator: "isEmpty", value: null };
1350
- }
1351
- function isNotEmpty(field) {
1352
- return { field, operator: "isNotEmpty", value: null };
1353
- }
1354
1350
 
1355
1351
  // src/types/workflows/definition.ts
1356
1352
  function isWorkflowDefinition(obj) {
@@ -1460,16 +1456,6 @@ function setContextValue(context, path, value) {
1460
1456
  }
1461
1457
  current[parts[parts.length - 1]] = value;
1462
1458
  }
1463
- function mergeFormToSlot(context, nodeId, slotId) {
1464
- const formData = context.forms[nodeId];
1465
- if (!formData) {
1466
- return;
1467
- }
1468
- if (!context.slots[slotId]) {
1469
- context.slots[slotId] = {};
1470
- }
1471
- Object.assign(context.slots[slotId], formData);
1472
- }
1473
1459
 
1474
1460
  // src/types/workflows/theme.ts
1475
1461
  var DEFAULT_THEME = {
@@ -1823,9 +1809,9 @@ function compareValues(actual, operator, expected) {
1823
1809
  return typeof actual === "string" && typeof expected === "string" ? actual.endsWith(expected) : false;
1824
1810
  // Presence
1825
1811
  case "isEmpty":
1826
- return isEmpty2(actual);
1812
+ return isEmptyValue(actual);
1827
1813
  case "isNotEmpty":
1828
- return !isEmpty2(actual);
1814
+ return !isEmptyValue(actual);
1829
1815
  // Set membership
1830
1816
  case "in":
1831
1817
  if (Array.isArray(expected)) {
@@ -1841,7 +1827,7 @@ function compareValues(actual, operator, expected) {
1841
1827
  return false;
1842
1828
  }
1843
1829
  }
1844
- function isEmpty2(value) {
1830
+ function isEmptyValue(value) {
1845
1831
  if (value === null || value === void 0) {
1846
1832
  return true;
1847
1833
  }
@@ -1851,7 +1837,7 @@ function isEmpty2(value) {
1851
1837
  if (Array.isArray(value) && value.length === 0) {
1852
1838
  return true;
1853
1839
  }
1854
- if (typeof value === "object" && Object.keys(value).length === 0) {
1840
+ if (typeof value === "object" && isEmpty(value)) {
1855
1841
  return true;
1856
1842
  }
1857
1843
  return false;
@@ -2096,7 +2082,7 @@ var DocumentExecutor = class {
2096
2082
  validateSlotReferences(node, workflowSlots) {
2097
2083
  const errors = [];
2098
2084
  if (node.targetSlotIds && node.targetSlotIds.length > 0) {
2099
- const slotIdSet = new Set(workflowSlots.map((s) => s.id));
2085
+ const slotIdSet = workflowSlots.reduce((set, s) => set.add(s.id), /* @__PURE__ */ new Set());
2100
2086
  for (const slotId of node.targetSlotIds) {
2101
2087
  if (!slotIdSet.has(slotId)) {
2102
2088
  errors.push(
@@ -2132,24 +2118,25 @@ var FormExecutor = class {
2132
2118
  }
2133
2119
  execute(node, context) {
2134
2120
  const { input } = context;
2135
- if (!input || Object.keys(input).length === 0) {
2121
+ if (isEmpty(input)) {
2136
2122
  const requiredParticipationId = _nullishCoalesce(node.participantId, () => ( void 0));
2137
2123
  return wait(`Waiting for form submission: ${node.label}`, {
2138
2124
  requiredParticipationId
2139
2125
  });
2140
2126
  }
2127
+ const formInput = input;
2141
2128
  const slotIds = this.extractSlotIds(node);
2142
2129
  if (slotIds.size === 0) {
2143
2130
  return error("MISSING_FIELDS", "FormNode must have fields or rows with slot references");
2144
2131
  }
2145
2132
  const contextUpdates = {
2146
2133
  forms: {
2147
- [node.id]: input
2134
+ [node.id]: formInput
2148
2135
  },
2149
2136
  slots: {}
2150
2137
  };
2151
2138
  for (const slotId of slotIds) {
2152
- const slotInput = _nullishCoalesce(input[slotId], () => ( {}));
2139
+ const slotInput = _nullishCoalesce(formInput[slotId], () => ( {}));
2153
2140
  if (!contextUpdates.slots) {
2154
2141
  contextUpdates.slots = {};
2155
2142
  }
@@ -2177,9 +2164,9 @@ var FormExecutor = class {
2177
2164
  }
2178
2165
  canExecute(node, context) {
2179
2166
  if (node.participantId && context.executorId) {
2180
- return context.input !== void 0 && Object.keys(context.input).length > 0;
2167
+ return hasProperties(context.input);
2181
2168
  }
2182
- return context.input !== void 0 && Object.keys(context.input).length > 0;
2169
+ return hasProperties(context.input);
2183
2170
  }
2184
2171
  validate(node) {
2185
2172
  const errors = [];
@@ -2740,7 +2727,7 @@ function createMockAIConversationsRepository(stores) {
2740
2727
  const userId = requireUserId();
2741
2728
  const now = /* @__PURE__ */ new Date();
2742
2729
  const conversation = {
2743
- id: generateId(),
2730
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
2744
2731
  tenantId,
2745
2732
  userId,
2746
2733
  title: _nullishCoalesce(data.title, () => ( null)),
@@ -2776,7 +2763,7 @@ function createMockAIConversationsRepository(stores) {
2776
2763
  addMessage(input) {
2777
2764
  const now = /* @__PURE__ */ new Date();
2778
2765
  const message = {
2779
- id: generateId(),
2766
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
2780
2767
  conversationId: input.conversationId,
2781
2768
  role: input.role,
2782
2769
  content: input.content,
@@ -2834,7 +2821,7 @@ function createMockAIUserMemoryRepository(stores) {
2834
2821
  const now = /* @__PURE__ */ new Date();
2835
2822
  const existing = stores.aiUserMemory.get(key);
2836
2823
  const memory = {
2837
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _39 => _39.id]), () => ( generateId())),
2824
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _39 => _39.id]), () => ( _chunkNEVERCM3js.generateId.call(void 0, ))),
2838
2825
  tenantId,
2839
2826
  userId,
2840
2827
  preferences: _nullishCoalesce(_nullishCoalesce(data.preferences, () => ( _optionalChain([existing, 'optionalAccess', _40 => _40.preferences]))), () => ( {})),
@@ -2852,7 +2839,7 @@ function createMockAIUserMemoryRepository(stores) {
2852
2839
  const now = /* @__PURE__ */ new Date();
2853
2840
  const existing = stores.aiUserMemory.get(key);
2854
2841
  const memory = {
2855
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _43 => _43.id]), () => ( generateId())),
2842
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _43 => _43.id]), () => ( _chunkNEVERCM3js.generateId.call(void 0, ))),
2856
2843
  tenantId,
2857
2844
  userId,
2858
2845
  preferences: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _44 => _44.preferences]), () => ( {})),
@@ -2870,7 +2857,7 @@ function createMockAIUserMemoryRepository(stores) {
2870
2857
  const now = /* @__PURE__ */ new Date();
2871
2858
  const existing = stores.aiUserMemory.get(key);
2872
2859
  const memory = {
2873
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _47 => _47.id]), () => ( generateId())),
2860
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _47 => _47.id]), () => ( _chunkNEVERCM3js.generateId.call(void 0, ))),
2874
2861
  tenantId,
2875
2862
  userId,
2876
2863
  preferences: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _48 => _48.preferences]), () => ( {})),
@@ -2888,7 +2875,7 @@ function createMockAIUserMemoryRepository(stores) {
2888
2875
  const now = /* @__PURE__ */ new Date();
2889
2876
  const existing = stores.aiUserMemory.get(memoryKey);
2890
2877
  const memory = {
2891
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _51 => _51.id]), () => ( generateId())),
2878
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _51 => _51.id]), () => ( _chunkNEVERCM3js.generateId.call(void 0, ))),
2892
2879
  tenantId,
2893
2880
  userId,
2894
2881
  preferences: { ..._nullishCoalesce(_optionalChain([existing, 'optionalAccess', _52 => _52.preferences]), () => ( {})), [prefKey]: value },
@@ -2930,7 +2917,7 @@ function createMockAIUsageMetricsRepository(stores) {
2930
2917
  toolUsage[data.toolName] = (_nullishCoalesce(toolUsage[data.toolName], () => ( 0))) + 1;
2931
2918
  }
2932
2919
  const metrics = {
2933
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _57 => _57.id]), () => ( generateId())),
2920
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _57 => _57.id]), () => ( _chunkNEVERCM3js.generateId.call(void 0, ))),
2934
2921
  tenantId,
2935
2922
  date: new Date(_nullishCoalesce(now.toISOString().split("T")[0], () => ( now.toISOString()))),
2936
2923
  requestCount: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _58 => _58.requestCount]), () => ( 0))) + 1,
@@ -2998,7 +2985,7 @@ function createMockFilesRepository(stores) {
2998
2985
  create(data) {
2999
2986
  const tenantId = getTenantId();
3000
2987
  const file2 = {
3001
- id: generateId(),
2988
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
3002
2989
  tenantId,
3003
2990
  name: data.name,
3004
2991
  originalName: data.originalName,
@@ -3099,7 +3086,7 @@ function createMockObjectsRepository(stores) {
3099
3086
  create(data) {
3100
3087
  const tenantId = getTenantId();
3101
3088
  const obj = {
3102
- id: generateId(),
3089
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
3103
3090
  tenantId,
3104
3091
  name: data.name,
3105
3092
  label: data.label,
@@ -3158,7 +3145,7 @@ function createMockObjectsRepository(stores) {
3158
3145
  }
3159
3146
  }
3160
3147
  const newObj = {
3161
- id: generateId(),
3148
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
3162
3149
  tenantId,
3163
3150
  name: data.name,
3164
3151
  label: data.label,
@@ -3190,7 +3177,7 @@ function createMockAttributesRepository(stores) {
3190
3177
  },
3191
3178
  create(data) {
3192
3179
  const attr = {
3193
- id: generateId(),
3180
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
3194
3181
  objectId: data.objectId,
3195
3182
  name: data.name,
3196
3183
  label: data.label,
@@ -3471,9 +3458,6 @@ var ConcurrentModificationError = class extends SchemaError {
3471
3458
  );
3472
3459
  }
3473
3460
  };
3474
- function isConcurrentModificationError(error2) {
3475
- return error2 instanceof ConcurrentModificationError;
3476
- }
3477
3461
 
3478
3462
  // src/format.ts
3479
3463
  var _constants = require('@stndrds/constants');
@@ -3822,7 +3806,7 @@ function createMockObjectRecordsRepository(stores) {
3822
3806
  create(data) {
3823
3807
  const tenantId = getTenantId();
3824
3808
  const internal = {
3825
- id: generateId(),
3809
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
3826
3810
  tenantId,
3827
3811
  objectId: data.objectId,
3828
3812
  label: data.label,
@@ -4075,6 +4059,91 @@ function createMockObjectRecordsRepository(stores) {
4075
4059
  };
4076
4060
  }
4077
4061
 
4062
+ // src/runtime/mock/mock-relation-attributes.ts
4063
+ var _crypto = require('crypto');
4064
+ function createMockRelationAttributesRepository(stores) {
4065
+ return {
4066
+ async upsertBatch(items) {
4067
+ const context = getContext2();
4068
+ if (!context) {
4069
+ throw new Error("Context required for relationAttributes operations");
4070
+ }
4071
+ const results = [];
4072
+ for (const item of items) {
4073
+ const _key = `${context.tenantId}:${item.fromObject}:${item.fromId}:${item.fromAttribute}:${item.toId}`;
4074
+ const existing = Array.from(stores.relationAttributes.values()).find(
4075
+ (row) => row.tenantId === context.tenantId && row.fromObject === item.fromObject && row.fromId === item.fromId && row.fromAttribute === item.fromAttribute && row.toId === item.toId
4076
+ );
4077
+ if (existing) {
4078
+ existing.properties = _nullishCoalesce(item.properties, () => ( {}));
4079
+ existing.updatedAt = /* @__PURE__ */ new Date();
4080
+ existing.updatedBy = _nullishCoalesce(_nullishCoalesce(item.updatedBy, () => ( context.userId)), () => ( null));
4081
+ results.push(existing);
4082
+ } else {
4083
+ const row = {
4084
+ id: _crypto.randomUUID.call(void 0, ),
4085
+ tenantId: context.tenantId,
4086
+ fromObject: item.fromObject,
4087
+ fromId: item.fromId,
4088
+ fromAttribute: item.fromAttribute,
4089
+ toId: item.toId,
4090
+ properties: _nullishCoalesce(item.properties, () => ( {})),
4091
+ createdAt: /* @__PURE__ */ new Date(),
4092
+ updatedAt: /* @__PURE__ */ new Date(),
4093
+ createdBy: _nullishCoalesce(_nullishCoalesce(item.createdBy, () => ( context.userId)), () => ( null)),
4094
+ updatedBy: _nullishCoalesce(_nullishCoalesce(item.updatedBy, () => ( context.userId)), () => ( null))
4095
+ };
4096
+ stores.relationAttributes.set(row.id, row);
4097
+ results.push(row);
4098
+ }
4099
+ }
4100
+ return results;
4101
+ },
4102
+ async findBySource(fromObject, fromId, fromAttribute) {
4103
+ const context = getContext2();
4104
+ if (!context) {
4105
+ throw new Error("Context required for relationAttributes operations");
4106
+ }
4107
+ return Array.from(stores.relationAttributes.values()).filter(
4108
+ (row) => row.tenantId === context.tenantId && row.fromObject === fromObject && row.fromId === fromId && row.fromAttribute === fromAttribute
4109
+ );
4110
+ },
4111
+ async findByTarget(toId) {
4112
+ const context = getContext2();
4113
+ if (!context) {
4114
+ throw new Error("Context required for relationAttributes operations");
4115
+ }
4116
+ return Array.from(stores.relationAttributes.values()).filter(
4117
+ (row) => row.tenantId === context.tenantId && row.toId === toId
4118
+ );
4119
+ },
4120
+ async deleteBySource(fromObject, fromId, fromAttribute) {
4121
+ const context = getContext2();
4122
+ if (!context) {
4123
+ throw new Error("Context required for relationAttributes operations");
4124
+ }
4125
+ const toDelete = Array.from(stores.relationAttributes.entries()).filter(
4126
+ ([_id, row]) => row.tenantId === context.tenantId && row.fromObject === fromObject && row.fromId === fromId && row.fromAttribute === fromAttribute
4127
+ );
4128
+ for (const [id] of toDelete) {
4129
+ stores.relationAttributes.delete(id);
4130
+ }
4131
+ },
4132
+ async deleteByTarget(toId) {
4133
+ const context = getContext2();
4134
+ if (!context) {
4135
+ throw new Error("Context required for relationAttributes operations");
4136
+ }
4137
+ const toDelete = Array.from(stores.relationAttributes.entries()).filter(
4138
+ ([_id, row]) => row.tenantId === context.tenantId && row.toId === toId
4139
+ );
4140
+ for (const [id] of toDelete) {
4141
+ stores.relationAttributes.delete(id);
4142
+ }
4143
+ }
4144
+ };
4145
+ }
4146
+
4078
4147
  // src/runtime/mock/mock-stores.ts
4079
4148
  function createEmptyStores() {
4080
4149
  return {
@@ -4095,7 +4164,8 @@ function createEmptyStores() {
4095
4164
  aiConversations: /* @__PURE__ */ new Map(),
4096
4165
  aiMessages: /* @__PURE__ */ new Map(),
4097
4166
  aiUserMemory: /* @__PURE__ */ new Map(),
4098
- aiUsageMetrics: /* @__PURE__ */ new Map()
4167
+ aiUsageMetrics: /* @__PURE__ */ new Map(),
4168
+ relationAttributes: /* @__PURE__ */ new Map()
4099
4169
  };
4100
4170
  }
4101
4171
 
@@ -4136,7 +4206,7 @@ function createMockUserProfilesRepository(stores) {
4136
4206
  create(data) {
4137
4207
  const tenantId = getTenantId();
4138
4208
  const profile = {
4139
- id: generateId(),
4209
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4140
4210
  tenantId,
4141
4211
  authId: data.authId,
4142
4212
  email: data.email,
@@ -4194,9 +4264,9 @@ function createMockUserProfilesRepository(stores) {
4194
4264
  invite(data) {
4195
4265
  const tenantId = getTenantId();
4196
4266
  const profile = {
4197
- id: generateId(),
4267
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4198
4268
  tenantId,
4199
- authId: `invited-${generateId()}`,
4269
+ authId: `invited-${_chunkNEVERCM3js.generateId.call(void 0, )}`,
4200
4270
  email: data.email,
4201
4271
  firstName: data.firstName,
4202
4272
  lastName: data.lastName,
@@ -4232,7 +4302,7 @@ function createMockPermissionsRepository(stores) {
4232
4302
  createRole(input) {
4233
4303
  const tenantId = getTenantId();
4234
4304
  const role = {
4235
- id: generateId(),
4305
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4236
4306
  tenantId,
4237
4307
  name: input.name,
4238
4308
  label: input.label,
@@ -4287,7 +4357,7 @@ function createMockPermissionsRepository(stores) {
4287
4357
  }
4288
4358
  for (const input of permissions) {
4289
4359
  const perm = {
4290
- id: generateId(),
4360
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4291
4361
  roleId,
4292
4362
  scope: input.scope,
4293
4363
  target: input.target,
@@ -4302,7 +4372,8 @@ function createMockPermissionsRepository(stores) {
4302
4372
  getUserRoles(userProfileId) {
4303
4373
  const tenantId = getTenantId();
4304
4374
  const roleIds = Array.from(stores.userRoles.values()).filter((ur) => ur.userProfileId === userProfileId && ur.tenantId === tenantId).map((ur) => ur.roleId);
4305
- const roles = Array.from(stores.roles.values()).filter((r) => roleIds.includes(r.id));
4375
+ const roleIdsSet = new Set(roleIds);
4376
+ const roles = Array.from(stores.roles.values()).filter((r) => roleIdsSet.has(r.id));
4306
4377
  return Promise.resolve(roles);
4307
4378
  },
4308
4379
  assignRole(input) {
@@ -4312,7 +4383,7 @@ function createMockPermissionsRepository(stores) {
4312
4383
  }
4313
4384
  }
4314
4385
  const userRole = {
4315
- id: generateId(),
4386
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4316
4387
  userProfileId: input.userProfileId,
4317
4388
  roleId: input.roleId,
4318
4389
  tenantId: input.tenantId,
@@ -4416,7 +4487,7 @@ function createMockViewsRepository(stores) {
4416
4487
  },
4417
4488
  create(data) {
4418
4489
  const tenantId = getTenantId();
4419
- const id = generateId();
4490
+ const id = _chunkNEVERCM3js.generateId.call(void 0, );
4420
4491
  const now = /* @__PURE__ */ new Date();
4421
4492
  const dbView = {
4422
4493
  id,
@@ -4518,7 +4589,7 @@ function createMockViewOverlaysRepository(stores) {
4518
4589
  const views = Array.from(stores.views.values()).filter(
4519
4590
  (v) => v.tenantId === tenantId && v.objectName === objectName && v.type === type
4520
4591
  );
4521
- const viewIds = new Set(views.map((v) => v.id));
4592
+ const viewIds = views.reduce((set, v) => set.add(v.id), /* @__PURE__ */ new Set());
4522
4593
  return Promise.resolve(
4523
4594
  _nullishCoalesce(Array.from(stores.viewOverlays.values()).find(
4524
4595
  (o) => o.tenantId === tenantId && o.userId === userId && o.isUserDefault === true && viewIds.has(o.viewId)
@@ -4527,7 +4598,7 @@ function createMockViewOverlaysRepository(stores) {
4527
4598
  },
4528
4599
  create(data) {
4529
4600
  const tenantId = getTenantId();
4530
- const id = generateId();
4601
+ const id = _chunkNEVERCM3js.generateId.call(void 0, );
4531
4602
  const now = /* @__PURE__ */ new Date();
4532
4603
  const overlay = {
4533
4604
  id,
@@ -4603,7 +4674,7 @@ function createMockViewOverlaysRepository(stores) {
4603
4674
  const views = Array.from(stores.views.values()).filter(
4604
4675
  (v) => v.tenantId === tenantId && v.objectName === objectName && v.type === type
4605
4676
  );
4606
- const viewIds = new Set(views.map((v) => v.id));
4677
+ const viewIds = views.reduce((set, v) => set.add(v.id), /* @__PURE__ */ new Set());
4607
4678
  for (const overlay of stores.viewOverlays.values()) {
4608
4679
  if (overlay.tenantId === tenantId && overlay.userId === userId && overlay.isUserDefault === true && viewIds.has(overlay.viewId)) {
4609
4680
  overlay.isUserDefault = false;
@@ -4659,7 +4730,7 @@ function createMockWorkflowsRepository(stores) {
4659
4730
  const tenantId = getTenantId();
4660
4731
  const now = (/* @__PURE__ */ new Date()).toISOString();
4661
4732
  const workflow2 = {
4662
- id: generateId(),
4733
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4663
4734
  tenant_id: tenantId,
4664
4735
  name: data.name,
4665
4736
  label: data.label,
@@ -4763,7 +4834,7 @@ function createMockWorkflowInstancesRepository(stores) {
4763
4834
  const tenantId = getTenantId();
4764
4835
  const now = (/* @__PURE__ */ new Date()).toISOString();
4765
4836
  const instance = {
4766
- id: generateId(),
4837
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4767
4838
  tenant_id: tenantId,
4768
4839
  workflow_id: data.workflowId,
4769
4840
  workflow_version: data.workflowVersion,
@@ -4893,7 +4964,7 @@ function createMockWorkflowInvitationsRepository(stores) {
4893
4964
  const tenantId = getTenantId();
4894
4965
  const now = (/* @__PURE__ */ new Date()).toISOString();
4895
4966
  const invitation = {
4896
- id: generateId(),
4967
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4897
4968
  tenant_id: tenantId,
4898
4969
  instance_id: data.instanceId,
4899
4970
  recipient_email: data.recipientEmail,
@@ -4957,7 +5028,7 @@ function createMockWorkflowAccessGrantsRepository(stores) {
4957
5028
  const tenantId = getTenantId();
4958
5029
  const now = (/* @__PURE__ */ new Date()).toISOString();
4959
5030
  const grant = {
4960
- id: generateId(),
5031
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
4961
5032
  tenant_id: tenantId,
4962
5033
  invitation_id: data.invitationId,
4963
5034
  instance_id: data.instanceId,
@@ -5009,6 +5080,8 @@ function createMockAdapter() {
5009
5080
  aiConversations: createMockAIConversationsRepository(stores),
5010
5081
  aiUserMemory: createMockAIUserMemoryRepository(stores),
5011
5082
  aiUsageMetrics: createMockAIUsageMetricsRepository(stores),
5083
+ // Relation attributes repository
5084
+ relationAttributes: createMockRelationAttributesRepository(stores),
5012
5085
  async transaction(callback) {
5013
5086
  return await callback(adapter);
5014
5087
  },
@@ -5034,6 +5107,7 @@ function createMockAdapter() {
5034
5107
  stores.aiMessages.clear();
5035
5108
  stores.aiUserMemory.clear();
5036
5109
  stores.aiUsageMetrics.clear();
5110
+ stores.relationAttributes.clear();
5037
5111
  }
5038
5112
  };
5039
5113
  return adapter;
@@ -5512,6 +5586,292 @@ function validateOptions(options, attributeName) {
5512
5586
  }
5513
5587
  }
5514
5588
 
5589
+ // src/types/relation-properties.ts
5590
+ var FORBIDDEN_PROPERTY_TYPES = [
5591
+ "formula",
5592
+ "rollup",
5593
+ "relation",
5594
+ "file",
5595
+ "user",
5596
+ "document",
5597
+ "richtext"
5598
+ ];
5599
+
5600
+ // src/builders/property-schema-builder.ts
5601
+ var PropertySchemaBuilder = class {
5602
+ constructor() {
5603
+ this.definitions = [];
5604
+ }
5605
+ /**
5606
+ * Add a property to the schema
5607
+ * The type of property is automatically detected based on the builder methods used
5608
+ */
5609
+ add(name, configure) {
5610
+ const builder = new PropertyTypeBuilder(name);
5611
+ const configured = configure(builder);
5612
+ const definition = configured.build();
5613
+ this.definitions.push(definition);
5614
+ return this;
5615
+ }
5616
+ /**
5617
+ * Build the final PropertySchema
5618
+ */
5619
+ build() {
5620
+ return {
5621
+ definitions: this.definitions
5622
+ };
5623
+ }
5624
+ };
5625
+ var PropertyTypeBuilder = class {
5626
+ constructor(name) {
5627
+ this.name = name;
5628
+ }
5629
+ // Explicit type constructors
5630
+ text() {
5631
+ return new TextPropertyBuilder(this.name);
5632
+ }
5633
+ textarea() {
5634
+ return new TextareaPropertyBuilder(this.name);
5635
+ }
5636
+ number() {
5637
+ return new NumberPropertyBuilder(this.name);
5638
+ }
5639
+ checkbox() {
5640
+ return new CheckboxPropertyBuilder(this.name);
5641
+ }
5642
+ date() {
5643
+ return new DatePropertyBuilder(this.name);
5644
+ }
5645
+ phone() {
5646
+ return new PhonePropertyBuilder(this.name);
5647
+ }
5648
+ currency() {
5649
+ return new CurrencyPropertyBuilder(this.name);
5650
+ }
5651
+ status() {
5652
+ return new StatusPropertyBuilder(this.name);
5653
+ }
5654
+ select() {
5655
+ return new SelectPropertyBuilder(this.name);
5656
+ }
5657
+ multiselect() {
5658
+ return new MultiselectPropertyBuilder(this.name);
5659
+ }
5660
+ rating() {
5661
+ return new RatingPropertyBuilder(this.name);
5662
+ }
5663
+ location() {
5664
+ return new LocationPropertyBuilder(this.name);
5665
+ }
5666
+ };
5667
+ var BasePropertyBuilder = class {
5668
+ constructor(name) {
5669
+ this.definition = { name };
5670
+ }
5671
+ /**
5672
+ * Set the label
5673
+ */
5674
+ label(label) {
5675
+ this.definition.label = label;
5676
+ return this;
5677
+ }
5678
+ /**
5679
+ * Mark as required
5680
+ */
5681
+ required() {
5682
+ this.definition.required = true;
5683
+ return this;
5684
+ }
5685
+ /**
5686
+ * Set description
5687
+ */
5688
+ description(description) {
5689
+ this.definition.description = description;
5690
+ return this;
5691
+ }
5692
+ /**
5693
+ * Build the final definition
5694
+ */
5695
+ build() {
5696
+ return this.definition;
5697
+ }
5698
+ };
5699
+ var TextPropertyBuilder = class extends BasePropertyBuilder {
5700
+ constructor(name) {
5701
+ super(name);
5702
+ this.definition.type = "text";
5703
+ }
5704
+ minLength(value) {
5705
+ this.definition.minLength = value;
5706
+ return this;
5707
+ }
5708
+ maxLength(value) {
5709
+ this.definition.maxLength = value;
5710
+ return this;
5711
+ }
5712
+ pattern(pattern) {
5713
+ this.definition.pattern = pattern;
5714
+ return this;
5715
+ }
5716
+ placeholder(value) {
5717
+ this.definition.placeholder = value;
5718
+ return this;
5719
+ }
5720
+ };
5721
+ var TextareaPropertyBuilder = class extends BasePropertyBuilder {
5722
+ constructor(name) {
5723
+ super(name);
5724
+ this.definition.type = "textarea";
5725
+ }
5726
+ minLength(value) {
5727
+ this.definition.minLength = value;
5728
+ return this;
5729
+ }
5730
+ maxLength(value) {
5731
+ this.definition.maxLength = value;
5732
+ return this;
5733
+ }
5734
+ placeholder(value) {
5735
+ this.definition.placeholder = value;
5736
+ return this;
5737
+ }
5738
+ };
5739
+ var NumberPropertyBuilder = class extends BasePropertyBuilder {
5740
+ constructor(name) {
5741
+ super(name);
5742
+ this.definition.type = "number";
5743
+ }
5744
+ min(value) {
5745
+ this.definition.min = value;
5746
+ return this;
5747
+ }
5748
+ max(value) {
5749
+ this.definition.max = value;
5750
+ return this;
5751
+ }
5752
+ decimal(places) {
5753
+ this.definition.decimal = places;
5754
+ return this;
5755
+ }
5756
+ integer() {
5757
+ this.definition.integer = true;
5758
+ return this;
5759
+ }
5760
+ placeholder(value) {
5761
+ this.definition.placeholder = value;
5762
+ return this;
5763
+ }
5764
+ };
5765
+ var CheckboxPropertyBuilder = class extends BasePropertyBuilder {
5766
+ constructor(name) {
5767
+ super(name);
5768
+ this.definition.type = "checkbox";
5769
+ }
5770
+ };
5771
+ var DatePropertyBuilder = class extends BasePropertyBuilder {
5772
+ constructor(name) {
5773
+ super(name);
5774
+ this.definition.type = "date";
5775
+ }
5776
+ includeTime() {
5777
+ this.definition.includeTime = true;
5778
+ return this;
5779
+ }
5780
+ min(date2) {
5781
+ this.definition.min = date2;
5782
+ return this;
5783
+ }
5784
+ max(date2) {
5785
+ this.definition.max = date2;
5786
+ return this;
5787
+ }
5788
+ };
5789
+ var PhonePropertyBuilder = class extends BasePropertyBuilder {
5790
+ constructor(name) {
5791
+ super(name);
5792
+ this.definition.type = "phone";
5793
+ }
5794
+ };
5795
+ var CurrencyPropertyBuilder = class extends BasePropertyBuilder {
5796
+ constructor(name) {
5797
+ super(name);
5798
+ this.definition.type = "currency";
5799
+ }
5800
+ currency(code) {
5801
+ this.definition.currency = code;
5802
+ return this;
5803
+ }
5804
+ min(value) {
5805
+ this.definition.min = value;
5806
+ return this;
5807
+ }
5808
+ max(value) {
5809
+ this.definition.max = value;
5810
+ return this;
5811
+ }
5812
+ };
5813
+ var StatusPropertyBuilder = class extends BasePropertyBuilder {
5814
+ constructor(name) {
5815
+ super(name);
5816
+ this.definition.type = "status";
5817
+ }
5818
+ options(options) {
5819
+ this.definition.options = options;
5820
+ return this;
5821
+ }
5822
+ };
5823
+ var SelectPropertyBuilder = class extends BasePropertyBuilder {
5824
+ constructor(name) {
5825
+ super(name);
5826
+ this.definition.type = "select";
5827
+ }
5828
+ options(options) {
5829
+ this.definition.options = options;
5830
+ return this;
5831
+ }
5832
+ };
5833
+ var MultiselectPropertyBuilder = class extends BasePropertyBuilder {
5834
+ constructor(name) {
5835
+ super(name);
5836
+ this.definition.type = "multiselect";
5837
+ }
5838
+ options(options) {
5839
+ this.definition.options = options;
5840
+ return this;
5841
+ }
5842
+ maxSelections(value) {
5843
+ this.definition.maxSelections = value;
5844
+ return this;
5845
+ }
5846
+ };
5847
+ var RatingPropertyBuilder = class extends BasePropertyBuilder {
5848
+ constructor(name) {
5849
+ super(name);
5850
+ this.definition.type = "rating";
5851
+ }
5852
+ max(value) {
5853
+ this.definition.max = value;
5854
+ return this;
5855
+ }
5856
+ icon(icon) {
5857
+ this.definition.icon = icon;
5858
+ return this;
5859
+ }
5860
+ };
5861
+ var LocationPropertyBuilder = class extends BasePropertyBuilder {
5862
+ constructor(name) {
5863
+ super(name);
5864
+ this.definition.type = "location";
5865
+ }
5866
+ };
5867
+ function validatePropertyType(type) {
5868
+ if (FORBIDDEN_PROPERTY_TYPES.includes(type)) {
5869
+ throw new Error(
5870
+ `Property type "${type}" is not supported in .qualifyWith(). Only simple types (text, number, date, select, etc.) are allowed. Complex types (formula, rollup, relation, file, user, document) would require duplicating backend behavior.`
5871
+ );
5872
+ }
5873
+ }
5874
+
5515
5875
  // src/builders/attribute-builders.ts
5516
5876
  var BaseAttributeBuilder = class {
5517
5877
  constructor(type, name, label) {
@@ -6068,6 +6428,32 @@ var SingleRelationAttributeBuilder = class extends BaseAttributeBuilder {
6068
6428
  );
6069
6429
  return multiBuilder;
6070
6430
  }
6431
+ /**
6432
+ * Add properties to qualify the relation
6433
+ * Must be called AFTER .to() to ensure targets are defined
6434
+ *
6435
+ * @example
6436
+ * ```typescript
6437
+ * relation({ name: "mainCompany", label: "Main Company" })
6438
+ * .to("companies")
6439
+ * .qualifyWith(props => props
6440
+ * .add("role", select => select.options([...]).required())
6441
+ * .add("shares", number => number.min(0))
6442
+ * )
6443
+ * ```
6444
+ */
6445
+ qualifyWith(configure) {
6446
+ const targets = this.attr.targets;
6447
+ if (!targets || targets.length === 0) {
6448
+ throw new Error(
6449
+ '.qualifyWith() must be called AFTER .to(). Example: relation({ name: "mainCompany" }).to("companies").qualifyWith(...)'
6450
+ );
6451
+ }
6452
+ const builder = new PropertySchemaBuilder();
6453
+ const schema = configure(builder).build();
6454
+ this.attr.properties = schema;
6455
+ return this;
6456
+ }
6071
6457
  required() {
6072
6458
  this.setRequired(true);
6073
6459
  return this;
@@ -6129,6 +6515,33 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
6129
6515
  this.attr.maxItems = count;
6130
6516
  return this;
6131
6517
  }
6518
+ /**
6519
+ * Add properties to qualify the relation
6520
+ * Must be called AFTER .to() or .many() to ensure targets are defined
6521
+ *
6522
+ * @example
6523
+ * ```typescript
6524
+ * relation({ name: "companies", label: "Companies" })
6525
+ * .to("companies")
6526
+ * .many()
6527
+ * .qualifyWith(props => props
6528
+ * .add("role", select => select.options([...]).required())
6529
+ * .add("shares", number => number.min(0))
6530
+ * )
6531
+ * ```
6532
+ */
6533
+ qualifyWith(configure) {
6534
+ const targets = this.attr.targets;
6535
+ if (!targets || targets.length === 0) {
6536
+ throw new Error(
6537
+ '.qualifyWith() must be called AFTER .to() or .many(). Example: relation({ name: "companies" }).to("companies").many().qualifyWith(...)'
6538
+ );
6539
+ }
6540
+ const builder = new PropertySchemaBuilder();
6541
+ const schema = configure(builder).build();
6542
+ this.attr.properties = schema;
6543
+ return this;
6544
+ }
6132
6545
  required() {
6133
6546
  this.setRequired(true);
6134
6547
  return this;
@@ -6514,7 +6927,7 @@ function object(config) {
6514
6927
  }
6515
6928
 
6516
6929
  // src/builders/view-builder.ts
6517
- var _crypto = require('crypto');
6930
+
6518
6931
 
6519
6932
  var GroupBuilder = class {
6520
6933
  constructor(id, label) {
@@ -7899,13 +8312,13 @@ var WorkflowBuilder = class {
7899
8312
  if (!this.startNodeId) {
7900
8313
  throw new Error("[WorkflowBuilder] A start node is required. Use .start() to add one.");
7901
8314
  }
7902
- if (!this.data.nodes || Object.keys(this.data.nodes).length === 0) {
8315
+ if (isEmpty(this.data.nodes)) {
7903
8316
  throw new Error("[WorkflowBuilder] At least one node is required.");
7904
8317
  }
7905
8318
  if (!this.data.slots || this.data.slots.length === 0) {
7906
8319
  throw new Error("[WorkflowBuilder] At least one slot is required. Use .slot() to add slots.");
7907
8320
  }
7908
- const hasEndNode = Object.values(this.data.nodes).some((n) => n.type === "end");
8321
+ const hasEndNode = this.data.nodes ? Object.values(this.data.nodes).some((n) => n.type === "end") : false;
7909
8322
  if (!hasEndNode) {
7910
8323
  throw new Error(
7911
8324
  "[WorkflowBuilder] At least one end node is required. Use .end() to add one."
@@ -7936,7 +8349,7 @@ var WorkflowBuilder = class {
7936
8349
  }
7937
8350
  }
7938
8351
  validateSlotReferences() {
7939
- const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _161 => _161.data, 'access', _162 => _162.slots, 'optionalAccess', _163 => _163.map, 'call', _164 => _164((s) => s.id)]), () => ( [])));
8352
+ const slotIds = _nullishCoalesce(_optionalChain([this, 'access', _161 => _161.data, 'access', _162 => _162.slots, 'optionalAccess', _163 => _163.reduce, 'call', _164 => _164((set, s) => set.add(s.id), /* @__PURE__ */ new Set())]), () => ( /* @__PURE__ */ new Set()));
7940
8353
  for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
7941
8354
  if (node.type === "form") {
7942
8355
  const referencedSlots = /* @__PURE__ */ new Set();
@@ -8041,22 +8454,6 @@ function isBehaviorProperty(property) {
8041
8454
  function isPresentationProperty(property) {
8042
8455
  return PRESENTATION_PROPERTIES.includes(property);
8043
8456
  }
8044
- function getPropertyProtectionLevel(property) {
8045
- if (isIdentityProperty(property)) return "identity";
8046
- if (isBehaviorProperty(property)) return "behavior";
8047
- if (isPresentationProperty(property)) return "presentation";
8048
- return "unknown";
8049
- }
8050
- function filterPropertiesByCategory(properties, category) {
8051
- switch (category) {
8052
- case "identity":
8053
- return properties.filter(isIdentityProperty);
8054
- case "behavior":
8055
- return properties.filter(isBehaviorProperty);
8056
- case "presentation":
8057
- return properties.filter(isPresentationProperty);
8058
- }
8059
- }
8060
8457
 
8061
8458
  // src/types/errors.ts
8062
8459
  var RecordReferencedError = class extends Error {
@@ -8118,613 +8515,56 @@ var SYSTEM_ATTRIBUTES = {
8118
8515
  id: "system:createdBy",
8119
8516
  name: "createdBy",
8120
8517
  label: "Created by",
8121
- type: "user",
8122
- required: false,
8123
- disabled: true,
8124
- system: true,
8125
- multiple: false,
8126
- icon: "user",
8127
- description: "User who created this record"
8128
- },
8129
- lastUpdatedBy: {
8130
- id: "system:lastUpdatedBy",
8131
- name: "lastUpdatedBy",
8132
- label: "Last edited by",
8133
- type: "user",
8134
- required: false,
8135
- disabled: true,
8136
- system: true,
8137
- multiple: false,
8138
- icon: "user",
8139
- description: "User who last modified this record"
8140
- },
8141
- /**
8142
- * System attribute for free-form document attachments.
8143
- * Hidden from forms, visible in Documents tab.
8144
- * Users can attach any document without template constraints.
8145
- */
8146
- attachments: {
8147
- id: "system:attachments",
8148
- name: "attachments",
8149
- label: "Pi\xE8ces jointes",
8150
- type: "document",
8151
- required: false,
8152
- disabled: false,
8153
- // Editable via Documents tab
8154
- system: true,
8155
- hidden: true,
8156
- // Hidden from regular form views
8157
- multiple: true,
8158
- icon: "paperclip",
8159
- description: "Free-form document attachments"
8160
- // No templateId = all templates allowed
8161
- }
8162
- };
8163
- function getSystemAttributeList() {
8164
- return Object.values(SYSTEM_ATTRIBUTES);
8165
- }
8166
- function isSystemAttribute(name) {
8167
- return name in SYSTEM_ATTRIBUTES;
8168
- }
8169
- function isSystemAttributeObject(attr) {
8170
- return attr.system === true;
8171
- }
8172
-
8173
- // src/validation/validators.ts
8174
-
8175
- var regexPatternCache = /* @__PURE__ */ new Map();
8176
- function getCachedRegex(pattern) {
8177
- let cached = regexPatternCache.get(pattern);
8178
- if (!cached) {
8179
- cached = new RegExp(pattern);
8180
- regexPatternCache.set(pattern, cached);
8181
- }
8182
- return cached;
8183
- }
8184
- var DEFAULT_VALIDATION_MESSAGES = {
8185
- required: (attr) => `${attr.label} is required`,
8186
- invalidType: (attr, expected) => `${attr.label} must be a ${expected}`,
8187
- minLength: (attr, min) => `${attr.label} must be at least ${min} characters`,
8188
- maxLength: (attr, max) => `${attr.label} must be at most ${max} characters`,
8189
- invalidPattern: (attr) => `${attr.label} format is invalid`,
8190
- minValue: (attr, min) => `${attr.label} must be at least ${min}`,
8191
- maxValue: (attr, max) => `${attr.label} must be at most ${max}`,
8192
- mustBeInteger: (attr) => `${attr.label} must be an integer`,
8193
- invalidDate: (attr) => `${attr.label} must be a valid date`,
8194
- invalidOption: (attr, options) => `${attr.label} must be one of: ${options.join(", ")}`,
8195
- invalidId: (attr) => `${attr.label} must be a valid ID`,
8196
- minItems: (attr, min) => `${attr.label} must have at least ${min} item${min > 1 ? "s" : ""}`,
8197
- maxItems: (attr, max) => `${attr.label} must have at most ${max} item${max > 1 ? "s" : ""}`,
8198
- invalidRichtext: (attr) => `${attr.label} must be valid rich text content`,
8199
- invalidPhone: (attr) => `${attr.label} must be a valid phone number`,
8200
- invalidCurrency: (attr) => `${attr.label} must be a valid currency value`,
8201
- invalidLocation: (attr) => `${attr.label} must be a valid location`
8202
- };
8203
- var baseConfigSchema = _zod.z.object({
8204
- disabled: _zod.z.boolean().optional(),
8205
- placeholder: _zod.z.string().optional(),
8206
- description: _zod.z.string().optional(),
8207
- defaultValue: _zod.z.unknown().optional(),
8208
- icon: _zod.z.string().optional(),
8209
- order: _zod.z.number().int().optional(),
8210
- hidden: _zod.z.boolean().optional(),
8211
- archived: _zod.z.boolean().optional(),
8212
- deprecated: _zod.z.boolean().optional(),
8213
- metadata: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional()
8214
- });
8215
- var optionSchema = _zod.z.object({
8216
- id: _zod.z.string().min(1),
8217
- label: _zod.z.string().min(1),
8218
- value: _zod.z.string().min(1),
8219
- color: _zod.z.string().optional(),
8220
- icon: _zod.z.string().optional(),
8221
- description: _zod.z.string().optional(),
8222
- group: _zod.z.enum(["idle", "in_progress", "finished"]).optional()
8223
- });
8224
- var optionsArraySchema = _zod.z.array(optionSchema).min(1).refine(
8225
- (options) => {
8226
- const values = options.map((o) => o.value);
8227
- return new Set(values).size === values.length;
8228
- },
8229
- { message: "Duplicate option values are not allowed" }
8230
- );
8231
- var relationTargetSchema = _zod.z.object({
8232
- object: _zod.z.string().min(1),
8233
- displayTemplate: _zod.z.string().optional(),
8234
- filter: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional()
8235
- });
8236
- var textConfigSchema = baseConfigSchema.extend({
8237
- minLength: _zod.z.number().int().min(0).optional(),
8238
- maxLength: _zod.z.number().int().min(1).optional(),
8239
- pattern: _zod.z.string().optional()
8240
- });
8241
- var textareaConfigSchema = baseConfigSchema;
8242
- var richtextConfigSchema = baseConfigSchema.extend({
8243
- features: _zod.z.array(
8244
- _zod.z.enum(["headings", "bold", "italic", "lists", "links", "images", "codeBlocks", "tables"])
8245
- ).optional()
8246
- });
8247
- var numberConfigSchema = baseConfigSchema.extend({
8248
- min: _zod.z.number().optional(),
8249
- max: _zod.z.number().optional(),
8250
- unit: _zod.z.enum(["integer", "decimal", "percentage"]).optional(),
8251
- decimals: _zod.z.number().int().min(0).optional()
8252
- });
8253
- var checkboxConfigSchema = baseConfigSchema;
8254
- var dateConfigSchema = baseConfigSchema.extend({
8255
- dateFormat: _zod.z.enum(["short", "long", "full", "relative"]).optional(),
8256
- minDate: _zod.z.string().optional(),
8257
- maxDate: _zod.z.string().optional()
8258
- });
8259
- var phoneConfigSchema = baseConfigSchema.extend({
8260
- defaultCountryCode: _zod.z.string().length(3).optional()
8261
- });
8262
- var currencyConfigSchema = baseConfigSchema.extend({
8263
- defaultCurrency: _zod.z.string().length(3).optional(),
8264
- allowedCurrencies: _zod.z.array(_zod.z.string().length(3)).optional()
8265
- });
8266
- var statusConfigSchema = baseConfigSchema.extend({
8267
- options: optionsArraySchema
8268
- });
8269
- var locationConfigSchema = baseConfigSchema.extend({
8270
- granularity: _zod.z.enum(["full", "address", "city", "state", "country", "coordinates"]),
8271
- enableAutocomplete: _zod.z.boolean().optional(),
8272
- enableMap: _zod.z.boolean().optional(),
8273
- defaultCountry: _zod.z.string().length(3).optional(),
8274
- allowedCountries: _zod.z.array(_zod.z.string().length(3)).optional(),
8275
- displayFormat: _zod.z.enum(["single_line", "multi_line", "compact"]).optional()
8276
- });
8277
- var selectConfigSchema = baseConfigSchema.extend({
8278
- options: optionsArraySchema
8279
- });
8280
- var multiselectConfigSchema = baseConfigSchema.extend({
8281
- options: optionsArraySchema
8282
- });
8283
- var fileConfigSchema = baseConfigSchema.extend({
8284
- maxFiles: _zod.z.number().int().min(1).optional(),
8285
- maxSize: _zod.z.number().int().min(1).optional(),
8286
- allowedTypes: _zod.z.array(_zod.z.string()).optional(),
8287
- multiple: _zod.z.boolean().optional()
8288
- });
8289
- var userConfigSchema = baseConfigSchema.extend({
8290
- allowedRoles: _zod.z.array(_zod.z.string()).optional(),
8291
- multiple: _zod.z.boolean().optional()
8292
- });
8293
- var relationConfigSchema = baseConfigSchema.extend({
8294
- targets: _zod.z.array(relationTargetSchema).min(1),
8295
- cardinality: _zod.z.enum(["one", "many"]),
8296
- minItems: _zod.z.number().int().min(0).optional(),
8297
- maxItems: _zod.z.number().int().min(1).optional()
8298
- });
8299
- var ratingConfigSchema = baseConfigSchema.extend({
8300
- max: _zod.z.number().int().min(1).optional(),
8301
- iconType: _zod.z.enum(["star", "heart", "thumbs", "number"]).optional()
8302
- });
8303
- var formulaConfigSchema = baseConfigSchema.extend({
8304
- expression: _zod.z.string().min(1),
8305
- returnType: _zod.z.enum(["text", "number", "boolean", "date"]),
8306
- decimals: _zod.z.number().int().min(0).max(10).optional(),
8307
- allowRelations: _zod.z.boolean().optional()
8308
- });
8309
- var rollupConfigSchema = baseConfigSchema.extend({
8310
- relationAttribute: _zod.z.string().min(1).optional(),
8311
- relationPath: _zod.z.string().optional(),
8312
- targetAttribute: _zod.z.string().min(1),
8313
- function: _zod.z.enum([
8314
- // Numeric aggregates
8315
- "sum",
8316
- "avg",
8317
- // Date aggregates
8318
- "earliest",
8319
- "latest",
8320
- // Count (universal)
8321
- "count",
8322
- "countValues",
8323
- "countUniqueValues",
8324
- "countEmpty",
8325
- // Percent (universal)
8326
- "percentEmpty",
8327
- "percentNotEmpty",
8328
- // Lookup (universal)
8329
- "original"
8330
- ]),
8331
- decimals: _zod.z.number().int().min(0).max(10).optional(),
8332
- targetAttributeType: _zod.z.string().optional(),
8333
- targetAttributeOptions: _zod.z.array(
8334
- _zod.z.object({
8335
- id: _zod.z.string(),
8336
- label: _zod.z.string(),
8337
- value: _zod.z.string(),
8338
- color: _zod.z.string().optional(),
8339
- icon: _zod.z.string().optional(),
8340
- description: _zod.z.string().optional(),
8341
- group: _zod.z.enum(["idle", "in_progress", "finished"]).optional()
8342
- })
8343
- ).optional()
8344
- });
8345
- var documentConfigSchema = baseConfigSchema.extend({
8346
- templateId: _zod.z.string().optional(),
8347
- allowedTemplates: _zod.z.array(_zod.z.string()).optional(),
8348
- multiple: _zod.z.boolean().optional(),
8349
- maxDocuments: _zod.z.number().int().min(1).optional(),
8350
- autoProcess: _zod.z.boolean().optional()
8351
- });
8352
- var attributeConfigSchemas = {
8353
- text: textConfigSchema,
8354
- textarea: textareaConfigSchema,
8355
- richtext: richtextConfigSchema,
8356
- number: numberConfigSchema,
8357
- checkbox: checkboxConfigSchema,
8358
- date: dateConfigSchema,
8359
- phone: phoneConfigSchema,
8360
- currency: currencyConfigSchema,
8361
- status: statusConfigSchema,
8362
- location: locationConfigSchema,
8363
- select: selectConfigSchema,
8364
- multiselect: multiselectConfigSchema,
8365
- file: fileConfigSchema,
8366
- user: userConfigSchema,
8367
- relation: relationConfigSchema,
8368
- rating: ratingConfigSchema,
8369
- formula: formulaConfigSchema,
8370
- rollup: rollupConfigSchema,
8371
- document: documentConfigSchema
8372
- };
8373
- function getAttributeConfigSchema(type) {
8374
- return attributeConfigSchemas[type];
8375
- }
8376
- function validateAttributeConfig(type, config) {
8377
- const schema = getAttributeConfigSchema(type);
8378
- const result = schema.safeParse(config);
8379
- if (result.success) {
8380
- return { success: true, data: result.data };
8381
- }
8382
- return {
8383
- success: false,
8384
- errors: result.error.issues.map((err) => `${err.path.join(".")}: ${err.message}`)
8385
- };
8386
- }
8387
- function parseAttributeConfig(type, config) {
8388
- const schema = getAttributeConfigSchema(type);
8389
- return schema.strip().parse(config);
8390
- }
8391
- function safeParseAttributeConfig(type, config) {
8392
- const schema = getAttributeConfigSchema(type);
8393
- const result = schema.strip().safeParse(config);
8394
- return result.success ? result.data : void 0;
8395
- }
8396
- function createTextValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8397
- let schema = _zod.z.string();
8398
- if (attr.minLength !== void 0) {
8399
- schema = schema.min(attr.minLength, messages.minLength(attr, attr.minLength));
8400
- }
8401
- if (attr.maxLength !== void 0) {
8402
- schema = schema.max(attr.maxLength, messages.maxLength(attr, attr.maxLength));
8403
- }
8404
- if (attr.pattern) {
8405
- schema = schema.regex(getCachedRegex(attr.pattern), messages.invalidPattern(attr));
8406
- }
8407
- return schema;
8408
- }
8409
- function createNumberValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8410
- let schema = _zod.z.number();
8411
- if (attr.min !== void 0) {
8412
- schema = schema.min(attr.min, messages.minValue(attr, attr.min));
8413
- }
8414
- if (attr.max !== void 0) {
8415
- schema = schema.max(attr.max, messages.maxValue(attr, attr.max));
8416
- }
8417
- if (attr.unit === "integer") {
8418
- schema = schema.int(messages.mustBeInteger(attr));
8419
- }
8420
- return schema;
8421
- }
8422
- function createCheckboxValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
8423
- return _zod.z.boolean();
8424
- }
8425
- function createDateValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8426
- return _zod.z.coerce.date({ message: messages.invalidDate(attr) });
8427
- }
8428
- function createPhoneValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8429
- return _zod.z.object(
8430
- {
8431
- countryCode: _zod.z.string().length(3),
8432
- phoneNumber: _zod.z.string().min(1)
8433
- },
8434
- { message: messages.invalidPhone(attr) }
8435
- );
8436
- }
8437
- function createCurrencyValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8438
- return _zod.z.object(
8439
- {
8440
- code: _zod.z.string().length(3),
8441
- value: _zod.z.number().min(0)
8442
- },
8443
- { message: messages.invalidCurrency(attr) }
8444
- );
8445
- }
8446
- function createStatusValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8447
- const validValues = attr.options.map((opt) => opt.value);
8448
- return _zod.z.enum(validValues, {
8449
- message: messages.invalidOption(attr, validValues)
8450
- });
8451
- }
8452
- function createSelectValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8453
- const validValues = attr.options.map((opt) => opt.value);
8454
- return _zod.z.enum(validValues, {
8455
- message: messages.invalidOption(attr, validValues)
8456
- });
8457
- }
8458
- function createMultiselectValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8459
- const validValues = attr.options.map((opt) => opt.value);
8460
- return _zod.z.array(
8461
- _zod.z.enum(validValues, {
8462
- message: messages.invalidOption(attr, validValues)
8463
- })
8464
- );
8465
- }
8466
- function createLocationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8467
- return _zod.z.object(
8468
- {
8469
- address: _zod.z.string().optional(),
8470
- address2: _zod.z.string().optional(),
8471
- city: _zod.z.string().optional(),
8472
- state: _zod.z.string().optional(),
8473
- postalCode: _zod.z.string().optional(),
8474
- country: _zod.z.string().length(3).optional(),
8475
- latitude: _zod.z.number().optional(),
8476
- longitude: _zod.z.number().optional()
8477
- },
8478
- { message: messages.invalidLocation(attr) }
8479
- );
8480
- }
8481
- function createFileValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8482
- const uuidSchema = _zod.z.uuid({
8483
- message: messages.invalidId(attr)
8484
- });
8485
- if (attr.multiple) {
8486
- let arraySchema = _zod.z.array(uuidSchema);
8487
- if (attr.maxFiles) {
8488
- arraySchema = arraySchema.max(attr.maxFiles, messages.maxItems(attr, attr.maxFiles));
8489
- }
8490
- return arraySchema;
8491
- }
8492
- return uuidSchema;
8493
- }
8494
- function createUserValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8495
- const uuidSchema = _zod.z.uuid({
8496
- message: messages.invalidId(attr)
8497
- });
8498
- if (attr.multiple) {
8499
- return _zod.z.array(uuidSchema);
8500
- }
8501
- return uuidSchema;
8502
- }
8503
- function createSingleRelationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8504
- const uuidSchema = _zod.z.uuid({
8505
- message: messages.invalidId(attr)
8506
- });
8507
- return _zod.z.union([uuidSchema, _zod.z.null()]);
8508
- }
8509
- function createMultiRelationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8510
- const uuidSchema = _zod.z.uuid({
8511
- message: messages.invalidId(attr)
8512
- });
8513
- let arraySchema = _zod.z.array(uuidSchema);
8514
- if (attr.minItems !== void 0) {
8515
- arraySchema = arraySchema.min(attr.minItems, messages.minItems(attr, attr.minItems));
8516
- }
8517
- if (attr.maxItems !== void 0) {
8518
- arraySchema = arraySchema.max(attr.maxItems, messages.maxItems(attr, attr.maxItems));
8519
- }
8520
- return arraySchema;
8521
- }
8522
- function createRelationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8523
- if (attr.cardinality === "many") {
8524
- return createMultiRelationValidator(attr, messages);
8525
- }
8526
- return createSingleRelationValidator(attr, messages);
8527
- }
8528
- function createRatingValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8529
- let schema = _zod.z.number().min(0);
8530
- if (attr.max !== void 0) {
8531
- schema = schema.max(attr.max, messages.maxValue(attr, attr.max));
8532
- }
8533
- return schema;
8534
- }
8535
- function createFormulaValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
8536
- return _zod.z.unknown();
8537
- }
8538
- function createRollupValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
8539
- return _zod.z.unknown();
8540
- }
8541
- function createTextAreaValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
8542
- return _zod.z.string();
8543
- }
8544
- function createRichtextValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8545
- return _zod.z.string({
8546
- message: messages.invalidRichtext(attr)
8547
- });
8548
- }
8549
- function createAttributeValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8550
- switch (attr.type) {
8551
- case "text":
8552
- return createTextValidator(attr, messages);
8553
- case "textarea":
8554
- return createTextAreaValidator(attr, messages);
8555
- case "richtext":
8556
- return createRichtextValidator(attr, messages);
8557
- case "number":
8558
- return createNumberValidator(attr, messages);
8559
- case "checkbox":
8560
- return createCheckboxValidator(attr, messages);
8561
- case "date":
8562
- return createDateValidator(attr, messages);
8563
- case "phone":
8564
- return createPhoneValidator(attr, messages);
8565
- case "currency":
8566
- return createCurrencyValidator(attr, messages);
8567
- case "status":
8568
- return createStatusValidator(attr, messages);
8569
- case "location":
8570
- return createLocationValidator(attr, messages);
8571
- case "select":
8572
- return createSelectValidator(attr, messages);
8573
- case "multiselect":
8574
- return createMultiselectValidator(attr, messages);
8575
- case "file":
8576
- return createFileValidator(attr, messages);
8577
- case "user":
8578
- return createUserValidator(attr, messages);
8579
- case "relation":
8580
- return createRelationValidator(attr, messages);
8581
- case "rating":
8582
- return createRatingValidator(attr, messages);
8583
- case "formula":
8584
- return createFormulaValidator(attr, messages);
8585
- case "rollup":
8586
- return createRollupValidator(attr, messages);
8587
- default:
8588
- return _zod.z.unknown();
8589
- }
8590
- }
8591
- function isEmptyValue(value) {
8592
- if (value === null || value === void 0) return true;
8593
- if (typeof value === "string" && value.trim() === "") return true;
8594
- if (value instanceof Date) return false;
8595
- if (typeof value === "object" && !Array.isArray(value)) {
8596
- return Object.values(value).every(
8597
- (v) => v === null || v === void 0 || typeof v === "string" && v.trim() === ""
8598
- );
8599
- }
8600
- return false;
8601
- }
8602
- function withEmptyToNull(validator) {
8603
- return _zod.z.preprocess((val) => isEmptyValue(val) ? null : val, validator.nullish());
8604
- }
8605
- function createFormAttributeValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
8606
- const validator = createAttributeValidator(attr, messages);
8607
- if (!attr.required) {
8608
- return withEmptyToNull(validator);
8609
- }
8610
- return validator;
8611
- }
8612
- function createObjectValidator(objectDef) {
8613
- const shape = {};
8614
- for (const attr of objectDef.attributes) {
8615
- const validator = createAttributeValidator(attr);
8616
- shape[attr.name] = attr.required ? validator : withEmptyToNull(validator);
8617
- }
8618
- return _zod.z.object(shape).passthrough();
8619
- }
8620
- function validateAttribute(attr, value) {
8621
- const validator = createAttributeValidator(attr);
8622
- if (!attr.required && (value === void 0 || value === null)) {
8623
- return { success: true, data: { [attr.name]: value } };
8624
- }
8625
- const result = validator.safeParse(value);
8626
- if (result.success) {
8627
- return {
8628
- success: true,
8629
- data: { [attr.name]: result.data }
8630
- };
8631
- }
8632
- return {
8633
- success: false,
8634
- errors: result.error.issues.map((err) => ({
8635
- path: [attr.name, ...err.path.map(String)],
8636
- message: err.message
8637
- }))
8638
- };
8639
- }
8640
- function validateObject(objectDef, data) {
8641
- const validator = createObjectValidator(objectDef);
8642
- const result = validator.safeParse(data);
8643
- if (result.success) {
8644
- return {
8645
- success: true,
8646
- data: result.data
8647
- };
8648
- }
8649
- return {
8650
- success: false,
8651
- errors: result.error.issues.map((err) => ({
8652
- path: err.path.map(String),
8653
- message: err.message
8654
- }))
8655
- };
8656
- }
8657
- function validateObjectOrThrow(objectDef, data) {
8658
- const result = validateObject(objectDef, data);
8659
- if (!result.success) {
8660
- const errorMessages = _optionalChain([result, 'access', _165 => _165.errors, 'optionalAccess', _166 => _166.map, 'call', _167 => _167((err) => `${err.path.join(".")}: ${err.message}`), 'access', _168 => _168.join, 'call', _169 => _169("\n")]) || "Unknown validation error";
8661
- throw new Error(`Validation failed for ${objectDef.label}:
8662
- ${errorMessages}`);
8663
- }
8664
- return result.data;
8665
- }
8666
- function createDraftValidator(objectDef) {
8667
- const shape = {};
8668
- for (const attr of objectDef.attributes) {
8669
- const validator = createAttributeValidator(attr);
8670
- shape[attr.name] = withEmptyToNull(validator);
8671
- }
8672
- return _zod.z.object(shape).passthrough();
8673
- }
8674
- function validateDraft(objectDef, data) {
8675
- const validator = createDraftValidator(objectDef);
8676
- const result = validator.safeParse(data);
8677
- if (result.success) {
8678
- return {
8679
- success: true,
8680
- data: result.data
8681
- };
8682
- }
8683
- return {
8684
- success: false,
8685
- errors: result.error.issues.map((err) => ({
8686
- path: err.path.map(String),
8687
- message: err.message
8688
- }))
8689
- };
8690
- }
8691
- function validateDraftOrThrow(objectDef, data) {
8692
- const result = validateDraft(objectDef, data);
8693
- if (!result.success) {
8694
- const errorMessages = _optionalChain([result, 'access', _170 => _170.errors, 'optionalAccess', _171 => _171.map, 'call', _172 => _172((err) => `${err.path.join(".")}: ${err.message}`), 'access', _173 => _173.join, 'call', _174 => _174("\n")]) || "Unknown validation error";
8695
- throw new Error(`Draft validation failed for ${objectDef.label}:
8696
- ${errorMessages}`);
8697
- }
8698
- return result.data;
8699
- }
8700
- function isValuePresent(value) {
8701
- if (value === void 0 || value === null) {
8702
- return false;
8703
- }
8704
- if (typeof value === "string" && value.trim() === "") {
8705
- return false;
8706
- }
8707
- return true;
8708
- }
8709
- function getMissingRequiredAttributes(objectDef, data) {
8710
- const missing = [];
8711
- for (const attr of objectDef.attributes) {
8712
- if (attr.required && !isValuePresent(data[attr.name])) {
8713
- missing.push(attr);
8714
- }
8518
+ type: "user",
8519
+ required: false,
8520
+ disabled: true,
8521
+ system: true,
8522
+ multiple: false,
8523
+ icon: "user",
8524
+ description: "User who created this record"
8525
+ },
8526
+ lastUpdatedBy: {
8527
+ id: "system:lastUpdatedBy",
8528
+ name: "lastUpdatedBy",
8529
+ label: "Last edited by",
8530
+ type: "user",
8531
+ required: false,
8532
+ disabled: true,
8533
+ system: true,
8534
+ multiple: false,
8535
+ icon: "user",
8536
+ description: "User who last modified this record"
8537
+ },
8538
+ /**
8539
+ * System attribute for free-form document attachments.
8540
+ * Hidden from forms, visible in Documents tab.
8541
+ * Users can attach any document without template constraints.
8542
+ */
8543
+ attachments: {
8544
+ id: "system:attachments",
8545
+ name: "attachments",
8546
+ label: "Pi\xE8ces jointes",
8547
+ type: "document",
8548
+ required: false,
8549
+ disabled: false,
8550
+ // Editable via Documents tab
8551
+ system: true,
8552
+ hidden: true,
8553
+ // Hidden from regular form views
8554
+ multiple: true,
8555
+ icon: "paperclip",
8556
+ description: "Free-form document attachments"
8557
+ // No templateId = all templates allowed
8715
8558
  }
8716
- return missing;
8559
+ };
8560
+ function getSystemAttributeList() {
8561
+ return Object.values(SYSTEM_ATTRIBUTES);
8717
8562
  }
8718
- function isRecordComplete(objectDef, data) {
8719
- const missing = getMissingRequiredAttributes(objectDef, data);
8720
- if (missing.length > 0) {
8721
- return false;
8722
- }
8723
- const validation = validateObject(objectDef, data);
8724
- return validation.success;
8563
+ function isSystemAttribute(name) {
8564
+ return name in SYSTEM_ATTRIBUTES;
8725
8565
  }
8726
- function computeRecordStatus(objectDef, data) {
8727
- return isRecordComplete(objectDef, data) ? "complete" : "draft";
8566
+ function isSystemAttributeObject(attr) {
8567
+ return attr.system === true;
8728
8568
  }
8729
8569
 
8730
8570
  // src/runtime/services/audit/helpers.ts
@@ -8747,7 +8587,7 @@ var ObjectSchemaService = class extends BaseService {
8747
8587
  constructor(adapter, nativeRegistry, options) {
8748
8588
  super(adapter);
8749
8589
  this.nativeRegistry = nativeRegistry;
8750
- this.auditService = _optionalChain([options, 'optionalAccess', _175 => _175.auditService]);
8590
+ this.auditService = _optionalChain([options, 'optionalAccess', _165 => _165.auditService]);
8751
8591
  }
8752
8592
  /**
8753
8593
  * Create a new custom object.
@@ -8960,7 +8800,7 @@ var ObjectSchemaService = class extends BaseService {
8960
8800
  resourceType: "attribute",
8961
8801
  resourceId: attributeId,
8962
8802
  resourceLabel: updatedDbAttr.label,
8963
- objectName: _optionalChain([dbObject, 'optionalAccess', _176 => _176.name]),
8803
+ objectName: _optionalChain([dbObject, 'optionalAccess', _166 => _166.name]),
8964
8804
  objectId: dbAttr.objectId,
8965
8805
  changes
8966
8806
  });
@@ -8971,7 +8811,7 @@ var ObjectSchemaService = class extends BaseService {
8971
8811
  const schema = await this.getObjectSchema(dbAttr.objectId);
8972
8812
  await this.adapter.objectRecords.batchRefreshStatus(
8973
8813
  dbAttr.objectId,
8974
- (values) => computeRecordStatus(schema, values)
8814
+ (values) => _chunkU4AB53AMjs.computeRecordStatus.call(void 0, schema, values)
8975
8815
  );
8976
8816
  }
8977
8817
  return this.convertDBAttributeToAttribute(updatedDbAttr);
@@ -8993,7 +8833,7 @@ var ObjectSchemaService = class extends BaseService {
8993
8833
  );
8994
8834
  }
8995
8835
  const dbObject = await this.adapter.objects.findById(dbAttr.objectId);
8996
- if (_optionalChain([dbObject, 'optionalAccess', _177 => _177.labelExpression])) {
8836
+ if (_optionalChain([dbObject, 'optionalAccess', _167 => _167.labelExpression])) {
8997
8837
  const usedAttributes = extractAttributeNames(dbObject.labelExpression);
8998
8838
  if (usedAttributes.includes(dbAttr.name)) {
8999
8839
  throw new AttributeInUseError(dbAttr.name, "labelExpression");
@@ -9009,7 +8849,7 @@ var ObjectSchemaService = class extends BaseService {
9009
8849
  resourceType: "attribute",
9010
8850
  resourceId: attributeId,
9011
8851
  resourceLabel: dbAttr.label,
9012
- objectName: _optionalChain([dbObject, 'optionalAccess', _178 => _178.name]),
8852
+ objectName: _optionalChain([dbObject, 'optionalAccess', _168 => _168.name]),
9013
8853
  objectId: dbAttr.objectId
9014
8854
  });
9015
8855
  }
@@ -9024,9 +8864,9 @@ var ObjectSchemaService = class extends BaseService {
9024
8864
  async listAttributes(objectId, options) {
9025
8865
  const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
9026
8866
  let filtered = dbAttributes;
9027
- if (_optionalChain([options, 'optionalAccess', _179 => _179.systemOnly])) {
8867
+ if (_optionalChain([options, 'optionalAccess', _169 => _169.systemOnly])) {
9028
8868
  filtered = dbAttributes.filter((attr) => attr.system);
9029
- } else if (_optionalChain([options, 'optionalAccess', _180 => _180.customOnly])) {
8869
+ } else if (_optionalChain([options, 'optionalAccess', _170 => _170.customOnly])) {
9030
8870
  filtered = dbAttributes.filter((attr) => !attr.system);
9031
8871
  }
9032
8872
  return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
@@ -9062,14 +8902,14 @@ var ObjectSchemaService = class extends BaseService {
9062
8902
  pluralLabel: dbObject.pluralLabel,
9063
8903
  description: dbObject.description,
9064
8904
  labelExpression: dbObject.labelExpression,
9065
- icon: _optionalChain([dbObject, 'access', _181 => _181.metadata, 'optionalAccess', _182 => _182.icon])
8905
+ icon: _optionalChain([dbObject, 'access', _171 => _171.metadata, 'optionalAccess', _172 => _172.icon])
9066
8906
  };
9067
8907
  let metadata = dbObject.metadata;
9068
8908
  if (updates.icon !== void 0 || updates.metadata !== void 0) {
9069
8909
  metadata = {
9070
8910
  ...dbObject.metadata,
9071
8911
  ...updates.metadata,
9072
- icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _183 => _183.metadata, 'optionalAccess', _184 => _184.icon])))
8912
+ icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _173 => _173.metadata, 'optionalAccess', _174 => _174.icon])))
9073
8913
  };
9074
8914
  }
9075
8915
  const updatedDbObject = await this.adapter.objects.update(objectId, {
@@ -9349,7 +9189,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
9349
9189
  label: dbObject.label,
9350
9190
  pluralLabel: dbObject.pluralLabel,
9351
9191
  description: dbObject.description,
9352
- icon: _optionalChain([dbObject, 'access', _185 => _185.metadata, 'optionalAccess', _186 => _186.icon]),
9192
+ icon: _optionalChain([dbObject, 'access', _175 => _175.metadata, 'optionalAccess', _176 => _176.icon]),
9353
9193
  labelExpression: dbObject.labelExpression,
9354
9194
  attributes,
9355
9195
  system: dbObject.system,
@@ -9383,7 +9223,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
9383
9223
  }
9384
9224
  }
9385
9225
  try {
9386
- return parseAttributeConfig(attribute.type, configInput);
9226
+ return _chunkU4AB53AMjs.parseAttributeConfig.call(void 0, attribute.type, configInput);
9387
9227
  } catch (error2) {
9388
9228
  if (error2 instanceof Error) {
9389
9229
  throw new Error(`Invalid config for ${attribute.type} attribute: ${error2.message}`);
@@ -9449,7 +9289,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
9449
9289
  const hasRelationToTarget = attrs.some((attr) => {
9450
9290
  if (attr.type !== "relation") return false;
9451
9291
  const config = attr.config;
9452
- return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _187 => _187.targets, 'optionalAccess', _188 => _188.some, 'call', _189 => _189((t) => t.object === targetObjectName)]), () => ( false));
9292
+ return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _177 => _177.targets, 'optionalAccess', _178 => _178.some, 'call', _179 => _179((t) => t.object === targetObjectName)]), () => ( false));
9453
9293
  });
9454
9294
  if (hasRelationToTarget) {
9455
9295
  referencing.push(obj.name);
@@ -9527,7 +9367,7 @@ Native objects must have system=true. Did you forget to call .system() in your b
9527
9367
  const existing = this.objects.get(object2.name);
9528
9368
  throw new Error(
9529
9369
  `[NativeObjectRegistry] Duplicate object name "${object2.name}":
9530
- - Existing: "${_optionalChain([existing, 'optionalAccess', _190 => _190.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _191 => _191.id])})
9370
+ - Existing: "${_optionalChain([existing, 'optionalAccess', _180 => _180.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _181 => _181.id])})
9531
9371
  - New: "${object2.label}" (id: ${object2.id})
9532
9372
  Please use unique names for each native object.`
9533
9373
  );
@@ -9644,7 +9484,7 @@ var AuditService = class extends BaseService {
9644
9484
  this.isFlushing = false;
9645
9485
  /** Pending flush promise to allow waiting on concurrent flush */
9646
9486
  this.flushPromise = null;
9647
- if (_optionalChain([options, 'optionalAccess', _192 => _192.async]) && options.flushIntervalMs) {
9487
+ if (_optionalChain([options, 'optionalAccess', _182 => _182.async]) && options.flushIntervalMs) {
9648
9488
  this.startFlushTimer();
9649
9489
  }
9650
9490
  }
@@ -9841,7 +9681,7 @@ var AuditService = class extends BaseService {
9841
9681
  if (!this.adapter.audit) {
9842
9682
  return;
9843
9683
  }
9844
- if (_optionalChain([this, 'access', _193 => _193.options, 'optionalAccess', _194 => _194.async])) {
9684
+ if (_optionalChain([this, 'access', _183 => _183.options, 'optionalAccess', _184 => _184.async])) {
9845
9685
  this.buffer.push(entry);
9846
9686
  const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
9847
9687
  if (this.buffer.length >= batchSize) {
@@ -9855,7 +9695,7 @@ var AuditService = class extends BaseService {
9855
9695
  * Start the flush timer for async mode
9856
9696
  */
9857
9697
  startFlushTimer() {
9858
- const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _195 => _195.options, 'optionalAccess', _196 => _196.flushIntervalMs]), () => ( 1e3));
9698
+ const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _185 => _185.options, 'optionalAccess', _186 => _186.flushIntervalMs]), () => ( 1e3));
9859
9699
  this.flushTimer = setInterval(() => {
9860
9700
  this.flush().catch(() => {
9861
9701
  });
@@ -9963,7 +9803,7 @@ var UserService = class extends BaseService {
9963
9803
  if (roleErrors.length > 0) {
9964
9804
  errors.push({
9965
9805
  attribute: attrName,
9966
- message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _197 => _197.allowedRoles, 'optionalAccess', _198 => _198.join, 'call', _199 => _199(", ")])}`,
9806
+ message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _187 => _187.allowedRoles, 'optionalAccess', _188 => _188.join, 'call', _189 => _189(", ")])}`,
9967
9807
  invalidIds: roleErrors
9968
9808
  });
9969
9809
  }
@@ -10238,7 +10078,7 @@ async function preloadSchemas(records, schemaService) {
10238
10078
  if (records.length === 0) {
10239
10079
  return schemasByObjectId;
10240
10080
  }
10241
- const uniqueObjectIds = [...new Set(records.map((r) => r.objectId))];
10081
+ const uniqueObjectIds = [...records.reduce((set, r) => set.add(r.objectId), /* @__PURE__ */ new Set())];
10242
10082
  await Promise.all(
10243
10083
  uniqueObjectIds.map(async (objId) => {
10244
10084
  const schema = await schemaService.getObjectSchema(objId);
@@ -10285,7 +10125,7 @@ var RecordQueryService = class extends BaseService {
10285
10125
  super(adapter);
10286
10126
  this.schemaService = schemaService;
10287
10127
  this.options = options;
10288
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _200 => _200.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _201 => _201.policyRegistry]), () => ( defaultPolicyRegistry));
10128
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _190 => _190.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _191 => _191.policyRegistry]), () => ( defaultPolicyRegistry));
10289
10129
  }
10290
10130
  // ============================================================================
10291
10131
  // LIST
@@ -10335,12 +10175,12 @@ var RecordQueryService = class extends BaseService {
10335
10175
  * Internal list query execution
10336
10176
  */
10337
10177
  async executeListQuery(schema, objectId, options) {
10338
- if (_optionalChain([this, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.permissionService]) && this.userId) {
10178
+ if (_optionalChain([this, 'access', _192 => _192.options, 'optionalAccess', _193 => _193.permissionService]) && this.userId) {
10339
10179
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
10340
10180
  }
10341
- const policy = _optionalChain([options, 'optionalAccess', _204 => _204.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
10181
+ const policy = _optionalChain([options, 'optionalAccess', _194 => _194.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
10342
10182
  let effectiveOptions = options;
10343
- if (_optionalChain([policy, 'optionalAccess', _205 => _205.applyListFilter]) && this.userId) {
10183
+ if (_optionalChain([policy, 'optionalAccess', _195 => _195.applyListFilter]) && this.userId) {
10344
10184
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
10345
10185
  effectiveOptions = policy.applyListFilter(ctx, options);
10346
10186
  }
@@ -10350,10 +10190,10 @@ var RecordQueryService = class extends BaseService {
10350
10190
  );
10351
10191
  let filteredRecords = result.records;
10352
10192
  let effectiveTotal = result.total;
10353
- if (_optionalChain([policy, 'optionalAccess', _206 => _206.canAccessRecord]) && this.userId) {
10193
+ if (_optionalChain([policy, 'optionalAccess', _196 => _196.canAccessRecord]) && this.userId) {
10354
10194
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
10355
- const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _207 => _207.limit]), () => ( 20));
10356
- const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _208 => _208.offset]), () => ( 0));
10195
+ const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _197 => _197.limit]), () => ( 20));
10196
+ const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _198 => _198.offset]), () => ( 0));
10357
10197
  const overfetchMultiplier = 5;
10358
10198
  const batchSize = requestedLimit * overfetchMultiplier;
10359
10199
  const maxScanRecords = 1e4;
@@ -10375,7 +10215,7 @@ var RecordQueryService = class extends BaseService {
10375
10215
  exhausted = true;
10376
10216
  break;
10377
10217
  }
10378
- const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _209 => _209.canAccessRecord, 'optionalCall', _210 => _210(ctx, record)]));
10218
+ const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _199 => _199.canAccessRecord, 'optionalCall', _200 => _200(ctx, record)]));
10379
10219
  collected.push(...filtered);
10380
10220
  dbOffset += batch.records.length;
10381
10221
  totalScanned += batch.records.length;
@@ -10387,7 +10227,14 @@ var RecordQueryService = class extends BaseService {
10387
10227
  effectiveTotal = exhausted ? collected.length : Math.max(collected.length, result.total);
10388
10228
  filteredRecords = collected.slice(requestedOffset, requestedOffset + requestedLimit);
10389
10229
  }
10390
- if (!_optionalChain([options, 'optionalAccess', _211 => _211.skipFormulas])) {
10230
+ if (_optionalChain([options, 'optionalAccess', _201 => _201.include]) && options.include.length > 0) {
10231
+ filteredRecords = await this.includeRelationsWithProperties(
10232
+ filteredRecords,
10233
+ schema,
10234
+ options.include
10235
+ );
10236
+ }
10237
+ if (!_optionalChain([options, 'optionalAccess', _202 => _202.skipFormulas])) {
10391
10238
  return {
10392
10239
  records: enrichRecordsWithFormulas(filteredRecords, schema),
10393
10240
  total: effectiveTotal
@@ -10447,14 +10294,14 @@ var RecordQueryService = class extends BaseService {
10447
10294
  * Internal search query execution
10448
10295
  */
10449
10296
  async executeSearchQuery(schema, objectId, query, options) {
10450
- if (_optionalChain([this, 'access', _212 => _212.options, 'optionalAccess', _213 => _213.permissionService]) && this.userId) {
10297
+ if (_optionalChain([this, 'access', _203 => _203.options, 'optionalAccess', _204 => _204.permissionService]) && this.userId) {
10451
10298
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
10452
10299
  }
10453
10300
  const result = await runWithSchemaContext(
10454
10301
  [schema],
10455
10302
  () => this.adapter.objectRecords.search(objectId, query, options)
10456
10303
  );
10457
- if (!_optionalChain([options, 'optionalAccess', _214 => _214.skipFormulas])) {
10304
+ if (!_optionalChain([options, 'optionalAccess', _205 => _205.skipFormulas])) {
10458
10305
  return {
10459
10306
  records: enrichRecordsWithFormulas(result.records, schema),
10460
10307
  total: result.total
@@ -10462,6 +10309,79 @@ var RecordQueryService = class extends BaseService {
10462
10309
  }
10463
10310
  return result;
10464
10311
  }
10312
+ // ============================================================================
10313
+ // INCLUDE RELATIONS WITH PROPERTIES
10314
+ // ============================================================================
10315
+ /**
10316
+ * Include relation properties in records.
10317
+ *
10318
+ * For each requested relation attribute:
10319
+ * - If attribute has properties → Fetch from relation_attributes and return hybrid format
10320
+ * - If attribute has NO properties → Return legacy format (string[] or string)
10321
+ *
10322
+ * Uses batch loading to avoid N+1 queries.
10323
+ *
10324
+ * @param records - Records to enrich with relation properties
10325
+ * @param schema - Object schema
10326
+ * @param includes - Array of relation attribute names to include
10327
+ * @returns Records enriched with relation properties in hybrid format
10328
+ * @private
10329
+ */
10330
+ async includeRelationsWithProperties(records, schema, includes) {
10331
+ if (records.length === 0 || includes.length === 0) {
10332
+ return records;
10333
+ }
10334
+ for (const includeName of includes) {
10335
+ const attr = schema.attributes.find((a) => a.name === includeName);
10336
+ if (!attr || attr.type !== "relation") {
10337
+ continue;
10338
+ }
10339
+ if (attr.properties && this.adapter.relationAttributes) {
10340
+ const recordIds = records.map((r) => r.id);
10341
+ const relationAttributesRepo = this.adapter.relationAttributes;
10342
+ const allRelationProps = await Promise.all(
10343
+ recordIds.map(
10344
+ (recordId) => relationAttributesRepo.findBySource(schema.name, recordId, includeName)
10345
+ )
10346
+ );
10347
+ const propsByRecord = /* @__PURE__ */ new Map();
10348
+ allRelationProps.forEach((props, index) => {
10349
+ const recordId = recordIds[index];
10350
+ const propsMap = /* @__PURE__ */ new Map();
10351
+ for (const prop of props) {
10352
+ propsMap.set(prop.toId, prop.properties);
10353
+ }
10354
+ propsByRecord.set(recordId, propsMap);
10355
+ });
10356
+ for (const record of records) {
10357
+ const currentValue = record.values[includeName];
10358
+ const propsMap = propsByRecord.get(record.id);
10359
+ if (!currentValue) {
10360
+ continue;
10361
+ }
10362
+ if (!propsMap) {
10363
+ continue;
10364
+ }
10365
+ if (attr.cardinality === "many" && Array.isArray(currentValue)) {
10366
+ record.values[includeName] = currentValue.map((id) => {
10367
+ if (typeof id === "string") {
10368
+ const props = propsMap.get(id);
10369
+ return props ? { id, props } : { id };
10370
+ }
10371
+ return id;
10372
+ });
10373
+ } else if (attr.cardinality === "one") {
10374
+ const id = typeof currentValue === "string" ? currentValue : null;
10375
+ if (id) {
10376
+ const props = propsMap.get(id);
10377
+ record.values[includeName] = props ? { id, props } : { id };
10378
+ }
10379
+ }
10380
+ }
10381
+ }
10382
+ }
10383
+ return records;
10384
+ }
10465
10385
  };
10466
10386
 
10467
10387
  // src/runtime/services/record/record-resolver.service.ts
@@ -10556,6 +10476,280 @@ var RecordResolverService = class extends BaseService {
10556
10476
  }
10557
10477
  };
10558
10478
 
10479
+ // src/runtime/services/record/relation-properties.service.ts
10480
+
10481
+ var RelationPropertiesService = class extends BaseService {
10482
+ constructor(adapter) {
10483
+ super(adapter);
10484
+ }
10485
+ // ============================================================================
10486
+ // PUBLIC API
10487
+ // ============================================================================
10488
+ /**
10489
+ * Normalize relation values for storage in object_records table.
10490
+ *
10491
+ * Extracts IDs from hybrid format ({ id, props }) and returns legacy format (string[] or string).
10492
+ * This ensures object_records.values only contains IDs, while properties are in relation_attributes.
10493
+ *
10494
+ * @param schema - Object schema
10495
+ * @param data - Record data with hybrid relation values
10496
+ * @returns Data with relation values normalized to ID-only format
10497
+ */
10498
+ normalizeRelationValuesForStorage(schema, data) {
10499
+ const normalized = { ...data };
10500
+ for (const attr of schema.attributes) {
10501
+ if (attr.type !== "relation" || !attr.properties) {
10502
+ continue;
10503
+ }
10504
+ const value = data[attr.name];
10505
+ if (value === null || value === void 0) {
10506
+ continue;
10507
+ }
10508
+ if (attr.cardinality === "many" && Array.isArray(value)) {
10509
+ normalized[attr.name] = value.map((item) => {
10510
+ if (typeof item === "string") return item;
10511
+ if (typeof item === "object" && item !== null && "id" in item) {
10512
+ return item.id;
10513
+ }
10514
+ return item;
10515
+ });
10516
+ } else if (typeof value === "object" && value !== null && "id" in value) {
10517
+ normalized[attr.name] = value.id;
10518
+ }
10519
+ }
10520
+ return normalized;
10521
+ }
10522
+ /**
10523
+ * Synchronize relation properties for a given attribute.
10524
+ *
10525
+ * Handles:
10526
+ * - Format normalization (legacy → new)
10527
+ * - Validation of properties
10528
+ * - Upsert for present IDs
10529
+ * - Delete for absent IDs
10530
+ *
10531
+ * @param schema - Object schema
10532
+ * @param recordId - Source record ID
10533
+ * @param attributeName - Relation attribute name
10534
+ * @param relationValue - Relation value (hybrid format)
10535
+ * @param adapter - Database adapter
10536
+ */
10537
+ async syncRelationProperties(schema, recordId, attributeName, relationValue, adapter) {
10538
+ const attribute = schema.attributes.find((a) => a.name === attributeName);
10539
+ if (!attribute || attribute.type !== "relation") {
10540
+ return;
10541
+ }
10542
+ if (!attribute.properties) {
10543
+ return;
10544
+ }
10545
+ const normalized = this.normalizeRelationValue(relationValue);
10546
+ for (const item of normalized) {
10547
+ if (item.props) {
10548
+ this.validateProperties(attribute.properties, item.props);
10549
+ }
10550
+ }
10551
+ const existing = await _optionalChain([adapter, 'access', _206 => _206.relationAttributes, 'optionalAccess', _207 => _207.findBySource, 'call', _208 => _208(
10552
+ schema.name,
10553
+ recordId,
10554
+ attributeName
10555
+ )]);
10556
+ const existingIds = new Set((_nullishCoalesce(existing, () => ( []))).map((r) => r.toId));
10557
+ const newIds = new Set(normalized.map((item) => item.id));
10558
+ const toUpsert = normalized.filter((item) => item.props !== void 0);
10559
+ const toDelete = Array.from(existingIds).filter((id) => !newIds.has(id));
10560
+ if (toUpsert.length > 0 && adapter.relationAttributes) {
10561
+ const inputs = toUpsert.map((item) => ({
10562
+ fromObject: schema.name,
10563
+ fromId: recordId,
10564
+ fromAttribute: attributeName,
10565
+ toId: item.id,
10566
+ properties: _nullishCoalesce(item.props, () => ( {})),
10567
+ updatedBy: _nullishCoalesce(this.userId, () => ( void 0)),
10568
+ createdBy: _nullishCoalesce(this.userId, () => ( void 0))
10569
+ }));
10570
+ await adapter.relationAttributes.upsertBatch(inputs);
10571
+ }
10572
+ if (toDelete.length > 0 && adapter.relationAttributes && existing) {
10573
+ for (const toId of toDelete) {
10574
+ const relation2 = existing.find((r) => r.toId === toId);
10575
+ if (relation2) {
10576
+ }
10577
+ }
10578
+ await adapter.relationAttributes.deleteBySource(schema.name, recordId, attributeName);
10579
+ if (toUpsert.length > 0) {
10580
+ const inputs = toUpsert.map((item) => ({
10581
+ fromObject: schema.name,
10582
+ fromId: recordId,
10583
+ fromAttribute: attributeName,
10584
+ toId: item.id,
10585
+ properties: _nullishCoalesce(item.props, () => ( {})),
10586
+ updatedBy: _nullishCoalesce(this.userId, () => ( void 0)),
10587
+ createdBy: _nullishCoalesce(this.userId, () => ( void 0))
10588
+ }));
10589
+ await adapter.relationAttributes.upsertBatch(inputs);
10590
+ }
10591
+ }
10592
+ }
10593
+ /**
10594
+ * Validate relation properties against PropertySchema.
10595
+ *
10596
+ * Uses Zod for runtime validation based on PropertyDefinition types.
10597
+ *
10598
+ * @param propertySchema - Schema defining allowed properties
10599
+ * @param properties - Properties to validate
10600
+ * @throws {z.ZodError} if validation fails
10601
+ */
10602
+ validateProperties(propertySchema, properties) {
10603
+ const schema = this.buildZodSchema(propertySchema);
10604
+ schema.parse(properties);
10605
+ }
10606
+ // ============================================================================
10607
+ // PRIVATE HELPERS
10608
+ // ============================================================================
10609
+ /**
10610
+ * Normalize relation value to unified internal format.
10611
+ *
10612
+ * Converts:
10613
+ * - string[] → Array<{ id, props?: undefined }>
10614
+ * - string → [{ id, props?: undefined }]
10615
+ * - null → []
10616
+ * - Array<{ id, props }> → Array<{ id, props }> (passthrough)
10617
+ * - { id, props } → [{ id, props }] (single to array)
10618
+ *
10619
+ * @param value - Relation value in hybrid format
10620
+ * @returns Normalized array of relation items
10621
+ * @private
10622
+ */
10623
+ normalizeRelationValue(value) {
10624
+ if (value === null || value === void 0) {
10625
+ return [];
10626
+ }
10627
+ if (typeof value === "string") {
10628
+ return [{ id: value }];
10629
+ }
10630
+ if (!Array.isArray(value) && typeof value === "object" && "id" in value) {
10631
+ return [value];
10632
+ }
10633
+ if (Array.isArray(value)) {
10634
+ return value.map((item) => {
10635
+ if (typeof item === "string") {
10636
+ return { id: item };
10637
+ }
10638
+ return item;
10639
+ });
10640
+ }
10641
+ return [];
10642
+ }
10643
+ /**
10644
+ * Build Zod schema from PropertySchema definition.
10645
+ *
10646
+ * Dynamically generates validation schema based on PropertyDefinition types.
10647
+ *
10648
+ * @param propertySchema - PropertySchema with definitions
10649
+ * @returns Zod schema for validation
10650
+ * @private
10651
+ */
10652
+ buildZodSchema(propertySchema) {
10653
+ const shape = {};
10654
+ for (const def of propertySchema.definitions) {
10655
+ let fieldSchema = this.buildFieldSchema(def);
10656
+ if (!def.required) {
10657
+ fieldSchema = fieldSchema.optional();
10658
+ }
10659
+ shape[def.name] = fieldSchema;
10660
+ }
10661
+ return _zod.z.object(shape);
10662
+ }
10663
+ /**
10664
+ * Build Zod schema for a single property field.
10665
+ *
10666
+ * @param def - PropertyDefinition
10667
+ * @returns Zod schema for the field
10668
+ * @private
10669
+ */
10670
+ buildFieldSchema(def) {
10671
+ switch (def.type) {
10672
+ case "text":
10673
+ case "textarea": {
10674
+ let schema = _zod.z.string();
10675
+ if (def.minLength !== void 0) {
10676
+ schema = schema.min(def.minLength);
10677
+ }
10678
+ if (def.maxLength !== void 0) {
10679
+ schema = schema.max(def.maxLength);
10680
+ }
10681
+ if (def.type === "text" && def.pattern) {
10682
+ schema = schema.regex(new RegExp(def.pattern));
10683
+ }
10684
+ return schema;
10685
+ }
10686
+ case "number": {
10687
+ let schema = _zod.z.number();
10688
+ if (def.min !== void 0) {
10689
+ schema = schema.min(def.min);
10690
+ }
10691
+ if (def.max !== void 0) {
10692
+ schema = schema.max(def.max);
10693
+ }
10694
+ if (def.integer) {
10695
+ schema = schema.int();
10696
+ }
10697
+ return schema;
10698
+ }
10699
+ case "checkbox": {
10700
+ return _zod.z.boolean();
10701
+ }
10702
+ case "date": {
10703
+ const schema = _zod.z.string().datetime();
10704
+ return schema;
10705
+ }
10706
+ case "phone": {
10707
+ return _zod.z.string();
10708
+ }
10709
+ case "currency": {
10710
+ let schema = _zod.z.number();
10711
+ if (def.min !== void 0) {
10712
+ schema = schema.min(def.min);
10713
+ }
10714
+ if (def.max !== void 0) {
10715
+ schema = schema.max(def.max);
10716
+ }
10717
+ return schema;
10718
+ }
10719
+ case "status":
10720
+ case "select": {
10721
+ const validValues = def.options.map((opt) => opt.value);
10722
+ return _zod.z.enum(validValues);
10723
+ }
10724
+ case "multiselect": {
10725
+ const validValues = def.options.map((opt) => opt.value);
10726
+ let schema = _zod.z.array(_zod.z.enum(validValues));
10727
+ if (def.maxSelections !== void 0) {
10728
+ schema = schema.max(def.maxSelections);
10729
+ }
10730
+ return schema;
10731
+ }
10732
+ case "rating": {
10733
+ let schema = _zod.z.number().int();
10734
+ if (def.max !== void 0) {
10735
+ schema = schema.max(def.max);
10736
+ }
10737
+ return schema.min(0);
10738
+ }
10739
+ case "location": {
10740
+ return _zod.z.object({
10741
+ address: _zod.z.string().optional(),
10742
+ lat: _zod.z.number().optional(),
10743
+ lng: _zod.z.number().optional()
10744
+ });
10745
+ }
10746
+ default: {
10747
+ return _zod.z.unknown();
10748
+ }
10749
+ }
10750
+ }
10751
+ };
10752
+
10559
10753
  // src/runtime/services/record/relation.service.ts
10560
10754
  var RelationService = class extends BaseService {
10561
10755
  constructor(adapter, nativeRegistry, options) {
@@ -10633,7 +10827,7 @@ var RelationService = class extends BaseService {
10633
10827
  }
10634
10828
  const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
10635
10829
  const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
10636
- if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _215 => _215.size]) === 0) {
10830
+ if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _209 => _209.size]) === 0) {
10637
10831
  errors.push({
10638
10832
  attribute: attr.name,
10639
10833
  message: `No valid target objects found for ${attr.label}`
@@ -10686,7 +10880,7 @@ var RelationService = class extends BaseService {
10686
10880
  for (const target of targets) {
10687
10881
  try {
10688
10882
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
10689
- if (_optionalChain([objectSchema, 'optionalAccess', _216 => _216.id])) {
10883
+ if (_optionalChain([objectSchema, 'optionalAccess', _210 => _210.id])) {
10690
10884
  objectIds.add(objectSchema.id);
10691
10885
  }
10692
10886
  } catch (e12) {
@@ -10755,7 +10949,7 @@ var RelationService = class extends BaseService {
10755
10949
  const targetResults = await Promise.all(
10756
10950
  filteredTargets.map(async (target) => {
10757
10951
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
10758
- if (!_optionalChain([objectSchema, 'optionalAccess', _217 => _217.id])) return { options: [], total: 0 };
10952
+ if (!_optionalChain([objectSchema, 'optionalAccess', _211 => _211.id])) return { options: [], total: 0 };
10759
10953
  const objectId = objectSchema.id;
10760
10954
  const result = query ? await queryService.searchRecords(objectId, query, queryOptions) : await queryService.listRecords(objectId, queryOptions);
10761
10955
  const options = await Promise.all(
@@ -10885,8 +11079,10 @@ var RelationService = class extends BaseService {
10885
11079
  const [attributeId, recordId] = c.split(":");
10886
11080
  return { compositeId: c, attributeId, recordId };
10887
11081
  });
10888
- const uniqueRecordIds = [...new Set(parsed.map((p) => p.recordId))];
10889
- const uniqueAttributeIds = [...new Set(parsed.map((p) => p.attributeId))];
11082
+ const uniqueRecordIds = [...parsed.reduce((set, p) => set.add(p.recordId), /* @__PURE__ */ new Set())];
11083
+ const uniqueAttributeIds = [
11084
+ ...parsed.reduce((set, p) => set.add(p.attributeId), /* @__PURE__ */ new Set())
11085
+ ];
10890
11086
  const records = await this.recordResolver.findByIds(uniqueRecordIds);
10891
11087
  if (records.length === 0) {
10892
11088
  return [];
@@ -10895,7 +11091,7 @@ var RelationService = class extends BaseService {
10895
11091
  const attributePromises = uniqueAttributeIds.map((id) => this.findAttributeById(id));
10896
11092
  const attributes = await Promise.all(attributePromises);
10897
11093
  const attributeMap = new Map(uniqueAttributeIds.map((id, i) => [id, attributes[i]]));
10898
- const uniqueObjectIds = [...new Set(records.map((r) => r.objectId))];
11094
+ const uniqueObjectIds = [...records.reduce((set, r) => set.add(r.objectId), /* @__PURE__ */ new Set())];
10899
11095
  const schemaPromises = uniqueObjectIds.map((id) => this.schemaService.getObjectSchema(id));
10900
11096
  const schemas = await Promise.all(schemaPromises);
10901
11097
  const schemaMap = new Map(uniqueObjectIds.map((id, i) => [id, schemas[i]]));
@@ -10910,8 +11106,8 @@ var RelationService = class extends BaseService {
10910
11106
  continue;
10911
11107
  }
10912
11108
  const attribute = attributeMap.get(attributeId);
10913
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _218 => _218.targets, 'optionalAccess', _219 => _219.find, 'call', _220 => _220((t) => t.object === objectSchema.name)]);
10914
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _221 => _221.displayTemplate]);
11109
+ const targetConfig = _optionalChain([attribute, 'optionalAccess', _212 => _212.targets, 'optionalAccess', _213 => _213.find, 'call', _214 => _214((t) => t.object === objectSchema.name)]);
11110
+ const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _215 => _215.displayTemplate]);
10915
11111
  const label = await this.resolveLabel(record, objectSchema, customTemplate);
10916
11112
  resolved.push({
10917
11113
  _compositeId: compositeId,
@@ -11061,14 +11257,14 @@ var RollupService = class extends BaseService {
11061
11257
  const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
11062
11258
  let sourceObjectId;
11063
11259
  let reverseRelationAttrName;
11064
- if (_optionalChain([sourceSchema, 'optionalAccess', _222 => _222.id])) {
11260
+ if (_optionalChain([sourceSchema, 'optionalAccess', _216 => _216.id])) {
11065
11261
  sourceObjectId = sourceSchema.id;
11066
11262
  const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
11067
11263
  if (attr.type !== "relation") return false;
11068
11264
  const relationConfig = attr;
11069
- return _optionalChain([relationConfig, 'optionalAccess', _223 => _223.targets, 'optionalAccess', _224 => _224.some, 'call', _225 => _225((t) => t.object === schema.name)]);
11265
+ return _optionalChain([relationConfig, 'optionalAccess', _217 => _217.targets, 'optionalAccess', _218 => _218.some, 'call', _219 => _219((t) => t.object === schema.name)]);
11070
11266
  });
11071
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _226 => _226.name]);
11267
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _220 => _220.name]);
11072
11268
  } else {
11073
11269
  const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
11074
11270
  if (!sourceObject) {
@@ -11079,9 +11275,9 @@ var RollupService = class extends BaseService {
11079
11275
  const reverseRelationAttr = sourceAttributes.find((attr) => {
11080
11276
  if (attr.type !== "relation") return false;
11081
11277
  const relationConfig = attr.config;
11082
- return _optionalChain([relationConfig, 'optionalAccess', _227 => _227.targets, 'optionalAccess', _228 => _228.some, 'call', _229 => _229((t) => t.object === schema.name)]);
11278
+ return _optionalChain([relationConfig, 'optionalAccess', _221 => _221.targets, 'optionalAccess', _222 => _222.some, 'call', _223 => _223((t) => t.object === schema.name)]);
11083
11279
  });
11084
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _230 => _230.name]);
11280
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _224 => _224.name]);
11085
11281
  }
11086
11282
  if (!reverseRelationAttrName) {
11087
11283
  return { value: null, recordCount: 0 };
@@ -11148,7 +11344,10 @@ var RollupService = class extends BaseService {
11148
11344
  return values.filter((v) => v != null && v !== "").length;
11149
11345
  case "countUniqueValues": {
11150
11346
  const nonEmpty = values.filter((v) => v != null && v !== "");
11151
- return new Set(nonEmpty.map((v) => JSON.stringify(v))).size;
11347
+ return nonEmpty.reduce(
11348
+ (set, v) => set.add(JSON.stringify(v)),
11349
+ /* @__PURE__ */ new Set()
11350
+ ).size;
11152
11351
  }
11153
11352
  case "countEmpty":
11154
11353
  return values.filter((v) => v == null || v === "").length;
@@ -11334,13 +11533,13 @@ var RollupService = class extends BaseService {
11334
11533
  if (!obj) continue;
11335
11534
  for (const rollupDbAttr of rollupAttrs) {
11336
11535
  const rollupConfig = rollupDbAttr.config;
11337
- if (!_optionalChain([rollupConfig, 'optionalAccess', _231 => _231.relationAttribute])) continue;
11536
+ if (!_optionalChain([rollupConfig, 'optionalAccess', _225 => _225.relationAttribute])) continue;
11338
11537
  const relationAttr = attributes.find(
11339
11538
  (a) => a.type === "relation" && a.name === rollupConfig.relationAttribute
11340
11539
  );
11341
11540
  if (!relationAttr) continue;
11342
11541
  const relationConfig = relationAttr.config;
11343
- const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _232 => _232.targets, 'optionalAccess', _233 => _233.some, 'call', _234 => _234(
11542
+ const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _226 => _226.targets, 'optionalAccess', _227 => _227.some, 'call', _228 => _228(
11344
11543
  (t) => t.object === changedSchema.name
11345
11544
  )]);
11346
11545
  if (!targetsChangedObject) continue;
@@ -11365,11 +11564,11 @@ var RecordService = class extends BaseService {
11365
11564
  constructor(adapter, options) {
11366
11565
  super(adapter);
11367
11566
  this.schemaService = new ObjectSchemaService(adapter, registry, {
11368
- auditService: _optionalChain([options, 'optionalAccess', _235 => _235.auditService])
11567
+ auditService: _optionalChain([options, 'optionalAccess', _229 => _229.auditService])
11369
11568
  });
11370
- this.permissionService = _optionalChain([options, 'optionalAccess', _236 => _236.permissionService]);
11371
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _237 => _237.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
11372
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _238 => _238.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _239 => _239.policyRegistry]), () => ( defaultPolicyRegistry));
11569
+ this.permissionService = _optionalChain([options, 'optionalAccess', _230 => _230.permissionService]);
11570
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
11571
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _232 => _232.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _233 => _233.policyRegistry]), () => ( defaultPolicyRegistry));
11373
11572
  this.recordResolver = new RecordResolverService(adapter);
11374
11573
  this.queryService = new RecordQueryService(adapter, this.schemaService, {
11375
11574
  permissionService: this.permissionService,
@@ -11379,11 +11578,12 @@ var RecordService = class extends BaseService {
11379
11578
  queryService: this.queryService,
11380
11579
  recordResolver: this.recordResolver
11381
11580
  });
11581
+ this.relationPropertiesService = new RelationPropertiesService(adapter);
11382
11582
  this.rollupService = new RollupService(adapter, {
11383
11583
  recordResolver: this.recordResolver
11384
11584
  });
11385
11585
  this.userService = new UserService(adapter);
11386
- this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _240 => _240.hookRegistry]), () => ( new NoopHookRegistry()));
11586
+ this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _234 => _234.hookRegistry]), () => ( new NoopHookRegistry()));
11387
11587
  this.labelResolver = this.recordResolver.createLabelResolver(this.relationService);
11388
11588
  this.rollupContext = this.recordResolver.createRollupContext(
11389
11589
  this.rollupService,
@@ -11418,35 +11618,51 @@ var RecordService = class extends BaseService {
11418
11618
  schema,
11419
11619
  this.tenantId,
11420
11620
  dataWithDefaults,
11421
- _optionalChain([options, 'optionalAccess', _241 => _241.hookMetadata])
11621
+ _optionalChain([options, 'optionalAccess', _235 => _235.hookMetadata])
11422
11622
  );
11423
- if (!_optionalChain([options, 'optionalAccess', _242 => _242.skipHooks])) {
11623
+ if (!_optionalChain([options, 'optionalAccess', _236 => _236.skipHooks])) {
11424
11624
  await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
11425
11625
  }
11426
- if (_optionalChain([options, 'optionalAccess', _243 => _243.validate]) !== false) {
11427
- if (_optionalChain([options, 'optionalAccess', _244 => _244.allowDraft])) {
11428
- validateDraftOrThrow(schema, dataWithDefaults);
11626
+ const normalizedData = this.relationPropertiesService.normalizeRelationValuesForStorage(
11627
+ schema,
11628
+ dataWithDefaults
11629
+ );
11630
+ if (_optionalChain([options, 'optionalAccess', _237 => _237.validate]) !== false) {
11631
+ if (_optionalChain([options, 'optionalAccess', _238 => _238.allowDraft])) {
11632
+ _chunkU4AB53AMjs.validateDraftOrThrow.call(void 0, schema, normalizedData);
11429
11633
  } else {
11430
- validateObjectOrThrow(schema, dataWithDefaults);
11634
+ _chunkU4AB53AMjs.validateObjectOrThrow.call(void 0, schema, normalizedData);
11431
11635
  }
11432
- if (!_optionalChain([options, 'optionalAccess', _245 => _245.skipRelationValidation])) {
11433
- await this.relationService.validateRelationsOrThrow(schema, dataWithDefaults);
11636
+ if (!_optionalChain([options, 'optionalAccess', _239 => _239.skipRelationValidation])) {
11637
+ await this.relationService.validateRelationsOrThrow(schema, normalizedData);
11434
11638
  }
11435
- if (!_optionalChain([options, 'optionalAccess', _246 => _246.skipUserValidation])) {
11436
- await this.userService.validateUsersOrThrow(schema, dataWithDefaults);
11639
+ if (!_optionalChain([options, 'optionalAccess', _240 => _240.skipUserValidation])) {
11640
+ await this.userService.validateUsersOrThrow(schema, normalizedData);
11437
11641
  }
11438
11642
  }
11439
- const completionStatus = computeRecordStatus(schema, dataWithDefaults);
11440
- const label = await computeLabel(schema, dataWithDefaults, this.labelResolver);
11643
+ const completionStatus = _chunkU4AB53AMjs.computeRecordStatus.call(void 0, schema, normalizedData);
11644
+ const label = await computeLabel(schema, normalizedData, this.labelResolver);
11441
11645
  const record = await this.adapter.objectRecords.create({
11442
11646
  objectId,
11443
- data: dataWithDefaults,
11647
+ data: normalizedData,
11444
11648
  label,
11445
11649
  completionStatus,
11446
- metadata: _optionalChain([options, 'optionalAccess', _247 => _247.metadata]),
11650
+ metadata: _optionalChain([options, 'optionalAccess', _241 => _241.metadata]),
11447
11651
  createdBy: this.userId
11448
11652
  });
11449
- if (!_optionalChain([options, 'optionalAccess', _248 => _248.skipHooks])) {
11653
+ for (const [attrName, value] of Object.entries(dataWithDefaults)) {
11654
+ const attr = schema.attributes.find((a) => a.name === attrName);
11655
+ if (_optionalChain([attr, 'optionalAccess', _242 => _242.type]) === "relation" && attr.properties) {
11656
+ await this.relationPropertiesService.syncRelationProperties(
11657
+ schema,
11658
+ record.id,
11659
+ attrName,
11660
+ value,
11661
+ this.adapter
11662
+ );
11663
+ }
11664
+ }
11665
+ if (!_optionalChain([options, 'optionalAccess', _243 => _243.skipHooks])) {
11450
11666
  const afterCtx = {
11451
11667
  ...hookCtx,
11452
11668
  recordId: record.id,
@@ -11464,7 +11680,7 @@ var RecordService = class extends BaseService {
11464
11680
  objectId: schema.id,
11465
11681
  recordId: record.id,
11466
11682
  recordLabel: record.label,
11467
- metadata: _optionalChain([options, 'optionalAccess', _249 => _249.hookMetadata])
11683
+ metadata: _optionalChain([options, 'optionalAccess', _244 => _244.hookMetadata])
11468
11684
  }).catch((err) => {
11469
11685
  console.error(
11470
11686
  "Audit log failed (record.created):",
@@ -11490,7 +11706,7 @@ var RecordService = class extends BaseService {
11490
11706
  return null;
11491
11707
  }
11492
11708
  const schema = await this.schemaService.getObjectSchema(record.objectId);
11493
- if (!_optionalChain([options, 'optionalAccess', _250 => _250.skipPolicyCheck])) {
11709
+ if (!_optionalChain([options, 'optionalAccess', _245 => _245.skipPolicyCheck])) {
11494
11710
  const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
11495
11711
  if (policy) {
11496
11712
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
@@ -11500,10 +11716,10 @@ var RecordService = class extends BaseService {
11500
11716
  }
11501
11717
  }
11502
11718
  let enrichedRecord = record;
11503
- if (!_optionalChain([options, 'optionalAccess', _251 => _251.skipFormulas])) {
11719
+ if (!_optionalChain([options, 'optionalAccess', _246 => _246.skipFormulas])) {
11504
11720
  enrichedRecord = enrichWithFormulas(record, schema);
11505
11721
  }
11506
- if (_optionalChain([options, 'optionalAccess', _252 => _252.includeSchema])) {
11722
+ if (_optionalChain([options, 'optionalAccess', _247 => _247.includeSchema])) {
11507
11723
  const recordWithSchema = enrichedRecord;
11508
11724
  recordWithSchema.schema = schema;
11509
11725
  return recordWithSchema;
@@ -11565,9 +11781,9 @@ var RecordService = class extends BaseService {
11565
11781
  existing,
11566
11782
  mergedData,
11567
11783
  changedAttributes,
11568
- _optionalChain([options, 'optionalAccess', _253 => _253.hookMetadata])
11784
+ _optionalChain([options, 'optionalAccess', _248 => _248.hookMetadata])
11569
11785
  );
11570
- if (!_optionalChain([options, 'optionalAccess', _254 => _254.skipHooks])) {
11786
+ if (!_optionalChain([options, 'optionalAccess', _249 => _249.skipHooks])) {
11571
11787
  await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
11572
11788
  }
11573
11789
  const hookModifiedValues = {};
@@ -11576,36 +11792,35 @@ var RecordService = class extends BaseService {
11576
11792
  hookModifiedValues[key] = hookCtx.newValues[key];
11577
11793
  }
11578
11794
  }
11579
- if (_optionalChain([options, 'optionalAccess', _255 => _255.validate]) !== false) {
11580
- if (_optionalChain([options, 'optionalAccess', _256 => _256.partial])) {
11581
- validateDraftOrThrow(schema, mergedData);
11795
+ const dataToUpdate = { ...data, ...hookModifiedValues };
11796
+ const normalizedUpdate = this.relationPropertiesService.normalizeRelationValuesForStorage(
11797
+ schema,
11798
+ dataToUpdate
11799
+ );
11800
+ const normalizedMergedData = { ...existing.values, ...normalizedUpdate };
11801
+ if (_optionalChain([options, 'optionalAccess', _250 => _250.validate]) !== false) {
11802
+ if (_optionalChain([options, 'optionalAccess', _251 => _251.partial])) {
11803
+ _chunkU4AB53AMjs.validateDraftOrThrow.call(void 0, schema, normalizedMergedData);
11582
11804
  } else {
11583
- validateObjectOrThrow(schema, mergedData);
11805
+ _chunkU4AB53AMjs.validateObjectOrThrow.call(void 0, schema, normalizedMergedData);
11584
11806
  }
11585
- if (!_optionalChain([options, 'optionalAccess', _257 => _257.skipRelationValidation])) {
11586
- await this.relationService.validateRelationsOrThrow(schema, {
11587
- ...data,
11588
- ...hookModifiedValues
11589
- });
11807
+ if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipRelationValidation])) {
11808
+ await this.relationService.validateRelationsOrThrow(schema, normalizedUpdate);
11590
11809
  }
11591
- if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipUserValidation])) {
11592
- await this.userService.validateUsersOrThrow(schema, {
11593
- ...data,
11594
- ...hookModifiedValues
11595
- });
11810
+ if (!_optionalChain([options, 'optionalAccess', _253 => _253.skipUserValidation])) {
11811
+ await this.userService.validateUsersOrThrow(schema, normalizedUpdate);
11596
11812
  }
11597
11813
  }
11598
- const completionStatus = computeRecordStatus(schema, mergedData);
11599
- const label = await computeLabel(schema, mergedData, this.labelResolver);
11814
+ const completionStatus = _chunkU4AB53AMjs.computeRecordStatus.call(void 0, schema, normalizedMergedData);
11815
+ const label = await computeLabel(schema, normalizedMergedData, this.labelResolver);
11600
11816
  const updatePayload = {
11601
- ...data,
11602
- ...hookModifiedValues,
11817
+ ...normalizedUpdate,
11603
11818
  __completionStatus: completionStatus,
11604
11819
  __label: label,
11605
11820
  __lastUpdatedBy: this.userId,
11606
11821
  __expectedUpdatedAt: existing.updatedAt instanceof Date ? existing.updatedAt.toISOString() : existing.updatedAt
11607
11822
  };
11608
- if (_optionalChain([options, 'optionalAccess', _259 => _259.metadata]) !== void 0) {
11823
+ if (_optionalChain([options, 'optionalAccess', _254 => _254.metadata]) !== void 0) {
11609
11824
  const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
11610
11825
  const mergedMetadata = { ...existingMetadata, ...options.metadata };
11611
11826
  const cleanedMetadata = Object.fromEntries(
@@ -11615,7 +11830,19 @@ var RecordService = class extends BaseService {
11615
11830
  }
11616
11831
  const updated = await this.adapter.objectRecords.update(recordId, updatePayload);
11617
11832
  await this.invalidateRecordCaches(recordId, existing.objectId);
11618
- if (!_optionalChain([options, 'optionalAccess', _260 => _260.skipHooks])) {
11833
+ for (const [attrName, value] of Object.entries(dataToUpdate)) {
11834
+ const attr = schema.attributes.find((a) => a.name === attrName);
11835
+ if (_optionalChain([attr, 'optionalAccess', _255 => _255.type]) === "relation" && attr.properties) {
11836
+ await this.relationPropertiesService.syncRelationProperties(
11837
+ schema,
11838
+ recordId,
11839
+ attrName,
11840
+ value,
11841
+ this.adapter
11842
+ );
11843
+ }
11844
+ }
11845
+ if (!_optionalChain([options, 'optionalAccess', _256 => _256.skipHooks])) {
11619
11846
  const afterCtx = {
11620
11847
  ...hookCtx,
11621
11848
  record: updated
@@ -11630,7 +11857,7 @@ var RecordService = class extends BaseService {
11630
11857
  if (this.auditService && this.userId && allChangedAttributes.length > 0) {
11631
11858
  const changes = allChangedAttributes.map((attr) => ({
11632
11859
  field: attr,
11633
- oldValue: _optionalChain([hookCtx, 'access', _261 => _261.oldValues, 'optionalAccess', _262 => _262[attr]]),
11860
+ oldValue: _optionalChain([hookCtx, 'access', _257 => _257.oldValues, 'optionalAccess', _258 => _258[attr]]),
11634
11861
  newValue: hookCtx.newValues[attr]
11635
11862
  }));
11636
11863
  this.auditService.logRecordAction({
@@ -11641,7 +11868,7 @@ var RecordService = class extends BaseService {
11641
11868
  recordId: updated.id,
11642
11869
  recordLabel: updated.label,
11643
11870
  changes,
11644
- metadata: _optionalChain([options, 'optionalAccess', _263 => _263.hookMetadata])
11871
+ metadata: _optionalChain([options, 'optionalAccess', _259 => _259.hookMetadata])
11645
11872
  }).catch((err) => {
11646
11873
  console.error(
11647
11874
  "Audit log failed (record.updated):",
@@ -11676,22 +11903,22 @@ var RecordService = class extends BaseService {
11676
11903
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
11677
11904
  checkRecordDeleteOrThrow(policy, record, ctx);
11678
11905
  }
11679
- if (_optionalChain([options, 'optionalAccess', _264 => _264.checkSystem]) && schema.system) {
11906
+ if (_optionalChain([options, 'optionalAccess', _260 => _260.checkSystem]) && schema.system) {
11680
11907
  throw new ProtectedResourceError("object", schema.name, "delete");
11681
11908
  }
11682
- if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipReferenceCheck])) {
11909
+ if (!_optionalChain([options, 'optionalAccess', _261 => _261.skipReferenceCheck])) {
11683
11910
  const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
11684
11911
  if (references.length > 0) {
11685
11912
  throw new RecordReferencedError(recordId, references);
11686
11913
  }
11687
11914
  }
11688
- const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _266 => _266.hookMetadata]));
11689
- if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipHooks])) {
11915
+ const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _262 => _262.hookMetadata]));
11916
+ if (!_optionalChain([options, 'optionalAccess', _263 => _263.skipHooks])) {
11690
11917
  await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
11691
11918
  }
11692
11919
  await this.adapter.objectRecords.delete(recordId);
11693
11920
  await this.invalidateRecordCaches(recordId, record.objectId);
11694
- if (!_optionalChain([options, 'optionalAccess', _268 => _268.skipHooks])) {
11921
+ if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipHooks])) {
11695
11922
  await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
11696
11923
  }
11697
11924
  await recalculateParentRollups(record, schema, this.rollupContext);
@@ -11703,7 +11930,7 @@ var RecordService = class extends BaseService {
11703
11930
  objectId: schema.id,
11704
11931
  recordId: record.id,
11705
11932
  recordLabel: record.label,
11706
- metadata: _optionalChain([options, 'optionalAccess', _269 => _269.hookMetadata])
11933
+ metadata: _optionalChain([options, 'optionalAccess', _265 => _265.hookMetadata])
11707
11934
  }).catch((err) => {
11708
11935
  console.error(
11709
11936
  "Audit log failed (record.deleted):",
@@ -11746,13 +11973,13 @@ var RecordService = class extends BaseService {
11746
11973
  this.tenantId
11747
11974
  );
11748
11975
  await checkPermission(this.permissionService, this.userId, schema.name, "update");
11749
- const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _270 => _270.hookMetadata]));
11750
- if (!_optionalChain([options, 'optionalAccess', _271 => _271.skipHooks])) {
11976
+ const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _266 => _266.hookMetadata]));
11977
+ if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipHooks])) {
11751
11978
  await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
11752
11979
  }
11753
11980
  const restored = await this.adapter.objectRecords.restore(recordId);
11754
11981
  await this.invalidateRecordCaches(recordId, record.objectId);
11755
- if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipHooks])) {
11982
+ if (!_optionalChain([options, 'optionalAccess', _268 => _268.skipHooks])) {
11756
11983
  const afterCtx = {
11757
11984
  ...hookCtx,
11758
11985
  record: restored
@@ -11767,7 +11994,7 @@ var RecordService = class extends BaseService {
11767
11994
  objectId: schema.id,
11768
11995
  recordId: restored.id,
11769
11996
  recordLabel: restored.label,
11770
- metadata: _optionalChain([options, 'optionalAccess', _273 => _273.hookMetadata])
11997
+ metadata: _optionalChain([options, 'optionalAccess', _269 => _269.hookMetadata])
11771
11998
  }).catch((err) => {
11772
11999
  console.error(
11773
12000
  "Audit log failed (record.restored):",
@@ -11816,14 +12043,14 @@ var RecordService = class extends BaseService {
11816
12043
  */
11817
12044
  async validateData(objectId, data) {
11818
12045
  const schema = await this.schemaService.getObjectSchema(objectId);
11819
- return validateObject(schema, data);
12046
+ return _chunkU4AB53AMjs.validateObject.call(void 0, schema, data);
11820
12047
  }
11821
12048
  /**
11822
12049
  * Compute the completion status for given data without saving
11823
12050
  */
11824
12051
  async computeStatus(objectId, data) {
11825
12052
  const schema = await this.schemaService.getObjectSchema(objectId);
11826
- return computeRecordStatus(schema, data);
12053
+ return _chunkU4AB53AMjs.computeRecordStatus.call(void 0, schema, data);
11827
12054
  }
11828
12055
  /**
11829
12056
  * Refresh the completion status of an existing record
@@ -11831,7 +12058,7 @@ var RecordService = class extends BaseService {
11831
12058
  async refreshRecordStatus(recordId) {
11832
12059
  const record = await this.getRecordOrThrow(recordId);
11833
12060
  const schema = await this.schemaService.getObjectSchema(record.objectId);
11834
- const newStatus = computeRecordStatus(schema, record.values);
12061
+ const newStatus = _chunkU4AB53AMjs.computeRecordStatus.call(void 0, schema, record.values);
11835
12062
  if (record.completionStatus !== newStatus) {
11836
12063
  await this.adapter.objectRecords.update(recordId, {
11837
12064
  __completionStatus: newStatus
@@ -12148,7 +12375,7 @@ var DocumentRendererService = class {
12148
12375
  throw new StorageDownloadNotSupportedError();
12149
12376
  }
12150
12377
  let storagePath = fileId;
12151
- if (_optionalChain([this, 'access', _274 => _274.options, 'optionalAccess', _275 => _275.filesRepository])) {
12378
+ if (_optionalChain([this, 'access', _270 => _270.options, 'optionalAccess', _271 => _271.filesRepository])) {
12152
12379
  const file2 = await this.options.filesRepository.findById(fileId);
12153
12380
  if (!file2) {
12154
12381
  throw new Error(`Template file not found: ${fileId}`);
@@ -12166,8 +12393,8 @@ var DocumentRendererService = class {
12166
12393
  for (const field of fields) {
12167
12394
  const rawValue = getContextValue(context, field.contextPath);
12168
12395
  const attrInfo = await this.getAttributeInfo(field.contextPath, workflow2);
12169
- if (_optionalChain([attrInfo, 'optionalAccess', _276 => _276.attribute])) {
12170
- if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access', _277 => _277.options, 'optionalAccess', _278 => _278.relationService])) {
12396
+ if (_optionalChain([attrInfo, 'optionalAccess', _272 => _272.attribute])) {
12397
+ if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access', _273 => _273.options, 'optionalAccess', _274 => _274.relationService])) {
12171
12398
  const ids = Array.isArray(rawValue) ? rawValue : [rawValue];
12172
12399
  const stringIds = ids.filter((id) => typeof id === "string");
12173
12400
  if (stringIds.length > 0) {
@@ -12188,7 +12415,7 @@ var DocumentRendererService = class {
12188
12415
  resolved.set(field.id, this.formatValueSimple(rawValue, field.fallback));
12189
12416
  }
12190
12417
  }
12191
- if (relationBatch.length > 0 && _optionalChain([this, 'access', _279 => _279.options, 'optionalAccess', _280 => _280.relationService])) {
12418
+ if (relationBatch.length > 0 && _optionalChain([this, 'access', _275 => _275.options, 'optionalAccess', _276 => _276.relationService])) {
12192
12419
  try {
12193
12420
  const batchResult = await this.options.relationService.resolveIdsBatch(
12194
12421
  relationBatch.map((r) => ({ attributeId: r.attributeId, ids: r.ids }))
@@ -12197,12 +12424,12 @@ var DocumentRendererService = class {
12197
12424
  const options = _nullishCoalesce(batchResult[attributeId], () => ( []));
12198
12425
  const labels = options.map((o) => o.label);
12199
12426
  const field = fields.find((f) => f.id === fieldId);
12200
- resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess', _281 => _281.fallback]) || "");
12427
+ resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess', _277 => _277.fallback]) || "");
12201
12428
  }
12202
12429
  } catch (e14) {
12203
12430
  for (const { fieldId, ids } of relationBatch) {
12204
12431
  const field = fields.find((f) => f.id === fieldId);
12205
- resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess', _282 => _282.fallback]) || "");
12432
+ resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess', _278 => _278.fallback]) || "");
12206
12433
  }
12207
12434
  }
12208
12435
  }
@@ -12213,7 +12440,7 @@ var DocumentRendererService = class {
12213
12440
  * Parses paths like "slots.client.firstName" to find the attribute definition
12214
12441
  */
12215
12442
  async getAttributeInfo(contextPath, workflow2) {
12216
- const schemaService = _optionalChain([this, 'access', _283 => _283.options, 'optionalAccess', _284 => _284.schemaService]);
12443
+ const schemaService = _optionalChain([this, 'access', _279 => _279.options, 'optionalAccess', _280 => _280.schemaService]);
12217
12444
  if (!schemaService) {
12218
12445
  return null;
12219
12446
  }
@@ -12226,7 +12453,7 @@ var DocumentRendererService = class {
12226
12453
  }
12227
12454
  const slotId = parts[1];
12228
12455
  const attributeName = parts[2];
12229
- const slot = _optionalChain([workflow2, 'access', _285 => _285.slots, 'optionalAccess', _286 => _286.find, 'call', _287 => _287((s) => s.id === slotId)]);
12456
+ const slot = _optionalChain([workflow2, 'access', _281 => _281.slots, 'optionalAccess', _282 => _282.find, 'call', _283 => _283((s) => s.id === slotId)]);
12230
12457
  if (!slot) {
12231
12458
  return null;
12232
12459
  }
@@ -12425,7 +12652,7 @@ var DocumentProcessingHook = class extends BaseService {
12425
12652
  const pendingIds = [];
12426
12653
  for (const [nodeId, doc] of Object.entries(context.documents)) {
12427
12654
  const metadata = doc.metadata;
12428
- if (_optionalChain([metadata, 'optionalAccess', _288 => _288.status]) === "pending") {
12655
+ if (_optionalChain([metadata, 'optionalAccess', _284 => _284.status]) === "pending") {
12429
12656
  pendingIds.push(nodeId);
12430
12657
  }
12431
12658
  }
@@ -12476,12 +12703,12 @@ var DocumentProcessingHook = class extends BaseService {
12476
12703
  }
12477
12704
  for (const slotId of targetSlotIds) {
12478
12705
  try {
12479
- const recordId = _optionalChain([context, 'access', _289 => _289.createdRecordIds, 'optionalAccess', _290 => _290[slotId]]);
12706
+ const recordId = _optionalChain([context, 'access', _285 => _285.createdRecordIds, 'optionalAccess', _286 => _286[slotId]]);
12480
12707
  if (!recordId) {
12481
12708
  continue;
12482
12709
  }
12483
- const slotDef = _optionalChain([workflow2, 'access', _291 => _291.slots, 'optionalAccess', _292 => _292.find, 'call', _293 => _293((s) => s.id === slotId)]);
12484
- const objectName = _optionalChain([slotDef, 'optionalAccess', _294 => _294.objectName]);
12710
+ const slotDef = _optionalChain([workflow2, 'access', _287 => _287.slots, 'optionalAccess', _288 => _288.find, 'call', _289 => _289((s) => s.id === slotId)]);
12711
+ const objectName = _optionalChain([slotDef, 'optionalAccess', _290 => _290.objectName]);
12485
12712
  if (!objectName) {
12486
12713
  continue;
12487
12714
  }
@@ -12498,7 +12725,7 @@ var DocumentProcessingHook = class extends BaseService {
12498
12725
  attachedDocumentIds.push(result.document.id);
12499
12726
  const record = await recordService.getRecord(recordId);
12500
12727
  if (record) {
12501
- const attachments = _nullishCoalesce(_optionalChain([record, 'access', _295 => _295.values, 'optionalAccess', _296 => _296.attachments]), () => ( []));
12728
+ const attachments = _nullishCoalesce(_optionalChain([record, 'access', _291 => _291.values, 'optionalAccess', _292 => _292.attachments]), () => ( []));
12502
12729
  await recordService.updateRecord(
12503
12730
  recordId,
12504
12731
  { attachments: [...attachments, result.document.id] },
@@ -12764,7 +12991,7 @@ var WorkflowAccessGrantService = class extends BaseService {
12764
12991
  * Check if a specific token has been revoked.
12765
12992
  */
12766
12993
  isTokenRevoked(dbGrant, jti) {
12767
- return _nullishCoalesce(_optionalChain([dbGrant, 'access', _297 => _297.revoked_token_jtis, 'optionalAccess', _298 => _298.includes, 'call', _299 => _299(jti)]), () => ( false));
12994
+ return _nullishCoalesce(_optionalChain([dbGrant, 'access', _293 => _293.revoked_token_jtis, 'optionalAccess', _294 => _294.includes, 'call', _295 => _295(jti)]), () => ( false));
12768
12995
  }
12769
12996
  /**
12770
12997
  * Validate access token payload against the grant.
@@ -12816,10 +13043,10 @@ var WorkflowInstanceService = class extends BaseService {
12816
13043
  constructor(adapter, workflowService, options) {
12817
13044
  super(adapter);
12818
13045
  this.workflowService = workflowService;
12819
- this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _300 => _300.executorRegistry]), () => ( getDefaultExecutorRegistry()));
12820
- this.schemaService = _optionalChain([options, 'optionalAccess', _301 => _301.schemaService]);
12821
- this.recordService = _optionalChain([options, 'optionalAccess', _302 => _302.recordService]);
12822
- this.documentProcessingHook = _optionalChain([options, 'optionalAccess', _303 => _303.documentProcessingHook]);
13046
+ this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _296 => _296.executorRegistry]), () => ( getDefaultExecutorRegistry()));
13047
+ this.schemaService = _optionalChain([options, 'optionalAccess', _297 => _297.schemaService]);
13048
+ this.recordService = _optionalChain([options, 'optionalAccess', _298 => _298.recordService]);
13049
+ this.documentProcessingHook = _optionalChain([options, 'optionalAccess', _299 => _299.documentProcessingHook]);
12823
13050
  }
12824
13051
  /**
12825
13052
  * Start a new workflow instance
@@ -12848,8 +13075,8 @@ var WorkflowInstanceService = class extends BaseService {
12848
13075
  context.variables = input.variables;
12849
13076
  }
12850
13077
  const instance = {
12851
- id: generateId(),
12852
- workflowId: _nullishCoalesce(workflow2.id, () => ( generateId())),
13078
+ id: _chunkNEVERCM3js.generateId.call(void 0, ),
13079
+ workflowId: _nullishCoalesce(workflow2.id, () => ( _chunkNEVERCM3js.generateId.call(void 0, ))),
12853
13080
  workflowVersion: workflow2.version,
12854
13081
  workflowSnapshot: workflow2,
12855
13082
  status: "running",
@@ -13001,7 +13228,7 @@ var WorkflowInstanceService = class extends BaseService {
13001
13228
  if (!this.adapter.workflowInstances) {
13002
13229
  return { instances: [], total: 0 };
13003
13230
  }
13004
- if (_optionalChain([options, 'optionalAccess', _304 => _304.workflowName])) {
13231
+ if (_optionalChain([options, 'optionalAccess', _300 => _300.workflowName])) {
13005
13232
  const allDbInstances = await this.adapter.workflowInstances.findByWorkflowName(
13006
13233
  options.workflowName,
13007
13234
  { status: options.status }
@@ -13015,11 +13242,11 @@ var WorkflowInstanceService = class extends BaseService {
13015
13242
  return { instances: instances2, total: total2 };
13016
13243
  }
13017
13244
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
13018
- limit: _optionalChain([options, 'optionalAccess', _305 => _305.limit]),
13019
- offset: _optionalChain([options, 'optionalAccess', _306 => _306.offset])
13245
+ limit: _optionalChain([options, 'optionalAccess', _301 => _301.limit]),
13246
+ offset: _optionalChain([options, 'optionalAccess', _302 => _302.offset])
13020
13247
  });
13021
13248
  let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
13022
- if (_optionalChain([options, 'optionalAccess', _307 => _307.status])) {
13249
+ if (_optionalChain([options, 'optionalAccess', _303 => _303.status])) {
13023
13250
  instances = instances.filter((i) => i.status === options.status);
13024
13251
  }
13025
13252
  instances = await this.markExpiredInstances(instances);
@@ -13040,9 +13267,9 @@ var WorkflowInstanceService = class extends BaseService {
13040
13267
  return { instances: [], total: 0 };
13041
13268
  }
13042
13269
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
13043
- status: _optionalChain([options, 'optionalAccess', _308 => _308.status]),
13044
- limit: _optionalChain([options, 'optionalAccess', _309 => _309.limit]),
13045
- offset: _optionalChain([options, 'optionalAccess', _310 => _310.offset])
13270
+ status: _optionalChain([options, 'optionalAccess', _304 => _304.status]),
13271
+ limit: _optionalChain([options, 'optionalAccess', _305 => _305.limit]),
13272
+ offset: _optionalChain([options, 'optionalAccess', _306 => _306.offset])
13046
13273
  });
13047
13274
  const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
13048
13275
  return { instances, total };
@@ -13077,7 +13304,7 @@ var WorkflowInstanceService = class extends BaseService {
13077
13304
  updatedAt: /* @__PURE__ */ new Date()
13078
13305
  };
13079
13306
  }
13080
- const executionId = generateId();
13307
+ const executionId = _chunkNEVERCM3js.generateId.call(void 0, );
13081
13308
  let current = {
13082
13309
  ...instance,
13083
13310
  context: {
@@ -13108,7 +13335,7 @@ var WorkflowInstanceService = class extends BaseService {
13108
13335
  try {
13109
13336
  const schemas = await Promise.all(
13110
13337
  current.workflowSnapshot.slots.map(
13111
- (slot) => _optionalChain([this, 'access', _311 => _311.schemaService, 'optionalAccess', _312 => _312.getObjectSchemaByName, 'call', _313 => _313(slot.objectName)])
13338
+ (slot) => _optionalChain([this, 'access', _307 => _307.schemaService, 'optionalAccess', _308 => _308.getObjectSchemaByName, 'call', _309 => _309(slot.objectName)])
13112
13339
  )
13113
13340
  );
13114
13341
  objectDefinitions = schemas.filter(
@@ -13373,8 +13600,8 @@ var WorkflowInstanceService = class extends BaseService {
13373
13600
  */
13374
13601
  async snapshotRecord(recordId) {
13375
13602
  try {
13376
- const record = await _optionalChain([this, 'access', _314 => _314.recordService, 'optionalAccess', _315 => _315.getRecord, 'call', _316 => _316(recordId, { skipPolicyCheck: true })]);
13377
- return _optionalChain([record, 'optionalAccess', _317 => _317.values]);
13603
+ const record = await _optionalChain([this, 'access', _310 => _310.recordService, 'optionalAccess', _311 => _311.getRecord, 'call', _312 => _312(recordId, { skipPolicyCheck: true })]);
13604
+ return _optionalChain([record, 'optionalAccess', _313 => _313.values]);
13378
13605
  } catch (e18) {
13379
13606
  return void 0;
13380
13607
  }
@@ -13393,13 +13620,13 @@ var WorkflowInstanceService = class extends BaseService {
13393
13620
  for (const op of [...operations].reverse()) {
13394
13621
  try {
13395
13622
  if (op.operation === "create") {
13396
- await _optionalChain([this, 'access', _318 => _318.recordService, 'optionalAccess', _319 => _319.deleteRecord, 'call', _320 => _320(op.recordId, {
13623
+ await _optionalChain([this, 'access', _314 => _314.recordService, 'optionalAccess', _315 => _315.deleteRecord, 'call', _316 => _316(op.recordId, {
13397
13624
  skipHooks: true,
13398
13625
  skipReferenceCheck: true
13399
13626
  })]);
13400
13627
  rolledBack.push(op.slotId);
13401
13628
  } else if (op.operation === "update" && op.previousData) {
13402
- await _optionalChain([this, 'access', _321 => _321.recordService, 'optionalAccess', _322 => _322.updateRecord, 'call', _323 => _323(op.recordId, op.previousData, {
13629
+ await _optionalChain([this, 'access', _317 => _317.recordService, 'optionalAccess', _318 => _318.updateRecord, 'call', _319 => _319(op.recordId, op.previousData, {
13403
13630
  partial: false
13404
13631
  })]);
13405
13632
  rolledBack.push(op.slotId);
@@ -13523,7 +13750,7 @@ var WorkflowInstanceService = class extends BaseService {
13523
13750
  if (!this.adapter.workflowInstances) {
13524
13751
  return;
13525
13752
  }
13526
- const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _324 => _324.context, 'access', _325 => _325.variables, 'optionalAccess', _326 => _326.__version]), () => ( 0));
13753
+ const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _320 => _320.context, 'access', _321 => _321.variables, 'optionalAccess', _322 => _322.__version]), () => ( 0));
13527
13754
  const nextVersion = currentVersion + 1;
13528
13755
  const instanceWithVersion = {
13529
13756
  ...instance,
@@ -13804,7 +14031,7 @@ var WorkflowRelationService = class extends BaseService {
13804
14031
  if (attr.type !== "relation") continue;
13805
14032
  for (const slot of slots) {
13806
14033
  const slotData = context.slots[slot.id];
13807
- const slotRecordId = _optionalChain([slotData, 'optionalAccess', _327 => _327.id]);
14034
+ const slotRecordId = _optionalChain([slotData, 'optionalAccess', _323 => _323.id]);
13808
14035
  if (!slotRecordId) continue;
13809
14036
  const targetsSlotObject = attr.targets.some(
13810
14037
  (t) => t.object === slot.objectName
@@ -13872,7 +14099,7 @@ var WorkflowService = class extends BaseService {
13872
14099
  if (Array.isArray(options)) {
13873
14100
  this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
13874
14101
  } else {
13875
- this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _328 => _328.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
14102
+ this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _324 => _324.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
13876
14103
  }
13877
14104
  }
13878
14105
  // ============================================================================
@@ -13987,7 +14214,7 @@ var WorkflowService = class extends BaseService {
13987
14214
  };
13988
14215
  const validationResult = WorkflowDefinitionSchema.safeParse(definition);
13989
14216
  if (!validationResult.success) {
13990
- const errors = validationResult.error.issues.map((i) => i.message);
14217
+ const errors = _chunkU4AB53AMjs.formatZodErrors.call(void 0, validationResult.error).map((err) => err.message);
13991
14218
  throw new SchemaError(
13992
14219
  `Invalid workflow definition: ${errors.join(", ")}`,
13993
14220
  SchemaErrorCode.VALIDATION_FAILED
@@ -14029,7 +14256,7 @@ var WorkflowService = class extends BaseService {
14029
14256
  };
14030
14257
  const validationResult = WorkflowDefinitionSchema.safeParse(updated);
14031
14258
  if (!validationResult.success) {
14032
- const errors = validationResult.error.issues.map((i) => i.message);
14259
+ const errors = _chunkU4AB53AMjs.formatZodErrors.call(void 0, validationResult.error).map((err) => err.message);
14033
14260
  throw new SchemaError(
14034
14261
  `Invalid workflow definition: ${errors.join(", ")}`,
14035
14262
  SchemaErrorCode.VALIDATION_FAILED
@@ -14058,7 +14285,7 @@ var WorkflowService = class extends BaseService {
14058
14285
  }
14059
14286
  const validationResult = WorkflowDefinitionSchema.safeParse(existing);
14060
14287
  if (!validationResult.success) {
14061
- const errors = validationResult.error.issues.map((i) => i.message);
14288
+ const errors = _chunkU4AB53AMjs.formatZodErrors.call(void 0, validationResult.error).map((err) => err.message);
14062
14289
  throw new SchemaError(
14063
14290
  `Cannot publish invalid workflow: ${errors.join(", ")}`,
14064
14291
  SchemaErrorCode.VALIDATION_FAILED
@@ -14170,7 +14397,7 @@ var WorkflowService = class extends BaseService {
14170
14397
  var UserProfileService = class extends BaseService {
14171
14398
  constructor(adapter, options) {
14172
14399
  super(adapter);
14173
- this.auditService = _optionalChain([options, 'optionalAccess', _329 => _329.auditService]);
14400
+ this.auditService = _optionalChain([options, 'optionalAccess', _325 => _325.auditService]);
14174
14401
  }
14175
14402
  // ============================================================================
14176
14403
  // CACHE MANAGEMENT
@@ -14333,7 +14560,7 @@ var UserProfileService = class extends BaseService {
14333
14560
  */
14334
14561
  async deleteProfile(profileId, options) {
14335
14562
  const profile = await this.getProfileOrThrow(profileId);
14336
- if (_optionalChain([options, 'optionalAccess', _330 => _330.checkAdmin])) {
14563
+ if (_optionalChain([options, 'optionalAccess', _326 => _326.checkAdmin])) {
14337
14564
  if (profile.role === "admin") {
14338
14565
  const adminCount = await this.adapter.userProfiles.countByRole("admin");
14339
14566
  if (adminCount <= 1) {
@@ -14408,7 +14635,7 @@ var UserProfileService = class extends BaseService {
14408
14635
  */
14409
14636
  async hasRole(profileId, role) {
14410
14637
  const profile = await this.getProfile(profileId);
14411
- return _optionalChain([profile, 'optionalAccess', _331 => _331.role]) === role;
14638
+ return _optionalChain([profile, 'optionalAccess', _327 => _327.role]) === role;
14412
14639
  }
14413
14640
  /**
14414
14641
  * Check if user is admin
@@ -14842,7 +15069,7 @@ var DocumentTemplateService = class extends BaseService {
14842
15069
  * Includes both system templates and tenant-specific templates.
14843
15070
  */
14844
15071
  async listTemplates(options) {
14845
- if (_optionalChain([options, 'optionalAccess', _332 => _332.systemOnly])) {
15072
+ if (_optionalChain([options, 'optionalAccess', _328 => _328.systemOnly])) {
14846
15073
  return SYSTEM_TEMPLATES;
14847
15074
  }
14848
15075
  const templates = [...SYSTEM_TEMPLATES];
@@ -14925,8 +15152,8 @@ var DocumentTemplateService = class extends BaseService {
14925
15152
  var DocumentService = class extends BaseService {
14926
15153
  constructor(adapter, options) {
14927
15154
  super(adapter);
14928
- this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _333 => _333.templateService]), () => ( new DocumentTemplateService(adapter)));
14929
- this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _334 => _334.fileService]), () => ( null));
15155
+ this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _329 => _329.templateService]), () => ( new DocumentTemplateService(adapter)));
15156
+ this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _330 => _330.fileService]), () => ( null));
14930
15157
  }
14931
15158
  // ============================================================================
14932
15159
  // CREATE
@@ -15143,7 +15370,7 @@ var DocumentService = class extends BaseService {
15143
15370
  const template = await this.templateService.getTemplateOrThrow(document2.templateId);
15144
15371
  const slots = await this.getSlots(documentId);
15145
15372
  const requiredSlots = template.slots.filter((s) => s.required);
15146
- const filledSlotNames = new Set(slots.map((s) => s.slotName));
15373
+ const filledSlotNames = slots.reduce((set, s) => set.add(s.slotName), /* @__PURE__ */ new Set());
15147
15374
  const allRequiredFilled = requiredSlots.every((s) => filledSlotNames.has(s.name));
15148
15375
  if (!allRequiredFilled) {
15149
15376
  return await this.updateStatus(documentId, "draft");
@@ -15177,7 +15404,7 @@ var DocumentService = class extends BaseService {
15177
15404
  */
15178
15405
  async isComplete(documentId) {
15179
15406
  const document2 = await this.getDocument(documentId);
15180
- return _optionalChain([document2, 'optionalAccess', _335 => _335.status]) !== "draft";
15407
+ return _optionalChain([document2, 'optionalAccess', _331 => _331.status]) !== "draft";
15181
15408
  }
15182
15409
  /**
15183
15410
  * Get document with its template and slots.
@@ -15435,7 +15662,7 @@ var DocumentProcessingService = class extends BaseService {
15435
15662
  type: "signature",
15436
15663
  provider: this.config.signatureAdapter.name,
15437
15664
  input: { signers, ...options },
15438
- expiresAt: _optionalChain([options, 'optionalAccess', _336 => _336.expiresAt])
15665
+ expiresAt: _optionalChain([options, 'optionalAccess', _332 => _332.expiresAt])
15439
15666
  });
15440
15667
  return job;
15441
15668
  }
@@ -15592,7 +15819,7 @@ var DocumentProcessingService = class extends BaseService {
15592
15819
  }
15593
15820
  const document2 = await this.documentService.getDocumentOrThrow(documentId);
15594
15821
  const template = await this.templateService.getTemplateOrThrow(document2.templateId);
15595
- if (!_optionalChain([template, 'access', _337 => _337.autoProcessing, 'optionalAccess', _338 => _338.identityVerification, 'optionalAccess', _339 => _339.enabled])) {
15822
+ if (!_optionalChain([template, 'access', _333 => _333.autoProcessing, 'optionalAccess', _334 => _334.identityVerification, 'optionalAccess', _335 => _335.enabled])) {
15596
15823
  throw new Error("Identity verification is not enabled for this document type");
15597
15824
  }
15598
15825
  const job = await this.adapter.documentJobs.create({
@@ -15678,13 +15905,13 @@ var DocumentProcessingService = class extends BaseService {
15678
15905
  const template = await this.templateService.getTemplateOrThrow(document2.templateId);
15679
15906
  const slots = await this.documentService.getSlots(documentId);
15680
15907
  const jobs = [];
15681
- if (_optionalChain([template, 'access', _340 => _340.autoProcessing, 'optionalAccess', _341 => _341.ocr, 'optionalAccess', _342 => _342.enabled]) && this.config.ocrAdapter) {
15908
+ if (_optionalChain([template, 'access', _336 => _336.autoProcessing, 'optionalAccess', _337 => _337.ocr, 'optionalAccess', _338 => _338.enabled]) && this.config.ocrAdapter) {
15682
15909
  for (const slot of slots) {
15683
15910
  const job = await this.processOcr(documentId, slot.slotName);
15684
15911
  jobs.push(job);
15685
15912
  }
15686
15913
  }
15687
- if (_optionalChain([template, 'access', _343 => _343.autoProcessing, 'optionalAccess', _344 => _344.identityVerification, 'optionalAccess', _345 => _345.enabled]) && this.config.identityAdapter) {
15914
+ if (_optionalChain([template, 'access', _339 => _339.autoProcessing, 'optionalAccess', _340 => _340.identityVerification, 'optionalAccess', _341 => _341.enabled]) && this.config.identityAdapter) {
15688
15915
  const job = await this.verifyIdentity(documentId);
15689
15916
  jobs.push(job);
15690
15917
  }
@@ -15755,15 +15982,15 @@ var DocumentProcessingService = class extends BaseService {
15755
15982
  return {
15756
15983
  ocr: {
15757
15984
  available: !!this.config.ocrAdapter,
15758
- provider: _optionalChain([this, 'access', _346 => _346.config, 'access', _347 => _347.ocrAdapter, 'optionalAccess', _348 => _348.name])
15985
+ provider: _optionalChain([this, 'access', _342 => _342.config, 'access', _343 => _343.ocrAdapter, 'optionalAccess', _344 => _344.name])
15759
15986
  },
15760
15987
  signature: {
15761
15988
  available: !!this.config.signatureAdapter,
15762
- provider: _optionalChain([this, 'access', _349 => _349.config, 'access', _350 => _350.signatureAdapter, 'optionalAccess', _351 => _351.name])
15989
+ provider: _optionalChain([this, 'access', _345 => _345.config, 'access', _346 => _346.signatureAdapter, 'optionalAccess', _347 => _347.name])
15763
15990
  },
15764
15991
  identityVerification: {
15765
15992
  available: !!this.config.identityAdapter,
15766
- provider: _optionalChain([this, 'access', _352 => _352.config, 'access', _353 => _353.identityAdapter, 'optionalAccess', _354 => _354.name])
15993
+ provider: _optionalChain([this, 'access', _348 => _348.config, 'access', _349 => _349.identityAdapter, 'optionalAccess', _350 => _350.name])
15767
15994
  }
15768
15995
  };
15769
15996
  }
@@ -15773,7 +16000,7 @@ var DocumentProcessingService = class extends BaseService {
15773
16000
  var FileService = class extends BaseService {
15774
16001
  constructor(adapter, options) {
15775
16002
  super(adapter);
15776
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _355 => _355.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
16003
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _351 => _351.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
15777
16004
  }
15778
16005
  // ============================================================================
15779
16006
  // UPLOAD (requires StorageAdapter)
@@ -15912,7 +16139,7 @@ var FileService = class extends BaseService {
15912
16139
  */
15913
16140
  async getFile(fileId) {
15914
16141
  const file2 = await this.adapter.files.findById(fileId);
15915
- if (_optionalChain([file2, 'optionalAccess', _356 => _356.deletedAt])) {
16142
+ if (_optionalChain([file2, 'optionalAccess', _352 => _352.deletedAt])) {
15916
16143
  return null;
15917
16144
  }
15918
16145
  return file2;
@@ -15974,12 +16201,12 @@ var FileService = class extends BaseService {
15974
16201
  */
15975
16202
  async deleteFile(fileId, options) {
15976
16203
  const file2 = await this.getFileOrThrow(fileId);
15977
- if (_optionalChain([options, 'optionalAccess', _357 => _357.checkOwnership]) && options.userId) {
16204
+ if (_optionalChain([options, 'optionalAccess', _353 => _353.checkOwnership]) && options.userId) {
15978
16205
  if (file2.uploadedBy !== options.userId) {
15979
16206
  throw new Error("You can only delete files you uploaded");
15980
16207
  }
15981
16208
  }
15982
- if (_optionalChain([options, 'optionalAccess', _358 => _358.hard])) {
16209
+ if (_optionalChain([options, 'optionalAccess', _354 => _354.hard])) {
15983
16210
  await this.adapter.files.hardDelete(fileId);
15984
16211
  } else {
15985
16212
  await this.adapter.files.delete(fileId);
@@ -16010,7 +16237,7 @@ var FileService = class extends BaseService {
16010
16237
  }
16011
16238
  const file2 = await this.getFileOrThrow(fileId);
16012
16239
  await this.adapter.storage.delete(file2.storagePath);
16013
- if (_optionalChain([options, 'optionalAccess', _359 => _359.hard])) {
16240
+ if (_optionalChain([options, 'optionalAccess', _355 => _355.hard])) {
16014
16241
  await this.adapter.files.hardDelete(fileId);
16015
16242
  } else {
16016
16243
  await this.adapter.files.delete(fileId);
@@ -16036,15 +16263,15 @@ var FileService = class extends BaseService {
16036
16263
  const fileResults = await Promise.all(fileIds.map((id) => this.getFile(id)));
16037
16264
  const files = fileResults.filter((f) => f !== null);
16038
16265
  if (files.length === 0) return;
16039
- if (_optionalChain([options, 'optionalAccess', _360 => _360.deleteFromStorage]) && this.adapter.storage) {
16266
+ if (_optionalChain([options, 'optionalAccess', _356 => _356.deleteFromStorage]) && this.adapter.storage) {
16040
16267
  const BATCH_SIZE = 10;
16041
16268
  for (let i = 0; i < files.length; i += BATCH_SIZE) {
16042
16269
  const batch = files.slice(i, i + BATCH_SIZE);
16043
- await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _361 => _361.adapter, 'access', _362 => _362.storage, 'optionalAccess', _363 => _363.delete, 'call', _364 => _364(file2.storagePath)])));
16270
+ await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _357 => _357.adapter, 'access', _358 => _358.storage, 'optionalAccess', _359 => _359.delete, 'call', _360 => _360(file2.storagePath)])));
16044
16271
  }
16045
16272
  }
16046
16273
  const idsToDelete = files.map((f) => f.id);
16047
- if (_optionalChain([options, 'optionalAccess', _365 => _365.hard])) {
16274
+ if (_optionalChain([options, 'optionalAccess', _361 => _361.hard])) {
16048
16275
  await Promise.all(idsToDelete.map((id) => this.adapter.files.hardDelete(id)));
16049
16276
  } else {
16050
16277
  await Promise.all(idsToDelete.map((id) => this.adapter.files.delete(id)));
@@ -16052,12 +16279,12 @@ var FileService = class extends BaseService {
16052
16279
  if (this.auditService && this.userId) {
16053
16280
  await Promise.all(
16054
16281
  files.map(
16055
- (file2) => _optionalChain([this, 'access', _366 => _366.auditService, 'optionalAccess', _367 => _367.logFileAction, 'call', _368 => _368({
16282
+ (file2) => _optionalChain([this, 'access', _362 => _362.auditService, 'optionalAccess', _363 => _363.logFileAction, 'call', _364 => _364({
16056
16283
  action: "file.deleted",
16057
16284
  actorId: _nullishCoalesce(this.userId, () => ( "")),
16058
16285
  fileId: file2.id,
16059
16286
  fileName: file2.name,
16060
- metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _369 => _369.deleteFromStorage]), () => ( false)) }
16287
+ metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _365 => _365.deleteFromStorage]), () => ( false)) }
16061
16288
  })])
16062
16289
  )
16063
16290
  );
@@ -16135,7 +16362,7 @@ var FileService = class extends BaseService {
16135
16362
  if (!file2) {
16136
16363
  return false;
16137
16364
  }
16138
- if (_optionalChain([options, 'optionalAccess', _370 => _370.isAdmin])) {
16365
+ if (_optionalChain([options, 'optionalAccess', _366 => _366.isAdmin])) {
16139
16366
  return true;
16140
16367
  }
16141
16368
  if (file2.visibility === "public") {
@@ -16145,7 +16372,7 @@ var FileService = class extends BaseService {
16145
16372
  return true;
16146
16373
  }
16147
16374
  if (file2.visibility === "restricted") {
16148
- return _nullishCoalesce(_optionalChain([file2, 'access', _371 => _371.allowedUsers, 'optionalAccess', _372 => _372.includes, 'call', _373 => _373(userId)]), () => ( false));
16375
+ return _nullishCoalesce(_optionalChain([file2, 'access', _367 => _367.allowedUsers, 'optionalAccess', _368 => _368.includes, 'call', _369 => _369(userId)]), () => ( false));
16149
16376
  }
16150
16377
  return false;
16151
16378
  }
@@ -16240,7 +16467,7 @@ function withTimeout(promise, ms, label) {
16240
16467
  var GeocodingService = class {
16241
16468
  constructor(adapter, options) {
16242
16469
  this.adapter = adapter;
16243
- this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
16470
+ this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _370 => _370.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
16244
16471
  }
16245
16472
  /**
16246
16473
  * Search for address suggestions as the user types
@@ -16324,10 +16551,10 @@ var GlobalSearchService = class extends BaseService {
16324
16551
  */
16325
16552
  async executeSearch(query, options) {
16326
16553
  return await this.adapter.objectRecords.globalSearch(query, {
16327
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _375 => _375.limit]), () => ( 20)),
16328
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _376 => _376.offset]), () => ( 0)),
16329
- objectNames: _optionalChain([options, 'optionalAccess', _377 => _377.objectNames]),
16330
- includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _378 => _378.includeObjectInfo]), () => ( true))
16554
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _371 => _371.limit]), () => ( 20)),
16555
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _372 => _372.offset]), () => ( 0)),
16556
+ objectNames: _optionalChain([options, 'optionalAccess', _373 => _373.objectNames]),
16557
+ includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.includeObjectInfo]), () => ( true))
16331
16558
  });
16332
16559
  }
16333
16560
  /**
@@ -16338,7 +16565,7 @@ var GlobalSearchService = class extends BaseService {
16338
16565
  * @returns Results grouped by object name
16339
16566
  */
16340
16567
  async searchGrouped(query, options) {
16341
- const limitPerGroup = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _379 => _379.limitPerGroup]), () => ( 5));
16568
+ const limitPerGroup = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _375 => _375.limitPerGroup]), () => ( 5));
16342
16569
  const estimatedGroupCount = 10;
16343
16570
  const fetchLimit = Math.min(limitPerGroup * estimatedGroupCount, 100);
16344
16571
  const { results, total } = await this.search(query, {
@@ -16380,7 +16607,7 @@ var PermissionService = class extends BaseService {
16380
16607
  }
16381
16608
  this.permissionsRepo = adapter.permissions;
16382
16609
  this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
16383
- this.auditService = _optionalChain([options, 'optionalAccess', _380 => _380.auditService]);
16610
+ this.auditService = _optionalChain([options, 'optionalAccess', _376 => _376.auditService]);
16384
16611
  }
16385
16612
  // ============================================================================
16386
16613
  // PERMISSION CHECKS
@@ -16399,11 +16626,11 @@ var PermissionService = class extends BaseService {
16399
16626
  return true;
16400
16627
  }
16401
16628
  const wildcardPerms = permissions.objectPermissions["*"];
16402
- if (_optionalChain([wildcardPerms, 'optionalAccess', _381 => _381.includes, 'call', _382 => _382(action)])) {
16629
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _377 => _377.includes, 'call', _378 => _378(action)])) {
16403
16630
  return true;
16404
16631
  }
16405
16632
  const objectPerms = permissions.objectPermissions[objectName];
16406
- return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _383 => _383.includes, 'call', _384 => _384(action)]), () => ( false));
16633
+ return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _379 => _379.includes, 'call', _380 => _380(action)]), () => ( false));
16407
16634
  }
16408
16635
  /**
16409
16636
  * Check if user can access an object, throw ForbiddenError if not.
@@ -16458,12 +16685,12 @@ var PermissionService = class extends BaseService {
16458
16685
  if (permissions.isAdmin) {
16459
16686
  return true;
16460
16687
  }
16461
- const wildcardPerms = _optionalChain([permissions, 'access', _385 => _385.systemPermissions, 'optionalAccess', _386 => _386["*"]]);
16462
- if (_optionalChain([wildcardPerms, 'optionalAccess', _387 => _387.includes, 'call', _388 => _388(action)])) {
16688
+ const wildcardPerms = _optionalChain([permissions, 'access', _381 => _381.systemPermissions, 'optionalAccess', _382 => _382["*"]]);
16689
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _383 => _383.includes, 'call', _384 => _384(action)])) {
16463
16690
  return true;
16464
16691
  }
16465
- const resourcePerms = _optionalChain([permissions, 'access', _389 => _389.systemPermissions, 'optionalAccess', _390 => _390[resource]]);
16466
- return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _391 => _391.includes, 'call', _392 => _392(action)]), () => ( false));
16692
+ const resourcePerms = _optionalChain([permissions, 'access', _385 => _385.systemPermissions, 'optionalAccess', _386 => _386[resource]]);
16693
+ return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _387 => _387.includes, 'call', _388 => _388(action)]), () => ( false));
16467
16694
  }
16468
16695
  /**
16469
16696
  * Check if user can access a system resource, throw ForbiddenError if not.
@@ -16492,8 +16719,8 @@ var PermissionService = class extends BaseService {
16492
16719
  if (permissions.isAdmin) {
16493
16720
  return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
16494
16721
  }
16495
- const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _393 => _393.systemPermissions, 'optionalAccess', _394 => _394["*"]]), () => ( []));
16496
- const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _395 => _395.systemPermissions, 'optionalAccess', _396 => _396[resource]]), () => ( []));
16722
+ const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _389 => _389.systemPermissions, 'optionalAccess', _390 => _390["*"]]), () => ( []));
16723
+ const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _391 => _391.systemPermissions, 'optionalAccess', _392 => _392[resource]]), () => ( []));
16497
16724
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
16498
16725
  return {
16499
16726
  canRead: allPerms.has("read"),
@@ -16636,7 +16863,7 @@ var PermissionService = class extends BaseService {
16636
16863
  action: "role.updated",
16637
16864
  actorId: this.userId,
16638
16865
  roleId,
16639
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _397 => _397.label]), () => ( roleId)),
16866
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _393 => _393.label]), () => ( roleId)),
16640
16867
  metadata: { permissionsUpdated: true, permissionCount: permissions.length }
16641
16868
  });
16642
16869
  }
@@ -16666,7 +16893,7 @@ var PermissionService = class extends BaseService {
16666
16893
  action: "role.assigned",
16667
16894
  actorId: this.userId,
16668
16895
  roleId,
16669
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _398 => _398.label]), () => ( roleId)),
16896
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _394 => _394.label]), () => ( roleId)),
16670
16897
  targetUserId: userProfileId
16671
16898
  });
16672
16899
  }
@@ -16684,7 +16911,7 @@ var PermissionService = class extends BaseService {
16684
16911
  action: "role.revoked",
16685
16912
  actorId: this.userId,
16686
16913
  roleId,
16687
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _399 => _399.label]), () => ( roleId)),
16914
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _395 => _395.label]), () => ( roleId)),
16688
16915
  targetUserId: userProfileId
16689
16916
  });
16690
16917
  }
@@ -16717,7 +16944,7 @@ var PermissionService = class extends BaseService {
16717
16944
  DEFAULT_ROLE_PERMISSIONS
16718
16945
  } = await Promise.resolve().then(() => _interopRequireWildcard(require("./default-roles-C3FYDYMN.js")));
16719
16946
  const existingRoles = await this.getRoles();
16720
- const existingRoleNames = new Set(existingRoles.map((r) => r.name));
16947
+ const existingRoleNames = existingRoles.reduce((set, r) => set.add(r.name), /* @__PURE__ */ new Set());
16721
16948
  for (const roleName of Object.values(DEFAULT_ROLES)) {
16722
16949
  if (existingRoleNames.has(roleName)) {
16723
16950
  continue;
@@ -17160,7 +17387,7 @@ var ViewService = class extends BaseService {
17160
17387
  dbView.objectName,
17161
17388
  dbView.type,
17162
17389
  objectDefinition,
17163
- dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _400 => _400.config, 'optionalAccess', _401 => _401.layout]), () => ( "page")) : void 0
17390
+ dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _396 => _396.config, 'optionalAccess', _397 => _397.layout]), () => ( "page")) : void 0
17164
17391
  );
17165
17392
  const newConfig = generated.config;
17166
17393
  const updated = await this.adapter.views.update(viewId, { config: newConfig });
@@ -17211,7 +17438,7 @@ var ViewService = class extends BaseService {
17211
17438
  */
17212
17439
  async hasUserCustomizations(viewId, userId) {
17213
17440
  const overlay = await this.adapter.viewOverlays.findByViewAndUser(viewId, userId);
17214
- return overlay !== null && Object.keys(overlay.configOverrides).length > 0;
17441
+ return overlay !== null && hasProperties(overlay.configOverrides);
17215
17442
  }
17216
17443
  // ============================================================================
17217
17444
  // OVERLAY MERGE LOGIC
@@ -17586,8 +17813,9 @@ async function handleDryRun(adapter, nativeObject, existingObject, result, optio
17586
17813
  if (options.verbose) {
17587
17814
  console.info(`[SyncService] Would ${isNew ? "create" : "update"} object: ${nativeObject.name}`);
17588
17815
  }
17816
+ const existingAttrs = existingObject ? await adapter.attributes.findByObjectId(existingObject.id) : [];
17589
17817
  for (const attr of nativeObject.attributes) {
17590
- const existingAttr = existingObject ? await adapter.attributes.findByObjectId(existingObject.id).then((attrs) => attrs.find((a) => a.name === attr.name)) : null;
17818
+ const existingAttr = _nullishCoalesce(existingAttrs.find((a) => a.name === attr.name), () => ( null));
17591
17819
  if (existingAttr) {
17592
17820
  result.attributesUpdated++;
17593
17821
  } else {
@@ -17609,8 +17837,9 @@ async function upsertObject(adapter, nativeObject, _options) {
17609
17837
  });
17610
17838
  }
17611
17839
  async function syncAttributes(adapter, nativeObject, dbObject, existingObject, result) {
17840
+ const existingAttrs = existingObject ? await adapter.attributes.findByObjectId(dbObject.id) : [];
17612
17841
  for (const [index, attr] of nativeObject.attributes.entries()) {
17613
- const existingAttr = existingObject ? await adapter.attributes.findByObjectId(dbObject.id).then((attrs) => attrs.find((a) => a.name === attr.name)) : null;
17842
+ const existingAttr = _nullishCoalesce(existingAttrs.find((a) => a.name === attr.name), () => ( null));
17614
17843
  await adapter.attributes.upsert({
17615
17844
  objectId: dbObject.id,
17616
17845
  name: attr.name,
@@ -18042,51 +18271,4 @@ var NoopGeocodingAdapter = class {
18042
18271
 
18043
18272
 
18044
18273
 
18045
-
18046
-
18047
-
18048
-
18049
-
18050
-
18051
-
18052
-
18053
-
18054
-
18055
-
18056
-
18057
-
18058
-
18059
-
18060
-
18061
-
18062
-
18063
-
18064
-
18065
-
18066
-
18067
-
18068
-
18069
-
18070
-
18071
-
18072
-
18073
-
18074
-
18075
-
18076
-
18077
-
18078
-
18079
-
18080
-
18081
-
18082
-
18083
-
18084
-
18085
-
18086
-
18087
-
18088
-
18089
-
18090
-
18091
-
18092
- exports.IDENTITY_PROPERTIES = IDENTITY_PROPERTIES; exports.BEHAVIOR_PROPERTIES = BEHAVIOR_PROPERTIES; exports.PRESENTATION_PROPERTIES = PRESENTATION_PROPERTIES; exports.isIdentityProperty = isIdentityProperty; exports.isBehaviorProperty = isBehaviorProperty; exports.isPresentationProperty = isPresentationProperty; exports.getPropertyProtectionLevel = getPropertyProtectionLevel; exports.filterPropertiesByCategory = filterPropertiesByCategory; exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isDocumentNode = isDocumentNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isInvitationValid = isInvitationValid; exports.isInvitationAccepted = isInvitationAccepted; exports.isInvitationExpired = isInvitationExpired; exports.isGrantValid = isGrantValid; exports.isGrantRevoked = isGrantRevoked; exports.isTokenRevoked = isTokenRevoked; exports.isGrantExpired = isGrantExpired; exports.canAccessNode = canAccessNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.mergeFormToSlot = mergeFormToSlot; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isInvitationOrGrantEvent = isInvitationOrGrantEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.DocumentNodeSchema = DocumentNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.AuthMethodSchema = AuthMethodSchema; exports.ShareStatusSchema = ShareStatusSchema; exports.WorkflowShareSchema = WorkflowShareSchema; exports.CreateShareInputSchema = CreateShareInputSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.asTenantId = asTenantId; exports.asUserId = asUserId; exports.generateId = generateId; exports.generatePrefixedId = generatePrefixedId; exports.slugify = slugify; exports.generateTemplateName = generateTemplateName; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.ConcurrentModificationError = ConcurrentModificationError; exports.isConcurrentModificationError = isConcurrentModificationError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.document = document; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.DirectTableTabConfig = DirectTableTabConfig; exports.InverseTableTabConfig = InverseTableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.NotesTabConfig = NotesTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.DocumentsTabConfig = DocumentsTabConfig; exports.TabBuilder = TabBuilder; exports.DetailViewBuilder = DetailViewBuilder; exports.ViewBuilder = ViewBuilder; exports.detailView = detailView; exports.view = view; exports.ListViewBuilder = ListViewBuilder; exports.ListViewTabConfigBuilder = ListViewTabConfigBuilder; exports.listView = listView; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.SYSTEM_TEMPLATE_IDS = SYSTEM_TEMPLATE_IDS; exports.FRENCH_ID_CARD = FRENCH_ID_CARD; exports.PASSPORT = PASSPORT; exports.DRIVING_LICENSE = DRIVING_LICENSE; exports.PROOF_OF_ADDRESS = PROOF_OF_ADDRESS; exports.SIGNABLE_CONTRACT = SIGNABLE_CONTRACT; exports.GENERIC_DOCUMENT = GENERIC_DOCUMENT; exports.SYSTEM_TEMPLATES = SYSTEM_TEMPLATES; exports.getSystemTemplate = getSystemTemplate; exports.isSystemTemplate = isSystemTemplate; exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES; exports.textConfigSchema = textConfigSchema; exports.textareaConfigSchema = textareaConfigSchema; exports.richtextConfigSchema = richtextConfigSchema; exports.numberConfigSchema = numberConfigSchema; exports.checkboxConfigSchema = checkboxConfigSchema; exports.dateConfigSchema = dateConfigSchema; exports.phoneConfigSchema = phoneConfigSchema; exports.currencyConfigSchema = currencyConfigSchema; exports.statusConfigSchema = statusConfigSchema; exports.locationConfigSchema = locationConfigSchema; exports.selectConfigSchema = selectConfigSchema; exports.multiselectConfigSchema = multiselectConfigSchema; exports.fileConfigSchema = fileConfigSchema; exports.userConfigSchema = userConfigSchema; exports.relationConfigSchema = relationConfigSchema; exports.ratingConfigSchema = ratingConfigSchema; exports.formulaConfigSchema = formulaConfigSchema; exports.rollupConfigSchema = rollupConfigSchema; exports.documentConfigSchema = documentConfigSchema; exports.attributeConfigSchemas = attributeConfigSchemas; exports.getAttributeConfigSchema = getAttributeConfigSchema; exports.validateAttributeConfig = validateAttributeConfig; exports.parseAttributeConfig = parseAttributeConfig; exports.safeParseAttributeConfig = safeParseAttributeConfig; exports.createTextValidator = createTextValidator; exports.createNumberValidator = createNumberValidator; exports.createCheckboxValidator = createCheckboxValidator; exports.createDateValidator = createDateValidator; exports.createPhoneValidator = createPhoneValidator; exports.createCurrencyValidator = createCurrencyValidator; exports.createStatusValidator = createStatusValidator; exports.createSelectValidator = createSelectValidator; exports.createMultiselectValidator = createMultiselectValidator; exports.createLocationValidator = createLocationValidator; exports.createFileValidator = createFileValidator; exports.createUserValidator = createUserValidator; exports.createSingleRelationValidator = createSingleRelationValidator; exports.createMultiRelationValidator = createMultiRelationValidator; exports.createRelationValidator = createRelationValidator; exports.createRatingValidator = createRatingValidator; exports.createFormulaValidator = createFormulaValidator; exports.createRollupValidator = createRollupValidator; exports.createTextAreaValidator = createTextAreaValidator; exports.createRichtextValidator = createRichtextValidator; exports.createAttributeValidator = createAttributeValidator; exports.createFormAttributeValidator = createFormAttributeValidator; exports.createObjectValidator = createObjectValidator; exports.validateAttribute = validateAttribute; exports.validateObject = validateObject; exports.validateObjectOrThrow = validateObjectOrThrow; exports.createDraftValidator = createDraftValidator; exports.validateDraft = validateDraft; exports.validateDraftOrThrow = validateDraftOrThrow; exports.getMissingRequiredAttributes = getMissingRequiredAttributes; exports.isRecordComplete = isRecordComplete; exports.computeRecordStatus = computeRecordStatus; exports.WorkflowJwtService = WorkflowJwtService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.FeatureFlagsContextError = FeatureFlagsContextError; exports.isFeatureEnabled = isFeatureEnabled; exports.getFeatureValue = getFeatureValue; exports.getFeatureFlags = getFeatureFlags; exports.tryGetFeatureValue = tryGetFeatureValue; exports.hasFeatureFlagsContext = hasFeatureFlagsContext; exports.runWithFeatureFlags = runWithFeatureFlags; exports.withFeatureFlags = withFeatureFlags; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext2; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.DocumentExecutor = DocumentExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.DEFAULT_LABEL_FALLBACK = DEFAULT_LABEL_FALLBACK; exports.renderLabelExpression = renderLabelExpression; exports.isLabelExpression = isLabelExpression; exports.extractAttributeNames = extractAttributeNames; exports.enrichValuesForDisplay = enrichValuesForDisplay; exports.enrichValuesWithSelectLabels = enrichValuesWithSelectLabels; exports.extractRelationIds = extractRelationIds; exports.computeLabelWithRelations = computeLabelWithRelations; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.notesPolicy = notesPolicy; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.checkSharedObjectWriteAccess = checkSharedObjectWriteAccess; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.DocumentRenderError = DocumentRenderError; exports.StorageDownloadNotSupportedError = StorageDownloadNotSupportedError; exports.DocumentRendererService = DocumentRendererService; exports.DocumentProcessingHook = DocumentProcessingHook; exports.GrantNotFoundError = GrantNotFoundError; exports.GrantExpiredError = GrantExpiredError; exports.GrantRevokedError = GrantRevokedError; exports.TokenRevokedError = TokenRevokedError; exports.WorkflowAccessGrantService = WorkflowAccessGrantService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.InvitationNotFoundError = InvitationNotFoundError; exports.InvitationExpiredError = InvitationExpiredError; exports.InvitationAlreadyAcceptedError = InvitationAlreadyAcceptedError; exports.InvitationRevokedError = InvitationRevokedError; exports.WorkflowInvitationService = WorkflowInvitationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.UserProfileService = UserProfileService; exports.DocumentGenerationTemplateNotFoundError = DocumentGenerationTemplateNotFoundError; exports.DocumentGenerationNotConfiguredError = DocumentGenerationNotConfiguredError; exports.DocumentGenerationService = DocumentGenerationService; exports.DocumentTemplateService = DocumentTemplateService; exports.DocumentService = DocumentService; exports.DocumentProcessingService = DocumentProcessingService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.seedRegistryViews = seedRegistryViews; exports.syncNativeViews = syncNativeViews; exports.verifyRegistryViewsSeeded = verifyRegistryViewsSeeded; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSeedPreview = getViewSeedPreview; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
18274
+ exports.IDENTITY_PROPERTIES = IDENTITY_PROPERTIES; exports.BEHAVIOR_PROPERTIES = BEHAVIOR_PROPERTIES; exports.PRESENTATION_PROPERTIES = PRESENTATION_PROPERTIES; exports.isIdentityProperty = isIdentityProperty; exports.isBehaviorProperty = isBehaviorProperty; exports.isPresentationProperty = isPresentationProperty; exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.FORBIDDEN_PROPERTY_TYPES = FORBIDDEN_PROPERTY_TYPES; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isDocumentNode = isDocumentNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isInvitationValid = isInvitationValid; exports.isInvitationAccepted = isInvitationAccepted; exports.isInvitationExpired = isInvitationExpired; exports.isGrantValid = isGrantValid; exports.isGrantRevoked = isGrantRevoked; exports.isTokenRevoked = isTokenRevoked; exports.isGrantExpired = isGrantExpired; exports.canAccessNode = canAccessNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isInvitationOrGrantEvent = isInvitationOrGrantEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.DocumentNodeSchema = DocumentNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.AuthMethodSchema = AuthMethodSchema; exports.ShareStatusSchema = ShareStatusSchema; exports.WorkflowShareSchema = WorkflowShareSchema; exports.CreateShareInputSchema = CreateShareInputSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.toUndefinedIfEmpty = toUndefinedIfEmpty; exports.hasProperties = hasProperties; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.ConcurrentModificationError = ConcurrentModificationError; exports.PropertySchemaBuilder = PropertySchemaBuilder; exports.PropertyTypeBuilder = PropertyTypeBuilder; exports.BasePropertyBuilder = BasePropertyBuilder; exports.TextPropertyBuilder = TextPropertyBuilder; exports.TextareaPropertyBuilder = TextareaPropertyBuilder; exports.NumberPropertyBuilder = NumberPropertyBuilder; exports.CheckboxPropertyBuilder = CheckboxPropertyBuilder; exports.DatePropertyBuilder = DatePropertyBuilder; exports.PhonePropertyBuilder = PhonePropertyBuilder; exports.CurrencyPropertyBuilder = CurrencyPropertyBuilder; exports.StatusPropertyBuilder = StatusPropertyBuilder; exports.SelectPropertyBuilder = SelectPropertyBuilder; exports.MultiselectPropertyBuilder = MultiselectPropertyBuilder; exports.RatingPropertyBuilder = RatingPropertyBuilder; exports.LocationPropertyBuilder = LocationPropertyBuilder; exports.validatePropertyType = validatePropertyType; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.document = document; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.DirectTableTabConfig = DirectTableTabConfig; exports.InverseTableTabConfig = InverseTableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.NotesTabConfig = NotesTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.DocumentsTabConfig = DocumentsTabConfig; exports.TabBuilder = TabBuilder; exports.DetailViewBuilder = DetailViewBuilder; exports.ViewBuilder = ViewBuilder; exports.detailView = detailView; exports.view = view; exports.ListViewBuilder = ListViewBuilder; exports.ListViewTabConfigBuilder = ListViewTabConfigBuilder; exports.listView = listView; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.SYSTEM_TEMPLATE_IDS = SYSTEM_TEMPLATE_IDS; exports.FRENCH_ID_CARD = FRENCH_ID_CARD; exports.PASSPORT = PASSPORT; exports.DRIVING_LICENSE = DRIVING_LICENSE; exports.PROOF_OF_ADDRESS = PROOF_OF_ADDRESS; exports.SIGNABLE_CONTRACT = SIGNABLE_CONTRACT; exports.GENERIC_DOCUMENT = GENERIC_DOCUMENT; exports.SYSTEM_TEMPLATES = SYSTEM_TEMPLATES; exports.getSystemTemplate = getSystemTemplate; exports.isSystemTemplate = isSystemTemplate; exports.WorkflowJwtService = WorkflowJwtService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.FeatureFlagsContextError = FeatureFlagsContextError; exports.isFeatureEnabled = isFeatureEnabled; exports.getFeatureValue = getFeatureValue; exports.getFeatureFlags = getFeatureFlags; exports.tryGetFeatureValue = tryGetFeatureValue; exports.hasFeatureFlagsContext = hasFeatureFlagsContext; exports.runWithFeatureFlags = runWithFeatureFlags; exports.withFeatureFlags = withFeatureFlags; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext2; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.DocumentExecutor = DocumentExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.DEFAULT_LABEL_FALLBACK = DEFAULT_LABEL_FALLBACK; exports.renderLabelExpression = renderLabelExpression; exports.isLabelExpression = isLabelExpression; exports.extractAttributeNames = extractAttributeNames; exports.enrichValuesForDisplay = enrichValuesForDisplay; exports.enrichValuesWithSelectLabels = enrichValuesWithSelectLabels; exports.extractRelationIds = extractRelationIds; exports.computeLabelWithRelations = computeLabelWithRelations; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.notesPolicy = notesPolicy; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.checkSharedObjectWriteAccess = checkSharedObjectWriteAccess; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationPropertiesService = RelationPropertiesService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.DocumentRenderError = DocumentRenderError; exports.StorageDownloadNotSupportedError = StorageDownloadNotSupportedError; exports.DocumentRendererService = DocumentRendererService; exports.DocumentProcessingHook = DocumentProcessingHook; exports.GrantNotFoundError = GrantNotFoundError; exports.GrantExpiredError = GrantExpiredError; exports.GrantRevokedError = GrantRevokedError; exports.TokenRevokedError = TokenRevokedError; exports.WorkflowAccessGrantService = WorkflowAccessGrantService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.InvitationNotFoundError = InvitationNotFoundError; exports.InvitationExpiredError = InvitationExpiredError; exports.InvitationAlreadyAcceptedError = InvitationAlreadyAcceptedError; exports.InvitationRevokedError = InvitationRevokedError; exports.WorkflowInvitationService = WorkflowInvitationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.UserProfileService = UserProfileService; exports.DocumentGenerationTemplateNotFoundError = DocumentGenerationTemplateNotFoundError; exports.DocumentGenerationNotConfiguredError = DocumentGenerationNotConfiguredError; exports.DocumentGenerationService = DocumentGenerationService; exports.DocumentTemplateService = DocumentTemplateService; exports.DocumentService = DocumentService; exports.DocumentProcessingService = DocumentProcessingService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.seedRegistryViews = seedRegistryViews; exports.syncNativeViews = syncNativeViews; exports.verifyRegistryViewsSeeded = verifyRegistryViewsSeeded; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSeedPreview = getViewSeedPreview; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;