@stndrds/schema 0.1.0-alpha.51 → 0.1.0-alpha.52

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.
@@ -9596,12 +9596,105 @@ var RecordQueryService = class extends BaseService {
9596
9596
  }
9597
9597
  };
9598
9598
 
9599
+ // src/runtime/services/record/record-resolver.service.ts
9600
+ var RecordResolverService = class extends BaseService {
9601
+ constructor(adapter) {
9602
+ super(adapter);
9603
+ }
9604
+ // ============================================================================
9605
+ // CACHED RECORD ACCESS
9606
+ // ============================================================================
9607
+ /**
9608
+ * Find a record by ID with caching.
9609
+ *
9610
+ * Uses the shared record cache for optimal performance.
9611
+ * Delegates to findByIds for consistent cache handling.
9612
+ *
9613
+ * @param id - Record ID
9614
+ * @returns Record or null if not found
9615
+ */
9616
+ async findById(id) {
9617
+ if (!id) return null;
9618
+ const results = await this.findByIds([id]);
9619
+ return _nullishCoalesce(results[0], () => ( null));
9620
+ }
9621
+ /**
9622
+ * Find multiple records by IDs with caching.
9623
+ *
9624
+ * Each record is cached individually for reuse across services.
9625
+ * Only fetches records not already in cache.
9626
+ *
9627
+ * @param ids - Record IDs to fetch
9628
+ * @returns Array of found records (missing IDs are not included)
9629
+ */
9630
+ async findByIds(ids) {
9631
+ if (!ids || ids.length === 0) {
9632
+ return [];
9633
+ }
9634
+ const uniqueIds = [...new Set(ids)];
9635
+ return this.cachedByMany(
9636
+ "record",
9637
+ uniqueIds,
9638
+ (missingIds) => this.adapter.objectRecords.findByIds(missingIds),
9639
+ (record) => record.id,
9640
+ cacheTtl.records
9641
+ );
9642
+ }
9643
+ // ============================================================================
9644
+ // FACTORY METHODS
9645
+ // ============================================================================
9646
+ /**
9647
+ * Create a RelationLabelResolver callback for computeLabelWithRelations.
9648
+ *
9649
+ * Used by RelationService.resolveLabel() and ObjectSchemaService.
9650
+ *
9651
+ * @returns Callback that resolves record IDs to their labels (cached)
9652
+ */
9653
+ createRelationLabelResolver() {
9654
+ return async (ids) => {
9655
+ const records = await this.findByIds(ids);
9656
+ return new Map(records.map((r) => [r.id, r.label]));
9657
+ };
9658
+ }
9659
+ /**
9660
+ * Create a LabelResolver interface for label computation helpers.
9661
+ *
9662
+ * Used by RecordService for computing record labels.
9663
+ *
9664
+ * @param relationService - RelationService for resolving relation display labels
9665
+ * @returns LabelResolver interface with cached record fetching
9666
+ */
9667
+ createLabelResolver(relationService) {
9668
+ return {
9669
+ resolveRelationIds: (ids, attrId) => relationService.resolveIds(ids, attrId),
9670
+ findRecordLabels: (ids) => this.findByIds(ids)
9671
+ };
9672
+ }
9673
+ /**
9674
+ * Create a RollupCascadeContext for rollup recalculation.
9675
+ *
9676
+ * Used by RecordService after create/update/delete operations.
9677
+ *
9678
+ * @param rollupService - RollupService for recalculating rollups
9679
+ * @param schemaService - ObjectSchemaService for fetching schemas
9680
+ * @returns Context with cached record fetching
9681
+ */
9682
+ createRollupContext(rollupService, schemaService) {
9683
+ return {
9684
+ rollupService,
9685
+ schemaService,
9686
+ findRecordsByIds: (ids) => this.findByIds(ids)
9687
+ };
9688
+ }
9689
+ };
9690
+
9599
9691
  // src/runtime/services/record/relation.service.ts
9600
9692
  var RelationService = class extends BaseService {
9601
9693
  constructor(adapter, nativeRegistry, options) {
9602
9694
  super(adapter);
9603
9695
  this.schemaService = new ObjectSchemaService(adapter, nativeRegistry);
9604
- this.queryService = _optionalChain([options, 'optionalAccess', _222 => _222.queryService]);
9696
+ this.queryService = options.queryService;
9697
+ this.recordResolver = options.recordResolver;
9605
9698
  }
9606
9699
  /**
9607
9700
  * Set the query service after construction.
@@ -9672,14 +9765,14 @@ var RelationService = class extends BaseService {
9672
9765
  }
9673
9766
  const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
9674
9767
  const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
9675
- if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _223 => _223.size]) === 0) {
9768
+ if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _222 => _222.size]) === 0) {
9676
9769
  errors.push({
9677
9770
  attribute: attr.name,
9678
9771
  message: `No valid target objects found for ${attr.label}`
9679
9772
  });
9680
9773
  return errors;
9681
9774
  }
9682
- const records = await this.adapter.objectRecords.findByIds(ids);
9775
+ const records = await this.recordResolver.findByIds(ids);
9683
9776
  const recordMap = new Map(records.map((r) => [r.id, r]));
9684
9777
  const invalidIds = [];
9685
9778
  for (const id of ids) {
@@ -9725,7 +9818,7 @@ var RelationService = class extends BaseService {
9725
9818
  for (const target of targets) {
9726
9819
  try {
9727
9820
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
9728
- if (_optionalChain([objectSchema, 'optionalAccess', _224 => _224.id])) {
9821
+ if (_optionalChain([objectSchema, 'optionalAccess', _223 => _223.id])) {
9729
9822
  objectIds.add(objectSchema.id);
9730
9823
  }
9731
9824
  } catch (e11) {
@@ -9789,7 +9882,7 @@ var RelationService = class extends BaseService {
9789
9882
  let totalCount = 0;
9790
9883
  for (const target of filteredTargets) {
9791
9884
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
9792
- if (!_optionalChain([objectSchema, 'optionalAccess', _225 => _225.id])) {
9885
+ if (!_optionalChain([objectSchema, 'optionalAccess', _224 => _224.id])) {
9793
9886
  continue;
9794
9887
  }
9795
9888
  const queryOptions = {
@@ -9801,20 +9894,7 @@ var RelationService = class extends BaseService {
9801
9894
  const result = query ? await queryService.searchRecords(objectSchema.id, query, queryOptions) : await queryService.listRecords(objectSchema.id, queryOptions);
9802
9895
  totalCount += result.total;
9803
9896
  for (const record of result.records) {
9804
- let label;
9805
- if (target.displayTemplate) {
9806
- label = await computeLabelWithRelations(
9807
- target.displayTemplate,
9808
- record.values,
9809
- objectSchema.attributes,
9810
- async (ids) => {
9811
- const linkedRecords = await this.adapter.objectRecords.findByIds(ids);
9812
- return new Map(linkedRecords.map((r) => [r.id, r.label]));
9813
- }
9814
- );
9815
- } else {
9816
- label = record.label;
9817
- }
9897
+ const label = await this.resolveLabel(record, objectSchema, target.displayTemplate);
9818
9898
  allOptions.push({
9819
9899
  id: record.id,
9820
9900
  objectId: objectSchema.id,
@@ -9852,17 +9932,8 @@ var RelationService = class extends BaseService {
9852
9932
  if (!ids || ids.length === 0) {
9853
9933
  return [];
9854
9934
  }
9855
- const compositeIds = ids.map((id) => `${attributeId}:${id}`);
9856
- return this.cachedByMany(
9857
- "resolvedRelation",
9858
- compositeIds,
9859
- async (missingCompositeIds) => {
9860
- const missingRecordIds = missingCompositeIds.map((c) => c.split(":")[1]);
9861
- return this.fetchResolveIds(missingRecordIds, attributeId);
9862
- },
9863
- (item) => `${attributeId}:${item.id}`,
9864
- cacheTtl.resolvedRelations
9865
- );
9935
+ const result = await this.resolveIdsBatch([{ attributeId, ids }]);
9936
+ return _nullishCoalesce(result[attributeId], () => ( []));
9866
9937
  }
9867
9938
  /**
9868
9939
  * Resolve multiple attribute/IDs batches in a single operation.
@@ -9905,7 +9976,7 @@ var RelationService = class extends BaseService {
9905
9976
  const allResolved = await this.cachedByMany(
9906
9977
  "resolvedRelation",
9907
9978
  allCompositeIds,
9908
- (missingCompositeIds) => this.fetchResolveIdsBatch(missingCompositeIds),
9979
+ (missingCompositeIds) => this.resolveCompositeIds(missingCompositeIds),
9909
9980
  (item) => item._compositeId,
9910
9981
  cacheTtl.resolvedRelations
9911
9982
  );
@@ -9926,10 +9997,12 @@ var RelationService = class extends BaseService {
9926
9997
  return response;
9927
9998
  }
9928
9999
  /**
9929
- * Internal method to fetch and resolve multiple composite IDs at once.
10000
+ * Internal method to resolve multiple composite IDs at once.
9930
10001
  * Optimized for batch operations - single DB query for all records.
10002
+ *
10003
+ * @param compositeIds - Array of composite IDs in format "attributeId:recordId"
9931
10004
  */
9932
- async fetchResolveIdsBatch(compositeIds) {
10005
+ async resolveCompositeIds(compositeIds) {
9933
10006
  if (compositeIds.length === 0) {
9934
10007
  return [];
9935
10008
  }
@@ -9939,7 +10012,7 @@ var RelationService = class extends BaseService {
9939
10012
  });
9940
10013
  const uniqueRecordIds = [...new Set(parsed.map((p) => p.recordId))];
9941
10014
  const uniqueAttributeIds = [...new Set(parsed.map((p) => p.attributeId))];
9942
- const records = await this.adapter.objectRecords.findByIds(uniqueRecordIds);
10015
+ const records = await this.recordResolver.findByIds(uniqueRecordIds);
9943
10016
  if (records.length === 0) {
9944
10017
  return [];
9945
10018
  }
@@ -9962,22 +10035,9 @@ var RelationService = class extends BaseService {
9962
10035
  continue;
9963
10036
  }
9964
10037
  const attribute = attributeMap.get(attributeId);
9965
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _226 => _226.targets, 'optionalAccess', _227 => _227.find, 'call', _228 => _228((t) => t.object === objectSchema.name)]);
9966
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _229 => _229.displayTemplate]);
9967
- let label;
9968
- if (customTemplate) {
9969
- label = await computeLabelWithRelations(
9970
- customTemplate,
9971
- record.values,
9972
- objectSchema.attributes,
9973
- async (nestedIds) => {
9974
- const linkedRecords = await this.adapter.objectRecords.findByIds(nestedIds);
9975
- return new Map(linkedRecords.map((r) => [r.id, r.label]));
9976
- }
9977
- );
9978
- } else {
9979
- label = record.label;
9980
- }
10038
+ const targetConfig = _optionalChain([attribute, 'optionalAccess', _225 => _225.targets, 'optionalAccess', _226 => _226.find, 'call', _227 => _227((t) => t.object === objectSchema.name)]);
10039
+ const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _228 => _228.displayTemplate]);
10040
+ const label = await this.resolveLabel(record, objectSchema, customTemplate);
9981
10041
  resolved.push({
9982
10042
  _compositeId: compositeId,
9983
10043
  id: record.id,
@@ -9991,59 +10051,22 @@ var RelationService = class extends BaseService {
9991
10051
  return resolved;
9992
10052
  }
9993
10053
  /**
9994
- * Internal method to fetch and resolve relation IDs (no caching).
9995
- * Uses batch fetching for performance - fetches all records in one query,
9996
- * then groups by objectId to minimize schema lookups.
10054
+ * Resolve the display label for a record.
10055
+ * Uses custom template if provided, otherwise falls back to pre-computed label.
9997
10056
  */
9998
- async fetchResolveIds(ids, attributeId) {
9999
- if (ids.length === 0) {
10000
- return [];
10001
- }
10002
- const attribute = await this.findAttributeById(attributeId);
10003
- const records = await this.adapter.objectRecords.findByIds(ids);
10004
- if (records.length === 0) {
10005
- return [];
10006
- }
10007
- const recordsByObjectId = /* @__PURE__ */ new Map();
10008
- for (const record of records) {
10009
- const existing = _nullishCoalesce(recordsByObjectId.get(record.objectId), () => ( []));
10010
- existing.push(record);
10011
- recordsByObjectId.set(record.objectId, existing);
10012
- }
10013
- const resolved = [];
10014
- for (const [objectId, objectRecords] of recordsByObjectId) {
10015
- const objectSchema = await this.schemaService.getObjectSchema(objectId);
10016
- if (!objectSchema) {
10017
- continue;
10018
- }
10019
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _230 => _230.targets, 'optionalAccess', _231 => _231.find, 'call', _232 => _232((t) => t.object === objectSchema.name)]);
10020
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _233 => _233.displayTemplate]);
10021
- for (const record of objectRecords) {
10022
- let label;
10023
- if (customTemplate) {
10024
- label = await computeLabelWithRelations(
10025
- customTemplate,
10026
- record.values,
10027
- objectSchema.attributes,
10028
- async (nestedIds) => {
10029
- const linkedRecords = await this.adapter.objectRecords.findByIds(nestedIds);
10030
- return new Map(linkedRecords.map((r) => [r.id, r.label]));
10031
- }
10032
- );
10033
- } else {
10034
- label = record.label;
10057
+ async resolveLabel(record, objectSchema, customTemplate) {
10058
+ if (customTemplate) {
10059
+ return computeLabelWithRelations(
10060
+ customTemplate,
10061
+ record.values,
10062
+ objectSchema.attributes,
10063
+ async (nestedIds) => {
10064
+ const linkedRecords = await this.recordResolver.findByIds(nestedIds);
10065
+ return new Map(linkedRecords.map((r) => [r.id, r.label]));
10035
10066
  }
10036
- resolved.push({
10037
- id: record.id,
10038
- objectId: record.objectId,
10039
- objectName: objectSchema.name,
10040
- objectLabel: objectSchema.label,
10041
- objectIcon: objectSchema.icon,
10042
- label
10043
- });
10044
- }
10067
+ );
10045
10068
  }
10046
- return resolved;
10069
+ return record.label;
10047
10070
  }
10048
10071
  /**
10049
10072
  * Find a relation attribute by ID.
@@ -10074,8 +10097,9 @@ var RelationService = class extends BaseService {
10074
10097
 
10075
10098
  // src/runtime/services/record/rollup.service.ts
10076
10099
  var RollupService = class extends BaseService {
10077
- constructor(adapter) {
10100
+ constructor(adapter, options) {
10078
10101
  super(adapter);
10102
+ this.recordResolver = options.recordResolver;
10079
10103
  }
10080
10104
  /**
10081
10105
  * Calculate a rollup value for a record
@@ -10129,7 +10153,7 @@ var RollupService = class extends BaseService {
10129
10153
  * Example: entreprise222 has relation "entreprises" → companies, rollup collects from companies
10130
10154
  */
10131
10155
  async calculateForward(recordId, rollupAttr) {
10132
- const record = await this.adapter.objectRecords.findById(recordId);
10156
+ const record = await this.recordResolver.findById(recordId);
10133
10157
  if (!record) {
10134
10158
  return { value: null, recordCount: 0 };
10135
10159
  }
@@ -10143,7 +10167,7 @@ var RollupService = class extends BaseService {
10143
10167
  if (relatedIds.length === 0) {
10144
10168
  return { value: this.getEmptyValue(rollupAttr.function), recordCount: 0 };
10145
10169
  }
10146
- const relatedRecords = await this.adapter.objectRecords.findByIds(relatedIds);
10170
+ const relatedRecords = await this.recordResolver.findByIds(relatedIds);
10147
10171
  if (relatedRecords.length === 0) {
10148
10172
  return { value: this.getEmptyValue(rollupAttr.function), recordCount: 0 };
10149
10173
  }
@@ -10154,7 +10178,7 @@ var RollupService = class extends BaseService {
10154
10178
  * Example: Company has rollup on "orders", Order has relation "company" → companies
10155
10179
  */
10156
10180
  async calculateReverse(recordId, rollupAttr, schema) {
10157
- const record = await this.adapter.objectRecords.findById(recordId);
10181
+ const record = await this.recordResolver.findById(recordId);
10158
10182
  if (!record) {
10159
10183
  return { value: null, recordCount: 0 };
10160
10184
  }
@@ -10162,14 +10186,14 @@ var RollupService = class extends BaseService {
10162
10186
  const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
10163
10187
  let sourceObjectId;
10164
10188
  let reverseRelationAttrName;
10165
- if (_optionalChain([sourceSchema, 'optionalAccess', _234 => _234.id])) {
10189
+ if (_optionalChain([sourceSchema, 'optionalAccess', _229 => _229.id])) {
10166
10190
  sourceObjectId = sourceSchema.id;
10167
10191
  const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
10168
10192
  if (attr.type !== "relation") return false;
10169
10193
  const relationConfig = attr;
10170
- return _optionalChain([relationConfig, 'optionalAccess', _235 => _235.targets, 'optionalAccess', _236 => _236.some, 'call', _237 => _237((t) => t.object === schema.name)]);
10194
+ return _optionalChain([relationConfig, 'optionalAccess', _230 => _230.targets, 'optionalAccess', _231 => _231.some, 'call', _232 => _232((t) => t.object === schema.name)]);
10171
10195
  });
10172
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _238 => _238.name]);
10196
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _233 => _233.name]);
10173
10197
  } else {
10174
10198
  const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
10175
10199
  if (!sourceObject) {
@@ -10180,9 +10204,9 @@ var RollupService = class extends BaseService {
10180
10204
  const reverseRelationAttr = sourceAttributes.find((attr) => {
10181
10205
  if (attr.type !== "relation") return false;
10182
10206
  const relationConfig = attr.config;
10183
- return _optionalChain([relationConfig, 'optionalAccess', _239 => _239.targets, 'optionalAccess', _240 => _240.some, 'call', _241 => _241((t) => t.object === schema.name)]);
10207
+ return _optionalChain([relationConfig, 'optionalAccess', _234 => _234.targets, 'optionalAccess', _235 => _235.some, 'call', _236 => _236((t) => t.object === schema.name)]);
10184
10208
  });
10185
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _242 => _242.name]);
10209
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _237 => _237.name]);
10186
10210
  }
10187
10211
  if (!reverseRelationAttrName) {
10188
10212
  return { value: null, recordCount: 0 };
@@ -10419,7 +10443,7 @@ var RollupService = class extends BaseService {
10419
10443
  }
10420
10444
  for (const rollupDbAttr of rollupAttrs) {
10421
10445
  const rollupConfig = rollupDbAttr.config;
10422
- if (!_optionalChain([rollupConfig, 'optionalAccess', _243 => _243.relationAttribute])) {
10446
+ if (!_optionalChain([rollupConfig, 'optionalAccess', _238 => _238.relationAttribute])) {
10423
10447
  continue;
10424
10448
  }
10425
10449
  const relationAttr = attributes.find(
@@ -10429,7 +10453,7 @@ var RollupService = class extends BaseService {
10429
10453
  continue;
10430
10454
  }
10431
10455
  const relationConfig = relationAttr.config;
10432
- const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _244 => _244.targets, 'optionalAccess', _245 => _245.some, 'call', _246 => _246(
10456
+ const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _239 => _239.targets, 'optionalAccess', _240 => _240.some, 'call', _241 => _241(
10433
10457
  (t) => t.object === changedSchema.name
10434
10458
  )]);
10435
10459
  if (!targetsChangedObject) {
@@ -10456,30 +10480,30 @@ var RecordService = class extends BaseService {
10456
10480
  constructor(adapter, options) {
10457
10481
  super(adapter);
10458
10482
  this.schemaService = new ObjectSchemaService(adapter, registry, {
10459
- auditService: _optionalChain([options, 'optionalAccess', _247 => _247.auditService])
10483
+ auditService: _optionalChain([options, 'optionalAccess', _242 => _242.auditService])
10460
10484
  });
10461
- this.permissionService = _optionalChain([options, 'optionalAccess', _248 => _248.permissionService]);
10462
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _249 => _249.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
10463
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _250 => _250.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _251 => _251.policyRegistry]), () => ( defaultPolicyRegistry));
10485
+ this.permissionService = _optionalChain([options, 'optionalAccess', _243 => _243.permissionService]);
10486
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
10487
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _245 => _245.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.policyRegistry]), () => ( defaultPolicyRegistry));
10488
+ this.recordResolver = new RecordResolverService(adapter);
10464
10489
  this.queryService = new RecordQueryService(adapter, this.schemaService, {
10465
10490
  permissionService: this.permissionService,
10466
10491
  policyRegistry: this.policyRegistry
10467
10492
  });
10468
10493
  this.relationService = new RelationService(adapter, registry, {
10469
- queryService: this.queryService
10494
+ queryService: this.queryService,
10495
+ recordResolver: this.recordResolver
10496
+ });
10497
+ this.rollupService = new RollupService(adapter, {
10498
+ recordResolver: this.recordResolver
10470
10499
  });
10471
10500
  this.userService = new UserService(adapter);
10472
- this.rollupService = new RollupService(adapter);
10473
- this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _252 => _252.hookRegistry]), () => ( new NoopHookRegistry()));
10474
- this.labelResolver = {
10475
- resolveRelationIds: (ids, attrId) => this.relationService.resolveIds(ids, attrId),
10476
- findRecordLabels: (ids) => this.adapter.objectRecords.findByIds(ids)
10477
- };
10478
- this.rollupContext = {
10479
- rollupService: this.rollupService,
10480
- schemaService: this.schemaService,
10481
- findRecordsByIds: (ids) => this.adapter.objectRecords.findByIds(ids)
10482
- };
10501
+ this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _247 => _247.hookRegistry]), () => ( new NoopHookRegistry()));
10502
+ this.labelResolver = this.recordResolver.createLabelResolver(this.relationService);
10503
+ this.rollupContext = this.recordResolver.createRollupContext(
10504
+ this.rollupService,
10505
+ this.schemaService
10506
+ );
10483
10507
  }
10484
10508
  // ============================================================================
10485
10509
  // CREATE
@@ -10502,21 +10526,21 @@ var RecordService = class extends BaseService {
10502
10526
  schema,
10503
10527
  this.tenantId,
10504
10528
  dataWithDefaults,
10505
- _optionalChain([options, 'optionalAccess', _253 => _253.hookMetadata])
10529
+ _optionalChain([options, 'optionalAccess', _248 => _248.hookMetadata])
10506
10530
  );
10507
- if (!_optionalChain([options, 'optionalAccess', _254 => _254.skipHooks])) {
10531
+ if (!_optionalChain([options, 'optionalAccess', _249 => _249.skipHooks])) {
10508
10532
  await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
10509
10533
  }
10510
- if (_optionalChain([options, 'optionalAccess', _255 => _255.validate]) !== false) {
10511
- if (_optionalChain([options, 'optionalAccess', _256 => _256.allowDraft])) {
10534
+ if (_optionalChain([options, 'optionalAccess', _250 => _250.validate]) !== false) {
10535
+ if (_optionalChain([options, 'optionalAccess', _251 => _251.allowDraft])) {
10512
10536
  validateDraftOrThrow(schema, dataWithDefaults);
10513
10537
  } else {
10514
10538
  validateObjectOrThrow(schema, dataWithDefaults);
10515
10539
  }
10516
- if (!_optionalChain([options, 'optionalAccess', _257 => _257.skipRelationValidation])) {
10540
+ if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipRelationValidation])) {
10517
10541
  await this.relationService.validateRelationsOrThrow(schema, dataWithDefaults);
10518
10542
  }
10519
- if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipUserValidation])) {
10543
+ if (!_optionalChain([options, 'optionalAccess', _253 => _253.skipUserValidation])) {
10520
10544
  await this.userService.validateUsersOrThrow(schema, dataWithDefaults);
10521
10545
  }
10522
10546
  }
@@ -10527,10 +10551,10 @@ var RecordService = class extends BaseService {
10527
10551
  data: dataWithDefaults,
10528
10552
  label,
10529
10553
  completionStatus,
10530
- metadata: _optionalChain([options, 'optionalAccess', _259 => _259.metadata]),
10554
+ metadata: _optionalChain([options, 'optionalAccess', _254 => _254.metadata]),
10531
10555
  createdBy: this.userId
10532
10556
  });
10533
- if (!_optionalChain([options, 'optionalAccess', _260 => _260.skipHooks])) {
10557
+ if (!_optionalChain([options, 'optionalAccess', _255 => _255.skipHooks])) {
10534
10558
  const afterCtx = {
10535
10559
  ...hookCtx,
10536
10560
  recordId: record.id,
@@ -10550,7 +10574,7 @@ var RecordService = class extends BaseService {
10550
10574
  objectId: schema.id,
10551
10575
  recordId: record.id,
10552
10576
  recordLabel: record.label,
10553
- metadata: _optionalChain([options, 'optionalAccess', _261 => _261.hookMetadata])
10577
+ metadata: _optionalChain([options, 'optionalAccess', _256 => _256.hookMetadata])
10554
10578
  });
10555
10579
  }
10556
10580
  return record;
@@ -10571,7 +10595,7 @@ var RecordService = class extends BaseService {
10571
10595
  return null;
10572
10596
  }
10573
10597
  const schema = await this.schemaService.getObjectSchema(record.objectId);
10574
- if (!_optionalChain([options, 'optionalAccess', _262 => _262.skipPolicyCheck])) {
10598
+ if (!_optionalChain([options, 'optionalAccess', _257 => _257.skipPolicyCheck])) {
10575
10599
  const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
10576
10600
  if (policy) {
10577
10601
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
@@ -10581,10 +10605,10 @@ var RecordService = class extends BaseService {
10581
10605
  }
10582
10606
  }
10583
10607
  let enrichedRecord = record;
10584
- if (!_optionalChain([options, 'optionalAccess', _263 => _263.skipFormulas])) {
10608
+ if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipFormulas])) {
10585
10609
  enrichedRecord = enrichWithFormulas(record, schema);
10586
10610
  }
10587
- if (_optionalChain([options, 'optionalAccess', _264 => _264.includeSchema])) {
10611
+ if (_optionalChain([options, 'optionalAccess', _259 => _259.includeSchema])) {
10588
10612
  const recordWithSchema = enrichedRecord;
10589
10613
  recordWithSchema.schema = schema;
10590
10614
  return recordWithSchema;
@@ -10627,9 +10651,9 @@ var RecordService = class extends BaseService {
10627
10651
  existing,
10628
10652
  mergedData,
10629
10653
  changedAttributes,
10630
- _optionalChain([options, 'optionalAccess', _265 => _265.hookMetadata])
10654
+ _optionalChain([options, 'optionalAccess', _260 => _260.hookMetadata])
10631
10655
  );
10632
- if (!_optionalChain([options, 'optionalAccess', _266 => _266.skipHooks])) {
10656
+ if (!_optionalChain([options, 'optionalAccess', _261 => _261.skipHooks])) {
10633
10657
  await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
10634
10658
  }
10635
10659
  const hookModifiedValues = {};
@@ -10638,19 +10662,19 @@ var RecordService = class extends BaseService {
10638
10662
  hookModifiedValues[key] = hookCtx.newValues[key];
10639
10663
  }
10640
10664
  }
10641
- if (_optionalChain([options, 'optionalAccess', _267 => _267.validate]) !== false) {
10642
- if (_optionalChain([options, 'optionalAccess', _268 => _268.partial])) {
10665
+ if (_optionalChain([options, 'optionalAccess', _262 => _262.validate]) !== false) {
10666
+ if (_optionalChain([options, 'optionalAccess', _263 => _263.partial])) {
10643
10667
  validateDraftOrThrow(schema, mergedData);
10644
10668
  } else {
10645
10669
  validateObjectOrThrow(schema, mergedData);
10646
10670
  }
10647
- if (!_optionalChain([options, 'optionalAccess', _269 => _269.skipRelationValidation])) {
10671
+ if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipRelationValidation])) {
10648
10672
  await this.relationService.validateRelationsOrThrow(schema, {
10649
10673
  ...data,
10650
10674
  ...hookModifiedValues
10651
10675
  });
10652
10676
  }
10653
- if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipUserValidation])) {
10677
+ if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipUserValidation])) {
10654
10678
  await this.userService.validateUsersOrThrow(schema, {
10655
10679
  ...data,
10656
10680
  ...hookModifiedValues
@@ -10666,7 +10690,7 @@ var RecordService = class extends BaseService {
10666
10690
  __label: label,
10667
10691
  __lastUpdatedBy: this.userId
10668
10692
  };
10669
- if (_optionalChain([options, 'optionalAccess', _271 => _271.metadata]) !== void 0) {
10693
+ if (_optionalChain([options, 'optionalAccess', _266 => _266.metadata]) !== void 0) {
10670
10694
  const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
10671
10695
  const mergedMetadata = { ...existingMetadata, ...options.metadata };
10672
10696
  const cleanedMetadata = Object.fromEntries(
@@ -10679,7 +10703,7 @@ var RecordService = class extends BaseService {
10679
10703
  await this.invalidateLists("allRecordLists", existing.objectId);
10680
10704
  await this.invalidateLists("allSearchResults", existing.objectId);
10681
10705
  await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
10682
- if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipHooks])) {
10706
+ if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipHooks])) {
10683
10707
  const afterCtx = {
10684
10708
  ...hookCtx,
10685
10709
  record: updated
@@ -10694,7 +10718,7 @@ var RecordService = class extends BaseService {
10694
10718
  if (this.auditService && this.userId && allChangedAttributes.length > 0) {
10695
10719
  const changes = allChangedAttributes.map((attr) => ({
10696
10720
  field: attr,
10697
- oldValue: _optionalChain([hookCtx, 'access', _273 => _273.oldValues, 'optionalAccess', _274 => _274[attr]]),
10721
+ oldValue: _optionalChain([hookCtx, 'access', _268 => _268.oldValues, 'optionalAccess', _269 => _269[attr]]),
10698
10722
  newValue: hookCtx.newValues[attr]
10699
10723
  }));
10700
10724
  await this.auditService.logRecordAction({
@@ -10705,7 +10729,7 @@ var RecordService = class extends BaseService {
10705
10729
  recordId: updated.id,
10706
10730
  recordLabel: updated.label,
10707
10731
  changes,
10708
- metadata: _optionalChain([options, 'optionalAccess', _275 => _275.hookMetadata])
10732
+ metadata: _optionalChain([options, 'optionalAccess', _270 => _270.hookMetadata])
10709
10733
  });
10710
10734
  }
10711
10735
  return updated;
@@ -10728,17 +10752,17 @@ var RecordService = class extends BaseService {
10728
10752
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
10729
10753
  checkRecordDeleteOrThrow(policy, record, ctx);
10730
10754
  }
10731
- if (_optionalChain([options, 'optionalAccess', _276 => _276.checkSystem]) && schema.system) {
10755
+ if (_optionalChain([options, 'optionalAccess', _271 => _271.checkSystem]) && schema.system) {
10732
10756
  throw new ProtectedResourceError("object", schema.name, "delete");
10733
10757
  }
10734
- if (!_optionalChain([options, 'optionalAccess', _277 => _277.skipReferenceCheck])) {
10758
+ if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipReferenceCheck])) {
10735
10759
  const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
10736
10760
  if (references.length > 0) {
10737
10761
  throw new RecordReferencedError(recordId, references);
10738
10762
  }
10739
10763
  }
10740
- const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _278 => _278.hookMetadata]));
10741
- if (!_optionalChain([options, 'optionalAccess', _279 => _279.skipHooks])) {
10764
+ const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _273 => _273.hookMetadata]));
10765
+ if (!_optionalChain([options, 'optionalAccess', _274 => _274.skipHooks])) {
10742
10766
  await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
10743
10767
  }
10744
10768
  await this.adapter.objectRecords.delete(recordId);
@@ -10747,7 +10771,7 @@ var RecordService = class extends BaseService {
10747
10771
  await this.invalidateLists("allSearchResults", record.objectId);
10748
10772
  await this.invalidateCachePattern(cacheKeys.allGlobalSearch(this.tenantId));
10749
10773
  await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
10750
- if (!_optionalChain([options, 'optionalAccess', _280 => _280.skipHooks])) {
10774
+ if (!_optionalChain([options, 'optionalAccess', _275 => _275.skipHooks])) {
10751
10775
  await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
10752
10776
  }
10753
10777
  await recalculateParentRollups(record, schema, this.rollupContext);
@@ -10759,7 +10783,7 @@ var RecordService = class extends BaseService {
10759
10783
  objectId: schema.id,
10760
10784
  recordId: record.id,
10761
10785
  recordLabel: record.label,
10762
- metadata: _optionalChain([options, 'optionalAccess', _281 => _281.hookMetadata])
10786
+ metadata: _optionalChain([options, 'optionalAccess', _276 => _276.hookMetadata])
10763
10787
  });
10764
10788
  }
10765
10789
  }
@@ -10794,8 +10818,8 @@ var RecordService = class extends BaseService {
10794
10818
  }
10795
10819
  const schema = await this.schemaService.getObjectSchema(record.objectId);
10796
10820
  await checkPermission(this.permissionService, this.userId, schema.name, "update");
10797
- const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _282 => _282.hookMetadata]));
10798
- if (!_optionalChain([options, 'optionalAccess', _283 => _283.skipHooks])) {
10821
+ const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _277 => _277.hookMetadata]));
10822
+ if (!_optionalChain([options, 'optionalAccess', _278 => _278.skipHooks])) {
10799
10823
  await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
10800
10824
  }
10801
10825
  const restored = await this.adapter.objectRecords.restore(recordId);
@@ -10804,7 +10828,7 @@ var RecordService = class extends BaseService {
10804
10828
  await this.invalidateLists("allSearchResults", record.objectId);
10805
10829
  await this.invalidateCachePattern(cacheKeys.allGlobalSearch(this.tenantId));
10806
10830
  await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
10807
- if (!_optionalChain([options, 'optionalAccess', _284 => _284.skipHooks])) {
10831
+ if (!_optionalChain([options, 'optionalAccess', _279 => _279.skipHooks])) {
10808
10832
  const afterCtx = {
10809
10833
  ...hookCtx,
10810
10834
  record: restored
@@ -10819,7 +10843,7 @@ var RecordService = class extends BaseService {
10819
10843
  objectId: schema.id,
10820
10844
  recordId: restored.id,
10821
10845
  recordLabel: restored.label,
10822
- metadata: _optionalChain([options, 'optionalAccess', _285 => _285.hookMetadata])
10846
+ metadata: _optionalChain([options, 'optionalAccess', _280 => _280.hookMetadata])
10823
10847
  });
10824
10848
  }
10825
10849
  return restored;
@@ -10874,15 +10898,19 @@ var RecordService = class extends BaseService {
10874
10898
  }
10875
10899
  };
10876
10900
 
10877
- // src/runtime/services/record/relation-resolver.service.ts
10878
- var RelationResolverService = class {
10879
- constructor(adapter) {
10880
- this.adapter = adapter;
10901
+ // src/runtime/services/record/formula-resolver.service.ts
10902
+ var FormulaResolverService = class extends BaseService {
10903
+ constructor(adapter, options) {
10904
+ super(adapter);
10905
+ this.recordResolver = options.recordResolver;
10881
10906
  }
10907
+ // ============================================================================
10908
+ // RESOLUTION
10909
+ // ============================================================================
10882
10910
  /**
10883
10911
  * Resolve values from related records for formula evaluation
10884
10912
  *
10885
- * Phase 2: Supports 1 level of relation traversal only
10913
+ * Supports 1 level of relation traversal only.
10886
10914
  *
10887
10915
  * @param record - The source record
10888
10916
  * @param schema - Schema of the source object
@@ -10891,7 +10919,6 @@ var RelationResolverService = class {
10891
10919
  *
10892
10920
  * @example
10893
10921
  * ```typescript
10894
- * // For an order with company relation
10895
10922
  * const resolved = await resolver.resolveRelationValues(
10896
10923
  * orderRecord,
10897
10924
  * orderSchema,
@@ -10920,7 +10947,7 @@ var RelationResolverService = class {
10920
10947
  if (idsToFetch.length === 0) {
10921
10948
  return result;
10922
10949
  }
10923
- const relatedRecords = await this.adapter.objectRecords.findByIds(idsToFetch);
10950
+ const relatedRecords = await this.recordResolver.findByIds(idsToFetch);
10924
10951
  for (const relatedRecord of relatedRecords) {
10925
10952
  const attrName = attrIdMap.get(relatedRecord.id);
10926
10953
  if (attrName) {
@@ -10966,7 +10993,7 @@ var RelationResolverService = class {
10966
10993
  if (allIdsToFetch.size === 0) {
10967
10994
  return resultMap;
10968
10995
  }
10969
- const relatedRecords = await this.adapter.objectRecords.findByIds([...allIdsToFetch]);
10996
+ const relatedRecords = await this.recordResolver.findByIds([...allIdsToFetch]);
10970
10997
  const relatedRecordMap = new Map(relatedRecords.map((r) => [r.id, r]));
10971
10998
  for (const record of records) {
10972
10999
  const result = resultMap.get(record.id);
@@ -10999,10 +11026,12 @@ var RelationResolverService = class {
10999
11026
  }
11000
11027
  return flat;
11001
11028
  }
11029
+ // ============================================================================
11030
+ // PRIVATE HELPERS
11031
+ // ============================================================================
11002
11032
  /**
11003
11033
  * Extract a single relation ID from a value
11004
11034
  * Handles both single (string) and multi (array) relations
11005
- * @internal
11006
11035
  */
11007
11036
  extractSingleId(value) {
11008
11037
  if (typeof value === "string" && value.length > 0) {
@@ -11021,9 +11050,9 @@ var RollupScheduler = class {
11021
11050
  this.adapter = adapter;
11022
11051
  this.getSchemaById = getSchemaById;
11023
11052
  this.pending = /* @__PURE__ */ new Map();
11024
- this.rollupService = new RollupService(adapter);
11025
- this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _286 => _286.debounceMs]), () => ( 100));
11026
- this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _287 => _287.maxPending]), () => ( 100));
11053
+ this.rollupService = new RollupService(adapter, { recordResolver: options.recordResolver });
11054
+ this.debounceMs = _nullishCoalesce(options.debounceMs, () => ( 100));
11055
+ this.maxPending = _nullishCoalesce(options.maxPending, () => ( 100));
11027
11056
  }
11028
11057
  /**
11029
11058
  * Schedule a rollup recalculation for a parent record.
@@ -11101,7 +11130,7 @@ var WorkflowService = class extends BaseService {
11101
11130
  if (Array.isArray(options)) {
11102
11131
  this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
11103
11132
  } else {
11104
- this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _288 => _288.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
11133
+ this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _281 => _281.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
11105
11134
  }
11106
11135
  }
11107
11136
  // ============================================================================
@@ -11404,9 +11433,9 @@ var WorkflowInstanceService = class extends BaseService {
11404
11433
  constructor(adapter, workflowService, options) {
11405
11434
  super(adapter);
11406
11435
  this.workflowService = workflowService;
11407
- this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _289 => _289.executorRegistry]), () => ( getDefaultExecutorRegistry()));
11408
- this.schemaService = _optionalChain([options, 'optionalAccess', _290 => _290.schemaService]);
11409
- this.recordService = _optionalChain([options, 'optionalAccess', _291 => _291.recordService]);
11436
+ this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _282 => _282.executorRegistry]), () => ( getDefaultExecutorRegistry()));
11437
+ this.schemaService = _optionalChain([options, 'optionalAccess', _283 => _283.schemaService]);
11438
+ this.recordService = _optionalChain([options, 'optionalAccess', _284 => _284.recordService]);
11410
11439
  }
11411
11440
  /**
11412
11441
  * Start a new workflow instance
@@ -11532,7 +11561,7 @@ var WorkflowInstanceService = class extends BaseService {
11532
11561
  if (!this.adapter.workflowInstances) {
11533
11562
  return { instances: [], total: 0 };
11534
11563
  }
11535
- if (_optionalChain([options, 'optionalAccess', _292 => _292.workflowName])) {
11564
+ if (_optionalChain([options, 'optionalAccess', _285 => _285.workflowName])) {
11536
11565
  const instances2 = await this.getInstancesByWorkflow(options.workflowName);
11537
11566
  let filtered = instances2;
11538
11567
  if (options.status) {
@@ -11546,11 +11575,11 @@ var WorkflowInstanceService = class extends BaseService {
11546
11575
  return { instances: paginated, total: total2 };
11547
11576
  }
11548
11577
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
11549
- limit: _optionalChain([options, 'optionalAccess', _293 => _293.limit]),
11550
- offset: _optionalChain([options, 'optionalAccess', _294 => _294.offset])
11578
+ limit: _optionalChain([options, 'optionalAccess', _286 => _286.limit]),
11579
+ offset: _optionalChain([options, 'optionalAccess', _287 => _287.offset])
11551
11580
  });
11552
11581
  let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
11553
- if (_optionalChain([options, 'optionalAccess', _295 => _295.status])) {
11582
+ if (_optionalChain([options, 'optionalAccess', _288 => _288.status])) {
11554
11583
  instances = instances.filter((i) => i.status === options.status);
11555
11584
  }
11556
11585
  return { instances, total };
@@ -11570,9 +11599,9 @@ var WorkflowInstanceService = class extends BaseService {
11570
11599
  return { instances: [], total: 0 };
11571
11600
  }
11572
11601
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
11573
- status: _optionalChain([options, 'optionalAccess', _296 => _296.status]),
11574
- limit: _optionalChain([options, 'optionalAccess', _297 => _297.limit]),
11575
- offset: _optionalChain([options, 'optionalAccess', _298 => _298.offset])
11602
+ status: _optionalChain([options, 'optionalAccess', _289 => _289.status]),
11603
+ limit: _optionalChain([options, 'optionalAccess', _290 => _290.limit]),
11604
+ offset: _optionalChain([options, 'optionalAccess', _291 => _291.offset])
11576
11605
  });
11577
11606
  const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
11578
11607
  return { instances, total };
@@ -11948,7 +11977,7 @@ var WorkflowParticipationService = class extends BaseService {
11948
11977
  SchemaErrorCode.RECORD_NOT_FOUND
11949
11978
  );
11950
11979
  }
11951
- const template = _optionalChain([instance, 'access', _299 => _299.workflowSnapshot, 'access', _300 => _300.participants, 'optionalAccess', _301 => _301.find, 'call', _302 => _302(
11980
+ const template = _optionalChain([instance, 'access', _292 => _292.workflowSnapshot, 'access', _293 => _293.participants, 'optionalAccess', _294 => _294.find, 'call', _295 => _295(
11952
11981
  (p) => p.id === input.participantTemplateId
11953
11982
  )]);
11954
11983
  if (!template) {
@@ -12250,7 +12279,7 @@ var WorkflowRelationService = class extends BaseService {
12250
12279
  if (attr.type !== "relation") continue;
12251
12280
  for (const slot of slots) {
12252
12281
  const slotData = context.slots[slot.id];
12253
- const slotRecordId = _optionalChain([slotData, 'optionalAccess', _303 => _303.id]);
12282
+ const slotRecordId = _optionalChain([slotData, 'optionalAccess', _296 => _296.id]);
12254
12283
  if (!slotRecordId) continue;
12255
12284
  const targetsSlotObject = attr.targets.some(
12256
12285
  (t) => t.object === slot.objectName
@@ -12315,7 +12344,7 @@ var WorkflowRelationService = class extends BaseService {
12315
12344
  var UserProfileService = class extends BaseService {
12316
12345
  constructor(adapter, options) {
12317
12346
  super(adapter);
12318
- this.auditService = _optionalChain([options, 'optionalAccess', _304 => _304.auditService]);
12347
+ this.auditService = _optionalChain([options, 'optionalAccess', _297 => _297.auditService]);
12319
12348
  }
12320
12349
  // ============================================================================
12321
12350
  // CACHE MANAGEMENT
@@ -12478,7 +12507,7 @@ var UserProfileService = class extends BaseService {
12478
12507
  */
12479
12508
  async deleteProfile(profileId, options) {
12480
12509
  const profile = await this.getProfileOrThrow(profileId);
12481
- if (_optionalChain([options, 'optionalAccess', _305 => _305.checkAdmin])) {
12510
+ if (_optionalChain([options, 'optionalAccess', _298 => _298.checkAdmin])) {
12482
12511
  if (profile.role === "admin") {
12483
12512
  const adminCount = await this.adapter.userProfiles.countByRole("admin");
12484
12513
  if (adminCount <= 1) {
@@ -12553,7 +12582,7 @@ var UserProfileService = class extends BaseService {
12553
12582
  */
12554
12583
  async hasRole(profileId, role) {
12555
12584
  const profile = await this.getProfile(profileId);
12556
- return _optionalChain([profile, 'optionalAccess', _306 => _306.role]) === role;
12585
+ return _optionalChain([profile, 'optionalAccess', _299 => _299.role]) === role;
12557
12586
  }
12558
12587
  /**
12559
12588
  * Check if user is admin
@@ -12610,7 +12639,7 @@ var UserProfileService = class extends BaseService {
12610
12639
  var FileService = class extends BaseService {
12611
12640
  constructor(adapter, options) {
12612
12641
  super(adapter);
12613
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _307 => _307.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12642
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _300 => _300.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12614
12643
  }
12615
12644
  // ============================================================================
12616
12645
  // UPLOAD (requires StorageAdapter)
@@ -12742,7 +12771,7 @@ var FileService = class extends BaseService {
12742
12771
  */
12743
12772
  async getFile(fileId) {
12744
12773
  const file2 = await this.adapter.files.findById(fileId);
12745
- if (_optionalChain([file2, 'optionalAccess', _308 => _308.deletedAt])) {
12774
+ if (_optionalChain([file2, 'optionalAccess', _301 => _301.deletedAt])) {
12746
12775
  return null;
12747
12776
  }
12748
12777
  return file2;
@@ -12804,12 +12833,12 @@ var FileService = class extends BaseService {
12804
12833
  */
12805
12834
  async deleteFile(fileId, options) {
12806
12835
  const file2 = await this.getFileOrThrow(fileId);
12807
- if (_optionalChain([options, 'optionalAccess', _309 => _309.checkOwnership]) && options.userId) {
12836
+ if (_optionalChain([options, 'optionalAccess', _302 => _302.checkOwnership]) && options.userId) {
12808
12837
  if (file2.uploadedBy !== options.userId) {
12809
12838
  throw new Error("You can only delete files you uploaded");
12810
12839
  }
12811
12840
  }
12812
- if (_optionalChain([options, 'optionalAccess', _310 => _310.hard])) {
12841
+ if (_optionalChain([options, 'optionalAccess', _303 => _303.hard])) {
12813
12842
  await this.adapter.files.hardDelete(fileId);
12814
12843
  } else {
12815
12844
  await this.adapter.files.delete(fileId);
@@ -12840,7 +12869,7 @@ var FileService = class extends BaseService {
12840
12869
  }
12841
12870
  const file2 = await this.getFileOrThrow(fileId);
12842
12871
  await this.adapter.storage.delete(file2.storagePath);
12843
- if (_optionalChain([options, 'optionalAccess', _311 => _311.hard])) {
12872
+ if (_optionalChain([options, 'optionalAccess', _304 => _304.hard])) {
12844
12873
  await this.adapter.files.hardDelete(fileId);
12845
12874
  } else {
12846
12875
  await this.adapter.files.delete(fileId);
@@ -12867,10 +12896,10 @@ var FileService = class extends BaseService {
12867
12896
  if (!file2) {
12868
12897
  continue;
12869
12898
  }
12870
- if (_optionalChain([options, 'optionalAccess', _312 => _312.deleteFromStorage]) && this.adapter.storage) {
12899
+ if (_optionalChain([options, 'optionalAccess', _305 => _305.deleteFromStorage]) && this.adapter.storage) {
12871
12900
  await this.adapter.storage.delete(file2.storagePath);
12872
12901
  }
12873
- if (_optionalChain([options, 'optionalAccess', _313 => _313.hard])) {
12902
+ if (_optionalChain([options, 'optionalAccess', _306 => _306.hard])) {
12874
12903
  await this.adapter.files.hardDelete(fileId);
12875
12904
  } else {
12876
12905
  await this.adapter.files.delete(fileId);
@@ -12881,7 +12910,7 @@ var FileService = class extends BaseService {
12881
12910
  actorId: this.userId,
12882
12911
  fileId,
12883
12912
  fileName: file2.name,
12884
- metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _314 => _314.deleteFromStorage]), () => ( false)) }
12913
+ metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _307 => _307.deleteFromStorage]), () => ( false)) }
12885
12914
  });
12886
12915
  }
12887
12916
  }
@@ -12965,7 +12994,7 @@ var FileService = class extends BaseService {
12965
12994
  return true;
12966
12995
  }
12967
12996
  if (file2.visibility === "restricted") {
12968
- return _nullishCoalesce(_optionalChain([file2, 'access', _315 => _315.allowedUsers, 'optionalAccess', _316 => _316.includes, 'call', _317 => _317(userId)]), () => ( false));
12997
+ return _nullishCoalesce(_optionalChain([file2, 'access', _308 => _308.allowedUsers, 'optionalAccess', _309 => _309.includes, 'call', _310 => _310(userId)]), () => ( false));
12969
12998
  }
12970
12999
  return false;
12971
13000
  }
@@ -13130,10 +13159,10 @@ var GlobalSearchService = class extends BaseService {
13130
13159
  */
13131
13160
  async executeSearch(query, options) {
13132
13161
  return await this.adapter.objectRecords.globalSearch(query, {
13133
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _318 => _318.limit]), () => ( 20)),
13134
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _319 => _319.offset]), () => ( 0)),
13135
- objectNames: _optionalChain([options, 'optionalAccess', _320 => _320.objectNames]),
13136
- includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _321 => _321.includeObjectInfo]), () => ( true))
13162
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _311 => _311.limit]), () => ( 20)),
13163
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _312 => _312.offset]), () => ( 0)),
13164
+ objectNames: _optionalChain([options, 'optionalAccess', _313 => _313.objectNames]),
13165
+ includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _314 => _314.includeObjectInfo]), () => ( true))
13137
13166
  });
13138
13167
  }
13139
13168
  /**
@@ -13183,7 +13212,7 @@ var PermissionService = class extends BaseService {
13183
13212
  }
13184
13213
  this.permissionsRepo = adapter.permissions;
13185
13214
  this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
13186
- this.auditService = _optionalChain([options, 'optionalAccess', _322 => _322.auditService]);
13215
+ this.auditService = _optionalChain([options, 'optionalAccess', _315 => _315.auditService]);
13187
13216
  }
13188
13217
  // ============================================================================
13189
13218
  // PERMISSION CHECKS
@@ -13202,11 +13231,11 @@ var PermissionService = class extends BaseService {
13202
13231
  return true;
13203
13232
  }
13204
13233
  const wildcardPerms = permissions.objectPermissions["*"];
13205
- if (_optionalChain([wildcardPerms, 'optionalAccess', _323 => _323.includes, 'call', _324 => _324(action)])) {
13234
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _316 => _316.includes, 'call', _317 => _317(action)])) {
13206
13235
  return true;
13207
13236
  }
13208
13237
  const objectPerms = permissions.objectPermissions[objectName];
13209
- return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _325 => _325.includes, 'call', _326 => _326(action)]), () => ( false));
13238
+ return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _318 => _318.includes, 'call', _319 => _319(action)]), () => ( false));
13210
13239
  }
13211
13240
  /**
13212
13241
  * Check if user can access an object, throw ForbiddenError if not.
@@ -13261,12 +13290,12 @@ var PermissionService = class extends BaseService {
13261
13290
  if (permissions.isAdmin) {
13262
13291
  return true;
13263
13292
  }
13264
- const wildcardPerms = _optionalChain([permissions, 'access', _327 => _327.systemPermissions, 'optionalAccess', _328 => _328["*"]]);
13265
- if (_optionalChain([wildcardPerms, 'optionalAccess', _329 => _329.includes, 'call', _330 => _330(action)])) {
13293
+ const wildcardPerms = _optionalChain([permissions, 'access', _320 => _320.systemPermissions, 'optionalAccess', _321 => _321["*"]]);
13294
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _322 => _322.includes, 'call', _323 => _323(action)])) {
13266
13295
  return true;
13267
13296
  }
13268
- const resourcePerms = _optionalChain([permissions, 'access', _331 => _331.systemPermissions, 'optionalAccess', _332 => _332[resource]]);
13269
- return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _333 => _333.includes, 'call', _334 => _334(action)]), () => ( false));
13297
+ const resourcePerms = _optionalChain([permissions, 'access', _324 => _324.systemPermissions, 'optionalAccess', _325 => _325[resource]]);
13298
+ return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _326 => _326.includes, 'call', _327 => _327(action)]), () => ( false));
13270
13299
  }
13271
13300
  /**
13272
13301
  * Check if user can access a system resource, throw ForbiddenError if not.
@@ -13295,8 +13324,8 @@ var PermissionService = class extends BaseService {
13295
13324
  if (permissions.isAdmin) {
13296
13325
  return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
13297
13326
  }
13298
- const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _335 => _335.systemPermissions, 'optionalAccess', _336 => _336["*"]]), () => ( []));
13299
- const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _337 => _337.systemPermissions, 'optionalAccess', _338 => _338[resource]]), () => ( []));
13327
+ const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _328 => _328.systemPermissions, 'optionalAccess', _329 => _329["*"]]), () => ( []));
13328
+ const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _330 => _330.systemPermissions, 'optionalAccess', _331 => _331[resource]]), () => ( []));
13300
13329
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
13301
13330
  return {
13302
13331
  canRead: allPerms.has("read"),
@@ -13438,7 +13467,7 @@ var PermissionService = class extends BaseService {
13438
13467
  action: "role.updated",
13439
13468
  actorId: this.userId,
13440
13469
  roleId,
13441
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _339 => _339.label]), () => ( roleId)),
13470
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _332 => _332.label]), () => ( roleId)),
13442
13471
  metadata: { permissionsUpdated: true, permissionCount: permissions.length }
13443
13472
  });
13444
13473
  }
@@ -13468,7 +13497,7 @@ var PermissionService = class extends BaseService {
13468
13497
  action: "role.assigned",
13469
13498
  actorId: this.userId,
13470
13499
  roleId,
13471
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _340 => _340.label]), () => ( roleId)),
13500
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _333 => _333.label]), () => ( roleId)),
13472
13501
  targetUserId: userProfileId
13473
13502
  });
13474
13503
  }
@@ -13486,7 +13515,7 @@ var PermissionService = class extends BaseService {
13486
13515
  action: "role.revoked",
13487
13516
  actorId: this.userId,
13488
13517
  roleId,
13489
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _341 => _341.label]), () => ( roleId)),
13518
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _334 => _334.label]), () => ( roleId)),
13490
13519
  targetUserId: userProfileId
13491
13520
  });
13492
13521
  }
@@ -14480,4 +14509,5 @@ var NoopGeocodingAdapter = class {
14480
14509
 
14481
14510
 
14482
14511
 
14483
- 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.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.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.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.TenantAwareRepository = TenantAwareRepository; exports.TenantAwareService = TenantAwareService; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RecordQueryService = RecordQueryService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.RelationResolverService = RelationResolverService; exports.RollupScheduler = RollupScheduler; exports.WorkflowService = WorkflowService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.UserProfileService = UserProfileService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
14512
+
14513
+ 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.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.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.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.TenantAwareRepository = TenantAwareRepository; exports.TenantAwareService = TenantAwareService; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.WorkflowService = WorkflowService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.UserProfileService = UserProfileService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;