@stndrds/schema 1.0.0-alpha.77 → 1.0.0-alpha.79

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.
@@ -15,9 +15,6 @@ var _chunkNEVERCM3js = require('./chunk-NEVERCM3.js');
15
15
  var _chunk3WTK7ESHjs = require('./chunk-3WTK7ESH.js');
16
16
 
17
17
 
18
- var _chunkJZO52C3Fjs = require('./chunk-JZO52C3F.js');
19
-
20
-
21
18
  var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
22
19
 
23
20
  // src/runtime/auth/workflow-jwt.service.ts
@@ -1295,6 +1292,23 @@ function createQueryBuilder(recordService, adapter, objectName, options) {
1295
1292
  return new QueryBuilder(recordService, adapter, objectName, initialState);
1296
1293
  }
1297
1294
 
1295
+ // src/types/flows.ts
1296
+ function isFlowFieldsRow(row) {
1297
+ return !row.type || row.type === "fields";
1298
+ }
1299
+ function isLayoutRow(row) {
1300
+ return !!row.type && row.type !== "fields";
1301
+ }
1302
+ function isFlowDefinition(obj) {
1303
+ return typeof obj === "object" && obj !== null && "slots" in obj && "pages" in obj && "relations" in obj && "status" in obj;
1304
+ }
1305
+ function isFlowPublished(flow) {
1306
+ return flow.status === "published";
1307
+ }
1308
+ function isSystemFlow(flow) {
1309
+ return flow.system === true;
1310
+ }
1311
+
1298
1312
  // src/types/workflows/nodes.ts
1299
1313
  function isSimpleFormNode(node) {
1300
1314
  return node.fields !== void 0 && node.rows === void 0;
@@ -1462,6 +1476,11 @@ function setContextValue(context, path, value) {
1462
1476
  current[parts[parts.length - 1]] = value;
1463
1477
  }
1464
1478
 
1479
+ // src/types/workflows/form-context.ts
1480
+ function isFormFieldsRow(row) {
1481
+ return !row.type || row.type === "fields";
1482
+ }
1483
+
1465
1484
  // src/types/workflows/theme.ts
1466
1485
  var DEFAULT_THEME = {
1467
1486
  borderRadius: 8,
@@ -1554,14 +1573,40 @@ var FlowRowFieldSchema = _zod.z.object({
1554
1573
  id: _zod.z.string().min(1),
1555
1574
  slotId: _zod.z.string().min(1),
1556
1575
  attribute: _zod.z.string().min(1),
1557
- label: _zod.z.string().optional(),
1576
+ label: _zod.z.string().max(200).optional(),
1577
+ tooltip: _zod.z.string().max(1e3).optional(),
1558
1578
  required: _zod.z.boolean().optional()
1559
1579
  });
1560
- var FlowRowSchema = _zod.z.object({
1580
+ var FlowFieldsRowSchema = _zod.z.object({
1561
1581
  id: _zod.z.string().min(1),
1562
1582
  order: _zod.z.number(),
1583
+ type: _zod.z.literal("fields").optional(),
1563
1584
  fields: _zod.z.array(FlowRowFieldSchema)
1564
1585
  });
1586
+ var FlowHeadingRowSchema = _zod.z.object({
1587
+ id: _zod.z.string().min(1),
1588
+ order: _zod.z.number(),
1589
+ type: _zod.z.literal("heading"),
1590
+ content: _zod.z.string().min(1).max(200),
1591
+ level: _zod.z.union([_zod.z.literal(1), _zod.z.literal(2), _zod.z.literal(3)]).optional()
1592
+ });
1593
+ var FlowSeparatorRowSchema = _zod.z.object({
1594
+ id: _zod.z.string().min(1),
1595
+ order: _zod.z.number(),
1596
+ type: _zod.z.literal("separator")
1597
+ });
1598
+ var FlowTextRowSchema = _zod.z.object({
1599
+ id: _zod.z.string().min(1),
1600
+ order: _zod.z.number(),
1601
+ type: _zod.z.literal("text"),
1602
+ content: _zod.z.string().min(1).max(5e3)
1603
+ });
1604
+ var FlowRowSchema = _zod.z.union([
1605
+ FlowHeadingRowSchema,
1606
+ FlowSeparatorRowSchema,
1607
+ FlowTextRowSchema,
1608
+ FlowFieldsRowSchema
1609
+ ]);
1565
1610
  var FormNodeSchema = _zod.z.object({
1566
1611
  type: _zod.z.literal("form"),
1567
1612
  id: _zod.z.string().min(1),
@@ -2237,9 +2282,11 @@ var FormExecutor = class {
2237
2282
  }
2238
2283
  if (node.rows) {
2239
2284
  for (const row of node.rows) {
2240
- for (const field of row.fields) {
2241
- if (field.slotId) {
2242
- slotIds.add(field.slotId);
2285
+ if (isFlowFieldsRow(row)) {
2286
+ for (const field of row.fields) {
2287
+ if (field.slotId) {
2288
+ slotIds.add(field.slotId);
2289
+ }
2243
2290
  }
2244
2291
  }
2245
2292
  }
@@ -2304,9 +2351,11 @@ var FormExecutor = class {
2304
2351
  }
2305
2352
  if (node.rows) {
2306
2353
  for (const row of node.rows) {
2307
- for (const field of row.fields) {
2308
- if (field.slotId && field.attribute) {
2309
- refs.push({ slotId: field.slotId, attribute: field.attribute });
2354
+ if (isFlowFieldsRow(row)) {
2355
+ for (const field of row.fields) {
2356
+ if (field.slotId && field.attribute) {
2357
+ refs.push({ slotId: field.slotId, attribute: field.attribute });
2358
+ }
2310
2359
  }
2311
2360
  }
2312
2361
  }
@@ -4401,9 +4450,12 @@ function createMockUserProfilesRepository(stores) {
4401
4450
  if (!existing) {
4402
4451
  return Promise.reject(new Error(`UserProfile ${id} not found`));
4403
4452
  }
4453
+ const sanitized = Object.fromEntries(
4454
+ Object.entries(data).map(([k, v]) => [k, v === null ? void 0 : v])
4455
+ );
4404
4456
  const updated = {
4405
4457
  ...existing,
4406
- ...data,
4458
+ ...sanitized,
4407
4459
  updatedAt: /* @__PURE__ */ new Date()
4408
4460
  };
4409
4461
  stores.userProfiles.set(id, updated);
@@ -4590,8 +4642,6 @@ function createMockPermissionsRepository(stores) {
4590
4642
  getEffectivePermissions(userProfileId) {
4591
4643
  const tenantId = getTenantId();
4592
4644
  const userRoleIds = Array.from(stores.userRoles.values()).filter((ur) => ur.userProfileId === userProfileId && ur.tenantId === tenantId).map((ur) => ur.roleId);
4593
- const userRoles = Array.from(stores.roles.values()).filter((r) => userRoleIds.includes(r.id));
4594
- const hasAdmin = userRoles.some((r) => _chunkJZO52C3Fjs.isAdminRole.call(void 0, r.name));
4595
4645
  const userPermissions = Array.from(stores.permissions.values()).filter(
4596
4646
  (p) => userRoleIds.includes(p.roleId)
4597
4647
  );
@@ -4618,7 +4668,7 @@ function createMockPermissionsRepository(stores) {
4618
4668
  }
4619
4669
  }
4620
4670
  }
4621
- return Promise.resolve({ isAdmin: hasAdmin, objectPermissions, systemPermissions });
4671
+ return Promise.resolve({ objectPermissions, systemPermissions });
4622
4672
  },
4623
4673
  countUsersWithRole(roleName) {
4624
4674
  const tenantId = getTenantId();
@@ -5636,7 +5686,10 @@ var NON_SORTABLE_TYPES = /* @__PURE__ */ new Set([
5636
5686
  "richtext",
5637
5687
  "file",
5638
5688
  "document",
5639
- "location"
5689
+ "location",
5690
+ "user",
5691
+ "multiselect",
5692
+ "relation"
5640
5693
  ]);
5641
5694
  function isAttributeSortable(attr) {
5642
5695
  return !NON_SORTABLE_TYPES.has(attr.type);
@@ -8371,8 +8424,10 @@ var WorkflowBuilder = class {
8371
8424
  }
8372
8425
  if (node.rows) {
8373
8426
  for (const row of node.rows) {
8374
- for (const field of row.fields) {
8375
- referencedSlots.add(field.slotId);
8427
+ if (isFlowFieldsRow(row)) {
8428
+ for (const field of row.fields) {
8429
+ referencedSlots.add(field.slotId);
8430
+ }
8376
8431
  }
8377
8432
  }
8378
8433
  }
@@ -9867,21 +9922,37 @@ var AuditService = class extends BaseService {
9867
9922
  if (!this.adapter.audit) {
9868
9923
  return;
9869
9924
  }
9925
+ const resolved = await this.resolveActorEmail(entry);
9870
9926
  if (_optionalChain([this, 'access', _183 => _183.options, 'optionalAccess', _184 => _184.async])) {
9871
- this.buffer.push(entry);
9927
+ this.buffer.push(resolved);
9872
9928
  const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
9873
9929
  if (this.buffer.length >= batchSize) {
9874
9930
  await this.flush();
9875
9931
  }
9876
9932
  } else {
9877
- await this.adapter.audit.create(entry);
9933
+ await this.adapter.audit.create(resolved);
9934
+ }
9935
+ }
9936
+ /**
9937
+ * Resolve actorEmail from user profiles if not already set
9938
+ */
9939
+ async resolveActorEmail(entry) {
9940
+ if (!entry.actorEmail && entry.actorId) {
9941
+ try {
9942
+ const profile = await this.adapter.userProfiles.findById(entry.actorId);
9943
+ if (_optionalChain([profile, 'optionalAccess', _185 => _185.email])) {
9944
+ return { ...entry, actorEmail: profile.email };
9945
+ }
9946
+ } catch (e13) {
9947
+ }
9878
9948
  }
9949
+ return entry;
9879
9950
  }
9880
9951
  /**
9881
9952
  * Start the flush timer for async mode
9882
9953
  */
9883
9954
  startFlushTimer() {
9884
- const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _185 => _185.options, 'optionalAccess', _186 => _186.flushIntervalMs]), () => ( 1e3));
9955
+ const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _186 => _186.options, 'optionalAccess', _187 => _187.flushIntervalMs]), () => ( 1e3));
9885
9956
  this.flushTimer = setInterval(() => {
9886
9957
  this.flush().catch(() => {
9887
9958
  });
@@ -9911,13 +9982,13 @@ var browserStub4 = {
9911
9982
  run: (_store, callback) => callback()
9912
9983
  };
9913
9984
  var AsyncLocalStorageClass4 = null;
9914
- if (typeof process !== "undefined" && _optionalChain([process, 'access', _187 => _187.versions, 'optionalAccess', _188 => _188.node])) {
9985
+ if (typeof process !== "undefined" && _optionalChain([process, 'access', _188 => _188.versions, 'optionalAccess', _189 => _189.node])) {
9915
9986
  try {
9916
9987
  if (typeof _chunk3RG5ZIWIjs.__require !== "undefined") {
9917
9988
  const asyncHooks = _chunk3RG5ZIWIjs.__require.call(void 0, "async_hooks");
9918
9989
  AsyncLocalStorageClass4 = asyncHooks.AsyncLocalStorage;
9919
9990
  }
9920
- } catch (e13) {
9991
+ } catch (e14) {
9921
9992
  try {
9922
9993
  const dynamicRequire = new Function(
9923
9994
  "m",
@@ -9927,7 +9998,7 @@ if (typeof process !== "undefined" && _optionalChain([process, 'access', _187 =>
9927
9998
  if (asyncHooks) {
9928
9999
  AsyncLocalStorageClass4 = asyncHooks.AsyncLocalStorage;
9929
10000
  }
9930
- } catch (e14) {
10001
+ } catch (e15) {
9931
10002
  }
9932
10003
  }
9933
10004
  }
@@ -9970,7 +10041,7 @@ var BilateralSyncService = class extends BaseService {
9970
10041
  }
9971
10042
  const ctx = getSyncContext().getStore();
9972
10043
  const syncKey = `${sourceSchema.name}:${sourceRecordId}:${attributeName}`;
9973
- if (_optionalChain([ctx, 'optionalAccess', _189 => _189.syncing, 'access', _190 => _190.has, 'call', _191 => _191(syncKey)])) {
10044
+ if (_optionalChain([ctx, 'optionalAccess', _190 => _190.syncing, 'access', _191 => _191.has, 'call', _192 => _192(syncKey)])) {
9974
10045
  return;
9975
10046
  }
9976
10047
  await this.runWithSyncContext(syncKey, async () => {
@@ -10195,7 +10266,7 @@ var BilateralSyncService = class extends BaseService {
10195
10266
  const storage = getSyncContext();
10196
10267
  const existingCtx = storage.getStore();
10197
10268
  const ctx = {
10198
- syncing: new Set(_nullishCoalesce(_optionalChain([existingCtx, 'optionalAccess', _192 => _192.syncing]), () => ( [])))
10269
+ syncing: new Set(_nullishCoalesce(_optionalChain([existingCtx, 'optionalAccess', _193 => _193.syncing]), () => ( [])))
10199
10270
  };
10200
10271
  ctx.syncing.add(syncKey);
10201
10272
  return await storage.run(ctx, fn);
@@ -10303,7 +10374,7 @@ var UserService = class extends BaseService {
10303
10374
  if (roleErrors.length > 0) {
10304
10375
  errors.push({
10305
10376
  attribute: attrName,
10306
- message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _193 => _193.allowedRoles, 'optionalAccess', _194 => _194.join, 'call', _195 => _195(", ")])}`,
10377
+ message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _194 => _194.allowedRoles, 'optionalAccess', _195 => _195.join, 'call', _196 => _196(", ")])}`,
10307
10378
  invalidIds: roleErrors
10308
10379
  });
10309
10380
  }
@@ -10827,7 +10898,7 @@ var RelationPropertiesService = class extends BaseService {
10827
10898
  }
10828
10899
  }
10829
10900
  }
10830
- const shouldStoreAsInverse = _optionalChain([attribute, 'access', _196 => _196.bilateral, 'optionalAccess', _197 => _197.storageOwner]) === false;
10901
+ const shouldStoreAsInverse = _optionalChain([attribute, 'access', _197 => _197.bilateral, 'optionalAccess', _198 => _198.storageOwner]) === false;
10831
10902
  let storageFromObject = schema.name;
10832
10903
  let storageFromAttribute = attributeName;
10833
10904
  if (shouldStoreAsInverse && attribute.bilateral) {
@@ -10839,7 +10910,7 @@ var RelationPropertiesService = class extends BaseService {
10839
10910
  if (shouldStoreAsInverse) {
10840
10911
  const results = await Promise.all(
10841
10912
  normalized.map(
10842
- (item) => _optionalChain([adapter, 'access', _198 => _198.relationAttributes, 'optionalAccess', _199 => _199.findBySource, 'call', _200 => _200(
10913
+ (item) => _optionalChain([adapter, 'access', _199 => _199.relationAttributes, 'optionalAccess', _200 => _200.findBySource, 'call', _201 => _201(
10843
10914
  storageFromObject,
10844
10915
  item.id,
10845
10916
  storageFromAttribute
@@ -10978,7 +11049,7 @@ var RecordQueryService = class extends BaseService {
10978
11049
  super(adapter);
10979
11050
  this.schemaService = schemaService;
10980
11051
  this.options = options;
10981
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _201 => _201.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _202 => _202.policyRegistry]), () => ( defaultPolicyRegistry));
11052
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _202 => _202.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _203 => _203.policyRegistry]), () => ( defaultPolicyRegistry));
10982
11053
  this.relationPropertiesService = new RelationPropertiesService(adapter);
10983
11054
  }
10984
11055
  // ============================================================================
@@ -11029,12 +11100,12 @@ var RecordQueryService = class extends BaseService {
11029
11100
  * Internal list query execution
11030
11101
  */
11031
11102
  async executeListQuery(schema, objectId, options) {
11032
- if (_optionalChain([this, 'access', _203 => _203.options, 'optionalAccess', _204 => _204.permissionService]) && this.userId) {
11103
+ if (_optionalChain([this, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.permissionService]) && this.userId) {
11033
11104
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
11034
11105
  }
11035
- const policy = _optionalChain([options, 'optionalAccess', _205 => _205.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
11106
+ const policy = _optionalChain([options, 'optionalAccess', _206 => _206.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
11036
11107
  let effectiveOptions = options;
11037
- if (_optionalChain([policy, 'optionalAccess', _206 => _206.applyListFilter]) && this.userId) {
11108
+ if (_optionalChain([policy, 'optionalAccess', _207 => _207.applyListFilter]) && this.userId) {
11038
11109
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
11039
11110
  effectiveOptions = policy.applyListFilter(ctx, options);
11040
11111
  }
@@ -11044,10 +11115,10 @@ var RecordQueryService = class extends BaseService {
11044
11115
  );
11045
11116
  let filteredRecords = result.records;
11046
11117
  let effectiveTotal = result.total;
11047
- if (_optionalChain([policy, 'optionalAccess', _207 => _207.canAccessRecord]) && this.userId) {
11118
+ if (_optionalChain([policy, 'optionalAccess', _208 => _208.canAccessRecord]) && this.userId) {
11048
11119
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
11049
- const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _208 => _208.limit]), () => ( 20));
11050
- const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _209 => _209.offset]), () => ( 0));
11120
+ const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _209 => _209.limit]), () => ( 20));
11121
+ const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _210 => _210.offset]), () => ( 0));
11051
11122
  const overfetchMultiplier = 5;
11052
11123
  const batchSize = requestedLimit * overfetchMultiplier;
11053
11124
  const maxScanRecords = 1e4;
@@ -11069,7 +11140,7 @@ var RecordQueryService = class extends BaseService {
11069
11140
  exhausted = true;
11070
11141
  break;
11071
11142
  }
11072
- const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _210 => _210.canAccessRecord, 'optionalCall', _211 => _211(ctx, record)]));
11143
+ const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _211 => _211.canAccessRecord, 'optionalCall', _212 => _212(ctx, record)]));
11073
11144
  collected.push(...filtered);
11074
11145
  dbOffset += batch.records.length;
11075
11146
  totalScanned += batch.records.length;
@@ -11085,7 +11156,7 @@ var RecordQueryService = class extends BaseService {
11085
11156
  filteredRecords,
11086
11157
  schema
11087
11158
  );
11088
- if (!_optionalChain([options, 'optionalAccess', _212 => _212.skipFormulas])) {
11159
+ if (!_optionalChain([options, 'optionalAccess', _213 => _213.skipFormulas])) {
11089
11160
  return {
11090
11161
  records: enrichRecordsWithFormulas(filteredRecords, schema),
11091
11162
  total: effectiveTotal
@@ -11145,21 +11216,21 @@ var RecordQueryService = class extends BaseService {
11145
11216
  * Internal search query execution
11146
11217
  */
11147
11218
  async executeSearchQuery(schema, objectId, query, options) {
11148
- if (_optionalChain([this, 'access', _213 => _213.options, 'optionalAccess', _214 => _214.permissionService]) && this.userId) {
11219
+ if (_optionalChain([this, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.permissionService]) && this.userId) {
11149
11220
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
11150
11221
  }
11151
11222
  let result;
11152
11223
  if (this.adapter.search) {
11153
11224
  try {
11154
11225
  result = await this.adapter.search.searchRecords(objectId, query, {
11155
- limit: _optionalChain([options, 'optionalAccess', _215 => _215.limit]),
11156
- offset: _optionalChain([options, 'optionalAccess', _216 => _216.offset]),
11157
- sorts: _optionalChain([options, 'optionalAccess', _217 => _217.sorts]),
11158
- filters: _optionalChain([options, 'optionalAccess', _218 => _218.filters]),
11226
+ limit: _optionalChain([options, 'optionalAccess', _216 => _216.limit]),
11227
+ offset: _optionalChain([options, 'optionalAccess', _217 => _217.offset]),
11228
+ sorts: _optionalChain([options, 'optionalAccess', _218 => _218.sorts]),
11229
+ filters: _optionalChain([options, 'optionalAccess', _219 => _219.filters]),
11159
11230
  attributes: schema.attributes
11160
11231
  });
11161
11232
  result = await this.healSearchResults(result);
11162
- } catch (e15) {
11233
+ } catch (e16) {
11163
11234
  result = await runWithSchemaContext(
11164
11235
  [schema],
11165
11236
  () => this.adapter.objectRecords.search(objectId, query, options)
@@ -11175,7 +11246,7 @@ var RecordQueryService = class extends BaseService {
11175
11246
  result.records,
11176
11247
  schema
11177
11248
  );
11178
- if (!_optionalChain([options, 'optionalAccess', _219 => _219.skipFormulas])) {
11249
+ if (!_optionalChain([options, 'optionalAccess', _220 => _220.skipFormulas])) {
11179
11250
  return {
11180
11251
  records: enrichRecordsWithFormulas(enrichedRecords, schema),
11181
11252
  total: result.total
@@ -11384,7 +11455,7 @@ var RelationService = class extends BaseService {
11384
11455
  }
11385
11456
  const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
11386
11457
  const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
11387
- if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _220 => _220.size]) === 0) {
11458
+ if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _221 => _221.size]) === 0) {
11388
11459
  errors.push({
11389
11460
  attribute: attr.name,
11390
11461
  message: `No valid target objects found for ${attr.label}`
@@ -11437,10 +11508,10 @@ var RelationService = class extends BaseService {
11437
11508
  for (const target of targets) {
11438
11509
  try {
11439
11510
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
11440
- if (_optionalChain([objectSchema, 'optionalAccess', _221 => _221.id])) {
11511
+ if (_optionalChain([objectSchema, 'optionalAccess', _222 => _222.id])) {
11441
11512
  objectIds.add(objectSchema.id);
11442
11513
  }
11443
- } catch (e16) {
11514
+ } catch (e17) {
11444
11515
  }
11445
11516
  }
11446
11517
  return objectIds;
@@ -11506,7 +11577,7 @@ var RelationService = class extends BaseService {
11506
11577
  const targetResults = await Promise.all(
11507
11578
  filteredTargets.map(async (target) => {
11508
11579
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
11509
- if (!_optionalChain([objectSchema, 'optionalAccess', _222 => _222.id])) return { options: [], total: 0 };
11580
+ if (!_optionalChain([objectSchema, 'optionalAccess', _223 => _223.id])) return { options: [], total: 0 };
11510
11581
  const objectId = objectSchema.id;
11511
11582
  const result = query ? await queryService.searchRecords(objectId, query, queryOptions) : await queryService.listRecords(objectId, queryOptions);
11512
11583
  const options = await Promise.all(
@@ -11663,8 +11734,8 @@ var RelationService = class extends BaseService {
11663
11734
  continue;
11664
11735
  }
11665
11736
  const attribute = attributeMap.get(attributeId);
11666
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _223 => _223.targets, 'optionalAccess', _224 => _224.find, 'call', _225 => _225((t) => t.object === objectSchema.name)]);
11667
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _226 => _226.displayTemplate]);
11737
+ const targetConfig = _optionalChain([attribute, 'optionalAccess', _224 => _224.targets, 'optionalAccess', _225 => _225.find, 'call', _226 => _226((t) => t.object === objectSchema.name)]);
11738
+ const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _227 => _227.displayTemplate]);
11668
11739
  const label = await this.resolveLabel(record, objectSchema, customTemplate);
11669
11740
  resolved.push({
11670
11741
  _compositeId: compositeId,
@@ -11827,14 +11898,14 @@ var RollupService = class extends BaseService {
11827
11898
  const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
11828
11899
  let sourceObjectId;
11829
11900
  let reverseRelationAttrName;
11830
- if (_optionalChain([sourceSchema, 'optionalAccess', _227 => _227.id])) {
11901
+ if (_optionalChain([sourceSchema, 'optionalAccess', _228 => _228.id])) {
11831
11902
  sourceObjectId = sourceSchema.id;
11832
11903
  const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
11833
11904
  if (attr.type !== "relation") return false;
11834
11905
  const relationConfig = attr;
11835
- return _optionalChain([relationConfig, 'optionalAccess', _228 => _228.targets, 'optionalAccess', _229 => _229.some, 'call', _230 => _230((t) => t.object === schema.name)]);
11906
+ return _optionalChain([relationConfig, 'optionalAccess', _229 => _229.targets, 'optionalAccess', _230 => _230.some, 'call', _231 => _231((t) => t.object === schema.name)]);
11836
11907
  });
11837
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _231 => _231.name]);
11908
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _232 => _232.name]);
11838
11909
  } else {
11839
11910
  const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
11840
11911
  if (!sourceObject) {
@@ -11845,9 +11916,9 @@ var RollupService = class extends BaseService {
11845
11916
  const reverseRelationAttr = sourceAttributes.find((attr) => {
11846
11917
  if (attr.type !== "relation") return false;
11847
11918
  const relationConfig = attr.config;
11848
- return _optionalChain([relationConfig, 'optionalAccess', _232 => _232.targets, 'optionalAccess', _233 => _233.some, 'call', _234 => _234((t) => t.object === schema.name)]);
11919
+ return _optionalChain([relationConfig, 'optionalAccess', _233 => _233.targets, 'optionalAccess', _234 => _234.some, 'call', _235 => _235((t) => t.object === schema.name)]);
11849
11920
  });
11850
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _235 => _235.name]);
11921
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _236 => _236.name]);
11851
11922
  }
11852
11923
  if (!reverseRelationAttrName) {
11853
11924
  return { value: null, recordCount: 0 };
@@ -12103,13 +12174,13 @@ var RollupService = class extends BaseService {
12103
12174
  if (!obj) continue;
12104
12175
  for (const rollupDbAttr of rollupAttrs) {
12105
12176
  const rollupConfig = rollupDbAttr.config;
12106
- if (!_optionalChain([rollupConfig, 'optionalAccess', _236 => _236.relationAttribute])) continue;
12177
+ if (!_optionalChain([rollupConfig, 'optionalAccess', _237 => _237.relationAttribute])) continue;
12107
12178
  const relationAttr = attributes.find(
12108
12179
  (a) => a.type === "relation" && a.name === rollupConfig.relationAttribute
12109
12180
  );
12110
12181
  if (!relationAttr) continue;
12111
12182
  const relationConfig = relationAttr.config;
12112
- const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _237 => _237.targets, 'optionalAccess', _238 => _238.some, 'call', _239 => _239(
12183
+ const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _238 => _238.targets, 'optionalAccess', _239 => _239.some, 'call', _240 => _240(
12113
12184
  (t) => t.object === changedSchema.name
12114
12185
  )]);
12115
12186
  if (!targetsChangedObject) continue;
@@ -12134,11 +12205,11 @@ var RecordService = class extends BaseService {
12134
12205
  constructor(adapter, options) {
12135
12206
  super(adapter);
12136
12207
  this.schemaService = new ObjectSchemaService(adapter, registry, {
12137
- auditService: _optionalChain([options, 'optionalAccess', _240 => _240.auditService])
12208
+ auditService: _optionalChain([options, 'optionalAccess', _241 => _241.auditService])
12138
12209
  });
12139
- this.permissionService = _optionalChain([options, 'optionalAccess', _241 => _241.permissionService]);
12140
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _242 => _242.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12141
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _243 => _243.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.policyRegistry]), () => ( defaultPolicyRegistry));
12210
+ this.permissionService = _optionalChain([options, 'optionalAccess', _242 => _242.permissionService]);
12211
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _243 => _243.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12212
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _244 => _244.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.policyRegistry]), () => ( defaultPolicyRegistry));
12142
12213
  this.recordResolver = new RecordResolverService(adapter);
12143
12214
  this.queryService = new RecordQueryService(adapter, this.schemaService, {
12144
12215
  permissionService: this.permissionService,
@@ -12153,7 +12224,7 @@ var RecordService = class extends BaseService {
12153
12224
  recordResolver: this.recordResolver
12154
12225
  });
12155
12226
  this.userService = new UserService(adapter);
12156
- this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.hookRegistry]), () => ( new NoopHookRegistry()));
12227
+ this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.hookRegistry]), () => ( new NoopHookRegistry()));
12157
12228
  this.bilateralSyncService = new BilateralSyncService(
12158
12229
  adapter,
12159
12230
  this.schemaService,
@@ -12193,25 +12264,25 @@ var RecordService = class extends BaseService {
12193
12264
  schema,
12194
12265
  this.tenantId,
12195
12266
  dataWithDefaults,
12196
- _optionalChain([options, 'optionalAccess', _246 => _246.hookMetadata])
12267
+ _optionalChain([options, 'optionalAccess', _247 => _247.hookMetadata])
12197
12268
  );
12198
- if (!_optionalChain([options, 'optionalAccess', _247 => _247.skipHooks])) {
12269
+ if (!_optionalChain([options, 'optionalAccess', _248 => _248.skipHooks])) {
12199
12270
  await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
12200
12271
  }
12201
12272
  const normalizedData = this.relationPropertiesService.normalizeRelationValuesForStorage(
12202
12273
  schema,
12203
12274
  dataWithDefaults
12204
12275
  );
12205
- if (_optionalChain([options, 'optionalAccess', _248 => _248.validate]) !== false) {
12206
- if (_optionalChain([options, 'optionalAccess', _249 => _249.allowDraft])) {
12276
+ if (_optionalChain([options, 'optionalAccess', _249 => _249.validate]) !== false) {
12277
+ if (_optionalChain([options, 'optionalAccess', _250 => _250.allowDraft])) {
12207
12278
  _chunk3WTK7ESHjs.validateDraftOrThrow.call(void 0, schema, normalizedData);
12208
12279
  } else {
12209
12280
  _chunk3WTK7ESHjs.validateObjectOrThrow.call(void 0, schema, normalizedData);
12210
12281
  }
12211
- if (!_optionalChain([options, 'optionalAccess', _250 => _250.skipRelationValidation])) {
12282
+ if (!_optionalChain([options, 'optionalAccess', _251 => _251.skipRelationValidation])) {
12212
12283
  await this.relationService.validateRelationsOrThrow(schema, normalizedData);
12213
12284
  }
12214
- if (!_optionalChain([options, 'optionalAccess', _251 => _251.skipUserValidation])) {
12285
+ if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipUserValidation])) {
12215
12286
  await this.userService.validateUsersOrThrow(schema, normalizedData);
12216
12287
  }
12217
12288
  }
@@ -12222,12 +12293,12 @@ var RecordService = class extends BaseService {
12222
12293
  data: normalizedData,
12223
12294
  label,
12224
12295
  completionStatus,
12225
- metadata: _optionalChain([options, 'optionalAccess', _252 => _252.metadata]),
12296
+ metadata: _optionalChain([options, 'optionalAccess', _253 => _253.metadata]),
12226
12297
  createdBy: this.userId
12227
12298
  });
12228
12299
  for (const [attrName, value] of Object.entries(dataWithDefaults)) {
12229
12300
  const attr = schema.attributes.find((a) => a.name === attrName);
12230
- if (_optionalChain([attr, 'optionalAccess', _253 => _253.type]) === "relation") {
12301
+ if (_optionalChain([attr, 'optionalAccess', _254 => _254.type]) === "relation") {
12231
12302
  const hasProperties2 = attr.properties !== void 0;
12232
12303
  const isBilateral = isBilateralRelation(attr);
12233
12304
  if (hasProperties2 || isBilateral) {
@@ -12243,7 +12314,7 @@ var RecordService = class extends BaseService {
12243
12314
  }
12244
12315
  for (const [attrName, value] of Object.entries(normalizedData)) {
12245
12316
  const attr = schema.attributes.find((a) => a.name === attrName);
12246
- if (_optionalChain([attr, 'optionalAccess', _254 => _254.type]) === "relation" && isBilateralRelation(attr)) {
12317
+ if (_optionalChain([attr, 'optionalAccess', _255 => _255.type]) === "relation" && isBilateralRelation(attr)) {
12247
12318
  await this.bilateralSyncService.syncBilateralRelation(
12248
12319
  schema,
12249
12320
  record.id,
@@ -12254,7 +12325,7 @@ var RecordService = class extends BaseService {
12254
12325
  );
12255
12326
  }
12256
12327
  }
12257
- if (!_optionalChain([options, 'optionalAccess', _255 => _255.skipHooks])) {
12328
+ if (!_optionalChain([options, 'optionalAccess', _256 => _256.skipHooks])) {
12258
12329
  const afterCtx = {
12259
12330
  ...hookCtx,
12260
12331
  recordId: record.id,
@@ -12264,11 +12335,11 @@ var RecordService = class extends BaseService {
12264
12335
  }
12265
12336
  await recalculateParentRollups(record, schema, this.rollupContext);
12266
12337
  await this.invalidateRecordCaches(record.id, objectId);
12267
- _optionalChain([this, 'access', _256 => _256.adapter, 'access', _257 => _257.search, 'optionalAccess', _258 => _258.indexRecord, 'call', _259 => _259(record, {
12338
+ _optionalChain([this, 'access', _257 => _257.adapter, 'access', _258 => _258.search, 'optionalAccess', _259 => _259.indexRecord, 'call', _260 => _260(record, {
12268
12339
  objectName: schema.name,
12269
12340
  objectLabel: schema.label,
12270
12341
  attributes: schema.attributes
12271
- }), 'access', _260 => _260.catch, 'call', _261 => _261((err) => console.error("[search] Failed to index created record", record.id, err))]);
12342
+ }), 'access', _261 => _261.catch, 'call', _262 => _262((err) => console.error("[search] Failed to index created record", record.id, err))]);
12272
12343
  if (this.auditService && this.userId) {
12273
12344
  this.auditService.logRecordAction({
12274
12345
  action: "record.created",
@@ -12277,7 +12348,7 @@ var RecordService = class extends BaseService {
12277
12348
  objectId: schema.id,
12278
12349
  recordId: record.id,
12279
12350
  recordLabel: record.label,
12280
- metadata: _optionalChain([options, 'optionalAccess', _262 => _262.hookMetadata])
12351
+ metadata: _optionalChain([options, 'optionalAccess', _263 => _263.hookMetadata])
12281
12352
  }).catch(() => {
12282
12353
  });
12283
12354
  }
@@ -12300,7 +12371,7 @@ var RecordService = class extends BaseService {
12300
12371
  return null;
12301
12372
  }
12302
12373
  const schema = await this.schemaService.getObjectSchema(record.objectId);
12303
- if (!_optionalChain([options, 'optionalAccess', _263 => _263.skipPolicyCheck])) {
12374
+ if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipPolicyCheck])) {
12304
12375
  const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
12305
12376
  if (policy) {
12306
12377
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
@@ -12310,11 +12381,11 @@ var RecordService = class extends BaseService {
12310
12381
  }
12311
12382
  }
12312
12383
  let enrichedRecord = record;
12313
- if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipFormulas])) {
12384
+ if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipFormulas])) {
12314
12385
  enrichedRecord = enrichWithFormulas(record, schema);
12315
12386
  }
12316
12387
  enrichedRecord = await this.enrichRelationProperties(enrichedRecord, schema);
12317
- if (_optionalChain([options, 'optionalAccess', _265 => _265.includeSchema])) {
12388
+ if (_optionalChain([options, 'optionalAccess', _266 => _266.includeSchema])) {
12318
12389
  const recordWithSchema = enrichedRecord;
12319
12390
  recordWithSchema.schema = schema;
12320
12391
  return recordWithSchema;
@@ -12364,7 +12435,7 @@ var RecordService = class extends BaseService {
12364
12435
  if (oldVal !== null && newVal !== null && typeof oldVal === "object" && typeof newVal === "object") {
12365
12436
  try {
12366
12437
  return JSON.stringify(oldVal) !== JSON.stringify(newVal);
12367
- } catch (e17) {
12438
+ } catch (e18) {
12368
12439
  return true;
12369
12440
  }
12370
12441
  }
@@ -12376,9 +12447,9 @@ var RecordService = class extends BaseService {
12376
12447
  existing,
12377
12448
  mergedData,
12378
12449
  changedAttributes,
12379
- _optionalChain([options, 'optionalAccess', _266 => _266.hookMetadata])
12450
+ _optionalChain([options, 'optionalAccess', _267 => _267.hookMetadata])
12380
12451
  );
12381
- if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipHooks])) {
12452
+ if (!_optionalChain([options, 'optionalAccess', _268 => _268.skipHooks])) {
12382
12453
  await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
12383
12454
  }
12384
12455
  const hookModifiedValues = {};
@@ -12393,16 +12464,16 @@ var RecordService = class extends BaseService {
12393
12464
  dataToUpdate
12394
12465
  );
12395
12466
  const normalizedMergedData = { ...existing.values, ...normalizedUpdate };
12396
- if (_optionalChain([options, 'optionalAccess', _268 => _268.validate]) !== false) {
12397
- if (_optionalChain([options, 'optionalAccess', _269 => _269.partial])) {
12467
+ if (_optionalChain([options, 'optionalAccess', _269 => _269.validate]) !== false) {
12468
+ if (_optionalChain([options, 'optionalAccess', _270 => _270.partial])) {
12398
12469
  _chunk3WTK7ESHjs.validateDraftOrThrow.call(void 0, schema, normalizedMergedData);
12399
12470
  } else {
12400
12471
  _chunk3WTK7ESHjs.validateObjectOrThrow.call(void 0, schema, normalizedMergedData);
12401
12472
  }
12402
- if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipRelationValidation])) {
12473
+ if (!_optionalChain([options, 'optionalAccess', _271 => _271.skipRelationValidation])) {
12403
12474
  await this.relationService.validateRelationsOrThrow(schema, normalizedUpdate);
12404
12475
  }
12405
- if (!_optionalChain([options, 'optionalAccess', _271 => _271.skipUserValidation])) {
12476
+ if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipUserValidation])) {
12406
12477
  await this.userService.validateUsersOrThrow(schema, normalizedUpdate);
12407
12478
  }
12408
12479
  }
@@ -12415,7 +12486,7 @@ var RecordService = class extends BaseService {
12415
12486
  __lastUpdatedBy: this.userId,
12416
12487
  __expectedUpdatedAt: existing.updatedAt instanceof Date ? existing.updatedAt.toISOString() : existing.updatedAt
12417
12488
  };
12418
- if (_optionalChain([options, 'optionalAccess', _272 => _272.metadata]) !== void 0) {
12489
+ if (_optionalChain([options, 'optionalAccess', _273 => _273.metadata]) !== void 0) {
12419
12490
  const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
12420
12491
  const mergedMetadata = { ...existingMetadata, ...options.metadata };
12421
12492
  const cleanedMetadata = Object.fromEntries(
@@ -12426,20 +12497,20 @@ var RecordService = class extends BaseService {
12426
12497
  const bilateralOldValues = {};
12427
12498
  for (const attrName of Object.keys(normalizedUpdate)) {
12428
12499
  const attr = schema.attributes.find((a) => a.name === attrName);
12429
- if (_optionalChain([attr, 'optionalAccess', _273 => _273.type]) === "relation" && isBilateralRelation(attr)) {
12500
+ if (_optionalChain([attr, 'optionalAccess', _274 => _274.type]) === "relation" && isBilateralRelation(attr)) {
12430
12501
  bilateralOldValues[attrName] = existing.values[attrName];
12431
12502
  }
12432
12503
  }
12433
12504
  const updated = await this.adapter.objectRecords.update(recordId, updatePayload);
12434
12505
  await this.invalidateRecordCaches(recordId, existing.objectId);
12435
- _optionalChain([this, 'access', _274 => _274.adapter, 'access', _275 => _275.search, 'optionalAccess', _276 => _276.indexRecord, 'call', _277 => _277(updated, {
12506
+ _optionalChain([this, 'access', _275 => _275.adapter, 'access', _276 => _276.search, 'optionalAccess', _277 => _277.indexRecord, 'call', _278 => _278(updated, {
12436
12507
  objectName: schema.name,
12437
12508
  objectLabel: schema.label,
12438
12509
  attributes: schema.attributes
12439
- }), 'access', _278 => _278.catch, 'call', _279 => _279((err) => console.error("[search] Failed to index updated record", updated.id, err))]);
12510
+ }), 'access', _279 => _279.catch, 'call', _280 => _280((err) => console.error("[search] Failed to index updated record", updated.id, err))]);
12440
12511
  for (const [attrName, value] of Object.entries(dataToUpdate)) {
12441
12512
  const attr = schema.attributes.find((a) => a.name === attrName);
12442
- if (_optionalChain([attr, 'optionalAccess', _280 => _280.type]) === "relation") {
12513
+ if (_optionalChain([attr, 'optionalAccess', _281 => _281.type]) === "relation") {
12443
12514
  const hasProperties2 = attr.properties !== void 0;
12444
12515
  const isBilateral = isBilateralRelation(attr);
12445
12516
  if (hasProperties2 || isBilateral) {
@@ -12455,7 +12526,7 @@ var RecordService = class extends BaseService {
12455
12526
  }
12456
12527
  for (const [attrName, value] of Object.entries(normalizedUpdate)) {
12457
12528
  const attr = schema.attributes.find((a) => a.name === attrName);
12458
- if (_optionalChain([attr, 'optionalAccess', _281 => _281.type]) === "relation" && isBilateralRelation(attr)) {
12529
+ if (_optionalChain([attr, 'optionalAccess', _282 => _282.type]) === "relation" && isBilateralRelation(attr)) {
12459
12530
  const oldValue = bilateralOldValues[attrName];
12460
12531
  await this.bilateralSyncService.syncBilateralRelation(
12461
12532
  schema,
@@ -12466,7 +12537,7 @@ var RecordService = class extends BaseService {
12466
12537
  );
12467
12538
  }
12468
12539
  }
12469
- if (!_optionalChain([options, 'optionalAccess', _282 => _282.skipHooks])) {
12540
+ if (!_optionalChain([options, 'optionalAccess', _283 => _283.skipHooks])) {
12470
12541
  const afterCtx = {
12471
12542
  ...hookCtx,
12472
12543
  record: updated
@@ -12481,7 +12552,7 @@ var RecordService = class extends BaseService {
12481
12552
  if (this.auditService && this.userId && allChangedAttributes.length > 0) {
12482
12553
  const changes = allChangedAttributes.map((attr) => ({
12483
12554
  field: attr,
12484
- oldValue: _optionalChain([hookCtx, 'access', _283 => _283.oldValues, 'optionalAccess', _284 => _284[attr]]),
12555
+ oldValue: _optionalChain([hookCtx, 'access', _284 => _284.oldValues, 'optionalAccess', _285 => _285[attr]]),
12485
12556
  newValue: hookCtx.newValues[attr]
12486
12557
  }));
12487
12558
  this.auditService.logRecordAction({
@@ -12492,7 +12563,7 @@ var RecordService = class extends BaseService {
12492
12563
  recordId: updated.id,
12493
12564
  recordLabel: updated.label,
12494
12565
  changes,
12495
- metadata: _optionalChain([options, 'optionalAccess', _285 => _285.hookMetadata])
12566
+ metadata: _optionalChain([options, 'optionalAccess', _286 => _286.hookMetadata])
12496
12567
  }).catch(() => {
12497
12568
  });
12498
12569
  }
@@ -12524,17 +12595,17 @@ var RecordService = class extends BaseService {
12524
12595
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
12525
12596
  checkRecordDeleteOrThrow(policy, record, ctx);
12526
12597
  }
12527
- if (_optionalChain([options, 'optionalAccess', _286 => _286.checkSystem]) && schema.system) {
12598
+ if (_optionalChain([options, 'optionalAccess', _287 => _287.checkSystem]) && schema.system) {
12528
12599
  throw new ProtectedResourceError("object", schema.name, "delete");
12529
12600
  }
12530
- if (!_optionalChain([options, 'optionalAccess', _287 => _287.skipReferenceCheck])) {
12601
+ if (!_optionalChain([options, 'optionalAccess', _288 => _288.skipReferenceCheck])) {
12531
12602
  const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
12532
12603
  if (references.length > 0) {
12533
12604
  throw new RecordReferencedError(recordId, references);
12534
12605
  }
12535
12606
  }
12536
- const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _288 => _288.hookMetadata]));
12537
- if (!_optionalChain([options, 'optionalAccess', _289 => _289.skipHooks])) {
12607
+ const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _289 => _289.hookMetadata]));
12608
+ if (!_optionalChain([options, 'optionalAccess', _290 => _290.skipHooks])) {
12538
12609
  await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
12539
12610
  }
12540
12611
  for (const attr of schema.attributes) {
@@ -12552,8 +12623,8 @@ var RecordService = class extends BaseService {
12552
12623
  }
12553
12624
  await this.adapter.objectRecords.delete(recordId);
12554
12625
  await this.invalidateRecordCaches(recordId, record.objectId);
12555
- _optionalChain([this, 'access', _290 => _290.adapter, 'access', _291 => _291.search, 'optionalAccess', _292 => _292.removeRecord, 'call', _293 => _293(recordId), 'access', _294 => _294.catch, 'call', _295 => _295((err) => console.error("[search] Failed to remove deleted record", recordId, err))]);
12556
- if (!_optionalChain([options, 'optionalAccess', _296 => _296.skipHooks])) {
12626
+ _optionalChain([this, 'access', _291 => _291.adapter, 'access', _292 => _292.search, 'optionalAccess', _293 => _293.removeRecord, 'call', _294 => _294(recordId), 'access', _295 => _295.catch, 'call', _296 => _296((err) => console.error("[search] Failed to remove deleted record", recordId, err))]);
12627
+ if (!_optionalChain([options, 'optionalAccess', _297 => _297.skipHooks])) {
12557
12628
  await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
12558
12629
  }
12559
12630
  await recalculateParentRollups(record, schema, this.rollupContext);
@@ -12565,7 +12636,7 @@ var RecordService = class extends BaseService {
12565
12636
  objectId: schema.id,
12566
12637
  recordId: record.id,
12567
12638
  recordLabel: record.label,
12568
- metadata: _optionalChain([options, 'optionalAccess', _297 => _297.hookMetadata])
12639
+ metadata: _optionalChain([options, 'optionalAccess', _298 => _298.hookMetadata])
12569
12640
  }).catch(() => {
12570
12641
  });
12571
12642
  }
@@ -12626,18 +12697,18 @@ var RecordService = class extends BaseService {
12626
12697
  this.tenantId
12627
12698
  );
12628
12699
  await checkPermission(this.permissionService, this.userId, schema.name, "update");
12629
- const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _298 => _298.hookMetadata]));
12630
- if (!_optionalChain([options, 'optionalAccess', _299 => _299.skipHooks])) {
12700
+ const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _299 => _299.hookMetadata]));
12701
+ if (!_optionalChain([options, 'optionalAccess', _300 => _300.skipHooks])) {
12631
12702
  await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
12632
12703
  }
12633
12704
  const restored = await this.adapter.objectRecords.restore(recordId);
12634
12705
  await this.invalidateRecordCaches(recordId, record.objectId);
12635
- _optionalChain([this, 'access', _300 => _300.adapter, 'access', _301 => _301.search, 'optionalAccess', _302 => _302.indexRecord, 'call', _303 => _303(restored, {
12706
+ _optionalChain([this, 'access', _301 => _301.adapter, 'access', _302 => _302.search, 'optionalAccess', _303 => _303.indexRecord, 'call', _304 => _304(restored, {
12636
12707
  objectName: schema.name,
12637
12708
  objectLabel: schema.label,
12638
12709
  attributes: schema.attributes
12639
- }), 'access', _304 => _304.catch, 'call', _305 => _305((err) => console.error("[search] Failed to index restored record", restored.id, err))]);
12640
- if (!_optionalChain([options, 'optionalAccess', _306 => _306.skipHooks])) {
12710
+ }), 'access', _305 => _305.catch, 'call', _306 => _306((err) => console.error("[search] Failed to index restored record", restored.id, err))]);
12711
+ if (!_optionalChain([options, 'optionalAccess', _307 => _307.skipHooks])) {
12641
12712
  const afterCtx = {
12642
12713
  ...hookCtx,
12643
12714
  record: restored
@@ -12652,7 +12723,7 @@ var RecordService = class extends BaseService {
12652
12723
  objectId: schema.id,
12653
12724
  recordId: restored.id,
12654
12725
  recordLabel: restored.label,
12655
- metadata: _optionalChain([options, 'optionalAccess', _307 => _307.hookMetadata])
12726
+ metadata: _optionalChain([options, 'optionalAccess', _308 => _308.hookMetadata])
12656
12727
  }).catch(() => {
12657
12728
  });
12658
12729
  }
@@ -13083,7 +13154,7 @@ var DocumentRendererService = class {
13083
13154
  throw new StorageDownloadNotSupportedError();
13084
13155
  }
13085
13156
  let storagePath = fileId;
13086
- if (_optionalChain([this, 'access', _308 => _308.options, 'optionalAccess', _309 => _309.filesRepository])) {
13157
+ if (_optionalChain([this, 'access', _309 => _309.options, 'optionalAccess', _310 => _310.filesRepository])) {
13087
13158
  const file2 = await this.options.filesRepository.findById(fileId);
13088
13159
  if (!file2) {
13089
13160
  throw new Error(`Template file not found: ${fileId}`);
@@ -13101,8 +13172,8 @@ var DocumentRendererService = class {
13101
13172
  for (const field of fields) {
13102
13173
  const rawValue = getContextValue(context, field.contextPath);
13103
13174
  const attrInfo = await this.getAttributeInfo(field.contextPath, workflow2);
13104
- if (_optionalChain([attrInfo, 'optionalAccess', _310 => _310.attribute])) {
13105
- if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access', _311 => _311.options, 'optionalAccess', _312 => _312.relationService])) {
13175
+ if (_optionalChain([attrInfo, 'optionalAccess', _311 => _311.attribute])) {
13176
+ if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.relationService])) {
13106
13177
  const ids = Array.isArray(rawValue) ? rawValue : [rawValue];
13107
13178
  const stringIds = ids.filter((id) => typeof id === "string");
13108
13179
  if (stringIds.length > 0) {
@@ -13123,7 +13194,7 @@ var DocumentRendererService = class {
13123
13194
  resolved.set(field.id, this.formatValueSimple(rawValue, field.fallback));
13124
13195
  }
13125
13196
  }
13126
- if (relationBatch.length > 0 && _optionalChain([this, 'access', _313 => _313.options, 'optionalAccess', _314 => _314.relationService])) {
13197
+ if (relationBatch.length > 0 && _optionalChain([this, 'access', _314 => _314.options, 'optionalAccess', _315 => _315.relationService])) {
13127
13198
  try {
13128
13199
  const batchResult = await this.options.relationService.resolveIdsBatch(
13129
13200
  relationBatch.map((r) => ({ attributeId: r.attributeId, ids: r.ids }))
@@ -13132,12 +13203,12 @@ var DocumentRendererService = class {
13132
13203
  const options = _nullishCoalesce(batchResult[attributeId], () => ( []));
13133
13204
  const labels = options.map((o) => o.label);
13134
13205
  const field = fields.find((f) => f.id === fieldId);
13135
- resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess', _315 => _315.fallback]) || "");
13206
+ resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess', _316 => _316.fallback]) || "");
13136
13207
  }
13137
- } catch (e18) {
13208
+ } catch (e19) {
13138
13209
  for (const { fieldId, ids } of relationBatch) {
13139
13210
  const field = fields.find((f) => f.id === fieldId);
13140
- resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess', _316 => _316.fallback]) || "");
13211
+ resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess', _317 => _317.fallback]) || "");
13141
13212
  }
13142
13213
  }
13143
13214
  }
@@ -13148,7 +13219,7 @@ var DocumentRendererService = class {
13148
13219
  * Parses paths like "slots.client.firstName" to find the attribute definition
13149
13220
  */
13150
13221
  async getAttributeInfo(contextPath, workflow2) {
13151
- const schemaService = _optionalChain([this, 'access', _317 => _317.options, 'optionalAccess', _318 => _318.schemaService]);
13222
+ const schemaService = _optionalChain([this, 'access', _318 => _318.options, 'optionalAccess', _319 => _319.schemaService]);
13152
13223
  if (!schemaService) {
13153
13224
  return null;
13154
13225
  }
@@ -13161,7 +13232,7 @@ var DocumentRendererService = class {
13161
13232
  }
13162
13233
  const slotId = parts[1];
13163
13234
  const attributeName = parts[2];
13164
- const slot = _optionalChain([workflow2, 'access', _319 => _319.slots, 'optionalAccess', _320 => _320.find, 'call', _321 => _321((s) => s.id === slotId)]);
13235
+ const slot = _optionalChain([workflow2, 'access', _320 => _320.slots, 'optionalAccess', _321 => _321.find, 'call', _322 => _322((s) => s.id === slotId)]);
13165
13236
  if (!slot) {
13166
13237
  return null;
13167
13238
  }
@@ -13170,7 +13241,7 @@ var DocumentRendererService = class {
13170
13241
  try {
13171
13242
  schema = await schemaService.getObjectSchemaByName(slot.objectName);
13172
13243
  this.schemaCache.set(slot.objectName, schema);
13173
- } catch (e19) {
13244
+ } catch (e20) {
13174
13245
  return null;
13175
13246
  }
13176
13247
  }
@@ -13360,7 +13431,7 @@ var DocumentProcessingHook = class extends BaseService {
13360
13431
  const pendingIds = [];
13361
13432
  for (const [nodeId, doc] of Object.entries(context.documents)) {
13362
13433
  const metadata = doc.metadata;
13363
- if (_optionalChain([metadata, 'optionalAccess', _322 => _322.status]) === "pending") {
13434
+ if (_optionalChain([metadata, 'optionalAccess', _323 => _323.status]) === "pending") {
13364
13435
  pendingIds.push(nodeId);
13365
13436
  }
13366
13437
  }
@@ -13411,12 +13482,12 @@ var DocumentProcessingHook = class extends BaseService {
13411
13482
  }
13412
13483
  for (const slotId of targetSlotIds) {
13413
13484
  try {
13414
- const recordId = _optionalChain([context, 'access', _323 => _323.createdRecordIds, 'optionalAccess', _324 => _324[slotId]]);
13485
+ const recordId = _optionalChain([context, 'access', _324 => _324.createdRecordIds, 'optionalAccess', _325 => _325[slotId]]);
13415
13486
  if (!recordId) {
13416
13487
  continue;
13417
13488
  }
13418
- const slotDef = _optionalChain([workflow2, 'access', _325 => _325.slots, 'optionalAccess', _326 => _326.find, 'call', _327 => _327((s) => s.id === slotId)]);
13419
- const objectName = _optionalChain([slotDef, 'optionalAccess', _328 => _328.objectName]);
13489
+ const slotDef = _optionalChain([workflow2, 'access', _326 => _326.slots, 'optionalAccess', _327 => _327.find, 'call', _328 => _328((s) => s.id === slotId)]);
13490
+ const objectName = _optionalChain([slotDef, 'optionalAccess', _329 => _329.objectName]);
13420
13491
  if (!objectName) {
13421
13492
  continue;
13422
13493
  }
@@ -13433,14 +13504,14 @@ var DocumentProcessingHook = class extends BaseService {
13433
13504
  attachedDocumentIds.push(result.document.id);
13434
13505
  const record = await recordService.getRecord(recordId);
13435
13506
  if (record) {
13436
- const attachments = _nullishCoalesce(_optionalChain([record, 'access', _329 => _329.values, 'optionalAccess', _330 => _330.attachments]), () => ( []));
13507
+ const attachments = _nullishCoalesce(_optionalChain([record, 'access', _330 => _330.values, 'optionalAccess', _331 => _331.attachments]), () => ( []));
13437
13508
  await recordService.updateRecord(
13438
13509
  recordId,
13439
13510
  { attachments: [...attachments, result.document.id] },
13440
13511
  { partial: true }
13441
13512
  );
13442
13513
  }
13443
- } catch (e20) {
13514
+ } catch (e21) {
13444
13515
  }
13445
13516
  }
13446
13517
  return attachedDocumentIds;
@@ -13699,7 +13770,7 @@ var WorkflowAccessGrantService = class extends BaseService {
13699
13770
  * Check if a specific token has been revoked.
13700
13771
  */
13701
13772
  isTokenRevoked(dbGrant, jti) {
13702
- return _nullishCoalesce(_optionalChain([dbGrant, 'access', _331 => _331.revoked_token_jtis, 'optionalAccess', _332 => _332.includes, 'call', _333 => _333(jti)]), () => ( false));
13773
+ return _nullishCoalesce(_optionalChain([dbGrant, 'access', _332 => _332.revoked_token_jtis, 'optionalAccess', _333 => _333.includes, 'call', _334 => _334(jti)]), () => ( false));
13703
13774
  }
13704
13775
  /**
13705
13776
  * Validate access token payload against the grant.
@@ -13751,10 +13822,10 @@ var WorkflowInstanceService = class extends BaseService {
13751
13822
  constructor(adapter, workflowService, options) {
13752
13823
  super(adapter);
13753
13824
  this.workflowService = workflowService;
13754
- this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _334 => _334.executorRegistry]), () => ( getDefaultExecutorRegistry()));
13755
- this.schemaService = _optionalChain([options, 'optionalAccess', _335 => _335.schemaService]);
13756
- this.recordService = _optionalChain([options, 'optionalAccess', _336 => _336.recordService]);
13757
- this.documentProcessingHook = _optionalChain([options, 'optionalAccess', _337 => _337.documentProcessingHook]);
13825
+ this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _335 => _335.executorRegistry]), () => ( getDefaultExecutorRegistry()));
13826
+ this.schemaService = _optionalChain([options, 'optionalAccess', _336 => _336.schemaService]);
13827
+ this.recordService = _optionalChain([options, 'optionalAccess', _337 => _337.recordService]);
13828
+ this.documentProcessingHook = _optionalChain([options, 'optionalAccess', _338 => _338.documentProcessingHook]);
13758
13829
  }
13759
13830
  /**
13760
13831
  * Start a new workflow instance
@@ -13936,7 +14007,7 @@ var WorkflowInstanceService = class extends BaseService {
13936
14007
  if (!this.adapter.workflowInstances) {
13937
14008
  return { instances: [], total: 0 };
13938
14009
  }
13939
- if (_optionalChain([options, 'optionalAccess', _338 => _338.workflowName])) {
14010
+ if (_optionalChain([options, 'optionalAccess', _339 => _339.workflowName])) {
13940
14011
  const allDbInstances = await this.adapter.workflowInstances.findByWorkflowName(
13941
14012
  options.workflowName,
13942
14013
  { status: options.status }
@@ -13950,11 +14021,11 @@ var WorkflowInstanceService = class extends BaseService {
13950
14021
  return { instances: instances2, total: total2 };
13951
14022
  }
13952
14023
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
13953
- limit: _optionalChain([options, 'optionalAccess', _339 => _339.limit]),
13954
- offset: _optionalChain([options, 'optionalAccess', _340 => _340.offset])
14024
+ limit: _optionalChain([options, 'optionalAccess', _340 => _340.limit]),
14025
+ offset: _optionalChain([options, 'optionalAccess', _341 => _341.offset])
13955
14026
  });
13956
14027
  let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
13957
- if (_optionalChain([options, 'optionalAccess', _341 => _341.status])) {
14028
+ if (_optionalChain([options, 'optionalAccess', _342 => _342.status])) {
13958
14029
  instances = instances.filter((i) => i.status === options.status);
13959
14030
  }
13960
14031
  instances = await this.markExpiredInstances(instances);
@@ -13975,9 +14046,9 @@ var WorkflowInstanceService = class extends BaseService {
13975
14046
  return { instances: [], total: 0 };
13976
14047
  }
13977
14048
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
13978
- status: _optionalChain([options, 'optionalAccess', _342 => _342.status]),
13979
- limit: _optionalChain([options, 'optionalAccess', _343 => _343.limit]),
13980
- offset: _optionalChain([options, 'optionalAccess', _344 => _344.offset])
14049
+ status: _optionalChain([options, 'optionalAccess', _343 => _343.status]),
14050
+ limit: _optionalChain([options, 'optionalAccess', _344 => _344.limit]),
14051
+ offset: _optionalChain([options, 'optionalAccess', _345 => _345.offset])
13981
14052
  });
13982
14053
  const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
13983
14054
  return { instances, total };
@@ -14043,13 +14114,13 @@ var WorkflowInstanceService = class extends BaseService {
14043
14114
  try {
14044
14115
  const schemas = await Promise.all(
14045
14116
  current.workflowSnapshot.slots.map(
14046
- (slot) => _optionalChain([this, 'access', _345 => _345.schemaService, 'optionalAccess', _346 => _346.getObjectSchemaByName, 'call', _347 => _347(slot.objectName)])
14117
+ (slot) => _optionalChain([this, 'access', _346 => _346.schemaService, 'optionalAccess', _347 => _347.getObjectSchemaByName, 'call', _348 => _348(slot.objectName)])
14047
14118
  )
14048
14119
  );
14049
14120
  objectDefinitions = schemas.filter(
14050
14121
  (s) => s !== void 0
14051
14122
  );
14052
- } catch (e21) {
14123
+ } catch (e22) {
14053
14124
  }
14054
14125
  }
14055
14126
  const executorContext = {
@@ -14308,9 +14379,9 @@ var WorkflowInstanceService = class extends BaseService {
14308
14379
  */
14309
14380
  async snapshotRecord(recordId) {
14310
14381
  try {
14311
- const record = await _optionalChain([this, 'access', _348 => _348.recordService, 'optionalAccess', _349 => _349.getRecord, 'call', _350 => _350(recordId, { skipPolicyCheck: true })]);
14312
- return _optionalChain([record, 'optionalAccess', _351 => _351.values]);
14313
- } catch (e22) {
14382
+ const record = await _optionalChain([this, 'access', _349 => _349.recordService, 'optionalAccess', _350 => _350.getRecord, 'call', _351 => _351(recordId, { skipPolicyCheck: true })]);
14383
+ return _optionalChain([record, 'optionalAccess', _352 => _352.values]);
14384
+ } catch (e23) {
14314
14385
  return void 0;
14315
14386
  }
14316
14387
  }
@@ -14328,18 +14399,18 @@ var WorkflowInstanceService = class extends BaseService {
14328
14399
  for (const op of [...operations].reverse()) {
14329
14400
  try {
14330
14401
  if (op.operation === "create") {
14331
- await _optionalChain([this, 'access', _352 => _352.recordService, 'optionalAccess', _353 => _353.deleteRecord, 'call', _354 => _354(op.recordId, {
14402
+ await _optionalChain([this, 'access', _353 => _353.recordService, 'optionalAccess', _354 => _354.deleteRecord, 'call', _355 => _355(op.recordId, {
14332
14403
  skipHooks: true,
14333
14404
  skipReferenceCheck: true
14334
14405
  })]);
14335
14406
  rolledBack.push(op.slotId);
14336
14407
  } else if (op.operation === "update" && op.previousData) {
14337
- await _optionalChain([this, 'access', _355 => _355.recordService, 'optionalAccess', _356 => _356.updateRecord, 'call', _357 => _357(op.recordId, op.previousData, {
14408
+ await _optionalChain([this, 'access', _356 => _356.recordService, 'optionalAccess', _357 => _357.updateRecord, 'call', _358 => _358(op.recordId, op.previousData, {
14338
14409
  partial: false
14339
14410
  })]);
14340
14411
  rolledBack.push(op.slotId);
14341
14412
  }
14342
- } catch (e23) {
14413
+ } catch (e24) {
14343
14414
  }
14344
14415
  }
14345
14416
  return rolledBack;
@@ -14458,7 +14529,7 @@ var WorkflowInstanceService = class extends BaseService {
14458
14529
  if (!this.adapter.workflowInstances) {
14459
14530
  return;
14460
14531
  }
14461
- const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _358 => _358.context, 'access', _359 => _359.variables, 'optionalAccess', _360 => _360.__version]), () => ( 0));
14532
+ const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _359 => _359.context, 'access', _360 => _360.variables, 'optionalAccess', _361 => _361.__version]), () => ( 0));
14462
14533
  const nextVersion = currentVersion + 1;
14463
14534
  const instanceWithVersion = {
14464
14535
  ...instance,
@@ -14739,7 +14810,7 @@ var WorkflowRelationService = class extends BaseService {
14739
14810
  if (attr.type !== "relation") continue;
14740
14811
  for (const slot of slots) {
14741
14812
  const slotData = context.slots[slot.id];
14742
- const slotRecordId = _optionalChain([slotData, 'optionalAccess', _361 => _361.id]);
14813
+ const slotRecordId = _optionalChain([slotData, 'optionalAccess', _362 => _362.id]);
14743
14814
  if (!slotRecordId) continue;
14744
14815
  const targetsSlotObject = attr.targets.some(
14745
14816
  (t) => t.object === slot.objectName
@@ -14807,7 +14878,7 @@ var WorkflowService = class extends BaseService {
14807
14878
  if (Array.isArray(options)) {
14808
14879
  this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
14809
14880
  } else {
14810
- this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _362 => _362.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
14881
+ this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _363 => _363.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
14811
14882
  }
14812
14883
  }
14813
14884
  // ============================================================================
@@ -15105,7 +15176,7 @@ var WorkflowService = class extends BaseService {
15105
15176
  var UserProfileService = class extends BaseService {
15106
15177
  constructor(adapter, options) {
15107
15178
  super(adapter);
15108
- this.auditService = _optionalChain([options, 'optionalAccess', _363 => _363.auditService]);
15179
+ this.auditService = _optionalChain([options, 'optionalAccess', _364 => _364.auditService]);
15109
15180
  }
15110
15181
  // ============================================================================
15111
15182
  // CACHE MANAGEMENT
@@ -15123,6 +15194,74 @@ var UserProfileService = class extends BaseService {
15123
15194
  await this.invalidateCache(cacheKeys.userProfileByEmail(this.tenantId, email));
15124
15195
  }
15125
15196
  }
15197
+ // ============================================================================
15198
+ // AVATAR URL RESOLUTION
15199
+ // ============================================================================
15200
+ /**
15201
+ * Resolve avatar storage path to a signed URL.
15202
+ * External URLs (https://) pass through unchanged.
15203
+ * Storage paths are resolved to fresh signed URLs (1h expiry).
15204
+ */
15205
+ async resolveAvatarUrl(profile) {
15206
+ if (!profile.avatarUrl || profile.avatarUrl.startsWith("https://")) {
15207
+ return profile;
15208
+ }
15209
+ if (!this.adapter.storage) return profile;
15210
+ try {
15211
+ const signedUrl = await this.adapter.storage.getSignedUrl(profile.avatarUrl, {
15212
+ expiresIn: 3600
15213
+ });
15214
+ return { ...profile, avatarUrl: signedUrl };
15215
+ } catch (e25) {
15216
+ return profile;
15217
+ }
15218
+ }
15219
+ async resolveAvatarUrls(profiles) {
15220
+ return Promise.all(profiles.map((p) => this.resolveAvatarUrl(p)));
15221
+ }
15222
+ // ============================================================================
15223
+ // AVATAR MANAGEMENT
15224
+ // ============================================================================
15225
+ /**
15226
+ * Upload a new avatar for the user.
15227
+ * Deletes previous avatar from storage if it was an internal upload.
15228
+ * Stores the storagePath — resolved to signed URL at read time.
15229
+ */
15230
+ async uploadAvatar(profileId, input) {
15231
+ if (!this.adapter.storage) {
15232
+ throw new Error("StorageAdapter is not configured.");
15233
+ }
15234
+ if (!input.mimeType.startsWith("image/")) {
15235
+ throw new Error("Only image files are allowed for avatars.");
15236
+ }
15237
+ const profile = await this.getProfileOrThrow(profileId);
15238
+ if (profile.avatarUrl && !profile.avatarUrl.startsWith("https://")) {
15239
+ await this.adapter.storage.delete(profile.avatarUrl).catch(() => void 0);
15240
+ }
15241
+ const result = await this.adapter.storage.upload({
15242
+ content: input.content,
15243
+ fileName: input.fileName,
15244
+ mimeType: input.mimeType,
15245
+ size: input.size,
15246
+ tenantId: this.tenantId,
15247
+ folderPath: "avatars"
15248
+ });
15249
+ return await this.updateProfile(profileId, { avatarUrl: result.storagePath });
15250
+ }
15251
+ /**
15252
+ * Delete the user's avatar.
15253
+ * Removes file from storage if it was an internal upload, then clears avatarUrl.
15254
+ */
15255
+ async deleteAvatar(profileId) {
15256
+ const profile = await this.getProfileOrThrow(profileId);
15257
+ if (profile.avatarUrl && !profile.avatarUrl.startsWith("https://")) {
15258
+ await _optionalChain([this, 'access', _365 => _365.adapter, 'access', _366 => _366.storage, 'optionalAccess', _367 => _367.delete, 'call', _368 => _368(profile.avatarUrl), 'access', _369 => _369.catch, 'call', _370 => _370(() => void 0)]);
15259
+ }
15260
+ return await this.updateProfile(profileId, { avatarUrl: null });
15261
+ }
15262
+ // ============================================================================
15263
+ // CREATE
15264
+ // ============================================================================
15126
15265
  /**
15127
15266
  * Create a new user profile (typically after first auth).
15128
15267
  * Automatically uses tenant context from AsyncLocalStorage.
@@ -15163,18 +15302,19 @@ var UserProfileService = class extends BaseService {
15163
15302
  targetUserEmail: profile.email
15164
15303
  });
15165
15304
  }
15166
- return profile;
15305
+ return this.resolveAvatarUrl(profile);
15167
15306
  }
15168
15307
  /**
15169
15308
  * Get user profile by ID.
15170
15309
  * Results are cached if a CacheAdapter is configured.
15171
15310
  */
15172
15311
  async getProfile(profileId) {
15173
- return this.cachedBy(
15312
+ const profile = await this.cachedBy(
15174
15313
  "userProfileById",
15175
15314
  profileId,
15176
15315
  () => this.adapter.userProfiles.findById(profileId)
15177
15316
  );
15317
+ return profile ? this.resolveAvatarUrl(profile) : null;
15178
15318
  }
15179
15319
  /**
15180
15320
  * Get user profile by ID or throw
@@ -15196,11 +15336,12 @@ var UserProfileService = class extends BaseService {
15196
15336
  * @returns User profile or null
15197
15337
  */
15198
15338
  async getProfileByAuthId(authId) {
15199
- return this.cachedBy(
15339
+ const profile = await this.cachedBy(
15200
15340
  "userProfileByAuthId",
15201
15341
  authId,
15202
15342
  () => this.adapter.userProfiles.findByAuthId(authId)
15203
15343
  );
15344
+ return profile ? this.resolveAvatarUrl(profile) : null;
15204
15345
  }
15205
15346
  /**
15206
15347
  * Get or create user profile (idempotent operation)
@@ -15239,11 +15380,11 @@ var UserProfileService = class extends BaseService {
15239
15380
  const updated = await this.adapter.userProfiles.update(profileId, data);
15240
15381
  await this.invalidateProfileCache(updated.id, updated.authId, updated.email);
15241
15382
  if (this.auditService && this.userId) {
15242
- const changes = buildAuditChanges(existing, data, [
15243
- "firstName",
15244
- "lastName",
15245
- "status"
15246
- ]);
15383
+ const changes = buildAuditChanges(
15384
+ existing,
15385
+ data,
15386
+ ["firstName", "lastName", "status"]
15387
+ );
15247
15388
  if (changes.length > 0) {
15248
15389
  await this.auditService.logUserAction({
15249
15390
  action: "user.updated",
@@ -15254,7 +15395,7 @@ var UserProfileService = class extends BaseService {
15254
15395
  });
15255
15396
  }
15256
15397
  }
15257
- return updated;
15398
+ return this.resolveAvatarUrl(updated);
15258
15399
  }
15259
15400
  /**
15260
15401
  * Delete user profile.
@@ -15265,7 +15406,7 @@ var UserProfileService = class extends BaseService {
15265
15406
  */
15266
15407
  async deleteProfile(profileId, options) {
15267
15408
  const profile = await this.getProfileOrThrow(profileId);
15268
- if (_optionalChain([options, 'optionalAccess', _364 => _364.checkAdmin]) && this.adapter.permissions) {
15409
+ if (_optionalChain([options, 'optionalAccess', _371 => _371.checkAdmin]) && this.adapter.permissions) {
15269
15410
  const ownerCount = await this.adapter.permissions.countUsersWithRole("owner");
15270
15411
  if (ownerCount <= 1) {
15271
15412
  const userRoles = await this.adapter.permissions.getUserRoles(profileId);
@@ -15291,7 +15432,8 @@ var UserProfileService = class extends BaseService {
15291
15432
  * Automatically uses tenant context from AsyncLocalStorage.
15292
15433
  */
15293
15434
  async listProfiles(options) {
15294
- return await this.adapter.userProfiles.list(options);
15435
+ const profiles = await this.adapter.userProfiles.list(options);
15436
+ return this.resolveAvatarUrls(profiles);
15295
15437
  }
15296
15438
  /**
15297
15439
  * Update last login timestamp
@@ -15322,11 +15464,12 @@ var UserProfileService = class extends BaseService {
15322
15464
  * Automatically uses tenant context from AsyncLocalStorage.
15323
15465
  */
15324
15466
  async getProfileByEmail(email) {
15325
- return this.cachedBy(
15467
+ const profile = await this.cachedBy(
15326
15468
  "userProfileByEmail",
15327
15469
  email,
15328
15470
  () => this.adapter.userProfiles.findByEmail(email)
15329
15471
  );
15472
+ return profile ? this.resolveAvatarUrl(profile) : null;
15330
15473
  }
15331
15474
  /**
15332
15475
  * Invite a new user by email.
@@ -15359,6 +15502,21 @@ var UserProfileService = class extends BaseService {
15359
15502
  throw new Error(`User with email "${data.email}" already exists in this tenant`);
15360
15503
  }
15361
15504
  const profile = await this.adapter.userProfiles.invite(data);
15505
+ if (this.adapter.permissions) {
15506
+ try {
15507
+ const roles = await this.adapter.permissions.getRoles();
15508
+ const defaultRole = roles.find((r) => r.name === "member" && r.system);
15509
+ if (defaultRole) {
15510
+ await this.adapter.permissions.assignRole({
15511
+ userProfileId: profile.id,
15512
+ roleId: defaultRole.id,
15513
+ tenantId: this.tenantId,
15514
+ assignedBy: _nullishCoalesce(this.userId, () => ( void 0))
15515
+ });
15516
+ }
15517
+ } catch (e26) {
15518
+ }
15519
+ }
15362
15520
  await this.invalidateProfileCache(profile.id, profile.authId, profile.email);
15363
15521
  if (this.auditService && this.userId) {
15364
15522
  await this.auditService.logUserAction({
@@ -15368,7 +15526,7 @@ var UserProfileService = class extends BaseService {
15368
15526
  targetUserEmail: profile.email
15369
15527
  });
15370
15528
  }
15371
- return profile;
15529
+ return this.resolveAvatarUrl(profile);
15372
15530
  }
15373
15531
  };
15374
15532
 
@@ -15753,7 +15911,7 @@ var DocumentTemplateService = class extends BaseService {
15753
15911
  * Includes both system templates and tenant-specific templates.
15754
15912
  */
15755
15913
  async listTemplates(options) {
15756
- if (_optionalChain([options, 'optionalAccess', _365 => _365.systemOnly])) {
15914
+ if (_optionalChain([options, 'optionalAccess', _372 => _372.systemOnly])) {
15757
15915
  return SYSTEM_TEMPLATES;
15758
15916
  }
15759
15917
  const templates = [...SYSTEM_TEMPLATES];
@@ -15836,8 +15994,8 @@ var DocumentTemplateService = class extends BaseService {
15836
15994
  var DocumentService = class extends BaseService {
15837
15995
  constructor(adapter, options) {
15838
15996
  super(adapter);
15839
- this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _366 => _366.templateService]), () => ( new DocumentTemplateService(adapter)));
15840
- this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _367 => _367.fileService]), () => ( null));
15997
+ this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _373 => _373.templateService]), () => ( new DocumentTemplateService(adapter)));
15998
+ this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.fileService]), () => ( null));
15841
15999
  }
15842
16000
  // ============================================================================
15843
16001
  // CREATE
@@ -16088,7 +16246,7 @@ var DocumentService = class extends BaseService {
16088
16246
  */
16089
16247
  async isComplete(documentId) {
16090
16248
  const document2 = await this.getDocument(documentId);
16091
- return _optionalChain([document2, 'optionalAccess', _368 => _368.status]) !== "draft";
16249
+ return _optionalChain([document2, 'optionalAccess', _375 => _375.status]) !== "draft";
16092
16250
  }
16093
16251
  /**
16094
16252
  * Get document with its template and slots.
@@ -16346,7 +16504,7 @@ var DocumentProcessingService = class extends BaseService {
16346
16504
  type: "signature",
16347
16505
  provider: this.config.signatureAdapter.name,
16348
16506
  input: { signers, ...options },
16349
- expiresAt: _optionalChain([options, 'optionalAccess', _369 => _369.expiresAt])
16507
+ expiresAt: _optionalChain([options, 'optionalAccess', _376 => _376.expiresAt])
16350
16508
  });
16351
16509
  return job;
16352
16510
  }
@@ -16503,7 +16661,7 @@ var DocumentProcessingService = class extends BaseService {
16503
16661
  }
16504
16662
  const document2 = await this.documentService.getDocumentOrThrow(documentId);
16505
16663
  const template = await this.templateService.getTemplateOrThrow(document2.templateId);
16506
- if (!_optionalChain([template, 'access', _370 => _370.autoProcessing, 'optionalAccess', _371 => _371.identityVerification, 'optionalAccess', _372 => _372.enabled])) {
16664
+ if (!_optionalChain([template, 'access', _377 => _377.autoProcessing, 'optionalAccess', _378 => _378.identityVerification, 'optionalAccess', _379 => _379.enabled])) {
16507
16665
  throw new Error("Identity verification is not enabled for this document type");
16508
16666
  }
16509
16667
  const job = await this.adapter.documentJobs.create({
@@ -16589,13 +16747,13 @@ var DocumentProcessingService = class extends BaseService {
16589
16747
  const template = await this.templateService.getTemplateOrThrow(document2.templateId);
16590
16748
  const slots = await this.documentService.getSlots(documentId);
16591
16749
  const jobs = [];
16592
- if (_optionalChain([template, 'access', _373 => _373.autoProcessing, 'optionalAccess', _374 => _374.ocr, 'optionalAccess', _375 => _375.enabled]) && this.config.ocrAdapter) {
16750
+ if (_optionalChain([template, 'access', _380 => _380.autoProcessing, 'optionalAccess', _381 => _381.ocr, 'optionalAccess', _382 => _382.enabled]) && this.config.ocrAdapter) {
16593
16751
  for (const slot of slots) {
16594
16752
  const job = await this.processOcr(documentId, slot.slotName);
16595
16753
  jobs.push(job);
16596
16754
  }
16597
16755
  }
16598
- if (_optionalChain([template, 'access', _376 => _376.autoProcessing, 'optionalAccess', _377 => _377.identityVerification, 'optionalAccess', _378 => _378.enabled]) && this.config.identityAdapter) {
16756
+ if (_optionalChain([template, 'access', _383 => _383.autoProcessing, 'optionalAccess', _384 => _384.identityVerification, 'optionalAccess', _385 => _385.enabled]) && this.config.identityAdapter) {
16599
16757
  const job = await this.verifyIdentity(documentId);
16600
16758
  jobs.push(job);
16601
16759
  }
@@ -16666,15 +16824,15 @@ var DocumentProcessingService = class extends BaseService {
16666
16824
  return {
16667
16825
  ocr: {
16668
16826
  available: !!this.config.ocrAdapter,
16669
- provider: _optionalChain([this, 'access', _379 => _379.config, 'access', _380 => _380.ocrAdapter, 'optionalAccess', _381 => _381.name])
16827
+ provider: _optionalChain([this, 'access', _386 => _386.config, 'access', _387 => _387.ocrAdapter, 'optionalAccess', _388 => _388.name])
16670
16828
  },
16671
16829
  signature: {
16672
16830
  available: !!this.config.signatureAdapter,
16673
- provider: _optionalChain([this, 'access', _382 => _382.config, 'access', _383 => _383.signatureAdapter, 'optionalAccess', _384 => _384.name])
16831
+ provider: _optionalChain([this, 'access', _389 => _389.config, 'access', _390 => _390.signatureAdapter, 'optionalAccess', _391 => _391.name])
16674
16832
  },
16675
16833
  identityVerification: {
16676
16834
  available: !!this.config.identityAdapter,
16677
- provider: _optionalChain([this, 'access', _385 => _385.config, 'access', _386 => _386.identityAdapter, 'optionalAccess', _387 => _387.name])
16835
+ provider: _optionalChain([this, 'access', _392 => _392.config, 'access', _393 => _393.identityAdapter, 'optionalAccess', _394 => _394.name])
16678
16836
  }
16679
16837
  };
16680
16838
  }
@@ -16684,7 +16842,7 @@ var DocumentProcessingService = class extends BaseService {
16684
16842
  var FileService = class extends BaseService {
16685
16843
  constructor(adapter, options) {
16686
16844
  super(adapter);
16687
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _388 => _388.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
16845
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _395 => _395.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
16688
16846
  }
16689
16847
  // ============================================================================
16690
16848
  // UPLOAD (requires StorageAdapter)
@@ -16823,7 +16981,7 @@ var FileService = class extends BaseService {
16823
16981
  */
16824
16982
  async getFile(fileId) {
16825
16983
  const file2 = await this.adapter.files.findById(fileId);
16826
- if (_optionalChain([file2, 'optionalAccess', _389 => _389.deletedAt])) {
16984
+ if (_optionalChain([file2, 'optionalAccess', _396 => _396.deletedAt])) {
16827
16985
  return null;
16828
16986
  }
16829
16987
  return file2;
@@ -16885,12 +17043,12 @@ var FileService = class extends BaseService {
16885
17043
  */
16886
17044
  async deleteFile(fileId, options) {
16887
17045
  const file2 = await this.getFileOrThrow(fileId);
16888
- if (_optionalChain([options, 'optionalAccess', _390 => _390.checkOwnership]) && options.userId) {
17046
+ if (_optionalChain([options, 'optionalAccess', _397 => _397.checkOwnership]) && options.userId) {
16889
17047
  if (file2.uploadedBy !== options.userId) {
16890
17048
  throw new Error("You can only delete files you uploaded");
16891
17049
  }
16892
17050
  }
16893
- if (_optionalChain([options, 'optionalAccess', _391 => _391.hard])) {
17051
+ if (_optionalChain([options, 'optionalAccess', _398 => _398.hard])) {
16894
17052
  await this.adapter.files.hardDelete(fileId);
16895
17053
  } else {
16896
17054
  await this.adapter.files.delete(fileId);
@@ -16921,7 +17079,7 @@ var FileService = class extends BaseService {
16921
17079
  }
16922
17080
  const file2 = await this.getFileOrThrow(fileId);
16923
17081
  await this.adapter.storage.delete(file2.storagePath);
16924
- if (_optionalChain([options, 'optionalAccess', _392 => _392.hard])) {
17082
+ if (_optionalChain([options, 'optionalAccess', _399 => _399.hard])) {
16925
17083
  await this.adapter.files.hardDelete(fileId);
16926
17084
  } else {
16927
17085
  await this.adapter.files.delete(fileId);
@@ -16947,15 +17105,15 @@ var FileService = class extends BaseService {
16947
17105
  const fileResults = await Promise.all(fileIds.map((id) => this.getFile(id)));
16948
17106
  const files = fileResults.filter((f) => f !== null);
16949
17107
  if (files.length === 0) return;
16950
- if (_optionalChain([options, 'optionalAccess', _393 => _393.deleteFromStorage]) && this.adapter.storage) {
17108
+ if (_optionalChain([options, 'optionalAccess', _400 => _400.deleteFromStorage]) && this.adapter.storage) {
16951
17109
  const BATCH_SIZE = 10;
16952
17110
  for (let i = 0; i < files.length; i += BATCH_SIZE) {
16953
17111
  const batch = files.slice(i, i + BATCH_SIZE);
16954
- await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _394 => _394.adapter, 'access', _395 => _395.storage, 'optionalAccess', _396 => _396.delete, 'call', _397 => _397(file2.storagePath)])));
17112
+ await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _401 => _401.adapter, 'access', _402 => _402.storage, 'optionalAccess', _403 => _403.delete, 'call', _404 => _404(file2.storagePath)])));
16955
17113
  }
16956
17114
  }
16957
17115
  const idsToDelete = files.map((f) => f.id);
16958
- if (_optionalChain([options, 'optionalAccess', _398 => _398.hard])) {
17116
+ if (_optionalChain([options, 'optionalAccess', _405 => _405.hard])) {
16959
17117
  await Promise.all(idsToDelete.map((id) => this.adapter.files.hardDelete(id)));
16960
17118
  } else {
16961
17119
  await Promise.all(idsToDelete.map((id) => this.adapter.files.delete(id)));
@@ -16963,12 +17121,12 @@ var FileService = class extends BaseService {
16963
17121
  if (this.auditService && this.userId) {
16964
17122
  await Promise.all(
16965
17123
  files.map(
16966
- (file2) => _optionalChain([this, 'access', _399 => _399.auditService, 'optionalAccess', _400 => _400.logFileAction, 'call', _401 => _401({
17124
+ (file2) => _optionalChain([this, 'access', _406 => _406.auditService, 'optionalAccess', _407 => _407.logFileAction, 'call', _408 => _408({
16967
17125
  action: "file.deleted",
16968
17126
  actorId: _nullishCoalesce(this.userId, () => ( "")),
16969
17127
  fileId: file2.id,
16970
17128
  fileName: file2.name,
16971
- metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _402 => _402.deleteFromStorage]), () => ( false)) }
17129
+ metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _409 => _409.deleteFromStorage]), () => ( false)) }
16972
17130
  })])
16973
17131
  )
16974
17132
  );
@@ -17041,14 +17199,11 @@ var FileService = class extends BaseService {
17041
17199
  * @param userId - User ID to check
17042
17200
  * @returns true if user can access the file
17043
17201
  */
17044
- async checkAccess(fileId, userId, options) {
17202
+ async checkAccess(fileId, userId) {
17045
17203
  const file2 = await this.getFile(fileId);
17046
17204
  if (!file2) {
17047
17205
  return false;
17048
17206
  }
17049
- if (_optionalChain([options, 'optionalAccess', _403 => _403.isAdmin])) {
17050
- return true;
17051
- }
17052
17207
  if (file2.visibility === "public") {
17053
17208
  return true;
17054
17209
  }
@@ -17056,7 +17211,7 @@ var FileService = class extends BaseService {
17056
17211
  return true;
17057
17212
  }
17058
17213
  if (file2.visibility === "restricted") {
17059
- return _nullishCoalesce(_optionalChain([file2, 'access', _404 => _404.allowedUsers, 'optionalAccess', _405 => _405.includes, 'call', _406 => _406(userId)]), () => ( false));
17214
+ return _nullishCoalesce(_optionalChain([file2, 'access', _410 => _410.allowedUsers, 'optionalAccess', _411 => _411.includes, 'call', _412 => _412(userId)]), () => ( false));
17060
17215
  }
17061
17216
  return false;
17062
17217
  }
@@ -17151,7 +17306,7 @@ function withTimeout(promise, ms, label) {
17151
17306
  var GeocodingService = class {
17152
17307
  constructor(adapter, options) {
17153
17308
  this.adapter = adapter;
17154
- this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _407 => _407.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
17309
+ this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _413 => _413.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
17155
17310
  }
17156
17311
  /**
17157
17312
  * Search for address suggestions as the user types
@@ -17210,9 +17365,9 @@ var GlobalSearchService = class extends BaseService {
17210
17365
  if (this.adapter.search) {
17211
17366
  try {
17212
17367
  const raw = await this.adapter.search.globalSearch(trimmed, {
17213
- objectNames: _optionalChain([options, 'optionalAccess', _408 => _408.objectNames]),
17214
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _409 => _409.limit]), () => ( 20)),
17215
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _410 => _410.offset]), () => ( 0))
17368
+ objectNames: _optionalChain([options, 'optionalAccess', _414 => _414.objectNames]),
17369
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _415 => _415.limit]), () => ( 20)),
17370
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _416 => _416.offset]), () => ( 0))
17216
17371
  });
17217
17372
  return await this.healGlobalSearchResults(raw);
17218
17373
  } catch (err) {
@@ -17220,9 +17375,9 @@ var GlobalSearchService = class extends BaseService {
17220
17375
  }
17221
17376
  }
17222
17377
  return this.adapter.objectRecords.globalSearch(trimmed, {
17223
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _411 => _411.limit]), () => ( 20)),
17224
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _412 => _412.offset]), () => ( 0)),
17225
- objectNames: _optionalChain([options, 'optionalAccess', _413 => _413.objectNames])
17378
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _417 => _417.limit]), () => ( 20)),
17379
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _418 => _418.offset]), () => ( 0)),
17380
+ objectNames: _optionalChain([options, 'optionalAccess', _419 => _419.objectNames])
17226
17381
  });
17227
17382
  }
17228
17383
  /**
@@ -17241,7 +17396,7 @@ var GlobalSearchService = class extends BaseService {
17241
17396
  if (this.adapter.search) {
17242
17397
  try {
17243
17398
  const raw = await this.adapter.search.globalSearchGrouped(trimmed, {
17244
- objectNames: _optionalChain([options, 'optionalAccess', _414 => _414.objectNames])
17399
+ objectNames: _optionalChain([options, 'optionalAccess', _420 => _420.objectNames])
17245
17400
  });
17246
17401
  return await this.healGroupedSearchResults(raw);
17247
17402
  } catch (err) {
@@ -17249,8 +17404,8 @@ var GlobalSearchService = class extends BaseService {
17249
17404
  }
17250
17405
  }
17251
17406
  return this.adapter.objectRecords.globalSearchGrouped(trimmed, {
17252
- objectNames: _optionalChain([options, 'optionalAccess', _415 => _415.objectNames]),
17253
- limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _416 => _416.limitPerGroup]), () => ( 5))
17407
+ objectNames: _optionalChain([options, 'optionalAccess', _421 => _421.objectNames]),
17408
+ limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _422 => _422.limitPerGroup]), () => ( 5))
17254
17409
  });
17255
17410
  }
17256
17411
  // ==========================================================================
@@ -17317,7 +17472,7 @@ var PermissionService = class extends BaseService {
17317
17472
  }
17318
17473
  this.permissionsRepo = adapter.permissions;
17319
17474
  this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
17320
- this.auditService = _optionalChain([options, 'optionalAccess', _417 => _417.auditService]);
17475
+ this.auditService = _optionalChain([options, 'optionalAccess', _423 => _423.auditService]);
17321
17476
  }
17322
17477
  // ============================================================================
17323
17478
  // PERMISSION CHECKS
@@ -17332,15 +17487,12 @@ var PermissionService = class extends BaseService {
17332
17487
  */
17333
17488
  async canAccessObject(userProfileId, objectName, action) {
17334
17489
  const permissions = await this.getEffectivePermissions(userProfileId);
17335
- if (permissions.isAdmin) {
17336
- return true;
17337
- }
17338
17490
  const wildcardPerms = permissions.objectPermissions["*"];
17339
- if (_optionalChain([wildcardPerms, 'optionalAccess', _418 => _418.includes, 'call', _419 => _419(action)])) {
17491
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _424 => _424.includes, 'call', _425 => _425(action)])) {
17340
17492
  return true;
17341
17493
  }
17342
17494
  const objectPerms = permissions.objectPermissions[objectName];
17343
- return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _420 => _420.includes, 'call', _421 => _421(action)]), () => ( false));
17495
+ return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _426 => _426.includes, 'call', _427 => _427(action)]), () => ( false));
17344
17496
  }
17345
17497
  /**
17346
17498
  * Check if user can access an object, throw ForbiddenError if not.
@@ -17366,9 +17518,6 @@ var PermissionService = class extends BaseService {
17366
17518
  */
17367
17519
  async getObjectPermissions(userProfileId, objectName) {
17368
17520
  const permissions = await this.getEffectivePermissions(userProfileId);
17369
- if (permissions.isAdmin) {
17370
- return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
17371
- }
17372
17521
  const wildcardPerms = _nullishCoalesce(permissions.objectPermissions["*"], () => ( []));
17373
17522
  const objectPerms = _nullishCoalesce(permissions.objectPermissions[objectName], () => ( []));
17374
17523
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...objectPerms]);
@@ -17392,15 +17541,12 @@ var PermissionService = class extends BaseService {
17392
17541
  */
17393
17542
  async canAccessSystem(userProfileId, resource, action) {
17394
17543
  const permissions = await this.getEffectivePermissions(userProfileId);
17395
- if (permissions.isAdmin) {
17544
+ const wildcardPerms = _optionalChain([permissions, 'access', _428 => _428.systemPermissions, 'optionalAccess', _429 => _429["*"]]);
17545
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _430 => _430.includes, 'call', _431 => _431(action)])) {
17396
17546
  return true;
17397
17547
  }
17398
- const wildcardPerms = _optionalChain([permissions, 'access', _422 => _422.systemPermissions, 'optionalAccess', _423 => _423["*"]]);
17399
- if (_optionalChain([wildcardPerms, 'optionalAccess', _424 => _424.includes, 'call', _425 => _425(action)])) {
17400
- return true;
17401
- }
17402
- const resourcePerms = _optionalChain([permissions, 'access', _426 => _426.systemPermissions, 'optionalAccess', _427 => _427[resource]]);
17403
- return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _428 => _428.includes, 'call', _429 => _429(action)]), () => ( false));
17548
+ const resourcePerms = _optionalChain([permissions, 'access', _432 => _432.systemPermissions, 'optionalAccess', _433 => _433[resource]]);
17549
+ return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _434 => _434.includes, 'call', _435 => _435(action)]), () => ( false));
17404
17550
  }
17405
17551
  /**
17406
17552
  * Check if user can access a system resource, throw ForbiddenError if not.
@@ -17426,11 +17572,8 @@ var PermissionService = class extends BaseService {
17426
17572
  */
17427
17573
  async getSystemPermissions(userProfileId, resource) {
17428
17574
  const permissions = await this.getEffectivePermissions(userProfileId);
17429
- if (permissions.isAdmin) {
17430
- return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
17431
- }
17432
- const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _430 => _430.systemPermissions, 'optionalAccess', _431 => _431["*"]]), () => ( []));
17433
- const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _432 => _432.systemPermissions, 'optionalAccess', _433 => _433[resource]]), () => ( []));
17575
+ const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _436 => _436.systemPermissions, 'optionalAccess', _437 => _437["*"]]), () => ( []));
17576
+ const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _438 => _438.systemPermissions, 'optionalAccess', _439 => _439[resource]]), () => ( []));
17434
17577
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
17435
17578
  return {
17436
17579
  canRead: allPerms.has("read"),
@@ -17573,7 +17716,7 @@ var PermissionService = class extends BaseService {
17573
17716
  action: "role.updated",
17574
17717
  actorId: this.userId,
17575
17718
  roleId,
17576
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _434 => _434.label]), () => ( roleId)),
17719
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _440 => _440.label]), () => ( roleId)),
17577
17720
  metadata: { permissionsUpdated: true, permissionCount: permissions.length }
17578
17721
  });
17579
17722
  }
@@ -17603,7 +17746,7 @@ var PermissionService = class extends BaseService {
17603
17746
  action: "role.assigned",
17604
17747
  actorId: this.userId,
17605
17748
  roleId,
17606
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _435 => _435.label]), () => ( roleId)),
17749
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _441 => _441.label]), () => ( roleId)),
17607
17750
  targetUserId: userProfileId
17608
17751
  });
17609
17752
  }
@@ -17621,7 +17764,7 @@ var PermissionService = class extends BaseService {
17621
17764
  action: "role.revoked",
17622
17765
  actorId: this.userId,
17623
17766
  roleId,
17624
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _436 => _436.label]), () => ( roleId)),
17767
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _442 => _442.label]), () => ( roleId)),
17625
17768
  targetUserId: userProfileId
17626
17769
  });
17627
17770
  }
@@ -17633,9 +17776,8 @@ var PermissionService = class extends BaseService {
17633
17776
  * Initialize default roles for the tenant if they don't exist.
17634
17777
  *
17635
17778
  * Creates the following roles with their default permissions:
17636
- * - **admin**: Full access to all system resources and objects
17637
- * - **member**: No system access, can read/create/update objects (no delete)
17638
- * - **guest**: No system access, read-only access to objects
17779
+ * - **owner**: Full access to all system resources and objects
17780
+ * - **member**: Full CRUD on business data, read-only on system resources (people, workspace)
17639
17781
  *
17640
17782
  * This method is idempotent - it only creates roles that don't already exist.
17641
17783
  * Should be called during tenant bootstrap or on first admin login.
@@ -17652,7 +17794,7 @@ var PermissionService = class extends BaseService {
17652
17794
  DEFAULT_ROLE_LABELS,
17653
17795
  DEFAULT_ROLE_DESCRIPTIONS,
17654
17796
  DEFAULT_ROLE_PERMISSIONS
17655
- } = await Promise.resolve().then(() => _interopRequireWildcard(require("./default-roles-76HUWY6T.js")));
17797
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./default-roles-5K3GHJTS.js")));
17656
17798
  const existingRoles = await this.getRoles();
17657
17799
  const existingRoleNames = existingRoles.reduce((set, r) => set.add(r.name), /* @__PURE__ */ new Set());
17658
17800
  for (const roleName of Object.values(DEFAULT_ROLES)) {
@@ -18096,7 +18238,7 @@ var ViewService = class extends BaseService {
18096
18238
  dbView.objectName,
18097
18239
  dbView.type,
18098
18240
  objectDefinition,
18099
- dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _437 => _437.config, 'optionalAccess', _438 => _438.layout]), () => ( "page")) : void 0
18241
+ dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _443 => _443.config, 'optionalAccess', _444 => _444.layout]), () => ( "page")) : void 0
18100
18242
  );
18101
18243
  const newConfig = generated.config;
18102
18244
  const updated = await this.adapter.views.update(viewId, { config: newConfig });
@@ -18591,9 +18733,7 @@ async function cleanupOrphanObjects(adapter, nativeObjects, result, options) {
18591
18733
  const registryNames = nativeObjects.map((obj) => obj.name);
18592
18734
  if (options.dryRun) {
18593
18735
  const allObjects = await adapter.objects.list();
18594
- const orphans = allObjects.filter(
18595
- (obj) => obj.system && !registryNames.includes(obj.name)
18596
- );
18736
+ const orphans = allObjects.filter((obj) => obj.system && !registryNames.includes(obj.name));
18597
18737
  result.objectsDeleted += orphans.length;
18598
18738
  if (options.verbose && orphans.length > 0) {
18599
18739
  console.info(
@@ -18999,4 +19139,10 @@ var NoopGeocodingAdapter = class {
18999
19139
 
19000
19140
 
19001
19141
 
19002
- exports.IDENTITY_PROPERTIES = IDENTITY_PROPERTIES; exports.BEHAVIOR_PROPERTIES = BEHAVIOR_PROPERTIES; exports.PRESENTATION_PROPERTIES = PRESENTATION_PROPERTIES; exports.isIdentityProperty = isIdentityProperty; exports.isBehaviorProperty = isBehaviorProperty; exports.isPresentationProperty = isPresentationProperty; exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.isBilateralRelation = isBilateralRelation; exports.inferInverseCardinality = inferInverseCardinality; exports.NON_SORTABLE_TYPES = NON_SORTABLE_TYPES; exports.isAttributeSortable = isAttributeSortable; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.getErrorMessage = getErrorMessage; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.FORBIDDEN_PROPERTY_TYPES = FORBIDDEN_PROPERTY_TYPES; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isDocumentNode = isDocumentNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isInvitationValid = isInvitationValid; exports.isInvitationAccepted = isInvitationAccepted; exports.isInvitationExpired = isInvitationExpired; exports.isGrantValid = isGrantValid; exports.isGrantRevoked = isGrantRevoked; exports.isTokenRevoked = isTokenRevoked; exports.isGrantExpired = isGrantExpired; exports.canAccessNode = canAccessNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isInvitationOrGrantEvent = isInvitationOrGrantEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.DocumentNodeSchema = DocumentNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.AuthMethodSchema = AuthMethodSchema; exports.ShareStatusSchema = ShareStatusSchema; exports.WorkflowShareSchema = WorkflowShareSchema; exports.CreateShareInputSchema = CreateShareInputSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.toUndefinedIfEmpty = toUndefinedIfEmpty; exports.hasProperties = hasProperties; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.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.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.ConcurrentModificationError = ConcurrentModificationError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.document = document; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.RelationGroupBuilder = RelationGroupBuilder; exports.TableTabConfig = TableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.RichtextTabConfig = RichtextTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.DocumentsTabConfig = DocumentsTabConfig; exports.TabBuilder = TabBuilder; exports.DetailViewBuilder = DetailViewBuilder; exports.ViewBuilder = ViewBuilder; exports.detailView = detailView; exports.view = view; exports.ListViewBuilder = ListViewBuilder; exports.ListViewTabConfigBuilder = ListViewTabConfigBuilder; exports.listView = listView; exports.group = group; exports.relationGroup = relationGroup; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.SYSTEM_TEMPLATE_IDS = SYSTEM_TEMPLATE_IDS; exports.FRENCH_ID_CARD = FRENCH_ID_CARD; exports.PASSPORT = PASSPORT; exports.DRIVING_LICENSE = DRIVING_LICENSE; exports.PROOF_OF_ADDRESS = PROOF_OF_ADDRESS; exports.SIGNABLE_CONTRACT = SIGNABLE_CONTRACT; exports.GENERIC_DOCUMENT = GENERIC_DOCUMENT; exports.SYSTEM_TEMPLATES = SYSTEM_TEMPLATES; exports.getSystemTemplate = getSystemTemplate; exports.isSystemTemplate = isSystemTemplate; exports.WorkflowJwtService = WorkflowJwtService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.FeatureFlagsContextError = FeatureFlagsContextError; exports.isFeatureEnabled = isFeatureEnabled; exports.getFeatureValue = getFeatureValue; exports.getFeatureFlags = getFeatureFlags; exports.tryGetFeatureValue = tryGetFeatureValue; exports.hasFeatureFlagsContext = hasFeatureFlagsContext; exports.runWithFeatureFlags = runWithFeatureFlags; exports.withFeatureFlags = withFeatureFlags; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext2; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.DocumentExecutor = DocumentExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.SORTABLE_ATTRIBUTE_TYPES = SORTABLE_ATTRIBUTE_TYPES; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.checkSharedObjectWriteAccess = checkSharedObjectWriteAccess; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RelationPropertiesService = RelationPropertiesService; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.DocumentRenderError = DocumentRenderError; exports.StorageDownloadNotSupportedError = StorageDownloadNotSupportedError; exports.DocumentRendererService = DocumentRendererService; exports.DocumentProcessingHook = DocumentProcessingHook; exports.GrantNotFoundError = GrantNotFoundError; exports.GrantExpiredError = GrantExpiredError; exports.GrantRevokedError = GrantRevokedError; exports.TokenRevokedError = TokenRevokedError; exports.WorkflowAccessGrantService = WorkflowAccessGrantService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.InvitationNotFoundError = InvitationNotFoundError; exports.InvitationExpiredError = InvitationExpiredError; exports.InvitationAlreadyAcceptedError = InvitationAlreadyAcceptedError; exports.InvitationRevokedError = InvitationRevokedError; exports.WorkflowInvitationService = WorkflowInvitationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.UserProfileService = UserProfileService; exports.DocumentGenerationTemplateNotFoundError = DocumentGenerationTemplateNotFoundError; exports.DocumentGenerationNotConfiguredError = DocumentGenerationNotConfiguredError; exports.DocumentGenerationService = DocumentGenerationService; exports.DocumentTemplateService = DocumentTemplateService; exports.DocumentService = DocumentService; exports.DocumentProcessingService = DocumentProcessingService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.seedRegistryViews = seedRegistryViews; exports.syncNativeViews = syncNativeViews; exports.verifyRegistryViewsSeeded = verifyRegistryViewsSeeded; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSeedPreview = getViewSeedPreview; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
19142
+
19143
+
19144
+
19145
+
19146
+
19147
+
19148
+ exports.IDENTITY_PROPERTIES = IDENTITY_PROPERTIES; exports.BEHAVIOR_PROPERTIES = BEHAVIOR_PROPERTIES; exports.PRESENTATION_PROPERTIES = PRESENTATION_PROPERTIES; exports.isIdentityProperty = isIdentityProperty; exports.isBehaviorProperty = isBehaviorProperty; exports.isPresentationProperty = isPresentationProperty; exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.isBilateralRelation = isBilateralRelation; exports.inferInverseCardinality = inferInverseCardinality; exports.NON_SORTABLE_TYPES = NON_SORTABLE_TYPES; exports.isAttributeSortable = isAttributeSortable; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.getErrorMessage = getErrorMessage; exports.isFlowFieldsRow = isFlowFieldsRow; exports.isLayoutRow = isLayoutRow; exports.isFlowDefinition = isFlowDefinition; exports.isFlowPublished = isFlowPublished; exports.isSystemFlow = isSystemFlow; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.FORBIDDEN_PROPERTY_TYPES = FORBIDDEN_PROPERTY_TYPES; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isDocumentNode = isDocumentNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isInvitationValid = isInvitationValid; exports.isInvitationAccepted = isInvitationAccepted; exports.isInvitationExpired = isInvitationExpired; exports.isGrantValid = isGrantValid; exports.isGrantRevoked = isGrantRevoked; exports.isTokenRevoked = isTokenRevoked; exports.isGrantExpired = isGrantExpired; exports.canAccessNode = canAccessNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.isFormFieldsRow = isFormFieldsRow; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isInvitationOrGrantEvent = isInvitationOrGrantEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.DocumentNodeSchema = DocumentNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.AuthMethodSchema = AuthMethodSchema; exports.ShareStatusSchema = ShareStatusSchema; exports.WorkflowShareSchema = WorkflowShareSchema; exports.CreateShareInputSchema = CreateShareInputSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.toUndefinedIfEmpty = toUndefinedIfEmpty; exports.hasProperties = hasProperties; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.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.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.ConcurrentModificationError = ConcurrentModificationError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.document = document; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.RelationGroupBuilder = RelationGroupBuilder; exports.TableTabConfig = TableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.RichtextTabConfig = RichtextTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.DocumentsTabConfig = DocumentsTabConfig; exports.TabBuilder = TabBuilder; exports.DetailViewBuilder = DetailViewBuilder; exports.ViewBuilder = ViewBuilder; exports.detailView = detailView; exports.view = view; exports.ListViewBuilder = ListViewBuilder; exports.ListViewTabConfigBuilder = ListViewTabConfigBuilder; exports.listView = listView; exports.group = group; exports.relationGroup = relationGroup; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.SYSTEM_TEMPLATE_IDS = SYSTEM_TEMPLATE_IDS; exports.FRENCH_ID_CARD = FRENCH_ID_CARD; exports.PASSPORT = PASSPORT; exports.DRIVING_LICENSE = DRIVING_LICENSE; exports.PROOF_OF_ADDRESS = PROOF_OF_ADDRESS; exports.SIGNABLE_CONTRACT = SIGNABLE_CONTRACT; exports.GENERIC_DOCUMENT = GENERIC_DOCUMENT; exports.SYSTEM_TEMPLATES = SYSTEM_TEMPLATES; exports.getSystemTemplate = getSystemTemplate; exports.isSystemTemplate = isSystemTemplate; exports.WorkflowJwtService = WorkflowJwtService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.FeatureFlagsContextError = FeatureFlagsContextError; exports.isFeatureEnabled = isFeatureEnabled; exports.getFeatureValue = getFeatureValue; exports.getFeatureFlags = getFeatureFlags; exports.tryGetFeatureValue = tryGetFeatureValue; exports.hasFeatureFlagsContext = hasFeatureFlagsContext; exports.runWithFeatureFlags = runWithFeatureFlags; exports.withFeatureFlags = withFeatureFlags; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext2; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.DocumentExecutor = DocumentExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.SORTABLE_ATTRIBUTE_TYPES = SORTABLE_ATTRIBUTE_TYPES; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.checkSharedObjectWriteAccess = checkSharedObjectWriteAccess; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RelationPropertiesService = RelationPropertiesService; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.DocumentRenderError = DocumentRenderError; exports.StorageDownloadNotSupportedError = StorageDownloadNotSupportedError; exports.DocumentRendererService = DocumentRendererService; exports.DocumentProcessingHook = DocumentProcessingHook; exports.GrantNotFoundError = GrantNotFoundError; exports.GrantExpiredError = GrantExpiredError; exports.GrantRevokedError = GrantRevokedError; exports.TokenRevokedError = TokenRevokedError; exports.WorkflowAccessGrantService = WorkflowAccessGrantService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.InvitationNotFoundError = InvitationNotFoundError; exports.InvitationExpiredError = InvitationExpiredError; exports.InvitationAlreadyAcceptedError = InvitationAlreadyAcceptedError; exports.InvitationRevokedError = InvitationRevokedError; exports.WorkflowInvitationService = WorkflowInvitationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.UserProfileService = UserProfileService; exports.DocumentGenerationTemplateNotFoundError = DocumentGenerationTemplateNotFoundError; exports.DocumentGenerationNotConfiguredError = DocumentGenerationNotConfiguredError; exports.DocumentGenerationService = DocumentGenerationService; exports.DocumentTemplateService = DocumentTemplateService; exports.DocumentService = DocumentService; exports.DocumentProcessingService = DocumentProcessingService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.seedRegistryViews = seedRegistryViews; exports.syncNativeViews = syncNativeViews; exports.verifyRegistryViewsSeeded = verifyRegistryViewsSeeded; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSeedPreview = getViewSeedPreview; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;