@stndrds/schema 1.0.0-alpha.76 → 1.0.0-alpha.78
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-JZO52C3F.js → chunk-7WT53FJ4.js} +14 -9
- package/dist/{chunk-6P3NPTYV.mjs → chunk-AGBBH7PL.mjs} +15 -10
- package/dist/{chunk-JEOP4TFZ.mjs → chunk-JYXUFVUD.mjs} +155 -41
- package/dist/{chunk-27O7E2WM.js → chunk-KGEV5PIT.js} +329 -215
- package/dist/default-roles-5K3GHJTS.js +23 -0
- package/dist/{default-roles-OAMHLOCS.mjs → default-roles-6D3HQ3DQ.mjs} +3 -3
- package/dist/index.d.mts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +23 -7
- package/dist/index.mjs +21 -5
- package/dist/{runtime-VuCTBbS6.d.ts → runtime-Df0uvz45.d.ts} +58 -24
- package/dist/{runtime-Cv41_Suf.d.mts → runtime-ntcKC7g8.d.mts} +58 -24
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -3
- package/dist/runtime.mjs +1 -2
- package/package.json +2 -2
- package/dist/default-roles-76HUWY6T.js +0 -23
|
@@ -15,9 +15,6 @@ var _chunkNEVERCM3js = require('./chunk-NEVERCM3.js');
|
|
|
15
15
|
var _chunk3WTK7ESHjs = require('./chunk-3WTK7ESH.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var _chunkJZO52C3Fjs = require('./chunk-JZO52C3F.js');
|
|
19
|
-
|
|
20
|
-
|
|
21
18
|
var _chunk3RG5ZIWIjs = require('./chunk-3RG5ZIWI.js');
|
|
22
19
|
|
|
23
20
|
// src/runtime/auth/workflow-jwt.service.ts
|
|
@@ -3210,6 +3207,17 @@ function createMockObjectsRepository(stores) {
|
|
|
3210
3207
|
);
|
|
3211
3208
|
return Promise.resolve(results);
|
|
3212
3209
|
},
|
|
3210
|
+
deleteSystemNotInNames(excludeNames) {
|
|
3211
|
+
const tenantId = getTenantId();
|
|
3212
|
+
let count = 0;
|
|
3213
|
+
for (const [id, obj] of stores.objects.entries()) {
|
|
3214
|
+
if (obj.tenantId === tenantId && obj.system && !excludeNames.includes(obj.name)) {
|
|
3215
|
+
stores.objects.delete(id);
|
|
3216
|
+
count++;
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
return Promise.resolve(count);
|
|
3220
|
+
},
|
|
3213
3221
|
upsert(data) {
|
|
3214
3222
|
const tenantId = getTenantId();
|
|
3215
3223
|
for (const obj of stores.objects.values()) {
|
|
@@ -4579,8 +4587,6 @@ function createMockPermissionsRepository(stores) {
|
|
|
4579
4587
|
getEffectivePermissions(userProfileId) {
|
|
4580
4588
|
const tenantId = getTenantId();
|
|
4581
4589
|
const userRoleIds = Array.from(stores.userRoles.values()).filter((ur) => ur.userProfileId === userProfileId && ur.tenantId === tenantId).map((ur) => ur.roleId);
|
|
4582
|
-
const userRoles = Array.from(stores.roles.values()).filter((r) => userRoleIds.includes(r.id));
|
|
4583
|
-
const hasAdmin = userRoles.some((r) => _chunkJZO52C3Fjs.isAdminRole.call(void 0, r.name));
|
|
4584
4590
|
const userPermissions = Array.from(stores.permissions.values()).filter(
|
|
4585
4591
|
(p) => userRoleIds.includes(p.roleId)
|
|
4586
4592
|
);
|
|
@@ -4607,7 +4613,7 @@ function createMockPermissionsRepository(stores) {
|
|
|
4607
4613
|
}
|
|
4608
4614
|
}
|
|
4609
4615
|
}
|
|
4610
|
-
return Promise.resolve({
|
|
4616
|
+
return Promise.resolve({ objectPermissions, systemPermissions });
|
|
4611
4617
|
},
|
|
4612
4618
|
countUsersWithRole(roleName) {
|
|
4613
4619
|
const tenantId = getTenantId();
|
|
@@ -9856,21 +9862,37 @@ var AuditService = class extends BaseService {
|
|
|
9856
9862
|
if (!this.adapter.audit) {
|
|
9857
9863
|
return;
|
|
9858
9864
|
}
|
|
9865
|
+
const resolved = await this.resolveActorEmail(entry);
|
|
9859
9866
|
if (_optionalChain([this, 'access', _183 => _183.options, 'optionalAccess', _184 => _184.async])) {
|
|
9860
|
-
this.buffer.push(
|
|
9867
|
+
this.buffer.push(resolved);
|
|
9861
9868
|
const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
|
|
9862
9869
|
if (this.buffer.length >= batchSize) {
|
|
9863
9870
|
await this.flush();
|
|
9864
9871
|
}
|
|
9865
9872
|
} else {
|
|
9866
|
-
await this.adapter.audit.create(
|
|
9873
|
+
await this.adapter.audit.create(resolved);
|
|
9874
|
+
}
|
|
9875
|
+
}
|
|
9876
|
+
/**
|
|
9877
|
+
* Resolve actorEmail from user profiles if not already set
|
|
9878
|
+
*/
|
|
9879
|
+
async resolveActorEmail(entry) {
|
|
9880
|
+
if (!entry.actorEmail && entry.actorId) {
|
|
9881
|
+
try {
|
|
9882
|
+
const profile = await this.adapter.userProfiles.findById(entry.actorId);
|
|
9883
|
+
if (_optionalChain([profile, 'optionalAccess', _185 => _185.email])) {
|
|
9884
|
+
return { ...entry, actorEmail: profile.email };
|
|
9885
|
+
}
|
|
9886
|
+
} catch (e13) {
|
|
9887
|
+
}
|
|
9867
9888
|
}
|
|
9889
|
+
return entry;
|
|
9868
9890
|
}
|
|
9869
9891
|
/**
|
|
9870
9892
|
* Start the flush timer for async mode
|
|
9871
9893
|
*/
|
|
9872
9894
|
startFlushTimer() {
|
|
9873
|
-
const intervalMs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
9895
|
+
const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _186 => _186.options, 'optionalAccess', _187 => _187.flushIntervalMs]), () => ( 1e3));
|
|
9874
9896
|
this.flushTimer = setInterval(() => {
|
|
9875
9897
|
this.flush().catch(() => {
|
|
9876
9898
|
});
|
|
@@ -9900,13 +9922,13 @@ var browserStub4 = {
|
|
|
9900
9922
|
run: (_store, callback) => callback()
|
|
9901
9923
|
};
|
|
9902
9924
|
var AsyncLocalStorageClass4 = null;
|
|
9903
|
-
if (typeof process !== "undefined" && _optionalChain([process, 'access',
|
|
9925
|
+
if (typeof process !== "undefined" && _optionalChain([process, 'access', _188 => _188.versions, 'optionalAccess', _189 => _189.node])) {
|
|
9904
9926
|
try {
|
|
9905
9927
|
if (typeof _chunk3RG5ZIWIjs.__require !== "undefined") {
|
|
9906
9928
|
const asyncHooks = _chunk3RG5ZIWIjs.__require.call(void 0, "async_hooks");
|
|
9907
9929
|
AsyncLocalStorageClass4 = asyncHooks.AsyncLocalStorage;
|
|
9908
9930
|
}
|
|
9909
|
-
} catch (
|
|
9931
|
+
} catch (e14) {
|
|
9910
9932
|
try {
|
|
9911
9933
|
const dynamicRequire = new Function(
|
|
9912
9934
|
"m",
|
|
@@ -9916,7 +9938,7 @@ if (typeof process !== "undefined" && _optionalChain([process, 'access', _187 =>
|
|
|
9916
9938
|
if (asyncHooks) {
|
|
9917
9939
|
AsyncLocalStorageClass4 = asyncHooks.AsyncLocalStorage;
|
|
9918
9940
|
}
|
|
9919
|
-
} catch (
|
|
9941
|
+
} catch (e15) {
|
|
9920
9942
|
}
|
|
9921
9943
|
}
|
|
9922
9944
|
}
|
|
@@ -9959,7 +9981,7 @@ var BilateralSyncService = class extends BaseService {
|
|
|
9959
9981
|
}
|
|
9960
9982
|
const ctx = getSyncContext().getStore();
|
|
9961
9983
|
const syncKey = `${sourceSchema.name}:${sourceRecordId}:${attributeName}`;
|
|
9962
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
9984
|
+
if (_optionalChain([ctx, 'optionalAccess', _190 => _190.syncing, 'access', _191 => _191.has, 'call', _192 => _192(syncKey)])) {
|
|
9963
9985
|
return;
|
|
9964
9986
|
}
|
|
9965
9987
|
await this.runWithSyncContext(syncKey, async () => {
|
|
@@ -10184,7 +10206,7 @@ var BilateralSyncService = class extends BaseService {
|
|
|
10184
10206
|
const storage = getSyncContext();
|
|
10185
10207
|
const existingCtx = storage.getStore();
|
|
10186
10208
|
const ctx = {
|
|
10187
|
-
syncing: new Set(_nullishCoalesce(_optionalChain([existingCtx, 'optionalAccess',
|
|
10209
|
+
syncing: new Set(_nullishCoalesce(_optionalChain([existingCtx, 'optionalAccess', _193 => _193.syncing]), () => ( [])))
|
|
10188
10210
|
};
|
|
10189
10211
|
ctx.syncing.add(syncKey);
|
|
10190
10212
|
return await storage.run(ctx, fn);
|
|
@@ -10292,7 +10314,7 @@ var UserService = class extends BaseService {
|
|
|
10292
10314
|
if (roleErrors.length > 0) {
|
|
10293
10315
|
errors.push({
|
|
10294
10316
|
attribute: attrName,
|
|
10295
|
-
message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access',
|
|
10317
|
+
message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _194 => _194.allowedRoles, 'optionalAccess', _195 => _195.join, 'call', _196 => _196(", ")])}`,
|
|
10296
10318
|
invalidIds: roleErrors
|
|
10297
10319
|
});
|
|
10298
10320
|
}
|
|
@@ -10816,7 +10838,7 @@ var RelationPropertiesService = class extends BaseService {
|
|
|
10816
10838
|
}
|
|
10817
10839
|
}
|
|
10818
10840
|
}
|
|
10819
|
-
const shouldStoreAsInverse = _optionalChain([attribute, 'access',
|
|
10841
|
+
const shouldStoreAsInverse = _optionalChain([attribute, 'access', _197 => _197.bilateral, 'optionalAccess', _198 => _198.storageOwner]) === false;
|
|
10820
10842
|
let storageFromObject = schema.name;
|
|
10821
10843
|
let storageFromAttribute = attributeName;
|
|
10822
10844
|
if (shouldStoreAsInverse && attribute.bilateral) {
|
|
@@ -10828,7 +10850,7 @@ var RelationPropertiesService = class extends BaseService {
|
|
|
10828
10850
|
if (shouldStoreAsInverse) {
|
|
10829
10851
|
const results = await Promise.all(
|
|
10830
10852
|
normalized.map(
|
|
10831
|
-
(item) => _optionalChain([adapter, 'access',
|
|
10853
|
+
(item) => _optionalChain([adapter, 'access', _199 => _199.relationAttributes, 'optionalAccess', _200 => _200.findBySource, 'call', _201 => _201(
|
|
10832
10854
|
storageFromObject,
|
|
10833
10855
|
item.id,
|
|
10834
10856
|
storageFromAttribute
|
|
@@ -10967,7 +10989,7 @@ var RecordQueryService = class extends BaseService {
|
|
|
10967
10989
|
super(adapter);
|
|
10968
10990
|
this.schemaService = schemaService;
|
|
10969
10991
|
this.options = options;
|
|
10970
|
-
this.policyRegistry = _optionalChain([options, 'optionalAccess',
|
|
10992
|
+
this.policyRegistry = _optionalChain([options, 'optionalAccess', _202 => _202.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _203 => _203.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
10971
10993
|
this.relationPropertiesService = new RelationPropertiesService(adapter);
|
|
10972
10994
|
}
|
|
10973
10995
|
// ============================================================================
|
|
@@ -11018,12 +11040,12 @@ var RecordQueryService = class extends BaseService {
|
|
|
11018
11040
|
* Internal list query execution
|
|
11019
11041
|
*/
|
|
11020
11042
|
async executeListQuery(schema, objectId, options) {
|
|
11021
|
-
if (_optionalChain([this, 'access',
|
|
11043
|
+
if (_optionalChain([this, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.permissionService]) && this.userId) {
|
|
11022
11044
|
await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
|
|
11023
11045
|
}
|
|
11024
|
-
const policy = _optionalChain([options, 'optionalAccess',
|
|
11046
|
+
const policy = _optionalChain([options, 'optionalAccess', _206 => _206.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
11025
11047
|
let effectiveOptions = options;
|
|
11026
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
11048
|
+
if (_optionalChain([policy, 'optionalAccess', _207 => _207.applyListFilter]) && this.userId) {
|
|
11027
11049
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
11028
11050
|
effectiveOptions = policy.applyListFilter(ctx, options);
|
|
11029
11051
|
}
|
|
@@ -11033,10 +11055,10 @@ var RecordQueryService = class extends BaseService {
|
|
|
11033
11055
|
);
|
|
11034
11056
|
let filteredRecords = result.records;
|
|
11035
11057
|
let effectiveTotal = result.total;
|
|
11036
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
11058
|
+
if (_optionalChain([policy, 'optionalAccess', _208 => _208.canAccessRecord]) && this.userId) {
|
|
11037
11059
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
11038
|
-
const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess',
|
|
11039
|
-
const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess',
|
|
11060
|
+
const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _209 => _209.limit]), () => ( 20));
|
|
11061
|
+
const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _210 => _210.offset]), () => ( 0));
|
|
11040
11062
|
const overfetchMultiplier = 5;
|
|
11041
11063
|
const batchSize = requestedLimit * overfetchMultiplier;
|
|
11042
11064
|
const maxScanRecords = 1e4;
|
|
@@ -11058,7 +11080,7 @@ var RecordQueryService = class extends BaseService {
|
|
|
11058
11080
|
exhausted = true;
|
|
11059
11081
|
break;
|
|
11060
11082
|
}
|
|
11061
|
-
const filtered = batch.records.filter((record) => _optionalChain([policy, 'access',
|
|
11083
|
+
const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _211 => _211.canAccessRecord, 'optionalCall', _212 => _212(ctx, record)]));
|
|
11062
11084
|
collected.push(...filtered);
|
|
11063
11085
|
dbOffset += batch.records.length;
|
|
11064
11086
|
totalScanned += batch.records.length;
|
|
@@ -11074,7 +11096,7 @@ var RecordQueryService = class extends BaseService {
|
|
|
11074
11096
|
filteredRecords,
|
|
11075
11097
|
schema
|
|
11076
11098
|
);
|
|
11077
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11099
|
+
if (!_optionalChain([options, 'optionalAccess', _213 => _213.skipFormulas])) {
|
|
11078
11100
|
return {
|
|
11079
11101
|
records: enrichRecordsWithFormulas(filteredRecords, schema),
|
|
11080
11102
|
total: effectiveTotal
|
|
@@ -11134,21 +11156,21 @@ var RecordQueryService = class extends BaseService {
|
|
|
11134
11156
|
* Internal search query execution
|
|
11135
11157
|
*/
|
|
11136
11158
|
async executeSearchQuery(schema, objectId, query, options) {
|
|
11137
|
-
if (_optionalChain([this, 'access',
|
|
11159
|
+
if (_optionalChain([this, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.permissionService]) && this.userId) {
|
|
11138
11160
|
await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
|
|
11139
11161
|
}
|
|
11140
11162
|
let result;
|
|
11141
11163
|
if (this.adapter.search) {
|
|
11142
11164
|
try {
|
|
11143
11165
|
result = await this.adapter.search.searchRecords(objectId, query, {
|
|
11144
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
11145
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
11146
|
-
sorts: _optionalChain([options, 'optionalAccess',
|
|
11147
|
-
filters: _optionalChain([options, 'optionalAccess',
|
|
11166
|
+
limit: _optionalChain([options, 'optionalAccess', _216 => _216.limit]),
|
|
11167
|
+
offset: _optionalChain([options, 'optionalAccess', _217 => _217.offset]),
|
|
11168
|
+
sorts: _optionalChain([options, 'optionalAccess', _218 => _218.sorts]),
|
|
11169
|
+
filters: _optionalChain([options, 'optionalAccess', _219 => _219.filters]),
|
|
11148
11170
|
attributes: schema.attributes
|
|
11149
11171
|
});
|
|
11150
11172
|
result = await this.healSearchResults(result);
|
|
11151
|
-
} catch (
|
|
11173
|
+
} catch (e16) {
|
|
11152
11174
|
result = await runWithSchemaContext(
|
|
11153
11175
|
[schema],
|
|
11154
11176
|
() => this.adapter.objectRecords.search(objectId, query, options)
|
|
@@ -11164,7 +11186,7 @@ var RecordQueryService = class extends BaseService {
|
|
|
11164
11186
|
result.records,
|
|
11165
11187
|
schema
|
|
11166
11188
|
);
|
|
11167
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
11189
|
+
if (!_optionalChain([options, 'optionalAccess', _220 => _220.skipFormulas])) {
|
|
11168
11190
|
return {
|
|
11169
11191
|
records: enrichRecordsWithFormulas(enrichedRecords, schema),
|
|
11170
11192
|
total: result.total
|
|
@@ -11373,7 +11395,7 @@ var RelationService = class extends BaseService {
|
|
|
11373
11395
|
}
|
|
11374
11396
|
const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
|
|
11375
11397
|
const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
|
|
11376
|
-
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess',
|
|
11398
|
+
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _221 => _221.size]) === 0) {
|
|
11377
11399
|
errors.push({
|
|
11378
11400
|
attribute: attr.name,
|
|
11379
11401
|
message: `No valid target objects found for ${attr.label}`
|
|
@@ -11426,10 +11448,10 @@ var RelationService = class extends BaseService {
|
|
|
11426
11448
|
for (const target of targets) {
|
|
11427
11449
|
try {
|
|
11428
11450
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
11429
|
-
if (_optionalChain([objectSchema, 'optionalAccess',
|
|
11451
|
+
if (_optionalChain([objectSchema, 'optionalAccess', _222 => _222.id])) {
|
|
11430
11452
|
objectIds.add(objectSchema.id);
|
|
11431
11453
|
}
|
|
11432
|
-
} catch (
|
|
11454
|
+
} catch (e17) {
|
|
11433
11455
|
}
|
|
11434
11456
|
}
|
|
11435
11457
|
return objectIds;
|
|
@@ -11495,7 +11517,7 @@ var RelationService = class extends BaseService {
|
|
|
11495
11517
|
const targetResults = await Promise.all(
|
|
11496
11518
|
filteredTargets.map(async (target) => {
|
|
11497
11519
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
11498
|
-
if (!_optionalChain([objectSchema, 'optionalAccess',
|
|
11520
|
+
if (!_optionalChain([objectSchema, 'optionalAccess', _223 => _223.id])) return { options: [], total: 0 };
|
|
11499
11521
|
const objectId = objectSchema.id;
|
|
11500
11522
|
const result = query ? await queryService.searchRecords(objectId, query, queryOptions) : await queryService.listRecords(objectId, queryOptions);
|
|
11501
11523
|
const options = await Promise.all(
|
|
@@ -11652,8 +11674,8 @@ var RelationService = class extends BaseService {
|
|
|
11652
11674
|
continue;
|
|
11653
11675
|
}
|
|
11654
11676
|
const attribute = attributeMap.get(attributeId);
|
|
11655
|
-
const targetConfig = _optionalChain([attribute, 'optionalAccess',
|
|
11656
|
-
const customTemplate = _optionalChain([targetConfig, 'optionalAccess',
|
|
11677
|
+
const targetConfig = _optionalChain([attribute, 'optionalAccess', _224 => _224.targets, 'optionalAccess', _225 => _225.find, 'call', _226 => _226((t) => t.object === objectSchema.name)]);
|
|
11678
|
+
const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _227 => _227.displayTemplate]);
|
|
11657
11679
|
const label = await this.resolveLabel(record, objectSchema, customTemplate);
|
|
11658
11680
|
resolved.push({
|
|
11659
11681
|
_compositeId: compositeId,
|
|
@@ -11816,14 +11838,14 @@ var RollupService = class extends BaseService {
|
|
|
11816
11838
|
const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
|
|
11817
11839
|
let sourceObjectId;
|
|
11818
11840
|
let reverseRelationAttrName;
|
|
11819
|
-
if (_optionalChain([sourceSchema, 'optionalAccess',
|
|
11841
|
+
if (_optionalChain([sourceSchema, 'optionalAccess', _228 => _228.id])) {
|
|
11820
11842
|
sourceObjectId = sourceSchema.id;
|
|
11821
11843
|
const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
|
|
11822
11844
|
if (attr.type !== "relation") return false;
|
|
11823
11845
|
const relationConfig = attr;
|
|
11824
|
-
return _optionalChain([relationConfig, 'optionalAccess',
|
|
11846
|
+
return _optionalChain([relationConfig, 'optionalAccess', _229 => _229.targets, 'optionalAccess', _230 => _230.some, 'call', _231 => _231((t) => t.object === schema.name)]);
|
|
11825
11847
|
});
|
|
11826
|
-
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess',
|
|
11848
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _232 => _232.name]);
|
|
11827
11849
|
} else {
|
|
11828
11850
|
const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
|
|
11829
11851
|
if (!sourceObject) {
|
|
@@ -11834,9 +11856,9 @@ var RollupService = class extends BaseService {
|
|
|
11834
11856
|
const reverseRelationAttr = sourceAttributes.find((attr) => {
|
|
11835
11857
|
if (attr.type !== "relation") return false;
|
|
11836
11858
|
const relationConfig = attr.config;
|
|
11837
|
-
return _optionalChain([relationConfig, 'optionalAccess',
|
|
11859
|
+
return _optionalChain([relationConfig, 'optionalAccess', _233 => _233.targets, 'optionalAccess', _234 => _234.some, 'call', _235 => _235((t) => t.object === schema.name)]);
|
|
11838
11860
|
});
|
|
11839
|
-
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess',
|
|
11861
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _236 => _236.name]);
|
|
11840
11862
|
}
|
|
11841
11863
|
if (!reverseRelationAttrName) {
|
|
11842
11864
|
return { value: null, recordCount: 0 };
|
|
@@ -12092,13 +12114,13 @@ var RollupService = class extends BaseService {
|
|
|
12092
12114
|
if (!obj) continue;
|
|
12093
12115
|
for (const rollupDbAttr of rollupAttrs) {
|
|
12094
12116
|
const rollupConfig = rollupDbAttr.config;
|
|
12095
|
-
if (!_optionalChain([rollupConfig, 'optionalAccess',
|
|
12117
|
+
if (!_optionalChain([rollupConfig, 'optionalAccess', _237 => _237.relationAttribute])) continue;
|
|
12096
12118
|
const relationAttr = attributes.find(
|
|
12097
12119
|
(a) => a.type === "relation" && a.name === rollupConfig.relationAttribute
|
|
12098
12120
|
);
|
|
12099
12121
|
if (!relationAttr) continue;
|
|
12100
12122
|
const relationConfig = relationAttr.config;
|
|
12101
|
-
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess',
|
|
12123
|
+
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _238 => _238.targets, 'optionalAccess', _239 => _239.some, 'call', _240 => _240(
|
|
12102
12124
|
(t) => t.object === changedSchema.name
|
|
12103
12125
|
)]);
|
|
12104
12126
|
if (!targetsChangedObject) continue;
|
|
@@ -12123,11 +12145,11 @@ var RecordService = class extends BaseService {
|
|
|
12123
12145
|
constructor(adapter, options) {
|
|
12124
12146
|
super(adapter);
|
|
12125
12147
|
this.schemaService = new ObjectSchemaService(adapter, registry, {
|
|
12126
|
-
auditService: _optionalChain([options, 'optionalAccess',
|
|
12148
|
+
auditService: _optionalChain([options, 'optionalAccess', _241 => _241.auditService])
|
|
12127
12149
|
});
|
|
12128
|
-
this.permissionService = _optionalChain([options, 'optionalAccess',
|
|
12129
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12130
|
-
this.policyRegistry = _optionalChain([options, 'optionalAccess',
|
|
12150
|
+
this.permissionService = _optionalChain([options, 'optionalAccess', _242 => _242.permissionService]);
|
|
12151
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _243 => _243.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
12152
|
+
this.policyRegistry = _optionalChain([options, 'optionalAccess', _244 => _244.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
12131
12153
|
this.recordResolver = new RecordResolverService(adapter);
|
|
12132
12154
|
this.queryService = new RecordQueryService(adapter, this.schemaService, {
|
|
12133
12155
|
permissionService: this.permissionService,
|
|
@@ -12142,7 +12164,7 @@ var RecordService = class extends BaseService {
|
|
|
12142
12164
|
recordResolver: this.recordResolver
|
|
12143
12165
|
});
|
|
12144
12166
|
this.userService = new UserService(adapter);
|
|
12145
|
-
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12167
|
+
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.hookRegistry]), () => ( new NoopHookRegistry()));
|
|
12146
12168
|
this.bilateralSyncService = new BilateralSyncService(
|
|
12147
12169
|
adapter,
|
|
12148
12170
|
this.schemaService,
|
|
@@ -12182,25 +12204,25 @@ var RecordService = class extends BaseService {
|
|
|
12182
12204
|
schema,
|
|
12183
12205
|
this.tenantId,
|
|
12184
12206
|
dataWithDefaults,
|
|
12185
|
-
_optionalChain([options, 'optionalAccess',
|
|
12207
|
+
_optionalChain([options, 'optionalAccess', _247 => _247.hookMetadata])
|
|
12186
12208
|
);
|
|
12187
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12209
|
+
if (!_optionalChain([options, 'optionalAccess', _248 => _248.skipHooks])) {
|
|
12188
12210
|
await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
|
|
12189
12211
|
}
|
|
12190
12212
|
const normalizedData = this.relationPropertiesService.normalizeRelationValuesForStorage(
|
|
12191
12213
|
schema,
|
|
12192
12214
|
dataWithDefaults
|
|
12193
12215
|
);
|
|
12194
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12195
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12216
|
+
if (_optionalChain([options, 'optionalAccess', _249 => _249.validate]) !== false) {
|
|
12217
|
+
if (_optionalChain([options, 'optionalAccess', _250 => _250.allowDraft])) {
|
|
12196
12218
|
_chunk3WTK7ESHjs.validateDraftOrThrow.call(void 0, schema, normalizedData);
|
|
12197
12219
|
} else {
|
|
12198
12220
|
_chunk3WTK7ESHjs.validateObjectOrThrow.call(void 0, schema, normalizedData);
|
|
12199
12221
|
}
|
|
12200
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12222
|
+
if (!_optionalChain([options, 'optionalAccess', _251 => _251.skipRelationValidation])) {
|
|
12201
12223
|
await this.relationService.validateRelationsOrThrow(schema, normalizedData);
|
|
12202
12224
|
}
|
|
12203
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12225
|
+
if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipUserValidation])) {
|
|
12204
12226
|
await this.userService.validateUsersOrThrow(schema, normalizedData);
|
|
12205
12227
|
}
|
|
12206
12228
|
}
|
|
@@ -12211,12 +12233,12 @@ var RecordService = class extends BaseService {
|
|
|
12211
12233
|
data: normalizedData,
|
|
12212
12234
|
label,
|
|
12213
12235
|
completionStatus,
|
|
12214
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
12236
|
+
metadata: _optionalChain([options, 'optionalAccess', _253 => _253.metadata]),
|
|
12215
12237
|
createdBy: this.userId
|
|
12216
12238
|
});
|
|
12217
12239
|
for (const [attrName, value] of Object.entries(dataWithDefaults)) {
|
|
12218
12240
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
12219
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
12241
|
+
if (_optionalChain([attr, 'optionalAccess', _254 => _254.type]) === "relation") {
|
|
12220
12242
|
const hasProperties2 = attr.properties !== void 0;
|
|
12221
12243
|
const isBilateral = isBilateralRelation(attr);
|
|
12222
12244
|
if (hasProperties2 || isBilateral) {
|
|
@@ -12232,7 +12254,7 @@ var RecordService = class extends BaseService {
|
|
|
12232
12254
|
}
|
|
12233
12255
|
for (const [attrName, value] of Object.entries(normalizedData)) {
|
|
12234
12256
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
12235
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
12257
|
+
if (_optionalChain([attr, 'optionalAccess', _255 => _255.type]) === "relation" && isBilateralRelation(attr)) {
|
|
12236
12258
|
await this.bilateralSyncService.syncBilateralRelation(
|
|
12237
12259
|
schema,
|
|
12238
12260
|
record.id,
|
|
@@ -12243,7 +12265,7 @@ var RecordService = class extends BaseService {
|
|
|
12243
12265
|
);
|
|
12244
12266
|
}
|
|
12245
12267
|
}
|
|
12246
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12268
|
+
if (!_optionalChain([options, 'optionalAccess', _256 => _256.skipHooks])) {
|
|
12247
12269
|
const afterCtx = {
|
|
12248
12270
|
...hookCtx,
|
|
12249
12271
|
recordId: record.id,
|
|
@@ -12253,11 +12275,11 @@ var RecordService = class extends BaseService {
|
|
|
12253
12275
|
}
|
|
12254
12276
|
await recalculateParentRollups(record, schema, this.rollupContext);
|
|
12255
12277
|
await this.invalidateRecordCaches(record.id, objectId);
|
|
12256
|
-
_optionalChain([this, 'access',
|
|
12278
|
+
_optionalChain([this, 'access', _257 => _257.adapter, 'access', _258 => _258.search, 'optionalAccess', _259 => _259.indexRecord, 'call', _260 => _260(record, {
|
|
12257
12279
|
objectName: schema.name,
|
|
12258
12280
|
objectLabel: schema.label,
|
|
12259
12281
|
attributes: schema.attributes
|
|
12260
|
-
}), 'access',
|
|
12282
|
+
}), 'access', _261 => _261.catch, 'call', _262 => _262((err) => console.error("[search] Failed to index created record", record.id, err))]);
|
|
12261
12283
|
if (this.auditService && this.userId) {
|
|
12262
12284
|
this.auditService.logRecordAction({
|
|
12263
12285
|
action: "record.created",
|
|
@@ -12266,7 +12288,7 @@ var RecordService = class extends BaseService {
|
|
|
12266
12288
|
objectId: schema.id,
|
|
12267
12289
|
recordId: record.id,
|
|
12268
12290
|
recordLabel: record.label,
|
|
12269
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
12291
|
+
metadata: _optionalChain([options, 'optionalAccess', _263 => _263.hookMetadata])
|
|
12270
12292
|
}).catch(() => {
|
|
12271
12293
|
});
|
|
12272
12294
|
}
|
|
@@ -12289,7 +12311,7 @@ var RecordService = class extends BaseService {
|
|
|
12289
12311
|
return null;
|
|
12290
12312
|
}
|
|
12291
12313
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
12292
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12314
|
+
if (!_optionalChain([options, 'optionalAccess', _264 => _264.skipPolicyCheck])) {
|
|
12293
12315
|
const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
12294
12316
|
if (policy) {
|
|
12295
12317
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
@@ -12299,11 +12321,11 @@ var RecordService = class extends BaseService {
|
|
|
12299
12321
|
}
|
|
12300
12322
|
}
|
|
12301
12323
|
let enrichedRecord = record;
|
|
12302
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12324
|
+
if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipFormulas])) {
|
|
12303
12325
|
enrichedRecord = enrichWithFormulas(record, schema);
|
|
12304
12326
|
}
|
|
12305
12327
|
enrichedRecord = await this.enrichRelationProperties(enrichedRecord, schema);
|
|
12306
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12328
|
+
if (_optionalChain([options, 'optionalAccess', _266 => _266.includeSchema])) {
|
|
12307
12329
|
const recordWithSchema = enrichedRecord;
|
|
12308
12330
|
recordWithSchema.schema = schema;
|
|
12309
12331
|
return recordWithSchema;
|
|
@@ -12353,7 +12375,7 @@ var RecordService = class extends BaseService {
|
|
|
12353
12375
|
if (oldVal !== null && newVal !== null && typeof oldVal === "object" && typeof newVal === "object") {
|
|
12354
12376
|
try {
|
|
12355
12377
|
return JSON.stringify(oldVal) !== JSON.stringify(newVal);
|
|
12356
|
-
} catch (
|
|
12378
|
+
} catch (e18) {
|
|
12357
12379
|
return true;
|
|
12358
12380
|
}
|
|
12359
12381
|
}
|
|
@@ -12365,9 +12387,9 @@ var RecordService = class extends BaseService {
|
|
|
12365
12387
|
existing,
|
|
12366
12388
|
mergedData,
|
|
12367
12389
|
changedAttributes,
|
|
12368
|
-
_optionalChain([options, 'optionalAccess',
|
|
12390
|
+
_optionalChain([options, 'optionalAccess', _267 => _267.hookMetadata])
|
|
12369
12391
|
);
|
|
12370
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12392
|
+
if (!_optionalChain([options, 'optionalAccess', _268 => _268.skipHooks])) {
|
|
12371
12393
|
await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
|
|
12372
12394
|
}
|
|
12373
12395
|
const hookModifiedValues = {};
|
|
@@ -12382,16 +12404,16 @@ var RecordService = class extends BaseService {
|
|
|
12382
12404
|
dataToUpdate
|
|
12383
12405
|
);
|
|
12384
12406
|
const normalizedMergedData = { ...existing.values, ...normalizedUpdate };
|
|
12385
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12386
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12407
|
+
if (_optionalChain([options, 'optionalAccess', _269 => _269.validate]) !== false) {
|
|
12408
|
+
if (_optionalChain([options, 'optionalAccess', _270 => _270.partial])) {
|
|
12387
12409
|
_chunk3WTK7ESHjs.validateDraftOrThrow.call(void 0, schema, normalizedMergedData);
|
|
12388
12410
|
} else {
|
|
12389
12411
|
_chunk3WTK7ESHjs.validateObjectOrThrow.call(void 0, schema, normalizedMergedData);
|
|
12390
12412
|
}
|
|
12391
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12413
|
+
if (!_optionalChain([options, 'optionalAccess', _271 => _271.skipRelationValidation])) {
|
|
12392
12414
|
await this.relationService.validateRelationsOrThrow(schema, normalizedUpdate);
|
|
12393
12415
|
}
|
|
12394
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12416
|
+
if (!_optionalChain([options, 'optionalAccess', _272 => _272.skipUserValidation])) {
|
|
12395
12417
|
await this.userService.validateUsersOrThrow(schema, normalizedUpdate);
|
|
12396
12418
|
}
|
|
12397
12419
|
}
|
|
@@ -12404,7 +12426,7 @@ var RecordService = class extends BaseService {
|
|
|
12404
12426
|
__lastUpdatedBy: this.userId,
|
|
12405
12427
|
__expectedUpdatedAt: existing.updatedAt instanceof Date ? existing.updatedAt.toISOString() : existing.updatedAt
|
|
12406
12428
|
};
|
|
12407
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12429
|
+
if (_optionalChain([options, 'optionalAccess', _273 => _273.metadata]) !== void 0) {
|
|
12408
12430
|
const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
|
|
12409
12431
|
const mergedMetadata = { ...existingMetadata, ...options.metadata };
|
|
12410
12432
|
const cleanedMetadata = Object.fromEntries(
|
|
@@ -12415,20 +12437,20 @@ var RecordService = class extends BaseService {
|
|
|
12415
12437
|
const bilateralOldValues = {};
|
|
12416
12438
|
for (const attrName of Object.keys(normalizedUpdate)) {
|
|
12417
12439
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
12418
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
12440
|
+
if (_optionalChain([attr, 'optionalAccess', _274 => _274.type]) === "relation" && isBilateralRelation(attr)) {
|
|
12419
12441
|
bilateralOldValues[attrName] = existing.values[attrName];
|
|
12420
12442
|
}
|
|
12421
12443
|
}
|
|
12422
12444
|
const updated = await this.adapter.objectRecords.update(recordId, updatePayload);
|
|
12423
12445
|
await this.invalidateRecordCaches(recordId, existing.objectId);
|
|
12424
|
-
_optionalChain([this, 'access',
|
|
12446
|
+
_optionalChain([this, 'access', _275 => _275.adapter, 'access', _276 => _276.search, 'optionalAccess', _277 => _277.indexRecord, 'call', _278 => _278(updated, {
|
|
12425
12447
|
objectName: schema.name,
|
|
12426
12448
|
objectLabel: schema.label,
|
|
12427
12449
|
attributes: schema.attributes
|
|
12428
|
-
}), 'access',
|
|
12450
|
+
}), 'access', _279 => _279.catch, 'call', _280 => _280((err) => console.error("[search] Failed to index updated record", updated.id, err))]);
|
|
12429
12451
|
for (const [attrName, value] of Object.entries(dataToUpdate)) {
|
|
12430
12452
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
12431
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
12453
|
+
if (_optionalChain([attr, 'optionalAccess', _281 => _281.type]) === "relation") {
|
|
12432
12454
|
const hasProperties2 = attr.properties !== void 0;
|
|
12433
12455
|
const isBilateral = isBilateralRelation(attr);
|
|
12434
12456
|
if (hasProperties2 || isBilateral) {
|
|
@@ -12444,7 +12466,7 @@ var RecordService = class extends BaseService {
|
|
|
12444
12466
|
}
|
|
12445
12467
|
for (const [attrName, value] of Object.entries(normalizedUpdate)) {
|
|
12446
12468
|
const attr = schema.attributes.find((a) => a.name === attrName);
|
|
12447
|
-
if (_optionalChain([attr, 'optionalAccess',
|
|
12469
|
+
if (_optionalChain([attr, 'optionalAccess', _282 => _282.type]) === "relation" && isBilateralRelation(attr)) {
|
|
12448
12470
|
const oldValue = bilateralOldValues[attrName];
|
|
12449
12471
|
await this.bilateralSyncService.syncBilateralRelation(
|
|
12450
12472
|
schema,
|
|
@@ -12455,7 +12477,7 @@ var RecordService = class extends BaseService {
|
|
|
12455
12477
|
);
|
|
12456
12478
|
}
|
|
12457
12479
|
}
|
|
12458
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12480
|
+
if (!_optionalChain([options, 'optionalAccess', _283 => _283.skipHooks])) {
|
|
12459
12481
|
const afterCtx = {
|
|
12460
12482
|
...hookCtx,
|
|
12461
12483
|
record: updated
|
|
@@ -12470,7 +12492,7 @@ var RecordService = class extends BaseService {
|
|
|
12470
12492
|
if (this.auditService && this.userId && allChangedAttributes.length > 0) {
|
|
12471
12493
|
const changes = allChangedAttributes.map((attr) => ({
|
|
12472
12494
|
field: attr,
|
|
12473
|
-
oldValue: _optionalChain([hookCtx, 'access',
|
|
12495
|
+
oldValue: _optionalChain([hookCtx, 'access', _284 => _284.oldValues, 'optionalAccess', _285 => _285[attr]]),
|
|
12474
12496
|
newValue: hookCtx.newValues[attr]
|
|
12475
12497
|
}));
|
|
12476
12498
|
this.auditService.logRecordAction({
|
|
@@ -12481,7 +12503,7 @@ var RecordService = class extends BaseService {
|
|
|
12481
12503
|
recordId: updated.id,
|
|
12482
12504
|
recordLabel: updated.label,
|
|
12483
12505
|
changes,
|
|
12484
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
12506
|
+
metadata: _optionalChain([options, 'optionalAccess', _286 => _286.hookMetadata])
|
|
12485
12507
|
}).catch(() => {
|
|
12486
12508
|
});
|
|
12487
12509
|
}
|
|
@@ -12513,17 +12535,17 @@ var RecordService = class extends BaseService {
|
|
|
12513
12535
|
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
12514
12536
|
checkRecordDeleteOrThrow(policy, record, ctx);
|
|
12515
12537
|
}
|
|
12516
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12538
|
+
if (_optionalChain([options, 'optionalAccess', _287 => _287.checkSystem]) && schema.system) {
|
|
12517
12539
|
throw new ProtectedResourceError("object", schema.name, "delete");
|
|
12518
12540
|
}
|
|
12519
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12541
|
+
if (!_optionalChain([options, 'optionalAccess', _288 => _288.skipReferenceCheck])) {
|
|
12520
12542
|
const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
|
|
12521
12543
|
if (references.length > 0) {
|
|
12522
12544
|
throw new RecordReferencedError(recordId, references);
|
|
12523
12545
|
}
|
|
12524
12546
|
}
|
|
12525
|
-
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess',
|
|
12526
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12547
|
+
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _289 => _289.hookMetadata]));
|
|
12548
|
+
if (!_optionalChain([options, 'optionalAccess', _290 => _290.skipHooks])) {
|
|
12527
12549
|
await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
|
|
12528
12550
|
}
|
|
12529
12551
|
for (const attr of schema.attributes) {
|
|
@@ -12541,8 +12563,8 @@ var RecordService = class extends BaseService {
|
|
|
12541
12563
|
}
|
|
12542
12564
|
await this.adapter.objectRecords.delete(recordId);
|
|
12543
12565
|
await this.invalidateRecordCaches(recordId, record.objectId);
|
|
12544
|
-
_optionalChain([this, 'access',
|
|
12545
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12566
|
+
_optionalChain([this, 'access', _291 => _291.adapter, 'access', _292 => _292.search, 'optionalAccess', _293 => _293.removeRecord, 'call', _294 => _294(recordId), 'access', _295 => _295.catch, 'call', _296 => _296((err) => console.error("[search] Failed to remove deleted record", recordId, err))]);
|
|
12567
|
+
if (!_optionalChain([options, 'optionalAccess', _297 => _297.skipHooks])) {
|
|
12546
12568
|
await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
|
|
12547
12569
|
}
|
|
12548
12570
|
await recalculateParentRollups(record, schema, this.rollupContext);
|
|
@@ -12554,7 +12576,7 @@ var RecordService = class extends BaseService {
|
|
|
12554
12576
|
objectId: schema.id,
|
|
12555
12577
|
recordId: record.id,
|
|
12556
12578
|
recordLabel: record.label,
|
|
12557
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
12579
|
+
metadata: _optionalChain([options, 'optionalAccess', _298 => _298.hookMetadata])
|
|
12558
12580
|
}).catch(() => {
|
|
12559
12581
|
});
|
|
12560
12582
|
}
|
|
@@ -12615,18 +12637,18 @@ var RecordService = class extends BaseService {
|
|
|
12615
12637
|
this.tenantId
|
|
12616
12638
|
);
|
|
12617
12639
|
await checkPermission(this.permissionService, this.userId, schema.name, "update");
|
|
12618
|
-
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess',
|
|
12619
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12640
|
+
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _299 => _299.hookMetadata]));
|
|
12641
|
+
if (!_optionalChain([options, 'optionalAccess', _300 => _300.skipHooks])) {
|
|
12620
12642
|
await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
|
|
12621
12643
|
}
|
|
12622
12644
|
const restored = await this.adapter.objectRecords.restore(recordId);
|
|
12623
12645
|
await this.invalidateRecordCaches(recordId, record.objectId);
|
|
12624
|
-
_optionalChain([this, 'access',
|
|
12646
|
+
_optionalChain([this, 'access', _301 => _301.adapter, 'access', _302 => _302.search, 'optionalAccess', _303 => _303.indexRecord, 'call', _304 => _304(restored, {
|
|
12625
12647
|
objectName: schema.name,
|
|
12626
12648
|
objectLabel: schema.label,
|
|
12627
12649
|
attributes: schema.attributes
|
|
12628
|
-
}), 'access',
|
|
12629
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
12650
|
+
}), 'access', _305 => _305.catch, 'call', _306 => _306((err) => console.error("[search] Failed to index restored record", restored.id, err))]);
|
|
12651
|
+
if (!_optionalChain([options, 'optionalAccess', _307 => _307.skipHooks])) {
|
|
12630
12652
|
const afterCtx = {
|
|
12631
12653
|
...hookCtx,
|
|
12632
12654
|
record: restored
|
|
@@ -12641,7 +12663,7 @@ var RecordService = class extends BaseService {
|
|
|
12641
12663
|
objectId: schema.id,
|
|
12642
12664
|
recordId: restored.id,
|
|
12643
12665
|
recordLabel: restored.label,
|
|
12644
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
12666
|
+
metadata: _optionalChain([options, 'optionalAccess', _308 => _308.hookMetadata])
|
|
12645
12667
|
}).catch(() => {
|
|
12646
12668
|
});
|
|
12647
12669
|
}
|
|
@@ -13072,7 +13094,7 @@ var DocumentRendererService = class {
|
|
|
13072
13094
|
throw new StorageDownloadNotSupportedError();
|
|
13073
13095
|
}
|
|
13074
13096
|
let storagePath = fileId;
|
|
13075
|
-
if (_optionalChain([this, 'access',
|
|
13097
|
+
if (_optionalChain([this, 'access', _309 => _309.options, 'optionalAccess', _310 => _310.filesRepository])) {
|
|
13076
13098
|
const file2 = await this.options.filesRepository.findById(fileId);
|
|
13077
13099
|
if (!file2) {
|
|
13078
13100
|
throw new Error(`Template file not found: ${fileId}`);
|
|
@@ -13090,8 +13112,8 @@ var DocumentRendererService = class {
|
|
|
13090
13112
|
for (const field of fields) {
|
|
13091
13113
|
const rawValue = getContextValue(context, field.contextPath);
|
|
13092
13114
|
const attrInfo = await this.getAttributeInfo(field.contextPath, workflow2);
|
|
13093
|
-
if (_optionalChain([attrInfo, 'optionalAccess',
|
|
13094
|
-
if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access',
|
|
13115
|
+
if (_optionalChain([attrInfo, 'optionalAccess', _311 => _311.attribute])) {
|
|
13116
|
+
if (attrInfo.attribute.type === "relation" && rawValue && _optionalChain([this, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.relationService])) {
|
|
13095
13117
|
const ids = Array.isArray(rawValue) ? rawValue : [rawValue];
|
|
13096
13118
|
const stringIds = ids.filter((id) => typeof id === "string");
|
|
13097
13119
|
if (stringIds.length > 0) {
|
|
@@ -13112,7 +13134,7 @@ var DocumentRendererService = class {
|
|
|
13112
13134
|
resolved.set(field.id, this.formatValueSimple(rawValue, field.fallback));
|
|
13113
13135
|
}
|
|
13114
13136
|
}
|
|
13115
|
-
if (relationBatch.length > 0 && _optionalChain([this, 'access',
|
|
13137
|
+
if (relationBatch.length > 0 && _optionalChain([this, 'access', _314 => _314.options, 'optionalAccess', _315 => _315.relationService])) {
|
|
13116
13138
|
try {
|
|
13117
13139
|
const batchResult = await this.options.relationService.resolveIdsBatch(
|
|
13118
13140
|
relationBatch.map((r) => ({ attributeId: r.attributeId, ids: r.ids }))
|
|
@@ -13121,12 +13143,12 @@ var DocumentRendererService = class {
|
|
|
13121
13143
|
const options = _nullishCoalesce(batchResult[attributeId], () => ( []));
|
|
13122
13144
|
const labels = options.map((o) => o.label);
|
|
13123
13145
|
const field = fields.find((f) => f.id === fieldId);
|
|
13124
|
-
resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess',
|
|
13146
|
+
resolved.set(fieldId, labels.join(", ") || _optionalChain([field, 'optionalAccess', _316 => _316.fallback]) || "");
|
|
13125
13147
|
}
|
|
13126
|
-
} catch (
|
|
13148
|
+
} catch (e19) {
|
|
13127
13149
|
for (const { fieldId, ids } of relationBatch) {
|
|
13128
13150
|
const field = fields.find((f) => f.id === fieldId);
|
|
13129
|
-
resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess',
|
|
13151
|
+
resolved.set(fieldId, ids.join(", ") || _optionalChain([field, 'optionalAccess', _317 => _317.fallback]) || "");
|
|
13130
13152
|
}
|
|
13131
13153
|
}
|
|
13132
13154
|
}
|
|
@@ -13137,7 +13159,7 @@ var DocumentRendererService = class {
|
|
|
13137
13159
|
* Parses paths like "slots.client.firstName" to find the attribute definition
|
|
13138
13160
|
*/
|
|
13139
13161
|
async getAttributeInfo(contextPath, workflow2) {
|
|
13140
|
-
const schemaService = _optionalChain([this, 'access',
|
|
13162
|
+
const schemaService = _optionalChain([this, 'access', _318 => _318.options, 'optionalAccess', _319 => _319.schemaService]);
|
|
13141
13163
|
if (!schemaService) {
|
|
13142
13164
|
return null;
|
|
13143
13165
|
}
|
|
@@ -13150,7 +13172,7 @@ var DocumentRendererService = class {
|
|
|
13150
13172
|
}
|
|
13151
13173
|
const slotId = parts[1];
|
|
13152
13174
|
const attributeName = parts[2];
|
|
13153
|
-
const slot = _optionalChain([workflow2, 'access',
|
|
13175
|
+
const slot = _optionalChain([workflow2, 'access', _320 => _320.slots, 'optionalAccess', _321 => _321.find, 'call', _322 => _322((s) => s.id === slotId)]);
|
|
13154
13176
|
if (!slot) {
|
|
13155
13177
|
return null;
|
|
13156
13178
|
}
|
|
@@ -13159,7 +13181,7 @@ var DocumentRendererService = class {
|
|
|
13159
13181
|
try {
|
|
13160
13182
|
schema = await schemaService.getObjectSchemaByName(slot.objectName);
|
|
13161
13183
|
this.schemaCache.set(slot.objectName, schema);
|
|
13162
|
-
} catch (
|
|
13184
|
+
} catch (e20) {
|
|
13163
13185
|
return null;
|
|
13164
13186
|
}
|
|
13165
13187
|
}
|
|
@@ -13349,7 +13371,7 @@ var DocumentProcessingHook = class extends BaseService {
|
|
|
13349
13371
|
const pendingIds = [];
|
|
13350
13372
|
for (const [nodeId, doc] of Object.entries(context.documents)) {
|
|
13351
13373
|
const metadata = doc.metadata;
|
|
13352
|
-
if (_optionalChain([metadata, 'optionalAccess',
|
|
13374
|
+
if (_optionalChain([metadata, 'optionalAccess', _323 => _323.status]) === "pending") {
|
|
13353
13375
|
pendingIds.push(nodeId);
|
|
13354
13376
|
}
|
|
13355
13377
|
}
|
|
@@ -13400,12 +13422,12 @@ var DocumentProcessingHook = class extends BaseService {
|
|
|
13400
13422
|
}
|
|
13401
13423
|
for (const slotId of targetSlotIds) {
|
|
13402
13424
|
try {
|
|
13403
|
-
const recordId = _optionalChain([context, 'access',
|
|
13425
|
+
const recordId = _optionalChain([context, 'access', _324 => _324.createdRecordIds, 'optionalAccess', _325 => _325[slotId]]);
|
|
13404
13426
|
if (!recordId) {
|
|
13405
13427
|
continue;
|
|
13406
13428
|
}
|
|
13407
|
-
const slotDef = _optionalChain([workflow2, 'access',
|
|
13408
|
-
const objectName = _optionalChain([slotDef, 'optionalAccess',
|
|
13429
|
+
const slotDef = _optionalChain([workflow2, 'access', _326 => _326.slots, 'optionalAccess', _327 => _327.find, 'call', _328 => _328((s) => s.id === slotId)]);
|
|
13430
|
+
const objectName = _optionalChain([slotDef, 'optionalAccess', _329 => _329.objectName]);
|
|
13409
13431
|
if (!objectName) {
|
|
13410
13432
|
continue;
|
|
13411
13433
|
}
|
|
@@ -13422,14 +13444,14 @@ var DocumentProcessingHook = class extends BaseService {
|
|
|
13422
13444
|
attachedDocumentIds.push(result.document.id);
|
|
13423
13445
|
const record = await recordService.getRecord(recordId);
|
|
13424
13446
|
if (record) {
|
|
13425
|
-
const attachments = _nullishCoalesce(_optionalChain([record, 'access',
|
|
13447
|
+
const attachments = _nullishCoalesce(_optionalChain([record, 'access', _330 => _330.values, 'optionalAccess', _331 => _331.attachments]), () => ( []));
|
|
13426
13448
|
await recordService.updateRecord(
|
|
13427
13449
|
recordId,
|
|
13428
13450
|
{ attachments: [...attachments, result.document.id] },
|
|
13429
13451
|
{ partial: true }
|
|
13430
13452
|
);
|
|
13431
13453
|
}
|
|
13432
|
-
} catch (
|
|
13454
|
+
} catch (e21) {
|
|
13433
13455
|
}
|
|
13434
13456
|
}
|
|
13435
13457
|
return attachedDocumentIds;
|
|
@@ -13688,7 +13710,7 @@ var WorkflowAccessGrantService = class extends BaseService {
|
|
|
13688
13710
|
* Check if a specific token has been revoked.
|
|
13689
13711
|
*/
|
|
13690
13712
|
isTokenRevoked(dbGrant, jti) {
|
|
13691
|
-
return _nullishCoalesce(_optionalChain([dbGrant, 'access',
|
|
13713
|
+
return _nullishCoalesce(_optionalChain([dbGrant, 'access', _332 => _332.revoked_token_jtis, 'optionalAccess', _333 => _333.includes, 'call', _334 => _334(jti)]), () => ( false));
|
|
13692
13714
|
}
|
|
13693
13715
|
/**
|
|
13694
13716
|
* Validate access token payload against the grant.
|
|
@@ -13740,10 +13762,10 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13740
13762
|
constructor(adapter, workflowService, options) {
|
|
13741
13763
|
super(adapter);
|
|
13742
13764
|
this.workflowService = workflowService;
|
|
13743
|
-
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
13744
|
-
this.schemaService = _optionalChain([options, 'optionalAccess',
|
|
13745
|
-
this.recordService = _optionalChain([options, 'optionalAccess',
|
|
13746
|
-
this.documentProcessingHook = _optionalChain([options, 'optionalAccess',
|
|
13765
|
+
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _335 => _335.executorRegistry]), () => ( getDefaultExecutorRegistry()));
|
|
13766
|
+
this.schemaService = _optionalChain([options, 'optionalAccess', _336 => _336.schemaService]);
|
|
13767
|
+
this.recordService = _optionalChain([options, 'optionalAccess', _337 => _337.recordService]);
|
|
13768
|
+
this.documentProcessingHook = _optionalChain([options, 'optionalAccess', _338 => _338.documentProcessingHook]);
|
|
13747
13769
|
}
|
|
13748
13770
|
/**
|
|
13749
13771
|
* Start a new workflow instance
|
|
@@ -13925,7 +13947,7 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13925
13947
|
if (!this.adapter.workflowInstances) {
|
|
13926
13948
|
return { instances: [], total: 0 };
|
|
13927
13949
|
}
|
|
13928
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
13950
|
+
if (_optionalChain([options, 'optionalAccess', _339 => _339.workflowName])) {
|
|
13929
13951
|
const allDbInstances = await this.adapter.workflowInstances.findByWorkflowName(
|
|
13930
13952
|
options.workflowName,
|
|
13931
13953
|
{ status: options.status }
|
|
@@ -13939,11 +13961,11 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13939
13961
|
return { instances: instances2, total: total2 };
|
|
13940
13962
|
}
|
|
13941
13963
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
|
|
13942
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
13943
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
13964
|
+
limit: _optionalChain([options, 'optionalAccess', _340 => _340.limit]),
|
|
13965
|
+
offset: _optionalChain([options, 'optionalAccess', _341 => _341.offset])
|
|
13944
13966
|
});
|
|
13945
13967
|
let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
13946
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
13968
|
+
if (_optionalChain([options, 'optionalAccess', _342 => _342.status])) {
|
|
13947
13969
|
instances = instances.filter((i) => i.status === options.status);
|
|
13948
13970
|
}
|
|
13949
13971
|
instances = await this.markExpiredInstances(instances);
|
|
@@ -13964,9 +13986,9 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
13964
13986
|
return { instances: [], total: 0 };
|
|
13965
13987
|
}
|
|
13966
13988
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
|
|
13967
|
-
status: _optionalChain([options, 'optionalAccess',
|
|
13968
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
13969
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
13989
|
+
status: _optionalChain([options, 'optionalAccess', _343 => _343.status]),
|
|
13990
|
+
limit: _optionalChain([options, 'optionalAccess', _344 => _344.limit]),
|
|
13991
|
+
offset: _optionalChain([options, 'optionalAccess', _345 => _345.offset])
|
|
13970
13992
|
});
|
|
13971
13993
|
const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
13972
13994
|
return { instances, total };
|
|
@@ -14032,13 +14054,13 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
14032
14054
|
try {
|
|
14033
14055
|
const schemas = await Promise.all(
|
|
14034
14056
|
current.workflowSnapshot.slots.map(
|
|
14035
|
-
(slot) => _optionalChain([this, 'access',
|
|
14057
|
+
(slot) => _optionalChain([this, 'access', _346 => _346.schemaService, 'optionalAccess', _347 => _347.getObjectSchemaByName, 'call', _348 => _348(slot.objectName)])
|
|
14036
14058
|
)
|
|
14037
14059
|
);
|
|
14038
14060
|
objectDefinitions = schemas.filter(
|
|
14039
14061
|
(s) => s !== void 0
|
|
14040
14062
|
);
|
|
14041
|
-
} catch (
|
|
14063
|
+
} catch (e22) {
|
|
14042
14064
|
}
|
|
14043
14065
|
}
|
|
14044
14066
|
const executorContext = {
|
|
@@ -14297,9 +14319,9 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
14297
14319
|
*/
|
|
14298
14320
|
async snapshotRecord(recordId) {
|
|
14299
14321
|
try {
|
|
14300
|
-
const record = await _optionalChain([this, 'access',
|
|
14301
|
-
return _optionalChain([record, 'optionalAccess',
|
|
14302
|
-
} catch (
|
|
14322
|
+
const record = await _optionalChain([this, 'access', _349 => _349.recordService, 'optionalAccess', _350 => _350.getRecord, 'call', _351 => _351(recordId, { skipPolicyCheck: true })]);
|
|
14323
|
+
return _optionalChain([record, 'optionalAccess', _352 => _352.values]);
|
|
14324
|
+
} catch (e23) {
|
|
14303
14325
|
return void 0;
|
|
14304
14326
|
}
|
|
14305
14327
|
}
|
|
@@ -14317,18 +14339,18 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
14317
14339
|
for (const op of [...operations].reverse()) {
|
|
14318
14340
|
try {
|
|
14319
14341
|
if (op.operation === "create") {
|
|
14320
|
-
await _optionalChain([this, 'access',
|
|
14342
|
+
await _optionalChain([this, 'access', _353 => _353.recordService, 'optionalAccess', _354 => _354.deleteRecord, 'call', _355 => _355(op.recordId, {
|
|
14321
14343
|
skipHooks: true,
|
|
14322
14344
|
skipReferenceCheck: true
|
|
14323
14345
|
})]);
|
|
14324
14346
|
rolledBack.push(op.slotId);
|
|
14325
14347
|
} else if (op.operation === "update" && op.previousData) {
|
|
14326
|
-
await _optionalChain([this, 'access',
|
|
14348
|
+
await _optionalChain([this, 'access', _356 => _356.recordService, 'optionalAccess', _357 => _357.updateRecord, 'call', _358 => _358(op.recordId, op.previousData, {
|
|
14327
14349
|
partial: false
|
|
14328
14350
|
})]);
|
|
14329
14351
|
rolledBack.push(op.slotId);
|
|
14330
14352
|
}
|
|
14331
|
-
} catch (
|
|
14353
|
+
} catch (e24) {
|
|
14332
14354
|
}
|
|
14333
14355
|
}
|
|
14334
14356
|
return rolledBack;
|
|
@@ -14447,7 +14469,7 @@ var WorkflowInstanceService = class extends BaseService {
|
|
|
14447
14469
|
if (!this.adapter.workflowInstances) {
|
|
14448
14470
|
return;
|
|
14449
14471
|
}
|
|
14450
|
-
const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access',
|
|
14472
|
+
const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _359 => _359.context, 'access', _360 => _360.variables, 'optionalAccess', _361 => _361.__version]), () => ( 0));
|
|
14451
14473
|
const nextVersion = currentVersion + 1;
|
|
14452
14474
|
const instanceWithVersion = {
|
|
14453
14475
|
...instance,
|
|
@@ -14728,7 +14750,7 @@ var WorkflowRelationService = class extends BaseService {
|
|
|
14728
14750
|
if (attr.type !== "relation") continue;
|
|
14729
14751
|
for (const slot of slots) {
|
|
14730
14752
|
const slotData = context.slots[slot.id];
|
|
14731
|
-
const slotRecordId = _optionalChain([slotData, 'optionalAccess',
|
|
14753
|
+
const slotRecordId = _optionalChain([slotData, 'optionalAccess', _362 => _362.id]);
|
|
14732
14754
|
if (!slotRecordId) continue;
|
|
14733
14755
|
const targetsSlotObject = attr.targets.some(
|
|
14734
14756
|
(t) => t.object === slot.objectName
|
|
@@ -14796,7 +14818,7 @@ var WorkflowService = class extends BaseService {
|
|
|
14796
14818
|
if (Array.isArray(options)) {
|
|
14797
14819
|
this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
|
|
14798
14820
|
} else {
|
|
14799
|
-
this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
14821
|
+
this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _363 => _363.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
|
|
14800
14822
|
}
|
|
14801
14823
|
}
|
|
14802
14824
|
// ============================================================================
|
|
@@ -15094,7 +15116,7 @@ var WorkflowService = class extends BaseService {
|
|
|
15094
15116
|
var UserProfileService = class extends BaseService {
|
|
15095
15117
|
constructor(adapter, options) {
|
|
15096
15118
|
super(adapter);
|
|
15097
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
15119
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _364 => _364.auditService]);
|
|
15098
15120
|
}
|
|
15099
15121
|
// ============================================================================
|
|
15100
15122
|
// CACHE MANAGEMENT
|
|
@@ -15112,6 +15134,74 @@ var UserProfileService = class extends BaseService {
|
|
|
15112
15134
|
await this.invalidateCache(cacheKeys.userProfileByEmail(this.tenantId, email));
|
|
15113
15135
|
}
|
|
15114
15136
|
}
|
|
15137
|
+
// ============================================================================
|
|
15138
|
+
// AVATAR URL RESOLUTION
|
|
15139
|
+
// ============================================================================
|
|
15140
|
+
/**
|
|
15141
|
+
* Resolve avatar storage path to a signed URL.
|
|
15142
|
+
* External URLs (https://) pass through unchanged.
|
|
15143
|
+
* Storage paths are resolved to fresh signed URLs (1h expiry).
|
|
15144
|
+
*/
|
|
15145
|
+
async resolveAvatarUrl(profile) {
|
|
15146
|
+
if (!profile.avatarUrl || profile.avatarUrl.startsWith("https://")) {
|
|
15147
|
+
return profile;
|
|
15148
|
+
}
|
|
15149
|
+
if (!this.adapter.storage) return profile;
|
|
15150
|
+
try {
|
|
15151
|
+
const signedUrl = await this.adapter.storage.getSignedUrl(profile.avatarUrl, {
|
|
15152
|
+
expiresIn: 3600
|
|
15153
|
+
});
|
|
15154
|
+
return { ...profile, avatarUrl: signedUrl };
|
|
15155
|
+
} catch (e25) {
|
|
15156
|
+
return profile;
|
|
15157
|
+
}
|
|
15158
|
+
}
|
|
15159
|
+
async resolveAvatarUrls(profiles) {
|
|
15160
|
+
return Promise.all(profiles.map((p) => this.resolveAvatarUrl(p)));
|
|
15161
|
+
}
|
|
15162
|
+
// ============================================================================
|
|
15163
|
+
// AVATAR MANAGEMENT
|
|
15164
|
+
// ============================================================================
|
|
15165
|
+
/**
|
|
15166
|
+
* Upload a new avatar for the user.
|
|
15167
|
+
* Deletes previous avatar from storage if it was an internal upload.
|
|
15168
|
+
* Stores the storagePath — resolved to signed URL at read time.
|
|
15169
|
+
*/
|
|
15170
|
+
async uploadAvatar(profileId, input) {
|
|
15171
|
+
if (!this.adapter.storage) {
|
|
15172
|
+
throw new Error("StorageAdapter is not configured.");
|
|
15173
|
+
}
|
|
15174
|
+
if (!input.mimeType.startsWith("image/")) {
|
|
15175
|
+
throw new Error("Only image files are allowed for avatars.");
|
|
15176
|
+
}
|
|
15177
|
+
const profile = await this.getProfileOrThrow(profileId);
|
|
15178
|
+
if (profile.avatarUrl && !profile.avatarUrl.startsWith("https://")) {
|
|
15179
|
+
await this.adapter.storage.delete(profile.avatarUrl).catch(() => void 0);
|
|
15180
|
+
}
|
|
15181
|
+
const result = await this.adapter.storage.upload({
|
|
15182
|
+
content: input.content,
|
|
15183
|
+
fileName: input.fileName,
|
|
15184
|
+
mimeType: input.mimeType,
|
|
15185
|
+
size: input.size,
|
|
15186
|
+
tenantId: this.tenantId,
|
|
15187
|
+
folderPath: "avatars"
|
|
15188
|
+
});
|
|
15189
|
+
return await this.updateProfile(profileId, { avatarUrl: result.storagePath });
|
|
15190
|
+
}
|
|
15191
|
+
/**
|
|
15192
|
+
* Delete the user's avatar.
|
|
15193
|
+
* Removes file from storage if it was an internal upload, then clears avatarUrl.
|
|
15194
|
+
*/
|
|
15195
|
+
async deleteAvatar(profileId) {
|
|
15196
|
+
const profile = await this.getProfileOrThrow(profileId);
|
|
15197
|
+
if (profile.avatarUrl && !profile.avatarUrl.startsWith("https://")) {
|
|
15198
|
+
await _optionalChain([this, 'access', _365 => _365.adapter, 'access', _366 => _366.storage, 'optionalAccess', _367 => _367.delete, 'call', _368 => _368(profile.avatarUrl), 'access', _369 => _369.catch, 'call', _370 => _370(() => void 0)]);
|
|
15199
|
+
}
|
|
15200
|
+
return await this.updateProfile(profileId, { avatarUrl: null });
|
|
15201
|
+
}
|
|
15202
|
+
// ============================================================================
|
|
15203
|
+
// CREATE
|
|
15204
|
+
// ============================================================================
|
|
15115
15205
|
/**
|
|
15116
15206
|
* Create a new user profile (typically after first auth).
|
|
15117
15207
|
* Automatically uses tenant context from AsyncLocalStorage.
|
|
@@ -15152,18 +15242,19 @@ var UserProfileService = class extends BaseService {
|
|
|
15152
15242
|
targetUserEmail: profile.email
|
|
15153
15243
|
});
|
|
15154
15244
|
}
|
|
15155
|
-
return profile;
|
|
15245
|
+
return this.resolveAvatarUrl(profile);
|
|
15156
15246
|
}
|
|
15157
15247
|
/**
|
|
15158
15248
|
* Get user profile by ID.
|
|
15159
15249
|
* Results are cached if a CacheAdapter is configured.
|
|
15160
15250
|
*/
|
|
15161
15251
|
async getProfile(profileId) {
|
|
15162
|
-
|
|
15252
|
+
const profile = await this.cachedBy(
|
|
15163
15253
|
"userProfileById",
|
|
15164
15254
|
profileId,
|
|
15165
15255
|
() => this.adapter.userProfiles.findById(profileId)
|
|
15166
15256
|
);
|
|
15257
|
+
return profile ? this.resolveAvatarUrl(profile) : null;
|
|
15167
15258
|
}
|
|
15168
15259
|
/**
|
|
15169
15260
|
* Get user profile by ID or throw
|
|
@@ -15185,11 +15276,12 @@ var UserProfileService = class extends BaseService {
|
|
|
15185
15276
|
* @returns User profile or null
|
|
15186
15277
|
*/
|
|
15187
15278
|
async getProfileByAuthId(authId) {
|
|
15188
|
-
|
|
15279
|
+
const profile = await this.cachedBy(
|
|
15189
15280
|
"userProfileByAuthId",
|
|
15190
15281
|
authId,
|
|
15191
15282
|
() => this.adapter.userProfiles.findByAuthId(authId)
|
|
15192
15283
|
);
|
|
15284
|
+
return profile ? this.resolveAvatarUrl(profile) : null;
|
|
15193
15285
|
}
|
|
15194
15286
|
/**
|
|
15195
15287
|
* Get or create user profile (idempotent operation)
|
|
@@ -15228,11 +15320,11 @@ var UserProfileService = class extends BaseService {
|
|
|
15228
15320
|
const updated = await this.adapter.userProfiles.update(profileId, data);
|
|
15229
15321
|
await this.invalidateProfileCache(updated.id, updated.authId, updated.email);
|
|
15230
15322
|
if (this.auditService && this.userId) {
|
|
15231
|
-
const changes = buildAuditChanges(
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
"status"
|
|
15235
|
-
|
|
15323
|
+
const changes = buildAuditChanges(
|
|
15324
|
+
existing,
|
|
15325
|
+
data,
|
|
15326
|
+
["firstName", "lastName", "status"]
|
|
15327
|
+
);
|
|
15236
15328
|
if (changes.length > 0) {
|
|
15237
15329
|
await this.auditService.logUserAction({
|
|
15238
15330
|
action: "user.updated",
|
|
@@ -15243,7 +15335,7 @@ var UserProfileService = class extends BaseService {
|
|
|
15243
15335
|
});
|
|
15244
15336
|
}
|
|
15245
15337
|
}
|
|
15246
|
-
return updated;
|
|
15338
|
+
return this.resolveAvatarUrl(updated);
|
|
15247
15339
|
}
|
|
15248
15340
|
/**
|
|
15249
15341
|
* Delete user profile.
|
|
@@ -15254,7 +15346,7 @@ var UserProfileService = class extends BaseService {
|
|
|
15254
15346
|
*/
|
|
15255
15347
|
async deleteProfile(profileId, options) {
|
|
15256
15348
|
const profile = await this.getProfileOrThrow(profileId);
|
|
15257
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
15349
|
+
if (_optionalChain([options, 'optionalAccess', _371 => _371.checkAdmin]) && this.adapter.permissions) {
|
|
15258
15350
|
const ownerCount = await this.adapter.permissions.countUsersWithRole("owner");
|
|
15259
15351
|
if (ownerCount <= 1) {
|
|
15260
15352
|
const userRoles = await this.adapter.permissions.getUserRoles(profileId);
|
|
@@ -15280,7 +15372,8 @@ var UserProfileService = class extends BaseService {
|
|
|
15280
15372
|
* Automatically uses tenant context from AsyncLocalStorage.
|
|
15281
15373
|
*/
|
|
15282
15374
|
async listProfiles(options) {
|
|
15283
|
-
|
|
15375
|
+
const profiles = await this.adapter.userProfiles.list(options);
|
|
15376
|
+
return this.resolveAvatarUrls(profiles);
|
|
15284
15377
|
}
|
|
15285
15378
|
/**
|
|
15286
15379
|
* Update last login timestamp
|
|
@@ -15311,11 +15404,12 @@ var UserProfileService = class extends BaseService {
|
|
|
15311
15404
|
* Automatically uses tenant context from AsyncLocalStorage.
|
|
15312
15405
|
*/
|
|
15313
15406
|
async getProfileByEmail(email) {
|
|
15314
|
-
|
|
15407
|
+
const profile = await this.cachedBy(
|
|
15315
15408
|
"userProfileByEmail",
|
|
15316
15409
|
email,
|
|
15317
15410
|
() => this.adapter.userProfiles.findByEmail(email)
|
|
15318
15411
|
);
|
|
15412
|
+
return profile ? this.resolveAvatarUrl(profile) : null;
|
|
15319
15413
|
}
|
|
15320
15414
|
/**
|
|
15321
15415
|
* Invite a new user by email.
|
|
@@ -15348,6 +15442,21 @@ var UserProfileService = class extends BaseService {
|
|
|
15348
15442
|
throw new Error(`User with email "${data.email}" already exists in this tenant`);
|
|
15349
15443
|
}
|
|
15350
15444
|
const profile = await this.adapter.userProfiles.invite(data);
|
|
15445
|
+
if (this.adapter.permissions) {
|
|
15446
|
+
try {
|
|
15447
|
+
const roles = await this.adapter.permissions.getRoles();
|
|
15448
|
+
const defaultRole = roles.find((r) => r.name === "member" && r.system);
|
|
15449
|
+
if (defaultRole) {
|
|
15450
|
+
await this.adapter.permissions.assignRole({
|
|
15451
|
+
userProfileId: profile.id,
|
|
15452
|
+
roleId: defaultRole.id,
|
|
15453
|
+
tenantId: this.tenantId,
|
|
15454
|
+
assignedBy: _nullishCoalesce(this.userId, () => ( void 0))
|
|
15455
|
+
});
|
|
15456
|
+
}
|
|
15457
|
+
} catch (e26) {
|
|
15458
|
+
}
|
|
15459
|
+
}
|
|
15351
15460
|
await this.invalidateProfileCache(profile.id, profile.authId, profile.email);
|
|
15352
15461
|
if (this.auditService && this.userId) {
|
|
15353
15462
|
await this.auditService.logUserAction({
|
|
@@ -15357,7 +15466,7 @@ var UserProfileService = class extends BaseService {
|
|
|
15357
15466
|
targetUserEmail: profile.email
|
|
15358
15467
|
});
|
|
15359
15468
|
}
|
|
15360
|
-
return profile;
|
|
15469
|
+
return this.resolveAvatarUrl(profile);
|
|
15361
15470
|
}
|
|
15362
15471
|
};
|
|
15363
15472
|
|
|
@@ -15742,7 +15851,7 @@ var DocumentTemplateService = class extends BaseService {
|
|
|
15742
15851
|
* Includes both system templates and tenant-specific templates.
|
|
15743
15852
|
*/
|
|
15744
15853
|
async listTemplates(options) {
|
|
15745
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
15854
|
+
if (_optionalChain([options, 'optionalAccess', _372 => _372.systemOnly])) {
|
|
15746
15855
|
return SYSTEM_TEMPLATES;
|
|
15747
15856
|
}
|
|
15748
15857
|
const templates = [...SYSTEM_TEMPLATES];
|
|
@@ -15825,8 +15934,8 @@ var DocumentTemplateService = class extends BaseService {
|
|
|
15825
15934
|
var DocumentService = class extends BaseService {
|
|
15826
15935
|
constructor(adapter, options) {
|
|
15827
15936
|
super(adapter);
|
|
15828
|
-
this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
15829
|
-
this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
15937
|
+
this.templateService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _373 => _373.templateService]), () => ( new DocumentTemplateService(adapter)));
|
|
15938
|
+
this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.fileService]), () => ( null));
|
|
15830
15939
|
}
|
|
15831
15940
|
// ============================================================================
|
|
15832
15941
|
// CREATE
|
|
@@ -16077,7 +16186,7 @@ var DocumentService = class extends BaseService {
|
|
|
16077
16186
|
*/
|
|
16078
16187
|
async isComplete(documentId) {
|
|
16079
16188
|
const document2 = await this.getDocument(documentId);
|
|
16080
|
-
return _optionalChain([document2, 'optionalAccess',
|
|
16189
|
+
return _optionalChain([document2, 'optionalAccess', _375 => _375.status]) !== "draft";
|
|
16081
16190
|
}
|
|
16082
16191
|
/**
|
|
16083
16192
|
* Get document with its template and slots.
|
|
@@ -16335,7 +16444,7 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
16335
16444
|
type: "signature",
|
|
16336
16445
|
provider: this.config.signatureAdapter.name,
|
|
16337
16446
|
input: { signers, ...options },
|
|
16338
|
-
expiresAt: _optionalChain([options, 'optionalAccess',
|
|
16447
|
+
expiresAt: _optionalChain([options, 'optionalAccess', _376 => _376.expiresAt])
|
|
16339
16448
|
});
|
|
16340
16449
|
return job;
|
|
16341
16450
|
}
|
|
@@ -16492,7 +16601,7 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
16492
16601
|
}
|
|
16493
16602
|
const document2 = await this.documentService.getDocumentOrThrow(documentId);
|
|
16494
16603
|
const template = await this.templateService.getTemplateOrThrow(document2.templateId);
|
|
16495
|
-
if (!_optionalChain([template, 'access',
|
|
16604
|
+
if (!_optionalChain([template, 'access', _377 => _377.autoProcessing, 'optionalAccess', _378 => _378.identityVerification, 'optionalAccess', _379 => _379.enabled])) {
|
|
16496
16605
|
throw new Error("Identity verification is not enabled for this document type");
|
|
16497
16606
|
}
|
|
16498
16607
|
const job = await this.adapter.documentJobs.create({
|
|
@@ -16578,13 +16687,13 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
16578
16687
|
const template = await this.templateService.getTemplateOrThrow(document2.templateId);
|
|
16579
16688
|
const slots = await this.documentService.getSlots(documentId);
|
|
16580
16689
|
const jobs = [];
|
|
16581
|
-
if (_optionalChain([template, 'access',
|
|
16690
|
+
if (_optionalChain([template, 'access', _380 => _380.autoProcessing, 'optionalAccess', _381 => _381.ocr, 'optionalAccess', _382 => _382.enabled]) && this.config.ocrAdapter) {
|
|
16582
16691
|
for (const slot of slots) {
|
|
16583
16692
|
const job = await this.processOcr(documentId, slot.slotName);
|
|
16584
16693
|
jobs.push(job);
|
|
16585
16694
|
}
|
|
16586
16695
|
}
|
|
16587
|
-
if (_optionalChain([template, 'access',
|
|
16696
|
+
if (_optionalChain([template, 'access', _383 => _383.autoProcessing, 'optionalAccess', _384 => _384.identityVerification, 'optionalAccess', _385 => _385.enabled]) && this.config.identityAdapter) {
|
|
16588
16697
|
const job = await this.verifyIdentity(documentId);
|
|
16589
16698
|
jobs.push(job);
|
|
16590
16699
|
}
|
|
@@ -16655,15 +16764,15 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
16655
16764
|
return {
|
|
16656
16765
|
ocr: {
|
|
16657
16766
|
available: !!this.config.ocrAdapter,
|
|
16658
|
-
provider: _optionalChain([this, 'access',
|
|
16767
|
+
provider: _optionalChain([this, 'access', _386 => _386.config, 'access', _387 => _387.ocrAdapter, 'optionalAccess', _388 => _388.name])
|
|
16659
16768
|
},
|
|
16660
16769
|
signature: {
|
|
16661
16770
|
available: !!this.config.signatureAdapter,
|
|
16662
|
-
provider: _optionalChain([this, 'access',
|
|
16771
|
+
provider: _optionalChain([this, 'access', _389 => _389.config, 'access', _390 => _390.signatureAdapter, 'optionalAccess', _391 => _391.name])
|
|
16663
16772
|
},
|
|
16664
16773
|
identityVerification: {
|
|
16665
16774
|
available: !!this.config.identityAdapter,
|
|
16666
|
-
provider: _optionalChain([this, 'access',
|
|
16775
|
+
provider: _optionalChain([this, 'access', _392 => _392.config, 'access', _393 => _393.identityAdapter, 'optionalAccess', _394 => _394.name])
|
|
16667
16776
|
}
|
|
16668
16777
|
};
|
|
16669
16778
|
}
|
|
@@ -16673,7 +16782,7 @@ var DocumentProcessingService = class extends BaseService {
|
|
|
16673
16782
|
var FileService = class extends BaseService {
|
|
16674
16783
|
constructor(adapter, options) {
|
|
16675
16784
|
super(adapter);
|
|
16676
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
16785
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _395 => _395.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
16677
16786
|
}
|
|
16678
16787
|
// ============================================================================
|
|
16679
16788
|
// UPLOAD (requires StorageAdapter)
|
|
@@ -16812,7 +16921,7 @@ var FileService = class extends BaseService {
|
|
|
16812
16921
|
*/
|
|
16813
16922
|
async getFile(fileId) {
|
|
16814
16923
|
const file2 = await this.adapter.files.findById(fileId);
|
|
16815
|
-
if (_optionalChain([file2, 'optionalAccess',
|
|
16924
|
+
if (_optionalChain([file2, 'optionalAccess', _396 => _396.deletedAt])) {
|
|
16816
16925
|
return null;
|
|
16817
16926
|
}
|
|
16818
16927
|
return file2;
|
|
@@ -16874,12 +16983,12 @@ var FileService = class extends BaseService {
|
|
|
16874
16983
|
*/
|
|
16875
16984
|
async deleteFile(fileId, options) {
|
|
16876
16985
|
const file2 = await this.getFileOrThrow(fileId);
|
|
16877
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16986
|
+
if (_optionalChain([options, 'optionalAccess', _397 => _397.checkOwnership]) && options.userId) {
|
|
16878
16987
|
if (file2.uploadedBy !== options.userId) {
|
|
16879
16988
|
throw new Error("You can only delete files you uploaded");
|
|
16880
16989
|
}
|
|
16881
16990
|
}
|
|
16882
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16991
|
+
if (_optionalChain([options, 'optionalAccess', _398 => _398.hard])) {
|
|
16883
16992
|
await this.adapter.files.hardDelete(fileId);
|
|
16884
16993
|
} else {
|
|
16885
16994
|
await this.adapter.files.delete(fileId);
|
|
@@ -16910,7 +17019,7 @@ var FileService = class extends BaseService {
|
|
|
16910
17019
|
}
|
|
16911
17020
|
const file2 = await this.getFileOrThrow(fileId);
|
|
16912
17021
|
await this.adapter.storage.delete(file2.storagePath);
|
|
16913
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17022
|
+
if (_optionalChain([options, 'optionalAccess', _399 => _399.hard])) {
|
|
16914
17023
|
await this.adapter.files.hardDelete(fileId);
|
|
16915
17024
|
} else {
|
|
16916
17025
|
await this.adapter.files.delete(fileId);
|
|
@@ -16936,15 +17045,15 @@ var FileService = class extends BaseService {
|
|
|
16936
17045
|
const fileResults = await Promise.all(fileIds.map((id) => this.getFile(id)));
|
|
16937
17046
|
const files = fileResults.filter((f) => f !== null);
|
|
16938
17047
|
if (files.length === 0) return;
|
|
16939
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17048
|
+
if (_optionalChain([options, 'optionalAccess', _400 => _400.deleteFromStorage]) && this.adapter.storage) {
|
|
16940
17049
|
const BATCH_SIZE = 10;
|
|
16941
17050
|
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
16942
17051
|
const batch = files.slice(i, i + BATCH_SIZE);
|
|
16943
|
-
await Promise.all(batch.map((file2) => _optionalChain([this, 'access',
|
|
17052
|
+
await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _401 => _401.adapter, 'access', _402 => _402.storage, 'optionalAccess', _403 => _403.delete, 'call', _404 => _404(file2.storagePath)])));
|
|
16944
17053
|
}
|
|
16945
17054
|
}
|
|
16946
17055
|
const idsToDelete = files.map((f) => f.id);
|
|
16947
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17056
|
+
if (_optionalChain([options, 'optionalAccess', _405 => _405.hard])) {
|
|
16948
17057
|
await Promise.all(idsToDelete.map((id) => this.adapter.files.hardDelete(id)));
|
|
16949
17058
|
} else {
|
|
16950
17059
|
await Promise.all(idsToDelete.map((id) => this.adapter.files.delete(id)));
|
|
@@ -16952,12 +17061,12 @@ var FileService = class extends BaseService {
|
|
|
16952
17061
|
if (this.auditService && this.userId) {
|
|
16953
17062
|
await Promise.all(
|
|
16954
17063
|
files.map(
|
|
16955
|
-
(file2) => _optionalChain([this, 'access',
|
|
17064
|
+
(file2) => _optionalChain([this, 'access', _406 => _406.auditService, 'optionalAccess', _407 => _407.logFileAction, 'call', _408 => _408({
|
|
16956
17065
|
action: "file.deleted",
|
|
16957
17066
|
actorId: _nullishCoalesce(this.userId, () => ( "")),
|
|
16958
17067
|
fileId: file2.id,
|
|
16959
17068
|
fileName: file2.name,
|
|
16960
|
-
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17069
|
+
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _409 => _409.deleteFromStorage]), () => ( false)) }
|
|
16961
17070
|
})])
|
|
16962
17071
|
)
|
|
16963
17072
|
);
|
|
@@ -17030,14 +17139,11 @@ var FileService = class extends BaseService {
|
|
|
17030
17139
|
* @param userId - User ID to check
|
|
17031
17140
|
* @returns true if user can access the file
|
|
17032
17141
|
*/
|
|
17033
|
-
async checkAccess(fileId, userId
|
|
17142
|
+
async checkAccess(fileId, userId) {
|
|
17034
17143
|
const file2 = await this.getFile(fileId);
|
|
17035
17144
|
if (!file2) {
|
|
17036
17145
|
return false;
|
|
17037
17146
|
}
|
|
17038
|
-
if (_optionalChain([options, 'optionalAccess', _403 => _403.isAdmin])) {
|
|
17039
|
-
return true;
|
|
17040
|
-
}
|
|
17041
17147
|
if (file2.visibility === "public") {
|
|
17042
17148
|
return true;
|
|
17043
17149
|
}
|
|
@@ -17045,7 +17151,7 @@ var FileService = class extends BaseService {
|
|
|
17045
17151
|
return true;
|
|
17046
17152
|
}
|
|
17047
17153
|
if (file2.visibility === "restricted") {
|
|
17048
|
-
return _nullishCoalesce(_optionalChain([file2, 'access',
|
|
17154
|
+
return _nullishCoalesce(_optionalChain([file2, 'access', _410 => _410.allowedUsers, 'optionalAccess', _411 => _411.includes, 'call', _412 => _412(userId)]), () => ( false));
|
|
17049
17155
|
}
|
|
17050
17156
|
return false;
|
|
17051
17157
|
}
|
|
@@ -17140,7 +17246,7 @@ function withTimeout(promise, ms, label) {
|
|
|
17140
17246
|
var GeocodingService = class {
|
|
17141
17247
|
constructor(adapter, options) {
|
|
17142
17248
|
this.adapter = adapter;
|
|
17143
|
-
this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17249
|
+
this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _413 => _413.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
|
|
17144
17250
|
}
|
|
17145
17251
|
/**
|
|
17146
17252
|
* Search for address suggestions as the user types
|
|
@@ -17199,9 +17305,9 @@ var GlobalSearchService = class extends BaseService {
|
|
|
17199
17305
|
if (this.adapter.search) {
|
|
17200
17306
|
try {
|
|
17201
17307
|
const raw = await this.adapter.search.globalSearch(trimmed, {
|
|
17202
|
-
objectNames: _optionalChain([options, 'optionalAccess',
|
|
17203
|
-
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17204
|
-
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17308
|
+
objectNames: _optionalChain([options, 'optionalAccess', _414 => _414.objectNames]),
|
|
17309
|
+
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _415 => _415.limit]), () => ( 20)),
|
|
17310
|
+
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _416 => _416.offset]), () => ( 0))
|
|
17205
17311
|
});
|
|
17206
17312
|
return await this.healGlobalSearchResults(raw);
|
|
17207
17313
|
} catch (err) {
|
|
@@ -17209,9 +17315,9 @@ var GlobalSearchService = class extends BaseService {
|
|
|
17209
17315
|
}
|
|
17210
17316
|
}
|
|
17211
17317
|
return this.adapter.objectRecords.globalSearch(trimmed, {
|
|
17212
|
-
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17213
|
-
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17214
|
-
objectNames: _optionalChain([options, 'optionalAccess',
|
|
17318
|
+
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _417 => _417.limit]), () => ( 20)),
|
|
17319
|
+
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _418 => _418.offset]), () => ( 0)),
|
|
17320
|
+
objectNames: _optionalChain([options, 'optionalAccess', _419 => _419.objectNames])
|
|
17215
17321
|
});
|
|
17216
17322
|
}
|
|
17217
17323
|
/**
|
|
@@ -17230,7 +17336,7 @@ var GlobalSearchService = class extends BaseService {
|
|
|
17230
17336
|
if (this.adapter.search) {
|
|
17231
17337
|
try {
|
|
17232
17338
|
const raw = await this.adapter.search.globalSearchGrouped(trimmed, {
|
|
17233
|
-
objectNames: _optionalChain([options, 'optionalAccess',
|
|
17339
|
+
objectNames: _optionalChain([options, 'optionalAccess', _420 => _420.objectNames])
|
|
17234
17340
|
});
|
|
17235
17341
|
return await this.healGroupedSearchResults(raw);
|
|
17236
17342
|
} catch (err) {
|
|
@@ -17238,8 +17344,8 @@ var GlobalSearchService = class extends BaseService {
|
|
|
17238
17344
|
}
|
|
17239
17345
|
}
|
|
17240
17346
|
return this.adapter.objectRecords.globalSearchGrouped(trimmed, {
|
|
17241
|
-
objectNames: _optionalChain([options, 'optionalAccess',
|
|
17242
|
-
limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
17347
|
+
objectNames: _optionalChain([options, 'optionalAccess', _421 => _421.objectNames]),
|
|
17348
|
+
limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _422 => _422.limitPerGroup]), () => ( 5))
|
|
17243
17349
|
});
|
|
17244
17350
|
}
|
|
17245
17351
|
// ==========================================================================
|
|
@@ -17306,7 +17412,7 @@ var PermissionService = class extends BaseService {
|
|
|
17306
17412
|
}
|
|
17307
17413
|
this.permissionsRepo = adapter.permissions;
|
|
17308
17414
|
this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
|
|
17309
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
17415
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _423 => _423.auditService]);
|
|
17310
17416
|
}
|
|
17311
17417
|
// ============================================================================
|
|
17312
17418
|
// PERMISSION CHECKS
|
|
@@ -17321,15 +17427,12 @@ var PermissionService = class extends BaseService {
|
|
|
17321
17427
|
*/
|
|
17322
17428
|
async canAccessObject(userProfileId, objectName, action) {
|
|
17323
17429
|
const permissions = await this.getEffectivePermissions(userProfileId);
|
|
17324
|
-
if (permissions.isAdmin) {
|
|
17325
|
-
return true;
|
|
17326
|
-
}
|
|
17327
17430
|
const wildcardPerms = permissions.objectPermissions["*"];
|
|
17328
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
17431
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _424 => _424.includes, 'call', _425 => _425(action)])) {
|
|
17329
17432
|
return true;
|
|
17330
17433
|
}
|
|
17331
17434
|
const objectPerms = permissions.objectPermissions[objectName];
|
|
17332
|
-
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess',
|
|
17435
|
+
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _426 => _426.includes, 'call', _427 => _427(action)]), () => ( false));
|
|
17333
17436
|
}
|
|
17334
17437
|
/**
|
|
17335
17438
|
* Check if user can access an object, throw ForbiddenError if not.
|
|
@@ -17355,9 +17458,6 @@ var PermissionService = class extends BaseService {
|
|
|
17355
17458
|
*/
|
|
17356
17459
|
async getObjectPermissions(userProfileId, objectName) {
|
|
17357
17460
|
const permissions = await this.getEffectivePermissions(userProfileId);
|
|
17358
|
-
if (permissions.isAdmin) {
|
|
17359
|
-
return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
|
|
17360
|
-
}
|
|
17361
17461
|
const wildcardPerms = _nullishCoalesce(permissions.objectPermissions["*"], () => ( []));
|
|
17362
17462
|
const objectPerms = _nullishCoalesce(permissions.objectPermissions[objectName], () => ( []));
|
|
17363
17463
|
const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...objectPerms]);
|
|
@@ -17381,15 +17481,12 @@ var PermissionService = class extends BaseService {
|
|
|
17381
17481
|
*/
|
|
17382
17482
|
async canAccessSystem(userProfileId, resource, action) {
|
|
17383
17483
|
const permissions = await this.getEffectivePermissions(userProfileId);
|
|
17384
|
-
|
|
17484
|
+
const wildcardPerms = _optionalChain([permissions, 'access', _428 => _428.systemPermissions, 'optionalAccess', _429 => _429["*"]]);
|
|
17485
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _430 => _430.includes, 'call', _431 => _431(action)])) {
|
|
17385
17486
|
return true;
|
|
17386
17487
|
}
|
|
17387
|
-
const
|
|
17388
|
-
|
|
17389
|
-
return true;
|
|
17390
|
-
}
|
|
17391
|
-
const resourcePerms = _optionalChain([permissions, 'access', _426 => _426.systemPermissions, 'optionalAccess', _427 => _427[resource]]);
|
|
17392
|
-
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _428 => _428.includes, 'call', _429 => _429(action)]), () => ( false));
|
|
17488
|
+
const resourcePerms = _optionalChain([permissions, 'access', _432 => _432.systemPermissions, 'optionalAccess', _433 => _433[resource]]);
|
|
17489
|
+
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _434 => _434.includes, 'call', _435 => _435(action)]), () => ( false));
|
|
17393
17490
|
}
|
|
17394
17491
|
/**
|
|
17395
17492
|
* Check if user can access a system resource, throw ForbiddenError if not.
|
|
@@ -17415,11 +17512,8 @@ var PermissionService = class extends BaseService {
|
|
|
17415
17512
|
*/
|
|
17416
17513
|
async getSystemPermissions(userProfileId, resource) {
|
|
17417
17514
|
const permissions = await this.getEffectivePermissions(userProfileId);
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
}
|
|
17421
|
-
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _430 => _430.systemPermissions, 'optionalAccess', _431 => _431["*"]]), () => ( []));
|
|
17422
|
-
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _432 => _432.systemPermissions, 'optionalAccess', _433 => _433[resource]]), () => ( []));
|
|
17515
|
+
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _436 => _436.systemPermissions, 'optionalAccess', _437 => _437["*"]]), () => ( []));
|
|
17516
|
+
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _438 => _438.systemPermissions, 'optionalAccess', _439 => _439[resource]]), () => ( []));
|
|
17423
17517
|
const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
|
|
17424
17518
|
return {
|
|
17425
17519
|
canRead: allPerms.has("read"),
|
|
@@ -17562,7 +17656,7 @@ var PermissionService = class extends BaseService {
|
|
|
17562
17656
|
action: "role.updated",
|
|
17563
17657
|
actorId: this.userId,
|
|
17564
17658
|
roleId,
|
|
17565
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
17659
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _440 => _440.label]), () => ( roleId)),
|
|
17566
17660
|
metadata: { permissionsUpdated: true, permissionCount: permissions.length }
|
|
17567
17661
|
});
|
|
17568
17662
|
}
|
|
@@ -17592,7 +17686,7 @@ var PermissionService = class extends BaseService {
|
|
|
17592
17686
|
action: "role.assigned",
|
|
17593
17687
|
actorId: this.userId,
|
|
17594
17688
|
roleId,
|
|
17595
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
17689
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _441 => _441.label]), () => ( roleId)),
|
|
17596
17690
|
targetUserId: userProfileId
|
|
17597
17691
|
});
|
|
17598
17692
|
}
|
|
@@ -17610,7 +17704,7 @@ var PermissionService = class extends BaseService {
|
|
|
17610
17704
|
action: "role.revoked",
|
|
17611
17705
|
actorId: this.userId,
|
|
17612
17706
|
roleId,
|
|
17613
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
17707
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _442 => _442.label]), () => ( roleId)),
|
|
17614
17708
|
targetUserId: userProfileId
|
|
17615
17709
|
});
|
|
17616
17710
|
}
|
|
@@ -17622,9 +17716,8 @@ var PermissionService = class extends BaseService {
|
|
|
17622
17716
|
* Initialize default roles for the tenant if they don't exist.
|
|
17623
17717
|
*
|
|
17624
17718
|
* Creates the following roles with their default permissions:
|
|
17625
|
-
* - **
|
|
17626
|
-
* - **member**:
|
|
17627
|
-
* - **guest**: No system access, read-only access to objects
|
|
17719
|
+
* - **owner**: Full access to all system resources and objects
|
|
17720
|
+
* - **member**: Full CRUD on business data, read-only on system resources (people, workspace)
|
|
17628
17721
|
*
|
|
17629
17722
|
* This method is idempotent - it only creates roles that don't already exist.
|
|
17630
17723
|
* Should be called during tenant bootstrap or on first admin login.
|
|
@@ -17641,7 +17734,7 @@ var PermissionService = class extends BaseService {
|
|
|
17641
17734
|
DEFAULT_ROLE_LABELS,
|
|
17642
17735
|
DEFAULT_ROLE_DESCRIPTIONS,
|
|
17643
17736
|
DEFAULT_ROLE_PERMISSIONS
|
|
17644
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./default-roles-
|
|
17737
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./default-roles-5K3GHJTS.js")));
|
|
17645
17738
|
const existingRoles = await this.getRoles();
|
|
17646
17739
|
const existingRoleNames = existingRoles.reduce((set, r) => set.add(r.name), /* @__PURE__ */ new Set());
|
|
17647
17740
|
for (const roleName of Object.values(DEFAULT_ROLES)) {
|
|
@@ -18085,7 +18178,7 @@ var ViewService = class extends BaseService {
|
|
|
18085
18178
|
dbView.objectName,
|
|
18086
18179
|
dbView.type,
|
|
18087
18180
|
objectDefinition,
|
|
18088
|
-
dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access',
|
|
18181
|
+
dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _443 => _443.config, 'optionalAccess', _444 => _444.layout]), () => ( "page")) : void 0
|
|
18089
18182
|
);
|
|
18090
18183
|
const newConfig = generated.config;
|
|
18091
18184
|
const updated = await this.adapter.views.update(viewId, { config: newConfig });
|
|
@@ -18426,6 +18519,7 @@ async function syncNativeObjects(adapter, nativeRegistry, options = {}) {
|
|
|
18426
18519
|
const result = {
|
|
18427
18520
|
success: true,
|
|
18428
18521
|
objectsSynced: 0,
|
|
18522
|
+
objectsDeleted: 0,
|
|
18429
18523
|
attributesSynced: 0,
|
|
18430
18524
|
objectsCreated: 0,
|
|
18431
18525
|
objectsUpdated: 0,
|
|
@@ -18451,6 +18545,7 @@ async function syncNativeObjects(adapter, nativeRegistry, options = {}) {
|
|
|
18451
18545
|
});
|
|
18452
18546
|
}
|
|
18453
18547
|
}
|
|
18548
|
+
await cleanupOrphanObjects(tx, nativeObjects, result, options);
|
|
18454
18549
|
});
|
|
18455
18550
|
} catch (error2) {
|
|
18456
18551
|
result.success = false;
|
|
@@ -18462,7 +18557,7 @@ async function syncNativeObjects(adapter, nativeRegistry, options = {}) {
|
|
|
18462
18557
|
if (options.verbose) {
|
|
18463
18558
|
console.info(
|
|
18464
18559
|
`[SyncService] ${result.success ? "\u2713" : "\u2717"} Sync complete:
|
|
18465
|
-
Objects: ${result.objectsCreated} created, ${result.objectsUpdated} updated
|
|
18560
|
+
Objects: ${result.objectsCreated} created, ${result.objectsUpdated} updated, ${result.objectsDeleted} deleted
|
|
18466
18561
|
Attributes: ${result.attributesCreated} created, ${result.attributesUpdated} updated, ${result.attributesDeleted} deleted
|
|
18467
18562
|
Errors: ${result.errors.length}`
|
|
18468
18563
|
);
|
|
@@ -18574,6 +18669,25 @@ async function cleanupAttributes(adapter, objectId, nativeObject, result) {
|
|
|
18574
18669
|
const deletedCount = await adapter.attributes.deleteSystemByNames(objectId, attributeNames);
|
|
18575
18670
|
result.attributesDeleted += deletedCount;
|
|
18576
18671
|
}
|
|
18672
|
+
async function cleanupOrphanObjects(adapter, nativeObjects, result, options) {
|
|
18673
|
+
const registryNames = nativeObjects.map((obj) => obj.name);
|
|
18674
|
+
if (options.dryRun) {
|
|
18675
|
+
const allObjects = await adapter.objects.list();
|
|
18676
|
+
const orphans = allObjects.filter((obj) => obj.system && !registryNames.includes(obj.name));
|
|
18677
|
+
result.objectsDeleted += orphans.length;
|
|
18678
|
+
if (options.verbose && orphans.length > 0) {
|
|
18679
|
+
console.info(
|
|
18680
|
+
`[SyncService] Would delete ${orphans.length} orphan system object(s): ${orphans.map((o) => o.name).join(", ")}`
|
|
18681
|
+
);
|
|
18682
|
+
}
|
|
18683
|
+
return;
|
|
18684
|
+
}
|
|
18685
|
+
const deletedCount = await adapter.objects.deleteSystemNotInNames(registryNames);
|
|
18686
|
+
result.objectsDeleted += deletedCount;
|
|
18687
|
+
if (options.verbose && deletedCount > 0) {
|
|
18688
|
+
console.info(`[SyncService] Deleted ${deletedCount} orphan system object(s)`);
|
|
18689
|
+
}
|
|
18690
|
+
}
|
|
18577
18691
|
function logSyncSuccess(nativeObject, options) {
|
|
18578
18692
|
if (options.verbose) {
|
|
18579
18693
|
console.info(
|