@stndrds/schema 0.1.0-alpha.59 → 0.1.0-alpha.60
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-DCTLP3ZD.js → chunk-KN6UXXVU.js} +238 -248
- package/dist/{chunk-O7FGYLYG.mjs → chunk-RRCPZUSK.mjs} +53 -63
- 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-BRkoIwsC.d.ts → runtime-Cx6QJ4QV.d.ts} +40 -45
- package/dist/{runtime-Chz-bTNq.d.mts → runtime-D0XMDY1D.d.mts} +40 -45
- 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
|
@@ -307,8 +307,8 @@ var cacheKeys = {
|
|
|
307
307
|
searchResults: (tenantId, objectId, hash) => `search:${tenantId}:${objectId}:${hash}`,
|
|
308
308
|
/** All search results for an object (for invalidation) */
|
|
309
309
|
allSearchResults: (tenantId, objectId) => `search:${tenantId}:${objectId}:*`,
|
|
310
|
-
/** Global search results */
|
|
311
|
-
globalSearch: (tenantId, hash) => `gsearch:${tenantId}:${hash}`,
|
|
310
|
+
/** Global search results (3-param signature to match cachedList pattern) */
|
|
311
|
+
globalSearch: (tenantId, _id, hash) => `gsearch:${tenantId}:${hash}`,
|
|
312
312
|
/** All global search results for tenant (for invalidation) */
|
|
313
313
|
allGlobalSearch: (tenantId) => `gsearch:${tenantId}:*`,
|
|
314
314
|
// -------------------------------------------------------------------------
|
|
@@ -3949,7 +3949,6 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3949
3949
|
objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _84 => _84.label]), () => ( "Unknown")),
|
|
3950
3950
|
label: renderLabelExpression(labelExpression, enrichedValues),
|
|
3951
3951
|
recordId: r.id,
|
|
3952
|
-
values: r.values,
|
|
3953
3952
|
completionStatus: r.completionStatus,
|
|
3954
3953
|
createdAt: r.createdAt,
|
|
3955
3954
|
updatedAt: r.updatedAt
|
|
@@ -3957,6 +3956,36 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3957
3956
|
});
|
|
3958
3957
|
return Promise.resolve({ results, total });
|
|
3959
3958
|
},
|
|
3959
|
+
globalSearchGrouped(query, options) {
|
|
3960
|
+
const limitPerGroup = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _85 => _85.limitPerGroup]), () => ( 5));
|
|
3961
|
+
return this.globalSearch(query, {
|
|
3962
|
+
objectNames: _optionalChain([options, 'optionalAccess', _86 => _86.objectNames]),
|
|
3963
|
+
limit: 500,
|
|
3964
|
+
offset: 0
|
|
3965
|
+
}).then(({ results }) => {
|
|
3966
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
3967
|
+
for (const result of results) {
|
|
3968
|
+
let group2 = groupMap.get(result.objectName);
|
|
3969
|
+
if (!group2) {
|
|
3970
|
+
group2 = {
|
|
3971
|
+
objectName: result.objectName,
|
|
3972
|
+
objectLabel: result.objectLabel,
|
|
3973
|
+
results: [],
|
|
3974
|
+
totalInGroup: 0
|
|
3975
|
+
};
|
|
3976
|
+
groupMap.set(result.objectName, group2);
|
|
3977
|
+
}
|
|
3978
|
+
group2.totalInGroup++;
|
|
3979
|
+
if (group2.results.length < limitPerGroup) {
|
|
3980
|
+
group2.results.push(result);
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
const groups = Array.from(groupMap.values());
|
|
3984
|
+
groups.sort((a, b) => b.totalInGroup - a.totalInGroup);
|
|
3985
|
+
const total = groups.reduce((sum, g) => sum + g.totalInGroup, 0);
|
|
3986
|
+
return { groups, total };
|
|
3987
|
+
});
|
|
3988
|
+
},
|
|
3960
3989
|
// -------------------------------------------------------------------------
|
|
3961
3990
|
// Schema Integrity Methods
|
|
3962
3991
|
// -------------------------------------------------------------------------
|
|
@@ -4241,7 +4270,7 @@ function createMockUserProfilesRepository(stores) {
|
|
|
4241
4270
|
list(options) {
|
|
4242
4271
|
const tenantId = getTenantId();
|
|
4243
4272
|
let results = Array.from(stores.userProfiles.values()).filter((p) => p.tenantId === tenantId);
|
|
4244
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4273
|
+
if (_optionalChain([options, 'optionalAccess', _87 => _87.limit])) {
|
|
4245
4274
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
4246
4275
|
}
|
|
4247
4276
|
return Promise.resolve(results);
|
|
@@ -4329,7 +4358,7 @@ function createMockPermissionsRepository(stores) {
|
|
|
4329
4358
|
},
|
|
4330
4359
|
deleteRole(roleId) {
|
|
4331
4360
|
const role = stores.roles.get(roleId);
|
|
4332
|
-
if (_optionalChain([role, 'optionalAccess',
|
|
4361
|
+
if (_optionalChain([role, 'optionalAccess', _88 => _88.system])) {
|
|
4333
4362
|
return Promise.reject(new Error(`Cannot delete system role ${roleId}`));
|
|
4334
4363
|
}
|
|
4335
4364
|
stores.roles.delete(roleId);
|
|
@@ -4818,7 +4847,7 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
4818
4847
|
(i) => i.tenant_id === tenantId
|
|
4819
4848
|
);
|
|
4820
4849
|
const total = results.length;
|
|
4821
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4850
|
+
if (_optionalChain([options, 'optionalAccess', _89 => _89.limit])) {
|
|
4822
4851
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
4823
4852
|
}
|
|
4824
4853
|
return Promise.resolve({ instances: results, total });
|
|
@@ -4846,7 +4875,7 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
4846
4875
|
pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
|
|
4847
4876
|
error: null,
|
|
4848
4877
|
started_by: data.startedBy,
|
|
4849
|
-
expires_at: _nullishCoalesce(_optionalChain([data, 'access',
|
|
4878
|
+
expires_at: _nullishCoalesce(_optionalChain([data, 'access', _90 => _90.expiresAt, 'optionalAccess', _91 => _91.toISOString, 'call', _92 => _92()]), () => ( null)),
|
|
4850
4879
|
created_at: now,
|
|
4851
4880
|
updated_at: now,
|
|
4852
4881
|
completed_at: null
|
|
@@ -4867,8 +4896,8 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
4867
4896
|
history: _nullishCoalesce(data.history, () => ( existing.history)),
|
|
4868
4897
|
pending_action: data.pendingAction !== void 0 ? data.pendingAction : existing.pending_action,
|
|
4869
4898
|
error: data.error !== void 0 ? data.error : existing.error,
|
|
4870
|
-
expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
4871
|
-
completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
4899
|
+
expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _93 => _93.expiresAt, 'optionalAccess', _94 => _94.toISOString, 'call', _95 => _95()]), () => ( null)) : existing.expires_at,
|
|
4900
|
+
completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _96 => _96.completedAt, 'optionalAccess', _97 => _97.toISOString, 'call', _98 => _98()]), () => ( null)) : existing.completed_at,
|
|
4872
4901
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4873
4902
|
};
|
|
4874
4903
|
stores.workflowInstances.set(id, updated);
|
|
@@ -4901,7 +4930,7 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
4901
4930
|
pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
|
|
4902
4931
|
error: null,
|
|
4903
4932
|
started_by: data.startedBy,
|
|
4904
|
-
expires_at: _nullishCoalesce(_optionalChain([data, 'access',
|
|
4933
|
+
expires_at: _nullishCoalesce(_optionalChain([data, 'access', _99 => _99.expiresAt, 'optionalAccess', _100 => _100.toISOString, 'call', _101 => _101()]), () => ( null)),
|
|
4905
4934
|
created_at: now,
|
|
4906
4935
|
updated_at: now,
|
|
4907
4936
|
completed_at: null
|
|
@@ -4924,13 +4953,13 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
4924
4953
|
return slotData.id === recordId;
|
|
4925
4954
|
});
|
|
4926
4955
|
});
|
|
4927
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4956
|
+
if (_optionalChain([options, 'optionalAccess', _102 => _102.status])) {
|
|
4928
4957
|
results = results.filter((i) => i.status === options.status);
|
|
4929
4958
|
}
|
|
4930
4959
|
const total = results.length;
|
|
4931
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4932
|
-
const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4933
|
-
const end = _optionalChain([options, 'optionalAccess',
|
|
4960
|
+
if (_optionalChain([options, 'optionalAccess', _103 => _103.offset]) !== void 0 || _optionalChain([options, 'optionalAccess', _104 => _104.limit]) !== void 0) {
|
|
4961
|
+
const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _105 => _105.offset]), () => ( 0));
|
|
4962
|
+
const end = _optionalChain([options, 'optionalAccess', _106 => _106.limit]) ? start + options.limit : void 0;
|
|
4934
4963
|
results = results.slice(start, end);
|
|
4935
4964
|
}
|
|
4936
4965
|
return Promise.resolve({ instances: results, total });
|
|
@@ -4986,7 +5015,7 @@ function createMockWorkflowInvitationsRepository(stores) {
|
|
|
4986
5015
|
const updated = {
|
|
4987
5016
|
...existing,
|
|
4988
5017
|
status: _nullishCoalesce(data.status, () => ( existing.status)),
|
|
4989
|
-
accepted_at: data.acceptedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
5018
|
+
accepted_at: data.acceptedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _107 => _107.acceptedAt, 'optionalAccess', _108 => _108.toISOString, 'call', _109 => _109()]), () => ( null)) : existing.accepted_at,
|
|
4990
5019
|
expires_at: data.expiresAt !== void 0 ? data.expiresAt.toISOString() : existing.expires_at
|
|
4991
5020
|
};
|
|
4992
5021
|
stores.workflowInvitations.set(id, updated);
|
|
@@ -5052,7 +5081,7 @@ function createMockWorkflowAccessGrantsRepository(stores) {
|
|
|
5052
5081
|
...existing,
|
|
5053
5082
|
last_used_at: data.lastUsedAt !== void 0 ? data.lastUsedAt.toISOString() : existing.last_used_at,
|
|
5054
5083
|
revoked_token_jtis: _nullishCoalesce(data.revokedTokenJtis, () => ( existing.revoked_token_jtis)),
|
|
5055
|
-
revoked_at: data.revokedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
5084
|
+
revoked_at: data.revokedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _110 => _110.revokedAt, 'optionalAccess', _111 => _111.toISOString, 'call', _112 => _112()]), () => ( null)) : existing.revoked_at
|
|
5056
5085
|
};
|
|
5057
5086
|
stores.workflowAccessGrants.set(id, updated);
|
|
5058
5087
|
return Promise.resolve(updated);
|
|
@@ -5201,7 +5230,7 @@ var notesPolicy = {
|
|
|
5201
5230
|
{ attribute: "visibility", operator: "is", value: "shared" },
|
|
5202
5231
|
{ attribute: "createdBy", operator: "is", value: ctx.userId }
|
|
5203
5232
|
];
|
|
5204
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
5233
|
+
if (!_optionalChain([options, 'optionalAccess', _113 => _113.filters]) || options.filters.rules.length === 0) {
|
|
5205
5234
|
return {
|
|
5206
5235
|
...options,
|
|
5207
5236
|
filters: { combinator: "or", rules: visibilityRules }
|
|
@@ -5347,7 +5376,7 @@ var BaseService = class {
|
|
|
5347
5376
|
* @param key - Cache key to invalidate
|
|
5348
5377
|
*/
|
|
5349
5378
|
async invalidateCache(key) {
|
|
5350
|
-
await _optionalChain([this, 'access',
|
|
5379
|
+
await _optionalChain([this, 'access', _114 => _114.cache, 'optionalAccess', _115 => _115.delete, 'call', _116 => _116(key)]);
|
|
5351
5380
|
}
|
|
5352
5381
|
/**
|
|
5353
5382
|
* Invalidate all cache keys matching a pattern.
|
|
@@ -5355,7 +5384,7 @@ var BaseService = class {
|
|
|
5355
5384
|
* @param pattern - Glob-style pattern (e.g., "schema:tenant-123:*")
|
|
5356
5385
|
*/
|
|
5357
5386
|
async invalidateCachePattern(pattern) {
|
|
5358
|
-
await _optionalChain([this, 'access',
|
|
5387
|
+
await _optionalChain([this, 'access', _117 => _117.cache, 'optionalAccess', _118 => _118.deletePattern, 'call', _119 => _119(pattern)]);
|
|
5359
5388
|
}
|
|
5360
5389
|
/**
|
|
5361
5390
|
* Invalidate all cached lists for a resource.
|
|
@@ -5553,17 +5582,17 @@ function validateOptions(options, attributeName) {
|
|
|
5553
5582
|
const ids = /* @__PURE__ */ new Set();
|
|
5554
5583
|
const values = /* @__PURE__ */ new Set();
|
|
5555
5584
|
for (const option of options) {
|
|
5556
|
-
if (!_optionalChain([option, 'access',
|
|
5585
|
+
if (!_optionalChain([option, 'access', _120 => _120.id, 'optionalAccess', _121 => _121.trim, 'call', _122 => _122()])) {
|
|
5557
5586
|
throw new Error(
|
|
5558
5587
|
`[AttributeBuilder] Option in "${attributeName}" has an empty or missing id.`
|
|
5559
5588
|
);
|
|
5560
5589
|
}
|
|
5561
|
-
if (!_optionalChain([option, 'access',
|
|
5590
|
+
if (!_optionalChain([option, 'access', _123 => _123.value, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()])) {
|
|
5562
5591
|
throw new Error(
|
|
5563
5592
|
`[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing value.`
|
|
5564
5593
|
);
|
|
5565
5594
|
}
|
|
5566
|
-
if (!_optionalChain([option, 'access',
|
|
5595
|
+
if (!_optionalChain([option, 'access', _126 => _126.label, 'optionalAccess', _127 => _127.trim, 'call', _128 => _128()])) {
|
|
5567
5596
|
throw new Error(
|
|
5568
5597
|
`[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing label.`
|
|
5569
5598
|
);
|
|
@@ -5947,8 +5976,8 @@ var BaseAttributeBuilder = class {
|
|
|
5947
5976
|
featureGate(flagName, options) {
|
|
5948
5977
|
this.attr.featureGate = {
|
|
5949
5978
|
flag: flagName,
|
|
5950
|
-
expectedValue: _optionalChain([options, 'optionalAccess',
|
|
5951
|
-
fallback: _optionalChain([options, 'optionalAccess',
|
|
5979
|
+
expectedValue: _optionalChain([options, 'optionalAccess', _129 => _129.expectedValue]),
|
|
5980
|
+
fallback: _optionalChain([options, 'optionalAccess', _130 => _130.fallback])
|
|
5952
5981
|
};
|
|
5953
5982
|
return this;
|
|
5954
5983
|
}
|
|
@@ -6396,7 +6425,7 @@ var SingleRelationAttributeBuilder = class extends BaseAttributeBuilder {
|
|
|
6396
6425
|
object: objectName,
|
|
6397
6426
|
...options
|
|
6398
6427
|
};
|
|
6399
|
-
_optionalChain([this, 'access',
|
|
6428
|
+
_optionalChain([this, 'access', _131 => _131.attr, 'access', _132 => _132.targets, 'optionalAccess', _133 => _133.push, 'call', _134 => _134(target)]);
|
|
6400
6429
|
return this;
|
|
6401
6430
|
}
|
|
6402
6431
|
/**
|
|
@@ -6467,9 +6496,9 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
|
|
|
6467
6496
|
constructor(name, label, initOptions) {
|
|
6468
6497
|
super("relation", name, label);
|
|
6469
6498
|
this.attr.cardinality = "many";
|
|
6470
|
-
this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess',
|
|
6499
|
+
this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _135 => _135.targets]), () => ( []));
|
|
6471
6500
|
this.attr.defaultValue = [];
|
|
6472
|
-
if (_optionalChain([initOptions, 'optionalAccess',
|
|
6501
|
+
if (_optionalChain([initOptions, 'optionalAccess', _136 => _136.isRequired])) {
|
|
6473
6502
|
this.setRequired(true);
|
|
6474
6503
|
}
|
|
6475
6504
|
}
|
|
@@ -6483,7 +6512,7 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
|
|
|
6483
6512
|
object: objectName,
|
|
6484
6513
|
...options
|
|
6485
6514
|
};
|
|
6486
|
-
_optionalChain([this, 'access',
|
|
6515
|
+
_optionalChain([this, 'access', _137 => _137.attr, 'access', _138 => _138.targets, 'optionalAccess', _139 => _139.push, 'call', _140 => _140(target)]);
|
|
6487
6516
|
return this;
|
|
6488
6517
|
}
|
|
6489
6518
|
/**
|
|
@@ -6964,7 +6993,7 @@ var GroupBuilder = class {
|
|
|
6964
6993
|
*/
|
|
6965
6994
|
fields(...names) {
|
|
6966
6995
|
for (const name of names) {
|
|
6967
|
-
_optionalChain([this, 'access',
|
|
6996
|
+
_optionalChain([this, 'access', _141 => _141.data, 'access', _142 => _142.fields, 'optionalAccess', _143 => _143.push, 'call', _144 => _144({ attribute: name })]);
|
|
6968
6997
|
}
|
|
6969
6998
|
return this;
|
|
6970
6999
|
}
|
|
@@ -6973,7 +7002,7 @@ var GroupBuilder = class {
|
|
|
6973
7002
|
* @example .field("name", { span: 8, readOnly: true })
|
|
6974
7003
|
*/
|
|
6975
7004
|
field(attribute, options) {
|
|
6976
|
-
_optionalChain([this, 'access',
|
|
7005
|
+
_optionalChain([this, 'access', _145 => _145.data, 'access', _146 => _146.fields, 'optionalAccess', _147 => _147.push, 'call', _148 => _148({ attribute, ...options })]);
|
|
6977
7006
|
return this;
|
|
6978
7007
|
}
|
|
6979
7008
|
/**
|
|
@@ -6982,7 +7011,7 @@ var GroupBuilder = class {
|
|
|
6982
7011
|
* @example .attributeGroup({ id: "address", label: "Address", attributes: ["street", "city", "postal_code"], displayTemplate: "{street}, {city}" })
|
|
6983
7012
|
*/
|
|
6984
7013
|
attributeGroup(config, options) {
|
|
6985
|
-
_optionalChain([this, 'access',
|
|
7014
|
+
_optionalChain([this, 'access', _149 => _149.data, 'access', _150 => _150.fields, 'optionalAccess', _151 => _151.push, 'call', _152 => _152({ attributeGroup: config, ...options })]);
|
|
6986
7015
|
return this;
|
|
6987
7016
|
}
|
|
6988
7017
|
/**
|
|
@@ -7914,8 +7943,8 @@ var WorkflowFormRowBuilder = class {
|
|
|
7914
7943
|
id: `${this.rowData.id}-${slotId}-${attribute}`,
|
|
7915
7944
|
slotId,
|
|
7916
7945
|
attribute,
|
|
7917
|
-
label: _optionalChain([options, 'optionalAccess',
|
|
7918
|
-
required: _optionalChain([options, 'optionalAccess',
|
|
7946
|
+
label: _optionalChain([options, 'optionalAccess', _153 => _153.label]),
|
|
7947
|
+
required: _optionalChain([options, 'optionalAccess', _154 => _154.required])
|
|
7919
7948
|
};
|
|
7920
7949
|
this.rowData.fields.push(field);
|
|
7921
7950
|
return this;
|
|
@@ -8206,7 +8235,7 @@ var WorkflowBuilder = class {
|
|
|
8206
8235
|
* @param options - Slot configuration
|
|
8207
8236
|
*/
|
|
8208
8237
|
slot(id, objectName, options) {
|
|
8209
|
-
if (_optionalChain([this, 'access',
|
|
8238
|
+
if (_optionalChain([this, 'access', _155 => _155.data, 'access', _156 => _156.slots, 'optionalAccess', _157 => _157.some, 'call', _158 => _158((s) => s.id === id)])) {
|
|
8210
8239
|
throw new Error(`[WorkflowBuilder] Duplicate slot id: "${id}"`);
|
|
8211
8240
|
}
|
|
8212
8241
|
const slot = {
|
|
@@ -8217,7 +8246,7 @@ var WorkflowBuilder = class {
|
|
|
8217
8246
|
color: options.color,
|
|
8218
8247
|
icon: options.icon
|
|
8219
8248
|
};
|
|
8220
|
-
_optionalChain([this, 'access',
|
|
8249
|
+
_optionalChain([this, 'access', _159 => _159.data, 'access', _160 => _160.slots, 'optionalAccess', _161 => _161.push, 'call', _162 => _162(slot)]);
|
|
8221
8250
|
return this;
|
|
8222
8251
|
}
|
|
8223
8252
|
// ============================================================================
|
|
@@ -8349,7 +8378,7 @@ var WorkflowBuilder = class {
|
|
|
8349
8378
|
}
|
|
8350
8379
|
}
|
|
8351
8380
|
validateSlotReferences() {
|
|
8352
|
-
const slotIds = _nullishCoalesce(_optionalChain([this, 'access',
|
|
8381
|
+
const slotIds = _nullishCoalesce(_optionalChain([this, 'access', _163 => _163.data, 'access', _164 => _164.slots, 'optionalAccess', _165 => _165.reduce, 'call', _166 => _166((set, s) => set.add(s.id), /* @__PURE__ */ new Set())]), () => ( /* @__PURE__ */ new Set()));
|
|
8353
8382
|
for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
|
|
8354
8383
|
if (node.type === "form") {
|
|
8355
8384
|
const referencedSlots = /* @__PURE__ */ new Set();
|
|
@@ -8587,7 +8616,7 @@ var ObjectSchemaService = class extends BaseService {
|
|
|
8587
8616
|
constructor(adapter, nativeRegistry, options) {
|
|
8588
8617
|
super(adapter);
|
|
8589
8618
|
this.nativeRegistry = nativeRegistry;
|
|
8590
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
8619
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _167 => _167.auditService]);
|
|
8591
8620
|
}
|
|
8592
8621
|
/**
|
|
8593
8622
|
* Create a new custom object.
|
|
@@ -8800,7 +8829,7 @@ var ObjectSchemaService = class extends BaseService {
|
|
|
8800
8829
|
resourceType: "attribute",
|
|
8801
8830
|
resourceId: attributeId,
|
|
8802
8831
|
resourceLabel: updatedDbAttr.label,
|
|
8803
|
-
objectName: _optionalChain([dbObject, 'optionalAccess',
|
|
8832
|
+
objectName: _optionalChain([dbObject, 'optionalAccess', _168 => _168.name]),
|
|
8804
8833
|
objectId: dbAttr.objectId,
|
|
8805
8834
|
changes
|
|
8806
8835
|
});
|
|
@@ -8833,7 +8862,7 @@ var ObjectSchemaService = class extends BaseService {
|
|
|
8833
8862
|
);
|
|
8834
8863
|
}
|
|
8835
8864
|
const dbObject = await this.adapter.objects.findById(dbAttr.objectId);
|
|
8836
|
-
if (_optionalChain([dbObject, 'optionalAccess',
|
|
8865
|
+
if (_optionalChain([dbObject, 'optionalAccess', _169 => _169.labelExpression])) {
|
|
8837
8866
|
const usedAttributes = extractAttributeNames(dbObject.labelExpression);
|
|
8838
8867
|
if (usedAttributes.includes(dbAttr.name)) {
|
|
8839
8868
|
throw new AttributeInUseError(dbAttr.name, "labelExpression");
|
|
@@ -8849,7 +8878,7 @@ var ObjectSchemaService = class extends BaseService {
|
|
|
8849
8878
|
resourceType: "attribute",
|
|
8850
8879
|
resourceId: attributeId,
|
|
8851
8880
|
resourceLabel: dbAttr.label,
|
|
8852
|
-
objectName: _optionalChain([dbObject, 'optionalAccess',
|
|
8881
|
+
objectName: _optionalChain([dbObject, 'optionalAccess', _170 => _170.name]),
|
|
8853
8882
|
objectId: dbAttr.objectId
|
|
8854
8883
|
});
|
|
8855
8884
|
}
|
|
@@ -8864,9 +8893,9 @@ var ObjectSchemaService = class extends BaseService {
|
|
|
8864
8893
|
async listAttributes(objectId, options) {
|
|
8865
8894
|
const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
|
|
8866
8895
|
let filtered = dbAttributes;
|
|
8867
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
8896
|
+
if (_optionalChain([options, 'optionalAccess', _171 => _171.systemOnly])) {
|
|
8868
8897
|
filtered = dbAttributes.filter((attr) => attr.system);
|
|
8869
|
-
} else if (_optionalChain([options, 'optionalAccess',
|
|
8898
|
+
} else if (_optionalChain([options, 'optionalAccess', _172 => _172.customOnly])) {
|
|
8870
8899
|
filtered = dbAttributes.filter((attr) => !attr.system);
|
|
8871
8900
|
}
|
|
8872
8901
|
return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
|
|
@@ -8902,14 +8931,14 @@ var ObjectSchemaService = class extends BaseService {
|
|
|
8902
8931
|
pluralLabel: dbObject.pluralLabel,
|
|
8903
8932
|
description: dbObject.description,
|
|
8904
8933
|
labelExpression: dbObject.labelExpression,
|
|
8905
|
-
icon: _optionalChain([dbObject, 'access',
|
|
8934
|
+
icon: _optionalChain([dbObject, 'access', _173 => _173.metadata, 'optionalAccess', _174 => _174.icon])
|
|
8906
8935
|
};
|
|
8907
8936
|
let metadata = dbObject.metadata;
|
|
8908
8937
|
if (updates.icon !== void 0 || updates.metadata !== void 0) {
|
|
8909
8938
|
metadata = {
|
|
8910
8939
|
...dbObject.metadata,
|
|
8911
8940
|
...updates.metadata,
|
|
8912
|
-
icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access',
|
|
8941
|
+
icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _175 => _175.metadata, 'optionalAccess', _176 => _176.icon])))
|
|
8913
8942
|
};
|
|
8914
8943
|
}
|
|
8915
8944
|
const updatedDbObject = await this.adapter.objects.update(objectId, {
|
|
@@ -9189,7 +9218,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
|
|
|
9189
9218
|
label: dbObject.label,
|
|
9190
9219
|
pluralLabel: dbObject.pluralLabel,
|
|
9191
9220
|
description: dbObject.description,
|
|
9192
|
-
icon: _optionalChain([dbObject, 'access',
|
|
9221
|
+
icon: _optionalChain([dbObject, 'access', _177 => _177.metadata, 'optionalAccess', _178 => _178.icon]),
|
|
9193
9222
|
labelExpression: dbObject.labelExpression,
|
|
9194
9223
|
attributes,
|
|
9195
9224
|
system: dbObject.system,
|
|
@@ -9289,7 +9318,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
|
|
|
9289
9318
|
const hasRelationToTarget = attrs.some((attr) => {
|
|
9290
9319
|
if (attr.type !== "relation") return false;
|
|
9291
9320
|
const config = attr.config;
|
|
9292
|
-
return _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
9321
|
+
return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _179 => _179.targets, 'optionalAccess', _180 => _180.some, 'call', _181 => _181((t) => t.object === targetObjectName)]), () => ( false));
|
|
9293
9322
|
});
|
|
9294
9323
|
if (hasRelationToTarget) {
|
|
9295
9324
|
referencing.push(obj.name);
|
|
@@ -9367,7 +9396,7 @@ Native objects must have system=true. Did you forget to call .system() in your b
|
|
|
9367
9396
|
const existing = this.objects.get(object2.name);
|
|
9368
9397
|
throw new Error(
|
|
9369
9398
|
`[NativeObjectRegistry] Duplicate object name "${object2.name}":
|
|
9370
|
-
- Existing: "${_optionalChain([existing, 'optionalAccess',
|
|
9399
|
+
- Existing: "${_optionalChain([existing, 'optionalAccess', _182 => _182.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _183 => _183.id])})
|
|
9371
9400
|
- New: "${object2.label}" (id: ${object2.id})
|
|
9372
9401
|
Please use unique names for each native object.`
|
|
9373
9402
|
);
|
|
@@ -9484,7 +9513,7 @@ var AuditService = class extends BaseService {
|
|
|
9484
9513
|
this.isFlushing = false;
|
|
9485
9514
|
/** Pending flush promise to allow waiting on concurrent flush */
|
|
9486
9515
|
this.flushPromise = null;
|
|
9487
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9516
|
+
if (_optionalChain([options, 'optionalAccess', _184 => _184.async]) && options.flushIntervalMs) {
|
|
9488
9517
|
this.startFlushTimer();
|
|
9489
9518
|
}
|
|
9490
9519
|
}
|
|
@@ -9681,7 +9710,7 @@ var AuditService = class extends BaseService {
|
|
|
9681
9710
|
if (!this.adapter.audit) {
|
|
9682
9711
|
return;
|
|
9683
9712
|
}
|
|
9684
|
-
if (_optionalChain([this, 'access',
|
|
9713
|
+
if (_optionalChain([this, 'access', _185 => _185.options, 'optionalAccess', _186 => _186.async])) {
|
|
9685
9714
|
this.buffer.push(entry);
|
|
9686
9715
|
const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
|
|
9687
9716
|
if (this.buffer.length >= batchSize) {
|
|
@@ -9695,7 +9724,7 @@ var AuditService = class extends BaseService {
|
|
|
9695
9724
|
* Start the flush timer for async mode
|
|
9696
9725
|
*/
|
|
9697
9726
|
startFlushTimer() {
|
|
9698
|
-
const intervalMs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
9727
|
+
const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _187 => _187.options, 'optionalAccess', _188 => _188.flushIntervalMs]), () => ( 1e3));
|
|
9699
9728
|
this.flushTimer = setInterval(() => {
|
|
9700
9729
|
this.flush().catch(() => {
|
|
9701
9730
|
});
|
|
@@ -9803,7 +9832,7 @@ var UserService = class extends BaseService {
|
|
|
9803
9832
|
if (roleErrors.length > 0) {
|
|
9804
9833
|
errors.push({
|
|
9805
9834
|
attribute: attrName,
|
|
9806
|
-
message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access',
|
|
9835
|
+
message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _189 => _189.allowedRoles, 'optionalAccess', _190 => _190.join, 'call', _191 => _191(", ")])}`,
|
|
9807
9836
|
invalidIds: roleErrors
|
|
9808
9837
|
});
|
|
9809
9838
|
}
|
|
@@ -10125,7 +10154,7 @@ var RecordQueryService = class extends BaseService {
|
|
|
10125
10154
|
super(adapter);
|
|
10126
10155
|
this.schemaService = schemaService;
|
|
10127
10156
|
this.options = options;
|
|
10128
|
-
this.policyRegistry = _optionalChain([options, 'optionalAccess',
|
|
10157
|
+
this.policyRegistry = _optionalChain([options, 'optionalAccess', _192 => _192.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
10129
10158
|
}
|
|
10130
10159
|
// ============================================================================
|
|
10131
10160
|
// LIST
|
|
@@ -10175,12 +10204,12 @@ var RecordQueryService = class extends BaseService {
|
|
|
10175
10204
|
* Internal list query execution
|
|
10176
10205
|
*/
|
|
10177
10206
|
async executeListQuery(schema, objectId, options) {
|
|
10178
|
-
if (_optionalChain([this, 'access',
|
|
10207
|
+
if (_optionalChain([this, 'access', _194 => _194.options, 'optionalAccess', _195 => _195.permissionService]) && this.userId) {
|
|
10179
10208
|
await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
|
|
10180
10209
|
}
|
|
10181
|
-
const policy = _optionalChain([options, 'optionalAccess',
|
|
10210
|
+
const policy = _optionalChain([options, 'optionalAccess', _196 => _196.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
10182
10211
|
let effectiveOptions = options;
|
|
10183
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
10212
|
+
if (_optionalChain([policy, 'optionalAccess', _197 => _197.applyListFilter]) && this.userId) {
|
|
10184
10213
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10185
10214
|
effectiveOptions = policy.applyListFilter(ctx, options);
|
|
10186
10215
|
}
|
|
@@ -10190,10 +10219,10 @@ var RecordQueryService = class extends BaseService {
|
|
|
10190
10219
|
);
|
|
10191
10220
|
let filteredRecords = result.records;
|
|
10192
10221
|
let effectiveTotal = result.total;
|
|
10193
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
10222
|
+
if (_optionalChain([policy, 'optionalAccess', _198 => _198.canAccessRecord]) && this.userId) {
|
|
10194
10223
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10195
|
-
const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess',
|
|
10196
|
-
const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess',
|
|
10224
|
+
const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _199 => _199.limit]), () => ( 20));
|
|
10225
|
+
const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _200 => _200.offset]), () => ( 0));
|
|
10197
10226
|
const overfetchMultiplier = 5;
|
|
10198
10227
|
const batchSize = requestedLimit * overfetchMultiplier;
|
|
10199
10228
|
const maxScanRecords = 1e4;
|
|
@@ -10215,7 +10244,7 @@ var RecordQueryService = class extends BaseService {
|
|
|
10215
10244
|
exhausted = true;
|
|
10216
10245
|
break;
|
|
10217
10246
|
}
|
|
10218
|
-
const filtered = batch.records.filter((record) => _optionalChain([policy, 'access',
|
|
10247
|
+
const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _201 => _201.canAccessRecord, 'optionalCall', _202 => _202(ctx, record)]));
|
|
10219
10248
|
collected.push(...filtered);
|
|
10220
10249
|
dbOffset += batch.records.length;
|
|
10221
10250
|
totalScanned += batch.records.length;
|
|
@@ -10227,14 +10256,14 @@ var RecordQueryService = class extends BaseService {
|
|
|
10227
10256
|
effectiveTotal = exhausted ? collected.length : Math.max(collected.length, result.total);
|
|
10228
10257
|
filteredRecords = collected.slice(requestedOffset, requestedOffset + requestedLimit);
|
|
10229
10258
|
}
|
|
10230
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10259
|
+
if (_optionalChain([options, 'optionalAccess', _203 => _203.include]) && options.include.length > 0) {
|
|
10231
10260
|
filteredRecords = await this.includeRelationsWithProperties(
|
|
10232
10261
|
filteredRecords,
|
|
10233
10262
|
schema,
|
|
10234
10263
|
options.include
|
|
10235
10264
|
);
|
|
10236
10265
|
}
|
|
10237
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10266
|
+
if (!_optionalChain([options, 'optionalAccess', _204 => _204.skipFormulas])) {
|
|
10238
10267
|
return {
|
|
10239
10268
|
records: enrichRecordsWithFormulas(filteredRecords, schema),
|
|
10240
10269
|
total: effectiveTotal
|
|
@@ -10294,14 +10323,14 @@ var RecordQueryService = class extends BaseService {
|
|
|
10294
10323
|
* Internal search query execution
|
|
10295
10324
|
*/
|
|
10296
10325
|
async executeSearchQuery(schema, objectId, query, options) {
|
|
10297
|
-
if (_optionalChain([this, 'access',
|
|
10326
|
+
if (_optionalChain([this, 'access', _205 => _205.options, 'optionalAccess', _206 => _206.permissionService]) && this.userId) {
|
|
10298
10327
|
await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
|
|
10299
10328
|
}
|
|
10300
10329
|
const result = await runWithSchemaContext(
|
|
10301
10330
|
[schema],
|
|
10302
10331
|
() => this.adapter.objectRecords.search(objectId, query, options)
|
|
10303
10332
|
);
|
|
10304
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10333
|
+
if (!_optionalChain([options, 'optionalAccess', _207 => _207.skipFormulas])) {
|
|
10305
10334
|
return {
|
|
10306
10335
|
records: enrichRecordsWithFormulas(result.records, schema),
|
|
10307
10336
|
total: result.total
|
|
@@ -10548,7 +10577,7 @@ var RelationPropertiesService = class extends BaseService {
|
|
|
10548
10577
|
this.validateProperties(attribute.properties, item.props);
|
|
10549
10578
|
}
|
|
10550
10579
|
}
|
|
10551
|
-
const existing = await _optionalChain([adapter, 'access',
|
|
10580
|
+
const existing = await _optionalChain([adapter, 'access', _208 => _208.relationAttributes, 'optionalAccess', _209 => _209.findBySource, 'call', _210 => _210(
|
|
10552
10581
|
schema.name,
|
|
10553
10582
|
recordId,
|
|
10554
10583
|
attributeName
|
|
@@ -10827,7 +10856,7 @@ var RelationService = class extends BaseService {
|
|
|
10827
10856
|
}
|
|
10828
10857
|
const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
|
|
10829
10858
|
const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
|
|
10830
|
-
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess',
|
|
10859
|
+
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _211 => _211.size]) === 0) {
|
|
10831
10860
|
errors.push({
|
|
10832
10861
|
attribute: attr.name,
|
|
10833
10862
|
message: `No valid target objects found for ${attr.label}`
|
|
@@ -10880,7 +10909,7 @@ var RelationService = class extends BaseService {
|
|
|
10880
10909
|
for (const target of targets) {
|
|
10881
10910
|
try {
|
|
10882
10911
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
10883
|
-
if (_optionalChain([objectSchema, 'optionalAccess',
|
|
10912
|
+
if (_optionalChain([objectSchema, 'optionalAccess', _212 => _212.id])) {
|
|
10884
10913
|
objectIds.add(objectSchema.id);
|
|
10885
10914
|
}
|
|
10886
10915
|
} catch (e12) {
|
|
@@ -10949,7 +10978,7 @@ var RelationService = class extends BaseService {
|
|
|
10949
10978
|
const targetResults = await Promise.all(
|
|
10950
10979
|
filteredTargets.map(async (target) => {
|
|
10951
10980
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
10952
|
-
if (!_optionalChain([objectSchema, 'optionalAccess',
|
|
10981
|
+
if (!_optionalChain([objectSchema, 'optionalAccess', _213 => _213.id])) return { options: [], total: 0 };
|
|
10953
10982
|
const objectId = objectSchema.id;
|
|
10954
10983
|
const result = query ? await queryService.searchRecords(objectId, query, queryOptions) : await queryService.listRecords(objectId, queryOptions);
|
|
10955
10984
|
const options = await Promise.all(
|
|
@@ -11106,8 +11135,8 @@ var RelationService = class extends BaseService {
|
|
|
11106
11135
|
continue;
|
|
11107
11136
|
}
|
|
11108
11137
|
const attribute = attributeMap.get(attributeId);
|
|
11109
|
-
const targetConfig = _optionalChain([attribute, 'optionalAccess',
|
|
11110
|
-
const customTemplate = _optionalChain([targetConfig, 'optionalAccess',
|
|
11138
|
+
const targetConfig = _optionalChain([attribute, 'optionalAccess', _214 => _214.targets, 'optionalAccess', _215 => _215.find, 'call', _216 => _216((t) => t.object === objectSchema.name)]);
|
|
11139
|
+
const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _217 => _217.displayTemplate]);
|
|
11111
11140
|
const label = await this.resolveLabel(record, objectSchema, customTemplate);
|
|
11112
11141
|
resolved.push({
|
|
11113
11142
|
_compositeId: compositeId,
|
|
@@ -11257,14 +11286,14 @@ var RollupService = class extends BaseService {
|
|
|
11257
11286
|
const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
|
|
11258
11287
|
let sourceObjectId;
|
|
11259
11288
|
let reverseRelationAttrName;
|
|
11260
|
-
if (_optionalChain([sourceSchema, 'optionalAccess',
|
|
11289
|
+
if (_optionalChain([sourceSchema, 'optionalAccess', _218 => _218.id])) {
|
|
11261
11290
|
sourceObjectId = sourceSchema.id;
|
|
11262
11291
|
const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
|
|
11263
11292
|
if (attr.type !== "relation") return false;
|
|
11264
11293
|
const relationConfig = attr;
|
|
11265
|
-
return _optionalChain([relationConfig, 'optionalAccess',
|
|
11294
|
+
return _optionalChain([relationConfig, 'optionalAccess', _219 => _219.targets, 'optionalAccess', _220 => _220.some, 'call', _221 => _221((t) => t.object === schema.name)]);
|
|
11266
11295
|
});
|
|
11267
|
-
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess',
|
|
11296
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _222 => _222.name]);
|
|
11268
11297
|
} else {
|
|
11269
11298
|
const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
|
|
11270
11299
|
if (!sourceObject) {
|
|
@@ -11275,9 +11304,9 @@ var RollupService = class extends BaseService {
|
|
|
11275
11304
|
const reverseRelationAttr = sourceAttributes.find((attr) => {
|
|
11276
11305
|
if (attr.type !== "relation") return false;
|
|
11277
11306
|
const relationConfig = attr.config;
|
|
11278
|
-
return _optionalChain([relationConfig, 'optionalAccess',
|
|
11307
|
+
return _optionalChain([relationConfig, 'optionalAccess', _223 => _223.targets, 'optionalAccess', _224 => _224.some, 'call', _225 => _225((t) => t.object === schema.name)]);
|
|
11279
11308
|
});
|
|
11280
|
-
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess',
|
|
11309
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _226 => _226.name]);
|
|
11281
11310
|
}
|
|
11282
11311
|
if (!reverseRelationAttrName) {
|
|
11283
11312
|
return { value: null, recordCount: 0 };
|
|
@@ -11533,13 +11562,13 @@ var RollupService = class extends BaseService {
|
|
|
11533
11562
|
if (!obj) continue;
|
|
11534
11563
|
for (const rollupDbAttr of rollupAttrs) {
|
|
11535
11564
|
const rollupConfig = rollupDbAttr.config;
|
|
11536
|
-
if (!_optionalChain([rollupConfig, 'optionalAccess',
|
|
11565
|
+
if (!_optionalChain([rollupConfig, 'optionalAccess', _227 => _227.relationAttribute])) continue;
|
|
11537
11566
|
const relationAttr = attributes.find(
|
|
11538
11567
|
(a) => a.type === "relation" && a.name === rollupConfig.relationAttribute
|
|
11539
11568
|
);
|
|
11540
11569
|
if (!relationAttr) continue;
|
|
11541
11570
|
const relationConfig = relationAttr.config;
|
|
11542
|
-
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess',
|
|
11571
|
+
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _228 => _228.targets, 'optionalAccess', _229 => _229.some, 'call', _230 => _230(
|
|
11543
11572
|
(t) => t.object === changedSchema.name
|
|
11544
11573
|
)]);
|
|
11545
11574
|
if (!targetsChangedObject) continue;
|
|
@@ -11564,11 +11593,11 @@ var RecordService = class extends BaseService {
|
|
|
11564
11593
|
constructor(adapter, options) {
|
|
11565
11594
|
super(adapter);
|
|
11566
11595
|
this.schemaService = new ObjectSchemaService(adapter, registry, {
|
|
11567
|
-
auditService: _optionalChain([options, 'optionalAccess',
|
|
11596
|
+
auditService: _optionalChain([options, 'optionalAccess', _231 => _231.auditService])
|
|
11568
11597
|
});
|
|
11569
|
-
this.permissionService = _optionalChain([options, 'optionalAccess',
|
|
11570
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11571
|
-
this.policyRegistry = _optionalChain([options, 'optionalAccess',
|
|
11598
|
+
this.permissionService = _optionalChain([options, 'optionalAccess', _232 => _232.permissionService]);
|
|
11599
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _233 => _233.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
11600
|
+
this.policyRegistry = _optionalChain([options, 'optionalAccess', _234 => _234.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _235 => _235.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
11572
11601
|
this.recordResolver = new RecordResolverService(adapter);
|
|
11573
11602
|
this.queryService = new RecordQueryService(adapter, this.schemaService, {
|
|
11574
11603
|
permissionService: this.permissionService,
|
|
@@ -11583,7 +11612,7 @@ var RecordService = class extends BaseService {
|
|
|
11583
11612
|
recordResolver: this.recordResolver
|
|
11584
11613
|
});
|
|
11585
11614
|
this.userService = new UserService(adapter);
|
|
11586
|
-
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11615
|
+
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _236 => _236.hookRegistry]), () => ( new NoopHookRegistry()));
|
|
11587
11616
|
this.labelResolver = this.recordResolver.createLabelResolver(this.relationService);
|
|
11588
11617
|
this.rollupContext = this.recordResolver.createRollupContext(
|
|
11589
11618
|
this.rollupService,
|
|
@@ -11618,25 +11647,25 @@ var RecordService = class extends BaseService {
|
|
|
11618
11647
|
schema,
|
|
11619
11648
|
this.tenantId,
|
|
11620
11649
|
dataWithDefaults,
|
|
11621
|
-
_optionalChain([options, 'optionalAccess',
|
|
11650
|
+
_optionalChain([options, 'optionalAccess', _237 => _237.hookMetadata])
|
|
11622
11651
|
);
|
|
11623
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11652
|
+
if (!_optionalChain([options, 'optionalAccess', _238 => _238.skipHooks])) {
|
|
11624
11653
|
await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
|
|
11625
11654
|
}
|
|
11626
11655
|
const normalizedData = this.relationPropertiesService.normalizeRelationValuesForStorage(
|
|
11627
11656
|
schema,
|
|
11628
11657
|
dataWithDefaults
|
|
11629
11658
|
);
|
|
11630
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11631
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11659
|
+
if (_optionalChain([options, 'optionalAccess', _239 => _239.validate]) !== false) {
|
|
11660
|
+
if (_optionalChain([options, 'optionalAccess', _240 => _240.allowDraft])) {
|
|
11632
11661
|
_chunkU4AB53AMjs.validateDraftOrThrow.call(void 0, schema, normalizedData);
|
|
11633
11662
|
} else {
|
|
11634
11663
|
_chunkU4AB53AMjs.validateObjectOrThrow.call(void 0, schema, normalizedData);
|
|
11635
11664
|
}
|
|
11636
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11665
|
+
if (!_optionalChain([options, 'optionalAccess', _241 => _241.skipRelationValidation])) {
|
|
11637
11666
|
await this.relationService.validateRelationsOrThrow(schema, normalizedData);
|
|
11638
11667
|
}
|
|
11639
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11668
|
+
if (!_optionalChain([options, 'optionalAccess', _242 => _242.skipUserValidation])) {
|
|
11640
11669
|
await this.userService.validateUsersOrThrow(schema, normalizedData);
|
|
11641
11670
|
}
|
|
11642
11671
|
}
|
|
@@ -11647,12 +11676,12 @@ var RecordService = class extends BaseService {
|
|
|
11647
11676
|
data: normalizedData,
|
|
11648
11677
|
label,
|
|
11649
11678
|
completionStatus,
|
|
11650
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
11679
|
+
metadata: _optionalChain([options, 'optionalAccess', _243 => _243.metadata]),
|
|
11651
11680
|
createdBy: this.userId
|
|
11652
11681
|
});
|
|
11653
11682
|
for (const [attrName, value] of Object.entries(dataWithDefaults)) {
|
|
11654
11683
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
11655
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
11684
|
+
if (_optionalChain([attr, 'optionalAccess', _244 => _244.type]) === "relation" && attr.properties) {
|
|
11656
11685
|
await this.relationPropertiesService.syncRelationProperties(
|
|
11657
11686
|
schema,
|
|
11658
11687
|
record.id,
|
|
@@ -11662,7 +11691,7 @@ var RecordService = class extends BaseService {
|
|
|
11662
11691
|
);
|
|
11663
11692
|
}
|
|
11664
11693
|
}
|
|
11665
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11694
|
+
if (!_optionalChain([options, 'optionalAccess', _245 => _245.skipHooks])) {
|
|
11666
11695
|
const afterCtx = {
|
|
11667
11696
|
...hookCtx,
|
|
11668
11697
|
recordId: record.id,
|
|
@@ -11680,7 +11709,7 @@ var RecordService = class extends BaseService {
|
|
|
11680
11709
|
objectId: schema.id,
|
|
11681
11710
|
recordId: record.id,
|
|
11682
11711
|
recordLabel: record.label,
|
|
11683
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
11712
|
+
metadata: _optionalChain([options, 'optionalAccess', _246 => _246.hookMetadata])
|
|
11684
11713
|
}).catch((err) => {
|
|
11685
11714
|
console.error(
|
|
11686
11715
|
"Audit log failed (record.created):",
|
|
@@ -11706,7 +11735,7 @@ var RecordService = class extends BaseService {
|
|
|
11706
11735
|
return null;
|
|
11707
11736
|
}
|
|
11708
11737
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
11709
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11738
|
+
if (!_optionalChain([options, 'optionalAccess', _247 => _247.skipPolicyCheck])) {
|
|
11710
11739
|
const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
11711
11740
|
if (policy) {
|
|
11712
11741
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
@@ -11716,10 +11745,10 @@ var RecordService = class extends BaseService {
|
|
|
11716
11745
|
}
|
|
11717
11746
|
}
|
|
11718
11747
|
let enrichedRecord = record;
|
|
11719
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11748
|
+
if (!_optionalChain([options, 'optionalAccess', _248 => _248.skipFormulas])) {
|
|
11720
11749
|
enrichedRecord = enrichWithFormulas(record, schema);
|
|
11721
11750
|
}
|
|
11722
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11751
|
+
if (_optionalChain([options, 'optionalAccess', _249 => _249.includeSchema])) {
|
|
11723
11752
|
const recordWithSchema = enrichedRecord;
|
|
11724
11753
|
recordWithSchema.schema = schema;
|
|
11725
11754
|
return recordWithSchema;
|
|
@@ -11781,9 +11810,9 @@ var RecordService = class extends BaseService {
|
|
|
11781
11810
|
existing,
|
|
11782
11811
|
mergedData,
|
|
11783
11812
|
changedAttributes,
|
|
11784
|
-
_optionalChain([options, 'optionalAccess',
|
|
11813
|
+
_optionalChain([options, 'optionalAccess', _250 => _250.hookMetadata])
|
|
11785
11814
|
);
|
|
11786
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11815
|
+
if (!_optionalChain([options, 'optionalAccess', _251 => _251.skipHooks])) {
|
|
11787
11816
|
await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
|
|
11788
11817
|
}
|
|
11789
11818
|
const hookModifiedValues = {};
|
|
@@ -11798,16 +11827,16 @@ var RecordService = class extends BaseService {
|
|
|
11798
11827
|
dataToUpdate
|
|
11799
11828
|
);
|
|
11800
11829
|
const normalizedMergedData = { ...existing.values, ...normalizedUpdate };
|
|
11801
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11802
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11830
|
+
if (_optionalChain([options, 'optionalAccess', _252 => _252.validate]) !== false) {
|
|
11831
|
+
if (_optionalChain([options, 'optionalAccess', _253 => _253.partial])) {
|
|
11803
11832
|
_chunkU4AB53AMjs.validateDraftOrThrow.call(void 0, schema, normalizedMergedData);
|
|
11804
11833
|
} else {
|
|
11805
11834
|
_chunkU4AB53AMjs.validateObjectOrThrow.call(void 0, schema, normalizedMergedData);
|
|
11806
11835
|
}
|
|
11807
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11836
|
+
if (!_optionalChain([options, 'optionalAccess', _254 => _254.skipRelationValidation])) {
|
|
11808
11837
|
await this.relationService.validateRelationsOrThrow(schema, normalizedUpdate);
|
|
11809
11838
|
}
|
|
11810
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11839
|
+
if (!_optionalChain([options, 'optionalAccess', _255 => _255.skipUserValidation])) {
|
|
11811
11840
|
await this.userService.validateUsersOrThrow(schema, normalizedUpdate);
|
|
11812
11841
|
}
|
|
11813
11842
|
}
|
|
@@ -11820,7 +11849,7 @@ var RecordService = class extends BaseService {
|
|
|
11820
11849
|
__lastUpdatedBy: this.userId,
|
|
11821
11850
|
__expectedUpdatedAt: existing.updatedAt instanceof Date ? existing.updatedAt.toISOString() : existing.updatedAt
|
|
11822
11851
|
};
|
|
11823
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11852
|
+
if (_optionalChain([options, 'optionalAccess', _256 => _256.metadata]) !== void 0) {
|
|
11824
11853
|
const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
|
|
11825
11854
|
const mergedMetadata = { ...existingMetadata, ...options.metadata };
|
|
11826
11855
|
const cleanedMetadata = Object.fromEntries(
|
|
@@ -11832,7 +11861,7 @@ var RecordService = class extends BaseService {
|
|
|
11832
11861
|
await this.invalidateRecordCaches(recordId, existing.objectId);
|
|
11833
11862
|
for (const [attrName, value] of Object.entries(dataToUpdate)) {
|
|
11834
11863
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
11835
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
11864
|
+
if (_optionalChain([attr, 'optionalAccess', _257 => _257.type]) === "relation" && attr.properties) {
|
|
11836
11865
|
await this.relationPropertiesService.syncRelationProperties(
|
|
11837
11866
|
schema,
|
|
11838
11867
|
recordId,
|
|
@@ -11842,7 +11871,7 @@ var RecordService = class extends BaseService {
|
|
|
11842
11871
|
);
|
|
11843
11872
|
}
|
|
11844
11873
|
}
|
|
11845
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11874
|
+
if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipHooks])) {
|
|
11846
11875
|
const afterCtx = {
|
|
11847
11876
|
...hookCtx,
|
|
11848
11877
|
record: updated
|
|
@@ -11857,7 +11886,7 @@ var RecordService = class extends BaseService {
|
|
|
11857
11886
|
if (this.auditService && this.userId && allChangedAttributes.length > 0) {
|
|
11858
11887
|
const changes = allChangedAttributes.map((attr) => ({
|
|
11859
11888
|
field: attr,
|
|
11860
|
-
oldValue: _optionalChain([hookCtx, 'access',
|
|
11889
|
+
oldValue: _optionalChain([hookCtx, 'access', _259 => _259.oldValues, 'optionalAccess', _260 => _260[attr]]),
|
|
11861
11890
|
newValue: hookCtx.newValues[attr]
|
|
11862
11891
|
}));
|
|
11863
11892
|
this.auditService.logRecordAction({
|
|
@@ -11868,7 +11897,7 @@ var RecordService = class extends BaseService {
|
|
|
11868
11897
|
recordId: updated.id,
|
|
11869
11898
|
recordLabel: updated.label,
|
|
11870
11899
|
changes,
|
|
11871
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
11900
|
+
metadata: _optionalChain([options, 'optionalAccess', _261 => _261.hookMetadata])
|
|
11872
11901
|
}).catch((err) => {
|
|
11873
11902
|
console.error(
|
|
11874
11903
|
"Audit log failed (record.updated):",
|
|
@@ -11903,22 +11932,22 @@ var RecordService = class extends BaseService {
|
|
|
11903
11932
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
11904
11933
|
checkRecordDeleteOrThrow(policy, record, ctx);
|
|
11905
11934
|
}
|
|
11906
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11935
|
+
if (_optionalChain([options, 'optionalAccess', _262 => _262.checkSystem]) && schema.system) {
|
|
11907
11936
|
throw new ProtectedResourceError("object", schema.name, "delete");
|
|
11908
11937
|
}
|
|
11909
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11938
|
+
if (!_optionalChain([options, 'optionalAccess', _263 => _263.skipReferenceCheck])) {
|
|
11910
11939
|
const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
|
|
11911
11940
|
if (references.length > 0) {
|
|
11912
11941
|
throw new RecordReferencedError(recordId, references);
|
|
11913
11942
|
}
|
|
11914
11943
|
}
|
|
11915
|
-
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess',
|
|
11916
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11944
|
+
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _264 => _264.hookMetadata]));
|
|
11945
|
+
if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipHooks])) {
|
|
11917
11946
|
await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
|
|
11918
11947
|
}
|
|
11919
11948
|
await this.adapter.objectRecords.delete(recordId);
|
|
11920
11949
|
await this.invalidateRecordCaches(recordId, record.objectId);
|
|
11921
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11950
|
+
if (!_optionalChain([options, 'optionalAccess', _266 => _266.skipHooks])) {
|
|
11922
11951
|
await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
|
|
11923
11952
|
}
|
|
11924
11953
|
await recalculateParentRollups(record, schema, this.rollupContext);
|
|
@@ -11930,7 +11959,7 @@ var RecordService = class extends BaseService {
|
|
|
11930
11959
|
objectId: schema.id,
|
|
11931
11960
|
recordId: record.id,
|
|
11932
11961
|
recordLabel: record.label,
|
|
11933
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
11962
|
+
metadata: _optionalChain([options, 'optionalAccess', _267 => _267.hookMetadata])
|
|
11934
11963
|
}).catch((err) => {
|
|
11935
11964
|
console.error(
|
|
11936
11965
|
"Audit log failed (record.deleted):",
|
|
@@ -11973,13 +12002,13 @@ var RecordService = class extends BaseService {
|
|
|
11973
12002
|
this.tenantId
|
|
11974
12003
|
);
|
|
11975
12004
|
await checkPermission(this.permissionService, this.userId, schema.name, "update");
|
|
11976
|
-
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess',
|
|
11977
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12005
|
+
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _268 => _268.hookMetadata]));
|
|
12006
|
+
if (!_optionalChain([options, 'optionalAccess', _269 => _269.skipHooks])) {
|
|
11978
12007
|
await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
|
|
11979
12008
|
}
|
|
11980
12009
|
const restored = await this.adapter.objectRecords.restore(recordId);
|
|
11981
12010
|
await this.invalidateRecordCaches(recordId, record.objectId);
|
|
11982
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12011
|
+
if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipHooks])) {
|
|
11983
12012
|
const afterCtx = {
|
|
11984
12013
|
...hookCtx,
|
|
11985
12014
|
record: restored
|
|
@@ -11994,7 +12023,7 @@ var RecordService = class extends BaseService {
|
|
|
11994
12023
|
objectId: schema.id,
|
|
11995
12024
|
recordId: restored.id,
|
|
11996
12025
|
recordLabel: restored.label,
|
|
11997
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
12026
|
+
metadata: _optionalChain([options, 'optionalAccess', _271 => _271.hookMetadata])
|
|
11998
12027
|
}).catch((err) => {
|
|
11999
12028
|
console.error(
|
|
12000
12029
|
"Audit log failed (record.restored):",
|
|
@@ -12375,7 +12404,7 @@ var DocumentRendererService = class {
|
|
|
12375
12404
|
throw new StorageDownloadNotSupportedError();
|
|
12376
12405
|
}
|
|
12377
12406
|
let storagePath = fileId;
|
|
12378
|
-
if (_optionalChain([this, 'access',
|
|
12407
|
+
if (_optionalChain([this, 'access', _272 => _272.options, 'optionalAccess', _273 => _273.filesRepository])) {
|
|
12379
12408
|
const file2 = await this.options.filesRepository.findById(fileId);
|
|
12380
12409
|
if (!file2) {
|
|
12381
12410
|
throw new Error(`Template file not found: ${fileId}`);
|
|
@@ -12393,8 +12422,8 @@ var DocumentRendererService = class {
|
|
|
12393
12422
|
for (const field of fields) {
|
|
12394
12423
|
const rawValue = getContextValue(context, field.contextPath);
|
|
12395
12424
|
const attrInfo = await this.getAttributeInfo(field.contextPath, workflow2);
|
|
12396
|
-
if (_optionalChain([attrInfo, 'optionalAccess',
|
|
12397
|
-
if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access',
|
|
12425
|
+
if (_optionalChain([attrInfo, 'optionalAccess', _274 => _274.attribute])) {
|
|
12426
|
+
if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access', _275 => _275.options, 'optionalAccess', _276 => _276.relationService])) {
|
|
12398
12427
|
const ids = Array.isArray(rawValue) ? rawValue : [rawValue];
|
|
12399
12428
|
const stringIds = ids.filter((id) => typeof id === "string");
|
|
12400
12429
|
if (stringIds.length > 0) {
|
|
@@ -12415,7 +12444,7 @@ var DocumentRendererService = class {
|
|
|
12415
12444
|
resolved.set(field.id, this.formatValueSimple(rawValue, field.fallback));
|
|
12416
12445
|
}
|
|
12417
12446
|
}
|
|
12418
|
-
if (relationBatch.length > 0 && _optionalChain([this, 'access',
|
|
12447
|
+
if (relationBatch.length > 0 && _optionalChain([this, 'access', _277 => _277.options, 'optionalAccess', _278 => _278.relationService])) {
|
|
12419
12448
|
try {
|
|
12420
12449
|
const batchResult = await this.options.relationService.resolveIdsBatch(
|
|
12421
12450
|
relationBatch.map((r) => ({ attributeId: r.attributeId, ids: r.ids }))
|
|
@@ -12424,12 +12453,12 @@ var DocumentRendererService = class {
|
|
|
12424
12453
|
const options = _nullishCoalesce(batchResult[attributeId], () => ( []));
|
|
12425
12454
|
const labels = options.map((o) => o.label);
|
|
12426
12455
|
const field = fields.find((f) => f.id === fieldId);
|
|
12427
|
-
resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess',
|
|
12456
|
+
resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess', _279 => _279.fallback]) || "");
|
|
12428
12457
|
}
|
|
12429
12458
|
} catch (e14) {
|
|
12430
12459
|
for (const { fieldId, ids } of relationBatch) {
|
|
12431
12460
|
const field = fields.find((f) => f.id === fieldId);
|
|
12432
|
-
resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess',
|
|
12461
|
+
resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess', _280 => _280.fallback]) || "");
|
|
12433
12462
|
}
|
|
12434
12463
|
}
|
|
12435
12464
|
}
|
|
@@ -12440,7 +12469,7 @@ var DocumentRendererService = class {
|
|
|
12440
12469
|
* Parses paths like "slots.client.firstName" to find the attribute definition
|
|
12441
12470
|
*/
|
|
12442
12471
|
async getAttributeInfo(contextPath, workflow2) {
|
|
12443
|
-
const schemaService = _optionalChain([this, 'access',
|
|
12472
|
+
const schemaService = _optionalChain([this, 'access', _281 => _281.options, 'optionalAccess', _282 => _282.schemaService]);
|
|
12444
12473
|
if (!schemaService) {
|
|
12445
12474
|
return null;
|
|
12446
12475
|
}
|
|
@@ -12453,7 +12482,7 @@ var DocumentRendererService = class {
|
|
|
12453
12482
|
}
|
|
12454
12483
|
const slotId = parts[1];
|
|
12455
12484
|
const attributeName = parts[2];
|
|
12456
|
-
const slot = _optionalChain([workflow2, 'access',
|
|
12485
|
+
const slot = _optionalChain([workflow2, 'access', _283 => _283.slots, 'optionalAccess', _284 => _284.find, 'call', _285 => _285((s) => s.id === slotId)]);
|
|
12457
12486
|
if (!slot) {
|
|
12458
12487
|
return null;
|
|
12459
12488
|
}
|
|
@@ -12652,7 +12681,7 @@ var DocumentProcessingHook = class extends BaseService {
|
|
|
12652
12681
|
const pendingIds = [];
|
|
12653
12682
|
for (const [nodeId, doc] of Object.entries(context.documents)) {
|
|
12654
12683
|
const metadata = doc.metadata;
|
|
12655
|
-
if (_optionalChain([metadata, 'optionalAccess',
|
|
12684
|
+
if (_optionalChain([metadata, 'optionalAccess', _286 => _286.status]) === "pending") {
|
|
12656
12685
|
pendingIds.push(nodeId);
|
|
12657
12686
|
}
|
|
12658
12687
|
}
|
|
@@ -12703,12 +12732,12 @@ var DocumentProcessingHook = class extends BaseService {
|
|
|
12703
12732
|
}
|
|
12704
12733
|
for (const slotId of targetSlotIds) {
|
|
12705
12734
|
try {
|
|
12706
|
-
const recordId = _optionalChain([context, 'access',
|
|
12735
|
+
const recordId = _optionalChain([context, 'access', _287 => _287.createdRecordIds, 'optionalAccess', _288 => _288[slotId]]);
|
|
12707
12736
|
if (!recordId) {
|
|
12708
12737
|
continue;
|
|
12709
12738
|
}
|
|
12710
|
-
const slotDef = _optionalChain([workflow2, 'access',
|
|
12711
|
-
const objectName = _optionalChain([slotDef, 'optionalAccess',
|
|
12739
|
+
const slotDef = _optionalChain([workflow2, 'access', _289 => _289.slots, 'optionalAccess', _290 => _290.find, 'call', _291 => _291((s) => s.id === slotId)]);
|
|
12740
|
+
const objectName = _optionalChain([slotDef, 'optionalAccess', _292 => _292.objectName]);
|
|
12712
12741
|
if (!objectName) {
|
|
12713
12742
|
continue;
|
|
12714
12743
|
}
|
|
@@ -12725,7 +12754,7 @@ var DocumentProcessingHook = class extends BaseService {
|
|
|
12725
12754
|
attachedDocumentIds.push(result.document.id);
|
|
12726
12755
|
const record = await recordService.getRecord(recordId);
|
|
12727
12756
|
if (record) {
|
|
12728
|
-
const attachments = _nullishCoalesce(_optionalChain([record, 'access',
|
|
12757
|
+
const attachments = _nullishCoalesce(_optionalChain([record, 'access', _293 => _293.values, 'optionalAccess', _294 => _294.attachments]), () => ( []));
|
|
12729
12758
|
await recordService.updateRecord(
|
|
12730
12759
|
recordId,
|
|
12731
12760
|
{ attachments: [...attachments, result.document.id] },
|
|
@@ -12991,7 +13020,7 @@ var WorkflowAccessGrantService = class extends BaseService {
|
|
|
12991
13020
|
* Check if a specific token has been revoked.
|
|
12992
13021
|
*/
|
|
12993
13022
|
isTokenRevoked(dbGrant, jti) {
|
|
12994
|
-
return _nullishCoalesce(_optionalChain([dbGrant, 'access',
|
|
13023
|
+
return _nullishCoalesce(_optionalChain([dbGrant, 'access', _295 => _295.revoked_token_jtis, 'optionalAccess', _296 => _296.includes, 'call', _297 => _297(jti)]), () => ( false));
|
|
12995
13024
|
}
|
|
12996
13025
|
/**
|
|
12997
13026
|
* Validate access token payload against the grant.
|
|
@@ -13043,10 +13072,10 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13043
13072
|
constructor(adapter, workflowService, options) {
|
|
13044
13073
|
super(adapter);
|
|
13045
13074
|
this.workflowService = workflowService;
|
|
13046
|
-
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
13047
|
-
this.schemaService = _optionalChain([options, 'optionalAccess',
|
|
13048
|
-
this.recordService = _optionalChain([options, 'optionalAccess',
|
|
13049
|
-
this.documentProcessingHook = _optionalChain([options, 'optionalAccess',
|
|
13075
|
+
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _298 => _298.executorRegistry]), () => ( getDefaultExecutorRegistry()));
|
|
13076
|
+
this.schemaService = _optionalChain([options, 'optionalAccess', _299 => _299.schemaService]);
|
|
13077
|
+
this.recordService = _optionalChain([options, 'optionalAccess', _300 => _300.recordService]);
|
|
13078
|
+
this.documentProcessingHook = _optionalChain([options, 'optionalAccess', _301 => _301.documentProcessingHook]);
|
|
13050
13079
|
}
|
|
13051
13080
|
/**
|
|
13052
13081
|
* Start a new workflow instance
|
|
@@ -13228,7 +13257,7 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13228
13257
|
if (!this.adapter.workflowInstances) {
|
|
13229
13258
|
return { instances: [], total: 0 };
|
|
13230
13259
|
}
|
|
13231
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
13260
|
+
if (_optionalChain([options, 'optionalAccess', _302 => _302.workflowName])) {
|
|
13232
13261
|
const allDbInstances = await this.adapter.workflowInstances.findByWorkflowName(
|
|
13233
13262
|
options.workflowName,
|
|
13234
13263
|
{ status: options.status }
|
|
@@ -13242,11 +13271,11 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13242
13271
|
return { instances: instances2, total: total2 };
|
|
13243
13272
|
}
|
|
13244
13273
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
|
|
13245
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
13246
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
13274
|
+
limit: _optionalChain([options, 'optionalAccess', _303 => _303.limit]),
|
|
13275
|
+
offset: _optionalChain([options, 'optionalAccess', _304 => _304.offset])
|
|
13247
13276
|
});
|
|
13248
13277
|
let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
13249
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
13278
|
+
if (_optionalChain([options, 'optionalAccess', _305 => _305.status])) {
|
|
13250
13279
|
instances = instances.filter((i) => i.status === options.status);
|
|
13251
13280
|
}
|
|
13252
13281
|
instances = await this.markExpiredInstances(instances);
|
|
@@ -13267,9 +13296,9 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13267
13296
|
return { instances: [], total: 0 };
|
|
13268
13297
|
}
|
|
13269
13298
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
|
|
13270
|
-
status: _optionalChain([options, 'optionalAccess',
|
|
13271
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
13272
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
13299
|
+
status: _optionalChain([options, 'optionalAccess', _306 => _306.status]),
|
|
13300
|
+
limit: _optionalChain([options, 'optionalAccess', _307 => _307.limit]),
|
|
13301
|
+
offset: _optionalChain([options, 'optionalAccess', _308 => _308.offset])
|
|
13273
13302
|
});
|
|
13274
13303
|
const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
13275
13304
|
return { instances, total };
|
|
@@ -13335,7 +13364,7 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13335
13364
|
try {
|
|
13336
13365
|
const schemas = await Promise.all(
|
|
13337
13366
|
current.workflowSnapshot.slots.map(
|
|
13338
|
-
(slot) => _optionalChain([this, 'access',
|
|
13367
|
+
(slot) => _optionalChain([this, 'access', _309 => _309.schemaService, 'optionalAccess', _310 => _310.getObjectSchemaByName, 'call', _311 => _311(slot.objectName)])
|
|
13339
13368
|
)
|
|
13340
13369
|
);
|
|
13341
13370
|
objectDefinitions = schemas.filter(
|
|
@@ -13600,8 +13629,8 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13600
13629
|
*/
|
|
13601
13630
|
async snapshotRecord(recordId) {
|
|
13602
13631
|
try {
|
|
13603
|
-
const record = await _optionalChain([this, 'access',
|
|
13604
|
-
return _optionalChain([record, 'optionalAccess',
|
|
13632
|
+
const record = await _optionalChain([this, 'access', _312 => _312.recordService, 'optionalAccess', _313 => _313.getRecord, 'call', _314 => _314(recordId, { skipPolicyCheck: true })]);
|
|
13633
|
+
return _optionalChain([record, 'optionalAccess', _315 => _315.values]);
|
|
13605
13634
|
} catch (e18) {
|
|
13606
13635
|
return void 0;
|
|
13607
13636
|
}
|
|
@@ -13620,13 +13649,13 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13620
13649
|
for (const op of [...operations].reverse()) {
|
|
13621
13650
|
try {
|
|
13622
13651
|
if (op.operation === "create") {
|
|
13623
|
-
await _optionalChain([this, 'access',
|
|
13652
|
+
await _optionalChain([this, 'access', _316 => _316.recordService, 'optionalAccess', _317 => _317.deleteRecord, 'call', _318 => _318(op.recordId, {
|
|
13624
13653
|
skipHooks: true,
|
|
13625
13654
|
skipReferenceCheck: true
|
|
13626
13655
|
})]);
|
|
13627
13656
|
rolledBack.push(op.slotId);
|
|
13628
13657
|
} else if (op.operation === "update" && op.previousData) {
|
|
13629
|
-
await _optionalChain([this, 'access',
|
|
13658
|
+
await _optionalChain([this, 'access', _319 => _319.recordService, 'optionalAccess', _320 => _320.updateRecord, 'call', _321 => _321(op.recordId, op.previousData, {
|
|
13630
13659
|
partial: false
|
|
13631
13660
|
})]);
|
|
13632
13661
|
rolledBack.push(op.slotId);
|
|
@@ -13750,7 +13779,7 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13750
13779
|
if (!this.adapter.workflowInstances) {
|
|
13751
13780
|
return;
|
|
13752
13781
|
}
|
|
13753
|
-
const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access',
|
|
13782
|
+
const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _322 => _322.context, 'access', _323 => _323.variables, 'optionalAccess', _324 => _324.__version]), () => ( 0));
|
|
13754
13783
|
const nextVersion = currentVersion + 1;
|
|
13755
13784
|
const instanceWithVersion = {
|
|
13756
13785
|
...instance,
|
|
@@ -14031,7 +14060,7 @@ var WorkflowRelationService = class extends BaseService {
|
|
|
14031
14060
|
if (attr.type !== "relation") continue;
|
|
14032
14061
|
for (const slot of slots) {
|
|
14033
14062
|
const slotData = context.slots[slot.id];
|
|
14034
|
-
const slotRecordId = _optionalChain([slotData, 'optionalAccess',
|
|
14063
|
+
const slotRecordId = _optionalChain([slotData, 'optionalAccess', _325 => _325.id]);
|
|
14035
14064
|
if (!slotRecordId) continue;
|
|
14036
14065
|
const targetsSlotObject = attr.targets.some(
|
|
14037
14066
|
(t) => t.object === slot.objectName
|
|
@@ -14099,7 +14128,7 @@ var WorkflowService = class extends BaseService {
|
|
|
14099
14128
|
if (Array.isArray(options)) {
|
|
14100
14129
|
this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
|
|
14101
14130
|
} else {
|
|
14102
|
-
this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
14131
|
+
this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _326 => _326.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
|
|
14103
14132
|
}
|
|
14104
14133
|
}
|
|
14105
14134
|
// ============================================================================
|
|
@@ -14397,7 +14426,7 @@ var WorkflowService = class extends BaseService {
|
|
|
14397
14426
|
var UserProfileService = class extends BaseService {
|
|
14398
14427
|
constructor(adapter, options) {
|
|
14399
14428
|
super(adapter);
|
|
14400
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
14429
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _327 => _327.auditService]);
|
|
14401
14430
|
}
|
|
14402
14431
|
// ============================================================================
|
|
14403
14432
|
// CACHE MANAGEMENT
|
|
@@ -14560,7 +14589,7 @@ var UserProfileService = class extends BaseService {
|
|
|
14560
14589
|
*/
|
|
14561
14590
|
async deleteProfile(profileId, options) {
|
|
14562
14591
|
const profile = await this.getProfileOrThrow(profileId);
|
|
14563
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
14592
|
+
if (_optionalChain([options, 'optionalAccess', _328 => _328.checkAdmin])) {
|
|
14564
14593
|
if (profile.role === "admin") {
|
|
14565
14594
|
const adminCount = await this.adapter.userProfiles.countByRole("admin");
|
|
14566
14595
|
if (adminCount <= 1) {
|
|
@@ -14635,7 +14664,7 @@ var UserProfileService = class extends BaseService {
|
|
|
14635
14664
|
*/
|
|
14636
14665
|
async hasRole(profileId, role) {
|
|
14637
14666
|
const profile = await this.getProfile(profileId);
|
|
14638
|
-
return _optionalChain([profile, 'optionalAccess',
|
|
14667
|
+
return _optionalChain([profile, 'optionalAccess', _329 => _329.role]) === role;
|
|
14639
14668
|
}
|
|
14640
14669
|
/**
|
|
14641
14670
|
* Check if user is admin
|
|
@@ -15069,7 +15098,7 @@ var DocumentTemplateService = class extends BaseService {
|
|
|
15069
15098
|
* Includes both system templates and tenant-specific templates.
|
|
15070
15099
|
*/
|
|
15071
15100
|
async listTemplates(options) {
|
|
15072
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
15101
|
+
if (_optionalChain([options, 'optionalAccess', _330 => _330.systemOnly])) {
|
|
15073
15102
|
return SYSTEM_TEMPLATES;
|
|
15074
15103
|
}
|
|
15075
15104
|
const templates = [...SYSTEM_TEMPLATES];
|
|
@@ -15152,8 +15181,8 @@ var DocumentTemplateService = class extends BaseService {
|
|
|
15152
15181
|
var DocumentService = class extends BaseService {
|
|
15153
15182
|
constructor(adapter, options) {
|
|
15154
15183
|
super(adapter);
|
|
15155
|
-
this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
15156
|
-
this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
15184
|
+
this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _331 => _331.templateService]), () => ( new DocumentTemplateService(adapter)));
|
|
15185
|
+
this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _332 => _332.fileService]), () => ( null));
|
|
15157
15186
|
}
|
|
15158
15187
|
// ============================================================================
|
|
15159
15188
|
// CREATE
|
|
@@ -15404,7 +15433,7 @@ var DocumentService = class extends BaseService {
|
|
|
15404
15433
|
*/
|
|
15405
15434
|
async isComplete(documentId) {
|
|
15406
15435
|
const document2 = await this.getDocument(documentId);
|
|
15407
|
-
return _optionalChain([document2, 'optionalAccess',
|
|
15436
|
+
return _optionalChain([document2, 'optionalAccess', _333 => _333.status]) !== "draft";
|
|
15408
15437
|
}
|
|
15409
15438
|
/**
|
|
15410
15439
|
* Get document with its template and slots.
|
|
@@ -15662,7 +15691,7 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
15662
15691
|
type: "signature",
|
|
15663
15692
|
provider: this.config.signatureAdapter.name,
|
|
15664
15693
|
input: { signers, ...options },
|
|
15665
|
-
expiresAt: _optionalChain([options, 'optionalAccess',
|
|
15694
|
+
expiresAt: _optionalChain([options, 'optionalAccess', _334 => _334.expiresAt])
|
|
15666
15695
|
});
|
|
15667
15696
|
return job;
|
|
15668
15697
|
}
|
|
@@ -15819,7 +15848,7 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
15819
15848
|
}
|
|
15820
15849
|
const document2 = await this.documentService.getDocumentOrThrow(documentId);
|
|
15821
15850
|
const template = await this.templateService.getTemplateOrThrow(document2.templateId);
|
|
15822
|
-
if (!_optionalChain([template, 'access',
|
|
15851
|
+
if (!_optionalChain([template, 'access', _335 => _335.autoProcessing, 'optionalAccess', _336 => _336.identityVerification, 'optionalAccess', _337 => _337.enabled])) {
|
|
15823
15852
|
throw new Error("Identity verification is not enabled for this document type");
|
|
15824
15853
|
}
|
|
15825
15854
|
const job = await this.adapter.documentJobs.create({
|
|
@@ -15905,13 +15934,13 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
15905
15934
|
const template = await this.templateService.getTemplateOrThrow(document2.templateId);
|
|
15906
15935
|
const slots = await this.documentService.getSlots(documentId);
|
|
15907
15936
|
const jobs = [];
|
|
15908
|
-
if (_optionalChain([template, 'access',
|
|
15937
|
+
if (_optionalChain([template, 'access', _338 => _338.autoProcessing, 'optionalAccess', _339 => _339.ocr, 'optionalAccess', _340 => _340.enabled]) && this.config.ocrAdapter) {
|
|
15909
15938
|
for (const slot of slots) {
|
|
15910
15939
|
const job = await this.processOcr(documentId, slot.slotName);
|
|
15911
15940
|
jobs.push(job);
|
|
15912
15941
|
}
|
|
15913
15942
|
}
|
|
15914
|
-
if (_optionalChain([template, 'access',
|
|
15943
|
+
if (_optionalChain([template, 'access', _341 => _341.autoProcessing, 'optionalAccess', _342 => _342.identityVerification, 'optionalAccess', _343 => _343.enabled]) && this.config.identityAdapter) {
|
|
15915
15944
|
const job = await this.verifyIdentity(documentId);
|
|
15916
15945
|
jobs.push(job);
|
|
15917
15946
|
}
|
|
@@ -15982,15 +16011,15 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
15982
16011
|
return {
|
|
15983
16012
|
ocr: {
|
|
15984
16013
|
available: !!this.config.ocrAdapter,
|
|
15985
|
-
provider: _optionalChain([this, 'access',
|
|
16014
|
+
provider: _optionalChain([this, 'access', _344 => _344.config, 'access', _345 => _345.ocrAdapter, 'optionalAccess', _346 => _346.name])
|
|
15986
16015
|
},
|
|
15987
16016
|
signature: {
|
|
15988
16017
|
available: !!this.config.signatureAdapter,
|
|
15989
|
-
provider: _optionalChain([this, 'access',
|
|
16018
|
+
provider: _optionalChain([this, 'access', _347 => _347.config, 'access', _348 => _348.signatureAdapter, 'optionalAccess', _349 => _349.name])
|
|
15990
16019
|
},
|
|
15991
16020
|
identityVerification: {
|
|
15992
16021
|
available: !!this.config.identityAdapter,
|
|
15993
|
-
provider: _optionalChain([this, 'access',
|
|
16022
|
+
provider: _optionalChain([this, 'access', _350 => _350.config, 'access', _351 => _351.identityAdapter, 'optionalAccess', _352 => _352.name])
|
|
15994
16023
|
}
|
|
15995
16024
|
};
|
|
15996
16025
|
}
|
|
@@ -16000,7 +16029,7 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
16000
16029
|
var FileService = class extends BaseService {
|
|
16001
16030
|
constructor(adapter, options) {
|
|
16002
16031
|
super(adapter);
|
|
16003
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
16032
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _353 => _353.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
16004
16033
|
}
|
|
16005
16034
|
// ============================================================================
|
|
16006
16035
|
// UPLOAD (requires StorageAdapter)
|
|
@@ -16139,7 +16168,7 @@ var FileService = class extends BaseService {
|
|
|
16139
16168
|
*/
|
|
16140
16169
|
async getFile(fileId) {
|
|
16141
16170
|
const file2 = await this.adapter.files.findById(fileId);
|
|
16142
|
-
if (_optionalChain([file2, 'optionalAccess',
|
|
16171
|
+
if (_optionalChain([file2, 'optionalAccess', _354 => _354.deletedAt])) {
|
|
16143
16172
|
return null;
|
|
16144
16173
|
}
|
|
16145
16174
|
return file2;
|
|
@@ -16201,12 +16230,12 @@ var FileService = class extends BaseService {
|
|
|
16201
16230
|
*/
|
|
16202
16231
|
async deleteFile(fileId, options) {
|
|
16203
16232
|
const file2 = await this.getFileOrThrow(fileId);
|
|
16204
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16233
|
+
if (_optionalChain([options, 'optionalAccess', _355 => _355.checkOwnership]) && options.userId) {
|
|
16205
16234
|
if (file2.uploadedBy !== options.userId) {
|
|
16206
16235
|
throw new Error("You can only delete files you uploaded");
|
|
16207
16236
|
}
|
|
16208
16237
|
}
|
|
16209
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16238
|
+
if (_optionalChain([options, 'optionalAccess', _356 => _356.hard])) {
|
|
16210
16239
|
await this.adapter.files.hardDelete(fileId);
|
|
16211
16240
|
} else {
|
|
16212
16241
|
await this.adapter.files.delete(fileId);
|
|
@@ -16237,7 +16266,7 @@ var FileService = class extends BaseService {
|
|
|
16237
16266
|
}
|
|
16238
16267
|
const file2 = await this.getFileOrThrow(fileId);
|
|
16239
16268
|
await this.adapter.storage.delete(file2.storagePath);
|
|
16240
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16269
|
+
if (_optionalChain([options, 'optionalAccess', _357 => _357.hard])) {
|
|
16241
16270
|
await this.adapter.files.hardDelete(fileId);
|
|
16242
16271
|
} else {
|
|
16243
16272
|
await this.adapter.files.delete(fileId);
|
|
@@ -16263,15 +16292,15 @@ var FileService = class extends BaseService {
|
|
|
16263
16292
|
const fileResults = await Promise.all(fileIds.map((id) => this.getFile(id)));
|
|
16264
16293
|
const files = fileResults.filter((f) => f !== null);
|
|
16265
16294
|
if (files.length === 0) return;
|
|
16266
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16295
|
+
if (_optionalChain([options, 'optionalAccess', _358 => _358.deleteFromStorage]) && this.adapter.storage) {
|
|
16267
16296
|
const BATCH_SIZE = 10;
|
|
16268
16297
|
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
16269
16298
|
const batch = files.slice(i, i + BATCH_SIZE);
|
|
16270
|
-
await Promise.all(batch.map((file2) => _optionalChain([this, 'access',
|
|
16299
|
+
await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _359 => _359.adapter, 'access', _360 => _360.storage, 'optionalAccess', _361 => _361.delete, 'call', _362 => _362(file2.storagePath)])));
|
|
16271
16300
|
}
|
|
16272
16301
|
}
|
|
16273
16302
|
const idsToDelete = files.map((f) => f.id);
|
|
16274
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16303
|
+
if (_optionalChain([options, 'optionalAccess', _363 => _363.hard])) {
|
|
16275
16304
|
await Promise.all(idsToDelete.map((id) => this.adapter.files.hardDelete(id)));
|
|
16276
16305
|
} else {
|
|
16277
16306
|
await Promise.all(idsToDelete.map((id) => this.adapter.files.delete(id)));
|
|
@@ -16279,12 +16308,12 @@ var FileService = class extends BaseService {
|
|
|
16279
16308
|
if (this.auditService && this.userId) {
|
|
16280
16309
|
await Promise.all(
|
|
16281
16310
|
files.map(
|
|
16282
|
-
(file2) => _optionalChain([this, 'access',
|
|
16311
|
+
(file2) => _optionalChain([this, 'access', _364 => _364.auditService, 'optionalAccess', _365 => _365.logFileAction, 'call', _366 => _366({
|
|
16283
16312
|
action: "file.deleted",
|
|
16284
16313
|
actorId: _nullishCoalesce(this.userId, () => ( "")),
|
|
16285
16314
|
fileId: file2.id,
|
|
16286
16315
|
fileName: file2.name,
|
|
16287
|
-
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
16316
|
+
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _367 => _367.deleteFromStorage]), () => ( false)) }
|
|
16288
16317
|
})])
|
|
16289
16318
|
)
|
|
16290
16319
|
);
|
|
@@ -16362,7 +16391,7 @@ var FileService = class extends BaseService {
|
|
|
16362
16391
|
if (!file2) {
|
|
16363
16392
|
return false;
|
|
16364
16393
|
}
|
|
16365
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16394
|
+
if (_optionalChain([options, 'optionalAccess', _368 => _368.isAdmin])) {
|
|
16366
16395
|
return true;
|
|
16367
16396
|
}
|
|
16368
16397
|
if (file2.visibility === "public") {
|
|
@@ -16372,7 +16401,7 @@ var FileService = class extends BaseService {
|
|
|
16372
16401
|
return true;
|
|
16373
16402
|
}
|
|
16374
16403
|
if (file2.visibility === "restricted") {
|
|
16375
|
-
return _nullishCoalesce(_optionalChain([file2, 'access',
|
|
16404
|
+
return _nullishCoalesce(_optionalChain([file2, 'access', _369 => _369.allowedUsers, 'optionalAccess', _370 => _370.includes, 'call', _371 => _371(userId)]), () => ( false));
|
|
16376
16405
|
}
|
|
16377
16406
|
return false;
|
|
16378
16407
|
}
|
|
@@ -16467,7 +16496,7 @@ function withTimeout(promise, ms, label) {
|
|
|
16467
16496
|
var GeocodingService = class {
|
|
16468
16497
|
constructor(adapter, options) {
|
|
16469
16498
|
this.adapter = adapter;
|
|
16470
|
-
this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
16499
|
+
this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _372 => _372.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
|
|
16471
16500
|
}
|
|
16472
16501
|
/**
|
|
16473
16502
|
* Search for address suggestions as the user types
|
|
@@ -16517,23 +16546,6 @@ var GlobalSearchService = class extends BaseService {
|
|
|
16517
16546
|
* @param query - Search query string
|
|
16518
16547
|
* @param options - Search options (pagination, object filters)
|
|
16519
16548
|
* @returns Matching records with object metadata and total count
|
|
16520
|
-
*
|
|
16521
|
-
* @example
|
|
16522
|
-
* ```typescript
|
|
16523
|
-
* // Basic search
|
|
16524
|
-
* const { results, total } = await service.search("nike air");
|
|
16525
|
-
*
|
|
16526
|
-
* // With pagination
|
|
16527
|
-
* const { results, total } = await service.search("nike", {
|
|
16528
|
-
* limit: 10,
|
|
16529
|
-
* offset: 20
|
|
16530
|
-
* });
|
|
16531
|
-
*
|
|
16532
|
-
* // Filter by object types
|
|
16533
|
-
* const { results, total } = await service.search("nike", {
|
|
16534
|
-
* objectNames: ["products", "orders"]
|
|
16535
|
-
* });
|
|
16536
|
-
* ```
|
|
16537
16549
|
*/
|
|
16538
16550
|
async search(query, options) {
|
|
16539
16551
|
if (!query || query.trim().length === 0) {
|
|
@@ -16541,58 +16553,36 @@ var GlobalSearchService = class extends BaseService {
|
|
|
16541
16553
|
}
|
|
16542
16554
|
return this.cachedList(
|
|
16543
16555
|
"globalSearch",
|
|
16544
|
-
"
|
|
16556
|
+
"search",
|
|
16545
16557
|
{ query: query.trim(), ...options },
|
|
16546
|
-
() => this.
|
|
16558
|
+
() => this.adapter.objectRecords.globalSearch(query.trim(), {
|
|
16559
|
+
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _373 => _373.limit]), () => ( 20)),
|
|
16560
|
+
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.offset]), () => ( 0)),
|
|
16561
|
+
objectNames: _optionalChain([options, 'optionalAccess', _375 => _375.objectNames])
|
|
16562
|
+
})
|
|
16547
16563
|
);
|
|
16548
16564
|
}
|
|
16549
16565
|
/**
|
|
16550
|
-
*
|
|
16551
|
-
|
|
16552
|
-
async executeSearch(query, options) {
|
|
16553
|
-
return await this.adapter.objectRecords.globalSearch(query, {
|
|
16554
|
-
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _371 => _371.limit]), () => ( 20)),
|
|
16555
|
-
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _372 => _372.offset]), () => ( 0)),
|
|
16556
|
-
objectNames: _optionalChain([options, 'optionalAccess', _373 => _373.objectNames]),
|
|
16557
|
-
includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.includeObjectInfo]), () => ( true))
|
|
16558
|
-
});
|
|
16559
|
-
}
|
|
16560
|
-
/**
|
|
16561
|
-
* Search and group results by object type
|
|
16566
|
+
* Search and group results by object type.
|
|
16567
|
+
* Delegates grouping to the database for accurate per-group counts.
|
|
16562
16568
|
*
|
|
16563
16569
|
* @param query - Search query string
|
|
16564
|
-
* @param options - Search options
|
|
16565
|
-
* @returns Results grouped by object name
|
|
16570
|
+
* @param options - Search options (object filters, limit per group)
|
|
16571
|
+
* @returns Results grouped by object name with per-group totals
|
|
16566
16572
|
*/
|
|
16567
16573
|
async searchGrouped(query, options) {
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
const fetchLimit = Math.min(limitPerGroup * estimatedGroupCount, 100);
|
|
16571
|
-
const { results, total } = await this.search(query, {
|
|
16572
|
-
...options,
|
|
16573
|
-
limit: fetchLimit,
|
|
16574
|
-
offset: 0
|
|
16575
|
-
});
|
|
16576
|
-
const groupMap = /* @__PURE__ */ new Map();
|
|
16577
|
-
for (const result of results) {
|
|
16578
|
-
const existing = groupMap.get(result.objectName);
|
|
16579
|
-
if (existing) {
|
|
16580
|
-
existing.results.push(result);
|
|
16581
|
-
} else {
|
|
16582
|
-
groupMap.set(result.objectName, {
|
|
16583
|
-
objectName: result.objectName,
|
|
16584
|
-
objectLabel: result.objectLabel,
|
|
16585
|
-
results: [result]
|
|
16586
|
-
});
|
|
16587
|
-
}
|
|
16574
|
+
if (!query || query.trim().length === 0) {
|
|
16575
|
+
return { groups: [], total: 0 };
|
|
16588
16576
|
}
|
|
16589
|
-
|
|
16590
|
-
|
|
16591
|
-
|
|
16592
|
-
|
|
16593
|
-
|
|
16594
|
-
|
|
16595
|
-
|
|
16577
|
+
return this.cachedList(
|
|
16578
|
+
"globalSearch",
|
|
16579
|
+
"grouped",
|
|
16580
|
+
{ query: query.trim(), ...options },
|
|
16581
|
+
() => this.adapter.objectRecords.globalSearchGrouped(query.trim(), {
|
|
16582
|
+
objectNames: _optionalChain([options, 'optionalAccess', _376 => _376.objectNames]),
|
|
16583
|
+
limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _377 => _377.limitPerGroup]), () => ( 5))
|
|
16584
|
+
})
|
|
16585
|
+
);
|
|
16596
16586
|
}
|
|
16597
16587
|
};
|
|
16598
16588
|
|
|
@@ -16607,7 +16597,7 @@ var PermissionService = class extends BaseService {
|
|
|
16607
16597
|
}
|
|
16608
16598
|
this.permissionsRepo = adapter.permissions;
|
|
16609
16599
|
this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
|
|
16610
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
16600
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _378 => _378.auditService]);
|
|
16611
16601
|
}
|
|
16612
16602
|
// ============================================================================
|
|
16613
16603
|
// PERMISSION CHECKS
|
|
@@ -16626,11 +16616,11 @@ var PermissionService = class extends BaseService {
|
|
|
16626
16616
|
return true;
|
|
16627
16617
|
}
|
|
16628
16618
|
const wildcardPerms = permissions.objectPermissions["*"];
|
|
16629
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
16619
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _379 => _379.includes, 'call', _380 => _380(action)])) {
|
|
16630
16620
|
return true;
|
|
16631
16621
|
}
|
|
16632
16622
|
const objectPerms = permissions.objectPermissions[objectName];
|
|
16633
|
-
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess',
|
|
16623
|
+
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _381 => _381.includes, 'call', _382 => _382(action)]), () => ( false));
|
|
16634
16624
|
}
|
|
16635
16625
|
/**
|
|
16636
16626
|
* Check if user can access an object, throw ForbiddenError if not.
|
|
@@ -16685,12 +16675,12 @@ var PermissionService = class extends BaseService {
|
|
|
16685
16675
|
if (permissions.isAdmin) {
|
|
16686
16676
|
return true;
|
|
16687
16677
|
}
|
|
16688
|
-
const wildcardPerms = _optionalChain([permissions, 'access',
|
|
16689
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
16678
|
+
const wildcardPerms = _optionalChain([permissions, 'access', _383 => _383.systemPermissions, 'optionalAccess', _384 => _384["*"]]);
|
|
16679
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _385 => _385.includes, 'call', _386 => _386(action)])) {
|
|
16690
16680
|
return true;
|
|
16691
16681
|
}
|
|
16692
|
-
const resourcePerms = _optionalChain([permissions, 'access',
|
|
16693
|
-
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess',
|
|
16682
|
+
const resourcePerms = _optionalChain([permissions, 'access', _387 => _387.systemPermissions, 'optionalAccess', _388 => _388[resource]]);
|
|
16683
|
+
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _389 => _389.includes, 'call', _390 => _390(action)]), () => ( false));
|
|
16694
16684
|
}
|
|
16695
16685
|
/**
|
|
16696
16686
|
* Check if user can access a system resource, throw ForbiddenError if not.
|
|
@@ -16719,8 +16709,8 @@ var PermissionService = class extends BaseService {
|
|
|
16719
16709
|
if (permissions.isAdmin) {
|
|
16720
16710
|
return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
|
|
16721
16711
|
}
|
|
16722
|
-
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access',
|
|
16723
|
-
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access',
|
|
16712
|
+
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _391 => _391.systemPermissions, 'optionalAccess', _392 => _392["*"]]), () => ( []));
|
|
16713
|
+
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _393 => _393.systemPermissions, 'optionalAccess', _394 => _394[resource]]), () => ( []));
|
|
16724
16714
|
const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
|
|
16725
16715
|
return {
|
|
16726
16716
|
canRead: allPerms.has("read"),
|
|
@@ -16863,7 +16853,7 @@ var PermissionService = class extends BaseService {
|
|
|
16863
16853
|
action: "role.updated",
|
|
16864
16854
|
actorId: this.userId,
|
|
16865
16855
|
roleId,
|
|
16866
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
16856
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _395 => _395.label]), () => ( roleId)),
|
|
16867
16857
|
metadata: { permissionsUpdated: true, permissionCount: permissions.length }
|
|
16868
16858
|
});
|
|
16869
16859
|
}
|
|
@@ -16893,7 +16883,7 @@ var PermissionService = class extends BaseService {
|
|
|
16893
16883
|
action: "role.assigned",
|
|
16894
16884
|
actorId: this.userId,
|
|
16895
16885
|
roleId,
|
|
16896
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
16886
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _396 => _396.label]), () => ( roleId)),
|
|
16897
16887
|
targetUserId: userProfileId
|
|
16898
16888
|
});
|
|
16899
16889
|
}
|
|
@@ -16911,7 +16901,7 @@ var PermissionService = class extends BaseService {
|
|
|
16911
16901
|
action: "role.revoked",
|
|
16912
16902
|
actorId: this.userId,
|
|
16913
16903
|
roleId,
|
|
16914
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
16904
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _397 => _397.label]), () => ( roleId)),
|
|
16915
16905
|
targetUserId: userProfileId
|
|
16916
16906
|
});
|
|
16917
16907
|
}
|
|
@@ -17387,7 +17377,7 @@ var ViewService = class extends BaseService {
|
|
|
17387
17377
|
dbView.objectName,
|
|
17388
17378
|
dbView.type,
|
|
17389
17379
|
objectDefinition,
|
|
17390
|
-
dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access',
|
|
17380
|
+
dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _398 => _398.config, 'optionalAccess', _399 => _399.layout]), () => ( "page")) : void 0
|
|
17391
17381
|
);
|
|
17392
17382
|
const newConfig = generated.config;
|
|
17393
17383
|
const updated = await this.adapter.views.update(viewId, { config: newConfig });
|