@stndrds/schema 0.1.0-alpha.49 → 0.1.0-alpha.51
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.
- package/dist/{chunk-FDWX5X6L.mjs → chunk-EK56IQJ7.mjs} +296 -1
- package/dist/{chunk-LPCQM5VG.js → chunk-IEHBD7WL.js} +440 -145
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +1 -1
- package/dist/{runtime-BbM_jyVU.d.mts → runtime-DRiI1SCJ.d.mts} +440 -7
- package/dist/{runtime-BbM_jyVU.d.ts → runtime-DRiI1SCJ.d.ts} +440 -7
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -2
- package/dist/runtime.mjs +1 -1
- package/package.json +2 -2
|
@@ -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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
5489
|
+
this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _125 => _125.targets]), () => ( []));
|
|
5195
5490
|
this.attr.defaultValue = [];
|
|
5196
|
-
if (_optionalChain([initOptions, 'optionalAccess',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
6180
|
-
required: _optionalChain([options, 'optionalAccess',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
8023
|
+
if (_optionalChain([options, 'optionalAccess', _187 => _187.systemOnly])) {
|
|
7729
8024
|
filtered = dbAttributes.filter((attr) => attr.system);
|
|
7730
|
-
} else if (_optionalChain([options, 'optionalAccess',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
9589
|
+
if (!_optionalChain([options, 'optionalAccess', _221 => _221.skipFormulas])) {
|
|
9295
9590
|
return {
|
|
9296
9591
|
records: enrichRecordsWithFormulas(result.records, schema),
|
|
9297
9592
|
total: result.total
|
|
@@ -9306,7 +9601,7 @@ var RelationService = class extends BaseService {
|
|
|
9306
9601
|
constructor(adapter, nativeRegistry, options) {
|
|
9307
9602
|
super(adapter);
|
|
9308
9603
|
this.schemaService = new ObjectSchemaService(adapter, nativeRegistry);
|
|
9309
|
-
this.queryService = _optionalChain([options, 'optionalAccess',
|
|
9604
|
+
this.queryService = _optionalChain([options, 'optionalAccess', _222 => _222.queryService]);
|
|
9310
9605
|
}
|
|
9311
9606
|
/**
|
|
9312
9607
|
* Set the query service after construction.
|
|
@@ -9377,7 +9672,7 @@ var RelationService = class extends BaseService {
|
|
|
9377
9672
|
}
|
|
9378
9673
|
const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
|
|
9379
9674
|
const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
|
|
9380
|
-
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess',
|
|
9675
|
+
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _223 => _223.size]) === 0) {
|
|
9381
9676
|
errors.push({
|
|
9382
9677
|
attribute: attr.name,
|
|
9383
9678
|
message: `No valid target objects found for ${attr.label}`
|
|
@@ -9430,7 +9725,7 @@ var RelationService = class extends BaseService {
|
|
|
9430
9725
|
for (const target of targets) {
|
|
9431
9726
|
try {
|
|
9432
9727
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
9433
|
-
if (_optionalChain([objectSchema, 'optionalAccess',
|
|
9728
|
+
if (_optionalChain([objectSchema, 'optionalAccess', _224 => _224.id])) {
|
|
9434
9729
|
objectIds.add(objectSchema.id);
|
|
9435
9730
|
}
|
|
9436
9731
|
} catch (e11) {
|
|
@@ -9494,7 +9789,7 @@ var RelationService = class extends BaseService {
|
|
|
9494
9789
|
let totalCount = 0;
|
|
9495
9790
|
for (const target of filteredTargets) {
|
|
9496
9791
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
9497
|
-
if (!_optionalChain([objectSchema, 'optionalAccess',
|
|
9792
|
+
if (!_optionalChain([objectSchema, 'optionalAccess', _225 => _225.id])) {
|
|
9498
9793
|
continue;
|
|
9499
9794
|
}
|
|
9500
9795
|
const queryOptions = {
|
|
@@ -9667,8 +9962,8 @@ var RelationService = class extends BaseService {
|
|
|
9667
9962
|
continue;
|
|
9668
9963
|
}
|
|
9669
9964
|
const attribute = attributeMap.get(attributeId);
|
|
9670
|
-
const targetConfig = _optionalChain([attribute, 'optionalAccess',
|
|
9671
|
-
const customTemplate = _optionalChain([targetConfig, 'optionalAccess',
|
|
9965
|
+
const targetConfig = _optionalChain([attribute, 'optionalAccess', _226 => _226.targets, 'optionalAccess', _227 => _227.find, 'call', _228 => _228((t) => t.object === objectSchema.name)]);
|
|
9966
|
+
const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _229 => _229.displayTemplate]);
|
|
9672
9967
|
let label;
|
|
9673
9968
|
if (customTemplate) {
|
|
9674
9969
|
label = await computeLabelWithRelations(
|
|
@@ -9721,8 +10016,8 @@ var RelationService = class extends BaseService {
|
|
|
9721
10016
|
if (!objectSchema) {
|
|
9722
10017
|
continue;
|
|
9723
10018
|
}
|
|
9724
|
-
const targetConfig = _optionalChain([attribute, 'optionalAccess',
|
|
9725
|
-
const customTemplate = _optionalChain([targetConfig, 'optionalAccess',
|
|
10019
|
+
const targetConfig = _optionalChain([attribute, 'optionalAccess', _230 => _230.targets, 'optionalAccess', _231 => _231.find, 'call', _232 => _232((t) => t.object === objectSchema.name)]);
|
|
10020
|
+
const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _233 => _233.displayTemplate]);
|
|
9726
10021
|
for (const record of objectRecords) {
|
|
9727
10022
|
let label;
|
|
9728
10023
|
if (customTemplate) {
|
|
@@ -9867,14 +10162,14 @@ var RollupService = class extends BaseService {
|
|
|
9867
10162
|
const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
|
|
9868
10163
|
let sourceObjectId;
|
|
9869
10164
|
let reverseRelationAttrName;
|
|
9870
|
-
if (_optionalChain([sourceSchema, 'optionalAccess',
|
|
10165
|
+
if (_optionalChain([sourceSchema, 'optionalAccess', _234 => _234.id])) {
|
|
9871
10166
|
sourceObjectId = sourceSchema.id;
|
|
9872
10167
|
const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
|
|
9873
10168
|
if (attr.type !== "relation") return false;
|
|
9874
10169
|
const relationConfig = attr;
|
|
9875
|
-
return _optionalChain([relationConfig, 'optionalAccess',
|
|
10170
|
+
return _optionalChain([relationConfig, 'optionalAccess', _235 => _235.targets, 'optionalAccess', _236 => _236.some, 'call', _237 => _237((t) => t.object === schema.name)]);
|
|
9876
10171
|
});
|
|
9877
|
-
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess',
|
|
10172
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _238 => _238.name]);
|
|
9878
10173
|
} else {
|
|
9879
10174
|
const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
|
|
9880
10175
|
if (!sourceObject) {
|
|
@@ -9885,9 +10180,9 @@ var RollupService = class extends BaseService {
|
|
|
9885
10180
|
const reverseRelationAttr = sourceAttributes.find((attr) => {
|
|
9886
10181
|
if (attr.type !== "relation") return false;
|
|
9887
10182
|
const relationConfig = attr.config;
|
|
9888
|
-
return _optionalChain([relationConfig, 'optionalAccess',
|
|
10183
|
+
return _optionalChain([relationConfig, 'optionalAccess', _239 => _239.targets, 'optionalAccess', _240 => _240.some, 'call', _241 => _241((t) => t.object === schema.name)]);
|
|
9889
10184
|
});
|
|
9890
|
-
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess',
|
|
10185
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _242 => _242.name]);
|
|
9891
10186
|
}
|
|
9892
10187
|
if (!reverseRelationAttrName) {
|
|
9893
10188
|
return { value: null, recordCount: 0 };
|
|
@@ -10124,7 +10419,7 @@ var RollupService = class extends BaseService {
|
|
|
10124
10419
|
}
|
|
10125
10420
|
for (const rollupDbAttr of rollupAttrs) {
|
|
10126
10421
|
const rollupConfig = rollupDbAttr.config;
|
|
10127
|
-
if (!_optionalChain([rollupConfig, 'optionalAccess',
|
|
10422
|
+
if (!_optionalChain([rollupConfig, 'optionalAccess', _243 => _243.relationAttribute])) {
|
|
10128
10423
|
continue;
|
|
10129
10424
|
}
|
|
10130
10425
|
const relationAttr = attributes.find(
|
|
@@ -10134,7 +10429,7 @@ var RollupService = class extends BaseService {
|
|
|
10134
10429
|
continue;
|
|
10135
10430
|
}
|
|
10136
10431
|
const relationConfig = relationAttr.config;
|
|
10137
|
-
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess',
|
|
10432
|
+
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _244 => _244.targets, 'optionalAccess', _245 => _245.some, 'call', _246 => _246(
|
|
10138
10433
|
(t) => t.object === changedSchema.name
|
|
10139
10434
|
)]);
|
|
10140
10435
|
if (!targetsChangedObject) {
|
|
@@ -10161,11 +10456,11 @@ var RecordService = class extends BaseService {
|
|
|
10161
10456
|
constructor(adapter, options) {
|
|
10162
10457
|
super(adapter);
|
|
10163
10458
|
this.schemaService = new ObjectSchemaService(adapter, registry, {
|
|
10164
|
-
auditService: _optionalChain([options, 'optionalAccess',
|
|
10459
|
+
auditService: _optionalChain([options, 'optionalAccess', _247 => _247.auditService])
|
|
10165
10460
|
});
|
|
10166
|
-
this.permissionService = _optionalChain([options, 'optionalAccess',
|
|
10167
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10168
|
-
this.policyRegistry = _optionalChain([options, 'optionalAccess',
|
|
10461
|
+
this.permissionService = _optionalChain([options, 'optionalAccess', _248 => _248.permissionService]);
|
|
10462
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _249 => _249.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
10463
|
+
this.policyRegistry = _optionalChain([options, 'optionalAccess', _250 => _250.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _251 => _251.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
10169
10464
|
this.queryService = new RecordQueryService(adapter, this.schemaService, {
|
|
10170
10465
|
permissionService: this.permissionService,
|
|
10171
10466
|
policyRegistry: this.policyRegistry
|
|
@@ -10175,7 +10470,7 @@ var RecordService = class extends BaseService {
|
|
|
10175
10470
|
});
|
|
10176
10471
|
this.userService = new UserService(adapter);
|
|
10177
10472
|
this.rollupService = new RollupService(adapter);
|
|
10178
|
-
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10473
|
+
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _252 => _252.hookRegistry]), () => ( new NoopHookRegistry()));
|
|
10179
10474
|
this.labelResolver = {
|
|
10180
10475
|
resolveRelationIds: (ids, attrId) => this.relationService.resolveIds(ids, attrId),
|
|
10181
10476
|
findRecordLabels: (ids) => this.adapter.objectRecords.findByIds(ids)
|
|
@@ -10207,21 +10502,21 @@ var RecordService = class extends BaseService {
|
|
|
10207
10502
|
schema,
|
|
10208
10503
|
this.tenantId,
|
|
10209
10504
|
dataWithDefaults,
|
|
10210
|
-
_optionalChain([options, 'optionalAccess',
|
|
10505
|
+
_optionalChain([options, 'optionalAccess', _253 => _253.hookMetadata])
|
|
10211
10506
|
);
|
|
10212
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10507
|
+
if (!_optionalChain([options, 'optionalAccess', _254 => _254.skipHooks])) {
|
|
10213
10508
|
await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
|
|
10214
10509
|
}
|
|
10215
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10216
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10510
|
+
if (_optionalChain([options, 'optionalAccess', _255 => _255.validate]) !== false) {
|
|
10511
|
+
if (_optionalChain([options, 'optionalAccess', _256 => _256.allowDraft])) {
|
|
10217
10512
|
validateDraftOrThrow(schema, dataWithDefaults);
|
|
10218
10513
|
} else {
|
|
10219
10514
|
validateObjectOrThrow(schema, dataWithDefaults);
|
|
10220
10515
|
}
|
|
10221
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10516
|
+
if (!_optionalChain([options, 'optionalAccess', _257 => _257.skipRelationValidation])) {
|
|
10222
10517
|
await this.relationService.validateRelationsOrThrow(schema, dataWithDefaults);
|
|
10223
10518
|
}
|
|
10224
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10519
|
+
if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipUserValidation])) {
|
|
10225
10520
|
await this.userService.validateUsersOrThrow(schema, dataWithDefaults);
|
|
10226
10521
|
}
|
|
10227
10522
|
}
|
|
@@ -10232,10 +10527,10 @@ var RecordService = class extends BaseService {
|
|
|
10232
10527
|
data: dataWithDefaults,
|
|
10233
10528
|
label,
|
|
10234
10529
|
completionStatus,
|
|
10235
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10530
|
+
metadata: _optionalChain([options, 'optionalAccess', _259 => _259.metadata]),
|
|
10236
10531
|
createdBy: this.userId
|
|
10237
10532
|
});
|
|
10238
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10533
|
+
if (!_optionalChain([options, 'optionalAccess', _260 => _260.skipHooks])) {
|
|
10239
10534
|
const afterCtx = {
|
|
10240
10535
|
...hookCtx,
|
|
10241
10536
|
recordId: record.id,
|
|
@@ -10255,7 +10550,7 @@ var RecordService = class extends BaseService {
|
|
|
10255
10550
|
objectId: schema.id,
|
|
10256
10551
|
recordId: record.id,
|
|
10257
10552
|
recordLabel: record.label,
|
|
10258
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10553
|
+
metadata: _optionalChain([options, 'optionalAccess', _261 => _261.hookMetadata])
|
|
10259
10554
|
});
|
|
10260
10555
|
}
|
|
10261
10556
|
return record;
|
|
@@ -10276,7 +10571,7 @@ var RecordService = class extends BaseService {
|
|
|
10276
10571
|
return null;
|
|
10277
10572
|
}
|
|
10278
10573
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10279
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10574
|
+
if (!_optionalChain([options, 'optionalAccess', _262 => _262.skipPolicyCheck])) {
|
|
10280
10575
|
const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
10281
10576
|
if (policy) {
|
|
10282
10577
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
@@ -10286,10 +10581,10 @@ var RecordService = class extends BaseService {
|
|
|
10286
10581
|
}
|
|
10287
10582
|
}
|
|
10288
10583
|
let enrichedRecord = record;
|
|
10289
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10584
|
+
if (!_optionalChain([options, 'optionalAccess', _263 => _263.skipFormulas])) {
|
|
10290
10585
|
enrichedRecord = enrichWithFormulas(record, schema);
|
|
10291
10586
|
}
|
|
10292
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10587
|
+
if (_optionalChain([options, 'optionalAccess', _264 => _264.includeSchema])) {
|
|
10293
10588
|
const recordWithSchema = enrichedRecord;
|
|
10294
10589
|
recordWithSchema.schema = schema;
|
|
10295
10590
|
return recordWithSchema;
|
|
@@ -10332,9 +10627,9 @@ var RecordService = class extends BaseService {
|
|
|
10332
10627
|
existing,
|
|
10333
10628
|
mergedData,
|
|
10334
10629
|
changedAttributes,
|
|
10335
|
-
_optionalChain([options, 'optionalAccess',
|
|
10630
|
+
_optionalChain([options, 'optionalAccess', _265 => _265.hookMetadata])
|
|
10336
10631
|
);
|
|
10337
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10632
|
+
if (!_optionalChain([options, 'optionalAccess', _266 => _266.skipHooks])) {
|
|
10338
10633
|
await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
|
|
10339
10634
|
}
|
|
10340
10635
|
const hookModifiedValues = {};
|
|
@@ -10343,19 +10638,19 @@ var RecordService = class extends BaseService {
|
|
|
10343
10638
|
hookModifiedValues[key] = hookCtx.newValues[key];
|
|
10344
10639
|
}
|
|
10345
10640
|
}
|
|
10346
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10347
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10641
|
+
if (_optionalChain([options, 'optionalAccess', _267 => _267.validate]) !== false) {
|
|
10642
|
+
if (_optionalChain([options, 'optionalAccess', _268 => _268.partial])) {
|
|
10348
10643
|
validateDraftOrThrow(schema, mergedData);
|
|
10349
10644
|
} else {
|
|
10350
10645
|
validateObjectOrThrow(schema, mergedData);
|
|
10351
10646
|
}
|
|
10352
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10647
|
+
if (!_optionalChain([options, 'optionalAccess', _269 => _269.skipRelationValidation])) {
|
|
10353
10648
|
await this.relationService.validateRelationsOrThrow(schema, {
|
|
10354
10649
|
...data,
|
|
10355
10650
|
...hookModifiedValues
|
|
10356
10651
|
});
|
|
10357
10652
|
}
|
|
10358
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10653
|
+
if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipUserValidation])) {
|
|
10359
10654
|
await this.userService.validateUsersOrThrow(schema, {
|
|
10360
10655
|
...data,
|
|
10361
10656
|
...hookModifiedValues
|
|
@@ -10371,7 +10666,7 @@ var RecordService = class extends BaseService {
|
|
|
10371
10666
|
__label: label,
|
|
10372
10667
|
__lastUpdatedBy: this.userId
|
|
10373
10668
|
};
|
|
10374
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10669
|
+
if (_optionalChain([options, 'optionalAccess', _271 => _271.metadata]) !== void 0) {
|
|
10375
10670
|
const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
|
|
10376
10671
|
const mergedMetadata = { ...existingMetadata, ...options.metadata };
|
|
10377
10672
|
const cleanedMetadata = Object.fromEntries(
|
|
@@ -10384,7 +10679,7 @@ var RecordService = class extends BaseService {
|
|
|
10384
10679
|
await this.invalidateLists("allRecordLists", existing.objectId);
|
|
10385
10680
|
await this.invalidateLists("allSearchResults", existing.objectId);
|
|
10386
10681
|
await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
|
|
10387
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10682
|
+
if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipHooks])) {
|
|
10388
10683
|
const afterCtx = {
|
|
10389
10684
|
...hookCtx,
|
|
10390
10685
|
record: updated
|
|
@@ -10399,7 +10694,7 @@ var RecordService = class extends BaseService {
|
|
|
10399
10694
|
if (this.auditService && this.userId && allChangedAttributes.length > 0) {
|
|
10400
10695
|
const changes = allChangedAttributes.map((attr) => ({
|
|
10401
10696
|
field: attr,
|
|
10402
|
-
oldValue: _optionalChain([hookCtx, 'access',
|
|
10697
|
+
oldValue: _optionalChain([hookCtx, 'access', _273 => _273.oldValues, 'optionalAccess', _274 => _274[attr]]),
|
|
10403
10698
|
newValue: hookCtx.newValues[attr]
|
|
10404
10699
|
}));
|
|
10405
10700
|
await this.auditService.logRecordAction({
|
|
@@ -10410,7 +10705,7 @@ var RecordService = class extends BaseService {
|
|
|
10410
10705
|
recordId: updated.id,
|
|
10411
10706
|
recordLabel: updated.label,
|
|
10412
10707
|
changes,
|
|
10413
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10708
|
+
metadata: _optionalChain([options, 'optionalAccess', _275 => _275.hookMetadata])
|
|
10414
10709
|
});
|
|
10415
10710
|
}
|
|
10416
10711
|
return updated;
|
|
@@ -10433,17 +10728,17 @@ var RecordService = class extends BaseService {
|
|
|
10433
10728
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10434
10729
|
checkRecordDeleteOrThrow(policy, record, ctx);
|
|
10435
10730
|
}
|
|
10436
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10731
|
+
if (_optionalChain([options, 'optionalAccess', _276 => _276.checkSystem]) && schema.system) {
|
|
10437
10732
|
throw new ProtectedResourceError("object", schema.name, "delete");
|
|
10438
10733
|
}
|
|
10439
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10734
|
+
if (!_optionalChain([options, 'optionalAccess', _277 => _277.skipReferenceCheck])) {
|
|
10440
10735
|
const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
|
|
10441
10736
|
if (references.length > 0) {
|
|
10442
10737
|
throw new RecordReferencedError(recordId, references);
|
|
10443
10738
|
}
|
|
10444
10739
|
}
|
|
10445
|
-
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess',
|
|
10446
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10740
|
+
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _278 => _278.hookMetadata]));
|
|
10741
|
+
if (!_optionalChain([options, 'optionalAccess', _279 => _279.skipHooks])) {
|
|
10447
10742
|
await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
|
|
10448
10743
|
}
|
|
10449
10744
|
await this.adapter.objectRecords.delete(recordId);
|
|
@@ -10452,7 +10747,7 @@ var RecordService = class extends BaseService {
|
|
|
10452
10747
|
await this.invalidateLists("allSearchResults", record.objectId);
|
|
10453
10748
|
await this.invalidateCachePattern(cacheKeys.allGlobalSearch(this.tenantId));
|
|
10454
10749
|
await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
|
|
10455
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10750
|
+
if (!_optionalChain([options, 'optionalAccess', _280 => _280.skipHooks])) {
|
|
10456
10751
|
await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
|
|
10457
10752
|
}
|
|
10458
10753
|
await recalculateParentRollups(record, schema, this.rollupContext);
|
|
@@ -10464,7 +10759,7 @@ var RecordService = class extends BaseService {
|
|
|
10464
10759
|
objectId: schema.id,
|
|
10465
10760
|
recordId: record.id,
|
|
10466
10761
|
recordLabel: record.label,
|
|
10467
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10762
|
+
metadata: _optionalChain([options, 'optionalAccess', _281 => _281.hookMetadata])
|
|
10468
10763
|
});
|
|
10469
10764
|
}
|
|
10470
10765
|
}
|
|
@@ -10499,8 +10794,8 @@ var RecordService = class extends BaseService {
|
|
|
10499
10794
|
}
|
|
10500
10795
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10501
10796
|
await checkPermission(this.permissionService, this.userId, schema.name, "update");
|
|
10502
|
-
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess',
|
|
10503
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10797
|
+
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _282 => _282.hookMetadata]));
|
|
10798
|
+
if (!_optionalChain([options, 'optionalAccess', _283 => _283.skipHooks])) {
|
|
10504
10799
|
await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
|
|
10505
10800
|
}
|
|
10506
10801
|
const restored = await this.adapter.objectRecords.restore(recordId);
|
|
@@ -10509,7 +10804,7 @@ var RecordService = class extends BaseService {
|
|
|
10509
10804
|
await this.invalidateLists("allSearchResults", record.objectId);
|
|
10510
10805
|
await this.invalidateCachePattern(cacheKeys.allGlobalSearch(this.tenantId));
|
|
10511
10806
|
await this.invalidateCachePattern(cacheKeys.resolvedRelationsByRecord(this.tenantId, recordId));
|
|
10512
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10807
|
+
if (!_optionalChain([options, 'optionalAccess', _284 => _284.skipHooks])) {
|
|
10513
10808
|
const afterCtx = {
|
|
10514
10809
|
...hookCtx,
|
|
10515
10810
|
record: restored
|
|
@@ -10524,7 +10819,7 @@ var RecordService = class extends BaseService {
|
|
|
10524
10819
|
objectId: schema.id,
|
|
10525
10820
|
recordId: restored.id,
|
|
10526
10821
|
recordLabel: restored.label,
|
|
10527
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10822
|
+
metadata: _optionalChain([options, 'optionalAccess', _285 => _285.hookMetadata])
|
|
10528
10823
|
});
|
|
10529
10824
|
}
|
|
10530
10825
|
return restored;
|
|
@@ -10727,8 +11022,8 @@ var RollupScheduler = class {
|
|
|
10727
11022
|
this.getSchemaById = getSchemaById;
|
|
10728
11023
|
this.pending = /* @__PURE__ */ new Map();
|
|
10729
11024
|
this.rollupService = new RollupService(adapter);
|
|
10730
|
-
this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10731
|
-
this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11025
|
+
this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _286 => _286.debounceMs]), () => ( 100));
|
|
11026
|
+
this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _287 => _287.maxPending]), () => ( 100));
|
|
10732
11027
|
}
|
|
10733
11028
|
/**
|
|
10734
11029
|
* Schedule a rollup recalculation for a parent record.
|
|
@@ -10806,7 +11101,7 @@ var WorkflowService = class extends BaseService {
|
|
|
10806
11101
|
if (Array.isArray(options)) {
|
|
10807
11102
|
this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
|
|
10808
11103
|
} else {
|
|
10809
|
-
this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11104
|
+
this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _288 => _288.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
|
|
10810
11105
|
}
|
|
10811
11106
|
}
|
|
10812
11107
|
// ============================================================================
|
|
@@ -11109,9 +11404,9 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
11109
11404
|
constructor(adapter, workflowService, options) {
|
|
11110
11405
|
super(adapter);
|
|
11111
11406
|
this.workflowService = workflowService;
|
|
11112
|
-
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11113
|
-
this.schemaService = _optionalChain([options, 'optionalAccess',
|
|
11114
|
-
this.recordService = _optionalChain([options, 'optionalAccess',
|
|
11407
|
+
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _289 => _289.executorRegistry]), () => ( getDefaultExecutorRegistry()));
|
|
11408
|
+
this.schemaService = _optionalChain([options, 'optionalAccess', _290 => _290.schemaService]);
|
|
11409
|
+
this.recordService = _optionalChain([options, 'optionalAccess', _291 => _291.recordService]);
|
|
11115
11410
|
}
|
|
11116
11411
|
/**
|
|
11117
11412
|
* Start a new workflow instance
|
|
@@ -11237,7 +11532,7 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
11237
11532
|
if (!this.adapter.workflowInstances) {
|
|
11238
11533
|
return { instances: [], total: 0 };
|
|
11239
11534
|
}
|
|
11240
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11535
|
+
if (_optionalChain([options, 'optionalAccess', _292 => _292.workflowName])) {
|
|
11241
11536
|
const instances2 = await this.getInstancesByWorkflow(options.workflowName);
|
|
11242
11537
|
let filtered = instances2;
|
|
11243
11538
|
if (options.status) {
|
|
@@ -11251,11 +11546,11 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
11251
11546
|
return { instances: paginated, total: total2 };
|
|
11252
11547
|
}
|
|
11253
11548
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
|
|
11254
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
11255
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
11549
|
+
limit: _optionalChain([options, 'optionalAccess', _293 => _293.limit]),
|
|
11550
|
+
offset: _optionalChain([options, 'optionalAccess', _294 => _294.offset])
|
|
11256
11551
|
});
|
|
11257
11552
|
let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
11258
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11553
|
+
if (_optionalChain([options, 'optionalAccess', _295 => _295.status])) {
|
|
11259
11554
|
instances = instances.filter((i) => i.status === options.status);
|
|
11260
11555
|
}
|
|
11261
11556
|
return { instances, total };
|
|
@@ -11275,9 +11570,9 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
11275
11570
|
return { instances: [], total: 0 };
|
|
11276
11571
|
}
|
|
11277
11572
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
|
|
11278
|
-
status: _optionalChain([options, 'optionalAccess',
|
|
11279
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
11280
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
11573
|
+
status: _optionalChain([options, 'optionalAccess', _296 => _296.status]),
|
|
11574
|
+
limit: _optionalChain([options, 'optionalAccess', _297 => _297.limit]),
|
|
11575
|
+
offset: _optionalChain([options, 'optionalAccess', _298 => _298.offset])
|
|
11281
11576
|
});
|
|
11282
11577
|
const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
11283
11578
|
return { instances, total };
|
|
@@ -11653,7 +11948,7 @@ var WorkflowParticipationService = class extends BaseService {
|
|
|
11653
11948
|
SchemaErrorCode.RECORD_NOT_FOUND
|
|
11654
11949
|
);
|
|
11655
11950
|
}
|
|
11656
|
-
const template = _optionalChain([instance, 'access',
|
|
11951
|
+
const template = _optionalChain([instance, 'access', _299 => _299.workflowSnapshot, 'access', _300 => _300.participants, 'optionalAccess', _301 => _301.find, 'call', _302 => _302(
|
|
11657
11952
|
(p) => p.id === input.participantTemplateId
|
|
11658
11953
|
)]);
|
|
11659
11954
|
if (!template) {
|
|
@@ -11955,7 +12250,7 @@ var WorkflowRelationService = class extends BaseService {
|
|
|
11955
12250
|
if (attr.type !== "relation") continue;
|
|
11956
12251
|
for (const slot of slots) {
|
|
11957
12252
|
const slotData = context.slots[slot.id];
|
|
11958
|
-
const slotRecordId = _optionalChain([slotData, 'optionalAccess',
|
|
12253
|
+
const slotRecordId = _optionalChain([slotData, 'optionalAccess', _303 => _303.id]);
|
|
11959
12254
|
if (!slotRecordId) continue;
|
|
11960
12255
|
const targetsSlotObject = attr.targets.some(
|
|
11961
12256
|
(t) => t.object === slot.objectName
|
|
@@ -12020,7 +12315,7 @@ var WorkflowRelationService = class extends BaseService {
|
|
|
12020
12315
|
var UserProfileService = class extends BaseService {
|
|
12021
12316
|
constructor(adapter, options) {
|
|
12022
12317
|
super(adapter);
|
|
12023
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
12318
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _304 => _304.auditService]);
|
|
12024
12319
|
}
|
|
12025
12320
|
// ============================================================================
|
|
12026
12321
|
// CACHE MANAGEMENT
|
|
@@ -12183,7 +12478,7 @@ var UserProfileService = class extends BaseService {
|
|
|
12183
12478
|
*/
|
|
12184
12479
|
async deleteProfile(profileId, options) {
|
|
12185
12480
|
const profile = await this.getProfileOrThrow(profileId);
|
|
12186
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12481
|
+
if (_optionalChain([options, 'optionalAccess', _305 => _305.checkAdmin])) {
|
|
12187
12482
|
if (profile.role === "admin") {
|
|
12188
12483
|
const adminCount = await this.adapter.userProfiles.countByRole("admin");
|
|
12189
12484
|
if (adminCount <= 1) {
|
|
@@ -12258,7 +12553,7 @@ var UserProfileService = class extends BaseService {
|
|
|
12258
12553
|
*/
|
|
12259
12554
|
async hasRole(profileId, role) {
|
|
12260
12555
|
const profile = await this.getProfile(profileId);
|
|
12261
|
-
return _optionalChain([profile, 'optionalAccess',
|
|
12556
|
+
return _optionalChain([profile, 'optionalAccess', _306 => _306.role]) === role;
|
|
12262
12557
|
}
|
|
12263
12558
|
/**
|
|
12264
12559
|
* Check if user is admin
|
|
@@ -12315,7 +12610,7 @@ var UserProfileService = class extends BaseService {
|
|
|
12315
12610
|
var FileService = class extends BaseService {
|
|
12316
12611
|
constructor(adapter, options) {
|
|
12317
12612
|
super(adapter);
|
|
12318
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12613
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _307 => _307.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
12319
12614
|
}
|
|
12320
12615
|
// ============================================================================
|
|
12321
12616
|
// UPLOAD (requires StorageAdapter)
|
|
@@ -12447,7 +12742,7 @@ var FileService = class extends BaseService {
|
|
|
12447
12742
|
*/
|
|
12448
12743
|
async getFile(fileId) {
|
|
12449
12744
|
const file2 = await this.adapter.files.findById(fileId);
|
|
12450
|
-
if (_optionalChain([file2, 'optionalAccess',
|
|
12745
|
+
if (_optionalChain([file2, 'optionalAccess', _308 => _308.deletedAt])) {
|
|
12451
12746
|
return null;
|
|
12452
12747
|
}
|
|
12453
12748
|
return file2;
|
|
@@ -12509,12 +12804,12 @@ var FileService = class extends BaseService {
|
|
|
12509
12804
|
*/
|
|
12510
12805
|
async deleteFile(fileId, options) {
|
|
12511
12806
|
const file2 = await this.getFileOrThrow(fileId);
|
|
12512
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12807
|
+
if (_optionalChain([options, 'optionalAccess', _309 => _309.checkOwnership]) && options.userId) {
|
|
12513
12808
|
if (file2.uploadedBy !== options.userId) {
|
|
12514
12809
|
throw new Error("You can only delete files you uploaded");
|
|
12515
12810
|
}
|
|
12516
12811
|
}
|
|
12517
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12812
|
+
if (_optionalChain([options, 'optionalAccess', _310 => _310.hard])) {
|
|
12518
12813
|
await this.adapter.files.hardDelete(fileId);
|
|
12519
12814
|
} else {
|
|
12520
12815
|
await this.adapter.files.delete(fileId);
|
|
@@ -12545,7 +12840,7 @@ var FileService = class extends BaseService {
|
|
|
12545
12840
|
}
|
|
12546
12841
|
const file2 = await this.getFileOrThrow(fileId);
|
|
12547
12842
|
await this.adapter.storage.delete(file2.storagePath);
|
|
12548
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12843
|
+
if (_optionalChain([options, 'optionalAccess', _311 => _311.hard])) {
|
|
12549
12844
|
await this.adapter.files.hardDelete(fileId);
|
|
12550
12845
|
} else {
|
|
12551
12846
|
await this.adapter.files.delete(fileId);
|
|
@@ -12572,10 +12867,10 @@ var FileService = class extends BaseService {
|
|
|
12572
12867
|
if (!file2) {
|
|
12573
12868
|
continue;
|
|
12574
12869
|
}
|
|
12575
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12870
|
+
if (_optionalChain([options, 'optionalAccess', _312 => _312.deleteFromStorage]) && this.adapter.storage) {
|
|
12576
12871
|
await this.adapter.storage.delete(file2.storagePath);
|
|
12577
12872
|
}
|
|
12578
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12873
|
+
if (_optionalChain([options, 'optionalAccess', _313 => _313.hard])) {
|
|
12579
12874
|
await this.adapter.files.hardDelete(fileId);
|
|
12580
12875
|
} else {
|
|
12581
12876
|
await this.adapter.files.delete(fileId);
|
|
@@ -12586,7 +12881,7 @@ var FileService = class extends BaseService {
|
|
|
12586
12881
|
actorId: this.userId,
|
|
12587
12882
|
fileId,
|
|
12588
12883
|
fileName: file2.name,
|
|
12589
|
-
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12884
|
+
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _314 => _314.deleteFromStorage]), () => ( false)) }
|
|
12590
12885
|
});
|
|
12591
12886
|
}
|
|
12592
12887
|
}
|
|
@@ -12670,7 +12965,7 @@ var FileService = class extends BaseService {
|
|
|
12670
12965
|
return true;
|
|
12671
12966
|
}
|
|
12672
12967
|
if (file2.visibility === "restricted") {
|
|
12673
|
-
return _nullishCoalesce(_optionalChain([file2, 'access',
|
|
12968
|
+
return _nullishCoalesce(_optionalChain([file2, 'access', _315 => _315.allowedUsers, 'optionalAccess', _316 => _316.includes, 'call', _317 => _317(userId)]), () => ( false));
|
|
12674
12969
|
}
|
|
12675
12970
|
return false;
|
|
12676
12971
|
}
|
|
@@ -12835,10 +13130,10 @@ var GlobalSearchService = class extends BaseService {
|
|
|
12835
13130
|
*/
|
|
12836
13131
|
async executeSearch(query, options) {
|
|
12837
13132
|
return await this.adapter.objectRecords.globalSearch(query, {
|
|
12838
|
-
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12839
|
-
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12840
|
-
objectNames: _optionalChain([options, 'optionalAccess',
|
|
12841
|
-
includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
13133
|
+
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _318 => _318.limit]), () => ( 20)),
|
|
13134
|
+
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _319 => _319.offset]), () => ( 0)),
|
|
13135
|
+
objectNames: _optionalChain([options, 'optionalAccess', _320 => _320.objectNames]),
|
|
13136
|
+
includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _321 => _321.includeObjectInfo]), () => ( true))
|
|
12842
13137
|
});
|
|
12843
13138
|
}
|
|
12844
13139
|
/**
|
|
@@ -12888,7 +13183,7 @@ var PermissionService = class extends BaseService {
|
|
|
12888
13183
|
}
|
|
12889
13184
|
this.permissionsRepo = adapter.permissions;
|
|
12890
13185
|
this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
|
|
12891
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
13186
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _322 => _322.auditService]);
|
|
12892
13187
|
}
|
|
12893
13188
|
// ============================================================================
|
|
12894
13189
|
// PERMISSION CHECKS
|
|
@@ -12907,11 +13202,11 @@ var PermissionService = class extends BaseService {
|
|
|
12907
13202
|
return true;
|
|
12908
13203
|
}
|
|
12909
13204
|
const wildcardPerms = permissions.objectPermissions["*"];
|
|
12910
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
13205
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _323 => _323.includes, 'call', _324 => _324(action)])) {
|
|
12911
13206
|
return true;
|
|
12912
13207
|
}
|
|
12913
13208
|
const objectPerms = permissions.objectPermissions[objectName];
|
|
12914
|
-
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess',
|
|
13209
|
+
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _325 => _325.includes, 'call', _326 => _326(action)]), () => ( false));
|
|
12915
13210
|
}
|
|
12916
13211
|
/**
|
|
12917
13212
|
* Check if user can access an object, throw ForbiddenError if not.
|
|
@@ -12966,12 +13261,12 @@ var PermissionService = class extends BaseService {
|
|
|
12966
13261
|
if (permissions.isAdmin) {
|
|
12967
13262
|
return true;
|
|
12968
13263
|
}
|
|
12969
|
-
const wildcardPerms = _optionalChain([permissions, 'access',
|
|
12970
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
13264
|
+
const wildcardPerms = _optionalChain([permissions, 'access', _327 => _327.systemPermissions, 'optionalAccess', _328 => _328["*"]]);
|
|
13265
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _329 => _329.includes, 'call', _330 => _330(action)])) {
|
|
12971
13266
|
return true;
|
|
12972
13267
|
}
|
|
12973
|
-
const resourcePerms = _optionalChain([permissions, 'access',
|
|
12974
|
-
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess',
|
|
13268
|
+
const resourcePerms = _optionalChain([permissions, 'access', _331 => _331.systemPermissions, 'optionalAccess', _332 => _332[resource]]);
|
|
13269
|
+
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _333 => _333.includes, 'call', _334 => _334(action)]), () => ( false));
|
|
12975
13270
|
}
|
|
12976
13271
|
/**
|
|
12977
13272
|
* Check if user can access a system resource, throw ForbiddenError if not.
|
|
@@ -13000,8 +13295,8 @@ var PermissionService = class extends BaseService {
|
|
|
13000
13295
|
if (permissions.isAdmin) {
|
|
13001
13296
|
return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
|
|
13002
13297
|
}
|
|
13003
|
-
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access',
|
|
13004
|
-
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access',
|
|
13298
|
+
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _335 => _335.systemPermissions, 'optionalAccess', _336 => _336["*"]]), () => ( []));
|
|
13299
|
+
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _337 => _337.systemPermissions, 'optionalAccess', _338 => _338[resource]]), () => ( []));
|
|
13005
13300
|
const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
|
|
13006
13301
|
return {
|
|
13007
13302
|
canRead: allPerms.has("read"),
|
|
@@ -13143,7 +13438,7 @@ var PermissionService = class extends BaseService {
|
|
|
13143
13438
|
action: "role.updated",
|
|
13144
13439
|
actorId: this.userId,
|
|
13145
13440
|
roleId,
|
|
13146
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
13441
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _339 => _339.label]), () => ( roleId)),
|
|
13147
13442
|
metadata: { permissionsUpdated: true, permissionCount: permissions.length }
|
|
13148
13443
|
});
|
|
13149
13444
|
}
|
|
@@ -13173,7 +13468,7 @@ var PermissionService = class extends BaseService {
|
|
|
13173
13468
|
action: "role.assigned",
|
|
13174
13469
|
actorId: this.userId,
|
|
13175
13470
|
roleId,
|
|
13176
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
13471
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _340 => _340.label]), () => ( roleId)),
|
|
13177
13472
|
targetUserId: userProfileId
|
|
13178
13473
|
});
|
|
13179
13474
|
}
|
|
@@ -13191,7 +13486,7 @@ var PermissionService = class extends BaseService {
|
|
|
13191
13486
|
action: "role.revoked",
|
|
13192
13487
|
actorId: this.userId,
|
|
13193
13488
|
roleId,
|
|
13194
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
13489
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _341 => _341.label]), () => ( roleId)),
|
|
13195
13490
|
targetUserId: userProfileId
|
|
13196
13491
|
});
|
|
13197
13492
|
}
|