@stndrds/schema 0.1.0-alpha.40 → 0.1.0-alpha.42
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-2C24E4Q2.mjs → chunk-MXYJTCA3.mjs} +490 -497
- package/dist/{chunk-UDJDDKGY.js → chunk-SWD6OPOV.js} +659 -666
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -6
- package/dist/index.mjs +17 -1
- package/dist/{runtime-Dl-kGqgX.d.mts → runtime-CvRbtIhb.d.mts} +212 -307
- package/dist/{runtime-Dl-kGqgX.d.ts → runtime-CvRbtIhb.d.ts} +212 -307
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +18 -2
- package/dist/runtime.mjs +17 -1
- package/package.json +2 -2
|
@@ -482,7 +482,7 @@ var TenantContextError = class _TenantContextError extends Error {
|
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
484
|
|
|
485
|
-
// src/runtime/context/
|
|
485
|
+
// src/runtime/context/schema-context.ts
|
|
486
486
|
var browserStub = {
|
|
487
487
|
getStore: () => void 0,
|
|
488
488
|
run: (_store, callback) => callback()
|
|
@@ -520,8 +520,102 @@ function getStorage() {
|
|
|
520
520
|
storageInstance = browserStub;
|
|
521
521
|
return storageInstance;
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function getSchemaFromContext(objectId) {
|
|
524
|
+
const ctx = getStorage().getStore();
|
|
525
|
+
return _optionalChain([ctx, 'optionalAccess', _5 => _5.objectsById, 'access', _6 => _6.get, 'call', _7 => _7(objectId)]);
|
|
526
|
+
}
|
|
527
|
+
function getSchemaByNameFromContext(objectName) {
|
|
528
|
+
const ctx = getStorage().getStore();
|
|
529
|
+
return _optionalChain([ctx, 'optionalAccess', _8 => _8.objectsByName, 'access', _9 => _9.get, 'call', _10 => _10(objectName)]);
|
|
530
|
+
}
|
|
531
|
+
function hasSchemaContext() {
|
|
532
|
+
return getStorage().getStore() !== void 0;
|
|
533
|
+
}
|
|
534
|
+
function getSchemaContext() {
|
|
535
|
+
return getStorage().getStore();
|
|
536
|
+
}
|
|
537
|
+
function addSchemaToContext(schema) {
|
|
524
538
|
const ctx = getStorage().getStore();
|
|
539
|
+
if (!ctx) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
if (schema.id) {
|
|
543
|
+
ctx.objectsById.set(schema.id, schema);
|
|
544
|
+
}
|
|
545
|
+
ctx.objectsByName.set(schema.name, schema);
|
|
546
|
+
}
|
|
547
|
+
function buildSchemaContext(schemas) {
|
|
548
|
+
const objectsById = /* @__PURE__ */ new Map();
|
|
549
|
+
const objectsByName = /* @__PURE__ */ new Map();
|
|
550
|
+
for (const schema of schemas) {
|
|
551
|
+
if (schema.id) {
|
|
552
|
+
objectsById.set(schema.id, schema);
|
|
553
|
+
}
|
|
554
|
+
objectsByName.set(schema.name, schema);
|
|
555
|
+
}
|
|
556
|
+
return { objectsById, objectsByName };
|
|
557
|
+
}
|
|
558
|
+
function runWithSchemaContext(schemas, fn) {
|
|
559
|
+
const context = buildSchemaContext(schemas);
|
|
560
|
+
return getStorage().run(context, fn);
|
|
561
|
+
}
|
|
562
|
+
function runWithMergedSchemaContext(schemas, fn) {
|
|
563
|
+
const existing = getStorage().getStore();
|
|
564
|
+
const objectsById = new Map(_optionalChain([existing, 'optionalAccess', _11 => _11.objectsById]));
|
|
565
|
+
const objectsByName = new Map(_optionalChain([existing, 'optionalAccess', _12 => _12.objectsByName]));
|
|
566
|
+
for (const schema of schemas) {
|
|
567
|
+
if (schema.id) {
|
|
568
|
+
objectsById.set(schema.id, schema);
|
|
569
|
+
}
|
|
570
|
+
objectsByName.set(schema.name, schema);
|
|
571
|
+
}
|
|
572
|
+
const context = {
|
|
573
|
+
objectsById,
|
|
574
|
+
objectsByName
|
|
575
|
+
};
|
|
576
|
+
return getStorage().run(context, fn);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/runtime/context/tenant-context.ts
|
|
580
|
+
var browserStub2 = {
|
|
581
|
+
getStore: () => void 0,
|
|
582
|
+
run: (_store, callback) => callback()
|
|
583
|
+
};
|
|
584
|
+
var AsyncLocalStorageClass2 = null;
|
|
585
|
+
if (typeof process !== "undefined" && _optionalChain([process, 'access', _13 => _13.versions, 'optionalAccess', _14 => _14.node])) {
|
|
586
|
+
try {
|
|
587
|
+
if (typeof _chunk3RG5ZIWIjs.__require !== "undefined") {
|
|
588
|
+
const asyncHooks = _chunk3RG5ZIWIjs.__require.call(void 0, "async_hooks");
|
|
589
|
+
AsyncLocalStorageClass2 = asyncHooks.AsyncLocalStorage;
|
|
590
|
+
}
|
|
591
|
+
} catch (e6) {
|
|
592
|
+
try {
|
|
593
|
+
const dynamicRequire = new Function(
|
|
594
|
+
"m",
|
|
595
|
+
'return typeof require!=="undefined"?require(m):null'
|
|
596
|
+
);
|
|
597
|
+
const asyncHooks = dynamicRequire("node:async_hooks");
|
|
598
|
+
if (asyncHooks) {
|
|
599
|
+
AsyncLocalStorageClass2 = asyncHooks.AsyncLocalStorage;
|
|
600
|
+
}
|
|
601
|
+
} catch (e7) {
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
var storageInstance2 = null;
|
|
606
|
+
function getStorage2() {
|
|
607
|
+
if (storageInstance2 !== null) {
|
|
608
|
+
return storageInstance2;
|
|
609
|
+
}
|
|
610
|
+
if (AsyncLocalStorageClass2) {
|
|
611
|
+
storageInstance2 = new AsyncLocalStorageClass2();
|
|
612
|
+
return storageInstance2;
|
|
613
|
+
}
|
|
614
|
+
storageInstance2 = browserStub2;
|
|
615
|
+
return storageInstance2;
|
|
616
|
+
}
|
|
617
|
+
function getContext() {
|
|
618
|
+
const ctx = getStorage2().getStore();
|
|
525
619
|
if (!ctx) {
|
|
526
620
|
throw new TenantContextError();
|
|
527
621
|
}
|
|
@@ -534,11 +628,11 @@ function getUserId() {
|
|
|
534
628
|
return getContext().userId;
|
|
535
629
|
}
|
|
536
630
|
function hasContext() {
|
|
537
|
-
return
|
|
631
|
+
return getStorage2().getStore() !== void 0;
|
|
538
632
|
}
|
|
539
633
|
function runWithContext(context, fn) {
|
|
540
634
|
const frozenContext = Object.freeze({ ...context });
|
|
541
|
-
return
|
|
635
|
+
return getStorage2().run(frozenContext, fn);
|
|
542
636
|
}
|
|
543
637
|
function withTenantContext(tenantId, fn, userId) {
|
|
544
638
|
return runWithContext({ tenantId, userId }, fn);
|
|
@@ -919,9 +1013,9 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
919
1013
|
objectId,
|
|
920
1014
|
data,
|
|
921
1015
|
{
|
|
922
|
-
allowDraft: _optionalChain([options, 'optionalAccess',
|
|
923
|
-
validate: _optionalChain([options, 'optionalAccess',
|
|
924
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
1016
|
+
allowDraft: _optionalChain([options, 'optionalAccess', _15 => _15.allowDraft]),
|
|
1017
|
+
validate: _optionalChain([options, 'optionalAccess', _16 => _16.validate]),
|
|
1018
|
+
metadata: _optionalChain([options, 'optionalAccess', _17 => _17.metadata])
|
|
925
1019
|
}
|
|
926
1020
|
);
|
|
927
1021
|
if (this.state.raw) {
|
|
@@ -956,7 +1050,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
956
1050
|
data,
|
|
957
1051
|
{
|
|
958
1052
|
partial: true,
|
|
959
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
1053
|
+
metadata: _optionalChain([options, 'optionalAccess', _18 => _18.metadata])
|
|
960
1054
|
}
|
|
961
1055
|
);
|
|
962
1056
|
if (this.state.raw) {
|
|
@@ -1004,7 +1098,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
1004
1098
|
const existing = await this.findById(id);
|
|
1005
1099
|
if (existing) {
|
|
1006
1100
|
return this.eq("id", id).update(writeData, {
|
|
1007
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
1101
|
+
metadata: _optionalChain([options, 'optionalAccess', _19 => _19.metadata])
|
|
1008
1102
|
});
|
|
1009
1103
|
}
|
|
1010
1104
|
}
|
|
@@ -1013,10 +1107,10 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
1013
1107
|
};
|
|
1014
1108
|
function createQueryBuilder(recordService, adapter, objectName, options) {
|
|
1015
1109
|
const initialState = {};
|
|
1016
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1110
|
+
if (_optionalChain([options, 'optionalAccess', _20 => _20.tenantId])) {
|
|
1017
1111
|
initialState.tenantId = asTenantId(options.tenantId);
|
|
1018
1112
|
}
|
|
1019
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1113
|
+
if (_optionalChain([options, 'optionalAccess', _21 => _21.userId])) {
|
|
1020
1114
|
initialState.userId = asUserId(options.userId);
|
|
1021
1115
|
}
|
|
1022
1116
|
return new QueryBuilder(recordService, adapter, objectName, initialState);
|
|
@@ -1425,7 +1519,7 @@ var WorkflowDefinitionSchema = _zod.z.object({
|
|
|
1425
1519
|
).refine(
|
|
1426
1520
|
(def) => {
|
|
1427
1521
|
const startNode = def.nodes[def.startNodeId];
|
|
1428
|
-
return _optionalChain([startNode, 'optionalAccess',
|
|
1522
|
+
return _optionalChain([startNode, 'optionalAccess', _22 => _22.type]) === "start";
|
|
1429
1523
|
},
|
|
1430
1524
|
{
|
|
1431
1525
|
message: "startNodeId must reference a node of type 'start'"
|
|
@@ -1657,8 +1751,8 @@ function wait(reason, options) {
|
|
|
1657
1751
|
return {
|
|
1658
1752
|
status: "wait",
|
|
1659
1753
|
reason,
|
|
1660
|
-
requiredParticipationId: _optionalChain([options, 'optionalAccess',
|
|
1661
|
-
expiresAt: _optionalChain([options, 'optionalAccess',
|
|
1754
|
+
requiredParticipationId: _optionalChain([options, 'optionalAccess', _23 => _23.requiredParticipationId]),
|
|
1755
|
+
expiresAt: _optionalChain([options, 'optionalAccess', _24 => _24.expiresAt])
|
|
1662
1756
|
};
|
|
1663
1757
|
}
|
|
1664
1758
|
function complete(finalStatus) {
|
|
@@ -1843,9 +1937,9 @@ var FormExecutor = class {
|
|
|
1843
1937
|
const object2 = objects.find((o) => o.name === slot.objectName);
|
|
1844
1938
|
if (!object2) continue;
|
|
1845
1939
|
const attribute = object2.attributes.find((a) => a.name === fieldRef.attribute);
|
|
1846
|
-
if (!_optionalChain([attribute, 'optionalAccess',
|
|
1940
|
+
if (!_optionalChain([attribute, 'optionalAccess', _25 => _25.required])) continue;
|
|
1847
1941
|
const slotInput = input[fieldRef.slotId];
|
|
1848
|
-
const value = _optionalChain([slotInput, 'optionalAccess',
|
|
1942
|
+
const value = _optionalChain([slotInput, 'optionalAccess', _26 => _26[fieldRef.attribute]]);
|
|
1849
1943
|
if (value === void 0 || value === null || value === "") {
|
|
1850
1944
|
errors.push(
|
|
1851
1945
|
`Field "${_nullishCoalesce(attribute.label, () => ( fieldRef.attribute))}" is required for ${slot.label}`
|
|
@@ -2019,7 +2113,7 @@ function evaluateFormula(expression, values) {
|
|
|
2019
2113
|
try {
|
|
2020
2114
|
const parsed = formulaParser.parse(expression);
|
|
2021
2115
|
return parsed.evaluate(values);
|
|
2022
|
-
} catch (
|
|
2116
|
+
} catch (e8) {
|
|
2023
2117
|
return null;
|
|
2024
2118
|
}
|
|
2025
2119
|
}
|
|
@@ -2079,7 +2173,7 @@ function extractFormulaVariables(expression) {
|
|
|
2079
2173
|
try {
|
|
2080
2174
|
const parsed = formulaParser.parse(expression);
|
|
2081
2175
|
return parsed.variables();
|
|
2082
|
-
} catch (
|
|
2176
|
+
} catch (e9) {
|
|
2083
2177
|
return [];
|
|
2084
2178
|
}
|
|
2085
2179
|
}
|
|
@@ -2166,7 +2260,7 @@ async function parsePath(path, startSchema, getSchema, maxDepth = 5) {
|
|
|
2166
2260
|
}
|
|
2167
2261
|
if (attr.type === "relation") {
|
|
2168
2262
|
const relationAttr = attr;
|
|
2169
|
-
const targetObject = _optionalChain([relationAttr, 'access',
|
|
2263
|
+
const targetObject = _optionalChain([relationAttr, 'access', _27 => _27.targets, 'access', _28 => _28[0], 'optionalAccess', _29 => _29.object]);
|
|
2170
2264
|
if (!targetObject) {
|
|
2171
2265
|
throw new InvalidPathError(path, segmentName, "Relation has no target object");
|
|
2172
2266
|
}
|
|
@@ -2207,7 +2301,7 @@ async function validatePath(path, startSchema, getSchema, maxDepth = 5) {
|
|
|
2207
2301
|
try {
|
|
2208
2302
|
await parsePath(path, startSchema, getSchema, maxDepth);
|
|
2209
2303
|
return true;
|
|
2210
|
-
} catch (
|
|
2304
|
+
} catch (e10) {
|
|
2211
2305
|
return false;
|
|
2212
2306
|
}
|
|
2213
2307
|
}
|
|
@@ -2229,7 +2323,7 @@ function getRelationPath(path) {
|
|
|
2229
2323
|
|
|
2230
2324
|
// src/runtime/formula/path-traversal.ts
|
|
2231
2325
|
async function traversePath(record, path, startSchemaName, adapter, getSchema, options) {
|
|
2232
|
-
const maxDepth = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2326
|
+
const maxDepth = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.maxDepth]), () => ( 5));
|
|
2233
2327
|
const startSchema = await getSchema(startSchemaName);
|
|
2234
2328
|
if (!startSchema) {
|
|
2235
2329
|
return { values: [], recordCounts: [0] };
|
|
@@ -2315,8 +2409,14 @@ function formatCheckbox(value) {
|
|
|
2315
2409
|
function formatNumber(value, attribute) {
|
|
2316
2410
|
if (typeof value !== "number") return String(value);
|
|
2317
2411
|
const decimals = attribute.decimals;
|
|
2318
|
-
if (attribute.unit === "
|
|
2412
|
+
if (attribute.unit === "integer") {
|
|
2319
2413
|
return value.toLocaleString(void 0, {
|
|
2414
|
+
minimumFractionDigits: 0,
|
|
2415
|
+
maximumFractionDigits: 0
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
if (attribute.unit === "percentage") {
|
|
2419
|
+
return (value / 100).toLocaleString(void 0, {
|
|
2320
2420
|
style: "percent",
|
|
2321
2421
|
minimumFractionDigits: decimals,
|
|
2322
2422
|
maximumFractionDigits: decimals
|
|
@@ -2355,7 +2455,7 @@ function formatPhone(value) {
|
|
|
2355
2455
|
if (!("phoneNumber" in phone2)) return String(value);
|
|
2356
2456
|
if (phone2.countryCode) {
|
|
2357
2457
|
const country = _constants.getCountryByIso3.call(void 0, phone2.countryCode);
|
|
2358
|
-
const dial = _nullishCoalesce(_optionalChain([country, 'optionalAccess',
|
|
2458
|
+
const dial = _nullishCoalesce(_optionalChain([country, 'optionalAccess', _31 => _31.phoneCode]), () => ( ""));
|
|
2359
2459
|
return `${dial} ${phone2.phoneNumber}`.trim();
|
|
2360
2460
|
}
|
|
2361
2461
|
return phone2.phoneNumber;
|
|
@@ -2401,13 +2501,13 @@ function formatLocation(value, attribute) {
|
|
|
2401
2501
|
}
|
|
2402
2502
|
function formatSelect(value, attribute) {
|
|
2403
2503
|
if (typeof value !== "string") return String(value);
|
|
2404
|
-
const option = _optionalChain([attribute, 'access',
|
|
2405
|
-
return _nullishCoalesce(_optionalChain([option, 'optionalAccess',
|
|
2504
|
+
const option = _optionalChain([attribute, 'access', _32 => _32.options, 'optionalAccess', _33 => _33.find, 'call', _34 => _34((o) => o.value === value)]);
|
|
2505
|
+
return _nullishCoalesce(_optionalChain([option, 'optionalAccess', _35 => _35.label]), () => ( String(value)));
|
|
2406
2506
|
}
|
|
2407
2507
|
function formatMultiselect(value, attribute) {
|
|
2408
2508
|
if (!Array.isArray(value)) return String(value);
|
|
2409
2509
|
if (attribute.options) {
|
|
2410
|
-
const labels = value.map((v) => _optionalChain([attribute, 'access',
|
|
2510
|
+
const labels = value.map((v) => _optionalChain([attribute, 'access', _36 => _36.options, 'access', _37 => _37.find, 'call', _38 => _38((o) => o.value === v), 'optionalAccess', _39 => _39.label])).filter(Boolean);
|
|
2411
2511
|
return labels.join(", ");
|
|
2412
2512
|
}
|
|
2413
2513
|
return value.join(", ");
|
|
@@ -2853,7 +2953,7 @@ function createMockUserProfilesRepository(stores) {
|
|
|
2853
2953
|
list(options) {
|
|
2854
2954
|
const tenantId = getTenantId();
|
|
2855
2955
|
let results = Array.from(stores.userProfiles.values()).filter((p) => p.tenantId === tenantId);
|
|
2856
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2956
|
+
if (_optionalChain([options, 'optionalAccess', _40 => _40.limit])) {
|
|
2857
2957
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
2858
2958
|
}
|
|
2859
2959
|
return Promise.resolve(results);
|
|
@@ -2896,7 +2996,7 @@ function createMockFilesRepository(stores) {
|
|
|
2896
2996
|
return {
|
|
2897
2997
|
findById(id) {
|
|
2898
2998
|
const file2 = stores.files.get(id);
|
|
2899
|
-
if (_optionalChain([file2, 'optionalAccess',
|
|
2999
|
+
if (_optionalChain([file2, 'optionalAccess', _41 => _41.deletedAt])) return Promise.resolve(null);
|
|
2900
3000
|
return Promise.resolve(_nullishCoalesce(file2, () => ( null)));
|
|
2901
3001
|
},
|
|
2902
3002
|
create(data) {
|
|
@@ -2953,10 +3053,10 @@ function createMockFilesRepository(stores) {
|
|
|
2953
3053
|
let results = Array.from(stores.files.values()).filter(
|
|
2954
3054
|
(f) => f.tenantId === tenantId && !f.deletedAt
|
|
2955
3055
|
);
|
|
2956
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3056
|
+
if (_optionalChain([options, 'optionalAccess', _42 => _42.mimeType])) {
|
|
2957
3057
|
results = results.filter((f) => f.mimeType === options.mimeType);
|
|
2958
3058
|
}
|
|
2959
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3059
|
+
if (_optionalChain([options, 'optionalAccess', _43 => _43.limit])) {
|
|
2960
3060
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
2961
3061
|
}
|
|
2962
3062
|
return Promise.resolve(results);
|
|
@@ -3058,7 +3158,7 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3058
3158
|
(r) => r.tenantId === tenantId && r.objectId === objectId
|
|
3059
3159
|
);
|
|
3060
3160
|
const total = results.length;
|
|
3061
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3161
|
+
if (_optionalChain([options, 'optionalAccess', _44 => _44.limit])) {
|
|
3062
3162
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
3063
3163
|
}
|
|
3064
3164
|
const records = results.map(({ tenantId: _t, ...r }) => r);
|
|
@@ -3074,7 +3174,7 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3074
3174
|
);
|
|
3075
3175
|
});
|
|
3076
3176
|
const total = results.length;
|
|
3077
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3177
|
+
if (_optionalChain([options, 'optionalAccess', _45 => _45.limit])) {
|
|
3078
3178
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
3079
3179
|
}
|
|
3080
3180
|
const records = results.map(({ tenantId: _t, ...r }) => r);
|
|
@@ -3090,7 +3190,7 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3090
3190
|
}
|
|
3091
3191
|
}
|
|
3092
3192
|
const allowedObjectIds = /* @__PURE__ */ new Set();
|
|
3093
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3193
|
+
if (_optionalChain([options, 'optionalAccess', _46 => _46.objectNames]) && options.objectNames.length > 0) {
|
|
3094
3194
|
for (const obj of objectsMap.values()) {
|
|
3095
3195
|
if (options.objectNames.includes(obj.name)) {
|
|
3096
3196
|
allowedObjectIds.add(obj.id);
|
|
@@ -3109,7 +3209,7 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3109
3209
|
);
|
|
3110
3210
|
});
|
|
3111
3211
|
const total = matchingRecords.length;
|
|
3112
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3212
|
+
if (_optionalChain([options, 'optionalAccess', _47 => _47.limit])) {
|
|
3113
3213
|
matchingRecords = matchingRecords.slice(
|
|
3114
3214
|
_nullishCoalesce(options.offset, () => ( 0)),
|
|
3115
3215
|
(_nullishCoalesce(options.offset, () => ( 0))) + options.limit
|
|
@@ -3120,11 +3220,11 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3120
3220
|
if (!attributesByObjectId.has(attr.objectId)) {
|
|
3121
3221
|
attributesByObjectId.set(attr.objectId, []);
|
|
3122
3222
|
}
|
|
3123
|
-
_optionalChain([attributesByObjectId, 'access',
|
|
3223
|
+
_optionalChain([attributesByObjectId, 'access', _48 => _48.get, 'call', _49 => _49(attr.objectId), 'optionalAccess', _50 => _50.push, 'call', _51 => _51(attr)]);
|
|
3124
3224
|
}
|
|
3125
3225
|
const results = matchingRecords.map((r) => {
|
|
3126
3226
|
const obj = objectsMap.get(r.objectId);
|
|
3127
|
-
const labelExpression = _nullishCoalesce(_optionalChain([obj, 'optionalAccess',
|
|
3227
|
+
const labelExpression = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _52 => _52.labelExpression]), () => ( "{{ name }}"));
|
|
3128
3228
|
const dbAttrs = _nullishCoalesce(attributesByObjectId.get(r.objectId), () => ( []));
|
|
3129
3229
|
const attrs = dbAttrs.map((a) => ({
|
|
3130
3230
|
...a.config,
|
|
@@ -3137,8 +3237,8 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3137
3237
|
const enrichedValues = enrichValuesForDisplay(r.values, attrs);
|
|
3138
3238
|
return {
|
|
3139
3239
|
objectId: r.objectId,
|
|
3140
|
-
objectName: _nullishCoalesce(_optionalChain([obj, 'optionalAccess',
|
|
3141
|
-
objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess',
|
|
3240
|
+
objectName: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _53 => _53.name]), () => ( "unknown")),
|
|
3241
|
+
objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _54 => _54.label]), () => ( "Unknown")),
|
|
3142
3242
|
label: renderLabelExpression(labelExpression, enrichedValues),
|
|
3143
3243
|
recordId: r.id,
|
|
3144
3244
|
values: r.values,
|
|
@@ -3200,11 +3300,11 @@ function createMockObjectRecordsRepository(stores) {
|
|
|
3200
3300
|
}
|
|
3201
3301
|
return Promise.resolve(updated);
|
|
3202
3302
|
},
|
|
3203
|
-
async batchRefreshLabels(objectId,
|
|
3303
|
+
async batchRefreshLabels(objectId, computeLabel2) {
|
|
3204
3304
|
let updated = 0;
|
|
3205
3305
|
for (const record of stores.objectRecords.values()) {
|
|
3206
3306
|
if (record.objectId === objectId) {
|
|
3207
|
-
const newLabel = await
|
|
3307
|
+
const newLabel = await computeLabel2(record.values);
|
|
3208
3308
|
if (newLabel !== record.label) {
|
|
3209
3309
|
record.label = newLabel;
|
|
3210
3310
|
record.updatedAt = /* @__PURE__ */ new Date();
|
|
@@ -3403,7 +3503,7 @@ function createMockPermissionsRepository(stores) {
|
|
|
3403
3503
|
},
|
|
3404
3504
|
deleteRole(roleId) {
|
|
3405
3505
|
const role = stores.roles.get(roleId);
|
|
3406
|
-
if (_optionalChain([role, 'optionalAccess',
|
|
3506
|
+
if (_optionalChain([role, 'optionalAccess', _55 => _55.system])) {
|
|
3407
3507
|
return Promise.reject(new Error(`Cannot delete system role ${roleId}`));
|
|
3408
3508
|
}
|
|
3409
3509
|
stores.roles.delete(roleId);
|
|
@@ -3645,7 +3745,7 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
3645
3745
|
(i) => i.tenant_id === tenantId
|
|
3646
3746
|
);
|
|
3647
3747
|
const total = results.length;
|
|
3648
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3748
|
+
if (_optionalChain([options, 'optionalAccess', _56 => _56.limit])) {
|
|
3649
3749
|
results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
|
|
3650
3750
|
}
|
|
3651
3751
|
return Promise.resolve({ instances: results, total });
|
|
@@ -3673,7 +3773,7 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
3673
3773
|
pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
|
|
3674
3774
|
error: null,
|
|
3675
3775
|
started_by: data.startedBy,
|
|
3676
|
-
expires_at: _nullishCoalesce(_optionalChain([data, 'access',
|
|
3776
|
+
expires_at: _nullishCoalesce(_optionalChain([data, 'access', _57 => _57.expiresAt, 'optionalAccess', _58 => _58.toISOString, 'call', _59 => _59()]), () => ( null)),
|
|
3677
3777
|
created_at: now,
|
|
3678
3778
|
updated_at: now,
|
|
3679
3779
|
completed_at: null
|
|
@@ -3694,8 +3794,8 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
3694
3794
|
history: _nullishCoalesce(data.history, () => ( existing.history)),
|
|
3695
3795
|
pending_action: data.pendingAction !== void 0 ? data.pendingAction : existing.pending_action,
|
|
3696
3796
|
error: data.error !== void 0 ? data.error : existing.error,
|
|
3697
|
-
expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
3698
|
-
completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
3797
|
+
expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _60 => _60.expiresAt, 'optionalAccess', _61 => _61.toISOString, 'call', _62 => _62()]), () => ( null)) : existing.expires_at,
|
|
3798
|
+
completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _63 => _63.completedAt, 'optionalAccess', _64 => _64.toISOString, 'call', _65 => _65()]), () => ( null)) : existing.completed_at,
|
|
3699
3799
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3700
3800
|
};
|
|
3701
3801
|
stores.workflowInstances.set(id, updated);
|
|
@@ -3728,7 +3828,7 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
3728
3828
|
pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
|
|
3729
3829
|
error: null,
|
|
3730
3830
|
started_by: data.startedBy,
|
|
3731
|
-
expires_at: _nullishCoalesce(_optionalChain([data, 'access',
|
|
3831
|
+
expires_at: _nullishCoalesce(_optionalChain([data, 'access', _66 => _66.expiresAt, 'optionalAccess', _67 => _67.toISOString, 'call', _68 => _68()]), () => ( null)),
|
|
3732
3832
|
created_at: now,
|
|
3733
3833
|
updated_at: now,
|
|
3734
3834
|
completed_at: null
|
|
@@ -3751,13 +3851,13 @@ function createMockWorkflowInstancesRepository(stores) {
|
|
|
3751
3851
|
return slotData.id === recordId;
|
|
3752
3852
|
});
|
|
3753
3853
|
});
|
|
3754
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3854
|
+
if (_optionalChain([options, 'optionalAccess', _69 => _69.status])) {
|
|
3755
3855
|
results = results.filter((i) => i.status === options.status);
|
|
3756
3856
|
}
|
|
3757
3857
|
const total = results.length;
|
|
3758
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3759
|
-
const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3760
|
-
const end = _optionalChain([options, 'optionalAccess',
|
|
3858
|
+
if (_optionalChain([options, 'optionalAccess', _70 => _70.offset]) !== void 0 || _optionalChain([options, 'optionalAccess', _71 => _71.limit]) !== void 0) {
|
|
3859
|
+
const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _72 => _72.offset]), () => ( 0));
|
|
3860
|
+
const end = _optionalChain([options, 'optionalAccess', _73 => _73.limit]) ? start + options.limit : void 0;
|
|
3761
3861
|
results = results.slice(start, end);
|
|
3762
3862
|
}
|
|
3763
3863
|
return Promise.resolve({ instances: results, total });
|
|
@@ -3820,8 +3920,8 @@ function createMockWorkflowParticipationsRepository(stores) {
|
|
|
3820
3920
|
...existing,
|
|
3821
3921
|
status: _nullishCoalesce(data.status, () => ( existing.status)),
|
|
3822
3922
|
auth: _nullishCoalesce(data.auth, () => ( existing.auth)),
|
|
3823
|
-
authenticated_at: data.authenticatedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
3824
|
-
last_activity_at: data.lastActivityAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access',
|
|
3923
|
+
authenticated_at: data.authenticatedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _74 => _74.authenticatedAt, 'optionalAccess', _75 => _75.toISOString, 'call', _76 => _76()]), () => ( null)) : existing.authenticated_at,
|
|
3924
|
+
last_activity_at: data.lastActivityAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _77 => _77.lastActivityAt, 'optionalAccess', _78 => _78.toISOString, 'call', _79 => _79()]), () => ( null)) : existing.last_activity_at,
|
|
3825
3925
|
completed_node_ids: _nullishCoalesce(data.completedNodeIds, () => ( existing.completed_node_ids)),
|
|
3826
3926
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3827
3927
|
};
|
|
@@ -4008,7 +4108,7 @@ var notesPolicy = {
|
|
|
4008
4108
|
{ attribute: "visibility", operator: "is", value: "shared" },
|
|
4009
4109
|
{ attribute: "createdBy", operator: "is", value: ctx.userId }
|
|
4010
4110
|
];
|
|
4011
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
4111
|
+
if (!_optionalChain([options, 'optionalAccess', _80 => _80.filters]) || options.filters.rules.length === 0) {
|
|
4012
4112
|
return {
|
|
4013
4113
|
...options,
|
|
4014
4114
|
filters: { combinator: "or", rules: visibilityRules }
|
|
@@ -4122,6 +4222,20 @@ var TenantAwareRepository = class {
|
|
|
4122
4222
|
return getUserId();
|
|
4123
4223
|
}
|
|
4124
4224
|
};
|
|
4225
|
+
var SchemaContextAwareRepository = class extends TenantAwareRepository {
|
|
4226
|
+
/**
|
|
4227
|
+
* Get an ObjectDefinition from context by its ID.
|
|
4228
|
+
*/
|
|
4229
|
+
getSchemaFromContext(objectId) {
|
|
4230
|
+
return getSchemaFromContext(objectId);
|
|
4231
|
+
}
|
|
4232
|
+
/**
|
|
4233
|
+
* Get an ObjectDefinition from context by its name.
|
|
4234
|
+
*/
|
|
4235
|
+
getSchemaByNameFromContext(objectName) {
|
|
4236
|
+
return getSchemaByNameFromContext(objectName);
|
|
4237
|
+
}
|
|
4238
|
+
};
|
|
4125
4239
|
|
|
4126
4240
|
// src/runtime/services/audit.service.ts
|
|
4127
4241
|
var SENSITIVE_PATTERNS = [
|
|
@@ -4146,7 +4260,7 @@ var AuditService = class extends TenantAwareService {
|
|
|
4146
4260
|
this.isFlushing = false;
|
|
4147
4261
|
/** Pending flush promise to allow waiting on concurrent flush */
|
|
4148
4262
|
this.flushPromise = null;
|
|
4149
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4263
|
+
if (_optionalChain([options, 'optionalAccess', _81 => _81.async]) && options.flushIntervalMs) {
|
|
4150
4264
|
this.startFlushTimer();
|
|
4151
4265
|
}
|
|
4152
4266
|
}
|
|
@@ -4343,7 +4457,7 @@ var AuditService = class extends TenantAwareService {
|
|
|
4343
4457
|
if (!this.adapter.audit) {
|
|
4344
4458
|
return;
|
|
4345
4459
|
}
|
|
4346
|
-
if (_optionalChain([this, 'access',
|
|
4460
|
+
if (_optionalChain([this, 'access', _82 => _82.options, 'optionalAccess', _83 => _83.async])) {
|
|
4347
4461
|
this.buffer.push(entry);
|
|
4348
4462
|
const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
|
|
4349
4463
|
if (this.buffer.length >= batchSize) {
|
|
@@ -4357,7 +4471,7 @@ var AuditService = class extends TenantAwareService {
|
|
|
4357
4471
|
* Start the flush timer for async mode
|
|
4358
4472
|
*/
|
|
4359
4473
|
startFlushTimer() {
|
|
4360
|
-
const intervalMs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
4474
|
+
const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _84 => _84.options, 'optionalAccess', _85 => _85.flushIntervalMs]), () => ( 1e3));
|
|
4361
4475
|
this.flushTimer = setInterval(() => {
|
|
4362
4476
|
this.flush().catch(console.error);
|
|
4363
4477
|
}, intervalMs);
|
|
@@ -4385,7 +4499,7 @@ var FileService = class extends TenantAwareService {
|
|
|
4385
4499
|
constructor(adapter, options) {
|
|
4386
4500
|
super();
|
|
4387
4501
|
this.adapter = adapter;
|
|
4388
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4502
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _86 => _86.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
4389
4503
|
}
|
|
4390
4504
|
// ============================================================================
|
|
4391
4505
|
// UPLOAD (requires StorageAdapter)
|
|
@@ -4517,7 +4631,7 @@ var FileService = class extends TenantAwareService {
|
|
|
4517
4631
|
*/
|
|
4518
4632
|
async getFile(fileId) {
|
|
4519
4633
|
const file2 = await this.adapter.files.findById(fileId);
|
|
4520
|
-
if (_optionalChain([file2, 'optionalAccess',
|
|
4634
|
+
if (_optionalChain([file2, 'optionalAccess', _87 => _87.deletedAt])) {
|
|
4521
4635
|
return null;
|
|
4522
4636
|
}
|
|
4523
4637
|
return file2;
|
|
@@ -4579,12 +4693,12 @@ var FileService = class extends TenantAwareService {
|
|
|
4579
4693
|
*/
|
|
4580
4694
|
async deleteFile(fileId, options) {
|
|
4581
4695
|
const file2 = await this.getFileOrThrow(fileId);
|
|
4582
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4696
|
+
if (_optionalChain([options, 'optionalAccess', _88 => _88.checkOwnership]) && options.userId) {
|
|
4583
4697
|
if (file2.uploadedBy !== options.userId) {
|
|
4584
4698
|
throw new Error("You can only delete files you uploaded");
|
|
4585
4699
|
}
|
|
4586
4700
|
}
|
|
4587
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4701
|
+
if (_optionalChain([options, 'optionalAccess', _89 => _89.hard])) {
|
|
4588
4702
|
await this.adapter.files.hardDelete(fileId);
|
|
4589
4703
|
} else {
|
|
4590
4704
|
await this.adapter.files.delete(fileId);
|
|
@@ -4615,7 +4729,7 @@ var FileService = class extends TenantAwareService {
|
|
|
4615
4729
|
}
|
|
4616
4730
|
const file2 = await this.getFileOrThrow(fileId);
|
|
4617
4731
|
await this.adapter.storage.delete(file2.storagePath);
|
|
4618
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4732
|
+
if (_optionalChain([options, 'optionalAccess', _90 => _90.hard])) {
|
|
4619
4733
|
await this.adapter.files.hardDelete(fileId);
|
|
4620
4734
|
} else {
|
|
4621
4735
|
await this.adapter.files.delete(fileId);
|
|
@@ -4642,10 +4756,10 @@ var FileService = class extends TenantAwareService {
|
|
|
4642
4756
|
if (!file2) {
|
|
4643
4757
|
continue;
|
|
4644
4758
|
}
|
|
4645
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4759
|
+
if (_optionalChain([options, 'optionalAccess', _91 => _91.deleteFromStorage]) && this.adapter.storage) {
|
|
4646
4760
|
await this.adapter.storage.delete(file2.storagePath);
|
|
4647
4761
|
}
|
|
4648
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4762
|
+
if (_optionalChain([options, 'optionalAccess', _92 => _92.hard])) {
|
|
4649
4763
|
await this.adapter.files.hardDelete(fileId);
|
|
4650
4764
|
} else {
|
|
4651
4765
|
await this.adapter.files.delete(fileId);
|
|
@@ -4656,7 +4770,7 @@ var FileService = class extends TenantAwareService {
|
|
|
4656
4770
|
actorId: this.userId,
|
|
4657
4771
|
fileId,
|
|
4658
4772
|
fileName: file2.name,
|
|
4659
|
-
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4773
|
+
metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _93 => _93.deleteFromStorage]), () => ( false)) }
|
|
4660
4774
|
});
|
|
4661
4775
|
}
|
|
4662
4776
|
}
|
|
@@ -4740,7 +4854,7 @@ var FileService = class extends TenantAwareService {
|
|
|
4740
4854
|
return true;
|
|
4741
4855
|
}
|
|
4742
4856
|
if (file2.visibility === "restricted") {
|
|
4743
|
-
return _nullishCoalesce(_optionalChain([file2, 'access',
|
|
4857
|
+
return _nullishCoalesce(_optionalChain([file2, 'access', _94 => _94.allowedUsers, 'optionalAccess', _95 => _95.includes, 'call', _96 => _96(userId)]), () => ( false));
|
|
4744
4858
|
}
|
|
4745
4859
|
return false;
|
|
4746
4860
|
}
|
|
@@ -4895,10 +5009,10 @@ var GlobalSearchService = class extends TenantAwareService {
|
|
|
4895
5009
|
return { results: [], total: 0 };
|
|
4896
5010
|
}
|
|
4897
5011
|
return await this.adapter.objectRecords.globalSearch(query.trim(), {
|
|
4898
|
-
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4899
|
-
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4900
|
-
objectNames: _optionalChain([options, 'optionalAccess',
|
|
4901
|
-
includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5012
|
+
limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.limit]), () => ( 20)),
|
|
5013
|
+
offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _98 => _98.offset]), () => ( 0)),
|
|
5014
|
+
objectNames: _optionalChain([options, 'optionalAccess', _99 => _99.objectNames]),
|
|
5015
|
+
includeObjectInfo: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _100 => _100.includeObjectInfo]), () => ( true))
|
|
4902
5016
|
});
|
|
4903
5017
|
}
|
|
4904
5018
|
/**
|
|
@@ -5015,17 +5129,17 @@ function validateOptions(options, attributeName) {
|
|
|
5015
5129
|
const ids = /* @__PURE__ */ new Set();
|
|
5016
5130
|
const values = /* @__PURE__ */ new Set();
|
|
5017
5131
|
for (const option of options) {
|
|
5018
|
-
if (!_optionalChain([option, 'access',
|
|
5132
|
+
if (!_optionalChain([option, 'access', _101 => _101.id, 'optionalAccess', _102 => _102.trim, 'call', _103 => _103()])) {
|
|
5019
5133
|
throw new Error(
|
|
5020
5134
|
`[AttributeBuilder] Option in "${attributeName}" has an empty or missing id.`
|
|
5021
5135
|
);
|
|
5022
5136
|
}
|
|
5023
|
-
if (!_optionalChain([option, 'access',
|
|
5137
|
+
if (!_optionalChain([option, 'access', _104 => _104.value, 'optionalAccess', _105 => _105.trim, 'call', _106 => _106()])) {
|
|
5024
5138
|
throw new Error(
|
|
5025
5139
|
`[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing value.`
|
|
5026
5140
|
);
|
|
5027
5141
|
}
|
|
5028
|
-
if (!_optionalChain([option, 'access',
|
|
5142
|
+
if (!_optionalChain([option, 'access', _107 => _107.label, 'optionalAccess', _108 => _108.trim, 'call', _109 => _109()])) {
|
|
5029
5143
|
throw new Error(
|
|
5030
5144
|
`[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing label.`
|
|
5031
5145
|
);
|
|
@@ -5546,7 +5660,7 @@ var SingleRelationAttributeBuilder = class extends BaseAttributeBuilder {
|
|
|
5546
5660
|
object: objectName,
|
|
5547
5661
|
...options
|
|
5548
5662
|
};
|
|
5549
|
-
_optionalChain([this, 'access',
|
|
5663
|
+
_optionalChain([this, 'access', _110 => _110.attr, 'access', _111 => _111.targets, 'optionalAccess', _112 => _112.push, 'call', _113 => _113(target)]);
|
|
5550
5664
|
return this;
|
|
5551
5665
|
}
|
|
5552
5666
|
/**
|
|
@@ -5591,9 +5705,9 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
|
|
|
5591
5705
|
constructor(name, label, initOptions) {
|
|
5592
5706
|
super("relation", name, label);
|
|
5593
5707
|
this.attr.cardinality = "many";
|
|
5594
|
-
this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess',
|
|
5708
|
+
this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _114 => _114.targets]), () => ( []));
|
|
5595
5709
|
this.attr.defaultValue = [];
|
|
5596
|
-
if (_optionalChain([initOptions, 'optionalAccess',
|
|
5710
|
+
if (_optionalChain([initOptions, 'optionalAccess', _115 => _115.isRequired])) {
|
|
5597
5711
|
this.setRequired(true);
|
|
5598
5712
|
}
|
|
5599
5713
|
}
|
|
@@ -5607,7 +5721,7 @@ var MultiRelationAttributeBuilder = class extends BaseAttributeBuilder {
|
|
|
5607
5721
|
object: objectName,
|
|
5608
5722
|
...options
|
|
5609
5723
|
};
|
|
5610
|
-
_optionalChain([this, 'access',
|
|
5724
|
+
_optionalChain([this, 'access', _116 => _116.attr, 'access', _117 => _117.targets, 'optionalAccess', _118 => _118.push, 'call', _119 => _119(target)]);
|
|
5611
5725
|
return this;
|
|
5612
5726
|
}
|
|
5613
5727
|
/**
|
|
@@ -5981,7 +6095,7 @@ var GroupBuilder = class {
|
|
|
5981
6095
|
*/
|
|
5982
6096
|
fields(...names) {
|
|
5983
6097
|
for (const name of names) {
|
|
5984
|
-
_optionalChain([this, 'access',
|
|
6098
|
+
_optionalChain([this, 'access', _120 => _120.data, 'access', _121 => _121.fields, 'optionalAccess', _122 => _122.push, 'call', _123 => _123({ attribute: name })]);
|
|
5985
6099
|
}
|
|
5986
6100
|
return this;
|
|
5987
6101
|
}
|
|
@@ -5990,7 +6104,7 @@ var GroupBuilder = class {
|
|
|
5990
6104
|
* @example .field("name", { span: 8, readOnly: true })
|
|
5991
6105
|
*/
|
|
5992
6106
|
field(attribute, options) {
|
|
5993
|
-
_optionalChain([this, 'access',
|
|
6107
|
+
_optionalChain([this, 'access', _124 => _124.data, 'access', _125 => _125.fields, 'optionalAccess', _126 => _126.push, 'call', _127 => _127({ attribute, ...options })]);
|
|
5994
6108
|
return this;
|
|
5995
6109
|
}
|
|
5996
6110
|
/**
|
|
@@ -5999,7 +6113,7 @@ var GroupBuilder = class {
|
|
|
5999
6113
|
* @example .attributeGroup({ id: "address", label: "Address", attributes: ["street", "city", "postal_code"], displayTemplate: "{street}, {city}" })
|
|
6000
6114
|
*/
|
|
6001
6115
|
attributeGroup(config, options) {
|
|
6002
|
-
_optionalChain([this, 'access',
|
|
6116
|
+
_optionalChain([this, 'access', _128 => _128.data, 'access', _129 => _129.fields, 'optionalAccess', _130 => _130.push, 'call', _131 => _131({ attributeGroup: config, ...options })]);
|
|
6003
6117
|
return this;
|
|
6004
6118
|
}
|
|
6005
6119
|
/**
|
|
@@ -6491,14 +6605,14 @@ var ViewBuilder = class {
|
|
|
6491
6605
|
* Add a pre-built tab
|
|
6492
6606
|
*/
|
|
6493
6607
|
addTab(tab) {
|
|
6494
|
-
_optionalChain([this, 'access',
|
|
6608
|
+
_optionalChain([this, 'access', _132 => _132.data, 'access', _133 => _133.tabs, 'optionalAccess', _134 => _134.push, 'call', _135 => _135(tab)]);
|
|
6495
6609
|
return this;
|
|
6496
6610
|
}
|
|
6497
6611
|
/**
|
|
6498
6612
|
* @internal Used by TabBuilder to add tabs
|
|
6499
6613
|
*/
|
|
6500
6614
|
_addTab(tab) {
|
|
6501
|
-
_optionalChain([this, 'access',
|
|
6615
|
+
_optionalChain([this, 'access', _136 => _136.data, 'access', _137 => _137.tabs, 'optionalAccess', _138 => _138.push, 'call', _139 => _139(tab)]);
|
|
6502
6616
|
return this;
|
|
6503
6617
|
}
|
|
6504
6618
|
/**
|
|
@@ -6576,8 +6690,8 @@ var WorkflowFormRowBuilder = class {
|
|
|
6576
6690
|
id: `${this.rowData.id}-${slotId}-${attribute}`,
|
|
6577
6691
|
slotId,
|
|
6578
6692
|
attribute,
|
|
6579
|
-
label: _optionalChain([options, 'optionalAccess',
|
|
6580
|
-
required: _optionalChain([options, 'optionalAccess',
|
|
6693
|
+
label: _optionalChain([options, 'optionalAccess', _140 => _140.label]),
|
|
6694
|
+
required: _optionalChain([options, 'optionalAccess', _141 => _141.required])
|
|
6581
6695
|
};
|
|
6582
6696
|
this.rowData.fields.push(field);
|
|
6583
6697
|
return this;
|
|
@@ -6942,7 +7056,7 @@ var WorkflowBuilder = class {
|
|
|
6942
7056
|
* @param options - Slot configuration
|
|
6943
7057
|
*/
|
|
6944
7058
|
slot(id, objectName, options) {
|
|
6945
|
-
if (_optionalChain([this, 'access',
|
|
7059
|
+
if (_optionalChain([this, 'access', _142 => _142.data, 'access', _143 => _143.slots, 'optionalAccess', _144 => _144.some, 'call', _145 => _145((s) => s.id === id)])) {
|
|
6946
7060
|
throw new Error(`[WorkflowBuilder] Duplicate slot id: "${id}"`);
|
|
6947
7061
|
}
|
|
6948
7062
|
const slot = {
|
|
@@ -6953,7 +7067,7 @@ var WorkflowBuilder = class {
|
|
|
6953
7067
|
color: options.color,
|
|
6954
7068
|
icon: options.icon
|
|
6955
7069
|
};
|
|
6956
|
-
_optionalChain([this, 'access',
|
|
7070
|
+
_optionalChain([this, 'access', _146 => _146.data, 'access', _147 => _147.slots, 'optionalAccess', _148 => _148.push, 'call', _149 => _149(slot)]);
|
|
6957
7071
|
return this;
|
|
6958
7072
|
}
|
|
6959
7073
|
// ============================================================================
|
|
@@ -6967,7 +7081,7 @@ var WorkflowBuilder = class {
|
|
|
6967
7081
|
}
|
|
6968
7082
|
/** @internal */
|
|
6969
7083
|
_addParticipant(template) {
|
|
6970
|
-
_optionalChain([this, 'access',
|
|
7084
|
+
_optionalChain([this, 'access', _150 => _150.data, 'access', _151 => _151.participants, 'optionalAccess', _152 => _152.push, 'call', _153 => _153(template)]);
|
|
6971
7085
|
return this;
|
|
6972
7086
|
}
|
|
6973
7087
|
// ============================================================================
|
|
@@ -7100,7 +7214,7 @@ var WorkflowBuilder = class {
|
|
|
7100
7214
|
}
|
|
7101
7215
|
}
|
|
7102
7216
|
validateSlotReferences() {
|
|
7103
|
-
const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access',
|
|
7217
|
+
const slotIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _154 => _154.data, 'access', _155 => _155.slots, 'optionalAccess', _156 => _156.map, 'call', _157 => _157((s) => s.id)]), () => ( [])));
|
|
7104
7218
|
for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
|
|
7105
7219
|
if (node.type === "form") {
|
|
7106
7220
|
const referencedSlots = /* @__PURE__ */ new Set();
|
|
@@ -7127,7 +7241,7 @@ var WorkflowBuilder = class {
|
|
|
7127
7241
|
}
|
|
7128
7242
|
}
|
|
7129
7243
|
validateParticipantReferences() {
|
|
7130
|
-
const participantIds = new Set(_nullishCoalesce(_optionalChain([this, 'access',
|
|
7244
|
+
const participantIds = new Set(_nullishCoalesce(_optionalChain([this, 'access', _158 => _158.data, 'access', _159 => _159.participants, 'optionalAccess', _160 => _160.map, 'call', _161 => _161((p) => p.id)]), () => ( [])));
|
|
7131
7245
|
for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
|
|
7132
7246
|
if (node.type === "form" && node.participantId) {
|
|
7133
7247
|
if (!participantIds.has(node.participantId)) {
|
|
@@ -7773,7 +7887,7 @@ function validateObject(objectDef, data) {
|
|
|
7773
7887
|
function validateObjectOrThrow(objectDef, data) {
|
|
7774
7888
|
const result = validateObject(objectDef, data);
|
|
7775
7889
|
if (!result.success) {
|
|
7776
|
-
const errorMessages = _optionalChain([result, 'access',
|
|
7890
|
+
const errorMessages = _optionalChain([result, 'access', _162 => _162.errors, 'optionalAccess', _163 => _163.map, 'call', _164 => _164((err) => `${err.path.join(".")}: ${err.message}`), 'access', _165 => _165.join, 'call', _166 => _166("\n")]) || "Unknown validation error";
|
|
7777
7891
|
throw new Error(`Validation failed for ${objectDef.label}:
|
|
7778
7892
|
${errorMessages}`);
|
|
7779
7893
|
}
|
|
@@ -7807,7 +7921,7 @@ function validateDraft(objectDef, data) {
|
|
|
7807
7921
|
function validateDraftOrThrow(objectDef, data) {
|
|
7808
7922
|
const result = validateDraft(objectDef, data);
|
|
7809
7923
|
if (!result.success) {
|
|
7810
|
-
const errorMessages = _optionalChain([result, 'access',
|
|
7924
|
+
const errorMessages = _optionalChain([result, 'access', _167 => _167.errors, 'optionalAccess', _168 => _168.map, 'call', _169 => _169((err) => `${err.path.join(".")}: ${err.message}`), 'access', _170 => _170.join, 'call', _171 => _171("\n")]) || "Unknown validation error";
|
|
7811
7925
|
throw new Error(`Draft validation failed for ${objectDef.label}:
|
|
7812
7926
|
${errorMessages}`);
|
|
7813
7927
|
}
|
|
@@ -7849,8 +7963,8 @@ var ObjectSchemaService = class extends TenantAwareService {
|
|
|
7849
7963
|
super();
|
|
7850
7964
|
this.adapter = adapter;
|
|
7851
7965
|
this.nativeRegistry = nativeRegistry;
|
|
7852
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
7853
|
-
this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7966
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _172 => _172.auditService]);
|
|
7967
|
+
this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _173 => _173.cache]), () => ( adapter.cache));
|
|
7854
7968
|
}
|
|
7855
7969
|
/**
|
|
7856
7970
|
* Create a new custom object.
|
|
@@ -8048,7 +8162,7 @@ var ObjectSchemaService = class extends TenantAwareService {
|
|
|
8048
8162
|
resourceType: "attribute",
|
|
8049
8163
|
resourceId: attributeId,
|
|
8050
8164
|
resourceLabel: updatedDbAttr.label,
|
|
8051
|
-
objectName: _optionalChain([dbObject, 'optionalAccess',
|
|
8165
|
+
objectName: _optionalChain([dbObject, 'optionalAccess', _174 => _174.name]),
|
|
8052
8166
|
objectId: dbAttr.objectId,
|
|
8053
8167
|
changes
|
|
8054
8168
|
});
|
|
@@ -8081,7 +8195,7 @@ var ObjectSchemaService = class extends TenantAwareService {
|
|
|
8081
8195
|
);
|
|
8082
8196
|
}
|
|
8083
8197
|
const dbObject = await this.adapter.objects.findById(dbAttr.objectId);
|
|
8084
|
-
if (_optionalChain([dbObject, 'optionalAccess',
|
|
8198
|
+
if (_optionalChain([dbObject, 'optionalAccess', _175 => _175.labelExpression])) {
|
|
8085
8199
|
const usedAttributes = extractAttributeNames(dbObject.labelExpression);
|
|
8086
8200
|
if (usedAttributes.includes(dbAttr.name)) {
|
|
8087
8201
|
throw new AttributeInUseError(dbAttr.name, "labelExpression");
|
|
@@ -8097,7 +8211,7 @@ var ObjectSchemaService = class extends TenantAwareService {
|
|
|
8097
8211
|
resourceType: "attribute",
|
|
8098
8212
|
resourceId: attributeId,
|
|
8099
8213
|
resourceLabel: dbAttr.label,
|
|
8100
|
-
objectName: _optionalChain([dbObject, 'optionalAccess',
|
|
8214
|
+
objectName: _optionalChain([dbObject, 'optionalAccess', _176 => _176.name]),
|
|
8101
8215
|
objectId: dbAttr.objectId
|
|
8102
8216
|
});
|
|
8103
8217
|
}
|
|
@@ -8112,9 +8226,9 @@ var ObjectSchemaService = class extends TenantAwareService {
|
|
|
8112
8226
|
async listAttributes(objectId, options) {
|
|
8113
8227
|
const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
|
|
8114
8228
|
let filtered = dbAttributes;
|
|
8115
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
8229
|
+
if (_optionalChain([options, 'optionalAccess', _177 => _177.systemOnly])) {
|
|
8116
8230
|
filtered = dbAttributes.filter((attr) => attr.system);
|
|
8117
|
-
} else if (_optionalChain([options, 'optionalAccess',
|
|
8231
|
+
} else if (_optionalChain([options, 'optionalAccess', _178 => _178.customOnly])) {
|
|
8118
8232
|
filtered = dbAttributes.filter((attr) => !attr.system);
|
|
8119
8233
|
}
|
|
8120
8234
|
return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
|
|
@@ -8150,14 +8264,14 @@ var ObjectSchemaService = class extends TenantAwareService {
|
|
|
8150
8264
|
pluralLabel: dbObject.pluralLabel,
|
|
8151
8265
|
description: dbObject.description,
|
|
8152
8266
|
labelExpression: dbObject.labelExpression,
|
|
8153
|
-
icon: _optionalChain([dbObject, 'access',
|
|
8267
|
+
icon: _optionalChain([dbObject, 'access', _179 => _179.metadata, 'optionalAccess', _180 => _180.icon])
|
|
8154
8268
|
};
|
|
8155
8269
|
let metadata = dbObject.metadata;
|
|
8156
8270
|
if (updates.icon !== void 0 || updates.metadata !== void 0) {
|
|
8157
8271
|
metadata = {
|
|
8158
8272
|
...dbObject.metadata,
|
|
8159
8273
|
...updates.metadata,
|
|
8160
|
-
icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access',
|
|
8274
|
+
icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _181 => _181.metadata, 'optionalAccess', _182 => _182.icon])))
|
|
8161
8275
|
};
|
|
8162
8276
|
}
|
|
8163
8277
|
const updatedDbObject = await this.adapter.objects.update(objectId, {
|
|
@@ -8447,7 +8561,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
|
|
|
8447
8561
|
label: dbObject.label,
|
|
8448
8562
|
pluralLabel: dbObject.pluralLabel,
|
|
8449
8563
|
description: dbObject.description,
|
|
8450
|
-
icon: _optionalChain([dbObject, 'access',
|
|
8564
|
+
icon: _optionalChain([dbObject, 'access', _183 => _183.metadata, 'optionalAccess', _184 => _184.icon]),
|
|
8451
8565
|
labelExpression: dbObject.labelExpression,
|
|
8452
8566
|
attributes,
|
|
8453
8567
|
system: dbObject.system,
|
|
@@ -8547,7 +8661,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
|
|
|
8547
8661
|
const hasRelationToTarget = attrs.some((attr) => {
|
|
8548
8662
|
if (attr.type !== "relation") return false;
|
|
8549
8663
|
const config = attr.config;
|
|
8550
|
-
return _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
8664
|
+
return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _185 => _185.targets, 'optionalAccess', _186 => _186.some, 'call', _187 => _187((t) => t.object === targetObjectName)]), () => ( false));
|
|
8551
8665
|
});
|
|
8552
8666
|
if (hasRelationToTarget) {
|
|
8553
8667
|
referencing.push(obj.name);
|
|
@@ -8697,7 +8811,7 @@ var SyncError = class extends SchemaError {
|
|
|
8697
8811
|
constructor(objectName, message, cause) {
|
|
8698
8812
|
super(`Failed to sync object "${objectName}": ${message}`, SchemaErrorCode.SYNC_FAILED, {
|
|
8699
8813
|
objectName,
|
|
8700
|
-
cause: _optionalChain([cause, 'optionalAccess',
|
|
8814
|
+
cause: _optionalChain([cause, 'optionalAccess', _188 => _188.message])
|
|
8701
8815
|
});
|
|
8702
8816
|
this.name = "SyncError";
|
|
8703
8817
|
this.objectName = objectName;
|
|
@@ -8785,8 +8899,8 @@ var PermissionService = class extends TenantAwareService {
|
|
|
8785
8899
|
);
|
|
8786
8900
|
}
|
|
8787
8901
|
this.permissionsRepo = adapter.permissions;
|
|
8788
|
-
this.cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8789
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
8902
|
+
this.cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _189 => _189.cache]), () => ( adapter.cache)), () => ( new NoopCacheAdapter()));
|
|
8903
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _190 => _190.auditService]);
|
|
8790
8904
|
}
|
|
8791
8905
|
// ============================================================================
|
|
8792
8906
|
// PERMISSION CHECKS
|
|
@@ -8805,11 +8919,11 @@ var PermissionService = class extends TenantAwareService {
|
|
|
8805
8919
|
return true;
|
|
8806
8920
|
}
|
|
8807
8921
|
const wildcardPerms = permissions.objectPermissions["*"];
|
|
8808
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
8922
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _191 => _191.includes, 'call', _192 => _192(action)])) {
|
|
8809
8923
|
return true;
|
|
8810
8924
|
}
|
|
8811
8925
|
const objectPerms = permissions.objectPermissions[objectName];
|
|
8812
|
-
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess',
|
|
8926
|
+
return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _193 => _193.includes, 'call', _194 => _194(action)]), () => ( false));
|
|
8813
8927
|
}
|
|
8814
8928
|
/**
|
|
8815
8929
|
* Check if user can access an object, throw ForbiddenError if not.
|
|
@@ -8864,12 +8978,12 @@ var PermissionService = class extends TenantAwareService {
|
|
|
8864
8978
|
if (permissions.isAdmin) {
|
|
8865
8979
|
return true;
|
|
8866
8980
|
}
|
|
8867
|
-
const wildcardPerms = _optionalChain([permissions, 'access',
|
|
8868
|
-
if (_optionalChain([wildcardPerms, 'optionalAccess',
|
|
8981
|
+
const wildcardPerms = _optionalChain([permissions, 'access', _195 => _195.systemPermissions, 'optionalAccess', _196 => _196["*"]]);
|
|
8982
|
+
if (_optionalChain([wildcardPerms, 'optionalAccess', _197 => _197.includes, 'call', _198 => _198(action)])) {
|
|
8869
8983
|
return true;
|
|
8870
8984
|
}
|
|
8871
|
-
const resourcePerms = _optionalChain([permissions, 'access',
|
|
8872
|
-
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess',
|
|
8985
|
+
const resourcePerms = _optionalChain([permissions, 'access', _199 => _199.systemPermissions, 'optionalAccess', _200 => _200[resource]]);
|
|
8986
|
+
return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _201 => _201.includes, 'call', _202 => _202(action)]), () => ( false));
|
|
8873
8987
|
}
|
|
8874
8988
|
/**
|
|
8875
8989
|
* Check if user can access a system resource, throw ForbiddenError if not.
|
|
@@ -8898,8 +9012,8 @@ var PermissionService = class extends TenantAwareService {
|
|
|
8898
9012
|
if (permissions.isAdmin) {
|
|
8899
9013
|
return { canRead: true, canCreate: true, canUpdate: true, canDelete: true };
|
|
8900
9014
|
}
|
|
8901
|
-
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access',
|
|
8902
|
-
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access',
|
|
9015
|
+
const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _203 => _203.systemPermissions, 'optionalAccess', _204 => _204["*"]]), () => ( []));
|
|
9016
|
+
const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _205 => _205.systemPermissions, 'optionalAccess', _206 => _206[resource]]), () => ( []));
|
|
8903
9017
|
const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
|
|
8904
9018
|
return {
|
|
8905
9019
|
canRead: allPerms.has("read"),
|
|
@@ -9041,7 +9155,7 @@ var PermissionService = class extends TenantAwareService {
|
|
|
9041
9155
|
action: "role.updated",
|
|
9042
9156
|
actorId: this.userId,
|
|
9043
9157
|
roleId,
|
|
9044
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
9158
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _207 => _207.label]), () => ( roleId)),
|
|
9045
9159
|
metadata: { permissionsUpdated: true, permissionCount: permissions.length }
|
|
9046
9160
|
});
|
|
9047
9161
|
}
|
|
@@ -9071,7 +9185,7 @@ var PermissionService = class extends TenantAwareService {
|
|
|
9071
9185
|
action: "role.assigned",
|
|
9072
9186
|
actorId: this.userId,
|
|
9073
9187
|
roleId,
|
|
9074
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
9188
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _208 => _208.label]), () => ( roleId)),
|
|
9075
9189
|
targetUserId: userProfileId
|
|
9076
9190
|
});
|
|
9077
9191
|
}
|
|
@@ -9089,7 +9203,7 @@ var PermissionService = class extends TenantAwareService {
|
|
|
9089
9203
|
action: "role.revoked",
|
|
9090
9204
|
actorId: this.userId,
|
|
9091
9205
|
roleId,
|
|
9092
|
-
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess',
|
|
9206
|
+
roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _209 => _209.label]), () => ( roleId)),
|
|
9093
9207
|
targetUserId: userProfileId
|
|
9094
9208
|
});
|
|
9095
9209
|
}
|
|
@@ -9206,7 +9320,7 @@ Native objects must have system=true. Did you forget to call .system() in your b
|
|
|
9206
9320
|
const existing = this.objects.get(object2.name);
|
|
9207
9321
|
throw new Error(
|
|
9208
9322
|
`[NativeObjectRegistry] Duplicate object name "${object2.name}":
|
|
9209
|
-
- Existing: "${_optionalChain([existing, 'optionalAccess',
|
|
9323
|
+
- Existing: "${_optionalChain([existing, 'optionalAccess', _210 => _210.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _211 => _211.id])})
|
|
9210
9324
|
- New: "${object2.label}" (id: ${object2.id})
|
|
9211
9325
|
Please use unique names for each native object.`
|
|
9212
9326
|
);
|
|
@@ -9306,7 +9420,7 @@ var RelationService = class extends TenantAwareService {
|
|
|
9306
9420
|
constructor(adapter, nativeRegistry, options) {
|
|
9307
9421
|
super();
|
|
9308
9422
|
this.adapter = adapter;
|
|
9309
|
-
this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9423
|
+
this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _212 => _212.cache]), () => ( adapter.cache));
|
|
9310
9424
|
this.schemaService = new ObjectSchemaService(adapter, nativeRegistry, { cache: this.cache });
|
|
9311
9425
|
}
|
|
9312
9426
|
/**
|
|
@@ -9349,6 +9463,8 @@ var RelationService = class extends TenantAwareService {
|
|
|
9349
9463
|
}
|
|
9350
9464
|
/**
|
|
9351
9465
|
* Validate a single relation attribute value
|
|
9466
|
+
*
|
|
9467
|
+
* Uses batch fetching (findByIds) to avoid N+1 query pattern.
|
|
9352
9468
|
*/
|
|
9353
9469
|
async validateRelationAttribute(attr, value) {
|
|
9354
9470
|
const errors = [];
|
|
@@ -9358,16 +9474,18 @@ var RelationService = class extends TenantAwareService {
|
|
|
9358
9474
|
}
|
|
9359
9475
|
const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
|
|
9360
9476
|
const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
|
|
9361
|
-
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess',
|
|
9477
|
+
if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _213 => _213.size]) === 0) {
|
|
9362
9478
|
errors.push({
|
|
9363
9479
|
attribute: attr.name,
|
|
9364
9480
|
message: `No valid target objects found for ${attr.label}`
|
|
9365
9481
|
});
|
|
9366
9482
|
return errors;
|
|
9367
9483
|
}
|
|
9484
|
+
const records = await this.adapter.objectRecords.findByIds(ids);
|
|
9485
|
+
const recordMap = new Map(records.map((r) => [r.id, r]));
|
|
9368
9486
|
const invalidIds = [];
|
|
9369
9487
|
for (const id of ids) {
|
|
9370
|
-
const record =
|
|
9488
|
+
const record = recordMap.get(id);
|
|
9371
9489
|
if (!record) {
|
|
9372
9490
|
invalidIds.push(id);
|
|
9373
9491
|
continue;
|
|
@@ -9409,10 +9527,10 @@ var RelationService = class extends TenantAwareService {
|
|
|
9409
9527
|
for (const target of targets) {
|
|
9410
9528
|
try {
|
|
9411
9529
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
9412
|
-
if (_optionalChain([objectSchema, 'optionalAccess',
|
|
9530
|
+
if (_optionalChain([objectSchema, 'optionalAccess', _214 => _214.id])) {
|
|
9413
9531
|
objectIds.add(objectSchema.id);
|
|
9414
9532
|
}
|
|
9415
|
-
} catch (
|
|
9533
|
+
} catch (e11) {
|
|
9416
9534
|
}
|
|
9417
9535
|
}
|
|
9418
9536
|
return objectIds;
|
|
@@ -9462,7 +9580,7 @@ var RelationService = class extends TenantAwareService {
|
|
|
9462
9580
|
const recordService = new RecordService(this.adapter);
|
|
9463
9581
|
for (const target of filteredTargets) {
|
|
9464
9582
|
const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
|
|
9465
|
-
if (!_optionalChain([objectSchema, 'optionalAccess',
|
|
9583
|
+
if (!_optionalChain([objectSchema, 'optionalAccess', _215 => _215.id])) {
|
|
9466
9584
|
continue;
|
|
9467
9585
|
}
|
|
9468
9586
|
const queryOptions = {
|
|
@@ -9541,8 +9659,8 @@ var RelationService = class extends TenantAwareService {
|
|
|
9541
9659
|
if (!objectSchema) {
|
|
9542
9660
|
continue;
|
|
9543
9661
|
}
|
|
9544
|
-
const targetConfig = _optionalChain([attribute, 'optionalAccess',
|
|
9545
|
-
const customTemplate = _optionalChain([targetConfig, 'optionalAccess',
|
|
9662
|
+
const targetConfig = _optionalChain([attribute, 'optionalAccess', _216 => _216.targets, 'optionalAccess', _217 => _217.find, 'call', _218 => _218((t) => t.object === objectSchema.name)]);
|
|
9663
|
+
const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _219 => _219.displayTemplate]);
|
|
9546
9664
|
for (const record of objectRecords) {
|
|
9547
9665
|
let label;
|
|
9548
9666
|
if (customTemplate) {
|
|
@@ -9593,7 +9711,7 @@ var RelationService = class extends TenantAwareService {
|
|
|
9593
9711
|
var RollupService = class {
|
|
9594
9712
|
constructor(adapter, options) {
|
|
9595
9713
|
this.adapter = adapter;
|
|
9596
|
-
this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9714
|
+
this.cache = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _220 => _220.cache]), () => ( adapter.cache));
|
|
9597
9715
|
}
|
|
9598
9716
|
/**
|
|
9599
9717
|
* Calculate a rollup value for a record
|
|
@@ -9681,22 +9799,37 @@ var RollupService = class {
|
|
|
9681
9799
|
return { value: null, recordCount: 0 };
|
|
9682
9800
|
}
|
|
9683
9801
|
const sourceObjectName = rollupAttr.relationAttribute;
|
|
9684
|
-
const
|
|
9685
|
-
|
|
9686
|
-
|
|
9802
|
+
const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
|
|
9803
|
+
let sourceObjectId;
|
|
9804
|
+
let reverseRelationAttrName;
|
|
9805
|
+
if (_optionalChain([sourceSchema, 'optionalAccess', _221 => _221.id])) {
|
|
9806
|
+
sourceObjectId = sourceSchema.id;
|
|
9807
|
+
const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
|
|
9808
|
+
if (attr.type !== "relation") return false;
|
|
9809
|
+
const relationConfig = attr;
|
|
9810
|
+
return _optionalChain([relationConfig, 'optionalAccess', _222 => _222.targets, 'optionalAccess', _223 => _223.some, 'call', _224 => _224((t) => t.object === schema.name)]);
|
|
9811
|
+
});
|
|
9812
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _225 => _225.name]);
|
|
9813
|
+
} else {
|
|
9814
|
+
const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
|
|
9815
|
+
if (!sourceObject) {
|
|
9816
|
+
return { value: null, recordCount: 0 };
|
|
9817
|
+
}
|
|
9818
|
+
sourceObjectId = sourceObject.id;
|
|
9819
|
+
const sourceAttributes = await this.adapter.attributes.findByObjectId(sourceObject.id);
|
|
9820
|
+
const reverseRelationAttr = sourceAttributes.find((attr) => {
|
|
9821
|
+
if (attr.type !== "relation") return false;
|
|
9822
|
+
const relationConfig = attr.config;
|
|
9823
|
+
return _optionalChain([relationConfig, 'optionalAccess', _226 => _226.targets, 'optionalAccess', _227 => _227.some, 'call', _228 => _228((t) => t.object === schema.name)]);
|
|
9824
|
+
});
|
|
9825
|
+
reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _229 => _229.name]);
|
|
9687
9826
|
}
|
|
9688
|
-
|
|
9689
|
-
const reverseRelationAttr = sourceAttributes.find((attr) => {
|
|
9690
|
-
if (attr.type !== "relation") return false;
|
|
9691
|
-
const relationConfig = attr.config;
|
|
9692
|
-
return _optionalChain([relationConfig, 'optionalAccess', _211 => _211.targets, 'optionalAccess', _212 => _212.some, 'call', _213 => _213((t) => t.object === schema.name)]);
|
|
9693
|
-
});
|
|
9694
|
-
if (!reverseRelationAttr) {
|
|
9827
|
+
if (!reverseRelationAttrName) {
|
|
9695
9828
|
return { value: null, recordCount: 0 };
|
|
9696
9829
|
}
|
|
9697
9830
|
const relatedRecords = await this.adapter.objectRecords.findByRelation(
|
|
9698
|
-
|
|
9699
|
-
|
|
9831
|
+
sourceObjectId,
|
|
9832
|
+
reverseRelationAttrName,
|
|
9700
9833
|
recordId
|
|
9701
9834
|
);
|
|
9702
9835
|
if (relatedRecords.length === 0) {
|
|
@@ -9930,7 +10063,7 @@ var RollupService = class {
|
|
|
9930
10063
|
}
|
|
9931
10064
|
for (const rollupDbAttr of rollupAttrs) {
|
|
9932
10065
|
const rollupConfig = rollupDbAttr.config;
|
|
9933
|
-
if (!_optionalChain([rollupConfig, 'optionalAccess',
|
|
10066
|
+
if (!_optionalChain([rollupConfig, 'optionalAccess', _230 => _230.relationAttribute])) {
|
|
9934
10067
|
continue;
|
|
9935
10068
|
}
|
|
9936
10069
|
const relationAttr = attributes.find(
|
|
@@ -9940,7 +10073,7 @@ var RollupService = class {
|
|
|
9940
10073
|
continue;
|
|
9941
10074
|
}
|
|
9942
10075
|
const relationConfig = relationAttr.config;
|
|
9943
|
-
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess',
|
|
10076
|
+
const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _231 => _231.targets, 'optionalAccess', _232 => _232.some, 'call', _233 => _233(
|
|
9944
10077
|
(t) => t.object === changedSchema.name
|
|
9945
10078
|
)]);
|
|
9946
10079
|
if (!targetsChangedObject) {
|
|
@@ -10043,7 +10176,7 @@ var UserService = class extends TenantAwareService {
|
|
|
10043
10176
|
if (roleErrors.length > 0) {
|
|
10044
10177
|
errors.push({
|
|
10045
10178
|
attribute: attr.name,
|
|
10046
|
-
message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access',
|
|
10179
|
+
message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _234 => _234.allowedRoles, 'optionalAccess', _235 => _235.join, 'call', _236 => _236(", ")])}`,
|
|
10047
10180
|
invalidIds: roleErrors
|
|
10048
10181
|
});
|
|
10049
10182
|
}
|
|
@@ -10079,7 +10212,7 @@ var UserService = class extends TenantAwareService {
|
|
|
10079
10212
|
}
|
|
10080
10213
|
};
|
|
10081
10214
|
|
|
10082
|
-
// src/runtime/services/record.
|
|
10215
|
+
// src/runtime/services/record/defaults.ts
|
|
10083
10216
|
function applyDefaultValues(schema, data) {
|
|
10084
10217
|
const result = { ...data };
|
|
10085
10218
|
for (const attr of schema.attributes) {
|
|
@@ -10092,170 +10225,267 @@ function applyDefaultValues(schema, data) {
|
|
|
10092
10225
|
}
|
|
10093
10226
|
return result;
|
|
10094
10227
|
}
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
auditService: _optionalChain([options, 'optionalAccess', _221 => _221.auditService])
|
|
10101
|
-
});
|
|
10102
|
-
this.relationService = new RelationService(adapter, registry);
|
|
10103
|
-
this.userService = new UserService(adapter);
|
|
10104
|
-
this.rollupService = new RollupService(adapter);
|
|
10105
|
-
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _222 => _222.hookRegistry]), () => ( new NoopHookRegistry()));
|
|
10106
|
-
this.permissionService = _optionalChain([options, 'optionalAccess', _223 => _223.permissionService]);
|
|
10107
|
-
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _224 => _224.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
10108
|
-
this.policyRegistry = _optionalChain([options, 'optionalAccess', _225 => _225.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _226 => _226.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
10228
|
+
|
|
10229
|
+
// src/runtime/services/record/access.ts
|
|
10230
|
+
async function checkPermission(permissionService, userId, objectName, action) {
|
|
10231
|
+
if (permissionService && userId) {
|
|
10232
|
+
await permissionService.checkObjectAccess(userId, objectName, action);
|
|
10109
10233
|
}
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
*/
|
|
10115
|
-
async checkPermission(objectName, action) {
|
|
10116
|
-
if (this.permissionService && this.userId) {
|
|
10117
|
-
await this.permissionService.checkObjectAccess(this.userId, objectName, action);
|
|
10118
|
-
}
|
|
10234
|
+
}
|
|
10235
|
+
function getPolicy(policyRegistry, userId, objectName) {
|
|
10236
|
+
if (!(policyRegistry && userId)) {
|
|
10237
|
+
return void 0;
|
|
10119
10238
|
}
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
return this.policyRegistry.get(objectName);
|
|
10239
|
+
return policyRegistry.get(objectName);
|
|
10240
|
+
}
|
|
10241
|
+
function buildPolicyContext(objectName, userId, tenantId) {
|
|
10242
|
+
return { userId, tenantId, objectName };
|
|
10243
|
+
}
|
|
10244
|
+
function checkRecordAccess(policy, record, context) {
|
|
10245
|
+
if (!policy.canAccessRecord) {
|
|
10246
|
+
return true;
|
|
10129
10247
|
}
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
return {
|
|
10136
|
-
// biome-ignore lint/style/noNonNullAssertion: userId is guaranteed to be set
|
|
10137
|
-
userId: this.userId,
|
|
10138
|
-
tenantId: this.tenantId,
|
|
10139
|
-
objectName
|
|
10140
|
-
};
|
|
10248
|
+
return policy.canAccessRecord(context, record);
|
|
10249
|
+
}
|
|
10250
|
+
function checkRecordModifyOrThrow(policy, record, context) {
|
|
10251
|
+
if (!policy.canModifyRecord) {
|
|
10252
|
+
return;
|
|
10141
10253
|
}
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
* Returns true if no policy exists or user can access.
|
|
10145
|
-
* @internal
|
|
10146
|
-
*/
|
|
10147
|
-
checkRecordAccess(policy, record) {
|
|
10148
|
-
if (!policy.canAccessRecord) {
|
|
10149
|
-
return true;
|
|
10150
|
-
}
|
|
10151
|
-
return policy.canAccessRecord(this.buildPolicyContext(policy.objectName), record);
|
|
10254
|
+
if (!policy.canModifyRecord(context, record)) {
|
|
10255
|
+
throw new PolicyViolationError(policy.objectName, "update", record.id);
|
|
10152
10256
|
}
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
*/
|
|
10158
|
-
checkRecordModify(policy, record) {
|
|
10159
|
-
if (!policy.canModifyRecord) {
|
|
10160
|
-
return;
|
|
10161
|
-
}
|
|
10162
|
-
const canModify = policy.canModifyRecord(this.buildPolicyContext(policy.objectName), record);
|
|
10163
|
-
if (!canModify) {
|
|
10164
|
-
throw new PolicyViolationError(policy.objectName, "update", record.id);
|
|
10165
|
-
}
|
|
10257
|
+
}
|
|
10258
|
+
function checkRecordDeleteOrThrow(policy, record, context) {
|
|
10259
|
+
if (!policy.canDeleteRecord) {
|
|
10260
|
+
return;
|
|
10166
10261
|
}
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10262
|
+
if (!policy.canDeleteRecord(context, record)) {
|
|
10263
|
+
throw new PolicyViolationError(policy.objectName, "delete", record.id);
|
|
10264
|
+
}
|
|
10265
|
+
}
|
|
10266
|
+
|
|
10267
|
+
// src/runtime/services/record/label.ts
|
|
10268
|
+
function extractRelationIds2(val) {
|
|
10269
|
+
if (typeof val === "string") return [val];
|
|
10270
|
+
if (Array.isArray(val) && typeof val[0] === "string") return [val[0]];
|
|
10271
|
+
return [];
|
|
10272
|
+
}
|
|
10273
|
+
async function resolveRelationLabels(relationAttrs, values, resolver) {
|
|
10274
|
+
const resolvedMap = /* @__PURE__ */ new Map();
|
|
10275
|
+
const idsWithAttrId = [];
|
|
10276
|
+
const idsWithoutAttrId = [];
|
|
10277
|
+
for (const attr of relationAttrs) {
|
|
10278
|
+
const ids = extractRelationIds2(values[attr.name]);
|
|
10279
|
+
if (ids.length > 0) {
|
|
10280
|
+
if (attr.id) {
|
|
10281
|
+
idsWithAttrId.push({ attrId: attr.id, ids });
|
|
10282
|
+
} else {
|
|
10283
|
+
idsWithoutAttrId.push(...ids);
|
|
10284
|
+
}
|
|
10179
10285
|
}
|
|
10180
10286
|
}
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
idsWithoutAttrId.push(...ids);
|
|
10287
|
+
await Promise.all(
|
|
10288
|
+
idsWithAttrId.map(async ({ attrId, ids }) => {
|
|
10289
|
+
const resolved = await resolver.resolveRelationIds(ids, attrId);
|
|
10290
|
+
for (const r of resolved) {
|
|
10291
|
+
resolvedMap.set(r.id, r.label);
|
|
10292
|
+
}
|
|
10293
|
+
})
|
|
10294
|
+
);
|
|
10295
|
+
if (idsWithoutAttrId.length > 0) {
|
|
10296
|
+
const uniqueIds = [...new Set(idsWithoutAttrId)].filter((id) => !resolvedMap.has(id));
|
|
10297
|
+
if (uniqueIds.length > 0) {
|
|
10298
|
+
const records = await resolver.findRecordLabels(uniqueIds);
|
|
10299
|
+
for (const record of records) {
|
|
10300
|
+
if (record.label) {
|
|
10301
|
+
resolvedMap.set(record.id, record.label);
|
|
10197
10302
|
}
|
|
10198
10303
|
}
|
|
10199
10304
|
}
|
|
10305
|
+
}
|
|
10306
|
+
return resolvedMap;
|
|
10307
|
+
}
|
|
10308
|
+
async function computeLabel(schema, values, resolver) {
|
|
10309
|
+
const attrNames = extractAttributeNames(schema.labelExpression);
|
|
10310
|
+
let enrichedValues = enrichValuesForDisplay(values, schema.attributes);
|
|
10311
|
+
const relationAttrs = schema.attributes.filter(
|
|
10312
|
+
(attr) => attr.type === "relation" && attrNames.includes(attr.name)
|
|
10313
|
+
);
|
|
10314
|
+
if (relationAttrs.length === 0) {
|
|
10315
|
+
return renderLabelExpression(schema.labelExpression, enrichedValues);
|
|
10316
|
+
}
|
|
10317
|
+
const resolvedMap = await resolveRelationLabels(relationAttrs, values, resolver);
|
|
10318
|
+
if (resolvedMap.size === 0) {
|
|
10319
|
+
return renderLabelExpression(schema.labelExpression, enrichedValues);
|
|
10320
|
+
}
|
|
10321
|
+
enrichedValues = { ...enrichedValues };
|
|
10322
|
+
for (const attr of relationAttrs) {
|
|
10323
|
+
const ids = extractRelationIds2(values[attr.name]);
|
|
10324
|
+
if (ids.length > 0 && resolvedMap.has(ids[0])) {
|
|
10325
|
+
enrichedValues[attr.name] = resolvedMap.get(ids[0]);
|
|
10326
|
+
}
|
|
10327
|
+
}
|
|
10328
|
+
return renderLabelExpression(schema.labelExpression, enrichedValues);
|
|
10329
|
+
}
|
|
10330
|
+
|
|
10331
|
+
// src/runtime/services/record/formula.ts
|
|
10332
|
+
function enrichWithFormulas(record, schema) {
|
|
10333
|
+
const formulaAttrs = schema.attributes.filter((a) => a.type === "formula");
|
|
10334
|
+
if (formulaAttrs.length === 0) {
|
|
10335
|
+
return record;
|
|
10336
|
+
}
|
|
10337
|
+
const enrichedValues = { ...record.values };
|
|
10338
|
+
for (const attr of formulaAttrs) {
|
|
10339
|
+
enrichedValues[attr.name] = evaluateFormulaAttribute(attr, record.values);
|
|
10340
|
+
}
|
|
10341
|
+
return {
|
|
10342
|
+
...record,
|
|
10343
|
+
values: enrichedValues
|
|
10344
|
+
};
|
|
10345
|
+
}
|
|
10346
|
+
function enrichRecordsWithFormulas(records, schema) {
|
|
10347
|
+
const formulaAttrs = schema.attributes.filter((a) => a.type === "formula");
|
|
10348
|
+
if (formulaAttrs.length === 0) {
|
|
10349
|
+
return records;
|
|
10350
|
+
}
|
|
10351
|
+
return records.map((record) => enrichWithFormulas(record, schema));
|
|
10352
|
+
}
|
|
10353
|
+
|
|
10354
|
+
// src/runtime/services/record/hook-context.ts
|
|
10355
|
+
function createGetChange(oldValues, newValues, changedAttributes) {
|
|
10356
|
+
return (attr) => ({
|
|
10357
|
+
oldValue: oldValues[attr],
|
|
10358
|
+
newValue: newValues[attr],
|
|
10359
|
+
changed: changedAttributes.includes(attr)
|
|
10360
|
+
});
|
|
10361
|
+
}
|
|
10362
|
+
function createContextForCreate(schema, tenantId, data, metadata) {
|
|
10363
|
+
const attributeNames = Object.keys(data);
|
|
10364
|
+
return {
|
|
10365
|
+
objectId: schema.id,
|
|
10366
|
+
objectName: schema.name,
|
|
10367
|
+
recordId: "",
|
|
10368
|
+
// Will be set after creation
|
|
10369
|
+
tenantId,
|
|
10370
|
+
record: null,
|
|
10371
|
+
// Will be set after creation
|
|
10372
|
+
oldValues: {},
|
|
10373
|
+
newValues: data,
|
|
10374
|
+
changedAttributes: attributeNames,
|
|
10375
|
+
// All attributes are "new"
|
|
10376
|
+
getChange: createGetChange({}, data, attributeNames),
|
|
10377
|
+
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10378
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
10379
|
+
};
|
|
10380
|
+
}
|
|
10381
|
+
function createContextForUpdate(schema, tenantId, existing, mergedData, changedAttributes, metadata) {
|
|
10382
|
+
const oldValuesSnapshot = { ...existing.values };
|
|
10383
|
+
return {
|
|
10384
|
+
objectId: schema.id,
|
|
10385
|
+
objectName: schema.name,
|
|
10386
|
+
recordId: existing.id,
|
|
10387
|
+
tenantId,
|
|
10388
|
+
record: existing,
|
|
10389
|
+
oldValues: oldValuesSnapshot,
|
|
10390
|
+
newValues: mergedData,
|
|
10391
|
+
changedAttributes,
|
|
10392
|
+
getChange: createGetChange(oldValuesSnapshot, mergedData, changedAttributes),
|
|
10393
|
+
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10394
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
10395
|
+
};
|
|
10396
|
+
}
|
|
10397
|
+
function createContextForDelete(schema, tenantId, record, metadata) {
|
|
10398
|
+
const attributeNames = Object.keys(record.values);
|
|
10399
|
+
return {
|
|
10400
|
+
objectId: schema.id,
|
|
10401
|
+
objectName: schema.name,
|
|
10402
|
+
recordId: record.id,
|
|
10403
|
+
tenantId,
|
|
10404
|
+
record,
|
|
10405
|
+
oldValues: record.values,
|
|
10406
|
+
newValues: {},
|
|
10407
|
+
changedAttributes: attributeNames,
|
|
10408
|
+
// All attributes are being "removed"
|
|
10409
|
+
getChange: createGetChange(record.values, {}, attributeNames),
|
|
10410
|
+
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10411
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
10412
|
+
};
|
|
10413
|
+
}
|
|
10414
|
+
function createContextForRestore(schema, tenantId, record, metadata) {
|
|
10415
|
+
return {
|
|
10416
|
+
objectId: schema.id,
|
|
10417
|
+
objectName: schema.name,
|
|
10418
|
+
recordId: record.id,
|
|
10419
|
+
tenantId,
|
|
10420
|
+
record,
|
|
10421
|
+
oldValues: record.values,
|
|
10422
|
+
newValues: record.values,
|
|
10423
|
+
changedAttributes: [],
|
|
10424
|
+
getChange: createGetChange(record.values, record.values, []),
|
|
10425
|
+
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10426
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
10427
|
+
};
|
|
10428
|
+
}
|
|
10429
|
+
|
|
10430
|
+
// src/runtime/services/record/rollup-cascade.ts
|
|
10431
|
+
async function recalculateParentRollups(record, schema, ctx) {
|
|
10432
|
+
const { rollupService, schemaService, findRecordsByIds } = ctx;
|
|
10433
|
+
const ownRollupAttrs = schema.attributes.filter((a) => a.type === "rollup");
|
|
10434
|
+
if (ownRollupAttrs.length > 0) {
|
|
10435
|
+
await rollupService.recalculateAndUpdate(record, schema);
|
|
10436
|
+
}
|
|
10437
|
+
const affectedParentIds = await rollupService.findAffectedParentRecords(record, schema);
|
|
10438
|
+
if (affectedParentIds.length > 0) {
|
|
10439
|
+
const parentRecords = await findRecordsByIds(affectedParentIds);
|
|
10200
10440
|
await Promise.all(
|
|
10201
|
-
|
|
10202
|
-
const
|
|
10203
|
-
|
|
10204
|
-
|
|
10441
|
+
parentRecords.map(async (parentRecord) => {
|
|
10442
|
+
const parentSchema = await schemaService.getObjectSchema(parentRecord.objectId);
|
|
10443
|
+
const rollupAttrs = parentSchema.attributes.filter(
|
|
10444
|
+
(a) => a.type === "rollup"
|
|
10445
|
+
);
|
|
10446
|
+
if (rollupAttrs.length > 0) {
|
|
10447
|
+
await rollupService.recalculateAndUpdate(parentRecord, parentSchema);
|
|
10205
10448
|
}
|
|
10206
10449
|
})
|
|
10207
10450
|
);
|
|
10208
|
-
if (idsWithoutAttrId.length > 0) {
|
|
10209
|
-
const uniqueIds = [...new Set(idsWithoutAttrId)].filter((id) => !resolvedMap.has(id));
|
|
10210
|
-
if (uniqueIds.length > 0) {
|
|
10211
|
-
const records = await this.adapter.objectRecords.findByIds(uniqueIds);
|
|
10212
|
-
for (const record of records) {
|
|
10213
|
-
if (record.label) {
|
|
10214
|
-
resolvedMap.set(record.id, record.label);
|
|
10215
|
-
}
|
|
10216
|
-
}
|
|
10217
|
-
}
|
|
10218
|
-
}
|
|
10219
|
-
return resolvedMap;
|
|
10220
|
-
}
|
|
10221
|
-
/**
|
|
10222
|
-
* Extract relation IDs from a value (string or array)
|
|
10223
|
-
* @internal
|
|
10224
|
-
*/
|
|
10225
|
-
extractRelationIds(val) {
|
|
10226
|
-
if (typeof val === "string") return [val];
|
|
10227
|
-
if (Array.isArray(val) && typeof val[0] === "string") return [val[0]];
|
|
10228
|
-
return [];
|
|
10229
10451
|
}
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10452
|
+
const affectedForwardRecords = await rollupService.findRecordsWithForwardRollup(record, schema);
|
|
10453
|
+
await Promise.all(
|
|
10454
|
+
affectedForwardRecords.map(async (forwardRecord) => {
|
|
10455
|
+
const forwardSchema = await schemaService.getObjectSchema(forwardRecord.objectId);
|
|
10456
|
+
await rollupService.recalculateAndUpdate(forwardRecord, forwardSchema);
|
|
10457
|
+
})
|
|
10458
|
+
);
|
|
10459
|
+
}
|
|
10460
|
+
|
|
10461
|
+
// src/runtime/services/record.service.ts
|
|
10462
|
+
var RecordService = class extends TenantAwareService {
|
|
10463
|
+
constructor(adapter, options) {
|
|
10464
|
+
super();
|
|
10465
|
+
this.adapter = adapter;
|
|
10466
|
+
this.schemaService = new ObjectSchemaService(adapter, registry, {
|
|
10467
|
+
auditService: _optionalChain([options, 'optionalAccess', _237 => _237.auditService])
|
|
10468
|
+
});
|
|
10469
|
+
this.relationService = new RelationService(adapter, registry);
|
|
10470
|
+
this.userService = new UserService(adapter);
|
|
10471
|
+
this.rollupService = new RollupService(adapter);
|
|
10472
|
+
this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _238 => _238.hookRegistry]), () => ( new NoopHookRegistry()));
|
|
10473
|
+
this.permissionService = _optionalChain([options, 'optionalAccess', _239 => _239.permissionService]);
|
|
10474
|
+
this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _240 => _240.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
|
|
10475
|
+
this.policyRegistry = _optionalChain([options, 'optionalAccess', _241 => _241.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _242 => _242.policyRegistry]), () => ( defaultPolicyRegistry));
|
|
10476
|
+
this.labelResolver = {
|
|
10477
|
+
resolveRelationIds: (ids, attrId) => this.relationService.resolveIds(ids, attrId),
|
|
10478
|
+
findRecordLabels: (ids) => this.adapter.objectRecords.findByIds(ids)
|
|
10479
|
+
};
|
|
10480
|
+
this.rollupContext = {
|
|
10481
|
+
rollupService: this.rollupService,
|
|
10482
|
+
schemaService: this.schemaService,
|
|
10483
|
+
findRecordsByIds: (ids) => this.adapter.objectRecords.findByIds(ids)
|
|
10484
|
+
};
|
|
10258
10485
|
}
|
|
10486
|
+
// ============================================================================
|
|
10487
|
+
// CREATE
|
|
10488
|
+
// ============================================================================
|
|
10259
10489
|
/**
|
|
10260
10490
|
* Create a new record with validation
|
|
10261
10491
|
*
|
|
@@ -10265,58 +10495,44 @@ var RecordService = class extends TenantAwareService {
|
|
|
10265
10495
|
* @param data - Record data (attribute values)
|
|
10266
10496
|
* @param options - Creation options
|
|
10267
10497
|
* @returns Created record with computed completionStatus
|
|
10268
|
-
*
|
|
10269
|
-
* @example
|
|
10270
|
-
* ```typescript
|
|
10271
|
-
* const service = new RecordService(adapter, "tenant-123");
|
|
10272
|
-
*
|
|
10273
|
-
* // Create a complete record (strict validation)
|
|
10274
|
-
* const product = await service.createRecord("obj-product", {
|
|
10275
|
-
* name: "Nike Air Max",
|
|
10276
|
-
* price: 129.99,
|
|
10277
|
-
* status: "active"
|
|
10278
|
-
* });
|
|
10279
|
-
* // → product.completionStatus = "complete"
|
|
10280
|
-
*
|
|
10281
|
-
* // Create a draft record (allows missing required fields)
|
|
10282
|
-
* const draft = await service.createRecord("obj-product", {
|
|
10283
|
-
* name: "Draft Product"
|
|
10284
|
-
* }, { allowDraft: true });
|
|
10285
|
-
* // → draft.completionStatus = "draft"
|
|
10286
|
-
* ```
|
|
10287
10498
|
*/
|
|
10288
10499
|
async createRecord(objectId, data, options) {
|
|
10289
10500
|
const schema = await this.schemaService.getObjectSchema(objectId);
|
|
10290
10501
|
const dataWithDefaults = applyDefaultValues(schema, data);
|
|
10291
|
-
await this.
|
|
10292
|
-
const hookCtx =
|
|
10293
|
-
|
|
10502
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "create");
|
|
10503
|
+
const hookCtx = createContextForCreate(
|
|
10504
|
+
schema,
|
|
10505
|
+
this.tenantId,
|
|
10506
|
+
dataWithDefaults,
|
|
10507
|
+
_optionalChain([options, 'optionalAccess', _243 => _243.hookMetadata])
|
|
10508
|
+
);
|
|
10509
|
+
if (!_optionalChain([options, 'optionalAccess', _244 => _244.skipHooks])) {
|
|
10294
10510
|
await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
|
|
10295
10511
|
}
|
|
10296
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10297
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10512
|
+
if (_optionalChain([options, 'optionalAccess', _245 => _245.validate]) !== false) {
|
|
10513
|
+
if (_optionalChain([options, 'optionalAccess', _246 => _246.allowDraft])) {
|
|
10298
10514
|
validateDraftOrThrow(schema, dataWithDefaults);
|
|
10299
10515
|
} else {
|
|
10300
10516
|
validateObjectOrThrow(schema, dataWithDefaults);
|
|
10301
10517
|
}
|
|
10302
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10518
|
+
if (!_optionalChain([options, 'optionalAccess', _247 => _247.skipRelationValidation])) {
|
|
10303
10519
|
await this.relationService.validateRelationsOrThrow(schema, dataWithDefaults);
|
|
10304
10520
|
}
|
|
10305
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10521
|
+
if (!_optionalChain([options, 'optionalAccess', _248 => _248.skipUserValidation])) {
|
|
10306
10522
|
await this.userService.validateUsersOrThrow(schema, dataWithDefaults);
|
|
10307
10523
|
}
|
|
10308
10524
|
}
|
|
10309
10525
|
const completionStatus = computeRecordStatus(schema, dataWithDefaults);
|
|
10310
|
-
const label = await
|
|
10526
|
+
const label = await computeLabel(schema, dataWithDefaults, this.labelResolver);
|
|
10311
10527
|
const record = await this.adapter.objectRecords.create({
|
|
10312
10528
|
objectId,
|
|
10313
10529
|
data: dataWithDefaults,
|
|
10314
10530
|
label,
|
|
10315
10531
|
completionStatus,
|
|
10316
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10532
|
+
metadata: _optionalChain([options, 'optionalAccess', _249 => _249.metadata]),
|
|
10317
10533
|
createdBy: this.userId
|
|
10318
10534
|
});
|
|
10319
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10535
|
+
if (!_optionalChain([options, 'optionalAccess', _250 => _250.skipHooks])) {
|
|
10320
10536
|
const afterCtx = {
|
|
10321
10537
|
...hookCtx,
|
|
10322
10538
|
recordId: record.id,
|
|
@@ -10324,7 +10540,7 @@ var RecordService = class extends TenantAwareService {
|
|
|
10324
10540
|
};
|
|
10325
10541
|
await this.hookRegistry.execute("afterCreate", schema.name, afterCtx);
|
|
10326
10542
|
}
|
|
10327
|
-
await
|
|
10543
|
+
await recalculateParentRollups(record, schema, this.rollupContext);
|
|
10328
10544
|
if (this.auditService && this.userId) {
|
|
10329
10545
|
await this.auditService.logRecordAction({
|
|
10330
10546
|
action: "record.created",
|
|
@@ -10333,17 +10549,16 @@ var RecordService = class extends TenantAwareService {
|
|
|
10333
10549
|
objectId: schema.id,
|
|
10334
10550
|
recordId: record.id,
|
|
10335
10551
|
recordLabel: record.label,
|
|
10336
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10552
|
+
metadata: _optionalChain([options, 'optionalAccess', _251 => _251.hookMetadata])
|
|
10337
10553
|
});
|
|
10338
10554
|
}
|
|
10339
10555
|
return record;
|
|
10340
10556
|
}
|
|
10557
|
+
// ============================================================================
|
|
10558
|
+
// READ
|
|
10559
|
+
// ============================================================================
|
|
10341
10560
|
/**
|
|
10342
10561
|
* Get a record by ID
|
|
10343
|
-
*
|
|
10344
|
-
* @param recordId - Record UUID
|
|
10345
|
-
* @param options - Query options
|
|
10346
|
-
* @returns Record or null if not found
|
|
10347
10562
|
*/
|
|
10348
10563
|
async getRecord(recordId, options) {
|
|
10349
10564
|
const record = await this.adapter.objectRecords.findById(recordId);
|
|
@@ -10351,17 +10566,20 @@ var RecordService = class extends TenantAwareService {
|
|
|
10351
10566
|
return null;
|
|
10352
10567
|
}
|
|
10353
10568
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10354
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10355
|
-
const policy = this.
|
|
10356
|
-
if (policy
|
|
10357
|
-
|
|
10569
|
+
if (!_optionalChain([options, 'optionalAccess', _252 => _252.skipPolicyCheck])) {
|
|
10570
|
+
const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
10571
|
+
if (policy) {
|
|
10572
|
+
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10573
|
+
if (!checkRecordAccess(policy, record, ctx)) {
|
|
10574
|
+
return null;
|
|
10575
|
+
}
|
|
10358
10576
|
}
|
|
10359
10577
|
}
|
|
10360
10578
|
let enrichedRecord = record;
|
|
10361
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10362
|
-
enrichedRecord =
|
|
10579
|
+
if (!_optionalChain([options, 'optionalAccess', _253 => _253.skipFormulas])) {
|
|
10580
|
+
enrichedRecord = enrichWithFormulas(record, schema);
|
|
10363
10581
|
}
|
|
10364
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10582
|
+
if (_optionalChain([options, 'optionalAccess', _254 => _254.includeSchema])) {
|
|
10365
10583
|
const recordWithSchema = enrichedRecord;
|
|
10366
10584
|
recordWithSchema.schema = schema;
|
|
10367
10585
|
return recordWithSchema;
|
|
@@ -10378,28 +10596,11 @@ var RecordService = class extends TenantAwareService {
|
|
|
10378
10596
|
}
|
|
10379
10597
|
return record;
|
|
10380
10598
|
}
|
|
10599
|
+
// ============================================================================
|
|
10600
|
+
// UPDATE
|
|
10601
|
+
// ============================================================================
|
|
10381
10602
|
/**
|
|
10382
10603
|
* Update a record with validation
|
|
10383
|
-
*
|
|
10384
|
-
* The completion status is automatically recalculated after each update.
|
|
10385
|
-
* A draft record becomes complete when all required fields are filled.
|
|
10386
|
-
*
|
|
10387
|
-
* Triggers beforeUpdate and afterUpdate hooks if a HookRegistry is configured.
|
|
10388
|
-
*
|
|
10389
|
-
* @param recordId - Record UUID
|
|
10390
|
-
* @param data - Partial data to update
|
|
10391
|
-
* @param options - Update options
|
|
10392
|
-
* @returns Updated record with recalculated completionStatus
|
|
10393
|
-
*
|
|
10394
|
-
* @example
|
|
10395
|
-
* ```typescript
|
|
10396
|
-
* // Update a draft record to make it complete
|
|
10397
|
-
* const updated = await service.updateRecord(draftId, {
|
|
10398
|
-
* price: 99.99,
|
|
10399
|
-
* status: "active"
|
|
10400
|
-
* });
|
|
10401
|
-
* // → updated.completionStatus = "complete" if all required fields now present
|
|
10402
|
-
* ```
|
|
10403
10604
|
*/
|
|
10404
10605
|
async updateRecord(recordId, data, options) {
|
|
10405
10606
|
const existing = await this.adapter.objectRecords.findById(recordId);
|
|
@@ -10407,22 +10608,23 @@ var RecordService = class extends TenantAwareService {
|
|
|
10407
10608
|
throw new RecordNotFoundError(recordId);
|
|
10408
10609
|
}
|
|
10409
10610
|
const schema = await this.schemaService.getObjectSchema(existing.objectId);
|
|
10410
|
-
await this.
|
|
10411
|
-
const policy = this.
|
|
10412
|
-
if (policy) {
|
|
10413
|
-
this.
|
|
10611
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "update");
|
|
10612
|
+
const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
10613
|
+
if (policy && this.userId) {
|
|
10614
|
+
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10615
|
+
checkRecordModifyOrThrow(policy, existing, ctx);
|
|
10414
10616
|
}
|
|
10415
10617
|
const mergedData = { ...existing.values, ...data };
|
|
10416
10618
|
const changedAttributes = Object.keys(data).filter((key) => existing.values[key] !== data[key]);
|
|
10417
|
-
const hookCtx =
|
|
10619
|
+
const hookCtx = createContextForUpdate(
|
|
10418
10620
|
schema,
|
|
10621
|
+
this.tenantId,
|
|
10419
10622
|
existing,
|
|
10420
|
-
data,
|
|
10421
10623
|
mergedData,
|
|
10422
10624
|
changedAttributes,
|
|
10423
|
-
_optionalChain([options, 'optionalAccess',
|
|
10625
|
+
_optionalChain([options, 'optionalAccess', _255 => _255.hookMetadata])
|
|
10424
10626
|
);
|
|
10425
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10627
|
+
if (!_optionalChain([options, 'optionalAccess', _256 => _256.skipHooks])) {
|
|
10426
10628
|
await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
|
|
10427
10629
|
}
|
|
10428
10630
|
const hookModifiedValues = {};
|
|
@@ -10431,19 +10633,19 @@ var RecordService = class extends TenantAwareService {
|
|
|
10431
10633
|
hookModifiedValues[key] = hookCtx.newValues[key];
|
|
10432
10634
|
}
|
|
10433
10635
|
}
|
|
10434
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10435
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10636
|
+
if (_optionalChain([options, 'optionalAccess', _257 => _257.validate]) !== false) {
|
|
10637
|
+
if (_optionalChain([options, 'optionalAccess', _258 => _258.partial])) {
|
|
10436
10638
|
validateDraftOrThrow(schema, mergedData);
|
|
10437
10639
|
} else {
|
|
10438
10640
|
validateObjectOrThrow(schema, mergedData);
|
|
10439
10641
|
}
|
|
10440
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10642
|
+
if (!_optionalChain([options, 'optionalAccess', _259 => _259.skipRelationValidation])) {
|
|
10441
10643
|
await this.relationService.validateRelationsOrThrow(schema, {
|
|
10442
10644
|
...data,
|
|
10443
10645
|
...hookModifiedValues
|
|
10444
10646
|
});
|
|
10445
10647
|
}
|
|
10446
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10648
|
+
if (!_optionalChain([options, 'optionalAccess', _260 => _260.skipUserValidation])) {
|
|
10447
10649
|
await this.userService.validateUsersOrThrow(schema, {
|
|
10448
10650
|
...data,
|
|
10449
10651
|
...hookModifiedValues
|
|
@@ -10451,7 +10653,7 @@ var RecordService = class extends TenantAwareService {
|
|
|
10451
10653
|
}
|
|
10452
10654
|
}
|
|
10453
10655
|
const completionStatus = computeRecordStatus(schema, mergedData);
|
|
10454
|
-
const label = await
|
|
10656
|
+
const label = await computeLabel(schema, mergedData, this.labelResolver);
|
|
10455
10657
|
const updatePayload = {
|
|
10456
10658
|
...data,
|
|
10457
10659
|
...hookModifiedValues,
|
|
@@ -10459,7 +10661,7 @@ var RecordService = class extends TenantAwareService {
|
|
|
10459
10661
|
__label: label,
|
|
10460
10662
|
__lastUpdatedBy: this.userId
|
|
10461
10663
|
};
|
|
10462
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10664
|
+
if (_optionalChain([options, 'optionalAccess', _261 => _261.metadata]) !== void 0) {
|
|
10463
10665
|
const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
|
|
10464
10666
|
const mergedMetadata = { ...existingMetadata, ...options.metadata };
|
|
10465
10667
|
const cleanedMetadata = Object.fromEntries(
|
|
@@ -10468,14 +10670,14 @@ var RecordService = class extends TenantAwareService {
|
|
|
10468
10670
|
updatePayload.__metadata = cleanedMetadata;
|
|
10469
10671
|
}
|
|
10470
10672
|
const updated = await this.adapter.objectRecords.update(recordId, updatePayload);
|
|
10471
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10673
|
+
if (!_optionalChain([options, 'optionalAccess', _262 => _262.skipHooks])) {
|
|
10472
10674
|
const afterCtx = {
|
|
10473
10675
|
...hookCtx,
|
|
10474
10676
|
record: updated
|
|
10475
10677
|
};
|
|
10476
10678
|
await this.hookRegistry.execute("afterUpdate", schema.name, afterCtx);
|
|
10477
10679
|
}
|
|
10478
|
-
await
|
|
10680
|
+
await recalculateParentRollups(updated, schema, this.rollupContext);
|
|
10479
10681
|
const allChangedAttributes = [
|
|
10480
10682
|
...changedAttributes,
|
|
10481
10683
|
...Object.keys(hookModifiedValues).filter((k) => !changedAttributes.includes(k))
|
|
@@ -10483,7 +10685,7 @@ var RecordService = class extends TenantAwareService {
|
|
|
10483
10685
|
if (this.auditService && this.userId && allChangedAttributes.length > 0) {
|
|
10484
10686
|
const changes = allChangedAttributes.map((attr) => ({
|
|
10485
10687
|
field: attr,
|
|
10486
|
-
oldValue: _optionalChain([hookCtx, 'access',
|
|
10688
|
+
oldValue: _optionalChain([hookCtx, 'access', _263 => _263.oldValues, 'optionalAccess', _264 => _264[attr]]),
|
|
10487
10689
|
newValue: hookCtx.newValues[attr]
|
|
10488
10690
|
}));
|
|
10489
10691
|
await this.auditService.logRecordAction({
|
|
@@ -10494,94 +10696,16 @@ var RecordService = class extends TenantAwareService {
|
|
|
10494
10696
|
recordId: updated.id,
|
|
10495
10697
|
recordLabel: updated.label,
|
|
10496
10698
|
changes,
|
|
10497
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10699
|
+
metadata: _optionalChain([options, 'optionalAccess', _265 => _265.hookMetadata])
|
|
10498
10700
|
});
|
|
10499
10701
|
}
|
|
10500
10702
|
return updated;
|
|
10501
10703
|
}
|
|
10704
|
+
// ============================================================================
|
|
10705
|
+
// DELETE
|
|
10706
|
+
// ============================================================================
|
|
10502
10707
|
/**
|
|
10503
|
-
*
|
|
10504
|
-
* @internal
|
|
10505
|
-
*/
|
|
10506
|
-
buildHookContext(schema, existing, newData, mergedData, changedAttributes, metadata) {
|
|
10507
|
-
const oldValuesSnapshot = { ...existing.values };
|
|
10508
|
-
return {
|
|
10509
|
-
objectId: schema.id,
|
|
10510
|
-
objectName: schema.name,
|
|
10511
|
-
recordId: existing.id,
|
|
10512
|
-
tenantId: this.tenantId,
|
|
10513
|
-
record: existing,
|
|
10514
|
-
oldValues: oldValuesSnapshot,
|
|
10515
|
-
newValues: mergedData,
|
|
10516
|
-
changedAttributes,
|
|
10517
|
-
getChange: (attr) => ({
|
|
10518
|
-
oldValue: oldValuesSnapshot[attr],
|
|
10519
|
-
newValue: _nullishCoalesce(newData[attr], () => ( oldValuesSnapshot[attr])),
|
|
10520
|
-
changed: changedAttributes.includes(attr)
|
|
10521
|
-
}),
|
|
10522
|
-
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10523
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
10524
|
-
};
|
|
10525
|
-
}
|
|
10526
|
-
/**
|
|
10527
|
-
* Build hook context for create operations (no existing record)
|
|
10528
|
-
* @internal
|
|
10529
|
-
*/
|
|
10530
|
-
buildCreateHookContext(schema, data, metadata) {
|
|
10531
|
-
const attributeNames = Object.keys(data);
|
|
10532
|
-
return {
|
|
10533
|
-
objectId: schema.id,
|
|
10534
|
-
objectName: schema.name,
|
|
10535
|
-
recordId: "",
|
|
10536
|
-
// Will be set after creation
|
|
10537
|
-
tenantId: this.tenantId,
|
|
10538
|
-
record: null,
|
|
10539
|
-
// Will be set after creation
|
|
10540
|
-
oldValues: {},
|
|
10541
|
-
newValues: data,
|
|
10542
|
-
changedAttributes: attributeNames,
|
|
10543
|
-
// All attributes are "new"
|
|
10544
|
-
getChange: (attr) => ({
|
|
10545
|
-
oldValue: void 0,
|
|
10546
|
-
newValue: data[attr],
|
|
10547
|
-
changed: attributeNames.includes(attr)
|
|
10548
|
-
}),
|
|
10549
|
-
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10550
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
10551
|
-
};
|
|
10552
|
-
}
|
|
10553
|
-
/**
|
|
10554
|
-
* Build hook context for delete operations
|
|
10555
|
-
* @internal
|
|
10556
|
-
*/
|
|
10557
|
-
buildDeleteHookContext(schema, record, metadata) {
|
|
10558
|
-
const attributeNames = Object.keys(record.values);
|
|
10559
|
-
return {
|
|
10560
|
-
objectId: schema.id,
|
|
10561
|
-
objectName: schema.name,
|
|
10562
|
-
recordId: record.id,
|
|
10563
|
-
tenantId: this.tenantId,
|
|
10564
|
-
record,
|
|
10565
|
-
oldValues: record.values,
|
|
10566
|
-
newValues: {},
|
|
10567
|
-
changedAttributes: attributeNames,
|
|
10568
|
-
// All attributes are being "removed"
|
|
10569
|
-
getChange: (attr) => ({
|
|
10570
|
-
oldValue: record.values[attr],
|
|
10571
|
-
newValue: void 0,
|
|
10572
|
-
changed: attributeNames.includes(attr)
|
|
10573
|
-
}),
|
|
10574
|
-
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10575
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
10576
|
-
};
|
|
10577
|
-
}
|
|
10578
|
-
/**
|
|
10579
|
-
* Delete a record
|
|
10580
|
-
*
|
|
10581
|
-
* Triggers beforeDelete and afterDelete hooks if a HookRegistry is configured.
|
|
10582
|
-
*
|
|
10583
|
-
* @param recordId - Record UUID
|
|
10584
|
-
* @param options - Delete options
|
|
10708
|
+
* Delete a record (soft delete)
|
|
10585
10709
|
*/
|
|
10586
10710
|
async deleteRecord(recordId, options) {
|
|
10587
10711
|
const record = await this.adapter.objectRecords.findById(recordId);
|
|
@@ -10589,31 +10713,30 @@ var RecordService = class extends TenantAwareService {
|
|
|
10589
10713
|
throw new RecordNotFoundError(recordId);
|
|
10590
10714
|
}
|
|
10591
10715
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10592
|
-
await this.
|
|
10593
|
-
const policy = this.
|
|
10594
|
-
if (policy) {
|
|
10595
|
-
this.
|
|
10716
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "delete");
|
|
10717
|
+
const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
10718
|
+
if (policy && this.userId) {
|
|
10719
|
+
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10720
|
+
checkRecordDeleteOrThrow(policy, record, ctx);
|
|
10596
10721
|
}
|
|
10597
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10598
|
-
|
|
10599
|
-
throw new ProtectedResourceError("object", schema.name, "delete");
|
|
10600
|
-
}
|
|
10722
|
+
if (_optionalChain([options, 'optionalAccess', _266 => _266.checkSystem]) && schema.system) {
|
|
10723
|
+
throw new ProtectedResourceError("object", schema.name, "delete");
|
|
10601
10724
|
}
|
|
10602
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10725
|
+
if (!_optionalChain([options, 'optionalAccess', _267 => _267.skipReferenceCheck])) {
|
|
10603
10726
|
const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
|
|
10604
10727
|
if (references.length > 0) {
|
|
10605
10728
|
throw new RecordReferencedError(recordId, references);
|
|
10606
10729
|
}
|
|
10607
10730
|
}
|
|
10608
|
-
const hookCtx =
|
|
10609
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10731
|
+
const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _268 => _268.hookMetadata]));
|
|
10732
|
+
if (!_optionalChain([options, 'optionalAccess', _269 => _269.skipHooks])) {
|
|
10610
10733
|
await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
|
|
10611
10734
|
}
|
|
10612
10735
|
await this.adapter.objectRecords.delete(recordId);
|
|
10613
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10736
|
+
if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipHooks])) {
|
|
10614
10737
|
await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
|
|
10615
10738
|
}
|
|
10616
|
-
await
|
|
10739
|
+
await recalculateParentRollups(record, schema, this.rollupContext);
|
|
10617
10740
|
if (this.auditService && this.userId) {
|
|
10618
10741
|
await this.auditService.logRecordAction({
|
|
10619
10742
|
action: "record.deleted",
|
|
@@ -10622,25 +10745,24 @@ var RecordService = class extends TenantAwareService {
|
|
|
10622
10745
|
objectId: schema.id,
|
|
10623
10746
|
recordId: record.id,
|
|
10624
10747
|
recordLabel: record.label,
|
|
10625
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10748
|
+
metadata: _optionalChain([options, 'optionalAccess', _271 => _271.hookMetadata])
|
|
10626
10749
|
});
|
|
10627
10750
|
}
|
|
10628
10751
|
}
|
|
10752
|
+
/**
|
|
10753
|
+
* Permanently delete a record (hard delete)
|
|
10754
|
+
*/
|
|
10755
|
+
async hardDeleteRecord(recordId) {
|
|
10756
|
+
const record = await this.getRecordOrThrow(recordId);
|
|
10757
|
+
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10758
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "delete");
|
|
10759
|
+
await this.adapter.objectRecords.hardDelete(recordId);
|
|
10760
|
+
}
|
|
10761
|
+
// ============================================================================
|
|
10762
|
+
// RESTORE
|
|
10763
|
+
// ============================================================================
|
|
10629
10764
|
/**
|
|
10630
10765
|
* Restore a soft-deleted record
|
|
10631
|
-
*
|
|
10632
|
-
* Triggers beforeRestore and afterRestore hooks if a HookRegistry is configured.
|
|
10633
|
-
*
|
|
10634
|
-
* @param recordId - Record UUID
|
|
10635
|
-
* @param options - Restore options
|
|
10636
|
-
* @returns Restored record
|
|
10637
|
-
*
|
|
10638
|
-
* @example
|
|
10639
|
-
* ```typescript
|
|
10640
|
-
* // Restore a deleted record
|
|
10641
|
-
* const restored = await service.restoreRecord("rec-123");
|
|
10642
|
-
* console.log(restored.deletedAt); // null
|
|
10643
|
-
* ```
|
|
10644
10766
|
*/
|
|
10645
10767
|
async restoreRecord(recordId, options) {
|
|
10646
10768
|
const record = await this.getRecordOrThrow(recordId);
|
|
@@ -10652,13 +10774,13 @@ var RecordService = class extends TenantAwareService {
|
|
|
10652
10774
|
);
|
|
10653
10775
|
}
|
|
10654
10776
|
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10655
|
-
await this.
|
|
10656
|
-
const hookCtx =
|
|
10657
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10777
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "update");
|
|
10778
|
+
const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _272 => _272.hookMetadata]));
|
|
10779
|
+
if (!_optionalChain([options, 'optionalAccess', _273 => _273.skipHooks])) {
|
|
10658
10780
|
await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
|
|
10659
10781
|
}
|
|
10660
10782
|
const restored = await this.adapter.objectRecords.restore(recordId);
|
|
10661
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10783
|
+
if (!_optionalChain([options, 'optionalAccess', _274 => _274.skipHooks])) {
|
|
10662
10784
|
const afterCtx = {
|
|
10663
10785
|
...hookCtx,
|
|
10664
10786
|
record: restored
|
|
@@ -10673,167 +10795,42 @@ var RecordService = class extends TenantAwareService {
|
|
|
10673
10795
|
objectId: schema.id,
|
|
10674
10796
|
recordId: restored.id,
|
|
10675
10797
|
recordLabel: restored.label,
|
|
10676
|
-
metadata: _optionalChain([options, 'optionalAccess',
|
|
10798
|
+
metadata: _optionalChain([options, 'optionalAccess', _275 => _275.hookMetadata])
|
|
10677
10799
|
});
|
|
10678
10800
|
}
|
|
10679
10801
|
return restored;
|
|
10680
10802
|
}
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
*/
|
|
10685
|
-
buildRestoreHookContext(schema, record, metadata) {
|
|
10686
|
-
return {
|
|
10687
|
-
objectId: schema.id,
|
|
10688
|
-
objectName: schema.name,
|
|
10689
|
-
recordId: record.id,
|
|
10690
|
-
tenantId: this.tenantId,
|
|
10691
|
-
record,
|
|
10692
|
-
oldValues: record.values,
|
|
10693
|
-
newValues: record.values,
|
|
10694
|
-
changedAttributes: [],
|
|
10695
|
-
getChange: (attr) => ({
|
|
10696
|
-
oldValue: record.values[attr],
|
|
10697
|
-
newValue: record.values[attr],
|
|
10698
|
-
changed: false
|
|
10699
|
-
}),
|
|
10700
|
-
metadata: _nullishCoalesce(metadata, () => ( {})),
|
|
10701
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
10702
|
-
};
|
|
10703
|
-
}
|
|
10704
|
-
/**
|
|
10705
|
-
* Enrich a record with computed formula values
|
|
10706
|
-
*
|
|
10707
|
-
* Formula attributes are calculated at read-time from the record's values.
|
|
10708
|
-
* This method adds the computed values to the record's values object.
|
|
10709
|
-
*
|
|
10710
|
-
* @param record - The record to enrich
|
|
10711
|
-
* @param schema - The object schema containing attribute definitions
|
|
10712
|
-
* @returns Record with formula values computed
|
|
10713
|
-
* @internal
|
|
10714
|
-
*/
|
|
10715
|
-
enrichWithFormulas(record, schema) {
|
|
10716
|
-
const formulaAttrs = schema.attributes.filter(
|
|
10717
|
-
(a) => a.type === "formula"
|
|
10718
|
-
);
|
|
10719
|
-
if (formulaAttrs.length === 0) {
|
|
10720
|
-
return record;
|
|
10721
|
-
}
|
|
10722
|
-
const enrichedValues = { ...record.values };
|
|
10723
|
-
for (const attr of formulaAttrs) {
|
|
10724
|
-
enrichedValues[attr.name] = evaluateFormulaAttribute(attr, record.values);
|
|
10725
|
-
}
|
|
10726
|
-
return {
|
|
10727
|
-
...record,
|
|
10728
|
-
values: enrichedValues
|
|
10729
|
-
};
|
|
10730
|
-
}
|
|
10731
|
-
/**
|
|
10732
|
-
* Enrich multiple records with computed formula values
|
|
10733
|
-
* @internal
|
|
10734
|
-
*/
|
|
10735
|
-
enrichRecordsWithFormulas(records, schema) {
|
|
10736
|
-
const formulaAttrs = schema.attributes.filter(
|
|
10737
|
-
(a) => a.type === "formula"
|
|
10738
|
-
);
|
|
10739
|
-
if (formulaAttrs.length === 0) {
|
|
10740
|
-
return records;
|
|
10741
|
-
}
|
|
10742
|
-
return records.map((record) => this.enrichWithFormulas(record, schema));
|
|
10743
|
-
}
|
|
10744
|
-
/**
|
|
10745
|
-
* Recalculate rollups after a record changes
|
|
10746
|
-
*
|
|
10747
|
-
* This handles three cases:
|
|
10748
|
-
* 1. The record itself has rollups (e.g., aggregating from related records it points to)
|
|
10749
|
-
* 2. Parent records have rollups that aggregate from this record (reverse pattern)
|
|
10750
|
-
* 3. Records that have forward rollups pointing to this record (forward pattern)
|
|
10751
|
-
*
|
|
10752
|
-
* @param record - The record that was modified
|
|
10753
|
-
* @param schema - Schema of the record's object
|
|
10754
|
-
* @internal
|
|
10755
|
-
*/
|
|
10756
|
-
async recalculateParentRollups(record, schema) {
|
|
10757
|
-
const ownRollupAttrs = schema.attributes.filter(
|
|
10758
|
-
(a) => a.type === "rollup"
|
|
10759
|
-
);
|
|
10760
|
-
if (ownRollupAttrs.length > 0) {
|
|
10761
|
-
await this.rollupService.recalculateAndUpdate(record, schema);
|
|
10762
|
-
}
|
|
10763
|
-
const affectedParentIds = await this.rollupService.findAffectedParentRecords(record, schema);
|
|
10764
|
-
if (affectedParentIds.length > 0) {
|
|
10765
|
-
const parentRecords = await this.adapter.objectRecords.findByIds(affectedParentIds);
|
|
10766
|
-
await Promise.all(
|
|
10767
|
-
parentRecords.map(async (parentRecord) => {
|
|
10768
|
-
const parentSchema = await this.schemaService.getObjectSchema(parentRecord.objectId);
|
|
10769
|
-
const rollupAttrs = parentSchema.attributes.filter(
|
|
10770
|
-
(a) => a.type === "rollup"
|
|
10771
|
-
);
|
|
10772
|
-
if (rollupAttrs.length > 0) {
|
|
10773
|
-
await this.rollupService.recalculateAndUpdate(parentRecord, parentSchema);
|
|
10774
|
-
}
|
|
10775
|
-
})
|
|
10776
|
-
);
|
|
10777
|
-
}
|
|
10778
|
-
const affectedForwardRecords = await this.rollupService.findRecordsWithForwardRollup(
|
|
10779
|
-
record,
|
|
10780
|
-
schema
|
|
10781
|
-
);
|
|
10782
|
-
await Promise.all(
|
|
10783
|
-
affectedForwardRecords.map(async (forwardRecord) => {
|
|
10784
|
-
const forwardSchema = await this.schemaService.getObjectSchema(forwardRecord.objectId);
|
|
10785
|
-
await this.rollupService.recalculateAndUpdate(forwardRecord, forwardSchema);
|
|
10786
|
-
})
|
|
10787
|
-
);
|
|
10788
|
-
}
|
|
10789
|
-
/**
|
|
10790
|
-
* Permanently delete a record (hard delete)
|
|
10791
|
-
*
|
|
10792
|
-
* This cannot be undone. Use with caution - prefer soft delete for data safety.
|
|
10793
|
-
* Does NOT trigger delete hooks (already triggered on soft delete).
|
|
10794
|
-
*
|
|
10795
|
-
* @param recordId - Record UUID
|
|
10796
|
-
*
|
|
10797
|
-
* @example
|
|
10798
|
-
* ```typescript
|
|
10799
|
-
* // Permanently delete a record
|
|
10800
|
-
* await service.hardDeleteRecord("rec-123");
|
|
10801
|
-
* ```
|
|
10802
|
-
*/
|
|
10803
|
-
async hardDeleteRecord(recordId) {
|
|
10804
|
-
const record = await this.getRecordOrThrow(recordId);
|
|
10805
|
-
const schema = await this.schemaService.getObjectSchema(record.objectId);
|
|
10806
|
-
await this.checkPermission(schema.name, "delete");
|
|
10807
|
-
await this.adapter.objectRecords.hardDelete(recordId);
|
|
10808
|
-
}
|
|
10803
|
+
// ============================================================================
|
|
10804
|
+
// LIST & SEARCH
|
|
10805
|
+
// ============================================================================
|
|
10809
10806
|
/**
|
|
10810
10807
|
* List records for an object with pagination
|
|
10811
|
-
*
|
|
10812
|
-
* @param objectId - Object UUID
|
|
10813
|
-
* @param options - List options
|
|
10814
|
-
* @returns Records and total count
|
|
10815
10808
|
*/
|
|
10816
10809
|
async listRecords(objectId, options) {
|
|
10817
10810
|
const schema = await this.schemaService.getObjectSchema(objectId);
|
|
10818
10811
|
if (this.permissionService && this.userId) {
|
|
10819
|
-
await this.
|
|
10812
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "read");
|
|
10820
10813
|
}
|
|
10821
|
-
const policy = _optionalChain([options, 'optionalAccess',
|
|
10814
|
+
const policy = _optionalChain([options, 'optionalAccess', _276 => _276.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
|
|
10822
10815
|
let effectiveOptions = options;
|
|
10823
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
10824
|
-
|
|
10816
|
+
if (_optionalChain([policy, 'optionalAccess', _277 => _277.applyListFilter]) && this.userId) {
|
|
10817
|
+
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10818
|
+
effectiveOptions = policy.applyListFilter(ctx, options);
|
|
10825
10819
|
}
|
|
10826
|
-
const result = await
|
|
10820
|
+
const result = await runWithSchemaContext(
|
|
10821
|
+
[schema],
|
|
10822
|
+
() => this.adapter.objectRecords.list(objectId, effectiveOptions)
|
|
10823
|
+
);
|
|
10827
10824
|
let filteredRecords = result.records;
|
|
10828
10825
|
let effectiveTotal = result.total;
|
|
10829
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
10830
|
-
const ctx =
|
|
10831
|
-
filteredRecords = result.records.filter((record) => _optionalChain([policy, 'access',
|
|
10826
|
+
if (_optionalChain([policy, 'optionalAccess', _278 => _278.canAccessRecord]) && this.userId) {
|
|
10827
|
+
const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
|
|
10828
|
+
filteredRecords = result.records.filter((record) => _optionalChain([policy, 'access', _279 => _279.canAccessRecord, 'optionalCall', _280 => _280(ctx, record)]));
|
|
10832
10829
|
effectiveTotal = filteredRecords.length;
|
|
10833
10830
|
}
|
|
10834
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
10831
|
+
if (!_optionalChain([options, 'optionalAccess', _281 => _281.skipFormulas])) {
|
|
10835
10832
|
return {
|
|
10836
|
-
records:
|
|
10833
|
+
records: enrichRecordsWithFormulas(filteredRecords, schema),
|
|
10837
10834
|
total: effectiveTotal
|
|
10838
10835
|
};
|
|
10839
10836
|
}
|
|
@@ -10844,55 +10841,43 @@ var RecordService = class extends TenantAwareService {
|
|
|
10844
10841
|
}
|
|
10845
10842
|
/**
|
|
10846
10843
|
* Search records using full-text search
|
|
10847
|
-
*
|
|
10848
|
-
* @param objectId - Object UUID
|
|
10849
|
-
* @param query - Search query
|
|
10850
|
-
* @param options - Search options
|
|
10851
|
-
* @returns Matching records and total count
|
|
10852
10844
|
*/
|
|
10853
10845
|
async searchRecords(objectId, query, options) {
|
|
10854
10846
|
const schema = await this.schemaService.getObjectSchema(objectId);
|
|
10855
10847
|
if (this.permissionService && this.userId) {
|
|
10856
|
-
await this.
|
|
10848
|
+
await checkPermission(this.permissionService, this.userId, schema.name, "read");
|
|
10857
10849
|
}
|
|
10858
|
-
const result = await
|
|
10859
|
-
|
|
10850
|
+
const result = await runWithSchemaContext(
|
|
10851
|
+
[schema],
|
|
10852
|
+
() => this.adapter.objectRecords.search(objectId, query, options)
|
|
10853
|
+
);
|
|
10854
|
+
if (!_optionalChain([options, 'optionalAccess', _282 => _282.skipFormulas])) {
|
|
10860
10855
|
return {
|
|
10861
|
-
records:
|
|
10856
|
+
records: enrichRecordsWithFormulas(result.records, schema),
|
|
10862
10857
|
total: result.total
|
|
10863
10858
|
};
|
|
10864
10859
|
}
|
|
10865
10860
|
return result;
|
|
10866
10861
|
}
|
|
10862
|
+
// ============================================================================
|
|
10863
|
+
// VALIDATION & STATUS
|
|
10864
|
+
// ============================================================================
|
|
10867
10865
|
/**
|
|
10868
10866
|
* Validate data against object schema without saving
|
|
10869
|
-
*
|
|
10870
|
-
* @param objectId - Object UUID
|
|
10871
|
-
* @param data - Data to validate
|
|
10872
|
-
* @returns Validation result
|
|
10873
10867
|
*/
|
|
10874
10868
|
async validateData(objectId, data) {
|
|
10875
10869
|
const schema = await this.schemaService.getObjectSchema(objectId);
|
|
10876
10870
|
return validateObject(schema, data);
|
|
10877
10871
|
}
|
|
10878
10872
|
/**
|
|
10879
|
-
* Compute the completion status for given data without saving
|
|
10880
|
-
* Useful for UI to show draft/complete status before submitting.
|
|
10881
|
-
*
|
|
10882
|
-
* @param objectId - Object UUID
|
|
10883
|
-
* @param data - Data to check
|
|
10884
|
-
* @returns Computed completion status
|
|
10873
|
+
* Compute the completion status for given data without saving
|
|
10885
10874
|
*/
|
|
10886
10875
|
async computeStatus(objectId, data) {
|
|
10887
10876
|
const schema = await this.schemaService.getObjectSchema(objectId);
|
|
10888
10877
|
return computeRecordStatus(schema, data);
|
|
10889
10878
|
}
|
|
10890
10879
|
/**
|
|
10891
|
-
* Refresh the completion status of an existing record
|
|
10892
|
-
* Useful when schema changes and you need to recompute statuses.
|
|
10893
|
-
*
|
|
10894
|
-
* @param recordId - Record UUID
|
|
10895
|
-
* @returns Updated completion status
|
|
10880
|
+
* Refresh the completion status of an existing record
|
|
10896
10881
|
*/
|
|
10897
10882
|
async refreshRecordStatus(recordId) {
|
|
10898
10883
|
const record = await this.getRecordOrThrow(recordId);
|
|
@@ -11055,8 +11040,8 @@ var RollupScheduler = class {
|
|
|
11055
11040
|
this.getSchemaById = getSchemaById;
|
|
11056
11041
|
this.pending = /* @__PURE__ */ new Map();
|
|
11057
11042
|
this.rollupService = new RollupService(adapter);
|
|
11058
|
-
this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11059
|
-
this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11043
|
+
this.debounceMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _283 => _283.debounceMs]), () => ( 100));
|
|
11044
|
+
this.maxPending = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _284 => _284.maxPending]), () => ( 100));
|
|
11060
11045
|
}
|
|
11061
11046
|
/**
|
|
11062
11047
|
* Schedule a rollup recalculation for a parent record.
|
|
@@ -11132,7 +11117,7 @@ var UserProfileService = class extends TenantAwareService {
|
|
|
11132
11117
|
constructor(adapter, options) {
|
|
11133
11118
|
super();
|
|
11134
11119
|
this.adapter = adapter;
|
|
11135
|
-
this.auditService = _optionalChain([options, 'optionalAccess',
|
|
11120
|
+
this.auditService = _optionalChain([options, 'optionalAccess', _285 => _285.auditService]);
|
|
11136
11121
|
}
|
|
11137
11122
|
/**
|
|
11138
11123
|
* Create a new user profile (typically after first auth).
|
|
@@ -11265,7 +11250,7 @@ var UserProfileService = class extends TenantAwareService {
|
|
|
11265
11250
|
*/
|
|
11266
11251
|
async deleteProfile(profileId, options) {
|
|
11267
11252
|
const profile = await this.getProfileOrThrow(profileId);
|
|
11268
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11253
|
+
if (_optionalChain([options, 'optionalAccess', _286 => _286.checkAdmin])) {
|
|
11269
11254
|
if (profile.role === "admin") {
|
|
11270
11255
|
const adminCount = await this.adapter.userProfiles.countByRole("admin");
|
|
11271
11256
|
if (adminCount <= 1) {
|
|
@@ -11334,7 +11319,7 @@ var UserProfileService = class extends TenantAwareService {
|
|
|
11334
11319
|
*/
|
|
11335
11320
|
async hasRole(profileId, role) {
|
|
11336
11321
|
const profile = await this.getProfile(profileId);
|
|
11337
|
-
return _optionalChain([profile, 'optionalAccess',
|
|
11322
|
+
return _optionalChain([profile, 'optionalAccess', _287 => _287.role]) === role;
|
|
11338
11323
|
}
|
|
11339
11324
|
/**
|
|
11340
11325
|
* Check if user is admin
|
|
@@ -11629,9 +11614,9 @@ var WorkflowInstanceService = class extends TenantAwareService {
|
|
|
11629
11614
|
super();
|
|
11630
11615
|
this.adapter = adapter;
|
|
11631
11616
|
this.workflowService = workflowService;
|
|
11632
|
-
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11633
|
-
this.schemaService = _optionalChain([options, 'optionalAccess',
|
|
11634
|
-
this.recordService = _optionalChain([options, 'optionalAccess',
|
|
11617
|
+
this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _288 => _288.executorRegistry]), () => ( getDefaultExecutorRegistry()));
|
|
11618
|
+
this.schemaService = _optionalChain([options, 'optionalAccess', _289 => _289.schemaService]);
|
|
11619
|
+
this.recordService = _optionalChain([options, 'optionalAccess', _290 => _290.recordService]);
|
|
11635
11620
|
}
|
|
11636
11621
|
/**
|
|
11637
11622
|
* Start a new workflow instance
|
|
@@ -11757,7 +11742,7 @@ var WorkflowInstanceService = class extends TenantAwareService {
|
|
|
11757
11742
|
if (!this.adapter.workflowInstances) {
|
|
11758
11743
|
return { instances: [], total: 0 };
|
|
11759
11744
|
}
|
|
11760
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11745
|
+
if (_optionalChain([options, 'optionalAccess', _291 => _291.workflowName])) {
|
|
11761
11746
|
const instances2 = await this.getInstancesByWorkflow(options.workflowName);
|
|
11762
11747
|
let filtered = instances2;
|
|
11763
11748
|
if (options.status) {
|
|
@@ -11771,11 +11756,11 @@ var WorkflowInstanceService = class extends TenantAwareService {
|
|
|
11771
11756
|
return { instances: paginated, total: total2 };
|
|
11772
11757
|
}
|
|
11773
11758
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
|
|
11774
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
11775
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
11759
|
+
limit: _optionalChain([options, 'optionalAccess', _292 => _292.limit]),
|
|
11760
|
+
offset: _optionalChain([options, 'optionalAccess', _293 => _293.offset])
|
|
11776
11761
|
});
|
|
11777
11762
|
let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
11778
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11763
|
+
if (_optionalChain([options, 'optionalAccess', _294 => _294.status])) {
|
|
11779
11764
|
instances = instances.filter((i) => i.status === options.status);
|
|
11780
11765
|
}
|
|
11781
11766
|
return { instances, total };
|
|
@@ -11795,9 +11780,9 @@ var WorkflowInstanceService = class extends TenantAwareService {
|
|
|
11795
11780
|
return { instances: [], total: 0 };
|
|
11796
11781
|
}
|
|
11797
11782
|
const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
|
|
11798
|
-
status: _optionalChain([options, 'optionalAccess',
|
|
11799
|
-
limit: _optionalChain([options, 'optionalAccess',
|
|
11800
|
-
offset: _optionalChain([options, 'optionalAccess',
|
|
11783
|
+
status: _optionalChain([options, 'optionalAccess', _295 => _295.status]),
|
|
11784
|
+
limit: _optionalChain([options, 'optionalAccess', _296 => _296.limit]),
|
|
11785
|
+
offset: _optionalChain([options, 'optionalAccess', _297 => _297.offset])
|
|
11801
11786
|
});
|
|
11802
11787
|
const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
|
|
11803
11788
|
return { instances, total };
|
|
@@ -12176,7 +12161,7 @@ var WorkflowParticipationService = class extends TenantAwareService {
|
|
|
12176
12161
|
SchemaErrorCode.RECORD_NOT_FOUND
|
|
12177
12162
|
);
|
|
12178
12163
|
}
|
|
12179
|
-
const template = _optionalChain([instance, 'access',
|
|
12164
|
+
const template = _optionalChain([instance, 'access', _298 => _298.workflowSnapshot, 'access', _299 => _299.participants, 'optionalAccess', _300 => _300.find, 'call', _301 => _301(
|
|
12180
12165
|
(p) => p.id === input.participantTemplateId
|
|
12181
12166
|
)]);
|
|
12182
12167
|
if (!template) {
|
|
@@ -12479,7 +12464,7 @@ var WorkflowRelationService = class extends TenantAwareService {
|
|
|
12479
12464
|
if (attr.type !== "relation") continue;
|
|
12480
12465
|
for (const slot of slots) {
|
|
12481
12466
|
const slotData = context.slots[slot.id];
|
|
12482
|
-
const slotRecordId = _optionalChain([slotData, 'optionalAccess',
|
|
12467
|
+
const slotRecordId = _optionalChain([slotData, 'optionalAccess', _302 => _302.id]);
|
|
12483
12468
|
if (!slotRecordId) continue;
|
|
12484
12469
|
const targetsSlotObject = attr.targets.some(
|
|
12485
12470
|
(t) => t.object === slot.objectName
|
|
@@ -13448,4 +13433,12 @@ var NoopGeocodingAdapter = class {
|
|
|
13448
13433
|
|
|
13449
13434
|
|
|
13450
13435
|
|
|
13451
|
-
exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isSignedLinkAuth = isSignedLinkAuth; exports.isPinCodeAuth = isPinCodeAuth; exports.canParticipate = canParticipate; exports.canAuthenticate = canAuthenticate; exports.canExecuteNode = canExecuteNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.mergeFormToSlot = mergeFormToSlot; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isParticipationEvent = isParticipationEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.ParticipantAuthConfigSchema = ParticipantAuthConfigSchema; exports.ParticipantTemplateSchema = ParticipantTemplateSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.asTenantId = asTenantId; exports.asUserId = asUserId; exports.generateId = generateId; exports.generatePrefixedId = generatePrefixedId; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.DirectTableTabConfig = DirectTableTabConfig; exports.InverseTableTabConfig = InverseTableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.NotesTabConfig = NotesTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.TabBuilder = TabBuilder; exports.ViewBuilder = ViewBuilder; exports.view = view; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowParticipantBuilder = WorkflowParticipantBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES; exports.textConfigSchema = textConfigSchema; exports.textareaConfigSchema = textareaConfigSchema; exports.richtextConfigSchema = richtextConfigSchema; exports.numberConfigSchema = numberConfigSchema; exports.checkboxConfigSchema = checkboxConfigSchema; exports.dateConfigSchema = dateConfigSchema; exports.phoneConfigSchema = phoneConfigSchema; exports.currencyConfigSchema = currencyConfigSchema; exports.statusConfigSchema = statusConfigSchema; exports.locationConfigSchema = locationConfigSchema; exports.selectConfigSchema = selectConfigSchema; exports.multiselectConfigSchema = multiselectConfigSchema; exports.fileConfigSchema = fileConfigSchema; exports.userConfigSchema = userConfigSchema; exports.relationConfigSchema = relationConfigSchema; exports.ratingConfigSchema = ratingConfigSchema; exports.formulaConfigSchema = formulaConfigSchema; exports.rollupConfigSchema = rollupConfigSchema; exports.attributeConfigSchemas = attributeConfigSchemas; exports.getAttributeConfigSchema = getAttributeConfigSchema; exports.validateAttributeConfig = validateAttributeConfig; exports.parseAttributeConfig = parseAttributeConfig; exports.safeParseAttributeConfig = safeParseAttributeConfig; exports.createTextValidator = createTextValidator; exports.createNumberValidator = createNumberValidator; exports.createCheckboxValidator = createCheckboxValidator; exports.createDateValidator = createDateValidator; exports.createPhoneValidator = createPhoneValidator; exports.createCurrencyValidator = createCurrencyValidator; exports.createStatusValidator = createStatusValidator; exports.createSelectValidator = createSelectValidator; exports.createMultiselectValidator = createMultiselectValidator; exports.createLocationValidator = createLocationValidator; exports.createFileValidator = createFileValidator; exports.createUserValidator = createUserValidator; exports.createSingleRelationValidator = createSingleRelationValidator; exports.createMultiRelationValidator = createMultiRelationValidator; exports.createRelationValidator = createRelationValidator; exports.createRatingValidator = createRatingValidator; exports.createFormulaValidator = createFormulaValidator; exports.createRollupValidator = createRollupValidator; exports.createTextAreaValidator = createTextAreaValidator; exports.createRichtextValidator = createRichtextValidator; exports.createAttributeValidator = createAttributeValidator; exports.createFormAttributeValidator = createFormAttributeValidator; exports.createObjectValidator = createObjectValidator; exports.validateAttribute = validateAttribute; exports.validateObject = validateObject; exports.validateObjectOrThrow = validateObjectOrThrow; exports.createDraftValidator = createDraftValidator; exports.validateDraft = validateDraft; exports.validateDraftOrThrow = validateDraftOrThrow; exports.getMissingRequiredAttributes = getMissingRequiredAttributes; exports.isRecordComplete = isRecordComplete; exports.computeRecordStatus = computeRecordStatus; exports.ParticipationTokenService = ParticipationTokenService; exports.getDefaultTokenService = getDefaultTokenService; exports.initializeTokenService = initializeTokenService; exports.PinCodeService = PinCodeService; exports.getDefaultPinCodeService = getDefaultPinCodeService; exports.initializePinCodeService = initializePinCodeService; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.getContext = getContext; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.DEFAULT_LABEL_FALLBACK = DEFAULT_LABEL_FALLBACK; exports.renderLabelExpression = renderLabelExpression; exports.isLabelExpression = isLabelExpression; exports.extractAttributeNames = extractAttributeNames; exports.enrichValuesForDisplay = enrichValuesForDisplay; exports.enrichValuesWithSelectLabels = enrichValuesWithSelectLabels; exports.extractRelationIds = extractRelationIds; exports.computeLabelWithRelations = computeLabelWithRelations; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.notesPolicy = notesPolicy; exports.buildAuditChanges = buildAuditChanges; exports.TenantAwareService = TenantAwareService; exports.TenantAwareRepository = TenantAwareRepository; exports.AuditService = AuditService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.ObjectSchemaService = ObjectSchemaService; exports.PermissionService = PermissionService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.UserService = UserService; exports.RecordService = RecordService; exports.RelationResolverService = RelationResolverService; exports.RollupScheduler = RollupScheduler; exports.UserProfileService = UserProfileService; exports.ViewService = ViewService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
|
|
13436
|
+
|
|
13437
|
+
|
|
13438
|
+
|
|
13439
|
+
|
|
13440
|
+
|
|
13441
|
+
|
|
13442
|
+
|
|
13443
|
+
|
|
13444
|
+
exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isEndNode = isEndNode; exports.getNodeOutputs = getNodeOutputs; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isSignedLinkAuth = isSignedLinkAuth; exports.isPinCodeAuth = isPinCodeAuth; exports.canParticipate = canParticipate; exports.canAuthenticate = canAuthenticate; exports.canExecuteNode = canExecuteNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.mergeFormToSlot = mergeFormToSlot; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isParticipationEvent = isParticipationEvent; exports.ConditionOperatorSchema = ConditionOperatorSchema; exports.ConditionRuleSchema = ConditionRuleSchema; exports.ConditionGroupSchema = ConditionGroupSchema; exports.StartNodeSchema = StartNodeSchema; exports.FormFieldRefSchema = FormFieldRefSchema; exports.FlowRowFieldSchema = FlowRowFieldSchema; exports.FlowRowSchema = FlowRowSchema; exports.FormNodeSchema = FormNodeSchema; exports.ConditionNodeSchema = ConditionNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.ParticipantAuthConfigSchema = ParticipantAuthConfigSchema; exports.ParticipantTemplateSchema = ParticipantTemplateSchema; exports.NodePositionSchema = NodePositionSchema; exports.ViewportSchema = ViewportSchema; exports.WorkflowLayoutSchema = WorkflowLayoutSchema; exports.ThemeColorsSchema = ThemeColorsSchema; exports.ThemeLogoSchema = ThemeLogoSchema; exports.WorkflowThemeSchema = WorkflowThemeSchema; exports.WorkflowConfigSchema = WorkflowConfigSchema; exports.WorkflowStatusSchema = WorkflowStatusSchema; exports.WorkflowDefinitionSchema = WorkflowDefinitionSchema; exports.asTenantId = asTenantId; exports.asUserId = asUserId; exports.generateId = generateId; exports.generatePrefixedId = generatePrefixedId; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; exports.SchemaErrorCode = SchemaErrorCode; exports.SchemaError = SchemaError; exports.NotFoundError = NotFoundError; exports.ObjectNotFoundError = ObjectNotFoundError; exports.AttributeNotFoundError = AttributeNotFoundError; exports.RecordNotFoundError = RecordNotFoundError; exports.UserProfileNotFoundError = UserProfileNotFoundError; exports.FileNotFoundError = FileNotFoundError; exports.ValidationError = ValidationError; exports.ProtectedResourceError = ProtectedResourceError; exports.SyncError = SyncError; exports.NotSystemObjectError = NotSystemObjectError; exports.DuplicateError = DuplicateError; exports.isSchemaError = isSchemaError; exports.isNotFoundError = isNotFoundError; exports.isValidationError = isValidationError; exports.isProtectedResourceError = isProtectedResourceError; exports.ForbiddenError = ForbiddenError; exports.ProtectedRoleError = ProtectedRoleError; exports.RoleNotFoundError = RoleNotFoundError; exports.isForbiddenError = isForbiddenError; exports.text = text; exports.textarea = textarea; exports.richtext = richtext; exports.number = number; exports.checkbox = checkbox; exports.date = date; exports.phone = phone; exports.currency = currency; exports.status = status; exports.select = select; exports.multiselect = multiselect; exports.location = location; exports.file = file; exports.user = user; exports.relation = relation; exports.rating = rating; exports.formula = formula; exports.rollup = rollup; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.DirectTableTabConfig = DirectTableTabConfig; exports.InverseTableTabConfig = InverseTableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.NotesTabConfig = NotesTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.TabBuilder = TabBuilder; exports.ViewBuilder = ViewBuilder; exports.view = view; exports.group = group; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowParticipantBuilder = WorkflowParticipantBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES; exports.textConfigSchema = textConfigSchema; exports.textareaConfigSchema = textareaConfigSchema; exports.richtextConfigSchema = richtextConfigSchema; exports.numberConfigSchema = numberConfigSchema; exports.checkboxConfigSchema = checkboxConfigSchema; exports.dateConfigSchema = dateConfigSchema; exports.phoneConfigSchema = phoneConfigSchema; exports.currencyConfigSchema = currencyConfigSchema; exports.statusConfigSchema = statusConfigSchema; exports.locationConfigSchema = locationConfigSchema; exports.selectConfigSchema = selectConfigSchema; exports.multiselectConfigSchema = multiselectConfigSchema; exports.fileConfigSchema = fileConfigSchema; exports.userConfigSchema = userConfigSchema; exports.relationConfigSchema = relationConfigSchema; exports.ratingConfigSchema = ratingConfigSchema; exports.formulaConfigSchema = formulaConfigSchema; exports.rollupConfigSchema = rollupConfigSchema; exports.attributeConfigSchemas = attributeConfigSchemas; exports.getAttributeConfigSchema = getAttributeConfigSchema; exports.validateAttributeConfig = validateAttributeConfig; exports.parseAttributeConfig = parseAttributeConfig; exports.safeParseAttributeConfig = safeParseAttributeConfig; exports.createTextValidator = createTextValidator; exports.createNumberValidator = createNumberValidator; exports.createCheckboxValidator = createCheckboxValidator; exports.createDateValidator = createDateValidator; exports.createPhoneValidator = createPhoneValidator; exports.createCurrencyValidator = createCurrencyValidator; exports.createStatusValidator = createStatusValidator; exports.createSelectValidator = createSelectValidator; exports.createMultiselectValidator = createMultiselectValidator; exports.createLocationValidator = createLocationValidator; exports.createFileValidator = createFileValidator; exports.createUserValidator = createUserValidator; exports.createSingleRelationValidator = createSingleRelationValidator; exports.createMultiRelationValidator = createMultiRelationValidator; exports.createRelationValidator = createRelationValidator; exports.createRatingValidator = createRatingValidator; exports.createFormulaValidator = createFormulaValidator; exports.createRollupValidator = createRollupValidator; exports.createTextAreaValidator = createTextAreaValidator; exports.createRichtextValidator = createRichtextValidator; exports.createAttributeValidator = createAttributeValidator; exports.createFormAttributeValidator = createFormAttributeValidator; exports.createObjectValidator = createObjectValidator; exports.validateAttribute = validateAttribute; exports.validateObject = validateObject; exports.validateObjectOrThrow = validateObjectOrThrow; exports.createDraftValidator = createDraftValidator; exports.validateDraft = validateDraft; exports.validateDraftOrThrow = validateDraftOrThrow; exports.getMissingRequiredAttributes = getMissingRequiredAttributes; exports.isRecordComplete = isRecordComplete; exports.computeRecordStatus = computeRecordStatus; exports.ParticipationTokenService = ParticipationTokenService; exports.getDefaultTokenService = getDefaultTokenService; exports.initializeTokenService = initializeTokenService; exports.PinCodeService = PinCodeService; exports.getDefaultPinCodeService = getDefaultPinCodeService; exports.initializePinCodeService = initializePinCodeService; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext; exports.getTenantId = getTenantId; exports.getUserId = getUserId; exports.hasContext = hasContext; exports.runWithContext = runWithContext; exports.withTenantContext = withTenantContext; exports.QueryBuilder = QueryBuilder; exports.createQueryBuilder = createQueryBuilder; exports.evaluateCondition = evaluateCondition; exports.evaluate = evaluate; exports.evaluateWithTrace = evaluateWithTrace; exports.ExecutorRegistry = ExecutorRegistry; exports.success = success; exports.wait = wait; exports.complete = complete; exports.error = error; exports.ConditionExecutor = ConditionExecutor; exports.EndExecutor = EndExecutor; exports.FormExecutor = FormExecutor; exports.StartExecutor = StartExecutor; exports.createDefaultExecutorRegistry = createDefaultExecutorRegistry; exports.getDefaultExecutorRegistry = getDefaultExecutorRegistry; exports.evaluateFormula = evaluateFormula; exports.evaluateFormulaWithResult = evaluateFormulaWithResult; exports.formatFormulaResult = formatFormulaResult; exports.evaluateFormulaAttribute = evaluateFormulaAttribute; exports.validateFormulaExpression = validateFormulaExpression; exports.extractFormulaVariables = extractFormulaVariables; exports.extractRelationReferences = extractRelationReferences; exports.extractRelationNames = extractRelationNames; exports.hasRelationReferences = hasRelationReferences; exports.flattenRelationsForEval = flattenRelationsForEval; exports.evaluateFormulaWithRelations = evaluateFormulaWithRelations; exports.evaluateFormulaAttributeWithRelations = evaluateFormulaAttributeWithRelations; exports.InvalidPathError = InvalidPathError; exports.MaxDepthExceededError = MaxDepthExceededError; exports.parsePath = parsePath; exports.validatePath = validatePath; exports.pathHasManyCardinality = pathHasManyCardinality; exports.getPathDepth = getPathDepth; exports.getTargetAttributeName = getTargetAttributeName; exports.getRelationPath = getRelationPath; exports.traversePath = traversePath; exports.resolveSingleValue = resolveSingleValue; exports.resolveMultiplePaths = resolveMultiplePaths; exports.NoopHookRegistry = NoopHookRegistry; exports.DEFAULT_LABEL_FALLBACK = DEFAULT_LABEL_FALLBACK; exports.renderLabelExpression = renderLabelExpression; exports.isLabelExpression = isLabelExpression; exports.extractAttributeNames = extractAttributeNames; exports.enrichValuesForDisplay = enrichValuesForDisplay; exports.enrichValuesWithSelectLabels = enrichValuesWithSelectLabels; exports.extractRelationIds = extractRelationIds; exports.computeLabelWithRelations = computeLabelWithRelations; exports.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.notesPolicy = notesPolicy; exports.buildAuditChanges = buildAuditChanges; exports.TenantAwareService = TenantAwareService; exports.TenantAwareRepository = TenantAwareRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.AuditService = AuditService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.ObjectSchemaService = ObjectSchemaService; exports.PermissionService = PermissionService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.UserService = UserService; exports.RecordService = RecordService; exports.RelationResolverService = RelationResolverService; exports.RollupScheduler = RollupScheduler; exports.UserProfileService = UserProfileService; exports.ViewService = ViewService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.WorkflowParticipationService = WorkflowParticipationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.syncNativeViews = syncNativeViews; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
|