@stndrds/schema 0.1.0-alpha.40 → 0.1.0-alpha.41

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.
@@ -482,7 +482,7 @@ var TenantContextError = class _TenantContextError extends Error {
482
482
  }
483
483
  };
484
484
 
485
- // src/runtime/context/tenant-context.ts
485
+ // src/runtime/context/schema-context.ts
486
486
  var browserStub = {
487
487
  getStore: () => void 0,
488
488
  run: (_store, callback) => callback()
@@ -520,8 +520,102 @@ function getStorage() {
520
520
  storageInstance = browserStub;
521
521
  return storageInstance;
522
522
  }
523
- function getContext() {
523
+ function getSchemaFromContext(objectId) {
524
+ const ctx = getStorage().getStore();
525
+ return _optionalChain([ctx, 'optionalAccess', _5 => _5.objectsById, 'access', _6 => _6.get, 'call', _7 => _7(objectId)]);
526
+ }
527
+ function getSchemaByNameFromContext(objectName) {
524
528
  const ctx = getStorage().getStore();
529
+ return _optionalChain([ctx, 'optionalAccess', _8 => _8.objectsByName, 'access', _9 => _9.get, 'call', _10 => _10(objectName)]);
530
+ }
531
+ function hasSchemaContext() {
532
+ return getStorage().getStore() !== void 0;
533
+ }
534
+ function getSchemaContext() {
535
+ return getStorage().getStore();
536
+ }
537
+ function addSchemaToContext(schema) {
538
+ const ctx = getStorage().getStore();
539
+ if (!ctx) {
540
+ return;
541
+ }
542
+ if (schema.id) {
543
+ ctx.objectsById.set(schema.id, schema);
544
+ }
545
+ ctx.objectsByName.set(schema.name, schema);
546
+ }
547
+ function buildSchemaContext(schemas) {
548
+ const objectsById = /* @__PURE__ */ new Map();
549
+ const objectsByName = /* @__PURE__ */ new Map();
550
+ for (const schema of schemas) {
551
+ if (schema.id) {
552
+ objectsById.set(schema.id, schema);
553
+ }
554
+ objectsByName.set(schema.name, schema);
555
+ }
556
+ return { objectsById, objectsByName };
557
+ }
558
+ function runWithSchemaContext(schemas, fn) {
559
+ const context = buildSchemaContext(schemas);
560
+ return getStorage().run(context, fn);
561
+ }
562
+ function runWithMergedSchemaContext(schemas, fn) {
563
+ const existing = getStorage().getStore();
564
+ const objectsById = new Map(_optionalChain([existing, 'optionalAccess', _11 => _11.objectsById]));
565
+ const objectsByName = new Map(_optionalChain([existing, 'optionalAccess', _12 => _12.objectsByName]));
566
+ for (const schema of schemas) {
567
+ if (schema.id) {
568
+ objectsById.set(schema.id, schema);
569
+ }
570
+ objectsByName.set(schema.name, schema);
571
+ }
572
+ const context = {
573
+ objectsById,
574
+ objectsByName
575
+ };
576
+ return getStorage().run(context, fn);
577
+ }
578
+
579
+ // src/runtime/context/tenant-context.ts
580
+ var browserStub2 = {
581
+ getStore: () => void 0,
582
+ run: (_store, callback) => callback()
583
+ };
584
+ var AsyncLocalStorageClass2 = null;
585
+ if (typeof process !== "undefined" && _optionalChain([process, 'access', _13 => _13.versions, 'optionalAccess', _14 => _14.node])) {
586
+ try {
587
+ if (typeof _chunk3RG5ZIWIjs.__require !== "undefined") {
588
+ const asyncHooks = _chunk3RG5ZIWIjs.__require.call(void 0, "async_hooks");
589
+ AsyncLocalStorageClass2 = asyncHooks.AsyncLocalStorage;
590
+ }
591
+ } catch (e6) {
592
+ try {
593
+ const dynamicRequire = new Function(
594
+ "m",
595
+ 'return typeof require!=="undefined"?require(m):null'
596
+ );
597
+ const asyncHooks = dynamicRequire("node:async_hooks");
598
+ if (asyncHooks) {
599
+ AsyncLocalStorageClass2 = asyncHooks.AsyncLocalStorage;
600
+ }
601
+ } catch (e7) {
602
+ }
603
+ }
604
+ }
605
+ var storageInstance2 = null;
606
+ function getStorage2() {
607
+ if (storageInstance2 !== null) {
608
+ return storageInstance2;
609
+ }
610
+ if (AsyncLocalStorageClass2) {
611
+ storageInstance2 = new AsyncLocalStorageClass2();
612
+ return storageInstance2;
613
+ }
614
+ storageInstance2 = browserStub2;
615
+ return storageInstance2;
616
+ }
617
+ function getContext() {
618
+ const ctx = getStorage2().getStore();
525
619
  if (!ctx) {
526
620
  throw new TenantContextError();
527
621
  }
@@ -534,11 +628,11 @@ function getUserId() {
534
628
  return getContext().userId;
535
629
  }
536
630
  function hasContext() {
537
- return getStorage().getStore() !== void 0;
631
+ return getStorage2().getStore() !== void 0;
538
632
  }
539
633
  function runWithContext(context, fn) {
540
634
  const frozenContext = Object.freeze({ ...context });
541
- return getStorage().run(frozenContext, fn);
635
+ return getStorage2().run(frozenContext, fn);
542
636
  }
543
637
  function withTenantContext(tenantId, fn, userId) {
544
638
  return runWithContext({ tenantId, userId }, fn);
@@ -919,9 +1013,9 @@ var QueryBuilder = class _QueryBuilder {
919
1013
  objectId,
920
1014
  data,
921
1015
  {
922
- allowDraft: _optionalChain([options, 'optionalAccess', _5 => _5.allowDraft]),
923
- validate: _optionalChain([options, 'optionalAccess', _6 => _6.validate]),
924
- metadata: _optionalChain([options, 'optionalAccess', _7 => _7.metadata])
1016
+ allowDraft: _optionalChain([options, 'optionalAccess', _15 => _15.allowDraft]),
1017
+ validate: _optionalChain([options, 'optionalAccess', _16 => _16.validate]),
1018
+ metadata: _optionalChain([options, 'optionalAccess', _17 => _17.metadata])
925
1019
  }
926
1020
  );
927
1021
  if (this.state.raw) {
@@ -956,7 +1050,7 @@ var QueryBuilder = class _QueryBuilder {
956
1050
  data,
957
1051
  {
958
1052
  partial: true,
959
- metadata: _optionalChain([options, 'optionalAccess', _8 => _8.metadata])
1053
+ metadata: _optionalChain([options, 'optionalAccess', _18 => _18.metadata])
960
1054
  }
961
1055
  );
962
1056
  if (this.state.raw) {
@@ -1004,7 +1098,7 @@ var QueryBuilder = class _QueryBuilder {
1004
1098
  const existing = await this.findById(id);
1005
1099
  if (existing) {
1006
1100
  return this.eq("id", id).update(writeData, {
1007
- metadata: _optionalChain([options, 'optionalAccess', _9 => _9.metadata])
1101
+ metadata: _optionalChain([options, 'optionalAccess', _19 => _19.metadata])
1008
1102
  });
1009
1103
  }
1010
1104
  }
@@ -1013,10 +1107,10 @@ var QueryBuilder = class _QueryBuilder {
1013
1107
  };
1014
1108
  function createQueryBuilder(recordService, adapter, objectName, options) {
1015
1109
  const initialState = {};
1016
- if (_optionalChain([options, 'optionalAccess', _10 => _10.tenantId])) {
1110
+ if (_optionalChain([options, 'optionalAccess', _20 => _20.tenantId])) {
1017
1111
  initialState.tenantId = asTenantId(options.tenantId);
1018
1112
  }
1019
- if (_optionalChain([options, 'optionalAccess', _11 => _11.userId])) {
1113
+ if (_optionalChain([options, 'optionalAccess', _21 => _21.userId])) {
1020
1114
  initialState.userId = asUserId(options.userId);
1021
1115
  }
1022
1116
  return new QueryBuilder(recordService, adapter, objectName, initialState);
@@ -1425,7 +1519,7 @@ var WorkflowDefinitionSchema = _zod.z.object({
1425
1519
  ).refine(
1426
1520
  (def) => {
1427
1521
  const startNode = def.nodes[def.startNodeId];
1428
- return _optionalChain([startNode, 'optionalAccess', _12 => _12.type]) === "start";
1522
+ return _optionalChain([startNode, 'optionalAccess', _22 => _22.type]) === "start";
1429
1523
  },
1430
1524
  {
1431
1525
  message: "startNodeId must reference a node of type 'start'"
@@ -1657,8 +1751,8 @@ function wait(reason, options) {
1657
1751
  return {
1658
1752
  status: "wait",
1659
1753
  reason,
1660
- requiredParticipationId: _optionalChain([options, 'optionalAccess', _13 => _13.requiredParticipationId]),
1661
- expiresAt: _optionalChain([options, 'optionalAccess', _14 => _14.expiresAt])
1754
+ requiredParticipationId: _optionalChain([options, 'optionalAccess', _23 => _23.requiredParticipationId]),
1755
+ expiresAt: _optionalChain([options, 'optionalAccess', _24 => _24.expiresAt])
1662
1756
  };
1663
1757
  }
1664
1758
  function complete(finalStatus) {
@@ -1843,9 +1937,9 @@ var FormExecutor = class {
1843
1937
  const object2 = objects.find((o) => o.name === slot.objectName);
1844
1938
  if (!object2) continue;
1845
1939
  const attribute = object2.attributes.find((a) => a.name === fieldRef.attribute);
1846
- if (!_optionalChain([attribute, 'optionalAccess', _15 => _15.required])) continue;
1940
+ if (!_optionalChain([attribute, 'optionalAccess', _25 => _25.required])) continue;
1847
1941
  const slotInput = input[fieldRef.slotId];
1848
- const value = _optionalChain([slotInput, 'optionalAccess', _16 => _16[fieldRef.attribute]]);
1942
+ const value = _optionalChain([slotInput, 'optionalAccess', _26 => _26[fieldRef.attribute]]);
1849
1943
  if (value === void 0 || value === null || value === "") {
1850
1944
  errors.push(
1851
1945
  `Field "${_nullishCoalesce(attribute.label, () => ( fieldRef.attribute))}" is required for ${slot.label}`
@@ -2019,7 +2113,7 @@ function evaluateFormula(expression, values) {
2019
2113
  try {
2020
2114
  const parsed = formulaParser.parse(expression);
2021
2115
  return parsed.evaluate(values);
2022
- } catch (e6) {
2116
+ } catch (e8) {
2023
2117
  return null;
2024
2118
  }
2025
2119
  }
@@ -2079,7 +2173,7 @@ function extractFormulaVariables(expression) {
2079
2173
  try {
2080
2174
  const parsed = formulaParser.parse(expression);
2081
2175
  return parsed.variables();
2082
- } catch (e7) {
2176
+ } catch (e9) {
2083
2177
  return [];
2084
2178
  }
2085
2179
  }
@@ -2166,7 +2260,7 @@ async function parsePath(path, startSchema, getSchema, maxDepth = 5) {
2166
2260
  }
2167
2261
  if (attr.type === "relation") {
2168
2262
  const relationAttr = attr;
2169
- const targetObject = _optionalChain([relationAttr, 'access', _17 => _17.targets, 'access', _18 => _18[0], 'optionalAccess', _19 => _19.object]);
2263
+ const targetObject = _optionalChain([relationAttr, 'access', _27 => _27.targets, 'access', _28 => _28[0], 'optionalAccess', _29 => _29.object]);
2170
2264
  if (!targetObject) {
2171
2265
  throw new InvalidPathError(path, segmentName, "Relation has no target object");
2172
2266
  }
@@ -2207,7 +2301,7 @@ async function validatePath(path, startSchema, getSchema, maxDepth = 5) {
2207
2301
  try {
2208
2302
  await parsePath(path, startSchema, getSchema, maxDepth);
2209
2303
  return true;
2210
- } catch (e8) {
2304
+ } catch (e10) {
2211
2305
  return false;
2212
2306
  }
2213
2307
  }
@@ -2229,7 +2323,7 @@ function getRelationPath(path) {
2229
2323
 
2230
2324
  // src/runtime/formula/path-traversal.ts
2231
2325
  async function traversePath(record, path, startSchemaName, adapter, getSchema, options) {
2232
- const maxDepth = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.maxDepth]), () => ( 5));
2326
+ const maxDepth = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.maxDepth]), () => ( 5));
2233
2327
  const startSchema = await getSchema(startSchemaName);
2234
2328
  if (!startSchema) {
2235
2329
  return { values: [], recordCounts: [0] };
@@ -2315,8 +2409,14 @@ function formatCheckbox(value) {
2315
2409
  function formatNumber(value, attribute) {
2316
2410
  if (typeof value !== "number") return String(value);
2317
2411
  const decimals = attribute.decimals;
2318
- if (attribute.unit === "percentage") {
2412
+ if (attribute.unit === "integer") {
2319
2413
  return value.toLocaleString(void 0, {
2414
+ minimumFractionDigits: 0,
2415
+ maximumFractionDigits: 0
2416
+ });
2417
+ }
2418
+ if (attribute.unit === "percentage") {
2419
+ return (value / 100).toLocaleString(void 0, {
2320
2420
  style: "percent",
2321
2421
  minimumFractionDigits: decimals,
2322
2422
  maximumFractionDigits: decimals
@@ -2355,7 +2455,7 @@ function formatPhone(value) {
2355
2455
  if (!("phoneNumber" in phone2)) return String(value);
2356
2456
  if (phone2.countryCode) {
2357
2457
  const country = _constants.getCountryByIso3.call(void 0, phone2.countryCode);
2358
- const dial = _nullishCoalesce(_optionalChain([country, 'optionalAccess', _21 => _21.phoneCode]), () => ( ""));
2458
+ const dial = _nullishCoalesce(_optionalChain([country, 'optionalAccess', _31 => _31.phoneCode]), () => ( ""));
2359
2459
  return `${dial} ${phone2.phoneNumber}`.trim();
2360
2460
  }
2361
2461
  return phone2.phoneNumber;
@@ -2401,13 +2501,13 @@ function formatLocation(value, attribute) {
2401
2501
  }
2402
2502
  function formatSelect(value, attribute) {
2403
2503
  if (typeof value !== "string") return String(value);
2404
- const option = _optionalChain([attribute, 'access', _22 => _22.options, 'optionalAccess', _23 => _23.find, 'call', _24 => _24((o) => o.value === value)]);
2405
- return _nullishCoalesce(_optionalChain([option, 'optionalAccess', _25 => _25.label]), () => ( String(value)));
2504
+ const option = _optionalChain([attribute, 'access', _32 => _32.options, 'optionalAccess', _33 => _33.find, 'call', _34 => _34((o) => o.value === value)]);
2505
+ return _nullishCoalesce(_optionalChain([option, 'optionalAccess', _35 => _35.label]), () => ( String(value)));
2406
2506
  }
2407
2507
  function formatMultiselect(value, attribute) {
2408
2508
  if (!Array.isArray(value)) return String(value);
2409
2509
  if (attribute.options) {
2410
- const labels = value.map((v) => _optionalChain([attribute, 'access', _26 => _26.options, 'access', _27 => _27.find, 'call', _28 => _28((o) => o.value === v), 'optionalAccess', _29 => _29.label])).filter(Boolean);
2510
+ const labels = value.map((v) => _optionalChain([attribute, 'access', _36 => _36.options, 'access', _37 => _37.find, 'call', _38 => _38((o) => o.value === v), 'optionalAccess', _39 => _39.label])).filter(Boolean);
2411
2511
  return labels.join(", ");
2412
2512
  }
2413
2513
  return value.join(", ");
@@ -2853,7 +2953,7 @@ function createMockUserProfilesRepository(stores) {
2853
2953
  list(options) {
2854
2954
  const tenantId = getTenantId();
2855
2955
  let results = Array.from(stores.userProfiles.values()).filter((p) => p.tenantId === tenantId);
2856
- if (_optionalChain([options, 'optionalAccess', _30 => _30.limit])) {
2956
+ if (_optionalChain([options, 'optionalAccess', _40 => _40.limit])) {
2857
2957
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
2858
2958
  }
2859
2959
  return Promise.resolve(results);
@@ -2896,7 +2996,7 @@ function createMockFilesRepository(stores) {
2896
2996
  return {
2897
2997
  findById(id) {
2898
2998
  const file2 = stores.files.get(id);
2899
- if (_optionalChain([file2, 'optionalAccess', _31 => _31.deletedAt])) return Promise.resolve(null);
2999
+ if (_optionalChain([file2, 'optionalAccess', _41 => _41.deletedAt])) return Promise.resolve(null);
2900
3000
  return Promise.resolve(_nullishCoalesce(file2, () => ( null)));
2901
3001
  },
2902
3002
  create(data) {
@@ -2953,10 +3053,10 @@ function createMockFilesRepository(stores) {
2953
3053
  let results = Array.from(stores.files.values()).filter(
2954
3054
  (f) => f.tenantId === tenantId && !f.deletedAt
2955
3055
  );
2956
- if (_optionalChain([options, 'optionalAccess', _32 => _32.mimeType])) {
3056
+ if (_optionalChain([options, 'optionalAccess', _42 => _42.mimeType])) {
2957
3057
  results = results.filter((f) => f.mimeType === options.mimeType);
2958
3058
  }
2959
- if (_optionalChain([options, 'optionalAccess', _33 => _33.limit])) {
3059
+ if (_optionalChain([options, 'optionalAccess', _43 => _43.limit])) {
2960
3060
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
2961
3061
  }
2962
3062
  return Promise.resolve(results);
@@ -3058,7 +3158,7 @@ function createMockObjectRecordsRepository(stores) {
3058
3158
  (r) => r.tenantId === tenantId && r.objectId === objectId
3059
3159
  );
3060
3160
  const total = results.length;
3061
- if (_optionalChain([options, 'optionalAccess', _34 => _34.limit])) {
3161
+ if (_optionalChain([options, 'optionalAccess', _44 => _44.limit])) {
3062
3162
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
3063
3163
  }
3064
3164
  const records = results.map(({ tenantId: _t, ...r }) => r);
@@ -3074,7 +3174,7 @@ function createMockObjectRecordsRepository(stores) {
3074
3174
  );
3075
3175
  });
3076
3176
  const total = results.length;
3077
- if (_optionalChain([options, 'optionalAccess', _35 => _35.limit])) {
3177
+ if (_optionalChain([options, 'optionalAccess', _45 => _45.limit])) {
3078
3178
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
3079
3179
  }
3080
3180
  const records = results.map(({ tenantId: _t, ...r }) => r);
@@ -3090,7 +3190,7 @@ function createMockObjectRecordsRepository(stores) {
3090
3190
  }
3091
3191
  }
3092
3192
  const allowedObjectIds = /* @__PURE__ */ new Set();
3093
- if (_optionalChain([options, 'optionalAccess', _36 => _36.objectNames]) && options.objectNames.length > 0) {
3193
+ if (_optionalChain([options, 'optionalAccess', _46 => _46.objectNames]) && options.objectNames.length > 0) {
3094
3194
  for (const obj of objectsMap.values()) {
3095
3195
  if (options.objectNames.includes(obj.name)) {
3096
3196
  allowedObjectIds.add(obj.id);
@@ -3109,7 +3209,7 @@ function createMockObjectRecordsRepository(stores) {
3109
3209
  );
3110
3210
  });
3111
3211
  const total = matchingRecords.length;
3112
- if (_optionalChain([options, 'optionalAccess', _37 => _37.limit])) {
3212
+ if (_optionalChain([options, 'optionalAccess', _47 => _47.limit])) {
3113
3213
  matchingRecords = matchingRecords.slice(
3114
3214
  _nullishCoalesce(options.offset, () => ( 0)),
3115
3215
  (_nullishCoalesce(options.offset, () => ( 0))) + options.limit
@@ -3120,11 +3220,11 @@ function createMockObjectRecordsRepository(stores) {
3120
3220
  if (!attributesByObjectId.has(attr.objectId)) {
3121
3221
  attributesByObjectId.set(attr.objectId, []);
3122
3222
  }
3123
- _optionalChain([attributesByObjectId, 'access', _38 => _38.get, 'call', _39 => _39(attr.objectId), 'optionalAccess', _40 => _40.push, 'call', _41 => _41(attr)]);
3223
+ _optionalChain([attributesByObjectId, 'access', _48 => _48.get, 'call', _49 => _49(attr.objectId), 'optionalAccess', _50 => _50.push, 'call', _51 => _51(attr)]);
3124
3224
  }
3125
3225
  const results = matchingRecords.map((r) => {
3126
3226
  const obj = objectsMap.get(r.objectId);
3127
- const labelExpression = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _42 => _42.labelExpression]), () => ( "{{ name }}"));
3227
+ const labelExpression = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _52 => _52.labelExpression]), () => ( "{{ name }}"));
3128
3228
  const dbAttrs = _nullishCoalesce(attributesByObjectId.get(r.objectId), () => ( []));
3129
3229
  const attrs = dbAttrs.map((a) => ({
3130
3230
  ...a.config,
@@ -3137,8 +3237,8 @@ function createMockObjectRecordsRepository(stores) {
3137
3237
  const enrichedValues = enrichValuesForDisplay(r.values, attrs);
3138
3238
  return {
3139
3239
  objectId: r.objectId,
3140
- objectName: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _43 => _43.name]), () => ( "unknown")),
3141
- objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _44 => _44.label]), () => ( "Unknown")),
3240
+ objectName: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _53 => _53.name]), () => ( "unknown")),
3241
+ objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _54 => _54.label]), () => ( "Unknown")),
3142
3242
  label: renderLabelExpression(labelExpression, enrichedValues),
3143
3243
  recordId: r.id,
3144
3244
  values: r.values,
@@ -3403,7 +3503,7 @@ function createMockPermissionsRepository(stores) {
3403
3503
  },
3404
3504
  deleteRole(roleId) {
3405
3505
  const role = stores.roles.get(roleId);
3406
- if (_optionalChain([role, 'optionalAccess', _45 => _45.system])) {
3506
+ if (_optionalChain([role, 'optionalAccess', _55 => _55.system])) {
3407
3507
  return Promise.reject(new Error(`Cannot delete system role ${roleId}`));
3408
3508
  }
3409
3509
  stores.roles.delete(roleId);
@@ -3645,7 +3745,7 @@ function createMockWorkflowInstancesRepository(stores) {
3645
3745
  (i) => i.tenant_id === tenantId
3646
3746
  );
3647
3747
  const total = results.length;
3648
- if (_optionalChain([options, 'optionalAccess', _46 => _46.limit])) {
3748
+ if (_optionalChain([options, 'optionalAccess', _56 => _56.limit])) {
3649
3749
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
3650
3750
  }
3651
3751
  return Promise.resolve({ instances: results, total });
@@ -3673,7 +3773,7 @@ function createMockWorkflowInstancesRepository(stores) {
3673
3773
  pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
3674
3774
  error: null,
3675
3775
  started_by: data.startedBy,
3676
- expires_at: _nullishCoalesce(_optionalChain([data, 'access', _47 => _47.expiresAt, 'optionalAccess', _48 => _48.toISOString, 'call', _49 => _49()]), () => ( null)),
3776
+ expires_at: _nullishCoalesce(_optionalChain([data, 'access', _57 => _57.expiresAt, 'optionalAccess', _58 => _58.toISOString, 'call', _59 => _59()]), () => ( null)),
3677
3777
  created_at: now,
3678
3778
  updated_at: now,
3679
3779
  completed_at: null
@@ -3694,8 +3794,8 @@ function createMockWorkflowInstancesRepository(stores) {
3694
3794
  history: _nullishCoalesce(data.history, () => ( existing.history)),
3695
3795
  pending_action: data.pendingAction !== void 0 ? data.pendingAction : existing.pending_action,
3696
3796
  error: data.error !== void 0 ? data.error : existing.error,
3697
- expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _50 => _50.expiresAt, 'optionalAccess', _51 => _51.toISOString, 'call', _52 => _52()]), () => ( null)) : existing.expires_at,
3698
- completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _53 => _53.completedAt, 'optionalAccess', _54 => _54.toISOString, 'call', _55 => _55()]), () => ( null)) : existing.completed_at,
3797
+ expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _60 => _60.expiresAt, 'optionalAccess', _61 => _61.toISOString, 'call', _62 => _62()]), () => ( null)) : existing.expires_at,
3798
+ completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _63 => _63.completedAt, 'optionalAccess', _64 => _64.toISOString, 'call', _65 => _65()]), () => ( null)) : existing.completed_at,
3699
3799
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3700
3800
  };
3701
3801
  stores.workflowInstances.set(id, updated);
@@ -3728,7 +3828,7 @@ function createMockWorkflowInstancesRepository(stores) {
3728
3828
  pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
3729
3829
  error: null,
3730
3830
  started_by: data.startedBy,
3731
- expires_at: _nullishCoalesce(_optionalChain([data, 'access', _56 => _56.expiresAt, 'optionalAccess', _57 => _57.toISOString, 'call', _58 => _58()]), () => ( null)),
3831
+ expires_at: _nullishCoalesce(_optionalChain([data, 'access', _66 => _66.expiresAt, 'optionalAccess', _67 => _67.toISOString, 'call', _68 => _68()]), () => ( null)),
3732
3832
  created_at: now,
3733
3833
  updated_at: now,
3734
3834
  completed_at: null
@@ -3751,13 +3851,13 @@ function createMockWorkflowInstancesRepository(stores) {
3751
3851
  return slotData.id === recordId;
3752
3852
  });
3753
3853
  });
3754
- if (_optionalChain([options, 'optionalAccess', _59 => _59.status])) {
3854
+ if (_optionalChain([options, 'optionalAccess', _69 => _69.status])) {
3755
3855
  results = results.filter((i) => i.status === options.status);
3756
3856
  }
3757
3857
  const total = results.length;
3758
- if (_optionalChain([options, 'optionalAccess', _60 => _60.offset]) !== void 0 || _optionalChain([options, 'optionalAccess', _61 => _61.limit]) !== void 0) {
3759
- const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _62 => _62.offset]), () => ( 0));
3760
- const end = _optionalChain([options, 'optionalAccess', _63 => _63.limit]) ? start + options.limit : void 0;
3858
+ if (_optionalChain([options, 'optionalAccess', _70 => _70.offset]) !== void 0 || _optionalChain([options, 'optionalAccess', _71 => _71.limit]) !== void 0) {
3859
+ const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _72 => _72.offset]), () => ( 0));
3860
+ const end = _optionalChain([options, 'optionalAccess', _73 => _73.limit]) ? start + options.limit : void 0;
3761
3861
  results = results.slice(start, end);
3762
3862
  }
3763
3863
  return Promise.resolve({ instances: results, total });
@@ -3820,8 +3920,8 @@ function createMockWorkflowParticipationsRepository(stores) {
3820
3920
  ...existing,
3821
3921
  status: _nullishCoalesce(data.status, () => ( existing.status)),
3822
3922
  auth: _nullishCoalesce(data.auth, () => ( existing.auth)),
3823
- authenticated_at: data.authenticatedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _64 => _64.authenticatedAt, 'optionalAccess', _65 => _65.toISOString, 'call', _66 => _66()]), () => ( null)) : existing.authenticated_at,
3824
- last_activity_at: data.lastActivityAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _67 => _67.lastActivityAt, 'optionalAccess', _68 => _68.toISOString, 'call', _69 => _69()]), () => ( null)) : existing.last_activity_at,
3923
+ authenticated_at: data.authenticatedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _74 => _74.authenticatedAt, 'optionalAccess', _75 => _75.toISOString, 'call', _76 => _76()]), () => ( null)) : existing.authenticated_at,
3924
+ last_activity_at: data.lastActivityAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _77 => _77.lastActivityAt, 'optionalAccess', _78 => _78.toISOString, 'call', _79 => _79()]), () => ( null)) : existing.last_activity_at,
3825
3925
  completed_node_ids: _nullishCoalesce(data.completedNodeIds, () => ( existing.completed_node_ids)),
3826
3926
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3827
3927
  };
@@ -4008,7 +4108,7 @@ var notesPolicy = {
4008
4108
  { attribute: "visibility", operator: "is", value: "shared" },
4009
4109
  { attribute: "createdBy", operator: "is", value: ctx.userId }
4010
4110
  ];
4011
- if (!_optionalChain([options, 'optionalAccess', _70 => _70.filters]) || options.filters.rules.length === 0) {
4111
+ if (!_optionalChain([options, 'optionalAccess', _80 => _80.filters]) || options.filters.rules.length === 0) {
4012
4112
  return {
4013
4113
  ...options,
4014
4114
  filters: { combinator: "or", rules: visibilityRules }
@@ -4122,6 +4222,20 @@ var TenantAwareRepository = class {
4122
4222
  return getUserId();
4123
4223
  }
4124
4224
  };
4225
+ var SchemaContextAwareRepository = class extends TenantAwareRepository {
4226
+ /**
4227
+ * Get an ObjectDefinition from context by its ID.
4228
+ */
4229
+ getSchemaFromContext(objectId) {
4230
+ return getSchemaFromContext(objectId);
4231
+ }
4232
+ /**
4233
+ * Get an ObjectDefinition from context by its name.
4234
+ */
4235
+ getSchemaByNameFromContext(objectName) {
4236
+ return getSchemaByNameFromContext(objectName);
4237
+ }
4238
+ };
4125
4239
 
4126
4240
  // src/runtime/services/audit.service.ts
4127
4241
  var SENSITIVE_PATTERNS = [
@@ -4146,7 +4260,7 @@ var AuditService = class extends TenantAwareService {
4146
4260
  this.isFlushing = false;
4147
4261
  /** Pending flush promise to allow waiting on concurrent flush */
4148
4262
  this.flushPromise = null;
4149
- if (_optionalChain([options, 'optionalAccess', _71 => _71.async]) && options.flushIntervalMs) {
4263
+ if (_optionalChain([options, 'optionalAccess', _81 => _81.async]) && options.flushIntervalMs) {
4150
4264
  this.startFlushTimer();
4151
4265
  }
4152
4266
  }
@@ -4343,7 +4457,7 @@ var AuditService = class extends TenantAwareService {
4343
4457
  if (!this.adapter.audit) {
4344
4458
  return;
4345
4459
  }
4346
- if (_optionalChain([this, 'access', _72 => _72.options, 'optionalAccess', _73 => _73.async])) {
4460
+ if (_optionalChain([this, 'access', _82 => _82.options, 'optionalAccess', _83 => _83.async])) {
4347
4461
  this.buffer.push(entry);
4348
4462
  const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
4349
4463
  if (this.buffer.length >= batchSize) {
@@ -4357,7 +4471,7 @@ var AuditService = class extends TenantAwareService {
4357
4471
  * Start the flush timer for async mode
4358
4472
  */
4359
4473
  startFlushTimer() {
4360
- const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _74 => _74.options, 'optionalAccess', _75 => _75.flushIntervalMs]), () => ( 1e3));
4474
+ const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _84 => _84.options, 'optionalAccess', _85 => _85.flushIntervalMs]), () => ( 1e3));
4361
4475
  this.flushTimer = setInterval(() => {
4362
4476
  this.flush().catch(console.error);
4363
4477
  }, intervalMs);
@@ -4385,7 +4499,7 @@ var FileService = class extends TenantAwareService {
4385
4499
  constructor(adapter, options) {
4386
4500
  super();
4387
4501
  this.adapter = adapter;
4388
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _76 => _76.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
4502
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _86 => _86.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
4389
4503
  }
4390
4504
  // ============================================================================
4391
4505
  // UPLOAD (requires StorageAdapter)
@@ -4517,7 +4631,7 @@ var FileService = class extends TenantAwareService {
4517
4631
  */
4518
4632
  async getFile(fileId) {
4519
4633
  const file2 = await this.adapter.files.findById(fileId);
4520
- if (_optionalChain([file2, 'optionalAccess', _77 => _77.deletedAt])) {
4634
+ if (_optionalChain([file2, 'optionalAccess', _87 => _87.deletedAt])) {
4521
4635
  return null;
4522
4636
  }
4523
4637
  return file2;
@@ -4579,12 +4693,12 @@ var FileService = class extends TenantAwareService {
4579
4693
  */
4580
4694
  async deleteFile(fileId, options) {
4581
4695
  const file2 = await this.getFileOrThrow(fileId);
4582
- if (_optionalChain([options, 'optionalAccess', _78 => _78.checkOwnership]) && options.userId) {
4696
+ if (_optionalChain([options, 'optionalAccess', _88 => _88.checkOwnership]) && options.userId) {
4583
4697
  if (file2.uploadedBy !== options.userId) {
4584
4698
  throw new Error("You can only delete files you uploaded");
4585
4699
  }
4586
4700
  }
4587
- if (_optionalChain([options, 'optionalAccess', _79 => _79.hard])) {
4701
+ if (_optionalChain([options, 'optionalAccess', _89 => _89.hard])) {
4588
4702
  await this.adapter.files.hardDelete(fileId);
4589
4703
  } else {
4590
4704
  await this.adapter.files.delete(fileId);
@@ -4615,7 +4729,7 @@ var FileService = class extends TenantAwareService {
4615
4729
  }
4616
4730
  const file2 = await this.getFileOrThrow(fileId);
4617
4731
  await this.adapter.storage.delete(file2.storagePath);
4618
- if (_optionalChain([options, 'optionalAccess', _80 => _80.hard])) {
4732
+ if (_optionalChain([options, 'optionalAccess', _90 => _90.hard])) {
4619
4733
  await this.adapter.files.hardDelete(fileId);
4620
4734
  } else {
4621
4735
  await this.adapter.files.delete(fileId);
@@ -4642,10 +4756,10 @@ var FileService = class extends TenantAwareService {
4642
4756
  if (!file2) {
4643
4757
  continue;
4644
4758
  }
4645
- if (_optionalChain([options, 'optionalAccess', _81 => _81.deleteFromStorage]) && this.adapter.storage) {
4759
+ if (_optionalChain([options, 'optionalAccess', _91 => _91.deleteFromStorage]) && this.adapter.storage) {
4646
4760
  await this.adapter.storage.delete(file2.storagePath);
4647
4761
  }
4648
- if (_optionalChain([options, 'optionalAccess', _82 => _82.hard])) {
4762
+ if (_optionalChain([options, 'optionalAccess', _92 => _92.hard])) {
4649
4763
  await this.adapter.files.hardDelete(fileId);
4650
4764
  } else {
4651
4765
  await this.adapter.files.delete(fileId);
@@ -4656,7 +4770,7 @@ var FileService = class extends TenantAwareService {
4656
4770
  actorId: this.userId,
4657
4771
  fileId,
4658
4772
  fileName: file2.name,
4659
- metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _83 => _83.deleteFromStorage]), () => ( false)) }
4773
+ metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _93 => _93.deleteFromStorage]), () => ( false)) }
4660
4774
  });
4661
4775
  }
4662
4776
  }
@@ -4740,7 +4854,7 @@ var FileService = class extends TenantAwareService {
4740
4854
  return true;
4741
4855
  }
4742
4856
  if (file2.visibility === "restricted") {
4743
- return _nullishCoalesce(_optionalChain([file2, 'access', _84 => _84.allowedUsers, 'optionalAccess', _85 => _85.includes, 'call', _86 => _86(userId)]), () => ( false));
4857
+ return _nullishCoalesce(_optionalChain([file2, 'access', _94 => _94.allowedUsers, 'optionalAccess', _95 => _95.includes, 'call', _96 => _96(userId)]), () => ( false));
4744
4858
  }
4745
4859
  return false;
4746
4860
  }
@@ -4895,10 +5009,10 @@ var GlobalSearchService = class extends TenantAwareService {
4895
5009
  return { results: [], total: 0 };
4896
5010
  }
4897
5011
  return await this.adapter.objectRecords.globalSearch(query.trim(), {
4898
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _87 => _87.limit]), () => ( 20)),
4899
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _88 => _88.offset]), () => ( 0)),
4900
- objectNames: _optionalChain([options, 'optionalAccess', _89 => _89.objectNames]),
4901
- includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _90 => _90.includeObjectInfo]), () => ( true))
5012
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.limit]), () => ( 20)),
5013
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _98 => _98.offset]), () => ( 0)),
5014
+ objectNames: _optionalChain([options, 'optionalAccess', _99 => _99.objectNames]),
5015
+ includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _100 => _100.includeObjectInfo]), () => ( true))
4902
5016
  });
4903
5017
  }
4904
5018
  /**
@@ -5015,17 +5129,17 @@ function validateOptions(options, attributeName) {
5015
5129
  const ids = /* @__PURE__ */ new Set();
5016
5130
  const values = /* @__PURE__ */ new Set();
5017
5131
  for (const option of options) {
5018
- if (!_optionalChain([option, 'access', _91 => _91.id, 'optionalAccess', _92 => _92.trim, 'call', _93 => _93()])) {
5132
+ if (!_optionalChain([option, 'access', _101 => _101.id, 'optionalAccess', _102 => _102.trim, 'call', _103 => _103()])) {
5019
5133
  throw new Error(
5020
5134
  `[AttributeBuilder] Option in "${attributeName}" has an empty or missing id.`
5021
5135
  );
5022
5136
  }
5023
- if (!_optionalChain([option, 'access', _94 => _94.value, 'optionalAccess', _95 => _95.trim, 'call', _96 => _96()])) {
5137
+ if (!_optionalChain([option, 'access', _104 => _104.value, 'optionalAccess', _105 => _105.trim, 'call', _106 => _106()])) {
5024
5138
  throw new Error(
5025
5139
  `[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing value.`
5026
5140
  );
5027
5141
  }
5028
- if (!_optionalChain([option, 'access', _97 => _97.label, 'optionalAccess', _98 => _98.trim, 'call', _99 => _99()])) {
5142
+ if (!_optionalChain([option, 'access', _107 => _107.label, 'optionalAccess', _108 => _108.trim, 'call', _109 => _109()])) {
5029
5143
  throw new Error(
5030
5144
  `[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing label.`
5031
5145
  );
@@ -5546,7 +5660,7 @@ var SingleRelationAttributeBuilder = class extends BaseAttributeBuilder {
5546
5660
  object: objectName,
5547
5661
  ...options
5548
5662
  };
5549
- _optionalChain([this, 'access', _100 => _100.attr, 'access', _101 => _101.targets, 'optionalAccess', _102 => _102.push, 'call', _103 => _103(target)]);
5663
+ _optionalChain([this, 'access', _110 => _110.attr, 'access', _111 => _111.targets, 'optionalAccess', _112 => _112.push, 'call', _113 => _113(target)]);
5550
5664
  return this;
5551
5665
  }
5552
5666
  /**
@@ -5591,9 +5705,9 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
5591
5705
  constructor(name, label, initOptions) {
5592
5706
  super("relation", name, label);
5593
5707
  this.attr.cardinality = "many";
5594
- this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _104 => _104.targets]), () => ( []));
5708
+ this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _114 => _114.targets]), () => ( []));
5595
5709
  this.attr.defaultValue = [];
5596
- if (_optionalChain([initOptions, 'optionalAccess', _105 => _105.isRequired])) {
5710
+ if (_optionalChain([initOptions, 'optionalAccess', _115 => _115.isRequired])) {
5597
5711
  this.setRequired(true);
5598
5712
  }
5599
5713
  }
@@ -5607,7 +5721,7 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
5607
5721
  object: objectName,
5608
5722
  ...options
5609
5723
  };
5610
- _optionalChain([this, 'access', _106 => _106.attr, 'access', _107 => _107.targets, 'optionalAccess', _108 => _108.push, 'call', _109 => _109(target)]);
5724
+ _optionalChain([this, 'access', _116 => _116.attr, 'access', _117 => _117.targets, 'optionalAccess', _118 => _118.push, 'call', _119 => _119(target)]);
5611
5725
  return this;
5612
5726
  }
5613
5727
  /**
@@ -5981,7 +6095,7 @@ var GroupBuilder = class {
5981
6095
  */
5982
6096
  fields(...names) {
5983
6097
  for (const name of names) {
5984
- _optionalChain([this, 'access', _110 => _110.data, 'access', _111 => _111.fields, 'optionalAccess', _112 => _112.push, 'call', _113 => _113({ attribute: name })]);
6098
+ _optionalChain([this, 'access', _120 => _120.data, 'access', _121 => _121.fields, 'optionalAccess', _122 => _122.push, 'call', _123 => _123({ attribute: name })]);
5985
6099
  }
5986
6100
  return this;
5987
6101
  }
@@ -5990,7 +6104,7 @@ var GroupBuilder = class {
5990
6104
  * @example .field("name", { span: 8, readOnly: true })
5991
6105
  */
5992
6106
  field(attribute, options) {
5993
- _optionalChain([this, 'access', _114 => _114.data, 'access', _115 => _115.fields, 'optionalAccess', _116 => _116.push, 'call', _117 => _117({ attribute, ...options })]);
6107
+ _optionalChain([this, 'access', _124 => _124.data, 'access', _125 => _125.fields, 'optionalAccess', _126 => _126.push, 'call', _127 => _127({ attribute, ...options })]);
5994
6108
  return this;
5995
6109
  }
5996
6110
  /**
@@ -5999,7 +6113,7 @@ var GroupBuilder = class {
5999
6113
  * @example .attributeGroup({ id: "address", label: "Address", attributes: ["street", "city", "postal_code"], displayTemplate: "{street}, {city}" })
6000
6114
  */
6001
6115
  attributeGroup(config, options) {
6002
- _optionalChain([this, 'access', _118 => _118.data, 'access', _119 => _119.fields, 'optionalAccess', _120 => _120.push, 'call', _121 => _121({ attributeGroup: config, ...options })]);
6116
+ _optionalChain([this, 'access', _128 => _128.data, 'access', _129 => _129.fields, 'optionalAccess', _130 => _130.push, 'call', _131 => _131({ attributeGroup: config, ...options })]);
6003
6117
  return this;
6004
6118
  }
6005
6119
  /**
@@ -6491,14 +6605,14 @@ var ViewBuilder = class {
6491
6605
  * Add a pre-built tab
6492
6606
  */
6493
6607
  addTab(tab) {
6494
- _optionalChain([this, 'access', _122 => _122.data, 'access', _123 => _123.tabs, 'optionalAccess', _124 => _124.push, 'call', _125 => _125(tab)]);
6608
+ _optionalChain([this, 'access', _132 => _132.data, 'access', _133 => _133.tabs, 'optionalAccess', _134 => _134.push, 'call', _135 => _135(tab)]);
6495
6609
  return this;
6496
6610
  }
6497
6611
  /**
6498
6612
  * @internal Used by TabBuilder to add tabs
6499
6613
  */
6500
6614
  _addTab(tab) {
6501
- _optionalChain([this, 'access', _126 => _126.data, 'access', _127 => _127.tabs, 'optionalAccess', _128 => _128.push, 'call', _129 => _129(tab)]);
6615
+ _optionalChain([this, 'access', _136 => _136.data, 'access', _137 => _137.tabs, 'optionalAccess', _138 => _138.push, 'call', _139 => _139(tab)]);
6502
6616
  return this;
6503
6617
  }
6504
6618
  /**
@@ -6576,8 +6690,8 @@ var WorkflowFormRowBuilder = class {
6576
6690
  id: `${this.rowData.id}-${slotId}-${attribute}`,
6577
6691
  slotId,
6578
6692
  attribute,
6579
- label: _optionalChain([options, 'optionalAccess', _130 => _130.label]),
6580
- required: _optionalChain([options, 'optionalAccess', _131 => _131.required])
6693
+ label: _optionalChain([options, 'optionalAccess', _140 => _140.label]),
6694
+ required: _optionalChain([options, 'optionalAccess', _141 => _141.required])
6581
6695
  };
6582
6696
  this.rowData.fields.push(field);
6583
6697
  return this;
@@ -6942,7 +7056,7 @@ var WorkflowBuilder = class {
6942
7056
  * @param options - Slot configuration
6943
7057
  */
6944
7058
  slot(id, objectName, options) {
6945
- if (_optionalChain([this, 'access', _132 => _132.data, 'access', _133 => _133.slots, 'optionalAccess', _134 => _134.some, 'call', _135 => _135((s) => s.id === id)])) {
7059
+ if (_optionalChain([this, 'access', _142 => _142.data, 'access', _143 => _143.slots, 'optionalAccess', _144 => _144.some, 'call', _145 => _145((s) => s.id === id)])) {
6946
7060
  throw new Error(`[WorkflowBuilder] Duplicate slot id: "${id}"`);
6947
7061
  }
6948
7062
  const slot = {
@@ -6953,7 +7067,7 @@ var WorkflowBuilder = class {
6953
7067
  color: options.color,
6954
7068
  icon: options.icon
6955
7069
  };
6956
- _optionalChain([this, 'access', _136 => _136.data, 'access', _137 => _137.slots, 'optionalAccess', _138 => _138.push, 'call', _139 => _139(slot)]);
7070
+ _optionalChain([this, 'access', _146 => _146.data, 'access', _147 => _147.slots, 'optionalAccess', _148 => _148.push, 'call', _149 => _149(slot)]);
6957
7071
  return this;
6958
7072
  }
6959
7073
  // ============================================================================
@@ -6967,7 +7081,7 @@ var WorkflowBuilder = class {
6967
7081
  }
6968
7082
  /** @internal */
6969
7083
  _addParticipant(template) {
6970
- _optionalChain([this, 'access', _140 => _140.data, 'access', _141 => _141.participants, 'optionalAccess', _142 => _142.push, 'call', _143 => _143(template)]);
7084
+ _optionalChain([this, 'access', _150 => _150.data, 'access', _151 => _151.participants, 'optionalAccess', _152 => _152.push, 'call', _153 => _153(template)]);
6971
7085
  return this;
6972
7086
  }
6973
7087
  // ============================================================================
@@ -7100,7 +7214,7 @@ var WorkflowBuilder = class {
7100
7214
  }
7101
7215
  }
7102
7216
  validateSlotReferences() {
7103
- const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _144 => _144.data, 'access', _145 => _145.slots, 'optionalAccess', _146 => _146.map, 'call', _147 => _147((s) => s.id)]), () => ( [])));
7217
+ const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _154 => _154.data, 'access', _155 => _155.slots, 'optionalAccess', _156 => _156.map, 'call', _157 => _157((s) => s.id)]), () => ( [])));
7104
7218
  for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
7105
7219
  if (node.type === "form") {
7106
7220
  const referencedSlots = /* @__PURE__ */ new Set();
@@ -7127,7 +7241,7 @@ var WorkflowBuilder = class {
7127
7241
  }
7128
7242
  }
7129
7243
  validateParticipantReferences() {
7130
- const participantIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _148 => _148.data, 'access', _149 => _149.participants, 'optionalAccess', _150 => _150.map, 'call', _151 => _151((p) => p.id)]), () => ( [])));
7244
+ const participantIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _158 => _158.data, 'access', _159 => _159.participants, 'optionalAccess', _160 => _160.map, 'call', _161 => _161((p) => p.id)]), () => ( [])));
7131
7245
  for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
7132
7246
  if (node.type === "form" && node.participantId) {
7133
7247
  if (!participantIds.has(node.participantId)) {
@@ -7773,7 +7887,7 @@ function validateObject(objectDef, data) {
7773
7887
  function validateObjectOrThrow(objectDef, data) {
7774
7888
  const result = validateObject(objectDef, data);
7775
7889
  if (!result.success) {
7776
- const errorMessages = _optionalChain([result, 'access', _152 => _152.errors, 'optionalAccess', _153 => _153.map, 'call', _154 => _154((err) => `${err.path.join(".")}: ${err.message}`), 'access', _155 => _155.join, 'call', _156 => _156("\n")]) || "Unknown validation error";
7890
+ const errorMessages = _optionalChain([result, 'access', _162 => _162.errors, 'optionalAccess', _163 => _163.map, 'call', _164 => _164((err) => `${err.path.join(".")}: ${err.message}`), 'access', _165 => _165.join, 'call', _166 => _166("\n")]) || "Unknown validation error";
7777
7891
  throw new Error(`Validation failed for ${objectDef.label}:
7778
7892
  ${errorMessages}`);
7779
7893
  }
@@ -7807,7 +7921,7 @@ function validateDraft(objectDef, data) {
7807
7921
  function validateDraftOrThrow(objectDef, data) {
7808
7922
  const result = validateDraft(objectDef, data);
7809
7923
  if (!result.success) {
7810
- const errorMessages = _optionalChain([result, 'access', _157 => _157.errors, 'optionalAccess', _158 => _158.map, 'call', _159 => _159((err) => `${err.path.join(".")}: ${err.message}`), 'access', _160 => _160.join, 'call', _161 => _161("\n")]) || "Unknown validation error";
7924
+ const errorMessages = _optionalChain([result, 'access', _167 => _167.errors, 'optionalAccess', _168 => _168.map, 'call', _169 => _169((err) => `${err.path.join(".")}: ${err.message}`), 'access', _170 => _170.join, 'call', _171 => _171("\n")]) || "Unknown validation error";
7811
7925
  throw new Error(`Draft validation failed for ${objectDef.label}:
7812
7926
  ${errorMessages}`);
7813
7927
  }
@@ -7849,8 +7963,8 @@ var ObjectSchemaService = class extends TenantAwareService {
7849
7963
  super();
7850
7964
  this.adapter = adapter;
7851
7965
  this.nativeRegistry = nativeRegistry;
7852
- this.auditService = _optionalChain([options, 'optionalAccess', _162 => _162.auditService]);
7853
- this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _163 => _163.cache]), () => ( adapter.cache));
7966
+ this.auditService = _optionalChain([options, 'optionalAccess', _172 => _172.auditService]);
7967
+ this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _173 => _173.cache]), () => ( adapter.cache));
7854
7968
  }
7855
7969
  /**
7856
7970
  * Create a new custom object.
@@ -8048,7 +8162,7 @@ var ObjectSchemaService = class extends TenantAwareService {
8048
8162
  resourceType: "attribute",
8049
8163
  resourceId: attributeId,
8050
8164
  resourceLabel: updatedDbAttr.label,
8051
- objectName: _optionalChain([dbObject, 'optionalAccess', _164 => _164.name]),
8165
+ objectName: _optionalChain([dbObject, 'optionalAccess', _174 => _174.name]),
8052
8166
  objectId: dbAttr.objectId,
8053
8167
  changes
8054
8168
  });
@@ -8081,7 +8195,7 @@ var ObjectSchemaService = class extends TenantAwareService {
8081
8195
  );
8082
8196
  }
8083
8197
  const dbObject = await this.adapter.objects.findById(dbAttr.objectId);
8084
- if (_optionalChain([dbObject, 'optionalAccess', _165 => _165.labelExpression])) {
8198
+ if (_optionalChain([dbObject, 'optionalAccess', _175 => _175.labelExpression])) {
8085
8199
  const usedAttributes = extractAttributeNames(dbObject.labelExpression);
8086
8200
  if (usedAttributes.includes(dbAttr.name)) {
8087
8201
  throw new AttributeInUseError(dbAttr.name, "labelExpression");
@@ -8097,7 +8211,7 @@ var ObjectSchemaService = class extends TenantAwareService {
8097
8211
  resourceType: "attribute",
8098
8212
  resourceId: attributeId,
8099
8213
  resourceLabel: dbAttr.label,
8100
- objectName: _optionalChain([dbObject, 'optionalAccess', _166 => _166.name]),
8214
+ objectName: _optionalChain([dbObject, 'optionalAccess', _176 => _176.name]),
8101
8215
  objectId: dbAttr.objectId
8102
8216
  });
8103
8217
  }
@@ -8112,9 +8226,9 @@ var ObjectSchemaService = class extends TenantAwareService {
8112
8226
  async listAttributes(objectId, options) {
8113
8227
  const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
8114
8228
  let filtered = dbAttributes;
8115
- if (_optionalChain([options, 'optionalAccess', _167 => _167.systemOnly])) {
8229
+ if (_optionalChain([options, 'optionalAccess', _177 => _177.systemOnly])) {
8116
8230
  filtered = dbAttributes.filter((attr) => attr.system);
8117
- } else if (_optionalChain([options, 'optionalAccess', _168 => _168.customOnly])) {
8231
+ } else if (_optionalChain([options, 'optionalAccess', _178 => _178.customOnly])) {
8118
8232
  filtered = dbAttributes.filter((attr) => !attr.system);
8119
8233
  }
8120
8234
  return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
@@ -8150,14 +8264,14 @@ var ObjectSchemaService = class extends TenantAwareService {
8150
8264
  pluralLabel: dbObject.pluralLabel,
8151
8265
  description: dbObject.description,
8152
8266
  labelExpression: dbObject.labelExpression,
8153
- icon: _optionalChain([dbObject, 'access', _169 => _169.metadata, 'optionalAccess', _170 => _170.icon])
8267
+ icon: _optionalChain([dbObject, 'access', _179 => _179.metadata, 'optionalAccess', _180 => _180.icon])
8154
8268
  };
8155
8269
  let metadata = dbObject.metadata;
8156
8270
  if (updates.icon !== void 0 || updates.metadata !== void 0) {
8157
8271
  metadata = {
8158
8272
  ...dbObject.metadata,
8159
8273
  ...updates.metadata,
8160
- icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _171 => _171.metadata, 'optionalAccess', _172 => _172.icon])))
8274
+ icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _181 => _181.metadata, 'optionalAccess', _182 => _182.icon])))
8161
8275
  };
8162
8276
  }
8163
8277
  const updatedDbObject = await this.adapter.objects.update(objectId, {
@@ -8447,7 +8561,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
8447
8561
  label: dbObject.label,
8448
8562
  pluralLabel: dbObject.pluralLabel,
8449
8563
  description: dbObject.description,
8450
- icon: _optionalChain([dbObject, 'access', _173 => _173.metadata, 'optionalAccess', _174 => _174.icon]),
8564
+ icon: _optionalChain([dbObject, 'access', _183 => _183.metadata, 'optionalAccess', _184 => _184.icon]),
8451
8565
  labelExpression: dbObject.labelExpression,
8452
8566
  attributes,
8453
8567
  system: dbObject.system,
@@ -8547,7 +8661,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
8547
8661
  const hasRelationToTarget = attrs.some((attr) => {
8548
8662
  if (attr.type !== "relation") return false;
8549
8663
  const config = attr.config;
8550
- return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _175 => _175.targets, 'optionalAccess', _176 => _176.some, 'call', _177 => _177((t) => t.object === targetObjectName)]), () => ( false));
8664
+ return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _185 => _185.targets, 'optionalAccess', _186 => _186.some, 'call', _187 => _187((t) => t.object === targetObjectName)]), () => ( false));
8551
8665
  });
8552
8666
  if (hasRelationToTarget) {
8553
8667
  referencing.push(obj.name);
@@ -8697,7 +8811,7 @@ var SyncError = class extends SchemaError {
8697
8811
  constructor(objectName, message, cause) {
8698
8812
  super(`Failed to sync object "${objectName}": ${message}`, SchemaErrorCode.SYNC_FAILED, {
8699
8813
  objectName,
8700
- cause: _optionalChain([cause, 'optionalAccess', _178 => _178.message])
8814
+ cause: _optionalChain([cause, 'optionalAccess', _188 => _188.message])
8701
8815
  });
8702
8816
  this.name = "SyncError";
8703
8817
  this.objectName = objectName;
@@ -8785,8 +8899,8 @@ var PermissionService = class extends TenantAwareService {
8785
8899
  );
8786
8900
  }
8787
8901
  this.permissionsRepo = adapter.permissions;
8788
- this.cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _179 => _179.cache]), () => ( adapter.cache)), () => ( new NoopCacheAdapter()));
8789
- this.auditService = _optionalChain([options, 'optionalAccess', _180 => _180.auditService]);
8902
+ this.cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _189 => _189.cache]), () => ( adapter.cache)), () => ( new NoopCacheAdapter()));
8903
+ this.auditService = _optionalChain([options, 'optionalAccess', _190 => _190.auditService]);
8790
8904
  }
8791
8905
  // ============================================================================
8792
8906
  // PERMISSION CHECKS
@@ -8805,11 +8919,11 @@ var PermissionService = class extends TenantAwareService {
8805
8919
  return true;
8806
8920
  }
8807
8921
  const wildcardPerms = permissions.objectPermissions["*"];
8808
- if (_optionalChain([wildcardPerms, 'optionalAccess', _181 => _181.includes, 'call', _182 => _182(action)])) {
8922
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _191 => _191.includes, 'call', _192 => _192(action)])) {
8809
8923
  return true;
8810
8924
  }
8811
8925
  const objectPerms = permissions.objectPermissions[objectName];
8812
- return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _183 => _183.includes, 'call', _184 => _184(action)]), () => ( false));
8926
+ return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _193 => _193.includes, 'call', _194 => _194(action)]), () => ( false));
8813
8927
  }
8814
8928
  /**
8815
8929
  * Check if user can access an object, throw ForbiddenError if not.
@@ -8864,12 +8978,12 @@ var PermissionService = class extends TenantAwareService {
8864
8978
  if (permissions.isAdmin) {
8865
8979
  return true;
8866
8980
  }
8867
- const wildcardPerms = _optionalChain([permissions, 'access', _185 => _185.systemPermissions, 'optionalAccess', _186 => _186["*"]]);
8868
- if (_optionalChain([wildcardPerms, 'optionalAccess', _187 => _187.includes, 'call', _188 => _188(action)])) {
8981
+ const wildcardPerms = _optionalChain([permissions, 'access', _195 => _195.systemPermissions, 'optionalAccess', _196 => _196["*"]]);
8982
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _197 => _197.includes, 'call', _198 => _198(action)])) {
8869
8983
  return true;
8870
8984
  }
8871
- const resourcePerms = _optionalChain([permissions, 'access', _189 => _189.systemPermissions, 'optionalAccess', _190 => _190[resource]]);
8872
- return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _191 => _191.includes, 'call', _192 => _192(action)]), () => ( false));
8985
+ const resourcePerms = _optionalChain([permissions, 'access', _199 => _199.systemPermissions, 'optionalAccess', _200 => _200[resource]]);
8986
+ return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _201 => _201.includes, 'call', _202 => _202(action)]), () => ( false));
8873
8987
  }
8874
8988
  /**
8875
8989
  * Check if user can access a system resource, throw ForbiddenError if not.
@@ -8898,8 +9012,8 @@ var PermissionService = class extends TenantAwareService {
8898
9012
  if (permissions.isAdmin) {
8899
9013
  return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
8900
9014
  }
8901
- const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _193 => _193.systemPermissions, 'optionalAccess', _194 => _194["*"]]), () => ( []));
8902
- const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _195 => _195.systemPermissions, 'optionalAccess', _196 => _196[resource]]), () => ( []));
9015
+ const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _203 => _203.systemPermissions, 'optionalAccess', _204 => _204["*"]]), () => ( []));
9016
+ const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _205 => _205.systemPermissions, 'optionalAccess', _206 => _206[resource]]), () => ( []));
8903
9017
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
8904
9018
  return {
8905
9019
  canRead: allPerms.has("read"),
@@ -9041,7 +9155,7 @@ var PermissionService = class extends TenantAwareService {
9041
9155
  action: "role.updated",
9042
9156
  actorId: this.userId,
9043
9157
  roleId,
9044
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _197 => _197.label]), () => ( roleId)),
9158
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _207 => _207.label]), () => ( roleId)),
9045
9159
  metadata: { permissionsUpdated: true, permissionCount: permissions.length }
9046
9160
  });
9047
9161
  }
@@ -9071,7 +9185,7 @@ var PermissionService = class extends TenantAwareService {
9071
9185
  action: "role.assigned",
9072
9186
  actorId: this.userId,
9073
9187
  roleId,
9074
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _198 => _198.label]), () => ( roleId)),
9188
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _208 => _208.label]), () => ( roleId)),
9075
9189
  targetUserId: userProfileId
9076
9190
  });
9077
9191
  }
@@ -9089,7 +9203,7 @@ var PermissionService = class extends TenantAwareService {
9089
9203
  action: "role.revoked",
9090
9204
  actorId: this.userId,
9091
9205
  roleId,
9092
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _199 => _199.label]), () => ( roleId)),
9206
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _209 => _209.label]), () => ( roleId)),
9093
9207
  targetUserId: userProfileId
9094
9208
  });
9095
9209
  }
@@ -9206,7 +9320,7 @@ Native objects must have system=true. Did you forget to call .system() in your b
9206
9320
  const existing = this.objects.get(object2.name);
9207
9321
  throw new Error(
9208
9322
  `[NativeObjectRegistry] Duplicate object name "${object2.name}":
9209
- - Existing: "${_optionalChain([existing, 'optionalAccess', _200 => _200.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _201 => _201.id])})
9323
+ - Existing: "${_optionalChain([existing, 'optionalAccess', _210 => _210.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _211 => _211.id])})
9210
9324
  - New: "${object2.label}" (id: ${object2.id})
9211
9325
  Please use unique names for each native object.`
9212
9326
  );
@@ -9306,7 +9420,7 @@ var RelationService = class extends TenantAwareService {
9306
9420
  constructor(adapter, nativeRegistry, options) {
9307
9421
  super();
9308
9422
  this.adapter = adapter;
9309
- this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _202 => _202.cache]), () => ( adapter.cache));
9423
+ this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _212 => _212.cache]), () => ( adapter.cache));
9310
9424
  this.schemaService = new ObjectSchemaService(adapter, nativeRegistry, { cache: this.cache });
9311
9425
  }
9312
9426
  /**
@@ -9349,6 +9463,8 @@ var RelationService = class extends TenantAwareService {
9349
9463
  }
9350
9464
  /**
9351
9465
  * Validate a single relation attribute value
9466
+ *
9467
+ * Uses batch fetching (findByIds) to avoid N+1 query pattern.
9352
9468
  */
9353
9469
  async validateRelationAttribute(attr, value) {
9354
9470
  const errors = [];
@@ -9358,16 +9474,18 @@ var RelationService = class extends TenantAwareService {
9358
9474
  }
9359
9475
  const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
9360
9476
  const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
9361
- if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _203 => _203.size]) === 0) {
9477
+ if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _213 => _213.size]) === 0) {
9362
9478
  errors.push({
9363
9479
  attribute: attr.name,
9364
9480
  message: `No valid target objects found for ${attr.label}`
9365
9481
  });
9366
9482
  return errors;
9367
9483
  }
9484
+ const records = await this.adapter.objectRecords.findByIds(ids);
9485
+ const recordMap = new Map(records.map((r) => [r.id, r]));
9368
9486
  const invalidIds = [];
9369
9487
  for (const id of ids) {
9370
- const record = await this.adapter.objectRecords.findById(id);
9488
+ const record = recordMap.get(id);
9371
9489
  if (!record) {
9372
9490
  invalidIds.push(id);
9373
9491
  continue;
@@ -9409,10 +9527,10 @@ var RelationService = class extends TenantAwareService {
9409
9527
  for (const target of targets) {
9410
9528
  try {
9411
9529
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
9412
- if (_optionalChain([objectSchema, 'optionalAccess', _204 => _204.id])) {
9530
+ if (_optionalChain([objectSchema, 'optionalAccess', _214 => _214.id])) {
9413
9531
  objectIds.add(objectSchema.id);
9414
9532
  }
9415
- } catch (e9) {
9533
+ } catch (e11) {
9416
9534
  }
9417
9535
  }
9418
9536
  return objectIds;
@@ -9462,7 +9580,7 @@ var RelationService = class extends TenantAwareService {
9462
9580
  const recordService = new RecordService(this.adapter);
9463
9581
  for (const target of filteredTargets) {
9464
9582
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
9465
- if (!_optionalChain([objectSchema, 'optionalAccess', _205 => _205.id])) {
9583
+ if (!_optionalChain([objectSchema, 'optionalAccess', _215 => _215.id])) {
9466
9584
  continue;
9467
9585
  }
9468
9586
  const queryOptions = {
@@ -9541,8 +9659,8 @@ var RelationService = class extends TenantAwareService {
9541
9659
  if (!objectSchema) {
9542
9660
  continue;
9543
9661
  }
9544
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _206 => _206.targets, 'optionalAccess', _207 => _207.find, 'call', _208 => _208((t) => t.object === objectSchema.name)]);
9545
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _209 => _209.displayTemplate]);
9662
+ const targetConfig = _optionalChain([attribute, 'optionalAccess', _216 => _216.targets, 'optionalAccess', _217 => _217.find, 'call', _218 => _218((t) => t.object === objectSchema.name)]);
9663
+ const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _219 => _219.displayTemplate]);
9546
9664
  for (const record of objectRecords) {
9547
9665
  let label;
9548
9666
  if (customTemplate) {
@@ -9593,7 +9711,7 @@ var RelationService = class extends TenantAwareService {
9593
9711
  var RollupService = class {
9594
9712
  constructor(adapter, options) {
9595
9713
  this.adapter = adapter;
9596
- this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _210 => _210.cache]), () => ( adapter.cache));
9714
+ this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _220 => _220.cache]), () => ( adapter.cache));
9597
9715
  }
9598
9716
  /**
9599
9717
  * Calculate a rollup value for a record
@@ -9681,22 +9799,37 @@ var RollupService = class {
9681
9799
  return { value: null, recordCount: 0 };
9682
9800
  }
9683
9801
  const sourceObjectName = rollupAttr.relationAttribute;
9684
- const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
9685
- if (!sourceObject) {
9686
- return { value: null, recordCount: 0 };
9802
+ const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
9803
+ let sourceObjectId;
9804
+ let reverseRelationAttrName;
9805
+ if (_optionalChain([sourceSchema, 'optionalAccess', _221 => _221.id])) {
9806
+ sourceObjectId = sourceSchema.id;
9807
+ const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
9808
+ if (attr.type !== "relation") return false;
9809
+ const relationConfig = attr;
9810
+ return _optionalChain([relationConfig, 'optionalAccess', _222 => _222.targets, 'optionalAccess', _223 => _223.some, 'call', _224 => _224((t) => t.object === schema.name)]);
9811
+ });
9812
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _225 => _225.name]);
9813
+ } else {
9814
+ const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
9815
+ if (!sourceObject) {
9816
+ return { value: null, recordCount: 0 };
9817
+ }
9818
+ sourceObjectId = sourceObject.id;
9819
+ const sourceAttributes = await this.adapter.attributes.findByObjectId(sourceObject.id);
9820
+ const reverseRelationAttr = sourceAttributes.find((attr) => {
9821
+ if (attr.type !== "relation") return false;
9822
+ const relationConfig = attr.config;
9823
+ return _optionalChain([relationConfig, 'optionalAccess', _226 => _226.targets, 'optionalAccess', _227 => _227.some, 'call', _228 => _228((t) => t.object === schema.name)]);
9824
+ });
9825
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _229 => _229.name]);
9687
9826
  }
9688
- const sourceAttributes = await this.adapter.attributes.findByObjectId(sourceObject.id);
9689
- const reverseRelationAttr = sourceAttributes.find((attr) => {
9690
- if (attr.type !== "relation") return false;
9691
- const relationConfig = attr.config;
9692
- return _optionalChain([relationConfig, 'optionalAccess', _211 => _211.targets, 'optionalAccess', _212 => _212.some, 'call', _213 => _213((t) => t.object === schema.name)]);
9693
- });
9694
- if (!reverseRelationAttr) {
9827
+ if (!reverseRelationAttrName) {
9695
9828
  return { value: null, recordCount: 0 };
9696
9829
  }
9697
9830
  const relatedRecords = await this.adapter.objectRecords.findByRelation(
9698
- sourceObject.id,
9699
- reverseRelationAttr.name,
9831
+ sourceObjectId,
9832
+ reverseRelationAttrName,
9700
9833
  recordId
9701
9834
  );
9702
9835
  if (relatedRecords.length === 0) {
@@ -9930,7 +10063,7 @@ var RollupService = class {
9930
10063
  }
9931
10064
  for (const rollupDbAttr of rollupAttrs) {
9932
10065
  const rollupConfig = rollupDbAttr.config;
9933
- if (!_optionalChain([rollupConfig, 'optionalAccess', _214 => _214.relationAttribute])) {
10066
+ if (!_optionalChain([rollupConfig, 'optionalAccess', _230 => _230.relationAttribute])) {
9934
10067
  continue;
9935
10068
  }
9936
10069
  const relationAttr = attributes.find(
@@ -9940,7 +10073,7 @@ var RollupService = class {
9940
10073
  continue;
9941
10074
  }
9942
10075
  const relationConfig = relationAttr.config;
9943
- const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _215 => _215.targets, 'optionalAccess', _216 => _216.some, 'call', _217 => _217(
10076
+ const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _231 => _231.targets, 'optionalAccess', _232 => _232.some, 'call', _233 => _233(
9944
10077
  (t) => t.object === changedSchema.name
9945
10078
  )]);
9946
10079
  if (!targetsChangedObject) {
@@ -10043,7 +10176,7 @@ var UserService = class extends TenantAwareService {
10043
10176
  if (roleErrors.length > 0) {
10044
10177
  errors.push({
10045
10178
  attribute: attr.name,
10046
- message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _218 => _218.allowedRoles, 'optionalAccess', _219 => _219.join, 'call', _220 => _220(", ")])}`,
10179
+ message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _234 => _234.allowedRoles, 'optionalAccess', _235 => _235.join, 'call', _236 => _236(", ")])}`,
10047
10180
  invalidIds: roleErrors
10048
10181
  });
10049
10182
  }
@@ -10097,15 +10230,15 @@ var RecordService = class extends TenantAwareService {
10097
10230
  super();
10098
10231
  this.adapter = adapter;
10099
10232
  this.schemaService = new ObjectSchemaService(adapter, registry, {
10100
- auditService: _optionalChain([options, 'optionalAccess', _221 => _221.auditService])
10233
+ auditService: _optionalChain([options, 'optionalAccess', _237 => _237.auditService])
10101
10234
  });
10102
10235
  this.relationService = new RelationService(adapter, registry);
10103
10236
  this.userService = new UserService(adapter);
10104
10237
  this.rollupService = new RollupService(adapter);
10105
- this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _222 => _222.hookRegistry]), () => ( new NoopHookRegistry()));
10106
- this.permissionService = _optionalChain([options, 'optionalAccess', _223 => _223.permissionService]);
10107
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _224 => _224.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
10108
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _225 => _225.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _226 => _226.policyRegistry]), () => ( defaultPolicyRegistry));
10238
+ this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _238 => _238.hookRegistry]), () => ( new NoopHookRegistry()));
10239
+ this.permissionService = _optionalChain([options, 'optionalAccess', _239 => _239.permissionService]);
10240
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _240 => _240.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
10241
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _241 => _241.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _242 => _242.policyRegistry]), () => ( defaultPolicyRegistry));
10109
10242
  }
10110
10243
  /**
10111
10244
  * Check permission for an action on an object.
@@ -10289,20 +10422,20 @@ var RecordService = class extends TenantAwareService {
10289
10422
  const schema = await this.schemaService.getObjectSchema(objectId);
10290
10423
  const dataWithDefaults = applyDefaultValues(schema, data);
10291
10424
  await this.checkPermission(schema.name, "create");
10292
- const hookCtx = this.buildCreateHookContext(schema, dataWithDefaults, _optionalChain([options, 'optionalAccess', _227 => _227.hookMetadata]));
10293
- if (!_optionalChain([options, 'optionalAccess', _228 => _228.skipHooks])) {
10425
+ const hookCtx = this.buildCreateHookContext(schema, dataWithDefaults, _optionalChain([options, 'optionalAccess', _243 => _243.hookMetadata]));
10426
+ if (!_optionalChain([options, 'optionalAccess', _244 => _244.skipHooks])) {
10294
10427
  await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
10295
10428
  }
10296
- if (_optionalChain([options, 'optionalAccess', _229 => _229.validate]) !== false) {
10297
- if (_optionalChain([options, 'optionalAccess', _230 => _230.allowDraft])) {
10429
+ if (_optionalChain([options, 'optionalAccess', _245 => _245.validate]) !== false) {
10430
+ if (_optionalChain([options, 'optionalAccess', _246 => _246.allowDraft])) {
10298
10431
  validateDraftOrThrow(schema, dataWithDefaults);
10299
10432
  } else {
10300
10433
  validateObjectOrThrow(schema, dataWithDefaults);
10301
10434
  }
10302
- if (!_optionalChain([options, 'optionalAccess', _231 => _231.skipRelationValidation])) {
10435
+ if (!_optionalChain([options, 'optionalAccess', _247 => _247.skipRelationValidation])) {
10303
10436
  await this.relationService.validateRelationsOrThrow(schema, dataWithDefaults);
10304
10437
  }
10305
- if (!_optionalChain([options, 'optionalAccess', _232 => _232.skipUserValidation])) {
10438
+ if (!_optionalChain([options, 'optionalAccess', _248 => _248.skipUserValidation])) {
10306
10439
  await this.userService.validateUsersOrThrow(schema, dataWithDefaults);
10307
10440
  }
10308
10441
  }
@@ -10313,10 +10446,10 @@ var RecordService = class extends TenantAwareService {
10313
10446
  data: dataWithDefaults,
10314
10447
  label,
10315
10448
  completionStatus,
10316
- metadata: _optionalChain([options, 'optionalAccess', _233 => _233.metadata]),
10449
+ metadata: _optionalChain([options, 'optionalAccess', _249 => _249.metadata]),
10317
10450
  createdBy: this.userId
10318
10451
  });
10319
- if (!_optionalChain([options, 'optionalAccess', _234 => _234.skipHooks])) {
10452
+ if (!_optionalChain([options, 'optionalAccess', _250 => _250.skipHooks])) {
10320
10453
  const afterCtx = {
10321
10454
  ...hookCtx,
10322
10455
  recordId: record.id,
@@ -10333,7 +10466,7 @@ var RecordService = class extends TenantAwareService {
10333
10466
  objectId: schema.id,
10334
10467
  recordId: record.id,
10335
10468
  recordLabel: record.label,
10336
- metadata: _optionalChain([options, 'optionalAccess', _235 => _235.hookMetadata])
10469
+ metadata: _optionalChain([options, 'optionalAccess', _251 => _251.hookMetadata])
10337
10470
  });
10338
10471
  }
10339
10472
  return record;
@@ -10351,17 +10484,17 @@ var RecordService = class extends TenantAwareService {
10351
10484
  return null;
10352
10485
  }
10353
10486
  const schema = await this.schemaService.getObjectSchema(record.objectId);
10354
- if (!_optionalChain([options, 'optionalAccess', _236 => _236.skipPolicyCheck])) {
10487
+ if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipPolicyCheck])) {
10355
10488
  const policy = this.getPolicy(schema.name);
10356
10489
  if (policy && !this.checkRecordAccess(policy, record)) {
10357
10490
  return null;
10358
10491
  }
10359
10492
  }
10360
10493
  let enrichedRecord = record;
10361
- if (!_optionalChain([options, 'optionalAccess', _237 => _237.skipFormulas])) {
10494
+ if (!_optionalChain([options, 'optionalAccess', _253 => _253.skipFormulas])) {
10362
10495
  enrichedRecord = this.enrichWithFormulas(record, schema);
10363
10496
  }
10364
- if (_optionalChain([options, 'optionalAccess', _238 => _238.includeSchema])) {
10497
+ if (_optionalChain([options, 'optionalAccess', _254 => _254.includeSchema])) {
10365
10498
  const recordWithSchema = enrichedRecord;
10366
10499
  recordWithSchema.schema = schema;
10367
10500
  return recordWithSchema;
@@ -10420,9 +10553,9 @@ var RecordService = class extends TenantAwareService {
10420
10553
  data,
10421
10554
  mergedData,
10422
10555
  changedAttributes,
10423
- _optionalChain([options, 'optionalAccess', _239 => _239.hookMetadata])
10556
+ _optionalChain([options, 'optionalAccess', _255 => _255.hookMetadata])
10424
10557
  );
10425
- if (!_optionalChain([options, 'optionalAccess', _240 => _240.skipHooks])) {
10558
+ if (!_optionalChain([options, 'optionalAccess', _256 => _256.skipHooks])) {
10426
10559
  await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
10427
10560
  }
10428
10561
  const hookModifiedValues = {};
@@ -10431,19 +10564,19 @@ var RecordService = class extends TenantAwareService {
10431
10564
  hookModifiedValues[key] = hookCtx.newValues[key];
10432
10565
  }
10433
10566
  }
10434
- if (_optionalChain([options, 'optionalAccess', _241 => _241.validate]) !== false) {
10435
- if (_optionalChain([options, 'optionalAccess', _242 => _242.partial])) {
10567
+ if (_optionalChain([options, 'optionalAccess', _257 => _257.validate]) !== false) {
10568
+ if (_optionalChain([options, 'optionalAccess', _258 => _258.partial])) {
10436
10569
  validateDraftOrThrow(schema, mergedData);
10437
10570
  } else {
10438
10571
  validateObjectOrThrow(schema, mergedData);
10439
10572
  }
10440
- if (!_optionalChain([options, 'optionalAccess', _243 => _243.skipRelationValidation])) {
10573
+ if (!_optionalChain([options, 'optionalAccess', _259 => _259.skipRelationValidation])) {
10441
10574
  await this.relationService.validateRelationsOrThrow(schema, {
10442
10575
  ...data,
10443
10576
  ...hookModifiedValues
10444
10577
  });
10445
10578
  }
10446
- if (!_optionalChain([options, 'optionalAccess', _244 => _244.skipUserValidation])) {
10579
+ if (!_optionalChain([options, 'optionalAccess', _260 => _260.skipUserValidation])) {
10447
10580
  await this.userService.validateUsersOrThrow(schema, {
10448
10581
  ...data,
10449
10582
  ...hookModifiedValues
@@ -10459,7 +10592,7 @@ var RecordService = class extends TenantAwareService {
10459
10592
  __label: label,
10460
10593
  __lastUpdatedBy: this.userId
10461
10594
  };
10462
- if (_optionalChain([options, 'optionalAccess', _245 => _245.metadata]) !== void 0) {
10595
+ if (_optionalChain([options, 'optionalAccess', _261 => _261.metadata]) !== void 0) {
10463
10596
  const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
10464
10597
  const mergedMetadata = { ...existingMetadata, ...options.metadata };
10465
10598
  const cleanedMetadata = Object.fromEntries(
@@ -10468,7 +10601,7 @@ var RecordService = class extends TenantAwareService {
10468
10601
  updatePayload.__metadata = cleanedMetadata;
10469
10602
  }
10470
10603
  const updated = await this.adapter.objectRecords.update(recordId, updatePayload);
10471
- if (!_optionalChain([options, 'optionalAccess', _246 => _246.skipHooks])) {
10604
+ if (!_optionalChain([options, 'optionalAccess', _262 => _262.skipHooks])) {
10472
10605
  const afterCtx = {
10473
10606
  ...hookCtx,
10474
10607
  record: updated
@@ -10483,7 +10616,7 @@ var RecordService = class extends TenantAwareService {
10483
10616
  if (this.auditService && this.userId && allChangedAttributes.length > 0) {
10484
10617
  const changes = allChangedAttributes.map((attr) => ({
10485
10618
  field: attr,
10486
- oldValue: _optionalChain([hookCtx, 'access', _247 => _247.oldValues, 'optionalAccess', _248 => _248[attr]]),
10619
+ oldValue: _optionalChain([hookCtx, 'access', _263 => _263.oldValues, 'optionalAccess', _264 => _264[attr]]),
10487
10620
  newValue: hookCtx.newValues[attr]
10488
10621
  }));
10489
10622
  await this.auditService.logRecordAction({
@@ -10494,7 +10627,7 @@ var RecordService = class extends TenantAwareService {
10494
10627
  recordId: updated.id,
10495
10628
  recordLabel: updated.label,
10496
10629
  changes,
10497
- metadata: _optionalChain([options, 'optionalAccess', _249 => _249.hookMetadata])
10630
+ metadata: _optionalChain([options, 'optionalAccess', _265 => _265.hookMetadata])
10498
10631
  });
10499
10632
  }
10500
10633
  return updated;
@@ -10594,23 +10727,23 @@ var RecordService = class extends TenantAwareService {
10594
10727
  if (policy) {
10595
10728
  this.checkRecordDelete(policy, record);
10596
10729
  }
10597
- if (_optionalChain([options, 'optionalAccess', _250 => _250.checkSystem])) {
10730
+ if (_optionalChain([options, 'optionalAccess', _266 => _266.checkSystem])) {
10598
10731
  if (schema.system) {
10599
10732
  throw new ProtectedResourceError("object", schema.name, "delete");
10600
10733
  }
10601
10734
  }
10602
- if (!_optionalChain([options, 'optionalAccess', _251 => _251.skipReferenceCheck])) {
10735
+ if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipReferenceCheck])) {
10603
10736
  const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
10604
10737
  if (references.length > 0) {
10605
10738
  throw new RecordReferencedError(recordId, references);
10606
10739
  }
10607
10740
  }
10608
- const hookCtx = this.buildDeleteHookContext(schema, record, _optionalChain([options, 'optionalAccess', _252 => _252.hookMetadata]));
10609
- if (!_optionalChain([options, 'optionalAccess', _253 => _253.skipHooks])) {
10741
+ const hookCtx = this.buildDeleteHookContext(schema, record, _optionalChain([options, 'optionalAccess', _268 => _268.hookMetadata]));
10742
+ if (!_optionalChain([options, 'optionalAccess', _269 => _269.skipHooks])) {
10610
10743
  await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
10611
10744
  }
10612
10745
  await this.adapter.objectRecords.delete(recordId);
10613
- if (!_optionalChain([options, 'optionalAccess', _254 => _254.skipHooks])) {
10746
+ if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipHooks])) {
10614
10747
  await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
10615
10748
  }
10616
10749
  await this.recalculateParentRollups(record, schema);
@@ -10622,7 +10755,7 @@ var RecordService = class extends TenantAwareService {
10622
10755
  objectId: schema.id,
10623
10756
  recordId: record.id,
10624
10757
  recordLabel: record.label,
10625
- metadata: _optionalChain([options, 'optionalAccess', _255 => _255.hookMetadata])
10758
+ metadata: _optionalChain([options, 'optionalAccess', _271 => _271.hookMetadata])
10626
10759
  });
10627
10760
  }
10628
10761
  }
@@ -10653,12 +10786,12 @@ var RecordService = class extends TenantAwareService {
10653
10786
  }
10654
10787
  const schema = await this.schemaService.getObjectSchema(record.objectId);
10655
10788
  await this.checkPermission(schema.name, "update");
10656
- const hookCtx = this.buildRestoreHookContext(schema, record, _optionalChain([options, 'optionalAccess', _256 => _256.hookMetadata]));
10657
- if (!_optionalChain([options, 'optionalAccess', _257 => _257.skipHooks])) {
10789
+ const hookCtx = this.buildRestoreHookContext(schema, record, _optionalChain([options, 'optionalAccess', _272 => _272.hookMetadata]));
10790
+ if (!_optionalChain([options, 'optionalAccess', _273 => _273.skipHooks])) {
10658
10791
  await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
10659
10792
  }
10660
10793
  const restored = await this.adapter.objectRecords.restore(recordId);
10661
- if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipHooks])) {
10794
+ if (!_optionalChain([options, 'optionalAccess', _274 => _274.skipHooks])) {
10662
10795
  const afterCtx = {
10663
10796
  ...hookCtx,
10664
10797
  record: restored
@@ -10673,7 +10806,7 @@ var RecordService = class extends TenantAwareService {
10673
10806
  objectId: schema.id,
10674
10807
  recordId: restored.id,
10675
10808
  recordLabel: restored.label,
10676
- metadata: _optionalChain([options, 'optionalAccess', _259 => _259.hookMetadata])
10809
+ metadata: _optionalChain([options, 'optionalAccess', _275 => _275.hookMetadata])
10677
10810
  });
10678
10811
  }
10679
10812
  return restored;
@@ -10818,20 +10951,23 @@ var RecordService = class extends TenantAwareService {
10818
10951
  if (this.permissionService && this.userId) {
10819
10952
  await this.checkPermission(schema.name, "read");
10820
10953
  }
10821
- const policy = _optionalChain([options, 'optionalAccess', _260 => _260.skipPolicyFilter]) ? void 0 : this.getPolicy(schema.name);
10954
+ const policy = _optionalChain([options, 'optionalAccess', _276 => _276.skipPolicyFilter]) ? void 0 : this.getPolicy(schema.name);
10822
10955
  let effectiveOptions = options;
10823
- if (_optionalChain([policy, 'optionalAccess', _261 => _261.applyListFilter])) {
10956
+ if (_optionalChain([policy, 'optionalAccess', _277 => _277.applyListFilter])) {
10824
10957
  effectiveOptions = policy.applyListFilter(this.buildPolicyContext(schema.name), options);
10825
10958
  }
10826
- const result = await this.adapter.objectRecords.list(objectId, effectiveOptions);
10959
+ const result = await runWithSchemaContext(
10960
+ [schema],
10961
+ () => this.adapter.objectRecords.list(objectId, effectiveOptions)
10962
+ );
10827
10963
  let filteredRecords = result.records;
10828
10964
  let effectiveTotal = result.total;
10829
- if (_optionalChain([policy, 'optionalAccess', _262 => _262.canAccessRecord])) {
10965
+ if (_optionalChain([policy, 'optionalAccess', _278 => _278.canAccessRecord])) {
10830
10966
  const ctx = this.buildPolicyContext(schema.name);
10831
- filteredRecords = result.records.filter((record) => _optionalChain([policy, 'access', _263 => _263.canAccessRecord, 'optionalCall', _264 => _264(ctx, record)]));
10967
+ filteredRecords = result.records.filter((record) => _optionalChain([policy, 'access', _279 => _279.canAccessRecord, 'optionalCall', _280 => _280(ctx, record)]));
10832
10968
  effectiveTotal = filteredRecords.length;
10833
10969
  }
10834
- if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipFormulas])) {
10970
+ if (!_optionalChain([options, 'optionalAccess', _281 => _281.skipFormulas])) {
10835
10971
  return {
10836
10972
  records: this.enrichRecordsWithFormulas(filteredRecords, schema),
10837
10973
  total: effectiveTotal
@@ -10855,8 +10991,11 @@ var RecordService = class extends TenantAwareService {
10855
10991
  if (this.permissionService && this.userId) {
10856
10992
  await this.checkPermission(schema.name, "read");
10857
10993
  }
10858
- const result = await this.adapter.objectRecords.search(objectId, query, options);
10859
- if (!_optionalChain([options, 'optionalAccess', _266 => _266.skipFormulas])) {
10994
+ const result = await runWithSchemaContext(
10995
+ [schema],
10996
+ () => this.adapter.objectRecords.search(objectId, query, options)
10997
+ );
10998
+ if (!_optionalChain([options, 'optionalAccess', _282 => _282.skipFormulas])) {
10860
10999
  return {
10861
11000
  records: this.enrichRecordsWithFormulas(result.records, schema),
10862
11001
  total: result.total
@@ -11055,8 +11194,8 @@ var RollupScheduler = class {
11055
11194
  this.getSchemaById = getSchemaById;
11056
11195
  this.pending = /* @__PURE__ */ new Map();
11057
11196
  this.rollupService = new RollupService(adapter);
11058
- this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _267 => _267.debounceMs]), () => ( 100));
11059
- this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _268 => _268.maxPending]), () => ( 100));
11197
+ this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _283 => _283.debounceMs]), () => ( 100));
11198
+ this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _284 => _284.maxPending]), () => ( 100));
11060
11199
  }
11061
11200
  /**
11062
11201
  * Schedule a rollup recalculation for a parent record.
@@ -11132,7 +11271,7 @@ var UserProfileService = class extends TenantAwareService {
11132
11271
  constructor(adapter, options) {
11133
11272
  super();
11134
11273
  this.adapter = adapter;
11135
- this.auditService = _optionalChain([options, 'optionalAccess', _269 => _269.auditService]);
11274
+ this.auditService = _optionalChain([options, 'optionalAccess', _285 => _285.auditService]);
11136
11275
  }
11137
11276
  /**
11138
11277
  * Create a new user profile (typically after first auth).
@@ -11265,7 +11404,7 @@ var UserProfileService = class extends TenantAwareService {
11265
11404
  */
11266
11405
  async deleteProfile(profileId, options) {
11267
11406
  const profile = await this.getProfileOrThrow(profileId);
11268
- if (_optionalChain([options, 'optionalAccess', _270 => _270.checkAdmin])) {
11407
+ if (_optionalChain([options, 'optionalAccess', _286 => _286.checkAdmin])) {
11269
11408
  if (profile.role === "admin") {
11270
11409
  const adminCount = await this.adapter.userProfiles.countByRole("admin");
11271
11410
  if (adminCount <= 1) {
@@ -11334,7 +11473,7 @@ var UserProfileService = class extends TenantAwareService {
11334
11473
  */
11335
11474
  async hasRole(profileId, role) {
11336
11475
  const profile = await this.getProfile(profileId);
11337
- return _optionalChain([profile, 'optionalAccess', _271 => _271.role]) === role;
11476
+ return _optionalChain([profile, 'optionalAccess', _287 => _287.role]) === role;
11338
11477
  }
11339
11478
  /**
11340
11479
  * Check if user is admin
@@ -11629,9 +11768,9 @@ var WorkflowInstanceService = class extends TenantAwareService {
11629
11768
  super();
11630
11769
  this.adapter = adapter;
11631
11770
  this.workflowService = workflowService;
11632
- this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _272 => _272.executorRegistry]), () => ( getDefaultExecutorRegistry()));
11633
- this.schemaService = _optionalChain([options, 'optionalAccess', _273 => _273.schemaService]);
11634
- this.recordService = _optionalChain([options, 'optionalAccess', _274 => _274.recordService]);
11771
+ this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _288 => _288.executorRegistry]), () => ( getDefaultExecutorRegistry()));
11772
+ this.schemaService = _optionalChain([options, 'optionalAccess', _289 => _289.schemaService]);
11773
+ this.recordService = _optionalChain([options, 'optionalAccess', _290 => _290.recordService]);
11635
11774
  }
11636
11775
  /**
11637
11776
  * Start a new workflow instance
@@ -11757,7 +11896,7 @@ var WorkflowInstanceService = class extends TenantAwareService {
11757
11896
  if (!this.adapter.workflowInstances) {
11758
11897
  return { instances: [], total: 0 };
11759
11898
  }
11760
- if (_optionalChain([options, 'optionalAccess', _275 => _275.workflowName])) {
11899
+ if (_optionalChain([options, 'optionalAccess', _291 => _291.workflowName])) {
11761
11900
  const instances2 = await this.getInstancesByWorkflow(options.workflowName);
11762
11901
  let filtered = instances2;
11763
11902
  if (options.status) {
@@ -11771,11 +11910,11 @@ var WorkflowInstanceService = class extends TenantAwareService {
11771
11910
  return { instances: paginated, total: total2 };
11772
11911
  }
11773
11912
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
11774
- limit: _optionalChain([options, 'optionalAccess', _276 => _276.limit]),
11775
- offset: _optionalChain([options, 'optionalAccess', _277 => _277.offset])
11913
+ limit: _optionalChain([options, 'optionalAccess', _292 => _292.limit]),
11914
+ offset: _optionalChain([options, 'optionalAccess', _293 => _293.offset])
11776
11915
  });
11777
11916
  let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
11778
- if (_optionalChain([options, 'optionalAccess', _278 => _278.status])) {
11917
+ if (_optionalChain([options, 'optionalAccess', _294 => _294.status])) {
11779
11918
  instances = instances.filter((i) => i.status === options.status);
11780
11919
  }
11781
11920
  return { instances, total };
@@ -11795,9 +11934,9 @@ var WorkflowInstanceService = class extends TenantAwareService {
11795
11934
  return { instances: [], total: 0 };
11796
11935
  }
11797
11936
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
11798
- status: _optionalChain([options, 'optionalAccess', _279 => _279.status]),
11799
- limit: _optionalChain([options, 'optionalAccess', _280 => _280.limit]),
11800
- offset: _optionalChain([options, 'optionalAccess', _281 => _281.offset])
11937
+ status: _optionalChain([options, 'optionalAccess', _295 => _295.status]),
11938
+ limit: _optionalChain([options, 'optionalAccess', _296 => _296.limit]),
11939
+ offset: _optionalChain([options, 'optionalAccess', _297 => _297.offset])
11801
11940
  });
11802
11941
  const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
11803
11942
  return { instances, total };
@@ -12176,7 +12315,7 @@ var WorkflowParticipationService = class extends TenantAwareService {
12176
12315
  SchemaErrorCode.RECORD_NOT_FOUND
12177
12316
  );
12178
12317
  }
12179
- const template = _optionalChain([instance, 'access', _282 => _282.workflowSnapshot, 'access', _283 => _283.participants, 'optionalAccess', _284 => _284.find, 'call', _285 => _285(
12318
+ const template = _optionalChain([instance, 'access', _298 => _298.workflowSnapshot, 'access', _299 => _299.participants, 'optionalAccess', _300 => _300.find, 'call', _301 => _301(
12180
12319
  (p) => p.id === input.participantTemplateId
12181
12320
  )]);
12182
12321
  if (!template) {
@@ -12479,7 +12618,7 @@ var WorkflowRelationService = class extends TenantAwareService {
12479
12618
  if (attr.type !== "relation") continue;
12480
12619
  for (const slot of slots) {
12481
12620
  const slotData = context.slots[slot.id];
12482
- const slotRecordId = _optionalChain([slotData, 'optionalAccess', _286 => _286.id]);
12621
+ const slotRecordId = _optionalChain([slotData, 'optionalAccess', _302 => _302.id]);
12483
12622
  if (!slotRecordId) continue;
12484
12623
  const targetsSlotObject = attr.targets.some(
12485
12624
  (t) => t.object === slot.objectName
@@ -13448,4 +13587,12 @@ var NoopGeocodingAdapter = class {
13448
13587
 
13449
13588
 
13450
13589
 
13451
- 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.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.isSignedLinkAuth = isSignedLinkAuth; exports.isPinCodeAuth = isPinCodeAuth; exports.canParticipate = canParticipate; exports.canAuthenticate = canAuthenticate; exports.canExecuteNode = canExecuteNode; 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.isParticipationEvent = isParticipationEvent; 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.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.ParticipantAuthConfigSchema = ParticipantAuthConfigSchema; exports.ParticipantTemplateSchema = ParticipantTemplateSchema; 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.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.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.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.TabBuilder = TabBuilder; exports.ViewBuilder = ViewBuilder; exports.view = view; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowParticipantBuilder = WorkflowParticipantBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; 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.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.ParticipationTokenService = ParticipationTokenService; exports.getDefaultTokenService = getDefaultTokenService; exports.initializeTokenService = initializeTokenService; exports.PinCodeService = PinCodeService; exports.getDefaultPinCodeService = getDefaultPinCodeService; exports.initializePinCodeService = initializePinCodeService; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; 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.getContext = getContext; 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.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.buildAuditChanges = buildAuditChanges; exports.TenantAwareService = TenantAwareService; exports.TenantAwareRepository = TenantAwareRepository; exports.AuditService = AuditService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.ObjectSchemaService = ObjectSchemaService; exports.PermissionService = PermissionService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.UserService = UserService; exports.RecordService = RecordService; exports.RelationResolverService = RelationResolverService; exports.RollupScheduler = RollupScheduler; exports.UserProfileService = UserProfileService; exports.ViewService = ViewService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
13590
+
13591
+
13592
+
13593
+
13594
+
13595
+
13596
+
13597
+
13598
+ 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.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.isSignedLinkAuth = isSignedLinkAuth; exports.isPinCodeAuth = isPinCodeAuth; exports.canParticipate = canParticipate; exports.canAuthenticate = canAuthenticate; exports.canExecuteNode = canExecuteNode; 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.isParticipationEvent = isParticipationEvent; 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.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.ParticipantAuthConfigSchema = ParticipantAuthConfigSchema; exports.ParticipantTemplateSchema = ParticipantTemplateSchema; 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.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.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.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.TabBuilder = TabBuilder; exports.ViewBuilder = ViewBuilder; exports.view = view; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowParticipantBuilder = WorkflowParticipantBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; 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.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.ParticipationTokenService = ParticipationTokenService; exports.getDefaultTokenService = getDefaultTokenService; exports.initializeTokenService = initializeTokenService; exports.PinCodeService = PinCodeService; exports.getDefaultPinCodeService = getDefaultPinCodeService; exports.initializePinCodeService = initializePinCodeService; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; 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.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext; 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.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.buildAuditChanges = buildAuditChanges; exports.TenantAwareService = TenantAwareService; exports.TenantAwareRepository = TenantAwareRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.AuditService = AuditService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.ObjectSchemaService = ObjectSchemaService; exports.PermissionService = PermissionService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.UserService = UserService; exports.RecordService = RecordService; exports.RelationResolverService = RelationResolverService; exports.RollupScheduler = RollupScheduler; exports.UserProfileService = UserProfileService; exports.ViewService = ViewService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;