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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3152,6 +3152,10 @@ function createMockFilesRepository(stores) {
3152
3152
  if (_optionalChain([file2, 'optionalAccess', _41 => _41.deletedAt])) return Promise.resolve(null);
3153
3153
  return Promise.resolve(_nullishCoalesce(file2, () => ( null)));
3154
3154
  },
3155
+ findByIds(ids) {
3156
+ const files = ids.map((id) => stores.files.get(id)).filter((f) => f != null && !f.deletedAt);
3157
+ return Promise.resolve(files);
3158
+ },
3155
3159
  create(data) {
3156
3160
  const tenantId = getTenantId();
3157
3161
  const file2 = {
@@ -4123,6 +4127,284 @@ function createMockWorkflowParticipationsRepository(stores) {
4123
4127
  }
4124
4128
  };
4125
4129
  }
4130
+ function requireUserId() {
4131
+ const userId = getUserId();
4132
+ if (!userId) {
4133
+ throw new Error("User context required for AI operations");
4134
+ }
4135
+ return userId;
4136
+ }
4137
+ function createMockAIConversationsRepository(stores) {
4138
+ return {
4139
+ findById(id) {
4140
+ const conversation = stores.aiConversations.get(id);
4141
+ if (!conversation || conversation.deletedAt) return Promise.resolve(null);
4142
+ const tenantId = getTenantId();
4143
+ if (conversation.tenantId !== tenantId) return Promise.resolve(null);
4144
+ return Promise.resolve(conversation);
4145
+ },
4146
+ list(options) {
4147
+ const tenantId = getTenantId();
4148
+ const userId = requireUserId();
4149
+ let results = Array.from(stores.aiConversations.values()).filter((c) => {
4150
+ if (c.tenantId !== tenantId || c.userId !== userId) return false;
4151
+ if (!_optionalChain([options, 'optionalAccess', _80 => _80.includeDeleted]) && c.deletedAt) return false;
4152
+ return true;
4153
+ });
4154
+ results.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
4155
+ const total = results.length;
4156
+ if (_optionalChain([options, 'optionalAccess', _81 => _81.limit])) {
4157
+ results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
4158
+ }
4159
+ return Promise.resolve({ conversations: results, total });
4160
+ },
4161
+ create(data) {
4162
+ const tenantId = getTenantId();
4163
+ const userId = requireUserId();
4164
+ const now = /* @__PURE__ */ new Date();
4165
+ const conversation = {
4166
+ id: generateId(),
4167
+ tenantId,
4168
+ userId,
4169
+ title: _nullishCoalesce(data.title, () => ( null)),
4170
+ messageCount: 0,
4171
+ totalTokens: 0,
4172
+ totalCost: 0,
4173
+ createdAt: now,
4174
+ updatedAt: now,
4175
+ deletedAt: null
4176
+ };
4177
+ stores.aiConversations.set(conversation.id, conversation);
4178
+ return Promise.resolve(conversation);
4179
+ },
4180
+ updateTitle(id, title) {
4181
+ const conversation = stores.aiConversations.get(id);
4182
+ if (!conversation || conversation.deletedAt) return Promise.resolve(null);
4183
+ const tenantId = getTenantId();
4184
+ if (conversation.tenantId !== tenantId) return Promise.resolve(null);
4185
+ conversation.title = title;
4186
+ conversation.updatedAt = /* @__PURE__ */ new Date();
4187
+ stores.aiConversations.set(id, conversation);
4188
+ return Promise.resolve(conversation);
4189
+ },
4190
+ delete(id) {
4191
+ const conversation = stores.aiConversations.get(id);
4192
+ if (!conversation) return Promise.resolve(false);
4193
+ const tenantId = getTenantId();
4194
+ if (conversation.tenantId !== tenantId) return Promise.resolve(false);
4195
+ conversation.deletedAt = /* @__PURE__ */ new Date();
4196
+ stores.aiConversations.set(id, conversation);
4197
+ return Promise.resolve(true);
4198
+ },
4199
+ addMessage(input) {
4200
+ const now = /* @__PURE__ */ new Date();
4201
+ const message = {
4202
+ id: generateId(),
4203
+ conversationId: input.conversationId,
4204
+ role: input.role,
4205
+ content: input.content,
4206
+ thinkingLevel: _nullishCoalesce(input.thinkingLevel, () => ( null)),
4207
+ thinkingSummary: _nullishCoalesce(input.thinkingSummary, () => ( null)),
4208
+ toolCalls: _nullishCoalesce(input.toolCalls, () => ( null)),
4209
+ inputTokens: _nullishCoalesce(input.inputTokens, () => ( null)),
4210
+ outputTokens: _nullishCoalesce(input.outputTokens, () => ( null)),
4211
+ cost: _nullishCoalesce(input.cost, () => ( null)),
4212
+ provider: _nullishCoalesce(input.provider, () => ( null)),
4213
+ model: _nullishCoalesce(input.model, () => ( null)),
4214
+ attachmentIds: _nullishCoalesce(input.attachmentIds, () => ( null)),
4215
+ createdAt: now
4216
+ };
4217
+ stores.aiMessages.set(message.id, message);
4218
+ const conversation = stores.aiConversations.get(input.conversationId);
4219
+ if (conversation) {
4220
+ conversation.messageCount++;
4221
+ conversation.totalTokens += (_nullishCoalesce(input.inputTokens, () => ( 0))) + (_nullishCoalesce(input.outputTokens, () => ( 0)));
4222
+ conversation.totalCost += _nullishCoalesce(input.cost, () => ( 0));
4223
+ conversation.updatedAt = now;
4224
+ stores.aiConversations.set(input.conversationId, conversation);
4225
+ }
4226
+ return Promise.resolve(message);
4227
+ },
4228
+ listMessages(conversationId, options) {
4229
+ let results = Array.from(stores.aiMessages.values()).filter((m) => m.conversationId === conversationId).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
4230
+ const total = results.length;
4231
+ if (_optionalChain([options, 'optionalAccess', _82 => _82.limit])) {
4232
+ results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
4233
+ }
4234
+ return Promise.resolve({ messages: results, total });
4235
+ },
4236
+ getRecentMessages(conversationId, count = 20) {
4237
+ const results = Array.from(stores.aiMessages.values()).filter((m) => m.conversationId === conversationId).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime()).slice(-count);
4238
+ return Promise.resolve(results);
4239
+ }
4240
+ };
4241
+ }
4242
+ function createMockAIUserMemoryRepository(stores) {
4243
+ const getKey = () => {
4244
+ const tenantId = getTenantId();
4245
+ const userId = requireUserId();
4246
+ return `${tenantId}:${userId}`;
4247
+ };
4248
+ return {
4249
+ get() {
4250
+ const key = getKey();
4251
+ return Promise.resolve(_nullishCoalesce(stores.aiUserMemory.get(key), () => ( null)));
4252
+ },
4253
+ upsert(data) {
4254
+ const key = getKey();
4255
+ const tenantId = getTenantId();
4256
+ const userId = requireUserId();
4257
+ const now = /* @__PURE__ */ new Date();
4258
+ const existing = stores.aiUserMemory.get(key);
4259
+ const memory = {
4260
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _83 => _83.id]), () => ( generateId())),
4261
+ tenantId,
4262
+ userId,
4263
+ preferences: _nullishCoalesce(_nullishCoalesce(data.preferences, () => ( _optionalChain([existing, 'optionalAccess', _84 => _84.preferences]))), () => ( {})),
4264
+ facts: _nullishCoalesce(_nullishCoalesce(data.facts, () => ( _optionalChain([existing, 'optionalAccess', _85 => _85.facts]))), () => ( [])),
4265
+ createdAt: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _86 => _86.createdAt]), () => ( now)),
4266
+ updatedAt: now
4267
+ };
4268
+ stores.aiUserMemory.set(key, memory);
4269
+ return Promise.resolve(memory);
4270
+ },
4271
+ addFact(fact) {
4272
+ const key = getKey();
4273
+ const tenantId = getTenantId();
4274
+ const userId = requireUserId();
4275
+ const now = /* @__PURE__ */ new Date();
4276
+ const existing = stores.aiUserMemory.get(key);
4277
+ const memory = {
4278
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _87 => _87.id]), () => ( generateId())),
4279
+ tenantId,
4280
+ userId,
4281
+ preferences: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _88 => _88.preferences]), () => ( {})),
4282
+ facts: [..._nullishCoalesce(_optionalChain([existing, 'optionalAccess', _89 => _89.facts]), () => ( [])), fact],
4283
+ createdAt: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _90 => _90.createdAt]), () => ( now)),
4284
+ updatedAt: now
4285
+ };
4286
+ stores.aiUserMemory.set(key, memory);
4287
+ return Promise.resolve(memory);
4288
+ },
4289
+ removeFact(fact) {
4290
+ const key = getKey();
4291
+ const tenantId = getTenantId();
4292
+ const userId = requireUserId();
4293
+ const now = /* @__PURE__ */ new Date();
4294
+ const existing = stores.aiUserMemory.get(key);
4295
+ const memory = {
4296
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _91 => _91.id]), () => ( generateId())),
4297
+ tenantId,
4298
+ userId,
4299
+ preferences: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _92 => _92.preferences]), () => ( {})),
4300
+ facts: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _93 => _93.facts]), () => ( []))).filter((f) => f !== fact),
4301
+ createdAt: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _94 => _94.createdAt]), () => ( now)),
4302
+ updatedAt: now
4303
+ };
4304
+ stores.aiUserMemory.set(key, memory);
4305
+ return Promise.resolve(memory);
4306
+ },
4307
+ setPreference(prefKey, value) {
4308
+ const memoryKey = getKey();
4309
+ const tenantId = getTenantId();
4310
+ const userId = requireUserId();
4311
+ const now = /* @__PURE__ */ new Date();
4312
+ const existing = stores.aiUserMemory.get(memoryKey);
4313
+ const memory = {
4314
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _95 => _95.id]), () => ( generateId())),
4315
+ tenantId,
4316
+ userId,
4317
+ preferences: { ..._nullishCoalesce(_optionalChain([existing, 'optionalAccess', _96 => _96.preferences]), () => ( {})), [prefKey]: value },
4318
+ facts: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _97 => _97.facts]), () => ( [])),
4319
+ createdAt: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _98 => _98.createdAt]), () => ( now)),
4320
+ updatedAt: now
4321
+ };
4322
+ stores.aiUserMemory.set(memoryKey, memory);
4323
+ return Promise.resolve(memory);
4324
+ },
4325
+ clear() {
4326
+ const key = getKey();
4327
+ stores.aiUserMemory.delete(key);
4328
+ return Promise.resolve();
4329
+ }
4330
+ };
4331
+ }
4332
+ function createMockAIUsageMetricsRepository(stores) {
4333
+ const getDateKey = (date2) => {
4334
+ const tenantId = getTenantId();
4335
+ const dateStr = date2.toISOString().split("T")[0];
4336
+ return `${tenantId}:${dateStr}`;
4337
+ };
4338
+ return {
4339
+ recordUsage(data) {
4340
+ const tenantId = getTenantId();
4341
+ const now = /* @__PURE__ */ new Date();
4342
+ const key = getDateKey(now);
4343
+ const existing = stores.aiUsageMetrics.get(key);
4344
+ const providerBreakdown = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _99 => _99.providerBreakdown]), () => ( {}));
4345
+ if (!providerBreakdown[data.provider]) {
4346
+ providerBreakdown[data.provider] = { requests: 0, tokens: 0, cost: 0 };
4347
+ }
4348
+ providerBreakdown[data.provider].requests++;
4349
+ providerBreakdown[data.provider].tokens += data.tokens;
4350
+ providerBreakdown[data.provider].cost += data.cost;
4351
+ const toolUsage = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _100 => _100.toolUsage]), () => ( {}));
4352
+ if (data.toolName) {
4353
+ toolUsage[data.toolName] = (_nullishCoalesce(toolUsage[data.toolName], () => ( 0))) + 1;
4354
+ }
4355
+ const metrics = {
4356
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _101 => _101.id]), () => ( generateId())),
4357
+ tenantId,
4358
+ date: new Date(_nullishCoalesce(now.toISOString().split("T")[0], () => ( now.toISOString()))),
4359
+ requestCount: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _102 => _102.requestCount]), () => ( 0))) + 1,
4360
+ totalTokens: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _103 => _103.totalTokens]), () => ( 0))) + data.tokens,
4361
+ totalCost: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _104 => _104.totalCost]), () => ( 0))) + data.cost,
4362
+ providerBreakdown,
4363
+ toolUsage
4364
+ };
4365
+ stores.aiUsageMetrics.set(key, metrics);
4366
+ return Promise.resolve();
4367
+ },
4368
+ getByDateRange(startDate, endDate) {
4369
+ const tenantId = getTenantId();
4370
+ const results = Array.from(stores.aiUsageMetrics.values()).filter((m) => {
4371
+ if (m.tenantId !== tenantId) return false;
4372
+ return m.date >= startDate && m.date <= endDate;
4373
+ });
4374
+ results.sort((a, b) => a.date.getTime() - b.date.getTime());
4375
+ return Promise.resolve(results);
4376
+ },
4377
+ getCurrentMonthUsage() {
4378
+ const tenantId = getTenantId();
4379
+ const now = /* @__PURE__ */ new Date();
4380
+ const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
4381
+ const monthMetrics = Array.from(stores.aiUsageMetrics.values()).filter((m) => {
4382
+ if (m.tenantId !== tenantId) return false;
4383
+ return m.date >= startOfMonth;
4384
+ });
4385
+ const aggregated = {
4386
+ requestCount: 0,
4387
+ totalTokens: 0,
4388
+ totalCost: 0,
4389
+ providerBreakdown: {}
4390
+ };
4391
+ for (const m of monthMetrics) {
4392
+ aggregated.requestCount += m.requestCount;
4393
+ aggregated.totalTokens += m.totalTokens;
4394
+ aggregated.totalCost += m.totalCost;
4395
+ for (const [provider, stats] of Object.entries(m.providerBreakdown)) {
4396
+ if (!aggregated.providerBreakdown[provider]) {
4397
+ aggregated.providerBreakdown[provider] = { requests: 0, tokens: 0, cost: 0 };
4398
+ }
4399
+ aggregated.providerBreakdown[provider].requests += stats.requests;
4400
+ aggregated.providerBreakdown[provider].tokens += stats.tokens;
4401
+ aggregated.providerBreakdown[provider].cost += stats.cost;
4402
+ }
4403
+ }
4404
+ return Promise.resolve(aggregated);
4405
+ }
4406
+ };
4407
+ }
4126
4408
  function createMockAdapter() {
4127
4409
  const stores = {
4128
4410
  objects: /* @__PURE__ */ new Map(),
@@ -4136,7 +4418,12 @@ function createMockAdapter() {
4136
4418
  userRoles: /* @__PURE__ */ new Map(),
4137
4419
  workflows: /* @__PURE__ */ new Map(),
4138
4420
  workflowInstances: /* @__PURE__ */ new Map(),
4139
- workflowParticipations: /* @__PURE__ */ new Map()
4421
+ workflowParticipations: /* @__PURE__ */ new Map(),
4422
+ // AI stores
4423
+ aiConversations: /* @__PURE__ */ new Map(),
4424
+ aiMessages: /* @__PURE__ */ new Map(),
4425
+ aiUserMemory: /* @__PURE__ */ new Map(),
4426
+ aiUsageMetrics: /* @__PURE__ */ new Map()
4140
4427
  };
4141
4428
  const adapter = {
4142
4429
  objects: createMockObjectsRepository(stores),
@@ -4149,6 +4436,10 @@ function createMockAdapter() {
4149
4436
  workflows: createMockWorkflowsRepository(stores),
4150
4437
  workflowInstances: createMockWorkflowInstancesRepository(stores),
4151
4438
  workflowParticipations: createMockWorkflowParticipationsRepository(stores),
4439
+ // AI repositories
4440
+ aiConversations: createMockAIConversationsRepository(stores),
4441
+ aiUserMemory: createMockAIUserMemoryRepository(stores),
4442
+ aiUsageMetrics: createMockAIUsageMetricsRepository(stores),
4152
4443
  async transaction(callback) {
4153
4444
  return await callback(adapter);
4154
4445
  },
@@ -4168,6 +4459,10 @@ function createMockAdapter() {
4168
4459
  stores.workflows.clear();
4169
4460
  stores.workflowInstances.clear();
4170
4461
  stores.workflowParticipations.clear();
4462
+ stores.aiConversations.clear();
4463
+ stores.aiMessages.clear();
4464
+ stores.aiUserMemory.clear();
4465
+ stores.aiUsageMetrics.clear();
4171
4466
  }
4172
4467
  };
4173
4468
  return adapter;
@@ -4261,7 +4556,7 @@ var notesPolicy = {
4261
4556
  { attribute: "visibility", operator: "is", value: "shared" },
4262
4557
  { attribute: "createdBy", operator: "is", value: ctx.userId }
4263
4558
  ];
4264
- if (!_optionalChain([options, 'optionalAccess', _80 => _80.filters]) || options.filters.rules.length === 0) {
4559
+ if (!_optionalChain([options, 'optionalAccess', _105 => _105.filters]) || options.filters.rules.length === 0) {
4265
4560
  return {
4266
4561
  ...options,
4267
4562
  filters: { combinator: "or", rules: visibilityRules }
@@ -4407,7 +4702,7 @@ var BaseService = class {
4407
4702
  * @param key - Cache key to invalidate
4408
4703
  */
4409
4704
  async invalidateCache(key) {
4410
- await _optionalChain([this, 'access', _81 => _81.cache, 'optionalAccess', _82 => _82.delete, 'call', _83 => _83(key)]);
4705
+ await _optionalChain([this, 'access', _106 => _106.cache, 'optionalAccess', _107 => _107.delete, 'call', _108 => _108(key)]);
4411
4706
  }
4412
4707
  /**
4413
4708
  * Invalidate all cache keys matching a pattern.
@@ -4415,7 +4710,7 @@ var BaseService = class {
4415
4710
  * @param pattern - Glob-style pattern (e.g., "schema:tenant-123:*")
4416
4711
  */
4417
4712
  async invalidateCachePattern(pattern) {
4418
- await _optionalChain([this, 'access', _84 => _84.cache, 'optionalAccess', _85 => _85.deletePattern, 'call', _86 => _86(pattern)]);
4713
+ await _optionalChain([this, 'access', _109 => _109.cache, 'optionalAccess', _110 => _110.deletePattern, 'call', _111 => _111(pattern)]);
4419
4714
  }
4420
4715
  /**
4421
4716
  * Invalidate all cached lists for a resource.
@@ -4615,17 +4910,17 @@ function validateOptions(options, attributeName) {
4615
4910
  const ids = /* @__PURE__ */ new Set();
4616
4911
  const values = /* @__PURE__ */ new Set();
4617
4912
  for (const option of options) {
4618
- if (!_optionalChain([option, 'access', _87 => _87.id, 'optionalAccess', _88 => _88.trim, 'call', _89 => _89()])) {
4913
+ if (!_optionalChain([option, 'access', _112 => _112.id, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()])) {
4619
4914
  throw new Error(
4620
4915
  `[AttributeBuilder] Option in "${attributeName}" has an empty or missing id.`
4621
4916
  );
4622
4917
  }
4623
- if (!_optionalChain([option, 'access', _90 => _90.value, 'optionalAccess', _91 => _91.trim, 'call', _92 => _92()])) {
4918
+ if (!_optionalChain([option, 'access', _115 => _115.value, 'optionalAccess', _116 => _116.trim, 'call', _117 => _117()])) {
4624
4919
  throw new Error(
4625
4920
  `[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing value.`
4626
4921
  );
4627
4922
  }
4628
- if (!_optionalChain([option, 'access', _93 => _93.label, 'optionalAccess', _94 => _94.trim, 'call', _95 => _95()])) {
4923
+ if (!_optionalChain([option, 'access', _118 => _118.label, 'optionalAccess', _119 => _119.trim, 'call', _120 => _120()])) {
4629
4924
  throw new Error(
4630
4925
  `[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing label.`
4631
4926
  );
@@ -5146,7 +5441,7 @@ var SingleRelationAttributeBuilder = class extends BaseAttributeBuilder {
5146
5441
  object: objectName,
5147
5442
  ...options
5148
5443
  };
5149
- _optionalChain([this, 'access', _96 => _96.attr, 'access', _97 => _97.targets, 'optionalAccess', _98 => _98.push, 'call', _99 => _99(target)]);
5444
+ _optionalChain([this, 'access', _121 => _121.attr, 'access', _122 => _122.targets, 'optionalAccess', _123 => _123.push, 'call', _124 => _124(target)]);
5150
5445
  return this;
5151
5446
  }
5152
5447
  /**
@@ -5191,9 +5486,9 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
5191
5486
  constructor(name, label, initOptions) {
5192
5487
  super("relation", name, label);
5193
5488
  this.attr.cardinality = "many";
5194
- this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _100 => _100.targets]), () => ( []));
5489
+ this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _125 => _125.targets]), () => ( []));
5195
5490
  this.attr.defaultValue = [];
5196
- if (_optionalChain([initOptions, 'optionalAccess', _101 => _101.isRequired])) {
5491
+ if (_optionalChain([initOptions, 'optionalAccess', _126 => _126.isRequired])) {
5197
5492
  this.setRequired(true);
5198
5493
  }
5199
5494
  }
@@ -5207,7 +5502,7 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
5207
5502
  object: objectName,
5208
5503
  ...options
5209
5504
  };
5210
- _optionalChain([this, 'access', _102 => _102.attr, 'access', _103 => _103.targets, 'optionalAccess', _104 => _104.push, 'call', _105 => _105(target)]);
5505
+ _optionalChain([this, 'access', _127 => _127.attr, 'access', _128 => _128.targets, 'optionalAccess', _129 => _129.push, 'call', _130 => _130(target)]);
5211
5506
  return this;
5212
5507
  }
5213
5508
  /**
@@ -5581,7 +5876,7 @@ var GroupBuilder = class {
5581
5876
  */
5582
5877
  fields(...names) {
5583
5878
  for (const name of names) {
5584
- _optionalChain([this, 'access', _106 => _106.data, 'access', _107 => _107.fields, 'optionalAccess', _108 => _108.push, 'call', _109 => _109({ attribute: name })]);
5879
+ _optionalChain([this, 'access', _131 => _131.data, 'access', _132 => _132.fields, 'optionalAccess', _133 => _133.push, 'call', _134 => _134({ attribute: name })]);
5585
5880
  }
5586
5881
  return this;
5587
5882
  }
@@ -5590,7 +5885,7 @@ var GroupBuilder = class {
5590
5885
  * @example .field("name", { span: 8, readOnly: true })
5591
5886
  */
5592
5887
  field(attribute, options) {
5593
- _optionalChain([this, 'access', _110 => _110.data, 'access', _111 => _111.fields, 'optionalAccess', _112 => _112.push, 'call', _113 => _113({ attribute, ...options })]);
5888
+ _optionalChain([this, 'access', _135 => _135.data, 'access', _136 => _136.fields, 'optionalAccess', _137 => _137.push, 'call', _138 => _138({ attribute, ...options })]);
5594
5889
  return this;
5595
5890
  }
5596
5891
  /**
@@ -5599,7 +5894,7 @@ var GroupBuilder = class {
5599
5894
  * @example .attributeGroup({ id: "address", label: "Address", attributes: ["street", "city", "postal_code"], displayTemplate: "{street}, {city}" })
5600
5895
  */
5601
5896
  attributeGroup(config, options) {
5602
- _optionalChain([this, 'access', _114 => _114.data, 'access', _115 => _115.fields, 'optionalAccess', _116 => _116.push, 'call', _117 => _117({ attributeGroup: config, ...options })]);
5897
+ _optionalChain([this, 'access', _139 => _139.data, 'access', _140 => _140.fields, 'optionalAccess', _141 => _141.push, 'call', _142 => _142({ attributeGroup: config, ...options })]);
5603
5898
  return this;
5604
5899
  }
5605
5900
  /**
@@ -6091,14 +6386,14 @@ var ViewBuilder = class {
6091
6386
  * Add a pre-built tab
6092
6387
  */
6093
6388
  addTab(tab) {
6094
- _optionalChain([this, 'access', _118 => _118.data, 'access', _119 => _119.tabs, 'optionalAccess', _120 => _120.push, 'call', _121 => _121(tab)]);
6389
+ _optionalChain([this, 'access', _143 => _143.data, 'access', _144 => _144.tabs, 'optionalAccess', _145 => _145.push, 'call', _146 => _146(tab)]);
6095
6390
  return this;
6096
6391
  }
6097
6392
  /**
6098
6393
  * @internal Used by TabBuilder to add tabs
6099
6394
  */
6100
6395
  _addTab(tab) {
6101
- _optionalChain([this, 'access', _122 => _122.data, 'access', _123 => _123.tabs, 'optionalAccess', _124 => _124.push, 'call', _125 => _125(tab)]);
6396
+ _optionalChain([this, 'access', _147 => _147.data, 'access', _148 => _148.tabs, 'optionalAccess', _149 => _149.push, 'call', _150 => _150(tab)]);
6102
6397
  return this;
6103
6398
  }
6104
6399
  /**
@@ -6176,8 +6471,8 @@ var WorkflowFormRowBuilder = class {
6176
6471
  id: `${this.rowData.id}-${slotId}-${attribute}`,
6177
6472
  slotId,
6178
6473
  attribute,
6179
- label: _optionalChain([options, 'optionalAccess', _126 => _126.label]),
6180
- required: _optionalChain([options, 'optionalAccess', _127 => _127.required])
6474
+ label: _optionalChain([options, 'optionalAccess', _151 => _151.label]),
6475
+ required: _optionalChain([options, 'optionalAccess', _152 => _152.required])
6181
6476
  };
6182
6477
  this.rowData.fields.push(field);
6183
6478
  return this;
@@ -6542,7 +6837,7 @@ var WorkflowBuilder = class {
6542
6837
  * @param options - Slot configuration
6543
6838
  */
6544
6839
  slot(id, objectName, options) {
6545
- if (_optionalChain([this, 'access', _128 => _128.data, 'access', _129 => _129.slots, 'optionalAccess', _130 => _130.some, 'call', _131 => _131((s) => s.id === id)])) {
6840
+ if (_optionalChain([this, 'access', _153 => _153.data, 'access', _154 => _154.slots, 'optionalAccess', _155 => _155.some, 'call', _156 => _156((s) => s.id === id)])) {
6546
6841
  throw new Error(`[WorkflowBuilder] Duplicate slot id: "${id}"`);
6547
6842
  }
6548
6843
  const slot = {
@@ -6553,7 +6848,7 @@ var WorkflowBuilder = class {
6553
6848
  color: options.color,
6554
6849
  icon: options.icon
6555
6850
  };
6556
- _optionalChain([this, 'access', _132 => _132.data, 'access', _133 => _133.slots, 'optionalAccess', _134 => _134.push, 'call', _135 => _135(slot)]);
6851
+ _optionalChain([this, 'access', _157 => _157.data, 'access', _158 => _158.slots, 'optionalAccess', _159 => _159.push, 'call', _160 => _160(slot)]);
6557
6852
  return this;
6558
6853
  }
6559
6854
  // ============================================================================
@@ -6567,7 +6862,7 @@ var WorkflowBuilder = class {
6567
6862
  }
6568
6863
  /** @internal */
6569
6864
  _addParticipant(template) {
6570
- _optionalChain([this, 'access', _136 => _136.data, 'access', _137 => _137.participants, 'optionalAccess', _138 => _138.push, 'call', _139 => _139(template)]);
6865
+ _optionalChain([this, 'access', _161 => _161.data, 'access', _162 => _162.participants, 'optionalAccess', _163 => _163.push, 'call', _164 => _164(template)]);
6571
6866
  return this;
6572
6867
  }
6573
6868
  // ============================================================================
@@ -6700,7 +6995,7 @@ var WorkflowBuilder = class {
6700
6995
  }
6701
6996
  }
6702
6997
  validateSlotReferences() {
6703
- const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _140 => _140.data, 'access', _141 => _141.slots, 'optionalAccess', _142 => _142.map, 'call', _143 => _143((s) => s.id)]), () => ( [])));
6998
+ const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _165 => _165.data, 'access', _166 => _166.slots, 'optionalAccess', _167 => _167.map, 'call', _168 => _168((s) => s.id)]), () => ( [])));
6704
6999
  for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
6705
7000
  if (node.type === "form") {
6706
7001
  const referencedSlots = /* @__PURE__ */ new Set();
@@ -6727,7 +7022,7 @@ var WorkflowBuilder = class {
6727
7022
  }
6728
7023
  }
6729
7024
  validateParticipantReferences() {
6730
- const participantIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _144 => _144.data, 'access', _145 => _145.participants, 'optionalAccess', _146 => _146.map, 'call', _147 => _147((p) => p.id)]), () => ( [])));
7025
+ const participantIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _169 => _169.data, 'access', _170 => _170.participants, 'optionalAccess', _171 => _171.map, 'call', _172 => _172((p) => p.id)]), () => ( [])));
6731
7026
  for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
6732
7027
  if (node.type === "form" && node.participantId) {
6733
7028
  if (!participantIds.has(node.participantId)) {
@@ -7373,7 +7668,7 @@ function validateObject(objectDef, data) {
7373
7668
  function validateObjectOrThrow(objectDef, data) {
7374
7669
  const result = validateObject(objectDef, data);
7375
7670
  if (!result.success) {
7376
- const errorMessages = _optionalChain([result, 'access', _148 => _148.errors, 'optionalAccess', _149 => _149.map, 'call', _150 => _150((err) => `${err.path.join(".")}: ${err.message}`), 'access', _151 => _151.join, 'call', _152 => _152("\n")]) || "Unknown validation error";
7671
+ const errorMessages = _optionalChain([result, 'access', _173 => _173.errors, 'optionalAccess', _174 => _174.map, 'call', _175 => _175((err) => `${err.path.join(".")}: ${err.message}`), 'access', _176 => _176.join, 'call', _177 => _177("\n")]) || "Unknown validation error";
7377
7672
  throw new Error(`Validation failed for ${objectDef.label}:
7378
7673
  ${errorMessages}`);
7379
7674
  }
@@ -7407,7 +7702,7 @@ function validateDraft(objectDef, data) {
7407
7702
  function validateDraftOrThrow(objectDef, data) {
7408
7703
  const result = validateDraft(objectDef, data);
7409
7704
  if (!result.success) {
7410
- const errorMessages = _optionalChain([result, 'access', _153 => _153.errors, 'optionalAccess', _154 => _154.map, 'call', _155 => _155((err) => `${err.path.join(".")}: ${err.message}`), 'access', _156 => _156.join, 'call', _157 => _157("\n")]) || "Unknown validation error";
7705
+ const errorMessages = _optionalChain([result, 'access', _178 => _178.errors, 'optionalAccess', _179 => _179.map, 'call', _180 => _180((err) => `${err.path.join(".")}: ${err.message}`), 'access', _181 => _181.join, 'call', _182 => _182("\n")]) || "Unknown validation error";
7411
7706
  throw new Error(`Draft validation failed for ${objectDef.label}:
7412
7707
  ${errorMessages}`);
7413
7708
  }
@@ -7463,7 +7758,7 @@ var ObjectSchemaService = class extends BaseService {
7463
7758
  constructor(adapter, nativeRegistry, options) {
7464
7759
  super(adapter);
7465
7760
  this.nativeRegistry = nativeRegistry;
7466
- this.auditService = _optionalChain([options, 'optionalAccess', _158 => _158.auditService]);
7761
+ this.auditService = _optionalChain([options, 'optionalAccess', _183 => _183.auditService]);
7467
7762
  }
7468
7763
  /**
7469
7764
  * Create a new custom object.
@@ -7661,7 +7956,7 @@ var ObjectSchemaService = class extends BaseService {
7661
7956
  resourceType: "attribute",
7662
7957
  resourceId: attributeId,
7663
7958
  resourceLabel: updatedDbAttr.label,
7664
- objectName: _optionalChain([dbObject, 'optionalAccess', _159 => _159.name]),
7959
+ objectName: _optionalChain([dbObject, 'optionalAccess', _184 => _184.name]),
7665
7960
  objectId: dbAttr.objectId,
7666
7961
  changes
7667
7962
  });
@@ -7694,7 +7989,7 @@ var ObjectSchemaService = class extends BaseService {
7694
7989
  );
7695
7990
  }
7696
7991
  const dbObject = await this.adapter.objects.findById(dbAttr.objectId);
7697
- if (_optionalChain([dbObject, 'optionalAccess', _160 => _160.labelExpression])) {
7992
+ if (_optionalChain([dbObject, 'optionalAccess', _185 => _185.labelExpression])) {
7698
7993
  const usedAttributes = extractAttributeNames(dbObject.labelExpression);
7699
7994
  if (usedAttributes.includes(dbAttr.name)) {
7700
7995
  throw new AttributeInUseError(dbAttr.name, "labelExpression");
@@ -7710,7 +8005,7 @@ var ObjectSchemaService = class extends BaseService {
7710
8005
  resourceType: "attribute",
7711
8006
  resourceId: attributeId,
7712
8007
  resourceLabel: dbAttr.label,
7713
- objectName: _optionalChain([dbObject, 'optionalAccess', _161 => _161.name]),
8008
+ objectName: _optionalChain([dbObject, 'optionalAccess', _186 => _186.name]),
7714
8009
  objectId: dbAttr.objectId
7715
8010
  });
7716
8011
  }
@@ -7725,9 +8020,9 @@ var ObjectSchemaService = class extends BaseService {
7725
8020
  async listAttributes(objectId, options) {
7726
8021
  const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
7727
8022
  let filtered = dbAttributes;
7728
- if (_optionalChain([options, 'optionalAccess', _162 => _162.systemOnly])) {
8023
+ if (_optionalChain([options, 'optionalAccess', _187 => _187.systemOnly])) {
7729
8024
  filtered = dbAttributes.filter((attr) => attr.system);
7730
- } else if (_optionalChain([options, 'optionalAccess', _163 => _163.customOnly])) {
8025
+ } else if (_optionalChain([options, 'optionalAccess', _188 => _188.customOnly])) {
7731
8026
  filtered = dbAttributes.filter((attr) => !attr.system);
7732
8027
  }
7733
8028
  return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
@@ -7763,14 +8058,14 @@ var ObjectSchemaService = class extends BaseService {
7763
8058
  pluralLabel: dbObject.pluralLabel,
7764
8059
  description: dbObject.description,
7765
8060
  labelExpression: dbObject.labelExpression,
7766
- icon: _optionalChain([dbObject, 'access', _164 => _164.metadata, 'optionalAccess', _165 => _165.icon])
8061
+ icon: _optionalChain([dbObject, 'access', _189 => _189.metadata, 'optionalAccess', _190 => _190.icon])
7767
8062
  };
7768
8063
  let metadata = dbObject.metadata;
7769
8064
  if (updates.icon !== void 0 || updates.metadata !== void 0) {
7770
8065
  metadata = {
7771
8066
  ...dbObject.metadata,
7772
8067
  ...updates.metadata,
7773
- icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _166 => _166.metadata, 'optionalAccess', _167 => _167.icon])))
8068
+ icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _191 => _191.metadata, 'optionalAccess', _192 => _192.icon])))
7774
8069
  };
7775
8070
  }
7776
8071
  const updatedDbObject = await this.adapter.objects.update(objectId, {
@@ -8029,7 +8324,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
8029
8324
  label: dbObject.label,
8030
8325
  pluralLabel: dbObject.pluralLabel,
8031
8326
  description: dbObject.description,
8032
- icon: _optionalChain([dbObject, 'access', _168 => _168.metadata, 'optionalAccess', _169 => _169.icon]),
8327
+ icon: _optionalChain([dbObject, 'access', _193 => _193.metadata, 'optionalAccess', _194 => _194.icon]),
8033
8328
  labelExpression: dbObject.labelExpression,
8034
8329
  attributes,
8035
8330
  system: dbObject.system,
@@ -8129,7 +8424,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
8129
8424
  const hasRelationToTarget = attrs.some((attr) => {
8130
8425
  if (attr.type !== "relation") return false;
8131
8426
  const config = attr.config;
8132
- return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _170 => _170.targets, 'optionalAccess', _171 => _171.some, 'call', _172 => _172((t) => t.object === targetObjectName)]), () => ( false));
8427
+ return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _195 => _195.targets, 'optionalAccess', _196 => _196.some, 'call', _197 => _197((t) => t.object === targetObjectName)]), () => ( false));
8133
8428
  });
8134
8429
  if (hasRelationToTarget) {
8135
8430
  referencing.push(obj.name);
@@ -8279,7 +8574,7 @@ var SyncError = class extends SchemaError {
8279
8574
  constructor(objectName, message, cause) {
8280
8575
  super(`Failed to sync object "${objectName}": ${message}`, SchemaErrorCode.SYNC_FAILED, {
8281
8576
  objectName,
8282
- cause: _optionalChain([cause, 'optionalAccess', _173 => _173.message])
8577
+ cause: _optionalChain([cause, 'optionalAccess', _198 => _198.message])
8283
8578
  });
8284
8579
  this.name = "SyncError";
8285
8580
  this.objectName = objectName;
@@ -8407,7 +8702,7 @@ Native objects must have system=true. Did you forget to call .system() in your b
8407
8702
  const existing = this.objects.get(object2.name);
8408
8703
  throw new Error(
8409
8704
  `[NativeObjectRegistry] Duplicate object name "${object2.name}":
8410
- - Existing: "${_optionalChain([existing, 'optionalAccess', _174 => _174.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _175 => _175.id])})
8705
+ - Existing: "${_optionalChain([existing, 'optionalAccess', _199 => _199.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _200 => _200.id])})
8411
8706
  - New: "${object2.label}" (id: ${object2.id})
8412
8707
  Please use unique names for each native object.`
8413
8708
  );
@@ -8524,7 +8819,7 @@ var AuditService = class extends BaseService {
8524
8819
  this.isFlushing = false;
8525
8820
  /** Pending flush promise to allow waiting on concurrent flush */
8526
8821
  this.flushPromise = null;
8527
- if (_optionalChain([options, 'optionalAccess', _176 => _176.async]) && options.flushIntervalMs) {
8822
+ if (_optionalChain([options, 'optionalAccess', _201 => _201.async]) && options.flushIntervalMs) {
8528
8823
  this.startFlushTimer();
8529
8824
  }
8530
8825
  }
@@ -8721,7 +9016,7 @@ var AuditService = class extends BaseService {
8721
9016
  if (!this.adapter.audit) {
8722
9017
  return;
8723
9018
  }
8724
- if (_optionalChain([this, 'access', _177 => _177.options, 'optionalAccess', _178 => _178.async])) {
9019
+ if (_optionalChain([this, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.async])) {
8725
9020
  this.buffer.push(entry);
8726
9021
  const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
8727
9022
  if (this.buffer.length >= batchSize) {
@@ -8735,7 +9030,7 @@ var AuditService = class extends BaseService {
8735
9030
  * Start the flush timer for async mode
8736
9031
  */
8737
9032
  startFlushTimer() {
8738
- const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _179 => _179.options, 'optionalAccess', _180 => _180.flushIntervalMs]), () => ( 1e3));
9033
+ const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.flushIntervalMs]), () => ( 1e3));
8739
9034
  this.flushTimer = setInterval(() => {
8740
9035
  this.flush().catch(console.error);
8741
9036
  }, intervalMs);
@@ -8842,7 +9137,7 @@ var UserService = class extends BaseService {
8842
9137
  if (roleErrors.length > 0) {
8843
9138
  errors.push({
8844
9139
  attribute: attrName,
8845
- message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _181 => _181.allowedRoles, 'optionalAccess', _182 => _182.join, 'call', _183 => _183(", ")])}`,
9140
+ message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _206 => _206.allowedRoles, 'optionalAccess', _207 => _207.join, 'call', _208 => _208(", ")])}`,
8846
9141
  invalidIds: roleErrors
8847
9142
  });
8848
9143
  }
@@ -9154,7 +9449,7 @@ var RecordQueryService = class extends BaseService {
9154
9449
  super(adapter);
9155
9450
  this.schemaService = schemaService;
9156
9451
  this.options = options;
9157
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _184 => _184.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _185 => _185.policyRegistry]), () => ( defaultPolicyRegistry));
9452
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _209 => _209.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _210 => _210.policyRegistry]), () => ( defaultPolicyRegistry));
9158
9453
  }
9159
9454
  // ============================================================================
9160
9455
  // LIST
@@ -9204,12 +9499,12 @@ var RecordQueryService = class extends BaseService {
9204
9499
  * Internal list query execution
9205
9500
  */
9206
9501
  async executeListQuery(schema, objectId, options) {
9207
- if (_optionalChain([this, 'access', _186 => _186.options, 'optionalAccess', _187 => _187.permissionService]) && this.userId) {
9502
+ if (_optionalChain([this, 'access', _211 => _211.options, 'optionalAccess', _212 => _212.permissionService]) && this.userId) {
9208
9503
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
9209
9504
  }
9210
- const policy = _optionalChain([options, 'optionalAccess', _188 => _188.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
9505
+ const policy = _optionalChain([options, 'optionalAccess', _213 => _213.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
9211
9506
  let effectiveOptions = options;
9212
- if (_optionalChain([policy, 'optionalAccess', _189 => _189.applyListFilter]) && this.userId) {
9507
+ if (_optionalChain([policy, 'optionalAccess', _214 => _214.applyListFilter]) && this.userId) {
9213
9508
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
9214
9509
  effectiveOptions = policy.applyListFilter(ctx, options);
9215
9510
  }
@@ -9219,12 +9514,12 @@ var RecordQueryService = class extends BaseService {
9219
9514
  );
9220
9515
  let filteredRecords = result.records;
9221
9516
  let effectiveTotal = result.total;
9222
- if (_optionalChain([policy, 'optionalAccess', _190 => _190.canAccessRecord]) && this.userId) {
9517
+ if (_optionalChain([policy, 'optionalAccess', _215 => _215.canAccessRecord]) && this.userId) {
9223
9518
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
9224
- filteredRecords = result.records.filter((record) => _optionalChain([policy, 'access', _191 => _191.canAccessRecord, 'optionalCall', _192 => _192(ctx, record)]));
9519
+ filteredRecords = result.records.filter((record) => _optionalChain([policy, 'access', _216 => _216.canAccessRecord, 'optionalCall', _217 => _217(ctx, record)]));
9225
9520
  effectiveTotal = filteredRecords.length;
9226
9521
  }
9227
- if (!_optionalChain([options, 'optionalAccess', _193 => _193.skipFormulas])) {
9522
+ if (!_optionalChain([options, 'optionalAccess', _218 => _218.skipFormulas])) {
9228
9523
  return {
9229
9524
  records: enrichRecordsWithFormulas(filteredRecords, schema),
9230
9525
  total: effectiveTotal
@@ -9284,14 +9579,14 @@ var RecordQueryService = class extends BaseService {
9284
9579
  * Internal search query execution
9285
9580
  */
9286
9581
  async executeSearchQuery(schema, objectId, query, options) {
9287
- if (_optionalChain([this, 'access', _194 => _194.options, 'optionalAccess', _195 => _195.permissionService]) && this.userId) {
9582
+ if (_optionalChain([this, 'access', _219 => _219.options, 'optionalAccess', _220 => _220.permissionService]) && this.userId) {
9288
9583
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
9289
9584
  }
9290
9585
  const result = await runWithSchemaContext(
9291
9586
  [schema],
9292
9587
  () => this.adapter.objectRecords.search(objectId, query, options)
9293
9588
  );
9294
- if (!_optionalChain([options, 'optionalAccess', _196 => _196.skipFormulas])) {
9589
+ if (!_optionalChain([options, 'optionalAccess', _221 => _221.skipFormulas])) {
9295
9590
  return {
9296
9591
  records: enrichRecordsWithFormulas(result.records, schema),
9297
9592
  total: result.total
@@ -9301,12 +9596,105 @@ var RecordQueryService = class extends BaseService {
9301
9596
  }
9302
9597
  };
9303
9598
 
9599
+ // src/runtime/services/record/record-resolver.service.ts
9600
+ var RecordResolverService = class extends BaseService {
9601
+ constructor(adapter) {
9602
+ super(adapter);
9603
+ }
9604
+ // ============================================================================
9605
+ // CACHED RECORD ACCESS
9606
+ // ============================================================================
9607
+ /**
9608
+ * Find a record by ID with caching.
9609
+ *
9610
+ * Uses the shared record cache for optimal performance.
9611
+ * Delegates to findByIds for consistent cache handling.
9612
+ *
9613
+ * @param id - Record ID
9614
+ * @returns Record or null if not found
9615
+ */
9616
+ async findById(id) {
9617
+ if (!id) return null;
9618
+ const results = await this.findByIds([id]);
9619
+ return _nullishCoalesce(results[0], () => ( null));
9620
+ }
9621
+ /**
9622
+ * Find multiple records by IDs with caching.
9623
+ *
9624
+ * Each record is cached individually for reuse across services.
9625
+ * Only fetches records not already in cache.
9626
+ *
9627
+ * @param ids - Record IDs to fetch
9628
+ * @returns Array of found records (missing IDs are not included)
9629
+ */
9630
+ async findByIds(ids) {
9631
+ if (!ids || ids.length === 0) {
9632
+ return [];
9633
+ }
9634
+ const uniqueIds = [...new Set(ids)];
9635
+ return this.cachedByMany(
9636
+ "record",
9637
+ uniqueIds,
9638
+ (missingIds) => this.adapter.objectRecords.findByIds(missingIds),
9639
+ (record) => record.id,
9640
+ cacheTtl.records
9641
+ );
9642
+ }
9643
+ // ============================================================================
9644
+ // FACTORY METHODS
9645
+ // ============================================================================
9646
+ /**
9647
+ * Create a RelationLabelResolver callback for computeLabelWithRelations.
9648
+ *
9649
+ * Used by RelationService.resolveLabel() and ObjectSchemaService.
9650
+ *
9651
+ * @returns Callback that resolves record IDs to their labels (cached)
9652
+ */
9653
+ createRelationLabelResolver() {
9654
+ return async (ids) => {
9655
+ const records = await this.findByIds(ids);
9656
+ return new Map(records.map((r) => [r.id, r.label]));
9657
+ };
9658
+ }
9659
+ /**
9660
+ * Create a LabelResolver interface for label computation helpers.
9661
+ *
9662
+ * Used by RecordService for computing record labels.
9663
+ *
9664
+ * @param relationService - RelationService for resolving relation display labels
9665
+ * @returns LabelResolver interface with cached record fetching
9666
+ */
9667
+ createLabelResolver(relationService) {
9668
+ return {
9669
+ resolveRelationIds: (ids, attrId) => relationService.resolveIds(ids, attrId),
9670
+ findRecordLabels: (ids) => this.findByIds(ids)
9671
+ };
9672
+ }
9673
+ /**
9674
+ * Create a RollupCascadeContext for rollup recalculation.
9675
+ *
9676
+ * Used by RecordService after create/update/delete operations.
9677
+ *
9678
+ * @param rollupService - RollupService for recalculating rollups
9679
+ * @param schemaService - ObjectSchemaService for fetching schemas
9680
+ * @returns Context with cached record fetching
9681
+ */
9682
+ createRollupContext(rollupService, schemaService) {
9683
+ return {
9684
+ rollupService,
9685
+ schemaService,
9686
+ findRecordsByIds: (ids) => this.findByIds(ids)
9687
+ };
9688
+ }
9689
+ };
9690
+
9304
9691
  // src/runtime/services/record/relation.service.ts
9305
9692
  var RelationService = class extends BaseService {
9306
9693
  constructor(adapter, nativeRegistry, options) {
9307
9694
  super(adapter);
9308
9695
  this.schemaService = new ObjectSchemaService(adapter, nativeRegistry);
9309
- this.queryService = _optionalChain([options, 'optionalAccess', _197 => _197.queryService]);
9696
+ this.queryService = options.queryService;
9697
+ this.recordResolver = options.recordResolver;
9310
9698
  }
9311
9699
  /**
9312
9700
  * Set the query service after construction.
@@ -9377,14 +9765,14 @@ var RelationService = class extends BaseService {
9377
9765
  }
9378
9766
  const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
9379
9767
  const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
9380
- if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _198 => _198.size]) === 0) {
9768
+ if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _222 => _222.size]) === 0) {
9381
9769
  errors.push({
9382
9770
  attribute: attr.name,
9383
9771
  message: `No valid target objects found for ${attr.label}`
9384
9772
  });
9385
9773
  return errors;
9386
9774
  }
9387
- const records = await this.adapter.objectRecords.findByIds(ids);
9775
+ const records = await this.recordResolver.findByIds(ids);
9388
9776
  const recordMap = new Map(records.map((r) => [r.id, r]));
9389
9777
  const invalidIds = [];
9390
9778
  for (const id of ids) {
@@ -9430,7 +9818,7 @@ var RelationService = class extends BaseService {
9430
9818
  for (const target of targets) {
9431
9819
  try {
9432
9820
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
9433
- if (_optionalChain([objectSchema, 'optionalAccess', _199 => _199.id])) {
9821
+ if (_optionalChain([objectSchema, 'optionalAccess', _223 => _223.id])) {
9434
9822
  objectIds.add(objectSchema.id);
9435
9823
  }
9436
9824
  } catch (e11) {
@@ -9494,7 +9882,7 @@ var RelationService = class extends BaseService {
9494
9882
  let totalCount = 0;
9495
9883
  for (const target of filteredTargets) {
9496
9884
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
9497
- if (!_optionalChain([objectSchema, 'optionalAccess', _200 => _200.id])) {
9885
+ if (!_optionalChain([objectSchema, 'optionalAccess', _224 => _224.id])) {
9498
9886
  continue;
9499
9887
  }
9500
9888
  const queryOptions = {
@@ -9506,20 +9894,7 @@ var RelationService = class extends BaseService {
9506
9894
  const result = query ? await queryService.searchRecords(objectSchema.id, query, queryOptions) : await queryService.listRecords(objectSchema.id, queryOptions);
9507
9895
  totalCount += result.total;
9508
9896
  for (const record of result.records) {
9509
- let label;
9510
- if (target.displayTemplate) {
9511
- label = await computeLabelWithRelations(
9512
- target.displayTemplate,
9513
- record.values,
9514
- objectSchema.attributes,
9515
- async (ids) => {
9516
- const linkedRecords = await this.adapter.objectRecords.findByIds(ids);
9517
- return new Map(linkedRecords.map((r) => [r.id, r.label]));
9518
- }
9519
- );
9520
- } else {
9521
- label = record.label;
9522
- }
9897
+ const label = await this.resolveLabel(record, objectSchema, target.displayTemplate);
9523
9898
  allOptions.push({
9524
9899
  id: record.id,
9525
9900
  objectId: objectSchema.id,
@@ -9557,17 +9932,8 @@ var RelationService = class extends BaseService {
9557
9932
  if (!ids || ids.length === 0) {
9558
9933
  return [];
9559
9934
  }
9560
- const compositeIds = ids.map((id) => `${attributeId}:${id}`);
9561
- return this.cachedByMany(
9562
- "resolvedRelation",
9563
- compositeIds,
9564
- async (missingCompositeIds) => {
9565
- const missingRecordIds = missingCompositeIds.map((c) => c.split(":")[1]);
9566
- return this.fetchResolveIds(missingRecordIds, attributeId);
9567
- },
9568
- (item) => `${attributeId}:${item.id}`,
9569
- cacheTtl.resolvedRelations
9570
- );
9935
+ const result = await this.resolveIdsBatch([{ attributeId, ids }]);
9936
+ return _nullishCoalesce(result[attributeId], () => ( []));
9571
9937
  }
9572
9938
  /**
9573
9939
  * Resolve multiple attribute/IDs batches in a single operation.
@@ -9610,7 +9976,7 @@ var RelationService = class extends BaseService {
9610
9976
  const allResolved = await this.cachedByMany(
9611
9977
  "resolvedRelation",
9612
9978
  allCompositeIds,
9613
- (missingCompositeIds) => this.fetchResolveIdsBatch(missingCompositeIds),
9979
+ (missingCompositeIds) => this.resolveCompositeIds(missingCompositeIds),
9614
9980
  (item) => item._compositeId,
9615
9981
  cacheTtl.resolvedRelations
9616
9982
  );
@@ -9631,10 +9997,12 @@ var RelationService = class extends BaseService {
9631
9997
  return response;
9632
9998
  }
9633
9999
  /**
9634
- * Internal method to fetch and resolve multiple composite IDs at once.
10000
+ * Internal method to resolve multiple composite IDs at once.
9635
10001
  * Optimized for batch operations - single DB query for all records.
10002
+ *
10003
+ * @param compositeIds - Array of composite IDs in format "attributeId:recordId"
9636
10004
  */
9637
- async fetchResolveIdsBatch(compositeIds) {
10005
+ async resolveCompositeIds(compositeIds) {
9638
10006
  if (compositeIds.length === 0) {
9639
10007
  return [];
9640
10008
  }
@@ -9644,7 +10012,7 @@ var RelationService = class extends BaseService {
9644
10012
  });
9645
10013
  const uniqueRecordIds = [...new Set(parsed.map((p) => p.recordId))];
9646
10014
  const uniqueAttributeIds = [...new Set(parsed.map((p) => p.attributeId))];
9647
- const records = await this.adapter.objectRecords.findByIds(uniqueRecordIds);
10015
+ const records = await this.recordResolver.findByIds(uniqueRecordIds);
9648
10016
  if (records.length === 0) {
9649
10017
  return [];
9650
10018
  }
@@ -9667,22 +10035,9 @@ var RelationService = class extends BaseService {
9667
10035
  continue;
9668
10036
  }
9669
10037
  const attribute = attributeMap.get(attributeId);
9670
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _201 => _201.targets, 'optionalAccess', _202 => _202.find, 'call', _203 => _203((t) => t.object === objectSchema.name)]);
9671
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _204 => _204.displayTemplate]);
9672
- let label;
9673
- if (customTemplate) {
9674
- label = await computeLabelWithRelations(
9675
- customTemplate,
9676
- record.values,
9677
- objectSchema.attributes,
9678
- async (nestedIds) => {
9679
- const linkedRecords = await this.adapter.objectRecords.findByIds(nestedIds);
9680
- return new Map(linkedRecords.map((r) => [r.id, r.label]));
9681
- }
9682
- );
9683
- } else {
9684
- label = record.label;
9685
- }
10038
+ const targetConfig = _optionalChain([attribute, 'optionalAccess', _225 => _225.targets, 'optionalAccess', _226 => _226.find, 'call', _227 => _227((t) => t.object === objectSchema.name)]);
10039
+ const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _228 => _228.displayTemplate]);
10040
+ const label = await this.resolveLabel(record, objectSchema, customTemplate);
9686
10041
  resolved.push({
9687
10042
  _compositeId: compositeId,
9688
10043
  id: record.id,
@@ -9696,59 +10051,22 @@ var RelationService = class extends BaseService {
9696
10051
  return resolved;
9697
10052
  }
9698
10053
  /**
9699
- * Internal method to fetch and resolve relation IDs (no caching).
9700
- * Uses batch fetching for performance - fetches all records in one query,
9701
- * then groups by objectId to minimize schema lookups.
10054
+ * Resolve the display label for a record.
10055
+ * Uses custom template if provided, otherwise falls back to pre-computed label.
9702
10056
  */
9703
- async fetchResolveIds(ids, attributeId) {
9704
- if (ids.length === 0) {
9705
- return [];
9706
- }
9707
- const attribute = await this.findAttributeById(attributeId);
9708
- const records = await this.adapter.objectRecords.findByIds(ids);
9709
- if (records.length === 0) {
9710
- return [];
9711
- }
9712
- const recordsByObjectId = /* @__PURE__ */ new Map();
9713
- for (const record of records) {
9714
- const existing = _nullishCoalesce(recordsByObjectId.get(record.objectId), () => ( []));
9715
- existing.push(record);
9716
- recordsByObjectId.set(record.objectId, existing);
9717
- }
9718
- const resolved = [];
9719
- for (const [objectId, objectRecords] of recordsByObjectId) {
9720
- const objectSchema = await this.schemaService.getObjectSchema(objectId);
9721
- if (!objectSchema) {
9722
- continue;
9723
- }
9724
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _205 => _205.targets, 'optionalAccess', _206 => _206.find, 'call', _207 => _207((t) => t.object === objectSchema.name)]);
9725
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _208 => _208.displayTemplate]);
9726
- for (const record of objectRecords) {
9727
- let label;
9728
- if (customTemplate) {
9729
- label = await computeLabelWithRelations(
9730
- customTemplate,
9731
- record.values,
9732
- objectSchema.attributes,
9733
- async (nestedIds) => {
9734
- const linkedRecords = await this.adapter.objectRecords.findByIds(nestedIds);
9735
- return new Map(linkedRecords.map((r) => [r.id, r.label]));
9736
- }
9737
- );
9738
- } else {
9739
- label = record.label;
10057
+ async resolveLabel(record, objectSchema, customTemplate) {
10058
+ if (customTemplate) {
10059
+ return computeLabelWithRelations(
10060
+ customTemplate,
10061
+ record.values,
10062
+ objectSchema.attributes,
10063
+ async (nestedIds) => {
10064
+ const linkedRecords = await this.recordResolver.findByIds(nestedIds);
10065
+ return new Map(linkedRecords.map((r) => [r.id, r.label]));
9740
10066
  }
9741
- resolved.push({
9742
- id: record.id,
9743
- objectId: record.objectId,
9744
- objectName: objectSchema.name,
9745
- objectLabel: objectSchema.label,
9746
- objectIcon: objectSchema.icon,
9747
- label
9748
- });
9749
- }
10067
+ );
9750
10068
  }
9751
- return resolved;
10069
+ return record.label;
9752
10070
  }
9753
10071
  /**
9754
10072
  * Find a relation attribute by ID.
@@ -9779,8 +10097,9 @@ var RelationService = class extends BaseService {
9779
10097
 
9780
10098
  // src/runtime/services/record/rollup.service.ts
9781
10099
  var RollupService = class extends BaseService {
9782
- constructor(adapter) {
10100
+ constructor(adapter, options) {
9783
10101
  super(adapter);
10102
+ this.recordResolver = options.recordResolver;
9784
10103
  }
9785
10104
  /**
9786
10105
  * Calculate a rollup value for a record
@@ -9834,7 +10153,7 @@ var RollupService = class extends BaseService {
9834
10153
  * Example: entreprise222 has relation "entreprises" → companies, rollup collects from companies
9835
10154
  */
9836
10155
  async calculateForward(recordId, rollupAttr) {
9837
- const record = await this.adapter.objectRecords.findById(recordId);
10156
+ const record = await this.recordResolver.findById(recordId);
9838
10157
  if (!record) {
9839
10158
  return { value: null, recordCount: 0 };
9840
10159
  }
@@ -9848,7 +10167,7 @@ var RollupService = class extends BaseService {
9848
10167
  if (relatedIds.length === 0) {
9849
10168
  return { value: this.getEmptyValue(rollupAttr.function), recordCount: 0 };
9850
10169
  }
9851
- const relatedRecords = await this.adapter.objectRecords.findByIds(relatedIds);
10170
+ const relatedRecords = await this.recordResolver.findByIds(relatedIds);
9852
10171
  if (relatedRecords.length === 0) {
9853
10172
  return { value: this.getEmptyValue(rollupAttr.function), recordCount: 0 };
9854
10173
  }
@@ -9859,7 +10178,7 @@ var RollupService = class extends BaseService {
9859
10178
  * Example: Company has rollup on "orders", Order has relation "company" → companies
9860
10179
  */
9861
10180
  async calculateReverse(recordId, rollupAttr, schema) {
9862
- const record = await this.adapter.objectRecords.findById(recordId);
10181
+ const record = await this.recordResolver.findById(recordId);
9863
10182
  if (!record) {
9864
10183
  return { value: null, recordCount: 0 };
9865
10184
  }
@@ -9867,14 +10186,14 @@ var RollupService = class extends BaseService {
9867
10186
  const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
9868
10187
  let sourceObjectId;
9869
10188
  let reverseRelationAttrName;
9870
- if (_optionalChain([sourceSchema, 'optionalAccess', _209 => _209.id])) {
10189
+ if (_optionalChain([sourceSchema, 'optionalAccess', _229 => _229.id])) {
9871
10190
  sourceObjectId = sourceSchema.id;
9872
10191
  const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
9873
10192
  if (attr.type !== "relation") return false;
9874
10193
  const relationConfig = attr;
9875
- return _optionalChain([relationConfig, 'optionalAccess', _210 => _210.targets, 'optionalAccess', _211 => _211.some, 'call', _212 => _212((t) => t.object === schema.name)]);
10194
+ return _optionalChain([relationConfig, 'optionalAccess', _230 => _230.targets, 'optionalAccess', _231 => _231.some, 'call', _232 => _232((t) => t.object === schema.name)]);
9876
10195
  });
9877
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _213 => _213.name]);
10196
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _233 => _233.name]);
9878
10197
  } else {
9879
10198
  const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
9880
10199
  if (!sourceObject) {
@@ -9885,9 +10204,9 @@ var RollupService = class extends BaseService {
9885
10204
  const reverseRelationAttr = sourceAttributes.find((attr) => {
9886
10205
  if (attr.type !== "relation") return false;
9887
10206
  const relationConfig = attr.config;
9888
- return _optionalChain([relationConfig, 'optionalAccess', _214 => _214.targets, 'optionalAccess', _215 => _215.some, 'call', _216 => _216((t) => t.object === schema.name)]);
10207
+ return _optionalChain([relationConfig, 'optionalAccess', _234 => _234.targets, 'optionalAccess', _235 => _235.some, 'call', _236 => _236((t) => t.object === schema.name)]);
9889
10208
  });
9890
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _217 => _217.name]);
10209
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _237 => _237.name]);
9891
10210
  }
9892
10211
  if (!reverseRelationAttrName) {
9893
10212
  return { value: null, recordCount: 0 };
@@ -10124,7 +10443,7 @@ var RollupService = class extends BaseService {
10124
10443
  }
10125
10444
  for (const rollupDbAttr of rollupAttrs) {
10126
10445
  const rollupConfig = rollupDbAttr.config;
10127
- if (!_optionalChain([rollupConfig, 'optionalAccess', _218 => _218.relationAttribute])) {
10446
+ if (!_optionalChain([rollupConfig, 'optionalAccess', _238 => _238.relationAttribute])) {
10128
10447
  continue;
10129
10448
  }
10130
10449
  const relationAttr = attributes.find(
@@ -10134,7 +10453,7 @@ var RollupService = class extends BaseService {
10134
10453
  continue;
10135
10454
  }
10136
10455
  const relationConfig = relationAttr.config;
10137
- const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _219 => _219.targets, 'optionalAccess', _220 => _220.some, 'call', _221 => _221(
10456
+ const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _239 => _239.targets, 'optionalAccess', _240 => _240.some, 'call', _241 => _241(
10138
10457
  (t) => t.object === changedSchema.name
10139
10458
  )]);
10140
10459
  if (!targetsChangedObject) {
@@ -10161,30 +10480,30 @@ var RecordService = class extends BaseService {
10161
10480
  constructor(adapter, options) {
10162
10481
  super(adapter);
10163
10482
  this.schemaService = new ObjectSchemaService(adapter, registry, {
10164
- auditService: _optionalChain([options, 'optionalAccess', _222 => _222.auditService])
10483
+ auditService: _optionalChain([options, 'optionalAccess', _242 => _242.auditService])
10165
10484
  });
10166
- this.permissionService = _optionalChain([options, 'optionalAccess', _223 => _223.permissionService]);
10167
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _224 => _224.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
10168
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _225 => _225.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _226 => _226.policyRegistry]), () => ( defaultPolicyRegistry));
10485
+ this.permissionService = _optionalChain([options, 'optionalAccess', _243 => _243.permissionService]);
10486
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
10487
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _245 => _245.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.policyRegistry]), () => ( defaultPolicyRegistry));
10488
+ this.recordResolver = new RecordResolverService(adapter);
10169
10489
  this.queryService = new RecordQueryService(adapter, this.schemaService, {
10170
10490
  permissionService: this.permissionService,
10171
10491
  policyRegistry: this.policyRegistry
10172
10492
  });
10173
10493
  this.relationService = new RelationService(adapter, registry, {
10174
- queryService: this.queryService
10494
+ queryService: this.queryService,
10495
+ recordResolver: this.recordResolver
10496
+ });
10497
+ this.rollupService = new RollupService(adapter, {
10498
+ recordResolver: this.recordResolver
10175
10499
  });
10176
10500
  this.userService = new UserService(adapter);
10177
- this.rollupService = new RollupService(adapter);
10178
- this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _227 => _227.hookRegistry]), () => ( new NoopHookRegistry()));
10179
- this.labelResolver = {
10180
- resolveRelationIds: (ids, attrId) => this.relationService.resolveIds(ids, attrId),
10181
- findRecordLabels: (ids) => this.adapter.objectRecords.findByIds(ids)
10182
- };
10183
- this.rollupContext = {
10184
- rollupService: this.rollupService,
10185
- schemaService: this.schemaService,
10186
- findRecordsByIds: (ids) => this.adapter.objectRecords.findByIds(ids)
10187
- };
10501
+ this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _247 => _247.hookRegistry]), () => ( new NoopHookRegistry()));
10502
+ this.labelResolver = this.recordResolver.createLabelResolver(this.relationService);
10503
+ this.rollupContext = this.recordResolver.createRollupContext(
10504
+ this.rollupService,
10505
+ this.schemaService
10506
+ );
10188
10507
  }
10189
10508
  // ============================================================================
10190
10509
  // CREATE
@@ -10207,21 +10526,21 @@ var RecordService = class extends BaseService {
10207
10526
  schema,
10208
10527
  this.tenantId,
10209
10528
  dataWithDefaults,
10210
- _optionalChain([options, 'optionalAccess', _228 => _228.hookMetadata])
10529
+ _optionalChain([options, 'optionalAccess', _248 => _248.hookMetadata])
10211
10530
  );
10212
- if (!_optionalChain([options, 'optionalAccess', _229 => _229.skipHooks])) {
10531
+ if (!_optionalChain([options, 'optionalAccess', _249 => _249.skipHooks])) {
10213
10532
  await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
10214
10533
  }
10215
- if (_optionalChain([options, 'optionalAccess', _230 => _230.validate]) !== false) {
10216
- if (_optionalChain([options, 'optionalAccess', _231 => _231.allowDraft])) {
10534
+ if (_optionalChain([options, 'optionalAccess', _250 => _250.validate]) !== false) {
10535
+ if (_optionalChain([options, 'optionalAccess', _251 => _251.allowDraft])) {
10217
10536
  validateDraftOrThrow(schema, dataWithDefaults);
10218
10537
  } else {
10219
10538
  validateObjectOrThrow(schema, dataWithDefaults);
10220
10539
  }
10221
- if (!_optionalChain([options, 'optionalAccess', _232 => _232.skipRelationValidation])) {
10540
+ if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipRelationValidation])) {
10222
10541
  await this.relationService.validateRelationsOrThrow(schema, dataWithDefaults);
10223
10542
  }
10224
- if (!_optionalChain([options, 'optionalAccess', _233 => _233.skipUserValidation])) {
10543
+ if (!_optionalChain([options, 'optionalAccess', _253 => _253.skipUserValidation])) {
10225
10544
  await this.userService.validateUsersOrThrow(schema, dataWithDefaults);
10226
10545
  }
10227
10546
  }
@@ -10232,10 +10551,10 @@ var RecordService = class extends BaseService {
10232
10551
  data: dataWithDefaults,
10233
10552
  label,
10234
10553
  completionStatus,
10235
- metadata: _optionalChain([options, 'optionalAccess', _234 => _234.metadata]),
10554
+ metadata: _optionalChain([options, 'optionalAccess', _254 => _254.metadata]),
10236
10555
  createdBy: this.userId
10237
10556
  });
10238
- if (!_optionalChain([options, 'optionalAccess', _235 => _235.skipHooks])) {
10557
+ if (!_optionalChain([options, 'optionalAccess', _255 => _255.skipHooks])) {
10239
10558
  const afterCtx = {
10240
10559
  ...hookCtx,
10241
10560
  recordId: record.id,
@@ -10255,7 +10574,7 @@ var RecordService = class extends BaseService {
10255
10574
  objectId: schema.id,
10256
10575
  recordId: record.id,
10257
10576
  recordLabel: record.label,
10258
- metadata: _optionalChain([options, 'optionalAccess', _236 => _236.hookMetadata])
10577
+ metadata: _optionalChain([options, 'optionalAccess', _256 => _256.hookMetadata])
10259
10578
  });
10260
10579
  }
10261
10580
  return record;
@@ -10276,7 +10595,7 @@ var RecordService = class extends BaseService {
10276
10595
  return null;
10277
10596
  }
10278
10597
  const schema = await this.schemaService.getObjectSchema(record.objectId);
10279
- if (!_optionalChain([options, 'optionalAccess', _237 => _237.skipPolicyCheck])) {
10598
+ if (!_optionalChain([options, 'optionalAccess', _257 => _257.skipPolicyCheck])) {
10280
10599
  const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
10281
10600
  if (policy) {
10282
10601
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
@@ -10286,10 +10605,10 @@ var RecordService = class extends BaseService {
10286
10605
  }
10287
10606
  }
10288
10607
  let enrichedRecord = record;
10289
- if (!_optionalChain([options, 'optionalAccess', _238 => _238.skipFormulas])) {
10608
+ if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipFormulas])) {
10290
10609
  enrichedRecord = enrichWithFormulas(record, schema);
10291
10610
  }
10292
- if (_optionalChain([options, 'optionalAccess', _239 => _239.includeSchema])) {
10611
+ if (_optionalChain([options, 'optionalAccess', _259 => _259.includeSchema])) {
10293
10612
  const recordWithSchema = enrichedRecord;
10294
10613
  recordWithSchema.schema = schema;
10295
10614
  return recordWithSchema;
@@ -10332,9 +10651,9 @@ var RecordService = class extends BaseService {
10332
10651
  existing,
10333
10652
  mergedData,
10334
10653
  changedAttributes,
10335
- _optionalChain([options, 'optionalAccess', _240 => _240.hookMetadata])
10654
+ _optionalChain([options, 'optionalAccess', _260 => _260.hookMetadata])
10336
10655
  );
10337
- if (!_optionalChain([options, 'optionalAccess', _241 => _241.skipHooks])) {
10656
+ if (!_optionalChain([options, 'optionalAccess', _261 => _261.skipHooks])) {
10338
10657
  await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
10339
10658
  }
10340
10659
  const hookModifiedValues = {};
@@ -10343,19 +10662,19 @@ var RecordService = class extends BaseService {
10343
10662
  hookModifiedValues[key] = hookCtx.newValues[key];
10344
10663
  }
10345
10664
  }
10346
- if (_optionalChain([options, 'optionalAccess', _242 => _242.validate]) !== false) {
10347
- if (_optionalChain([options, 'optionalAccess', _243 => _243.partial])) {
10665
+ if (_optionalChain([options, 'optionalAccess', _262 => _262.validate]) !== false) {
10666
+ if (_optionalChain([options, 'optionalAccess', _263 => _263.partial])) {
10348
10667
  validateDraftOrThrow(schema, mergedData);
10349
10668
  } else {
10350
10669
  validateObjectOrThrow(schema, mergedData);
10351
10670
  }
10352
- if (!_optionalChain([options, 'optionalAccess', _244 => _244.skipRelationValidation])) {
10671
+ if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipRelationValidation])) {
10353
10672
  await this.relationService.validateRelationsOrThrow(schema, {
10354
10673
  ...data,
10355
10674
  ...hookModifiedValues
10356
10675
  });
10357
10676
  }
10358
- if (!_optionalChain([options, 'optionalAccess', _245 => _245.skipUserValidation])) {
10677
+ if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipUserValidation])) {
10359
10678
  await this.userService.validateUsersOrThrow(schema, {
10360
10679
  ...data,
10361
10680
  ...hookModifiedValues
@@ -10371,7 +10690,7 @@ var RecordService = class extends BaseService {
10371
10690
  __label: label,
10372
10691
  __lastUpdatedBy: this.userId
10373
10692
  };
10374
- if (_optionalChain([options, 'optionalAccess', _246 => _246.metadata]) !== void 0) {
10693
+ if (_optionalChain([options, 'optionalAccess', _266 => _266.metadata]) !== void 0) {
10375
10694
  const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
10376
10695
  const mergedMetadata = { ...existingMetadata, ...options.metadata };
10377
10696
  const cleanedMetadata = Object.fromEntries(
@@ -10384,7 +10703,7 @@ var RecordService = class extends BaseService {
10384
10703
  await this.invalidateLists("allRecordLists", existing.objectId);
10385
10704
  await this.invalidateLists("allSearchResults", existing.objectId);
10386
10705
  await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
10387
- if (!_optionalChain([options, 'optionalAccess', _247 => _247.skipHooks])) {
10706
+ if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipHooks])) {
10388
10707
  const afterCtx = {
10389
10708
  ...hookCtx,
10390
10709
  record: updated
@@ -10399,7 +10718,7 @@ var RecordService = class extends BaseService {
10399
10718
  if (this.auditService && this.userId && allChangedAttributes.length > 0) {
10400
10719
  const changes = allChangedAttributes.map((attr) => ({
10401
10720
  field: attr,
10402
- oldValue: _optionalChain([hookCtx, 'access', _248 => _248.oldValues, 'optionalAccess', _249 => _249[attr]]),
10721
+ oldValue: _optionalChain([hookCtx, 'access', _268 => _268.oldValues, 'optionalAccess', _269 => _269[attr]]),
10403
10722
  newValue: hookCtx.newValues[attr]
10404
10723
  }));
10405
10724
  await this.auditService.logRecordAction({
@@ -10410,7 +10729,7 @@ var RecordService = class extends BaseService {
10410
10729
  recordId: updated.id,
10411
10730
  recordLabel: updated.label,
10412
10731
  changes,
10413
- metadata: _optionalChain([options, 'optionalAccess', _250 => _250.hookMetadata])
10732
+ metadata: _optionalChain([options, 'optionalAccess', _270 => _270.hookMetadata])
10414
10733
  });
10415
10734
  }
10416
10735
  return updated;
@@ -10433,17 +10752,17 @@ var RecordService = class extends BaseService {
10433
10752
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
10434
10753
  checkRecordDeleteOrThrow(policy, record, ctx);
10435
10754
  }
10436
- if (_optionalChain([options, 'optionalAccess', _251 => _251.checkSystem]) && schema.system) {
10755
+ if (_optionalChain([options, 'optionalAccess', _271 => _271.checkSystem]) && schema.system) {
10437
10756
  throw new ProtectedResourceError("object", schema.name, "delete");
10438
10757
  }
10439
- if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipReferenceCheck])) {
10758
+ if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipReferenceCheck])) {
10440
10759
  const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
10441
10760
  if (references.length > 0) {
10442
10761
  throw new RecordReferencedError(recordId, references);
10443
10762
  }
10444
10763
  }
10445
- const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _253 => _253.hookMetadata]));
10446
- if (!_optionalChain([options, 'optionalAccess', _254 => _254.skipHooks])) {
10764
+ const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _273 => _273.hookMetadata]));
10765
+ if (!_optionalChain([options, 'optionalAccess', _274 => _274.skipHooks])) {
10447
10766
  await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
10448
10767
  }
10449
10768
  await this.adapter.objectRecords.delete(recordId);
@@ -10452,7 +10771,7 @@ var RecordService = class extends BaseService {
10452
10771
  await this.invalidateLists("allSearchResults", record.objectId);
10453
10772
  await this.invalidateCachePattern(cacheKeys.allGlobalSearch(this.tenantId));
10454
10773
  await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
10455
- if (!_optionalChain([options, 'optionalAccess', _255 => _255.skipHooks])) {
10774
+ if (!_optionalChain([options, 'optionalAccess', _275 => _275.skipHooks])) {
10456
10775
  await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
10457
10776
  }
10458
10777
  await recalculateParentRollups(record, schema, this.rollupContext);
@@ -10464,7 +10783,7 @@ var RecordService = class extends BaseService {
10464
10783
  objectId: schema.id,
10465
10784
  recordId: record.id,
10466
10785
  recordLabel: record.label,
10467
- metadata: _optionalChain([options, 'optionalAccess', _256 => _256.hookMetadata])
10786
+ metadata: _optionalChain([options, 'optionalAccess', _276 => _276.hookMetadata])
10468
10787
  });
10469
10788
  }
10470
10789
  }
@@ -10499,8 +10818,8 @@ var RecordService = class extends BaseService {
10499
10818
  }
10500
10819
  const schema = await this.schemaService.getObjectSchema(record.objectId);
10501
10820
  await checkPermission(this.permissionService, this.userId, schema.name, "update");
10502
- const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _257 => _257.hookMetadata]));
10503
- if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipHooks])) {
10821
+ const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _277 => _277.hookMetadata]));
10822
+ if (!_optionalChain([options, 'optionalAccess', _278 => _278.skipHooks])) {
10504
10823
  await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
10505
10824
  }
10506
10825
  const restored = await this.adapter.objectRecords.restore(recordId);
@@ -10509,7 +10828,7 @@ var RecordService = class extends BaseService {
10509
10828
  await this.invalidateLists("allSearchResults", record.objectId);
10510
10829
  await this.invalidateCachePattern(cacheKeys.allGlobalSearch(this.tenantId));
10511
10830
  await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
10512
- if (!_optionalChain([options, 'optionalAccess', _259 => _259.skipHooks])) {
10831
+ if (!_optionalChain([options, 'optionalAccess', _279 => _279.skipHooks])) {
10513
10832
  const afterCtx = {
10514
10833
  ...hookCtx,
10515
10834
  record: restored
@@ -10524,7 +10843,7 @@ var RecordService = class extends BaseService {
10524
10843
  objectId: schema.id,
10525
10844
  recordId: restored.id,
10526
10845
  recordLabel: restored.label,
10527
- metadata: _optionalChain([options, 'optionalAccess', _260 => _260.hookMetadata])
10846
+ metadata: _optionalChain([options, 'optionalAccess', _280 => _280.hookMetadata])
10528
10847
  });
10529
10848
  }
10530
10849
  return restored;
@@ -10579,15 +10898,19 @@ var RecordService = class extends BaseService {
10579
10898
  }
10580
10899
  };
10581
10900
 
10582
- // src/runtime/services/record/relation-resolver.service.ts
10583
- var RelationResolverService = class {
10584
- constructor(adapter) {
10585
- this.adapter = adapter;
10901
+ // src/runtime/services/record/formula-resolver.service.ts
10902
+ var FormulaResolverService = class extends BaseService {
10903
+ constructor(adapter, options) {
10904
+ super(adapter);
10905
+ this.recordResolver = options.recordResolver;
10586
10906
  }
10907
+ // ============================================================================
10908
+ // RESOLUTION
10909
+ // ============================================================================
10587
10910
  /**
10588
10911
  * Resolve values from related records for formula evaluation
10589
10912
  *
10590
- * Phase 2: Supports 1 level of relation traversal only
10913
+ * Supports 1 level of relation traversal only.
10591
10914
  *
10592
10915
  * @param record - The source record
10593
10916
  * @param schema - Schema of the source object
@@ -10596,7 +10919,6 @@ var RelationResolverService = class {
10596
10919
  *
10597
10920
  * @example
10598
10921
  * ```typescript
10599
- * // For an order with company relation
10600
10922
  * const resolved = await resolver.resolveRelationValues(
10601
10923
  * orderRecord,
10602
10924
  * orderSchema,
@@ -10625,7 +10947,7 @@ var RelationResolverService = class {
10625
10947
  if (idsToFetch.length === 0) {
10626
10948
  return result;
10627
10949
  }
10628
- const relatedRecords = await this.adapter.objectRecords.findByIds(idsToFetch);
10950
+ const relatedRecords = await this.recordResolver.findByIds(idsToFetch);
10629
10951
  for (const relatedRecord of relatedRecords) {
10630
10952
  const attrName = attrIdMap.get(relatedRecord.id);
10631
10953
  if (attrName) {
@@ -10671,7 +10993,7 @@ var RelationResolverService = class {
10671
10993
  if (allIdsToFetch.size === 0) {
10672
10994
  return resultMap;
10673
10995
  }
10674
- const relatedRecords = await this.adapter.objectRecords.findByIds([...allIdsToFetch]);
10996
+ const relatedRecords = await this.recordResolver.findByIds([...allIdsToFetch]);
10675
10997
  const relatedRecordMap = new Map(relatedRecords.map((r) => [r.id, r]));
10676
10998
  for (const record of records) {
10677
10999
  const result = resultMap.get(record.id);
@@ -10704,10 +11026,12 @@ var RelationResolverService = class {
10704
11026
  }
10705
11027
  return flat;
10706
11028
  }
11029
+ // ============================================================================
11030
+ // PRIVATE HELPERS
11031
+ // ============================================================================
10707
11032
  /**
10708
11033
  * Extract a single relation ID from a value
10709
11034
  * Handles both single (string) and multi (array) relations
10710
- * @internal
10711
11035
  */
10712
11036
  extractSingleId(value) {
10713
11037
  if (typeof value === "string" && value.length > 0) {
@@ -10726,9 +11050,9 @@ var RollupScheduler = class {
10726
11050
  this.adapter = adapter;
10727
11051
  this.getSchemaById = getSchemaById;
10728
11052
  this.pending = /* @__PURE__ */ new Map();
10729
- this.rollupService = new RollupService(adapter);
10730
- this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _261 => _261.debounceMs]), () => ( 100));
10731
- this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _262 => _262.maxPending]), () => ( 100));
11053
+ this.rollupService = new RollupService(adapter, { recordResolver: options.recordResolver });
11054
+ this.debounceMs = _nullishCoalesce(options.debounceMs, () => ( 100));
11055
+ this.maxPending = _nullishCoalesce(options.maxPending, () => ( 100));
10732
11056
  }
10733
11057
  /**
10734
11058
  * Schedule a rollup recalculation for a parent record.
@@ -10806,7 +11130,7 @@ var WorkflowService = class extends BaseService {
10806
11130
  if (Array.isArray(options)) {
10807
11131
  this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
10808
11132
  } else {
10809
- this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _263 => _263.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
11133
+ this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _281 => _281.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
10810
11134
  }
10811
11135
  }
10812
11136
  // ============================================================================
@@ -11109,9 +11433,9 @@ var WorkflowInstanceService = class extends BaseService {
11109
11433
  constructor(adapter, workflowService, options) {
11110
11434
  super(adapter);
11111
11435
  this.workflowService = workflowService;
11112
- this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _264 => _264.executorRegistry]), () => ( getDefaultExecutorRegistry()));
11113
- this.schemaService = _optionalChain([options, 'optionalAccess', _265 => _265.schemaService]);
11114
- this.recordService = _optionalChain([options, 'optionalAccess', _266 => _266.recordService]);
11436
+ this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _282 => _282.executorRegistry]), () => ( getDefaultExecutorRegistry()));
11437
+ this.schemaService = _optionalChain([options, 'optionalAccess', _283 => _283.schemaService]);
11438
+ this.recordService = _optionalChain([options, 'optionalAccess', _284 => _284.recordService]);
11115
11439
  }
11116
11440
  /**
11117
11441
  * Start a new workflow instance
@@ -11237,7 +11561,7 @@ var WorkflowInstanceService = class extends BaseService {
11237
11561
  if (!this.adapter.workflowInstances) {
11238
11562
  return { instances: [], total: 0 };
11239
11563
  }
11240
- if (_optionalChain([options, 'optionalAccess', _267 => _267.workflowName])) {
11564
+ if (_optionalChain([options, 'optionalAccess', _285 => _285.workflowName])) {
11241
11565
  const instances2 = await this.getInstancesByWorkflow(options.workflowName);
11242
11566
  let filtered = instances2;
11243
11567
  if (options.status) {
@@ -11251,11 +11575,11 @@ var WorkflowInstanceService = class extends BaseService {
11251
11575
  return { instances: paginated, total: total2 };
11252
11576
  }
11253
11577
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
11254
- limit: _optionalChain([options, 'optionalAccess', _268 => _268.limit]),
11255
- offset: _optionalChain([options, 'optionalAccess', _269 => _269.offset])
11578
+ limit: _optionalChain([options, 'optionalAccess', _286 => _286.limit]),
11579
+ offset: _optionalChain([options, 'optionalAccess', _287 => _287.offset])
11256
11580
  });
11257
11581
  let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
11258
- if (_optionalChain([options, 'optionalAccess', _270 => _270.status])) {
11582
+ if (_optionalChain([options, 'optionalAccess', _288 => _288.status])) {
11259
11583
  instances = instances.filter((i) => i.status === options.status);
11260
11584
  }
11261
11585
  return { instances, total };
@@ -11275,9 +11599,9 @@ var WorkflowInstanceService = class extends BaseService {
11275
11599
  return { instances: [], total: 0 };
11276
11600
  }
11277
11601
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
11278
- status: _optionalChain([options, 'optionalAccess', _271 => _271.status]),
11279
- limit: _optionalChain([options, 'optionalAccess', _272 => _272.limit]),
11280
- offset: _optionalChain([options, 'optionalAccess', _273 => _273.offset])
11602
+ status: _optionalChain([options, 'optionalAccess', _289 => _289.status]),
11603
+ limit: _optionalChain([options, 'optionalAccess', _290 => _290.limit]),
11604
+ offset: _optionalChain([options, 'optionalAccess', _291 => _291.offset])
11281
11605
  });
11282
11606
  const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
11283
11607
  return { instances, total };
@@ -11653,7 +11977,7 @@ var WorkflowParticipationService = class extends BaseService {
11653
11977
  SchemaErrorCode.RECORD_NOT_FOUND
11654
11978
  );
11655
11979
  }
11656
- const template = _optionalChain([instance, 'access', _274 => _274.workflowSnapshot, 'access', _275 => _275.participants, 'optionalAccess', _276 => _276.find, 'call', _277 => _277(
11980
+ const template = _optionalChain([instance, 'access', _292 => _292.workflowSnapshot, 'access', _293 => _293.participants, 'optionalAccess', _294 => _294.find, 'call', _295 => _295(
11657
11981
  (p) => p.id === input.participantTemplateId
11658
11982
  )]);
11659
11983
  if (!template) {
@@ -11955,7 +12279,7 @@ var WorkflowRelationService = class extends BaseService {
11955
12279
  if (attr.type !== "relation") continue;
11956
12280
  for (const slot of slots) {
11957
12281
  const slotData = context.slots[slot.id];
11958
- const slotRecordId = _optionalChain([slotData, 'optionalAccess', _278 => _278.id]);
12282
+ const slotRecordId = _optionalChain([slotData, 'optionalAccess', _296 => _296.id]);
11959
12283
  if (!slotRecordId) continue;
11960
12284
  const targetsSlotObject = attr.targets.some(
11961
12285
  (t) => t.object === slot.objectName
@@ -12020,7 +12344,7 @@ var WorkflowRelationService = class extends BaseService {
12020
12344
  var UserProfileService = class extends BaseService {
12021
12345
  constructor(adapter, options) {
12022
12346
  super(adapter);
12023
- this.auditService = _optionalChain([options, 'optionalAccess', _279 => _279.auditService]);
12347
+ this.auditService = _optionalChain([options, 'optionalAccess', _297 => _297.auditService]);
12024
12348
  }
12025
12349
  // ============================================================================
12026
12350
  // CACHE MANAGEMENT
@@ -12183,7 +12507,7 @@ var UserProfileService = class extends BaseService {
12183
12507
  */
12184
12508
  async deleteProfile(profileId, options) {
12185
12509
  const profile = await this.getProfileOrThrow(profileId);
12186
- if (_optionalChain([options, 'optionalAccess', _280 => _280.checkAdmin])) {
12510
+ if (_optionalChain([options, 'optionalAccess', _298 => _298.checkAdmin])) {
12187
12511
  if (profile.role === "admin") {
12188
12512
  const adminCount = await this.adapter.userProfiles.countByRole("admin");
12189
12513
  if (adminCount <= 1) {
@@ -12258,7 +12582,7 @@ var UserProfileService = class extends BaseService {
12258
12582
  */
12259
12583
  async hasRole(profileId, role) {
12260
12584
  const profile = await this.getProfile(profileId);
12261
- return _optionalChain([profile, 'optionalAccess', _281 => _281.role]) === role;
12585
+ return _optionalChain([profile, 'optionalAccess', _299 => _299.role]) === role;
12262
12586
  }
12263
12587
  /**
12264
12588
  * Check if user is admin
@@ -12315,7 +12639,7 @@ var UserProfileService = class extends BaseService {
12315
12639
  var FileService = class extends BaseService {
12316
12640
  constructor(adapter, options) {
12317
12641
  super(adapter);
12318
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _282 => _282.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12642
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _300 => _300.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12319
12643
  }
12320
12644
  // ============================================================================
12321
12645
  // UPLOAD (requires StorageAdapter)
@@ -12447,7 +12771,7 @@ var FileService = class extends BaseService {
12447
12771
  */
12448
12772
  async getFile(fileId) {
12449
12773
  const file2 = await this.adapter.files.findById(fileId);
12450
- if (_optionalChain([file2, 'optionalAccess', _283 => _283.deletedAt])) {
12774
+ if (_optionalChain([file2, 'optionalAccess', _301 => _301.deletedAt])) {
12451
12775
  return null;
12452
12776
  }
12453
12777
  return file2;
@@ -12509,12 +12833,12 @@ var FileService = class extends BaseService {
12509
12833
  */
12510
12834
  async deleteFile(fileId, options) {
12511
12835
  const file2 = await this.getFileOrThrow(fileId);
12512
- if (_optionalChain([options, 'optionalAccess', _284 => _284.checkOwnership]) && options.userId) {
12836
+ if (_optionalChain([options, 'optionalAccess', _302 => _302.checkOwnership]) && options.userId) {
12513
12837
  if (file2.uploadedBy !== options.userId) {
12514
12838
  throw new Error("You can only delete files you uploaded");
12515
12839
  }
12516
12840
  }
12517
- if (_optionalChain([options, 'optionalAccess', _285 => _285.hard])) {
12841
+ if (_optionalChain([options, 'optionalAccess', _303 => _303.hard])) {
12518
12842
  await this.adapter.files.hardDelete(fileId);
12519
12843
  } else {
12520
12844
  await this.adapter.files.delete(fileId);
@@ -12545,7 +12869,7 @@ var FileService = class extends BaseService {
12545
12869
  }
12546
12870
  const file2 = await this.getFileOrThrow(fileId);
12547
12871
  await this.adapter.storage.delete(file2.storagePath);
12548
- if (_optionalChain([options, 'optionalAccess', _286 => _286.hard])) {
12872
+ if (_optionalChain([options, 'optionalAccess', _304 => _304.hard])) {
12549
12873
  await this.adapter.files.hardDelete(fileId);
12550
12874
  } else {
12551
12875
  await this.adapter.files.delete(fileId);
@@ -12572,10 +12896,10 @@ var FileService = class extends BaseService {
12572
12896
  if (!file2) {
12573
12897
  continue;
12574
12898
  }
12575
- if (_optionalChain([options, 'optionalAccess', _287 => _287.deleteFromStorage]) && this.adapter.storage) {
12899
+ if (_optionalChain([options, 'optionalAccess', _305 => _305.deleteFromStorage]) && this.adapter.storage) {
12576
12900
  await this.adapter.storage.delete(file2.storagePath);
12577
12901
  }
12578
- if (_optionalChain([options, 'optionalAccess', _288 => _288.hard])) {
12902
+ if (_optionalChain([options, 'optionalAccess', _306 => _306.hard])) {
12579
12903
  await this.adapter.files.hardDelete(fileId);
12580
12904
  } else {
12581
12905
  await this.adapter.files.delete(fileId);
@@ -12586,7 +12910,7 @@ var FileService = class extends BaseService {
12586
12910
  actorId: this.userId,
12587
12911
  fileId,
12588
12912
  fileName: file2.name,
12589
- metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _289 => _289.deleteFromStorage]), () => ( false)) }
12913
+ metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _307 => _307.deleteFromStorage]), () => ( false)) }
12590
12914
  });
12591
12915
  }
12592
12916
  }
@@ -12670,7 +12994,7 @@ var FileService = class extends BaseService {
12670
12994
  return true;
12671
12995
  }
12672
12996
  if (file2.visibility === "restricted") {
12673
- return _nullishCoalesce(_optionalChain([file2, 'access', _290 => _290.allowedUsers, 'optionalAccess', _291 => _291.includes, 'call', _292 => _292(userId)]), () => ( false));
12997
+ return _nullishCoalesce(_optionalChain([file2, 'access', _308 => _308.allowedUsers, 'optionalAccess', _309 => _309.includes, 'call', _310 => _310(userId)]), () => ( false));
12674
12998
  }
12675
12999
  return false;
12676
13000
  }
@@ -12835,10 +13159,10 @@ var GlobalSearchService = class extends BaseService {
12835
13159
  */
12836
13160
  async executeSearch(query, options) {
12837
13161
  return await this.adapter.objectRecords.globalSearch(query, {
12838
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _293 => _293.limit]), () => ( 20)),
12839
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _294 => _294.offset]), () => ( 0)),
12840
- objectNames: _optionalChain([options, 'optionalAccess', _295 => _295.objectNames]),
12841
- includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _296 => _296.includeObjectInfo]), () => ( true))
13162
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _311 => _311.limit]), () => ( 20)),
13163
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _312 => _312.offset]), () => ( 0)),
13164
+ objectNames: _optionalChain([options, 'optionalAccess', _313 => _313.objectNames]),
13165
+ includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _314 => _314.includeObjectInfo]), () => ( true))
12842
13166
  });
12843
13167
  }
12844
13168
  /**
@@ -12888,7 +13212,7 @@ var PermissionService = class extends BaseService {
12888
13212
  }
12889
13213
  this.permissionsRepo = adapter.permissions;
12890
13214
  this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
12891
- this.auditService = _optionalChain([options, 'optionalAccess', _297 => _297.auditService]);
13215
+ this.auditService = _optionalChain([options, 'optionalAccess', _315 => _315.auditService]);
12892
13216
  }
12893
13217
  // ============================================================================
12894
13218
  // PERMISSION CHECKS
@@ -12907,11 +13231,11 @@ var PermissionService = class extends BaseService {
12907
13231
  return true;
12908
13232
  }
12909
13233
  const wildcardPerms = permissions.objectPermissions["*"];
12910
- if (_optionalChain([wildcardPerms, 'optionalAccess', _298 => _298.includes, 'call', _299 => _299(action)])) {
13234
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _316 => _316.includes, 'call', _317 => _317(action)])) {
12911
13235
  return true;
12912
13236
  }
12913
13237
  const objectPerms = permissions.objectPermissions[objectName];
12914
- return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _300 => _300.includes, 'call', _301 => _301(action)]), () => ( false));
13238
+ return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _318 => _318.includes, 'call', _319 => _319(action)]), () => ( false));
12915
13239
  }
12916
13240
  /**
12917
13241
  * Check if user can access an object, throw ForbiddenError if not.
@@ -12966,12 +13290,12 @@ var PermissionService = class extends BaseService {
12966
13290
  if (permissions.isAdmin) {
12967
13291
  return true;
12968
13292
  }
12969
- const wildcardPerms = _optionalChain([permissions, 'access', _302 => _302.systemPermissions, 'optionalAccess', _303 => _303["*"]]);
12970
- if (_optionalChain([wildcardPerms, 'optionalAccess', _304 => _304.includes, 'call', _305 => _305(action)])) {
13293
+ const wildcardPerms = _optionalChain([permissions, 'access', _320 => _320.systemPermissions, 'optionalAccess', _321 => _321["*"]]);
13294
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _322 => _322.includes, 'call', _323 => _323(action)])) {
12971
13295
  return true;
12972
13296
  }
12973
- const resourcePerms = _optionalChain([permissions, 'access', _306 => _306.systemPermissions, 'optionalAccess', _307 => _307[resource]]);
12974
- return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _308 => _308.includes, 'call', _309 => _309(action)]), () => ( false));
13297
+ const resourcePerms = _optionalChain([permissions, 'access', _324 => _324.systemPermissions, 'optionalAccess', _325 => _325[resource]]);
13298
+ return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _326 => _326.includes, 'call', _327 => _327(action)]), () => ( false));
12975
13299
  }
12976
13300
  /**
12977
13301
  * Check if user can access a system resource, throw ForbiddenError if not.
@@ -13000,8 +13324,8 @@ var PermissionService = class extends BaseService {
13000
13324
  if (permissions.isAdmin) {
13001
13325
  return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
13002
13326
  }
13003
- const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _310 => _310.systemPermissions, 'optionalAccess', _311 => _311["*"]]), () => ( []));
13004
- const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _312 => _312.systemPermissions, 'optionalAccess', _313 => _313[resource]]), () => ( []));
13327
+ const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _328 => _328.systemPermissions, 'optionalAccess', _329 => _329["*"]]), () => ( []));
13328
+ const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _330 => _330.systemPermissions, 'optionalAccess', _331 => _331[resource]]), () => ( []));
13005
13329
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
13006
13330
  return {
13007
13331
  canRead: allPerms.has("read"),
@@ -13143,7 +13467,7 @@ var PermissionService = class extends BaseService {
13143
13467
  action: "role.updated",
13144
13468
  actorId: this.userId,
13145
13469
  roleId,
13146
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _314 => _314.label]), () => ( roleId)),
13470
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _332 => _332.label]), () => ( roleId)),
13147
13471
  metadata: { permissionsUpdated: true, permissionCount: permissions.length }
13148
13472
  });
13149
13473
  }
@@ -13173,7 +13497,7 @@ var PermissionService = class extends BaseService {
13173
13497
  action: "role.assigned",
13174
13498
  actorId: this.userId,
13175
13499
  roleId,
13176
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _315 => _315.label]), () => ( roleId)),
13500
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _333 => _333.label]), () => ( roleId)),
13177
13501
  targetUserId: userProfileId
13178
13502
  });
13179
13503
  }
@@ -13191,7 +13515,7 @@ var PermissionService = class extends BaseService {
13191
13515
  action: "role.revoked",
13192
13516
  actorId: this.userId,
13193
13517
  roleId,
13194
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _316 => _316.label]), () => ( roleId)),
13518
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _334 => _334.label]), () => ( roleId)),
13195
13519
  targetUserId: userProfileId
13196
13520
  });
13197
13521
  }
@@ -14185,4 +14509,5 @@ var NoopGeocodingAdapter = class {
14185
14509
 
14186
14510
 
14187
14511
 
14188
- exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isSignedLinkAuth = isSignedLinkAuth; exports.isPinCodeAuth = isPinCodeAuth; exports.canParticipate = canParticipate; exports.canAuthenticate = canAuthenticate; exports.canExecuteNode = canExecuteNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.mergeFormToSlot = mergeFormToSlot; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isParticipationEvent = isParticipationEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.ParticipantAuthConfigSchema = ParticipantAuthConfigSchema; exports.ParticipantTemplateSchema = ParticipantTemplateSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.asTenantId = asTenantId; exports.asUserId = asUserId; exports.generateId = generateId; exports.generatePrefixedId = generatePrefixedId; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.DirectTableTabConfig = DirectTableTabConfig; exports.InverseTableTabConfig = InverseTableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.NotesTabConfig = NotesTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.TabBuilder = TabBuilder; exports.ViewBuilder = ViewBuilder; exports.view = view; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowParticipantBuilder = WorkflowParticipantBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES; exports.textConfigSchema = textConfigSchema; exports.textareaConfigSchema = textareaConfigSchema; exports.richtextConfigSchema = richtextConfigSchema; exports.numberConfigSchema = numberConfigSchema; exports.checkboxConfigSchema = checkboxConfigSchema; exports.dateConfigSchema = dateConfigSchema; exports.phoneConfigSchema = phoneConfigSchema; exports.currencyConfigSchema = currencyConfigSchema; exports.statusConfigSchema = statusConfigSchema; exports.locationConfigSchema = locationConfigSchema; exports.selectConfigSchema = selectConfigSchema; exports.multiselectConfigSchema = multiselectConfigSchema; exports.fileConfigSchema = fileConfigSchema; exports.userConfigSchema = userConfigSchema; exports.relationConfigSchema = relationConfigSchema; exports.ratingConfigSchema = ratingConfigSchema; exports.formulaConfigSchema = formulaConfigSchema; exports.rollupConfigSchema = rollupConfigSchema; exports.attributeConfigSchemas = attributeConfigSchemas; exports.getAttributeConfigSchema = getAttributeConfigSchema; exports.validateAttributeConfig = validateAttributeConfig; exports.parseAttributeConfig = parseAttributeConfig; exports.safeParseAttributeConfig = safeParseAttributeConfig; exports.createTextValidator = createTextValidator; exports.createNumberValidator = createNumberValidator; exports.createCheckboxValidator = createCheckboxValidator; exports.createDateValidator = createDateValidator; exports.createPhoneValidator = createPhoneValidator; exports.createCurrencyValidator = createCurrencyValidator; exports.createStatusValidator = createStatusValidator; exports.createSelectValidator = createSelectValidator; exports.createMultiselectValidator = createMultiselectValidator; exports.createLocationValidator = createLocationValidator; exports.createFileValidator = createFileValidator; exports.createUserValidator = createUserValidator; exports.createSingleRelationValidator = createSingleRelationValidator; exports.createMultiRelationValidator = createMultiRelationValidator; exports.createRelationValidator = createRelationValidator; exports.createRatingValidator = createRatingValidator; exports.createFormulaValidator = createFormulaValidator; exports.createRollupValidator = createRollupValidator; exports.createTextAreaValidator = createTextAreaValidator; exports.createRichtextValidator = createRichtextValidator; exports.createAttributeValidator = createAttributeValidator; exports.createFormAttributeValidator = createFormAttributeValidator; exports.createObjectValidator = createObjectValidator; exports.validateAttribute = validateAttribute; exports.validateObject = validateObject; exports.validateObjectOrThrow = validateObjectOrThrow; exports.createDraftValidator = createDraftValidator; exports.validateDraft = validateDraft; exports.validateDraftOrThrow = validateDraftOrThrow; exports.getMissingRequiredAttributes = getMissingRequiredAttributes; exports.isRecordComplete = isRecordComplete; exports.computeRecordStatus = computeRecordStatus; exports.ParticipationTokenService = ParticipationTokenService; exports.getDefaultTokenService = getDefaultTokenService; exports.initializeTokenService = initializeTokenService; exports.PinCodeService = PinCodeService; exports.getDefaultPinCodeService = getDefaultPinCodeService; exports.initializePinCodeService = initializePinCodeService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.DEFAULT_LABEL_FALLBACK = DEFAULT_LABEL_FALLBACK; exports.renderLabelExpression = renderLabelExpression; exports.isLabelExpression = isLabelExpression; exports.extractAttributeNames = extractAttributeNames; exports.enrichValuesForDisplay = enrichValuesForDisplay; exports.enrichValuesWithSelectLabels = enrichValuesWithSelectLabels; exports.extractRelationIds = extractRelationIds; exports.computeLabelWithRelations = computeLabelWithRelations; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.notesPolicy = notesPolicy; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.TenantAwareRepository = TenantAwareRepository; exports.TenantAwareService = TenantAwareService; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RecordQueryService = RecordQueryService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.RelationResolverService = RelationResolverService; exports.RollupScheduler = RollupScheduler; exports.WorkflowService = WorkflowService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.UserProfileService = UserProfileService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
14512
+
14513
+ exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isSignedLinkAuth = isSignedLinkAuth; exports.isPinCodeAuth = isPinCodeAuth; exports.canParticipate = canParticipate; exports.canAuthenticate = canAuthenticate; exports.canExecuteNode = canExecuteNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.mergeFormToSlot = mergeFormToSlot; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isParticipationEvent = isParticipationEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.ParticipantAuthConfigSchema = ParticipantAuthConfigSchema; exports.ParticipantTemplateSchema = ParticipantTemplateSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.asTenantId = asTenantId; exports.asUserId = asUserId; exports.generateId = generateId; exports.generatePrefixedId = generatePrefixedId; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.DirectTableTabConfig = DirectTableTabConfig; exports.InverseTableTabConfig = InverseTableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.NotesTabConfig = NotesTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.TabBuilder = TabBuilder; exports.ViewBuilder = ViewBuilder; exports.view = view; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowParticipantBuilder = WorkflowParticipantBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES; exports.textConfigSchema = textConfigSchema; exports.textareaConfigSchema = textareaConfigSchema; exports.richtextConfigSchema = richtextConfigSchema; exports.numberConfigSchema = numberConfigSchema; exports.checkboxConfigSchema = checkboxConfigSchema; exports.dateConfigSchema = dateConfigSchema; exports.phoneConfigSchema = phoneConfigSchema; exports.currencyConfigSchema = currencyConfigSchema; exports.statusConfigSchema = statusConfigSchema; exports.locationConfigSchema = locationConfigSchema; exports.selectConfigSchema = selectConfigSchema; exports.multiselectConfigSchema = multiselectConfigSchema; exports.fileConfigSchema = fileConfigSchema; exports.userConfigSchema = userConfigSchema; exports.relationConfigSchema = relationConfigSchema; exports.ratingConfigSchema = ratingConfigSchema; exports.formulaConfigSchema = formulaConfigSchema; exports.rollupConfigSchema = rollupConfigSchema; exports.attributeConfigSchemas = attributeConfigSchemas; exports.getAttributeConfigSchema = getAttributeConfigSchema; exports.validateAttributeConfig = validateAttributeConfig; exports.parseAttributeConfig = parseAttributeConfig; exports.safeParseAttributeConfig = safeParseAttributeConfig; exports.createTextValidator = createTextValidator; exports.createNumberValidator = createNumberValidator; exports.createCheckboxValidator = createCheckboxValidator; exports.createDateValidator = createDateValidator; exports.createPhoneValidator = createPhoneValidator; exports.createCurrencyValidator = createCurrencyValidator; exports.createStatusValidator = createStatusValidator; exports.createSelectValidator = createSelectValidator; exports.createMultiselectValidator = createMultiselectValidator; exports.createLocationValidator = createLocationValidator; exports.createFileValidator = createFileValidator; exports.createUserValidator = createUserValidator; exports.createSingleRelationValidator = createSingleRelationValidator; exports.createMultiRelationValidator = createMultiRelationValidator; exports.createRelationValidator = createRelationValidator; exports.createRatingValidator = createRatingValidator; exports.createFormulaValidator = createFormulaValidator; exports.createRollupValidator = createRollupValidator; exports.createTextAreaValidator = createTextAreaValidator; exports.createRichtextValidator = createRichtextValidator; exports.createAttributeValidator = createAttributeValidator; exports.createFormAttributeValidator = createFormAttributeValidator; exports.createObjectValidator = createObjectValidator; exports.validateAttribute = validateAttribute; exports.validateObject = validateObject; exports.validateObjectOrThrow = validateObjectOrThrow; exports.createDraftValidator = createDraftValidator; exports.validateDraft = validateDraft; exports.validateDraftOrThrow = validateDraftOrThrow; exports.getMissingRequiredAttributes = getMissingRequiredAttributes; exports.isRecordComplete = isRecordComplete; exports.computeRecordStatus = computeRecordStatus; exports.ParticipationTokenService = ParticipationTokenService; exports.getDefaultTokenService = getDefaultTokenService; exports.initializeTokenService = initializeTokenService; exports.PinCodeService = PinCodeService; exports.getDefaultPinCodeService = getDefaultPinCodeService; exports.initializePinCodeService = initializePinCodeService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.DEFAULT_LABEL_FALLBACK = DEFAULT_LABEL_FALLBACK; exports.renderLabelExpression = renderLabelExpression; exports.isLabelExpression = isLabelExpression; exports.extractAttributeNames = extractAttributeNames; exports.enrichValuesForDisplay = enrichValuesForDisplay; exports.enrichValuesWithSelectLabels = enrichValuesWithSelectLabels; exports.extractRelationIds = extractRelationIds; exports.computeLabelWithRelations = computeLabelWithRelations; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.notesPolicy = notesPolicy; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.TenantAwareRepository = TenantAwareRepository; exports.TenantAwareService = TenantAwareService; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.WorkflowService = WorkflowService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.UserProfileService = UserProfileService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;