@stndrds/schema 1.0.0-alpha.85 → 1.0.0-alpha.87

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.
@@ -1390,6 +1390,9 @@ function isConditionNode(node) {
1390
1390
  function isAssignNode(node) {
1391
1391
  return node.type === "assign";
1392
1392
  }
1393
+ function isAINode(node) {
1394
+ return node.type === "ai";
1395
+ }
1393
1396
  function isEndNode(node) {
1394
1397
  return node.type === "end";
1395
1398
  }
@@ -1530,6 +1533,47 @@ var assignNodeType = {
1530
1533
  };
1531
1534
  nodeTypeRegistry.register(assignNodeType);
1532
1535
 
1536
+ // src/types/workflows/node-types/ai.node-type.ts
1537
+ var aiNodeType = {
1538
+ type: "ai",
1539
+ isLinear: true,
1540
+ structural: false,
1541
+ getOutputs(node) {
1542
+ return node.next ? [node.next] : [];
1543
+ },
1544
+ setNext(node, targetId) {
1545
+ return { ...node, next: targetId };
1546
+ },
1547
+ getSlotIds(node) {
1548
+ const slotIds = /* @__PURE__ */ new Set();
1549
+ const action = node.action;
1550
+ if (action.type === "document-generation") {
1551
+ for (const id of action.inputSlotIds) slotIds.add(id);
1552
+ for (const id of action.targetSlotIds) slotIds.add(id);
1553
+ } else if (action.type === "code-execution") {
1554
+ for (const id of _nullishCoalesce(action.inputSlotIds, () => ( []))) slotIds.add(id);
1555
+ }
1556
+ return [...slotIds];
1557
+ },
1558
+ validate(node) {
1559
+ const errors = [];
1560
+ if (!node.label) errors.push("AINode must have a label");
1561
+ if (!node.action) errors.push("AINode must have an action");
1562
+ if (!node.next) errors.push("AINode must have a 'next' target");
1563
+ if (_optionalChain([node, 'access', _29 => _29.action, 'optionalAccess', _30 => _30.type]) === "document-generation") {
1564
+ if (!node.action.templateId) errors.push("Document generation must have a templateId");
1565
+ if (!_optionalChain([node, 'access', _31 => _31.action, 'access', _32 => _32.inputSlotIds, 'optionalAccess', _33 => _33.length]))
1566
+ errors.push("Document generation must have input slots");
1567
+ if (!_optionalChain([node, 'access', _34 => _34.action, 'access', _35 => _35.targetSlotIds, 'optionalAccess', _36 => _36.length]))
1568
+ errors.push("Document generation must have target slots");
1569
+ } else if (_optionalChain([node, 'access', _37 => _37.action, 'optionalAccess', _38 => _38.type]) === "code-execution") {
1570
+ if (!node.action.code) errors.push("Code execution must have code");
1571
+ }
1572
+ return errors;
1573
+ }
1574
+ };
1575
+ nodeTypeRegistry.register(aiNodeType);
1576
+
1533
1577
  // src/types/workflows/node-types/end.node-type.ts
1534
1578
  var endNodeType = {
1535
1579
  type: "end",
@@ -1742,14 +1786,15 @@ function isInvitationOrGrantEvent(event) {
1742
1786
  var ZONE_ORDER = ["collect", "actions"];
1743
1787
  var ZONE_CONFIG = {
1744
1788
  collect: { allowedNodeTypes: ["form", "condition"] },
1745
- actions: { allowedNodeTypes: ["condition", "assign"] }
1789
+ actions: { allowedNodeTypes: ["condition", "assign", "ai"] }
1746
1790
  };
1747
1791
  var TERMINAL_NODE_TYPES = /* @__PURE__ */ new Set(["start", "end"]);
1748
1792
  var NODE_TYPE_ZONE = {
1749
1793
  form: "collect",
1750
1794
  condition: "collect",
1751
1795
  // default — overridden by assignNodeZones logic
1752
- assign: "actions"
1796
+ assign: "actions",
1797
+ ai: "actions"
1753
1798
  };
1754
1799
  function assignNodeZones(orderedNodes) {
1755
1800
  const result = /* @__PURE__ */ new Map();
@@ -1834,9 +1879,14 @@ var StartNodeSchema = _zod.z.object({
1834
1879
  id: _zod.z.string().min(1),
1835
1880
  next: _zod.z.string().nullish()
1836
1881
  });
1882
+ var RelationFieldConfigSchema = _zod.z.object({
1883
+ visibleProperties: _zod.z.array(_zod.z.string()).optional(),
1884
+ allowCreate: _zod.z.boolean().optional()
1885
+ }).optional();
1837
1886
  var FormFieldRefSchema = _zod.z.object({
1838
1887
  slotId: _zod.z.string().min(1, "slotId is required"),
1839
- attribute: _zod.z.string().min(1, "attribute is required")
1888
+ attribute: _zod.z.string().min(1, "attribute is required"),
1889
+ relationConfig: RelationFieldConfigSchema
1840
1890
  });
1841
1891
  var FlowRowFieldSchema = _zod.z.object({
1842
1892
  id: _zod.z.string().min(1),
@@ -1844,7 +1894,8 @@ var FlowRowFieldSchema = _zod.z.object({
1844
1894
  attribute: _zod.z.string().min(1),
1845
1895
  label: _zod.z.string().max(200).optional(),
1846
1896
  tooltip: _zod.z.string().max(1e3).optional(),
1847
- required: _zod.z.boolean().optional()
1897
+ required: _zod.z.boolean().optional(),
1898
+ relationConfig: RelationFieldConfigSchema
1848
1899
  });
1849
1900
  var FlowFieldsRowSchema = _zod.z.object({
1850
1901
  id: _zod.z.string().min(1),
@@ -1925,6 +1976,35 @@ var AssignNodeSchema = _zod.z.object({
1925
1976
  assignments: _zod.z.array(AssignmentMappingSchema).min(1),
1926
1977
  next: _zod.z.string().nullish()
1927
1978
  });
1979
+ var DocumentGenerationActionSchema = _zod.z.object({
1980
+ type: _zod.z.literal("document-generation"),
1981
+ templateId: _zod.z.string().min(1, "Template ID is required"),
1982
+ inputSlotIds: _zod.z.array(_zod.z.string().min(1)).min(1, "At least one input slot is required"),
1983
+ targetSlotIds: _zod.z.array(_zod.z.string().min(1)).min(1, "At least one target slot is required"),
1984
+ outputFormat: _zod.z.enum(["pdf", "docx"]),
1985
+ aiInstructions: _zod.z.string().nullish()
1986
+ });
1987
+ var CodeExecutionActionSchema = _zod.z.object({
1988
+ type: _zod.z.literal("code-execution"),
1989
+ code: _zod.z.string().min(1, "Code is required"),
1990
+ language: _zod.z.enum(["javascript", "typescript", "python"]),
1991
+ inputSlotIds: _zod.z.array(_zod.z.string().min(1)).optional(),
1992
+ outputVariable: _zod.z.string().optional(),
1993
+ packages: _zod.z.array(_zod.z.string()).optional()
1994
+ });
1995
+ var AIActionConfigSchema = _zod.z.discriminatedUnion("type", [
1996
+ DocumentGenerationActionSchema,
1997
+ CodeExecutionActionSchema
1998
+ ]);
1999
+ var AINodeSchema = _zod.z.object({
2000
+ type: _zod.z.literal("ai"),
2001
+ id: _zod.z.string().min(1),
2002
+ label: _zod.z.string().min(1),
2003
+ description: _zod.z.string().nullish(),
2004
+ action: AIActionConfigSchema,
2005
+ timeoutMs: _zod.z.number().positive().optional(),
2006
+ next: _zod.z.string().nullish()
2007
+ });
1928
2008
  var EndNodeSchema = _zod.z.object({
1929
2009
  type: _zod.z.literal("end"),
1930
2010
  id: _zod.z.string().min(1),
@@ -1936,6 +2016,7 @@ var WorkflowNodeSchema = _zod.z.discriminatedUnion("type", [
1936
2016
  FormNodeSchema,
1937
2017
  ConditionNodeSchema,
1938
2018
  AssignNodeSchema,
2019
+ AINodeSchema,
1939
2020
  EndNodeSchema
1940
2021
  ]);
1941
2022
  var SlotModeSchema = _zod.z.enum(["create", "select", "optional"]);
@@ -2049,7 +2130,7 @@ var WorkflowDefinitionSchema = _zod.z.object({
2049
2130
  ).refine(
2050
2131
  (def) => {
2051
2132
  const startNode = def.nodes[def.startNodeId];
2052
- return _optionalChain([startNode, 'optionalAccess', _29 => _29.type]) === "start";
2133
+ return _optionalChain([startNode, 'optionalAccess', _39 => _39.type]) === "start";
2053
2134
  },
2054
2135
  {
2055
2136
  message: "startNodeId must reference a node of type 'start'"
@@ -2309,8 +2390,8 @@ function wait(reason, options) {
2309
2390
  return {
2310
2391
  status: "wait",
2311
2392
  reason,
2312
- requiredParticipationId: _optionalChain([options, 'optionalAccess', _30 => _30.requiredParticipationId]),
2313
- expiresAt: _optionalChain([options, 'optionalAccess', _31 => _31.expiresAt])
2393
+ requiredParticipationId: _optionalChain([options, 'optionalAccess', _40 => _40.requiredParticipationId]),
2394
+ expiresAt: _optionalChain([options, 'optionalAccess', _41 => _41.expiresAt])
2314
2395
  };
2315
2396
  }
2316
2397
  function complete(finalStatus) {
@@ -2398,7 +2479,7 @@ var FormExecutor = class {
2398
2479
  }
2399
2480
  execute(node, context) {
2400
2481
  const { input } = context;
2401
- const hasContent = (_nullishCoalesce(_optionalChain([node, 'access', _32 => _32.fields, 'optionalAccess', _33 => _33.length]), () => ( 0))) > 0 || (_nullishCoalesce(_optionalChain([node, 'access', _34 => _34.rows, 'optionalAccess', _35 => _35.length]), () => ( 0))) > 0;
2482
+ const hasContent = (_nullishCoalesce(_optionalChain([node, 'access', _42 => _42.fields, 'optionalAccess', _43 => _43.length]), () => ( 0))) > 0 || (_nullishCoalesce(_optionalChain([node, 'access', _44 => _44.rows, 'optionalAccess', _45 => _45.length]), () => ( 0))) > 0;
2402
2483
  if (!hasContent) {
2403
2484
  if (!node.next) {
2404
2485
  return error("MISSING_NEXT", `FormNode "${node.id}" has no 'next' target defined`);
@@ -2497,9 +2578,9 @@ var FormExecutor = class {
2497
2578
  continue;
2498
2579
  }
2499
2580
  const attribute = object2.attributes.find((a) => a.name === fieldRef.attribute);
2500
- if (!_optionalChain([attribute, 'optionalAccess', _36 => _36.required])) continue;
2581
+ if (!_optionalChain([attribute, 'optionalAccess', _46 => _46.required])) continue;
2501
2582
  const slotInput = input[fieldRef.slotId];
2502
- const value = _optionalChain([slotInput, 'optionalAccess', _37 => _37[fieldRef.attribute]]);
2583
+ const value = _optionalChain([slotInput, 'optionalAccess', _47 => _47[fieldRef.attribute]]);
2503
2584
  if (value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0) {
2504
2585
  errors.push(
2505
2586
  `Field "${_nullishCoalesce(attribute.label, () => ( fieldRef.attribute))}" is required for ${slot.label}`
@@ -2611,13 +2692,13 @@ function formatLocation(value, attribute) {
2611
2692
  }
2612
2693
  function formatSelect(value, attribute) {
2613
2694
  if (typeof value !== "string") return String(value);
2614
- const option = _optionalChain([attribute, 'access', _38 => _38.options, 'optionalAccess', _39 => _39.find, 'call', _40 => _40((o) => o.value === value)]);
2615
- return _nullishCoalesce(_optionalChain([option, 'optionalAccess', _41 => _41.label]), () => ( String(value)));
2695
+ const option = _optionalChain([attribute, 'access', _48 => _48.options, 'optionalAccess', _49 => _49.find, 'call', _50 => _50((o) => o.value === value)]);
2696
+ return _nullishCoalesce(_optionalChain([option, 'optionalAccess', _51 => _51.label]), () => ( String(value)));
2616
2697
  }
2617
2698
  function formatMultiselect(value, attribute) {
2618
2699
  if (!Array.isArray(value)) return String(value);
2619
2700
  if (attribute.options) {
2620
- const labels = value.map((v) => _optionalChain([attribute, 'access', _42 => _42.options, 'access', _43 => _43.find, 'call', _44 => _44((o) => o.value === v), 'optionalAccess', _45 => _45.label])).filter(Boolean);
2701
+ const labels = value.map((v) => _optionalChain([attribute, 'access', _52 => _52.options, 'access', _53 => _53.find, 'call', _54 => _54((o) => o.value === v), 'optionalAccess', _55 => _55.label])).filter(Boolean);
2621
2702
  return labels.join(", ");
2622
2703
  }
2623
2704
  return value.join(", ");
@@ -2879,7 +2960,7 @@ var AssignExecutor = class {
2879
2960
  if (!node.targetSlotId) {
2880
2961
  errors.push("AssignNode must have a target slot");
2881
2962
  }
2882
- if (!_optionalChain([node, 'access', _46 => _46.assignments, 'optionalAccess', _47 => _47.length])) {
2963
+ if (!_optionalChain([node, 'access', _56 => _56.assignments, 'optionalAccess', _57 => _57.length])) {
2883
2964
  errors.push("AssignNode must have at least one assignment");
2884
2965
  }
2885
2966
  if (!node.next) {
@@ -2899,6 +2980,214 @@ function resolveSource(source, slotValues) {
2899
2980
  }
2900
2981
  }
2901
2982
 
2983
+ // src/runtime/executors/ai.executor.ts
2984
+ var AIExecutor = class {
2985
+ constructor(actionRegistry) {
2986
+ this.actionRegistry = actionRegistry;
2987
+ this.nodeType = "ai";
2988
+ }
2989
+ async execute(node, ctx) {
2990
+ if (!node.next) {
2991
+ return error("MISSING_NEXT", "AINode must have a 'next' target");
2992
+ }
2993
+ const handler = this.actionRegistry.get(node.action.type);
2994
+ if (!handler) {
2995
+ return error(
2996
+ "UNKNOWN_AI_ACTION",
2997
+ `No handler registered for AI action type: ${node.action.type}`
2998
+ );
2999
+ }
3000
+ const result = await handler.execute(node.action, ctx);
3001
+ if (!result.success) {
3002
+ return error("AI_ACTION_FAILED", _nullishCoalesce(result.error, () => ( "AI action failed")), true);
3003
+ }
3004
+ return success(node.next, result.contextUpdates);
3005
+ }
3006
+ validate(node) {
3007
+ const errors = [];
3008
+ if (!node.label) errors.push("AINode must have a label");
3009
+ if (!node.action) errors.push("AINode must have an action");
3010
+ if (!node.next) errors.push("AINode must have a 'next' target");
3011
+ return errors;
3012
+ }
3013
+ };
3014
+
3015
+ // src/runtime/executors/ai-actions/types.ts
3016
+ var AIActionRegistry = class {
3017
+ constructor() {
3018
+ this.handlers = /* @__PURE__ */ new Map();
3019
+ }
3020
+ register(handler) {
3021
+ this.handlers.set(handler.actionType, handler);
3022
+ }
3023
+ get(actionType) {
3024
+ return this.handlers.get(actionType);
3025
+ }
3026
+ has(actionType) {
3027
+ return this.handlers.has(actionType);
3028
+ }
3029
+ };
3030
+
3031
+ // src/runtime/executors/ai-actions/document-generation.handler.ts
3032
+ var DocumentGenerationHandler = class {
3033
+ constructor(deps = null) {
3034
+ this.deps = deps;
3035
+ this.actionType = "document-generation";
3036
+ }
3037
+ async execute(action, ctx) {
3038
+ if (!this.deps) {
3039
+ return {
3040
+ success: false,
3041
+ error: "Document generation not configured. Provide sandbox, fileService, and storage in SchemaModule."
3042
+ };
3043
+ }
3044
+ const { sandbox, fileService, storage } = this.deps;
3045
+ const file2 = await fileService.getFile(action.templateId);
3046
+ if (!file2) {
3047
+ return {
3048
+ success: false,
3049
+ error: `Template file not found: ${action.templateId}`
3050
+ };
3051
+ }
3052
+ if (!storage.download) {
3053
+ return {
3054
+ success: false,
3055
+ error: "StorageAdapter.download() not implemented. Required for document generation."
3056
+ };
3057
+ }
3058
+ let templateContent;
3059
+ try {
3060
+ const buffer = await storage.download(file2.storagePath);
3061
+ templateContent = new Uint8Array(buffer);
3062
+ } catch (err) {
3063
+ return {
3064
+ success: false,
3065
+ error: `Failed to download template "${file2.name}": ${err instanceof Error ? err.message : "unknown error"}`
3066
+ };
3067
+ }
3068
+ const slotData = {};
3069
+ for (const slotId of action.inputSlotIds) {
3070
+ slotData[slotId] = _nullishCoalesce(ctx.executionContext.slots[slotId], () => ( {}));
3071
+ }
3072
+ const instructions = [
3073
+ "Generate a professional document based on the provided template and data.",
3074
+ _nullishCoalesce(action.aiInstructions, () => ( "")),
3075
+ "",
3076
+ "## Data Context",
3077
+ "```json",
3078
+ JSON.stringify(slotData, null, 2),
3079
+ "```",
3080
+ "",
3081
+ "## Instructions",
3082
+ "1. Unpack the template: python3 /workspace/scripts/office/unpack.py /workspace/template.docx /workspace/unpacked/",
3083
+ "2. Analyze the XML structure in /workspace/unpacked/word/document.xml",
3084
+ "3. Read the data from /workspace/data.json",
3085
+ "4. Modify the XML content using the provided data \u2014 replace placeholders, fill tables, update fields",
3086
+ "5. Pack: python3 /workspace/scripts/office/pack.py /workspace/unpacked/ /workspace/output.docx",
3087
+ "6. Validate: python3 /workspace/scripts/office/validate.py /workspace/output.docx",
3088
+ action.outputFormat === "pdf" ? "7. Convert to PDF: python3 /workspace/scripts/office/convert.py /workspace/output.docx pdf /workspace/" : ""
3089
+ ].filter(Boolean).join("\n");
3090
+ const outputPath = action.outputFormat === "pdf" ? "/workspace/output.pdf" : "/workspace/output.docx";
3091
+ try {
3092
+ const result = await sandbox.executeAgent({
3093
+ instructions,
3094
+ template: "stndrds-pdf",
3095
+ inputFiles: [
3096
+ {
3097
+ path: "/workspace/template.docx",
3098
+ content: templateContent
3099
+ },
3100
+ {
3101
+ path: "/workspace/data.json",
3102
+ content: JSON.stringify(slotData, null, 2)
3103
+ }
3104
+ ],
3105
+ expectedOutputs: [outputPath],
3106
+ timeoutMs: 6e5,
3107
+ maxIterations: 20
3108
+ });
3109
+ if (!result.success || result.artifacts.length === 0) {
3110
+ return {
3111
+ success: false,
3112
+ error: _nullishCoalesce(result.summary, () => ( "Agent failed to generate document"))
3113
+ };
3114
+ }
3115
+ const contextUpdates = {};
3116
+ for (const slotId of action.targetSlotIds) {
3117
+ contextUpdates[slotId] = {
3118
+ ..._nullishCoalesce(ctx.executionContext.slots[slotId], () => ( {})),
3119
+ _generatedDocuments: result.artifacts.map((a) => ({
3120
+ path: a.path,
3121
+ mimeType: a.mimeType
3122
+ }))
3123
+ };
3124
+ }
3125
+ return { success: true, contextUpdates };
3126
+ } catch (err) {
3127
+ return {
3128
+ success: false,
3129
+ error: err instanceof Error ? err.message : "Document generation failed"
3130
+ };
3131
+ }
3132
+ }
3133
+ };
3134
+
3135
+ // src/runtime/executors/ai-actions/code-execution.handler.ts
3136
+ var CodeExecutionHandler = class {
3137
+ constructor(sandbox = null) {
3138
+ this.sandbox = sandbox;
3139
+ this.actionType = "code-execution";
3140
+ }
3141
+ async execute(action, ctx) {
3142
+ if (!this.sandbox) {
3143
+ return {
3144
+ success: false,
3145
+ error: "Code execution handler not configured. Inject a SandboxExecutor via constructor."
3146
+ };
3147
+ }
3148
+ const env = {};
3149
+ for (const slotId of _nullishCoalesce(action.inputSlotIds, () => ( []))) {
3150
+ const slotData = _nullishCoalesce(ctx.executionContext.slots[slotId], () => ( {}));
3151
+ env[`SLOT_${slotId.toUpperCase()}`] = JSON.stringify(slotData);
3152
+ }
3153
+ try {
3154
+ const result = await this.sandbox.executeCode({
3155
+ code: action.code,
3156
+ language: action.language,
3157
+ env,
3158
+ packages: action.packages,
3159
+ timeoutMs: 3e4
3160
+ // 30s for code mode
3161
+ });
3162
+ if (result.exitCode !== 0) {
3163
+ return {
3164
+ success: false,
3165
+ error: `Code execution failed (exit ${result.exitCode}): ${result.stderr}`
3166
+ };
3167
+ }
3168
+ const contextUpdates = {};
3169
+ if (action.outputVariable) {
3170
+ contextUpdates[action.outputVariable] = result.stdout.trim();
3171
+ }
3172
+ return { success: true, contextUpdates };
3173
+ } catch (err) {
3174
+ return {
3175
+ success: false,
3176
+ error: err instanceof Error ? err.message : "Code execution failed"
3177
+ };
3178
+ }
3179
+ }
3180
+ };
3181
+
3182
+ // src/runtime/executors/ai-actions/index.ts
3183
+ function createDefaultAIActionRegistry(deps) {
3184
+ const registry2 = new AIActionRegistry();
3185
+ const docGenDeps = _optionalChain([deps, 'optionalAccess', _58 => _58.sandbox]) && _optionalChain([deps, 'optionalAccess', _59 => _59.fileService]) && _optionalChain([deps, 'optionalAccess', _60 => _60.storage]) ? { sandbox: deps.sandbox, fileService: deps.fileService, storage: deps.storage } : null;
3186
+ registry2.register(new DocumentGenerationHandler(docGenDeps));
3187
+ registry2.register(new CodeExecutionHandler(_nullishCoalesce(_optionalChain([deps, 'optionalAccess', _61 => _61.sandbox]), () => ( null))));
3188
+ return registry2;
3189
+ }
3190
+
2902
3191
  // src/runtime/executors/start.executor.ts
2903
3192
  var StartExecutor = class {
2904
3193
  constructor() {
@@ -3185,7 +3474,7 @@ async function parsePath(path, startSchema, getSchema, maxDepth = 5) {
3185
3474
  }
3186
3475
  if (attr.type === "relation") {
3187
3476
  const relationAttr = attr;
3188
- const targetObject = _optionalChain([relationAttr, 'access', _48 => _48.targets, 'access', _49 => _49[0], 'optionalAccess', _50 => _50.object]);
3477
+ const targetObject = _optionalChain([relationAttr, 'access', _62 => _62.targets, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.object]);
3189
3478
  if (!targetObject) {
3190
3479
  throw new InvalidPathError(path, segmentName, "Relation has no target object");
3191
3480
  }
@@ -3248,7 +3537,7 @@ function getRelationPath(path) {
3248
3537
 
3249
3538
  // src/runtime/formula/path-traversal.ts
3250
3539
  async function traversePath(record, path, startSchemaName, adapter, getSchema, options) {
3251
- const maxDepth = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _51 => _51.maxDepth]), () => ( 5));
3540
+ const maxDepth = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _65 => _65.maxDepth]), () => ( 5));
3252
3541
  const startSchema = await getSchema(startSchemaName);
3253
3542
  if (!startSchema) {
3254
3543
  return { values: [], recordCounts: [0] };
@@ -3344,12 +3633,12 @@ function createMockAIConversationsRepository(stores) {
3344
3633
  const userId = requireUserId();
3345
3634
  let results = Array.from(stores.aiConversations.values()).filter((c) => {
3346
3635
  if (c.tenantId !== tenantId || c.userId !== userId) return false;
3347
- if (!_optionalChain([options, 'optionalAccess', _52 => _52.includeDeleted]) && c.deletedAt) return false;
3636
+ if (!_optionalChain([options, 'optionalAccess', _66 => _66.includeDeleted]) && c.deletedAt) return false;
3348
3637
  return true;
3349
3638
  });
3350
3639
  results.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
3351
3640
  const total = results.length;
3352
- if (_optionalChain([options, 'optionalAccess', _53 => _53.limit])) {
3641
+ if (_optionalChain([options, 'optionalAccess', _67 => _67.limit])) {
3353
3642
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
3354
3643
  }
3355
3644
  return Promise.resolve({ conversations: results, total });
@@ -3439,7 +3728,7 @@ function createMockAIConversationsRepository(stores) {
3439
3728
  }
3440
3729
  let results = Array.from(stores.aiMessages.values()).filter((m) => m.conversationId === conversationId).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
3441
3730
  const total = results.length;
3442
- if (_optionalChain([options, 'optionalAccess', _54 => _54.limit])) {
3731
+ if (_optionalChain([options, 'optionalAccess', _68 => _68.limit])) {
3443
3732
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
3444
3733
  }
3445
3734
  return Promise.resolve({ messages: results, total });
@@ -3471,24 +3760,24 @@ function createMockAIUsageMetricsRepository(stores) {
3471
3760
  const now = /* @__PURE__ */ new Date();
3472
3761
  const key = getDateKey(now);
3473
3762
  const existing = stores.aiUsageMetrics.get(key);
3474
- const providerBreakdown = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _55 => _55.providerBreakdown]), () => ( {}));
3763
+ const providerBreakdown = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _69 => _69.providerBreakdown]), () => ( {}));
3475
3764
  if (!providerBreakdown[data.provider]) {
3476
3765
  providerBreakdown[data.provider] = { requests: 0, tokens: 0, cost: 0 };
3477
3766
  }
3478
3767
  providerBreakdown[data.provider].requests++;
3479
3768
  providerBreakdown[data.provider].tokens += data.tokens;
3480
3769
  providerBreakdown[data.provider].cost += data.cost;
3481
- const toolUsage = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _56 => _56.toolUsage]), () => ( {}));
3770
+ const toolUsage = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _70 => _70.toolUsage]), () => ( {}));
3482
3771
  if (data.toolName) {
3483
3772
  toolUsage[data.toolName] = (_nullishCoalesce(toolUsage[data.toolName], () => ( 0))) + 1;
3484
3773
  }
3485
3774
  const metrics = {
3486
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _57 => _57.id]), () => ( _chunkE6XO2STSjs.generateId.call(void 0, ))),
3775
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _71 => _71.id]), () => ( _chunkE6XO2STSjs.generateId.call(void 0, ))),
3487
3776
  tenantId,
3488
3777
  date: new Date(_nullishCoalesce(now.toISOString().split("T")[0], () => ( now.toISOString()))),
3489
- requestCount: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _58 => _58.requestCount]), () => ( 0))) + 1,
3490
- totalTokens: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _59 => _59.totalTokens]), () => ( 0))) + data.tokens,
3491
- totalCost: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _60 => _60.totalCost]), () => ( 0))) + data.cost,
3778
+ requestCount: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _72 => _72.requestCount]), () => ( 0))) + 1,
3779
+ totalTokens: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _73 => _73.totalTokens]), () => ( 0))) + data.tokens,
3780
+ totalCost: (_nullishCoalesce(_optionalChain([existing, 'optionalAccess', _74 => _74.totalCost]), () => ( 0))) + data.cost,
3492
3781
  providerBreakdown,
3493
3782
  toolUsage
3494
3783
  };
@@ -3541,7 +3830,7 @@ function createMockFilesRepository(stores) {
3541
3830
  return {
3542
3831
  findById(id) {
3543
3832
  const file2 = stores.files.get(id);
3544
- if (_optionalChain([file2, 'optionalAccess', _61 => _61.deletedAt])) return Promise.resolve(null);
3833
+ if (_optionalChain([file2, 'optionalAccess', _75 => _75.deletedAt])) return Promise.resolve(null);
3545
3834
  return Promise.resolve(_nullishCoalesce(file2, () => ( null)));
3546
3835
  },
3547
3836
  findByIds(ids) {
@@ -3602,10 +3891,10 @@ function createMockFilesRepository(stores) {
3602
3891
  let results = Array.from(stores.files.values()).filter(
3603
3892
  (f) => f.tenantId === tenantId && !f.deletedAt
3604
3893
  );
3605
- if (_optionalChain([options, 'optionalAccess', _62 => _62.mimeType])) {
3894
+ if (_optionalChain([options, 'optionalAccess', _76 => _76.mimeType])) {
3606
3895
  results = results.filter((f) => f.mimeType === options.mimeType);
3607
3896
  }
3608
- if (_optionalChain([options, 'optionalAccess', _63 => _63.limit])) {
3897
+ if (_optionalChain([options, 'optionalAccess', _77 => _77.limit])) {
3609
3898
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
3610
3899
  }
3611
3900
  return Promise.resolve(results);
@@ -3961,7 +4250,7 @@ var SyncError = class extends SchemaError {
3961
4250
  constructor(objectName, message, cause) {
3962
4251
  super(`Failed to sync object "${objectName}": ${message}`, SchemaErrorCode.SYNC_FAILED, {
3963
4252
  objectName,
3964
- cause: _optionalChain([cause, 'optionalAccess', _64 => _64.message])
4253
+ cause: _optionalChain([cause, 'optionalAccess', _78 => _78.message])
3965
4254
  });
3966
4255
  this.name = "SyncError";
3967
4256
  this.objectName = objectName;
@@ -4149,7 +4438,7 @@ function createMockObjectRecordsRepository(stores) {
4149
4438
  (r) => r.tenantId === tenantId && r.objectId === objectId && !r.deletedAt
4150
4439
  );
4151
4440
  const total = results.length;
4152
- if (_optionalChain([options, 'optionalAccess', _65 => _65.limit])) {
4441
+ if (_optionalChain([options, 'optionalAccess', _79 => _79.limit])) {
4153
4442
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
4154
4443
  }
4155
4444
  const records = results.map(({ tenantId: _t, ...r }) => r);
@@ -4165,7 +4454,7 @@ function createMockObjectRecordsRepository(stores) {
4165
4454
  );
4166
4455
  });
4167
4456
  const total = results.length;
4168
- if (_optionalChain([options, 'optionalAccess', _66 => _66.limit])) {
4457
+ if (_optionalChain([options, 'optionalAccess', _80 => _80.limit])) {
4169
4458
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
4170
4459
  }
4171
4460
  const records = results.map(({ tenantId: _t, ...r }) => r);
@@ -4181,7 +4470,7 @@ function createMockObjectRecordsRepository(stores) {
4181
4470
  }
4182
4471
  }
4183
4472
  const allowedObjectIds = /* @__PURE__ */ new Set();
4184
- if (_optionalChain([options, 'optionalAccess', _67 => _67.objectNames]) && options.objectNames.length > 0) {
4473
+ if (_optionalChain([options, 'optionalAccess', _81 => _81.objectNames]) && options.objectNames.length > 0) {
4185
4474
  for (const obj of objectsMap.values()) {
4186
4475
  if (options.objectNames.includes(obj.name)) {
4187
4476
  allowedObjectIds.add(obj.id);
@@ -4200,7 +4489,7 @@ function createMockObjectRecordsRepository(stores) {
4200
4489
  );
4201
4490
  });
4202
4491
  const total = matchingRecords.length;
4203
- if (_optionalChain([options, 'optionalAccess', _68 => _68.limit])) {
4492
+ if (_optionalChain([options, 'optionalAccess', _82 => _82.limit])) {
4204
4493
  matchingRecords = matchingRecords.slice(
4205
4494
  _nullishCoalesce(options.offset, () => ( 0)),
4206
4495
  (_nullishCoalesce(options.offset, () => ( 0))) + options.limit
@@ -4211,11 +4500,11 @@ function createMockObjectRecordsRepository(stores) {
4211
4500
  if (!attributesByObjectId.has(attr.objectId)) {
4212
4501
  attributesByObjectId.set(attr.objectId, []);
4213
4502
  }
4214
- _optionalChain([attributesByObjectId, 'access', _69 => _69.get, 'call', _70 => _70(attr.objectId), 'optionalAccess', _71 => _71.push, 'call', _72 => _72(attr)]);
4503
+ _optionalChain([attributesByObjectId, 'access', _83 => _83.get, 'call', _84 => _84(attr.objectId), 'optionalAccess', _85 => _85.push, 'call', _86 => _86(attr)]);
4215
4504
  }
4216
4505
  const results = matchingRecords.map((r) => {
4217
4506
  const obj = objectsMap.get(r.objectId);
4218
- const labelExpression = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _73 => _73.labelExpression]), () => ( "{{ name }}"));
4507
+ const labelExpression = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _87 => _87.labelExpression]), () => ( "{{ name }}"));
4219
4508
  const dbAttrs = _nullishCoalesce(attributesByObjectId.get(r.objectId), () => ( []));
4220
4509
  const attrs = dbAttrs.map((a) => ({
4221
4510
  ...a.config,
@@ -4228,8 +4517,8 @@ function createMockObjectRecordsRepository(stores) {
4228
4517
  const enrichedValues = enrichValuesForDisplay(r.values, attrs);
4229
4518
  return {
4230
4519
  objectId: r.objectId,
4231
- objectName: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _74 => _74.name]), () => ( "unknown")),
4232
- objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _75 => _75.label]), () => ( "Unknown")),
4520
+ objectName: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _88 => _88.name]), () => ( "unknown")),
4521
+ objectLabel: _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _89 => _89.label]), () => ( "Unknown")),
4233
4522
  label: renderLabelExpression(labelExpression, enrichedValues),
4234
4523
  recordId: r.id,
4235
4524
  completionStatus: r.completionStatus,
@@ -4240,9 +4529,9 @@ function createMockObjectRecordsRepository(stores) {
4240
4529
  return Promise.resolve({ results, total });
4241
4530
  },
4242
4531
  globalSearchGrouped(query, options) {
4243
- const limitPerGroup = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _76 => _76.limitPerGroup]), () => ( 5));
4532
+ const limitPerGroup = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _90 => _90.limitPerGroup]), () => ( 5));
4244
4533
  return this.globalSearch(query, {
4245
- objectNames: _optionalChain([options, 'optionalAccess', _77 => _77.objectNames]),
4534
+ objectNames: _optionalChain([options, 'optionalAccess', _91 => _91.objectNames]),
4246
4535
  limit: 500,
4247
4536
  offset: 0
4248
4537
  }).then(({ results }) => {
@@ -4588,7 +4877,7 @@ function createMockUserProfilesRepository(stores) {
4588
4877
  list(options) {
4589
4878
  const tenantId = getTenantId();
4590
4879
  let results = Array.from(stores.userProfiles.values()).filter((p) => p.tenantId === tenantId);
4591
- if (_optionalChain([options, 'optionalAccess', _78 => _78.limit])) {
4880
+ if (_optionalChain([options, 'optionalAccess', _92 => _92.limit])) {
4592
4881
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
4593
4882
  }
4594
4883
  return Promise.resolve(results);
@@ -4602,7 +4891,7 @@ function createMockUserProfilesRepository(stores) {
4602
4891
  for (const profile of profiles) {
4603
4892
  const roleIds = Array.from(stores.userRoles.values()).filter((ur) => ur.userProfileId === profile.id && ur.tenantId === tenantId).map((ur) => ur.roleId);
4604
4893
  const roles = Array.from(stores.roles.values()).filter((r) => roleIds.includes(r.id));
4605
- if (_optionalChain([filters, 'optionalAccess', _79 => _79.allowedRoles]) && filters.allowedRoles.length > 0) {
4894
+ if (_optionalChain([filters, 'optionalAccess', _93 => _93.allowedRoles]) && filters.allowedRoles.length > 0) {
4606
4895
  const allowed = filters.allowedRoles;
4607
4896
  const hasMatchingRole = roles.some((r) => allowed.includes(r.name));
4608
4897
  if (!hasMatchingRole) continue;
@@ -4686,7 +4975,7 @@ function createMockPermissionsRepository(stores) {
4686
4975
  },
4687
4976
  deleteRole(roleId) {
4688
4977
  const role = stores.roles.get(roleId);
4689
- if (_optionalChain([role, 'optionalAccess', _80 => _80.system])) {
4978
+ if (_optionalChain([role, 'optionalAccess', _94 => _94.system])) {
4690
4979
  return Promise.reject(new Error(`Cannot delete system role ${roleId}`));
4691
4980
  }
4692
4981
  stores.roles.delete(roleId);
@@ -5194,7 +5483,7 @@ function createMockWorkflowInstancesRepository(stores) {
5194
5483
  (i) => i.tenant_id === tenantId
5195
5484
  );
5196
5485
  const total = results.length;
5197
- if (_optionalChain([options, 'optionalAccess', _81 => _81.limit])) {
5486
+ if (_optionalChain([options, 'optionalAccess', _95 => _95.limit])) {
5198
5487
  results = results.slice(_nullishCoalesce(options.offset, () => ( 0)), (_nullishCoalesce(options.offset, () => ( 0))) + options.limit);
5199
5488
  }
5200
5489
  return Promise.resolve({ instances: results, total });
@@ -5222,7 +5511,7 @@ function createMockWorkflowInstancesRepository(stores) {
5222
5511
  pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
5223
5512
  error: null,
5224
5513
  started_by: data.startedBy,
5225
- expires_at: _nullishCoalesce(_optionalChain([data, 'access', _82 => _82.expiresAt, 'optionalAccess', _83 => _83.toISOString, 'call', _84 => _84()]), () => ( null)),
5514
+ expires_at: _nullishCoalesce(_optionalChain([data, 'access', _96 => _96.expiresAt, 'optionalAccess', _97 => _97.toISOString, 'call', _98 => _98()]), () => ( null)),
5226
5515
  created_at: now,
5227
5516
  updated_at: now,
5228
5517
  completed_at: null
@@ -5247,8 +5536,8 @@ function createMockWorkflowInstancesRepository(stores) {
5247
5536
  history: _nullishCoalesce(data.history, () => ( existing.history)),
5248
5537
  pending_action: data.pendingAction !== void 0 ? data.pendingAction : existing.pending_action,
5249
5538
  error: data.error !== void 0 ? data.error : existing.error,
5250
- expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _85 => _85.expiresAt, 'optionalAccess', _86 => _86.toISOString, 'call', _87 => _87()]), () => ( null)) : existing.expires_at,
5251
- completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _88 => _88.completedAt, 'optionalAccess', _89 => _89.toISOString, 'call', _90 => _90()]), () => ( null)) : existing.completed_at,
5539
+ expires_at: data.expiresAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _99 => _99.expiresAt, 'optionalAccess', _100 => _100.toISOString, 'call', _101 => _101()]), () => ( null)) : existing.expires_at,
5540
+ completed_at: data.completedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _102 => _102.completedAt, 'optionalAccess', _103 => _103.toISOString, 'call', _104 => _104()]), () => ( null)) : existing.completed_at,
5252
5541
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
5253
5542
  };
5254
5543
  stores.workflowInstances.set(id, updated);
@@ -5281,7 +5570,7 @@ function createMockWorkflowInstancesRepository(stores) {
5281
5570
  pending_action: _nullishCoalesce(data.pendingAction, () => ( null)),
5282
5571
  error: null,
5283
5572
  started_by: data.startedBy,
5284
- expires_at: _nullishCoalesce(_optionalChain([data, 'access', _91 => _91.expiresAt, 'optionalAccess', _92 => _92.toISOString, 'call', _93 => _93()]), () => ( null)),
5573
+ expires_at: _nullishCoalesce(_optionalChain([data, 'access', _105 => _105.expiresAt, 'optionalAccess', _106 => _106.toISOString, 'call', _107 => _107()]), () => ( null)),
5285
5574
  created_at: now,
5286
5575
  updated_at: now,
5287
5576
  completed_at: null
@@ -5304,13 +5593,13 @@ function createMockWorkflowInstancesRepository(stores) {
5304
5593
  return slotData.id === recordId;
5305
5594
  });
5306
5595
  });
5307
- if (_optionalChain([options, 'optionalAccess', _94 => _94.status])) {
5596
+ if (_optionalChain([options, 'optionalAccess', _108 => _108.status])) {
5308
5597
  results = results.filter((i) => i.status === options.status);
5309
5598
  }
5310
5599
  const total = results.length;
5311
- if (_optionalChain([options, 'optionalAccess', _95 => _95.offset]) !== void 0 || _optionalChain([options, 'optionalAccess', _96 => _96.limit]) !== void 0) {
5312
- const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _97 => _97.offset]), () => ( 0));
5313
- const end = _optionalChain([options, 'optionalAccess', _98 => _98.limit]) ? start + options.limit : void 0;
5600
+ if (_optionalChain([options, 'optionalAccess', _109 => _109.offset]) !== void 0 || _optionalChain([options, 'optionalAccess', _110 => _110.limit]) !== void 0) {
5601
+ const start = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _111 => _111.offset]), () => ( 0));
5602
+ const end = _optionalChain([options, 'optionalAccess', _112 => _112.limit]) ? start + options.limit : void 0;
5314
5603
  results = results.slice(start, end);
5315
5604
  }
5316
5605
  return Promise.resolve({ instances: results, total });
@@ -5370,7 +5659,7 @@ function createMockWorkflowInvitationsRepository(stores) {
5370
5659
  const updated = {
5371
5660
  ...existing,
5372
5661
  status: _nullishCoalesce(data.status, () => ( existing.status)),
5373
- accepted_at: data.acceptedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _99 => _99.acceptedAt, 'optionalAccess', _100 => _100.toISOString, 'call', _101 => _101()]), () => ( null)) : existing.accepted_at,
5662
+ accepted_at: data.acceptedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _113 => _113.acceptedAt, 'optionalAccess', _114 => _114.toISOString, 'call', _115 => _115()]), () => ( null)) : existing.accepted_at,
5374
5663
  expires_at: data.expiresAt !== void 0 ? data.expiresAt.toISOString() : existing.expires_at
5375
5664
  };
5376
5665
  stores.workflowInvitations.set(id, updated);
@@ -5440,7 +5729,7 @@ function createMockWorkflowAccessGrantsRepository(stores) {
5440
5729
  ...existing,
5441
5730
  last_used_at: data.lastUsedAt !== void 0 ? data.lastUsedAt.toISOString() : existing.last_used_at,
5442
5731
  revoked_token_jtis: _nullishCoalesce(data.revokedTokenJtis, () => ( existing.revoked_token_jtis)),
5443
- revoked_at: data.revokedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _102 => _102.revokedAt, 'optionalAccess', _103 => _103.toISOString, 'call', _104 => _104()]), () => ( null)) : existing.revoked_at
5732
+ revoked_at: data.revokedAt !== void 0 ? _nullishCoalesce(_optionalChain([data, 'access', _116 => _116.revokedAt, 'optionalAccess', _117 => _117.toISOString, 'call', _118 => _118()]), () => ( null)) : existing.revoked_at
5444
5733
  };
5445
5734
  stores.workflowAccessGrants.set(id, updated);
5446
5735
  return Promise.resolve(updated);
@@ -5661,7 +5950,7 @@ var BaseService = class {
5661
5950
  * @param key - Cache key to invalidate
5662
5951
  */
5663
5952
  async invalidateCache(key) {
5664
- await _optionalChain([this, 'access', _105 => _105.cache, 'optionalAccess', _106 => _106.delete, 'call', _107 => _107(key)]);
5953
+ await _optionalChain([this, 'access', _119 => _119.cache, 'optionalAccess', _120 => _120.delete, 'call', _121 => _121(key)]);
5665
5954
  }
5666
5955
  /**
5667
5956
  * Invalidate all cache keys matching a pattern.
@@ -5669,7 +5958,7 @@ var BaseService = class {
5669
5958
  * @param pattern - Glob-style pattern (e.g., "schema:tenant-123:*")
5670
5959
  */
5671
5960
  async invalidateCachePattern(pattern) {
5672
- await _optionalChain([this, 'access', _108 => _108.cache, 'optionalAccess', _109 => _109.deletePattern, 'call', _110 => _110(pattern)]);
5961
+ await _optionalChain([this, 'access', _122 => _122.cache, 'optionalAccess', _123 => _123.deletePattern, 'call', _124 => _124(pattern)]);
5673
5962
  }
5674
5963
  /**
5675
5964
  * Invalidate all cached lists for a resource.
@@ -5899,17 +6188,17 @@ function validateOptions(options, attributeName) {
5899
6188
  const ids = /* @__PURE__ */ new Set();
5900
6189
  const values = /* @__PURE__ */ new Set();
5901
6190
  for (const option of options) {
5902
- if (!_optionalChain([option, 'access', _111 => _111.id, 'optionalAccess', _112 => _112.trim, 'call', _113 => _113()])) {
6191
+ if (!_optionalChain([option, 'access', _125 => _125.id, 'optionalAccess', _126 => _126.trim, 'call', _127 => _127()])) {
5903
6192
  throw new Error(
5904
6193
  `[AttributeBuilder] Option in "${attributeName}" has an empty or missing id.`
5905
6194
  );
5906
6195
  }
5907
- if (!_optionalChain([option, 'access', _114 => _114.value, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()])) {
6196
+ if (!_optionalChain([option, 'access', _128 => _128.value, 'optionalAccess', _129 => _129.trim, 'call', _130 => _130()])) {
5908
6197
  throw new Error(
5909
6198
  `[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing value.`
5910
6199
  );
5911
6200
  }
5912
- if (!_optionalChain([option, 'access', _117 => _117.label, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()])) {
6201
+ if (!_optionalChain([option, 'access', _131 => _131.label, 'optionalAccess', _132 => _132.trim, 'call', _133 => _133()])) {
5913
6202
  throw new Error(
5914
6203
  `[AttributeBuilder] Option "${option.id}" in "${attributeName}" has an empty or missing label.`
5915
6204
  );
@@ -6021,8 +6310,8 @@ var BaseAttributeBuilder = class {
6021
6310
  featureGate(flagName, options) {
6022
6311
  this.attr.featureGate = {
6023
6312
  flag: flagName,
6024
- expectedValue: _optionalChain([options, 'optionalAccess', _120 => _120.expectedValue]),
6025
- fallback: _optionalChain([options, 'optionalAccess', _121 => _121.fallback])
6313
+ expectedValue: _optionalChain([options, 'optionalAccess', _134 => _134.expectedValue]),
6314
+ fallback: _optionalChain([options, 'optionalAccess', _135 => _135.fallback])
6026
6315
  };
6027
6316
  return this;
6028
6317
  }
@@ -6465,7 +6754,7 @@ var BaseRelationAttributeBuilder = class extends BaseAttributeBuilder {
6465
6754
  object: objectName,
6466
6755
  ...options
6467
6756
  };
6468
- _optionalChain([this, 'access', _122 => _122.attr, 'access', _123 => _123.targets, 'optionalAccess', _124 => _124.push, 'call', _125 => _125(target)]);
6757
+ _optionalChain([this, 'access', _136 => _136.attr, 'access', _137 => _137.targets, 'optionalAccess', _138 => _138.push, 'call', _139 => _139(target)]);
6469
6758
  return this;
6470
6759
  }
6471
6760
  /**
@@ -6577,9 +6866,9 @@ var MultiRelationAttributeBuilder = class extends BaseRelationAttributeBuilder {
6577
6866
  constructor(name, label, initOptions) {
6578
6867
  super("relation", name, label);
6579
6868
  this.attr.cardinality = "many";
6580
- this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _126 => _126.targets]), () => ( []));
6869
+ this.attr.targets = _nullishCoalesce(_optionalChain([initOptions, 'optionalAccess', _140 => _140.targets]), () => ( []));
6581
6870
  this.attr.defaultValue = [];
6582
- if (_optionalChain([initOptions, 'optionalAccess', _127 => _127.isRequired])) {
6871
+ if (_optionalChain([initOptions, 'optionalAccess', _141 => _141.isRequired])) {
6583
6872
  this.setRequired(true);
6584
6873
  }
6585
6874
  }
@@ -7011,7 +7300,7 @@ var GroupBuilder = class {
7011
7300
  */
7012
7301
  fields(...names) {
7013
7302
  for (const name of names) {
7014
- _optionalChain([this, 'access', _128 => _128.data, 'access', _129 => _129.fields, 'optionalAccess', _130 => _130.push, 'call', _131 => _131({ attribute: name })]);
7303
+ _optionalChain([this, 'access', _142 => _142.data, 'access', _143 => _143.fields, 'optionalAccess', _144 => _144.push, 'call', _145 => _145({ attribute: name })]);
7015
7304
  }
7016
7305
  return this;
7017
7306
  }
@@ -7020,7 +7309,7 @@ var GroupBuilder = class {
7020
7309
  * @example .field("name", { span: 8, readOnly: true })
7021
7310
  */
7022
7311
  field(attribute, options) {
7023
- _optionalChain([this, 'access', _132 => _132.data, 'access', _133 => _133.fields, 'optionalAccess', _134 => _134.push, 'call', _135 => _135({ attribute, ...options })]);
7312
+ _optionalChain([this, 'access', _146 => _146.data, 'access', _147 => _147.fields, 'optionalAccess', _148 => _148.push, 'call', _149 => _149({ attribute, ...options })]);
7024
7313
  return this;
7025
7314
  }
7026
7315
  /**
@@ -7029,7 +7318,7 @@ var GroupBuilder = class {
7029
7318
  * @example .attributeGroup({ id: "address", label: "Address", attributes: ["street", "city", "postal_code"], displayTemplate: "{street}, {city}" })
7030
7319
  */
7031
7320
  attributeGroup(config, options) {
7032
- _optionalChain([this, 'access', _136 => _136.data, 'access', _137 => _137.fields, 'optionalAccess', _138 => _138.push, 'call', _139 => _139({ attributeGroup: config, ...options })]);
7321
+ _optionalChain([this, 'access', _150 => _150.data, 'access', _151 => _151.fields, 'optionalAccess', _152 => _152.push, 'call', _153 => _153({ attributeGroup: config, ...options })]);
7033
7322
  return this;
7034
7323
  }
7035
7324
  /**
@@ -7898,7 +8187,10 @@ var ListViewBuilder = class {
7898
8187
  groupByAttribute: tab.groupByAttribute,
7899
8188
  cardUserAttribute: tab.cardUserAttribute,
7900
8189
  cardDateAttribute: tab.cardDateAttribute,
7901
- createMode: tab.createMode
8190
+ createMode: tab.createMode,
8191
+ kanbanColumnOrder: tab.kanbanColumnOrder,
8192
+ kanbanColumnVisibility: tab.kanbanColumnVisibility,
8193
+ kanbanPinnedColumns: tab.kanbanPinnedColumns
7902
8194
  }))
7903
8195
  };
7904
8196
  return {
@@ -7987,6 +8279,34 @@ var ListViewTabConfigBuilder = class _ListViewTabConfigBuilder {
7987
8279
  this.tabData.cardDateAttribute = attributeName;
7988
8280
  return this;
7989
8281
  }
8282
+ /**
8283
+ * Set the order of kanban columns by option values (for kanban layout only)
8284
+ * @param order - Array of option values in desired order
8285
+ * @example .kanbanColumnOrder(["new", "in_progress", "done"])
8286
+ */
8287
+ kanbanColumnOrder(order) {
8288
+ this.tabData.kanbanColumnOrder = order;
8289
+ return this;
8290
+ }
8291
+ /**
8292
+ * Set the visibility of kanban columns by option values (for kanban layout only)
8293
+ * @param visibility - Record mapping option values to visibility (true = visible, false = hidden)
8294
+ * @example .kanbanColumnVisibility({ "new": true, "archived": false })
8295
+ */
8296
+ kanbanColumnVisibility(visibility) {
8297
+ this.tabData.kanbanColumnVisibility = visibility;
8298
+ return this;
8299
+ }
8300
+ /**
8301
+ * Set pinned kanban columns by option values (for kanban layout only)
8302
+ * Pinned columns remain fixed during horizontal scrolling
8303
+ * @param pinnedColumns - Array of option values to pin
8304
+ * @example .kanbanPinnedColumns(["new", "done"])
8305
+ */
8306
+ kanbanPinnedColumns(pinnedColumns) {
8307
+ this.tabData.kanbanPinnedColumns = pinnedColumns;
8308
+ return this;
8309
+ }
7990
8310
  /**
7991
8311
  * Set creation behavior when clicking "+"
7992
8312
  * @param mode - "redirect" (navigate to detail), "inline" (empty row), or "modal" (stacked modal)
@@ -8097,8 +8417,33 @@ var WorkflowFormRowBuilder = class {
8097
8417
  id: `${this.rowData.id}-${slotId}-${attribute}`,
8098
8418
  slotId,
8099
8419
  attribute,
8100
- label: _optionalChain([options, 'optionalAccess', _140 => _140.label]),
8101
- required: _optionalChain([options, 'optionalAccess', _141 => _141.required])
8420
+ label: _optionalChain([options, 'optionalAccess', _154 => _154.label]),
8421
+ required: _optionalChain([options, 'optionalAccess', _155 => _155.required])
8422
+ };
8423
+ this.rowData.fields.push(field);
8424
+ return this;
8425
+ }
8426
+ /**
8427
+ * Add a relation field to the current row.
8428
+ * Use this for relation attributes that need specific configuration
8429
+ * (e.g., which qualified properties to display).
8430
+ *
8431
+ * @param slotId - The slot containing the relation attribute
8432
+ * @param attribute - The relation attribute name
8433
+ * @param options - Optional label, required flag, and relation config
8434
+ */
8435
+ relationField(slotId, attribute, options) {
8436
+ const relationConfig = _optionalChain([options, 'optionalAccess', _156 => _156.visibleProperties]) || _optionalChain([options, 'optionalAccess', _157 => _157.allowCreate]) !== void 0 ? {
8437
+ visibleProperties: _optionalChain([options, 'optionalAccess', _158 => _158.visibleProperties]),
8438
+ allowCreate: _optionalChain([options, 'optionalAccess', _159 => _159.allowCreate])
8439
+ } : void 0;
8440
+ const field = {
8441
+ id: `${this.rowData.id}-${slotId}-${attribute}`,
8442
+ slotId,
8443
+ attribute,
8444
+ label: _optionalChain([options, 'optionalAccess', _160 => _160.label]),
8445
+ required: _optionalChain([options, 'optionalAccess', _161 => _161.required]),
8446
+ relationConfig
8102
8447
  };
8103
8448
  this.rowData.fields.push(field);
8104
8449
  return this;
@@ -8109,6 +8454,24 @@ var WorkflowFormRowBuilder = class {
8109
8454
  row(id) {
8110
8455
  return this.formBuilder._finalizeRow(this.rowData).row(id);
8111
8456
  }
8457
+ /**
8458
+ * Add a heading row (finalizes the current field row first)
8459
+ */
8460
+ heading(content, level) {
8461
+ return this.formBuilder._finalizeRow(this.rowData).heading(content, level);
8462
+ }
8463
+ /**
8464
+ * Add a visual separator (finalizes the current field row first)
8465
+ */
8466
+ separator() {
8467
+ return this.formBuilder._finalizeRow(this.rowData).separator();
8468
+ }
8469
+ /**
8470
+ * Add a static text row (finalizes the current field row first)
8471
+ */
8472
+ text(content) {
8473
+ return this.formBuilder._finalizeRow(this.rowData).text(content);
8474
+ }
8112
8475
  /**
8113
8476
  * Set the next node and finish this form
8114
8477
  */
@@ -8139,13 +8502,56 @@ var WorkflowFormBuilder = class {
8139
8502
  this.rowOrder++;
8140
8503
  return new WorkflowFormRowBuilder(this, id, this.rowOrder);
8141
8504
  }
8505
+ /**
8506
+ * Add a heading row to the form
8507
+ */
8508
+ heading(content, level) {
8509
+ this.rowOrder++;
8510
+ const row = {
8511
+ id: `heading-${this.rowOrder}`,
8512
+ order: this.rowOrder,
8513
+ type: "heading",
8514
+ content,
8515
+ level
8516
+ };
8517
+ this.rows.push(row);
8518
+ return this;
8519
+ }
8520
+ /**
8521
+ * Add a visual separator row to the form
8522
+ */
8523
+ separator() {
8524
+ this.rowOrder++;
8525
+ const row = {
8526
+ id: `separator-${this.rowOrder}`,
8527
+ order: this.rowOrder,
8528
+ type: "separator"
8529
+ };
8530
+ this.rows.push(row);
8531
+ return this;
8532
+ }
8533
+ /**
8534
+ * Add a static text row to the form
8535
+ */
8536
+ text(content) {
8537
+ this.rowOrder++;
8538
+ const row = {
8539
+ id: `text-${this.rowOrder}`,
8540
+ order: this.rowOrder,
8541
+ type: "text",
8542
+ content
8543
+ };
8544
+ this.rows.push(row);
8545
+ return this;
8546
+ }
8142
8547
  /**
8143
8548
  * Set the next node and complete the form definition
8144
8549
  */
8145
8550
  next(nodeId) {
8146
- if (this.rows.length === 0) {
8551
+ const hasFieldRows = this.rows.some((r) => !r.type || r.type === "fields");
8552
+ if (!hasFieldRows) {
8147
8553
  throw new Error(
8148
- `[WorkflowBuilder] Form "${this.nodeId}" has no rows. Use .row() to add rows.`
8554
+ `[WorkflowBuilder] Form "${this.nodeId}" has no field rows. Use .row() to add fields.`
8149
8555
  );
8150
8556
  }
8151
8557
  return this.workflowBuilder._addFormNode({
@@ -8196,6 +8602,22 @@ var WorkflowSimpleFormBuilder = class {
8196
8602
  }
8197
8603
  return this;
8198
8604
  }
8605
+ /**
8606
+ * Add a relation field with optional configuration.
8607
+ * Use this for relation attributes that need specific configuration
8608
+ * (e.g., which qualified properties to display).
8609
+ */
8610
+ relationField(slotId, attribute, options) {
8611
+ this.fieldList.push({
8612
+ slotId,
8613
+ attribute,
8614
+ relationConfig: options ? {
8615
+ visibleProperties: options.visibleProperties,
8616
+ allowCreate: options.allowCreate
8617
+ } : void 0
8618
+ });
8619
+ return this;
8620
+ }
8199
8621
  /**
8200
8622
  * Set the next node and complete the form definition
8201
8623
  */
@@ -8337,6 +8759,68 @@ var WorkflowAssignBuilder = class {
8337
8759
  });
8338
8760
  }
8339
8761
  };
8762
+ var WorkflowAIBuilder = class {
8763
+ /** @internal */
8764
+ constructor(workflowBuilder, nodeId, label) {
8765
+ this.action = null;
8766
+ this.workflowBuilder = workflowBuilder;
8767
+ this.nodeId = nodeId;
8768
+ this.label = label;
8769
+ }
8770
+ /**
8771
+ * Set the description for this AI node
8772
+ */
8773
+ describe(description) {
8774
+ this.nodeDescription = description;
8775
+ return this;
8776
+ }
8777
+ /**
8778
+ * Set a custom timeout (default: 120_000ms)
8779
+ */
8780
+ timeout(ms) {
8781
+ this.nodeTimeoutMs = ms;
8782
+ return this;
8783
+ }
8784
+ /**
8785
+ * Configure document generation action
8786
+ */
8787
+ documentGeneration(config) {
8788
+ this.action = {
8789
+ type: "document-generation",
8790
+ ...config
8791
+ };
8792
+ return this;
8793
+ }
8794
+ /**
8795
+ * Configure code execution action
8796
+ */
8797
+ codeExecution(config) {
8798
+ this.action = {
8799
+ type: "code-execution",
8800
+ ...config
8801
+ };
8802
+ return this;
8803
+ }
8804
+ /**
8805
+ * Set the next node and complete the AI node definition
8806
+ */
8807
+ next(nodeId) {
8808
+ if (!this.action) {
8809
+ throw new Error(
8810
+ `[WorkflowBuilder] AI node "${this.nodeId}" must have an action. Use .documentGeneration() or .codeExecution() first.`
8811
+ );
8812
+ }
8813
+ return this.workflowBuilder._addNode({
8814
+ type: "ai",
8815
+ id: this.nodeId,
8816
+ label: this.label,
8817
+ description: this.nodeDescription,
8818
+ action: this.action,
8819
+ timeoutMs: this.nodeTimeoutMs,
8820
+ next: nodeId
8821
+ });
8822
+ }
8823
+ };
8340
8824
  var WorkflowEndBuilder = class {
8341
8825
  /** @internal */
8342
8826
  constructor(workflowBuilder, nodeId) {
@@ -8457,7 +8941,7 @@ var WorkflowBuilder = class {
8457
8941
  * @param options - Slot configuration
8458
8942
  */
8459
8943
  slot(id, objectName, options) {
8460
- if (_optionalChain([this, 'access', _142 => _142.data, 'access', _143 => _143.slots, 'optionalAccess', _144 => _144.some, 'call', _145 => _145((s) => s.id === id)])) {
8944
+ if (_optionalChain([this, 'access', _162 => _162.data, 'access', _163 => _163.slots, 'optionalAccess', _164 => _164.some, 'call', _165 => _165((s) => s.id === id)])) {
8461
8945
  throw new Error(`[WorkflowBuilder] Duplicate slot id: "${id}"`);
8462
8946
  }
8463
8947
  const slot = {
@@ -8468,7 +8952,7 @@ var WorkflowBuilder = class {
8468
8952
  color: options.color,
8469
8953
  icon: options.icon
8470
8954
  };
8471
- _optionalChain([this, 'access', _146 => _146.data, 'access', _147 => _147.slots, 'optionalAccess', _148 => _148.push, 'call', _149 => _149(slot)]);
8955
+ _optionalChain([this, 'access', _166 => _166.data, 'access', _167 => _167.slots, 'optionalAccess', _168 => _168.push, 'call', _169 => _169(slot)]);
8472
8956
  return this;
8473
8957
  }
8474
8958
  // ============================================================================
@@ -8508,6 +8992,12 @@ var WorkflowBuilder = class {
8508
8992
  assign(id, label, targetSlotId) {
8509
8993
  return new WorkflowAssignBuilder(this, id, label, targetSlotId);
8510
8994
  }
8995
+ /**
8996
+ * Define an AI node (run an AI action like document generation or code execution)
8997
+ */
8998
+ ai(id, label) {
8999
+ return new WorkflowAIBuilder(this, id, label);
9000
+ }
8511
9001
  /**
8512
9002
  * Define an end node
8513
9003
  */
@@ -8595,7 +9085,7 @@ var WorkflowBuilder = class {
8595
9085
  }
8596
9086
  }
8597
9087
  validateSlotReferences() {
8598
- const slotIds = _nullishCoalesce(_optionalChain([this, 'access', _150 => _150.data, 'access', _151 => _151.slots, 'optionalAccess', _152 => _152.reduce, 'call', _153 => _153((set, s) => set.add(s.id), /* @__PURE__ */ new Set())]), () => ( /* @__PURE__ */ new Set()));
9088
+ const slotIds = _nullishCoalesce(_optionalChain([this, 'access', _170 => _170.data, 'access', _171 => _171.slots, 'optionalAccess', _172 => _172.reduce, 'call', _173 => _173((set, s) => set.add(s.id), /* @__PURE__ */ new Set())]), () => ( /* @__PURE__ */ new Set()));
8599
9089
  for (const node of Object.values(_nullishCoalesce(this.data.nodes, () => ( {})))) {
8600
9090
  for (const slotId of getNodeSlotIds(node)) {
8601
9091
  if (!slotIds.has(slotId)) {
@@ -8887,7 +9377,7 @@ var ObjectSchemaService = class extends BaseService {
8887
9377
  constructor(adapter, nativeRegistry, options) {
8888
9378
  super(adapter);
8889
9379
  this.nativeRegistry = nativeRegistry;
8890
- this.auditService = _optionalChain([options, 'optionalAccess', _154 => _154.auditService]);
9380
+ this.auditService = _optionalChain([options, 'optionalAccess', _174 => _174.auditService]);
8891
9381
  this.bilateralValidationService = new BilateralValidationService(adapter, this);
8892
9382
  }
8893
9383
  /**
@@ -9130,7 +9620,7 @@ var ObjectSchemaService = class extends BaseService {
9130
9620
  resourceType: "attribute",
9131
9621
  resourceId: attributeId,
9132
9622
  resourceLabel: updatedDbAttr.label,
9133
- objectName: _optionalChain([dbObject, 'optionalAccess', _155 => _155.name]),
9623
+ objectName: _optionalChain([dbObject, 'optionalAccess', _175 => _175.name]),
9134
9624
  objectId: dbAttr.objectId,
9135
9625
  changes
9136
9626
  });
@@ -9163,7 +9653,7 @@ var ObjectSchemaService = class extends BaseService {
9163
9653
  );
9164
9654
  }
9165
9655
  const dbObject = await this.adapter.objects.findById(dbAttr.objectId);
9166
- if (_optionalChain([dbObject, 'optionalAccess', _156 => _156.labelExpression])) {
9656
+ if (_optionalChain([dbObject, 'optionalAccess', _176 => _176.labelExpression])) {
9167
9657
  const usedAttributes = extractAttributeNames(dbObject.labelExpression);
9168
9658
  if (usedAttributes.includes(dbAttr.name)) {
9169
9659
  throw new AttributeInUseError(dbAttr.name, "labelExpression");
@@ -9179,7 +9669,7 @@ var ObjectSchemaService = class extends BaseService {
9179
9669
  resourceType: "attribute",
9180
9670
  resourceId: attributeId,
9181
9671
  resourceLabel: dbAttr.label,
9182
- objectName: _optionalChain([dbObject, 'optionalAccess', _157 => _157.name]),
9672
+ objectName: _optionalChain([dbObject, 'optionalAccess', _177 => _177.name]),
9183
9673
  objectId: dbAttr.objectId
9184
9674
  });
9185
9675
  }
@@ -9194,9 +9684,9 @@ var ObjectSchemaService = class extends BaseService {
9194
9684
  async listAttributes(objectId, options) {
9195
9685
  const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
9196
9686
  let filtered = dbAttributes;
9197
- if (_optionalChain([options, 'optionalAccess', _158 => _158.systemOnly])) {
9687
+ if (_optionalChain([options, 'optionalAccess', _178 => _178.systemOnly])) {
9198
9688
  filtered = dbAttributes.filter((attr) => attr.system);
9199
- } else if (_optionalChain([options, 'optionalAccess', _159 => _159.customOnly])) {
9689
+ } else if (_optionalChain([options, 'optionalAccess', _179 => _179.customOnly])) {
9200
9690
  filtered = dbAttributes.filter((attr) => !attr.system);
9201
9691
  }
9202
9692
  return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
@@ -9232,14 +9722,14 @@ var ObjectSchemaService = class extends BaseService {
9232
9722
  pluralLabel: dbObject.pluralLabel,
9233
9723
  description: dbObject.description,
9234
9724
  labelExpression: dbObject.labelExpression,
9235
- icon: _optionalChain([dbObject, 'access', _160 => _160.metadata, 'optionalAccess', _161 => _161.icon])
9725
+ icon: _optionalChain([dbObject, 'access', _180 => _180.metadata, 'optionalAccess', _181 => _181.icon])
9236
9726
  };
9237
9727
  let metadata = dbObject.metadata;
9238
9728
  if (updates.icon !== void 0 || updates.metadata !== void 0) {
9239
9729
  metadata = {
9240
9730
  ...dbObject.metadata,
9241
9731
  ...updates.metadata,
9242
- icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _162 => _162.metadata, 'optionalAccess', _163 => _163.icon])))
9732
+ icon: _nullishCoalesce(updates.icon, () => ( _optionalChain([dbObject, 'access', _182 => _182.metadata, 'optionalAccess', _183 => _183.icon])))
9243
9733
  };
9244
9734
  }
9245
9735
  const updatedDbObject = await this.adapter.objects.update(objectId, {
@@ -9495,7 +9985,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
9495
9985
  let properties = inverseDbAttr.config.properties;
9496
9986
  if (!properties) {
9497
9987
  const nativeObj = this.nativeRegistry.getByName(bilateral.object);
9498
- const nativeAttr = _optionalChain([nativeObj, 'optionalAccess', _164 => _164.attributes, 'access', _165 => _165.find, 'call', _166 => _166((a) => a.name === bilateral.attribute)]);
9988
+ const nativeAttr = _optionalChain([nativeObj, 'optionalAccess', _184 => _184.attributes, 'access', _185 => _185.find, 'call', _186 => _186((a) => a.name === bilateral.attribute)]);
9499
9989
  if (nativeAttr && "properties" in nativeAttr) {
9500
9990
  properties = nativeAttr.properties;
9501
9991
  }
@@ -9584,7 +10074,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
9584
10074
  label: dbObject.label,
9585
10075
  pluralLabel: dbObject.pluralLabel,
9586
10076
  description: dbObject.description,
9587
- icon: _optionalChain([dbObject, 'access', _167 => _167.metadata, 'optionalAccess', _168 => _168.icon]),
10077
+ icon: _optionalChain([dbObject, 'access', _187 => _187.metadata, 'optionalAccess', _188 => _188.icon]),
9588
10078
  labelExpression: dbObject.labelExpression,
9589
10079
  attributes,
9590
10080
  system: dbObject.system,
@@ -9684,7 +10174,7 @@ Reserved names: ${RESERVED_ATTRIBUTE_NAMES.join(", ")}`
9684
10174
  const hasRelationToTarget = attrs.some((attr) => {
9685
10175
  if (attr.type !== "relation") return false;
9686
10176
  const config = attr.config;
9687
- return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _169 => _169.targets, 'optionalAccess', _170 => _170.some, 'call', _171 => _171((t) => t.object === targetObjectName)]), () => ( false));
10177
+ return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _189 => _189.targets, 'optionalAccess', _190 => _190.some, 'call', _191 => _191((t) => t.object === targetObjectName)]), () => ( false));
9688
10178
  });
9689
10179
  if (hasRelationToTarget) {
9690
10180
  referencing.push(obj.name);
@@ -9762,7 +10252,7 @@ Native objects must have system=true. Did you forget to call .system() in your b
9762
10252
  const existing = this.objects.get(object2.name);
9763
10253
  throw new Error(
9764
10254
  `[NativeObjectRegistry] Duplicate object name "${object2.name}":
9765
- - Existing: "${_optionalChain([existing, 'optionalAccess', _172 => _172.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _173 => _173.id])})
10255
+ - Existing: "${_optionalChain([existing, 'optionalAccess', _192 => _192.label])}" (id: ${_optionalChain([existing, 'optionalAccess', _193 => _193.id])})
9766
10256
  - New: "${object2.label}" (id: ${object2.id})
9767
10257
  Please use unique names for each native object.`
9768
10258
  );
@@ -9879,7 +10369,7 @@ var AuditService = class extends BaseService {
9879
10369
  this.isFlushing = false;
9880
10370
  /** Pending flush promise to allow waiting on concurrent flush */
9881
10371
  this.flushPromise = null;
9882
- if (_optionalChain([options, 'optionalAccess', _174 => _174.async]) && options.flushIntervalMs) {
10372
+ if (_optionalChain([options, 'optionalAccess', _194 => _194.async]) && options.flushIntervalMs) {
9883
10373
  this.startFlushTimer();
9884
10374
  }
9885
10375
  }
@@ -10077,7 +10567,7 @@ var AuditService = class extends BaseService {
10077
10567
  return;
10078
10568
  }
10079
10569
  const resolved = await this.resolveActorEmail(entry);
10080
- if (_optionalChain([this, 'access', _175 => _175.options, 'optionalAccess', _176 => _176.async])) {
10570
+ if (_optionalChain([this, 'access', _195 => _195.options, 'optionalAccess', _196 => _196.async])) {
10081
10571
  this.buffer.push(resolved);
10082
10572
  const batchSize = _nullishCoalesce(this.options.batchSize, () => ( 10));
10083
10573
  if (this.buffer.length >= batchSize) {
@@ -10094,7 +10584,7 @@ var AuditService = class extends BaseService {
10094
10584
  if (!entry.actorEmail && entry.actorId) {
10095
10585
  try {
10096
10586
  const profile = await this.adapter.userProfiles.findById(entry.actorId);
10097
- if (_optionalChain([profile, 'optionalAccess', _177 => _177.email])) {
10587
+ if (_optionalChain([profile, 'optionalAccess', _197 => _197.email])) {
10098
10588
  return { ...entry, actorEmail: profile.email };
10099
10589
  }
10100
10590
  } catch (e13) {
@@ -10106,7 +10596,7 @@ var AuditService = class extends BaseService {
10106
10596
  * Start the flush timer for async mode
10107
10597
  */
10108
10598
  startFlushTimer() {
10109
- const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _178 => _178.options, 'optionalAccess', _179 => _179.flushIntervalMs]), () => ( 1e3));
10599
+ const intervalMs = _nullishCoalesce(_optionalChain([this, 'access', _198 => _198.options, 'optionalAccess', _199 => _199.flushIntervalMs]), () => ( 1e3));
10110
10600
  this.flushTimer = setInterval(() => {
10111
10601
  this.flush().catch(() => {
10112
10602
  });
@@ -10136,7 +10626,7 @@ var browserStub4 = {
10136
10626
  run: (_store, callback) => callback()
10137
10627
  };
10138
10628
  var AsyncLocalStorageClass4 = null;
10139
- if (typeof process !== "undefined" && _optionalChain([process, 'access', _180 => _180.versions, 'optionalAccess', _181 => _181.node])) {
10629
+ if (typeof process !== "undefined" && _optionalChain([process, 'access', _200 => _200.versions, 'optionalAccess', _201 => _201.node])) {
10140
10630
  try {
10141
10631
  if (typeof _chunk3RG5ZIWIjs.__require !== "undefined") {
10142
10632
  const asyncHooks = _chunk3RG5ZIWIjs.__require.call(void 0, "async_hooks");
@@ -10195,7 +10685,7 @@ var BilateralSyncService = class extends BaseService {
10195
10685
  }
10196
10686
  const ctx = getSyncContext().getStore();
10197
10687
  const syncKey = `${sourceSchema.name}:${sourceRecordId}:${attributeName}`;
10198
- if (_optionalChain([ctx, 'optionalAccess', _182 => _182.syncing, 'access', _183 => _183.has, 'call', _184 => _184(syncKey)])) {
10688
+ if (_optionalChain([ctx, 'optionalAccess', _202 => _202.syncing, 'access', _203 => _203.has, 'call', _204 => _204(syncKey)])) {
10199
10689
  return;
10200
10690
  }
10201
10691
  await this.runWithSyncContext(syncKey, async () => {
@@ -10436,7 +10926,7 @@ var BilateralSyncService = class extends BaseService {
10436
10926
  */
10437
10927
  buildInverseMappings(sourceAttr) {
10438
10928
  const mappings = /* @__PURE__ */ new Map();
10439
- const definitions = _optionalChain([sourceAttr, 'access', _185 => _185.properties, 'optionalAccess', _186 => _186.definitions]);
10929
+ const definitions = _optionalChain([sourceAttr, 'access', _205 => _205.properties, 'optionalAccess', _206 => _206.definitions]);
10440
10930
  if (!definitions) return mappings;
10441
10931
  for (const def of definitions) {
10442
10932
  if (!hasOptions2(def)) continue;
@@ -10506,7 +10996,7 @@ var BilateralSyncService = class extends BaseService {
10506
10996
  const storage = getSyncContext();
10507
10997
  const existingCtx = storage.getStore();
10508
10998
  const ctx = {
10509
- syncing: new Set(_nullishCoalesce(_optionalChain([existingCtx, 'optionalAccess', _187 => _187.syncing]), () => ( [])))
10999
+ syncing: new Set(_nullishCoalesce(_optionalChain([existingCtx, 'optionalAccess', _207 => _207.syncing]), () => ( [])))
10510
11000
  };
10511
11001
  ctx.syncing.add(syncKey);
10512
11002
  return await storage.run(ctx, fn);
@@ -10614,7 +11104,7 @@ var UserService = class extends BaseService {
10614
11104
  if (roleErrors.length > 0) {
10615
11105
  errors.push({
10616
11106
  attribute: attrName,
10617
- message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _188 => _188.allowedRoles, 'optionalAccess', _189 => _189.join, 'call', _190 => _190(", ")])}`,
11107
+ message: `Users do not have required role for ${attr.label}. Allowed roles: ${_optionalChain([attr, 'access', _208 => _208.allowedRoles, 'optionalAccess', _209 => _209.join, 'call', _210 => _210(", ")])}`,
10618
11108
  invalidIds: roleErrors
10619
11109
  });
10620
11110
  }
@@ -11144,7 +11634,7 @@ var RelationPropertiesService = class extends BaseService {
11144
11634
  }
11145
11635
  }
11146
11636
  }
11147
- const shouldStoreAsInverse = _optionalChain([attribute, 'access', _191 => _191.bilateral, 'optionalAccess', _192 => _192.storageOwner]) === false;
11637
+ const shouldStoreAsInverse = _optionalChain([attribute, 'access', _211 => _211.bilateral, 'optionalAccess', _212 => _212.storageOwner]) === false;
11148
11638
  let storageFromObject = schema.name;
11149
11639
  let storageFromAttribute = attributeName;
11150
11640
  if (shouldStoreAsInverse && attribute.bilateral) {
@@ -11156,7 +11646,7 @@ var RelationPropertiesService = class extends BaseService {
11156
11646
  if (shouldStoreAsInverse) {
11157
11647
  const results = await Promise.all(
11158
11648
  normalized.map(
11159
- (item) => _optionalChain([adapter, 'access', _193 => _193.relationAttributes, 'optionalAccess', _194 => _194.findBySource, 'call', _195 => _195(
11649
+ (item) => _optionalChain([adapter, 'access', _213 => _213.relationAttributes, 'optionalAccess', _214 => _214.findBySource, 'call', _215 => _215(
11160
11650
  storageFromObject,
11161
11651
  item.id,
11162
11652
  storageFromAttribute
@@ -11295,7 +11785,7 @@ var RecordQueryService = class extends BaseService {
11295
11785
  super(adapter);
11296
11786
  this.schemaService = schemaService;
11297
11787
  this.options = options;
11298
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _196 => _196.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _197 => _197.policyRegistry]), () => ( defaultPolicyRegistry));
11788
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _216 => _216.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _217 => _217.policyRegistry]), () => ( defaultPolicyRegistry));
11299
11789
  this.relationPropertiesService = new RelationPropertiesService(adapter);
11300
11790
  }
11301
11791
  // ============================================================================
@@ -11346,12 +11836,12 @@ var RecordQueryService = class extends BaseService {
11346
11836
  * Internal list query execution
11347
11837
  */
11348
11838
  async executeListQuery(schema, objectId, options) {
11349
- if (_optionalChain([this, 'access', _198 => _198.options, 'optionalAccess', _199 => _199.permissionService]) && this.userId) {
11839
+ if (_optionalChain([this, 'access', _218 => _218.options, 'optionalAccess', _219 => _219.permissionService]) && this.userId) {
11350
11840
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
11351
11841
  }
11352
- const policy = _optionalChain([options, 'optionalAccess', _200 => _200.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
11842
+ const policy = _optionalChain([options, 'optionalAccess', _220 => _220.skipPolicyFilter]) ? void 0 : getPolicy(this.policyRegistry, this.userId, schema.name);
11353
11843
  let effectiveOptions = options;
11354
- if (_optionalChain([policy, 'optionalAccess', _201 => _201.applyListFilter]) && this.userId) {
11844
+ if (_optionalChain([policy, 'optionalAccess', _221 => _221.applyListFilter]) && this.userId) {
11355
11845
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
11356
11846
  effectiveOptions = policy.applyListFilter(ctx, options);
11357
11847
  }
@@ -11361,10 +11851,10 @@ var RecordQueryService = class extends BaseService {
11361
11851
  );
11362
11852
  let filteredRecords = result.records;
11363
11853
  let effectiveTotal = result.total;
11364
- if (_optionalChain([policy, 'optionalAccess', _202 => _202.canAccessRecord]) && this.userId) {
11854
+ if (_optionalChain([policy, 'optionalAccess', _222 => _222.canAccessRecord]) && this.userId) {
11365
11855
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
11366
- const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _203 => _203.limit]), () => ( 20));
11367
- const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _204 => _204.offset]), () => ( 0));
11856
+ const requestedLimit = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _223 => _223.limit]), () => ( 20));
11857
+ const requestedOffset = _nullishCoalesce(_optionalChain([effectiveOptions, 'optionalAccess', _224 => _224.offset]), () => ( 0));
11368
11858
  const overfetchMultiplier = 5;
11369
11859
  const batchSize = requestedLimit * overfetchMultiplier;
11370
11860
  const maxScanRecords = 1e4;
@@ -11386,7 +11876,7 @@ var RecordQueryService = class extends BaseService {
11386
11876
  exhausted = true;
11387
11877
  break;
11388
11878
  }
11389
- const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _205 => _205.canAccessRecord, 'optionalCall', _206 => _206(ctx, record)]));
11879
+ const filtered = batch.records.filter((record) => _optionalChain([policy, 'access', _225 => _225.canAccessRecord, 'optionalCall', _226 => _226(ctx, record)]));
11390
11880
  collected.push(...filtered);
11391
11881
  dbOffset += batch.records.length;
11392
11882
  totalScanned += batch.records.length;
@@ -11402,7 +11892,7 @@ var RecordQueryService = class extends BaseService {
11402
11892
  filteredRecords,
11403
11893
  schema
11404
11894
  );
11405
- if (!_optionalChain([options, 'optionalAccess', _207 => _207.skipFormulas])) {
11895
+ if (!_optionalChain([options, 'optionalAccess', _227 => _227.skipFormulas])) {
11406
11896
  return {
11407
11897
  records: enrichRecordsWithFormulas(filteredRecords, schema),
11408
11898
  total: effectiveTotal
@@ -11462,17 +11952,17 @@ var RecordQueryService = class extends BaseService {
11462
11952
  * Internal search query execution
11463
11953
  */
11464
11954
  async executeSearchQuery(schema, objectId, query, options) {
11465
- if (_optionalChain([this, 'access', _208 => _208.options, 'optionalAccess', _209 => _209.permissionService]) && this.userId) {
11955
+ if (_optionalChain([this, 'access', _228 => _228.options, 'optionalAccess', _229 => _229.permissionService]) && this.userId) {
11466
11956
  await checkPermission(this.options.permissionService, this.userId, schema.name, "read");
11467
11957
  }
11468
11958
  let result;
11469
11959
  if (this.adapter.search) {
11470
11960
  try {
11471
11961
  result = await this.adapter.search.searchRecords(objectId, query, {
11472
- limit: _optionalChain([options, 'optionalAccess', _210 => _210.limit]),
11473
- offset: _optionalChain([options, 'optionalAccess', _211 => _211.offset]),
11474
- sorts: _optionalChain([options, 'optionalAccess', _212 => _212.sorts]),
11475
- filters: _optionalChain([options, 'optionalAccess', _213 => _213.filters]),
11962
+ limit: _optionalChain([options, 'optionalAccess', _230 => _230.limit]),
11963
+ offset: _optionalChain([options, 'optionalAccess', _231 => _231.offset]),
11964
+ sorts: _optionalChain([options, 'optionalAccess', _232 => _232.sorts]),
11965
+ filters: _optionalChain([options, 'optionalAccess', _233 => _233.filters]),
11476
11966
  attributes: schema.attributes
11477
11967
  });
11478
11968
  result = await this.healSearchResults(result);
@@ -11492,7 +11982,7 @@ var RecordQueryService = class extends BaseService {
11492
11982
  result.records,
11493
11983
  schema
11494
11984
  );
11495
- if (!_optionalChain([options, 'optionalAccess', _214 => _214.skipFormulas])) {
11985
+ if (!_optionalChain([options, 'optionalAccess', _234 => _234.skipFormulas])) {
11496
11986
  return {
11497
11987
  records: enrichRecordsWithFormulas(enrichedRecords, schema),
11498
11988
  total: result.total
@@ -11701,7 +12191,7 @@ var RelationService = class extends BaseService {
11701
12191
  }
11702
12192
  const isUniversal = attr.targets.length === 1 && attr.targets[0].object === RELATION_TARGET_ANY;
11703
12193
  const validObjectIds = isUniversal ? null : await this.getValidObjectIds(attr.targets);
11704
- if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _215 => _215.size]) === 0) {
12194
+ if (!isUniversal && _optionalChain([validObjectIds, 'optionalAccess', _235 => _235.size]) === 0) {
11705
12195
  errors.push({
11706
12196
  attribute: attr.name,
11707
12197
  message: `No valid target objects found for ${attr.label}`
@@ -11754,7 +12244,7 @@ var RelationService = class extends BaseService {
11754
12244
  for (const target of targets) {
11755
12245
  try {
11756
12246
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
11757
- if (_optionalChain([objectSchema, 'optionalAccess', _216 => _216.id])) {
12247
+ if (_optionalChain([objectSchema, 'optionalAccess', _236 => _236.id])) {
11758
12248
  objectIds.add(objectSchema.id);
11759
12249
  }
11760
12250
  } catch (e17) {
@@ -11823,7 +12313,7 @@ var RelationService = class extends BaseService {
11823
12313
  const targetResults = await Promise.all(
11824
12314
  filteredTargets.map(async (target) => {
11825
12315
  const objectSchema = await this.schemaService.getObjectSchemaByName(target.object);
11826
- if (!_optionalChain([objectSchema, 'optionalAccess', _217 => _217.id])) return { options: [], total: 0 };
12316
+ if (!_optionalChain([objectSchema, 'optionalAccess', _237 => _237.id])) return { options: [], total: 0 };
11827
12317
  const objectId = objectSchema.id;
11828
12318
  const result = query ? await queryService.searchRecords(objectId, query, queryOptions) : await queryService.listRecords(objectId, queryOptions);
11829
12319
  const options = await Promise.all(
@@ -11980,8 +12470,8 @@ var RelationService = class extends BaseService {
11980
12470
  continue;
11981
12471
  }
11982
12472
  const attribute = attributeMap.get(attributeId);
11983
- const targetConfig = _optionalChain([attribute, 'optionalAccess', _218 => _218.targets, 'optionalAccess', _219 => _219.find, 'call', _220 => _220((t) => t.object === objectSchema.name)]);
11984
- const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _221 => _221.displayTemplate]);
12473
+ const targetConfig = _optionalChain([attribute, 'optionalAccess', _238 => _238.targets, 'optionalAccess', _239 => _239.find, 'call', _240 => _240((t) => t.object === objectSchema.name)]);
12474
+ const customTemplate = _optionalChain([targetConfig, 'optionalAccess', _241 => _241.displayTemplate]);
11985
12475
  const label = await this.resolveLabel(record, objectSchema, customTemplate);
11986
12476
  resolved.push({
11987
12477
  _compositeId: compositeId,
@@ -12144,14 +12634,14 @@ var RollupService = class extends BaseService {
12144
12634
  const sourceSchema = getSchemaByNameFromContext(sourceObjectName);
12145
12635
  let sourceObjectId;
12146
12636
  let reverseRelationAttrName;
12147
- if (_optionalChain([sourceSchema, 'optionalAccess', _222 => _222.id])) {
12637
+ if (_optionalChain([sourceSchema, 'optionalAccess', _242 => _242.id])) {
12148
12638
  sourceObjectId = sourceSchema.id;
12149
12639
  const reverseRelationAttr = sourceSchema.attributes.find((attr) => {
12150
12640
  if (attr.type !== "relation") return false;
12151
12641
  const relationConfig = attr;
12152
- return _optionalChain([relationConfig, 'optionalAccess', _223 => _223.targets, 'optionalAccess', _224 => _224.some, 'call', _225 => _225((t) => t.object === schema.name)]);
12642
+ return _optionalChain([relationConfig, 'optionalAccess', _243 => _243.targets, 'optionalAccess', _244 => _244.some, 'call', _245 => _245((t) => t.object === schema.name)]);
12153
12643
  });
12154
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _226 => _226.name]);
12644
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _246 => _246.name]);
12155
12645
  } else {
12156
12646
  const sourceObject = await this.adapter.objects.findByName(sourceObjectName);
12157
12647
  if (!sourceObject) {
@@ -12162,9 +12652,9 @@ var RollupService = class extends BaseService {
12162
12652
  const reverseRelationAttr = sourceAttributes.find((attr) => {
12163
12653
  if (attr.type !== "relation") return false;
12164
12654
  const relationConfig = attr.config;
12165
- return _optionalChain([relationConfig, 'optionalAccess', _227 => _227.targets, 'optionalAccess', _228 => _228.some, 'call', _229 => _229((t) => t.object === schema.name)]);
12655
+ return _optionalChain([relationConfig, 'optionalAccess', _247 => _247.targets, 'optionalAccess', _248 => _248.some, 'call', _249 => _249((t) => t.object === schema.name)]);
12166
12656
  });
12167
- reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _230 => _230.name]);
12657
+ reverseRelationAttrName = _optionalChain([reverseRelationAttr, 'optionalAccess', _250 => _250.name]);
12168
12658
  }
12169
12659
  if (!reverseRelationAttrName) {
12170
12660
  return { value: null, recordCount: 0 };
@@ -12420,13 +12910,13 @@ var RollupService = class extends BaseService {
12420
12910
  if (!obj) continue;
12421
12911
  for (const rollupDbAttr of rollupAttrs) {
12422
12912
  const rollupConfig = rollupDbAttr.config;
12423
- if (!_optionalChain([rollupConfig, 'optionalAccess', _231 => _231.relationAttribute])) continue;
12913
+ if (!_optionalChain([rollupConfig, 'optionalAccess', _251 => _251.relationAttribute])) continue;
12424
12914
  const relationAttr = attributes.find(
12425
12915
  (a) => a.type === "relation" && a.name === rollupConfig.relationAttribute
12426
12916
  );
12427
12917
  if (!relationAttr) continue;
12428
12918
  const relationConfig = relationAttr.config;
12429
- const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _232 => _232.targets, 'optionalAccess', _233 => _233.some, 'call', _234 => _234(
12919
+ const targetsChangedObject = _optionalChain([relationConfig, 'optionalAccess', _252 => _252.targets, 'optionalAccess', _253 => _253.some, 'call', _254 => _254(
12430
12920
  (t) => t.object === changedSchema.name
12431
12921
  )]);
12432
12922
  if (!targetsChangedObject) continue;
@@ -12451,11 +12941,11 @@ var RecordService = class extends BaseService {
12451
12941
  constructor(adapter, options) {
12452
12942
  super(adapter);
12453
12943
  this.schemaService = new ObjectSchemaService(adapter, registry, {
12454
- auditService: _optionalChain([options, 'optionalAccess', _235 => _235.auditService])
12944
+ auditService: _optionalChain([options, 'optionalAccess', _255 => _255.auditService])
12455
12945
  });
12456
- this.permissionService = _optionalChain([options, 'optionalAccess', _236 => _236.permissionService]);
12457
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _237 => _237.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12458
- this.policyRegistry = _optionalChain([options, 'optionalAccess', _238 => _238.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _239 => _239.policyRegistry]), () => ( defaultPolicyRegistry));
12946
+ this.permissionService = _optionalChain([options, 'optionalAccess', _256 => _256.permissionService]);
12947
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _257 => _257.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
12948
+ this.policyRegistry = _optionalChain([options, 'optionalAccess', _258 => _258.policyRegistry]) === null ? null : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _259 => _259.policyRegistry]), () => ( defaultPolicyRegistry));
12459
12949
  this.recordResolver = new RecordResolverService(adapter);
12460
12950
  this.queryService = new RecordQueryService(adapter, this.schemaService, {
12461
12951
  permissionService: this.permissionService,
@@ -12470,7 +12960,7 @@ var RecordService = class extends BaseService {
12470
12960
  recordResolver: this.recordResolver
12471
12961
  });
12472
12962
  this.userService = new UserService(adapter);
12473
- this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _240 => _240.hookRegistry]), () => ( new NoopHookRegistry()));
12963
+ this.hookRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _260 => _260.hookRegistry]), () => ( new NoopHookRegistry()));
12474
12964
  this.bilateralSyncService = new BilateralSyncService(
12475
12965
  adapter,
12476
12966
  this.schemaService,
@@ -12510,25 +13000,25 @@ var RecordService = class extends BaseService {
12510
13000
  schema,
12511
13001
  this.tenantId,
12512
13002
  dataWithDefaults,
12513
- _optionalChain([options, 'optionalAccess', _241 => _241.hookMetadata])
13003
+ _optionalChain([options, 'optionalAccess', _261 => _261.hookMetadata])
12514
13004
  );
12515
- if (!_optionalChain([options, 'optionalAccess', _242 => _242.skipHooks])) {
13005
+ if (!_optionalChain([options, 'optionalAccess', _262 => _262.skipHooks])) {
12516
13006
  await this.hookRegistry.execute("beforeCreate", schema.name, hookCtx);
12517
13007
  }
12518
13008
  const normalizedData = this.relationPropertiesService.normalizeRelationValuesForStorage(
12519
13009
  schema,
12520
13010
  dataWithDefaults
12521
13011
  );
12522
- if (_optionalChain([options, 'optionalAccess', _243 => _243.validate]) !== false) {
12523
- if (_optionalChain([options, 'optionalAccess', _244 => _244.allowDraft])) {
13012
+ if (_optionalChain([options, 'optionalAccess', _263 => _263.validate]) !== false) {
13013
+ if (_optionalChain([options, 'optionalAccess', _264 => _264.allowDraft])) {
12524
13014
  _chunkZW4N6FV7js.validateDraftOrThrow.call(void 0, schema, normalizedData);
12525
13015
  } else {
12526
13016
  _chunkZW4N6FV7js.validateObjectOrThrow.call(void 0, schema, normalizedData);
12527
13017
  }
12528
- if (!_optionalChain([options, 'optionalAccess', _245 => _245.skipRelationValidation])) {
13018
+ if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipRelationValidation])) {
12529
13019
  await this.relationService.validateRelationsOrThrow(schema, normalizedData);
12530
13020
  }
12531
- if (!_optionalChain([options, 'optionalAccess', _246 => _246.skipUserValidation])) {
13021
+ if (!_optionalChain([options, 'optionalAccess', _266 => _266.skipUserValidation])) {
12532
13022
  await this.userService.validateUsersOrThrow(schema, normalizedData);
12533
13023
  }
12534
13024
  }
@@ -12539,12 +13029,12 @@ var RecordService = class extends BaseService {
12539
13029
  data: normalizedData,
12540
13030
  label,
12541
13031
  completionStatus,
12542
- metadata: _optionalChain([options, 'optionalAccess', _247 => _247.metadata]),
13032
+ metadata: _optionalChain([options, 'optionalAccess', _267 => _267.metadata]),
12543
13033
  createdBy: this.userId
12544
13034
  });
12545
13035
  for (const [attrName, value] of Object.entries(dataWithDefaults)) {
12546
13036
  const attr = schema.attributes.find((a) => a.name === attrName);
12547
- if (_optionalChain([attr, 'optionalAccess', _248 => _248.type]) === "relation") {
13037
+ if (_optionalChain([attr, 'optionalAccess', _268 => _268.type]) === "relation") {
12548
13038
  const hasProperties2 = attr.properties !== void 0;
12549
13039
  const isBilateral = isBilateralRelation(attr);
12550
13040
  if (hasProperties2 || isBilateral) {
@@ -12560,7 +13050,7 @@ var RecordService = class extends BaseService {
12560
13050
  }
12561
13051
  for (const [attrName, value] of Object.entries(dataWithDefaults)) {
12562
13052
  const attr = schema.attributes.find((a) => a.name === attrName);
12563
- if (_optionalChain([attr, 'optionalAccess', _249 => _249.type]) === "relation" && isBilateralRelation(attr)) {
13053
+ if (_optionalChain([attr, 'optionalAccess', _269 => _269.type]) === "relation" && isBilateralRelation(attr)) {
12564
13054
  await this.bilateralSyncService.syncBilateralRelation(
12565
13055
  schema,
12566
13056
  record.id,
@@ -12571,7 +13061,7 @@ var RecordService = class extends BaseService {
12571
13061
  );
12572
13062
  }
12573
13063
  }
12574
- if (!_optionalChain([options, 'optionalAccess', _250 => _250.skipHooks])) {
13064
+ if (!_optionalChain([options, 'optionalAccess', _270 => _270.skipHooks])) {
12575
13065
  const afterCtx = {
12576
13066
  ...hookCtx,
12577
13067
  recordId: record.id,
@@ -12581,11 +13071,11 @@ var RecordService = class extends BaseService {
12581
13071
  }
12582
13072
  await recalculateParentRollups(record, schema, this.rollupContext);
12583
13073
  await this.invalidateRecordCaches(record.id, objectId);
12584
- _optionalChain([this, 'access', _251 => _251.adapter, 'access', _252 => _252.search, 'optionalAccess', _253 => _253.indexRecord, 'call', _254 => _254(record, {
13074
+ _optionalChain([this, 'access', _271 => _271.adapter, 'access', _272 => _272.search, 'optionalAccess', _273 => _273.indexRecord, 'call', _274 => _274(record, {
12585
13075
  objectName: schema.name,
12586
13076
  objectLabel: schema.label,
12587
13077
  attributes: schema.attributes
12588
- }), 'access', _255 => _255.catch, 'call', _256 => _256((err) => console.error("[search] Failed to index created record", record.id, err))]);
13078
+ }), 'access', _275 => _275.catch, 'call', _276 => _276((err) => console.error("[search] Failed to index created record", record.id, err))]);
12589
13079
  if (this.auditService && this.userId) {
12590
13080
  this.auditService.logRecordAction({
12591
13081
  action: "record.created",
@@ -12594,7 +13084,7 @@ var RecordService = class extends BaseService {
12594
13084
  objectId: schema.id,
12595
13085
  recordId: record.id,
12596
13086
  recordLabel: record.label,
12597
- metadata: _optionalChain([options, 'optionalAccess', _257 => _257.hookMetadata])
13087
+ metadata: _optionalChain([options, 'optionalAccess', _277 => _277.hookMetadata])
12598
13088
  }).catch(() => {
12599
13089
  });
12600
13090
  }
@@ -12617,7 +13107,7 @@ var RecordService = class extends BaseService {
12617
13107
  return null;
12618
13108
  }
12619
13109
  const schema = await this.schemaService.getObjectSchema(record.objectId);
12620
- if (!_optionalChain([options, 'optionalAccess', _258 => _258.skipPolicyCheck])) {
13110
+ if (!_optionalChain([options, 'optionalAccess', _278 => _278.skipPolicyCheck])) {
12621
13111
  const policy = getPolicy(this.policyRegistry, this.userId, schema.name);
12622
13112
  if (policy) {
12623
13113
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
@@ -12627,11 +13117,11 @@ var RecordService = class extends BaseService {
12627
13117
  }
12628
13118
  }
12629
13119
  let enrichedRecord = record;
12630
- if (!_optionalChain([options, 'optionalAccess', _259 => _259.skipFormulas])) {
13120
+ if (!_optionalChain([options, 'optionalAccess', _279 => _279.skipFormulas])) {
12631
13121
  enrichedRecord = enrichWithFormulas(record, schema);
12632
13122
  }
12633
13123
  enrichedRecord = await this.enrichRelationProperties(enrichedRecord, schema);
12634
- if (_optionalChain([options, 'optionalAccess', _260 => _260.includeSchema])) {
13124
+ if (_optionalChain([options, 'optionalAccess', _280 => _280.includeSchema])) {
12635
13125
  const recordWithSchema = enrichedRecord;
12636
13126
  recordWithSchema.schema = schema;
12637
13127
  return recordWithSchema;
@@ -12693,9 +13183,9 @@ var RecordService = class extends BaseService {
12693
13183
  existing,
12694
13184
  mergedData,
12695
13185
  changedAttributes,
12696
- _optionalChain([options, 'optionalAccess', _261 => _261.hookMetadata])
13186
+ _optionalChain([options, 'optionalAccess', _281 => _281.hookMetadata])
12697
13187
  );
12698
- if (!_optionalChain([options, 'optionalAccess', _262 => _262.skipHooks])) {
13188
+ if (!_optionalChain([options, 'optionalAccess', _282 => _282.skipHooks])) {
12699
13189
  await this.hookRegistry.execute("beforeUpdate", schema.name, hookCtx);
12700
13190
  }
12701
13191
  const hookModifiedValues = {};
@@ -12710,16 +13200,16 @@ var RecordService = class extends BaseService {
12710
13200
  dataToUpdate
12711
13201
  );
12712
13202
  const normalizedMergedData = { ...existing.values, ...normalizedUpdate };
12713
- if (_optionalChain([options, 'optionalAccess', _263 => _263.validate]) !== false) {
12714
- if (_optionalChain([options, 'optionalAccess', _264 => _264.partial])) {
13203
+ if (_optionalChain([options, 'optionalAccess', _283 => _283.validate]) !== false) {
13204
+ if (_optionalChain([options, 'optionalAccess', _284 => _284.partial])) {
12715
13205
  _chunkZW4N6FV7js.validateDraftOrThrow.call(void 0, schema, normalizedMergedData);
12716
13206
  } else {
12717
13207
  _chunkZW4N6FV7js.validateObjectOrThrow.call(void 0, schema, normalizedMergedData);
12718
13208
  }
12719
- if (!_optionalChain([options, 'optionalAccess', _265 => _265.skipRelationValidation])) {
13209
+ if (!_optionalChain([options, 'optionalAccess', _285 => _285.skipRelationValidation])) {
12720
13210
  await this.relationService.validateRelationsOrThrow(schema, normalizedUpdate);
12721
13211
  }
12722
- if (!_optionalChain([options, 'optionalAccess', _266 => _266.skipUserValidation])) {
13212
+ if (!_optionalChain([options, 'optionalAccess', _286 => _286.skipUserValidation])) {
12723
13213
  await this.userService.validateUsersOrThrow(schema, normalizedUpdate);
12724
13214
  }
12725
13215
  }
@@ -12732,7 +13222,7 @@ var RecordService = class extends BaseService {
12732
13222
  __lastUpdatedBy: this.userId,
12733
13223
  __expectedUpdatedAt: existing.updatedAt instanceof Date ? existing.updatedAt.toISOString() : existing.updatedAt
12734
13224
  };
12735
- if (_optionalChain([options, 'optionalAccess', _267 => _267.metadata]) !== void 0) {
13225
+ if (_optionalChain([options, 'optionalAccess', _287 => _287.metadata]) !== void 0) {
12736
13226
  const existingMetadata = _nullishCoalesce(existing.metadata, () => ( {}));
12737
13227
  const mergedMetadata = { ...existingMetadata, ...options.metadata };
12738
13228
  const cleanedMetadata = Object.fromEntries(
@@ -12743,20 +13233,20 @@ var RecordService = class extends BaseService {
12743
13233
  const bilateralOldValues = {};
12744
13234
  for (const attrName of Object.keys(normalizedUpdate)) {
12745
13235
  const attr = schema.attributes.find((a) => a.name === attrName);
12746
- if (_optionalChain([attr, 'optionalAccess', _268 => _268.type]) === "relation" && isBilateralRelation(attr)) {
13236
+ if (_optionalChain([attr, 'optionalAccess', _288 => _288.type]) === "relation" && isBilateralRelation(attr)) {
12747
13237
  bilateralOldValues[attrName] = existing.values[attrName];
12748
13238
  }
12749
13239
  }
12750
13240
  const updated = await this.adapter.objectRecords.update(recordId, updatePayload);
12751
13241
  await this.invalidateRecordCaches(recordId, existing.objectId);
12752
- _optionalChain([this, 'access', _269 => _269.adapter, 'access', _270 => _270.search, 'optionalAccess', _271 => _271.indexRecord, 'call', _272 => _272(updated, {
13242
+ _optionalChain([this, 'access', _289 => _289.adapter, 'access', _290 => _290.search, 'optionalAccess', _291 => _291.indexRecord, 'call', _292 => _292(updated, {
12753
13243
  objectName: schema.name,
12754
13244
  objectLabel: schema.label,
12755
13245
  attributes: schema.attributes
12756
- }), 'access', _273 => _273.catch, 'call', _274 => _274((err) => console.error("[search] Failed to index updated record", updated.id, err))]);
13246
+ }), 'access', _293 => _293.catch, 'call', _294 => _294((err) => console.error("[search] Failed to index updated record", updated.id, err))]);
12757
13247
  for (const [attrName, value] of Object.entries(dataToUpdate)) {
12758
13248
  const attr = schema.attributes.find((a) => a.name === attrName);
12759
- if (_optionalChain([attr, 'optionalAccess', _275 => _275.type]) === "relation") {
13249
+ if (_optionalChain([attr, 'optionalAccess', _295 => _295.type]) === "relation") {
12760
13250
  const hasProperties2 = attr.properties !== void 0;
12761
13251
  const isBilateral = isBilateralRelation(attr);
12762
13252
  if (hasProperties2 || isBilateral) {
@@ -12772,7 +13262,7 @@ var RecordService = class extends BaseService {
12772
13262
  }
12773
13263
  for (const [attrName, value] of Object.entries(dataToUpdate)) {
12774
13264
  const attr = schema.attributes.find((a) => a.name === attrName);
12775
- if (_optionalChain([attr, 'optionalAccess', _276 => _276.type]) === "relation" && isBilateralRelation(attr)) {
13265
+ if (_optionalChain([attr, 'optionalAccess', _296 => _296.type]) === "relation" && isBilateralRelation(attr)) {
12776
13266
  const oldValue = bilateralOldValues[attrName];
12777
13267
  await this.bilateralSyncService.syncBilateralRelation(
12778
13268
  schema,
@@ -12783,7 +13273,7 @@ var RecordService = class extends BaseService {
12783
13273
  );
12784
13274
  }
12785
13275
  }
12786
- if (!_optionalChain([options, 'optionalAccess', _277 => _277.skipHooks])) {
13276
+ if (!_optionalChain([options, 'optionalAccess', _297 => _297.skipHooks])) {
12787
13277
  const afterCtx = {
12788
13278
  ...hookCtx,
12789
13279
  record: updated
@@ -12798,7 +13288,7 @@ var RecordService = class extends BaseService {
12798
13288
  if (this.auditService && this.userId && allChangedAttributes.length > 0) {
12799
13289
  const changes = allChangedAttributes.map((attr) => ({
12800
13290
  field: attr,
12801
- oldValue: _optionalChain([hookCtx, 'access', _278 => _278.oldValues, 'optionalAccess', _279 => _279[attr]]),
13291
+ oldValue: _optionalChain([hookCtx, 'access', _298 => _298.oldValues, 'optionalAccess', _299 => _299[attr]]),
12802
13292
  newValue: hookCtx.newValues[attr]
12803
13293
  }));
12804
13294
  this.auditService.logRecordAction({
@@ -12809,7 +13299,7 @@ var RecordService = class extends BaseService {
12809
13299
  recordId: updated.id,
12810
13300
  recordLabel: updated.label,
12811
13301
  changes,
12812
- metadata: _optionalChain([options, 'optionalAccess', _280 => _280.hookMetadata])
13302
+ metadata: _optionalChain([options, 'optionalAccess', _300 => _300.hookMetadata])
12813
13303
  }).catch(() => {
12814
13304
  });
12815
13305
  }
@@ -12841,17 +13331,17 @@ var RecordService = class extends BaseService {
12841
13331
  const ctx = buildPolicyContext(schema.name, this.userId, this.tenantId);
12842
13332
  checkRecordDeleteOrThrow(policy, record, ctx);
12843
13333
  }
12844
- if (_optionalChain([options, 'optionalAccess', _281 => _281.checkSystem]) && schema.system) {
13334
+ if (_optionalChain([options, 'optionalAccess', _301 => _301.checkSystem]) && schema.system) {
12845
13335
  throw new ProtectedResourceError("object", schema.name, "delete");
12846
13336
  }
12847
- if (!_optionalChain([options, 'optionalAccess', _282 => _282.skipReferenceCheck])) {
13337
+ if (!_optionalChain([options, 'optionalAccess', _302 => _302.skipReferenceCheck])) {
12848
13338
  const references = await this.adapter.objectRecords.countRecordsReferencingId(recordId);
12849
13339
  if (references.length > 0) {
12850
13340
  throw new RecordReferencedError(recordId, references);
12851
13341
  }
12852
13342
  }
12853
- const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _283 => _283.hookMetadata]));
12854
- if (!_optionalChain([options, 'optionalAccess', _284 => _284.skipHooks])) {
13343
+ const hookCtx = createContextForDelete(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _303 => _303.hookMetadata]));
13344
+ if (!_optionalChain([options, 'optionalAccess', _304 => _304.skipHooks])) {
12855
13345
  await this.hookRegistry.execute("beforeDelete", schema.name, hookCtx);
12856
13346
  }
12857
13347
  for (const attr of schema.attributes) {
@@ -12869,8 +13359,8 @@ var RecordService = class extends BaseService {
12869
13359
  }
12870
13360
  await this.adapter.objectRecords.delete(recordId);
12871
13361
  await this.invalidateRecordCaches(recordId, record.objectId);
12872
- _optionalChain([this, 'access', _285 => _285.adapter, 'access', _286 => _286.search, 'optionalAccess', _287 => _287.removeRecord, 'call', _288 => _288(recordId), 'access', _289 => _289.catch, 'call', _290 => _290((err) => console.error("[search] Failed to remove deleted record", recordId, err))]);
12873
- if (!_optionalChain([options, 'optionalAccess', _291 => _291.skipHooks])) {
13362
+ _optionalChain([this, 'access', _305 => _305.adapter, 'access', _306 => _306.search, 'optionalAccess', _307 => _307.removeRecord, 'call', _308 => _308(recordId), 'access', _309 => _309.catch, 'call', _310 => _310((err) => console.error("[search] Failed to remove deleted record", recordId, err))]);
13363
+ if (!_optionalChain([options, 'optionalAccess', _311 => _311.skipHooks])) {
12874
13364
  await this.hookRegistry.execute("afterDelete", schema.name, hookCtx);
12875
13365
  }
12876
13366
  await recalculateParentRollups(record, schema, this.rollupContext);
@@ -12882,7 +13372,7 @@ var RecordService = class extends BaseService {
12882
13372
  objectId: schema.id,
12883
13373
  recordId: record.id,
12884
13374
  recordLabel: record.label,
12885
- metadata: _optionalChain([options, 'optionalAccess', _292 => _292.hookMetadata])
13375
+ metadata: _optionalChain([options, 'optionalAccess', _312 => _312.hookMetadata])
12886
13376
  }).catch(() => {
12887
13377
  });
12888
13378
  }
@@ -12943,18 +13433,18 @@ var RecordService = class extends BaseService {
12943
13433
  this.tenantId
12944
13434
  );
12945
13435
  await checkPermission(this.permissionService, this.userId, schema.name, "update");
12946
- const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _293 => _293.hookMetadata]));
12947
- if (!_optionalChain([options, 'optionalAccess', _294 => _294.skipHooks])) {
13436
+ const hookCtx = createContextForRestore(schema, this.tenantId, record, _optionalChain([options, 'optionalAccess', _313 => _313.hookMetadata]));
13437
+ if (!_optionalChain([options, 'optionalAccess', _314 => _314.skipHooks])) {
12948
13438
  await this.hookRegistry.execute("beforeRestore", schema.name, hookCtx);
12949
13439
  }
12950
13440
  const restored = await this.adapter.objectRecords.restore(recordId);
12951
13441
  await this.invalidateRecordCaches(recordId, record.objectId);
12952
- _optionalChain([this, 'access', _295 => _295.adapter, 'access', _296 => _296.search, 'optionalAccess', _297 => _297.indexRecord, 'call', _298 => _298(restored, {
13442
+ _optionalChain([this, 'access', _315 => _315.adapter, 'access', _316 => _316.search, 'optionalAccess', _317 => _317.indexRecord, 'call', _318 => _318(restored, {
12953
13443
  objectName: schema.name,
12954
13444
  objectLabel: schema.label,
12955
13445
  attributes: schema.attributes
12956
- }), 'access', _299 => _299.catch, 'call', _300 => _300((err) => console.error("[search] Failed to index restored record", restored.id, err))]);
12957
- if (!_optionalChain([options, 'optionalAccess', _301 => _301.skipHooks])) {
13446
+ }), 'access', _319 => _319.catch, 'call', _320 => _320((err) => console.error("[search] Failed to index restored record", restored.id, err))]);
13447
+ if (!_optionalChain([options, 'optionalAccess', _321 => _321.skipHooks])) {
12958
13448
  const afterCtx = {
12959
13449
  ...hookCtx,
12960
13450
  record: restored
@@ -12969,7 +13459,7 @@ var RecordService = class extends BaseService {
12969
13459
  objectId: schema.id,
12970
13460
  recordId: restored.id,
12971
13461
  recordLabel: restored.label,
12972
- metadata: _optionalChain([options, 'optionalAccess', _302 => _302.hookMetadata])
13462
+ metadata: _optionalChain([options, 'optionalAccess', _322 => _322.hookMetadata])
12973
13463
  }).catch(() => {
12974
13464
  });
12975
13465
  }
@@ -13570,7 +14060,7 @@ var WorkflowAccessGrantService = class extends BaseService {
13570
14060
  * Check if a specific token has been revoked.
13571
14061
  */
13572
14062
  isTokenRevoked(dbGrant, jti) {
13573
- return _nullishCoalesce(_optionalChain([dbGrant, 'access', _303 => _303.revoked_token_jtis, 'optionalAccess', _304 => _304.includes, 'call', _305 => _305(jti)]), () => ( false));
14063
+ return _nullishCoalesce(_optionalChain([dbGrant, 'access', _323 => _323.revoked_token_jtis, 'optionalAccess', _324 => _324.includes, 'call', _325 => _325(jti)]), () => ( false));
13574
14064
  }
13575
14065
  /**
13576
14066
  * Validate access token payload against the grant.
@@ -13622,15 +14112,15 @@ var WorkflowInstanceService = class extends BaseService {
13622
14112
  constructor(adapter, workflowService, options) {
13623
14113
  super(adapter);
13624
14114
  this.workflowService = workflowService;
13625
- this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _306 => _306.executorRegistry]), () => ( getDefaultExecutorRegistry()));
13626
- this.schemaService = _optionalChain([options, 'optionalAccess', _307 => _307.schemaService]);
13627
- this.recordService = _optionalChain([options, 'optionalAccess', _308 => _308.recordService]);
14115
+ this.executorRegistry = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _326 => _326.executorRegistry]), () => ( getDefaultExecutorRegistry()));
14116
+ this.schemaService = _optionalChain([options, 'optionalAccess', _327 => _327.schemaService]);
14117
+ this.recordService = _optionalChain([options, 'optionalAccess', _328 => _328.recordService]);
13628
14118
  }
13629
14119
  /**
13630
14120
  * Start a new workflow instance
13631
14121
  */
13632
14122
  async startWorkflow(input) {
13633
- const workflow2 = await this.workflowService.getWorkflow(input.workflowName);
14123
+ let workflow2 = await this.workflowService.getWorkflow(input.workflowName);
13634
14124
  if (!workflow2) {
13635
14125
  throw new SchemaError(
13636
14126
  `Workflow "${input.workflowName}" not found`,
@@ -13643,6 +14133,20 @@ var WorkflowInstanceService = class extends BaseService {
13643
14133
  SchemaErrorCode.VALIDATION_FAILED
13644
14134
  );
13645
14135
  }
14136
+ if (workflow2.system && this.adapter.workflows) {
14137
+ const dbWorkflow = await this.adapter.workflows.upsert({
14138
+ name: workflow2.name,
14139
+ label: _nullishCoalesce(workflow2.label, () => ( workflow2.name)),
14140
+ description: workflow2.description,
14141
+ status: "published",
14142
+ version: workflow2.version,
14143
+ slots: _nullishCoalesce(workflow2.slots, () => ( [])),
14144
+ nodes: workflow2.nodes,
14145
+ startNodeId: workflow2.startNodeId,
14146
+ system: true
14147
+ });
14148
+ workflow2 = { ...workflow2, id: dbWorkflow.id };
14149
+ }
13646
14150
  const context = createEmptyContext();
13647
14151
  if (input.initialSlots) {
13648
14152
  for (const [slotId, data] of Object.entries(input.initialSlots)) {
@@ -13806,7 +14310,7 @@ var WorkflowInstanceService = class extends BaseService {
13806
14310
  if (!this.adapter.workflowInstances) {
13807
14311
  return { instances: [], total: 0 };
13808
14312
  }
13809
- if (_optionalChain([options, 'optionalAccess', _309 => _309.workflowName])) {
14313
+ if (_optionalChain([options, 'optionalAccess', _329 => _329.workflowName])) {
13810
14314
  const allDbInstances = await this.adapter.workflowInstances.findByWorkflowName(
13811
14315
  options.workflowName,
13812
14316
  { status: options.status }
@@ -13820,11 +14324,11 @@ var WorkflowInstanceService = class extends BaseService {
13820
14324
  return { instances: instances2, total: total2 };
13821
14325
  }
13822
14326
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.list({
13823
- limit: _optionalChain([options, 'optionalAccess', _310 => _310.limit]),
13824
- offset: _optionalChain([options, 'optionalAccess', _311 => _311.offset])
14327
+ limit: _optionalChain([options, 'optionalAccess', _330 => _330.limit]),
14328
+ offset: _optionalChain([options, 'optionalAccess', _331 => _331.offset])
13825
14329
  });
13826
14330
  let instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
13827
- if (_optionalChain([options, 'optionalAccess', _312 => _312.status])) {
14331
+ if (_optionalChain([options, 'optionalAccess', _332 => _332.status])) {
13828
14332
  instances = instances.filter((i) => i.status === options.status);
13829
14333
  }
13830
14334
  instances = await this.markExpiredInstances(instances);
@@ -13845,9 +14349,9 @@ var WorkflowInstanceService = class extends BaseService {
13845
14349
  return { instances: [], total: 0 };
13846
14350
  }
13847
14351
  const { instances: dbInstances, total } = await this.adapter.workflowInstances.findByRecordInSlots(objectName, recordId, {
13848
- status: _optionalChain([options, 'optionalAccess', _313 => _313.status]),
13849
- limit: _optionalChain([options, 'optionalAccess', _314 => _314.limit]),
13850
- offset: _optionalChain([options, 'optionalAccess', _315 => _315.offset])
14352
+ status: _optionalChain([options, 'optionalAccess', _333 => _333.status]),
14353
+ limit: _optionalChain([options, 'optionalAccess', _334 => _334.limit]),
14354
+ offset: _optionalChain([options, 'optionalAccess', _335 => _335.offset])
13851
14355
  });
13852
14356
  const instances = dbInstances.map((db) => this.convertDBInstanceToInstance(db));
13853
14357
  return { instances, total };
@@ -13913,7 +14417,7 @@ var WorkflowInstanceService = class extends BaseService {
13913
14417
  try {
13914
14418
  const schemas = await Promise.all(
13915
14419
  current.workflowSnapshot.slots.map(
13916
- (slot) => _optionalChain([this, 'access', _316 => _316.schemaService, 'optionalAccess', _317 => _317.getObjectSchemaByName, 'call', _318 => _318(slot.objectName)])
14420
+ (slot) => _optionalChain([this, 'access', _336 => _336.schemaService, 'optionalAccess', _337 => _337.getObjectSchemaByName, 'call', _338 => _338(slot.objectName)])
13917
14421
  )
13918
14422
  );
13919
14423
  objectDefinitions = schemas.filter(
@@ -14171,8 +14675,8 @@ var WorkflowInstanceService = class extends BaseService {
14171
14675
  */
14172
14676
  async snapshotRecord(recordId) {
14173
14677
  try {
14174
- const record = await _optionalChain([this, 'access', _319 => _319.recordService, 'optionalAccess', _320 => _320.getRecord, 'call', _321 => _321(recordId, { skipPolicyCheck: true })]);
14175
- return _optionalChain([record, 'optionalAccess', _322 => _322.values]);
14678
+ const record = await _optionalChain([this, 'access', _339 => _339.recordService, 'optionalAccess', _340 => _340.getRecord, 'call', _341 => _341(recordId, { skipPolicyCheck: true })]);
14679
+ return _optionalChain([record, 'optionalAccess', _342 => _342.values]);
14176
14680
  } catch (e20) {
14177
14681
  return void 0;
14178
14682
  }
@@ -14191,13 +14695,13 @@ var WorkflowInstanceService = class extends BaseService {
14191
14695
  for (const op of [...operations].reverse()) {
14192
14696
  try {
14193
14697
  if (op.operation === "create") {
14194
- await _optionalChain([this, 'access', _323 => _323.recordService, 'optionalAccess', _324 => _324.deleteRecord, 'call', _325 => _325(op.recordId, {
14698
+ await _optionalChain([this, 'access', _343 => _343.recordService, 'optionalAccess', _344 => _344.deleteRecord, 'call', _345 => _345(op.recordId, {
14195
14699
  skipHooks: true,
14196
14700
  skipReferenceCheck: true
14197
14701
  })]);
14198
14702
  rolledBack.push(op.slotId);
14199
14703
  } else if (op.operation === "update" && op.previousData) {
14200
- await _optionalChain([this, 'access', _326 => _326.recordService, 'optionalAccess', _327 => _327.updateRecord, 'call', _328 => _328(op.recordId, op.previousData, {
14704
+ await _optionalChain([this, 'access', _346 => _346.recordService, 'optionalAccess', _347 => _347.updateRecord, 'call', _348 => _348(op.recordId, op.previousData, {
14201
14705
  partial: false
14202
14706
  })]);
14203
14707
  rolledBack.push(op.slotId);
@@ -14321,7 +14825,7 @@ var WorkflowInstanceService = class extends BaseService {
14321
14825
  if (!this.adapter.workflowInstances) {
14322
14826
  return;
14323
14827
  }
14324
- const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _329 => _329.context, 'access', _330 => _330.variables, 'optionalAccess', _331 => _331.__version]), () => ( 0));
14828
+ const currentVersion = _nullishCoalesce(_optionalChain([instance, 'access', _349 => _349.context, 'access', _350 => _350.variables, 'optionalAccess', _351 => _351.__version]), () => ( 0));
14325
14829
  const nextVersion = currentVersion + 1;
14326
14830
  const instanceWithVersion = {
14327
14831
  ...instance,
@@ -14602,7 +15106,7 @@ var WorkflowRelationService = class extends BaseService {
14602
15106
  if (attr.type !== "relation") continue;
14603
15107
  for (const slot of slots) {
14604
15108
  const slotData = context.slots[slot.id];
14605
- const slotRecordId = _optionalChain([slotData, 'optionalAccess', _332 => _332.id]);
15109
+ const slotRecordId = _optionalChain([slotData, 'optionalAccess', _352 => _352.id]);
14606
15110
  if (!slotRecordId) continue;
14607
15111
  const targetsSlotObject = attr.targets.some(
14608
15112
  (t) => t.object === slot.objectName
@@ -14670,7 +15174,7 @@ var WorkflowService = class extends BaseService {
14670
15174
  if (Array.isArray(options)) {
14671
15175
  this.systemWorkflows = new Map(options.map((w) => [w.name, w]));
14672
15176
  } else {
14673
- this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _333 => _333.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
15177
+ this.systemWorkflows = new Map((_nullishCoalesce(_optionalChain([options, 'optionalAccess', _353 => _353.systemWorkflows]), () => ( []))).map((w) => [w.name, w]));
14674
15178
  }
14675
15179
  }
14676
15180
  // ============================================================================
@@ -14968,7 +15472,7 @@ var WorkflowService = class extends BaseService {
14968
15472
  var UserProfileService = class extends BaseService {
14969
15473
  constructor(adapter, options) {
14970
15474
  super(adapter);
14971
- this.auditService = _optionalChain([options, 'optionalAccess', _334 => _334.auditService]);
15475
+ this.auditService = _optionalChain([options, 'optionalAccess', _354 => _354.auditService]);
14972
15476
  }
14973
15477
  // ============================================================================
14974
15478
  // CACHE MANAGEMENT
@@ -15047,7 +15551,7 @@ var UserProfileService = class extends BaseService {
15047
15551
  async deleteAvatar(profileId) {
15048
15552
  const profile = await this.getProfileOrThrow(profileId);
15049
15553
  if (profile.avatarUrl && !profile.avatarUrl.startsWith("https://")) {
15050
- await _optionalChain([this, 'access', _335 => _335.adapter, 'access', _336 => _336.storage, 'optionalAccess', _337 => _337.delete, 'call', _338 => _338(profile.avatarUrl), 'access', _339 => _339.catch, 'call', _340 => _340(() => void 0)]);
15554
+ await _optionalChain([this, 'access', _355 => _355.adapter, 'access', _356 => _356.storage, 'optionalAccess', _357 => _357.delete, 'call', _358 => _358(profile.avatarUrl), 'access', _359 => _359.catch, 'call', _360 => _360(() => void 0)]);
15051
15555
  }
15052
15556
  return await this.updateProfile(profileId, { avatarUrl: null });
15053
15557
  }
@@ -15198,7 +15702,7 @@ var UserProfileService = class extends BaseService {
15198
15702
  */
15199
15703
  async deleteProfile(profileId, options) {
15200
15704
  const profile = await this.getProfileOrThrow(profileId);
15201
- if (_optionalChain([options, 'optionalAccess', _341 => _341.checkAdmin]) && this.adapter.permissions) {
15705
+ if (_optionalChain([options, 'optionalAccess', _361 => _361.checkAdmin]) && this.adapter.permissions) {
15202
15706
  const ownerCount = await this.adapter.permissions.countUsersWithRole("owner");
15203
15707
  if (ownerCount <= 1) {
15204
15708
  const userRoles = await this.adapter.permissions.getUserRoles(profileId);
@@ -15326,7 +15830,7 @@ var UserProfileService = class extends BaseService {
15326
15830
  var DocumentService = class extends BaseService {
15327
15831
  constructor(adapter, options) {
15328
15832
  super(adapter);
15329
- this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _342 => _342.fileService]), () => ( null));
15833
+ this.fileService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _362 => _362.fileService]), () => ( null));
15330
15834
  }
15331
15835
  // ============================================================================
15332
15836
  // CREATE
@@ -15544,7 +16048,7 @@ var DocumentService = class extends BaseService {
15544
16048
  */
15545
16049
  async isComplete(documentId) {
15546
16050
  const document2 = await this.getDocument(documentId);
15547
- return _optionalChain([document2, 'optionalAccess', _343 => _343.status]) !== "draft";
16051
+ return _optionalChain([document2, 'optionalAccess', _363 => _363.status]) !== "draft";
15548
16052
  }
15549
16053
  /**
15550
16054
  * Get document with its slots.
@@ -15787,7 +16291,7 @@ var DocumentProcessingService = class extends BaseService {
15787
16291
  type: "signature",
15788
16292
  provider: this.config.signatureAdapter.name,
15789
16293
  input: { signers, ...options },
15790
- expiresAt: _optionalChain([options, 'optionalAccess', _344 => _344.expiresAt])
16294
+ expiresAt: _optionalChain([options, 'optionalAccess', _364 => _364.expiresAt])
15791
16295
  });
15792
16296
  return job;
15793
16297
  }
@@ -16099,15 +16603,15 @@ var DocumentProcessingService = class extends BaseService {
16099
16603
  return {
16100
16604
  ocr: {
16101
16605
  available: !!this.config.ocrAdapter,
16102
- provider: _optionalChain([this, 'access', _345 => _345.config, 'access', _346 => _346.ocrAdapter, 'optionalAccess', _347 => _347.name])
16606
+ provider: _optionalChain([this, 'access', _365 => _365.config, 'access', _366 => _366.ocrAdapter, 'optionalAccess', _367 => _367.name])
16103
16607
  },
16104
16608
  signature: {
16105
16609
  available: !!this.config.signatureAdapter,
16106
- provider: _optionalChain([this, 'access', _348 => _348.config, 'access', _349 => _349.signatureAdapter, 'optionalAccess', _350 => _350.name])
16610
+ provider: _optionalChain([this, 'access', _368 => _368.config, 'access', _369 => _369.signatureAdapter, 'optionalAccess', _370 => _370.name])
16107
16611
  },
16108
16612
  identityVerification: {
16109
16613
  available: !!this.config.identityAdapter,
16110
- provider: _optionalChain([this, 'access', _351 => _351.config, 'access', _352 => _352.identityAdapter, 'optionalAccess', _353 => _353.name])
16614
+ provider: _optionalChain([this, 'access', _371 => _371.config, 'access', _372 => _372.identityAdapter, 'optionalAccess', _373 => _373.name])
16111
16615
  }
16112
16616
  };
16113
16617
  }
@@ -16129,7 +16633,7 @@ function decodeFileName(name) {
16129
16633
  var FileService = class extends BaseService {
16130
16634
  constructor(adapter, options) {
16131
16635
  super(adapter);
16132
- this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _354 => _354.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
16636
+ this.auditService = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.auditService]), () => ( (adapter.audit ? new AuditService(adapter) : void 0)));
16133
16637
  }
16134
16638
  // ============================================================================
16135
16639
  // UPLOAD (requires StorageAdapter)
@@ -16269,7 +16773,7 @@ var FileService = class extends BaseService {
16269
16773
  */
16270
16774
  async getFile(fileId) {
16271
16775
  const file2 = await this.adapter.files.findById(fileId);
16272
- if (_optionalChain([file2, 'optionalAccess', _355 => _355.deletedAt])) {
16776
+ if (_optionalChain([file2, 'optionalAccess', _375 => _375.deletedAt])) {
16273
16777
  return null;
16274
16778
  }
16275
16779
  return file2;
@@ -16331,12 +16835,12 @@ var FileService = class extends BaseService {
16331
16835
  */
16332
16836
  async deleteFile(fileId, options) {
16333
16837
  const file2 = await this.getFileOrThrow(fileId);
16334
- if (_optionalChain([options, 'optionalAccess', _356 => _356.checkOwnership]) && options.userId) {
16838
+ if (_optionalChain([options, 'optionalAccess', _376 => _376.checkOwnership]) && options.userId) {
16335
16839
  if (file2.uploadedBy !== options.userId) {
16336
16840
  throw new Error("You can only delete files you uploaded");
16337
16841
  }
16338
16842
  }
16339
- if (_optionalChain([options, 'optionalAccess', _357 => _357.hard])) {
16843
+ if (_optionalChain([options, 'optionalAccess', _377 => _377.hard])) {
16340
16844
  await this.adapter.files.hardDelete(fileId);
16341
16845
  } else {
16342
16846
  await this.adapter.files.delete(fileId);
@@ -16367,7 +16871,7 @@ var FileService = class extends BaseService {
16367
16871
  }
16368
16872
  const file2 = await this.getFileOrThrow(fileId);
16369
16873
  await this.adapter.storage.delete(file2.storagePath);
16370
- if (_optionalChain([options, 'optionalAccess', _358 => _358.hard])) {
16874
+ if (_optionalChain([options, 'optionalAccess', _378 => _378.hard])) {
16371
16875
  await this.adapter.files.hardDelete(fileId);
16372
16876
  } else {
16373
16877
  await this.adapter.files.delete(fileId);
@@ -16393,15 +16897,15 @@ var FileService = class extends BaseService {
16393
16897
  const fileResults = await Promise.all(fileIds.map((id) => this.getFile(id)));
16394
16898
  const files = fileResults.filter((f) => f !== null);
16395
16899
  if (files.length === 0) return;
16396
- if (_optionalChain([options, 'optionalAccess', _359 => _359.deleteFromStorage]) && this.adapter.storage) {
16900
+ if (_optionalChain([options, 'optionalAccess', _379 => _379.deleteFromStorage]) && this.adapter.storage) {
16397
16901
  const BATCH_SIZE = 10;
16398
16902
  for (let i = 0; i < files.length; i += BATCH_SIZE) {
16399
16903
  const batch = files.slice(i, i + BATCH_SIZE);
16400
- await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _360 => _360.adapter, 'access', _361 => _361.storage, 'optionalAccess', _362 => _362.delete, 'call', _363 => _363(file2.storagePath)])));
16904
+ await Promise.all(batch.map((file2) => _optionalChain([this, 'access', _380 => _380.adapter, 'access', _381 => _381.storage, 'optionalAccess', _382 => _382.delete, 'call', _383 => _383(file2.storagePath)])));
16401
16905
  }
16402
16906
  }
16403
16907
  const idsToDelete = files.map((f) => f.id);
16404
- if (_optionalChain([options, 'optionalAccess', _364 => _364.hard])) {
16908
+ if (_optionalChain([options, 'optionalAccess', _384 => _384.hard])) {
16405
16909
  await Promise.all(idsToDelete.map((id) => this.adapter.files.hardDelete(id)));
16406
16910
  } else {
16407
16911
  await Promise.all(idsToDelete.map((id) => this.adapter.files.delete(id)));
@@ -16409,12 +16913,12 @@ var FileService = class extends BaseService {
16409
16913
  if (this.auditService && this.userId) {
16410
16914
  await Promise.all(
16411
16915
  files.map(
16412
- (file2) => _optionalChain([this, 'access', _365 => _365.auditService, 'optionalAccess', _366 => _366.logFileAction, 'call', _367 => _367({
16916
+ (file2) => _optionalChain([this, 'access', _385 => _385.auditService, 'optionalAccess', _386 => _386.logFileAction, 'call', _387 => _387({
16413
16917
  action: "file.deleted",
16414
16918
  actorId: _nullishCoalesce(this.userId, () => ( "")),
16415
16919
  fileId: file2.id,
16416
16920
  fileName: file2.name,
16417
- metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _368 => _368.deleteFromStorage]), () => ( false)) }
16921
+ metadata: { deletedFromStorage: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _388 => _388.deleteFromStorage]), () => ( false)) }
16418
16922
  })])
16419
16923
  )
16420
16924
  );
@@ -16499,7 +17003,7 @@ var FileService = class extends BaseService {
16499
17003
  return true;
16500
17004
  }
16501
17005
  if (file2.visibility === "restricted") {
16502
- return _nullishCoalesce(_optionalChain([file2, 'access', _369 => _369.allowedUsers, 'optionalAccess', _370 => _370.includes, 'call', _371 => _371(userId)]), () => ( false));
17006
+ return _nullishCoalesce(_optionalChain([file2, 'access', _389 => _389.allowedUsers, 'optionalAccess', _390 => _390.includes, 'call', _391 => _391(userId)]), () => ( false));
16503
17007
  }
16504
17008
  return false;
16505
17009
  }
@@ -16594,7 +17098,7 @@ function withTimeout(promise, ms, label) {
16594
17098
  var GeocodingService = class {
16595
17099
  constructor(adapter, options) {
16596
17100
  this.adapter = adapter;
16597
- this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _372 => _372.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
17101
+ this.timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _392 => _392.timeoutMs]), () => ( GEOCODING_TIMEOUT_MS));
16598
17102
  }
16599
17103
  /**
16600
17104
  * Search for address suggestions as the user types
@@ -16653,9 +17157,9 @@ var GlobalSearchService = class extends BaseService {
16653
17157
  if (this.adapter.search) {
16654
17158
  try {
16655
17159
  const raw = await this.adapter.search.globalSearch(trimmed, {
16656
- objectNames: _optionalChain([options, 'optionalAccess', _373 => _373.objectNames]),
16657
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.limit]), () => ( 20)),
16658
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _375 => _375.offset]), () => ( 0))
17160
+ objectNames: _optionalChain([options, 'optionalAccess', _393 => _393.objectNames]),
17161
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _394 => _394.limit]), () => ( 20)),
17162
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _395 => _395.offset]), () => ( 0))
16659
17163
  });
16660
17164
  return await this.healGlobalSearchResults(raw);
16661
17165
  } catch (err) {
@@ -16663,9 +17167,9 @@ var GlobalSearchService = class extends BaseService {
16663
17167
  }
16664
17168
  }
16665
17169
  return this.adapter.objectRecords.globalSearch(trimmed, {
16666
- limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _376 => _376.limit]), () => ( 20)),
16667
- offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _377 => _377.offset]), () => ( 0)),
16668
- objectNames: _optionalChain([options, 'optionalAccess', _378 => _378.objectNames])
17170
+ limit: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _396 => _396.limit]), () => ( 20)),
17171
+ offset: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _397 => _397.offset]), () => ( 0)),
17172
+ objectNames: _optionalChain([options, 'optionalAccess', _398 => _398.objectNames])
16669
17173
  });
16670
17174
  }
16671
17175
  /**
@@ -16684,7 +17188,7 @@ var GlobalSearchService = class extends BaseService {
16684
17188
  if (this.adapter.search) {
16685
17189
  try {
16686
17190
  const raw = await this.adapter.search.globalSearchGrouped(trimmed, {
16687
- objectNames: _optionalChain([options, 'optionalAccess', _379 => _379.objectNames])
17191
+ objectNames: _optionalChain([options, 'optionalAccess', _399 => _399.objectNames])
16688
17192
  });
16689
17193
  return await this.healGroupedSearchResults(raw);
16690
17194
  } catch (err) {
@@ -16692,8 +17196,8 @@ var GlobalSearchService = class extends BaseService {
16692
17196
  }
16693
17197
  }
16694
17198
  return this.adapter.objectRecords.globalSearchGrouped(trimmed, {
16695
- objectNames: _optionalChain([options, 'optionalAccess', _380 => _380.objectNames]),
16696
- limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _381 => _381.limitPerGroup]), () => ( 5))
17199
+ objectNames: _optionalChain([options, 'optionalAccess', _400 => _400.objectNames]),
17200
+ limitPerGroup: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _401 => _401.limitPerGroup]), () => ( 5))
16697
17201
  });
16698
17202
  }
16699
17203
  // ==========================================================================
@@ -16760,7 +17264,7 @@ var PermissionService = class extends BaseService {
16760
17264
  }
16761
17265
  this.permissionsRepo = adapter.permissions;
16762
17266
  this.permissionCache = _nullishCoalesce(adapter.cache, () => ( new NoopCacheAdapter()));
16763
- this.auditService = _optionalChain([options, 'optionalAccess', _382 => _382.auditService]);
17267
+ this.auditService = _optionalChain([options, 'optionalAccess', _402 => _402.auditService]);
16764
17268
  }
16765
17269
  // ============================================================================
16766
17270
  // PERMISSION CHECKS
@@ -16776,11 +17280,11 @@ var PermissionService = class extends BaseService {
16776
17280
  async canAccessObject(userProfileId, objectName, action) {
16777
17281
  const permissions = await this.getEffectivePermissions(userProfileId);
16778
17282
  const wildcardPerms = permissions.objectPermissions["*"];
16779
- if (_optionalChain([wildcardPerms, 'optionalAccess', _383 => _383.includes, 'call', _384 => _384(action)])) {
17283
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _403 => _403.includes, 'call', _404 => _404(action)])) {
16780
17284
  return true;
16781
17285
  }
16782
17286
  const objectPerms = permissions.objectPermissions[objectName];
16783
- return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _385 => _385.includes, 'call', _386 => _386(action)]), () => ( false));
17287
+ return _nullishCoalesce(_optionalChain([objectPerms, 'optionalAccess', _405 => _405.includes, 'call', _406 => _406(action)]), () => ( false));
16784
17288
  }
16785
17289
  /**
16786
17290
  * Check if user can access an object, throw ForbiddenError if not.
@@ -16829,12 +17333,12 @@ var PermissionService = class extends BaseService {
16829
17333
  */
16830
17334
  async canAccessSystem(userProfileId, resource, action) {
16831
17335
  const permissions = await this.getEffectivePermissions(userProfileId);
16832
- const wildcardPerms = _optionalChain([permissions, 'access', _387 => _387.systemPermissions, 'optionalAccess', _388 => _388["*"]]);
16833
- if (_optionalChain([wildcardPerms, 'optionalAccess', _389 => _389.includes, 'call', _390 => _390(action)])) {
17336
+ const wildcardPerms = _optionalChain([permissions, 'access', _407 => _407.systemPermissions, 'optionalAccess', _408 => _408["*"]]);
17337
+ if (_optionalChain([wildcardPerms, 'optionalAccess', _409 => _409.includes, 'call', _410 => _410(action)])) {
16834
17338
  return true;
16835
17339
  }
16836
- const resourcePerms = _optionalChain([permissions, 'access', _391 => _391.systemPermissions, 'optionalAccess', _392 => _392[resource]]);
16837
- return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _393 => _393.includes, 'call', _394 => _394(action)]), () => ( false));
17340
+ const resourcePerms = _optionalChain([permissions, 'access', _411 => _411.systemPermissions, 'optionalAccess', _412 => _412[resource]]);
17341
+ return _nullishCoalesce(_optionalChain([resourcePerms, 'optionalAccess', _413 => _413.includes, 'call', _414 => _414(action)]), () => ( false));
16838
17342
  }
16839
17343
  /**
16840
17344
  * Check if user can access a system resource, throw ForbiddenError if not.
@@ -16860,8 +17364,8 @@ var PermissionService = class extends BaseService {
16860
17364
  */
16861
17365
  async getSystemPermissions(userProfileId, resource) {
16862
17366
  const permissions = await this.getEffectivePermissions(userProfileId);
16863
- const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _395 => _395.systemPermissions, 'optionalAccess', _396 => _396["*"]]), () => ( []));
16864
- const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _397 => _397.systemPermissions, 'optionalAccess', _398 => _398[resource]]), () => ( []));
17367
+ const wildcardPerms = _nullishCoalesce(_optionalChain([permissions, 'access', _415 => _415.systemPermissions, 'optionalAccess', _416 => _416["*"]]), () => ( []));
17368
+ const resourcePerms = _nullishCoalesce(_optionalChain([permissions, 'access', _417 => _417.systemPermissions, 'optionalAccess', _418 => _418[resource]]), () => ( []));
16865
17369
  const allPerms = /* @__PURE__ */ new Set([...wildcardPerms, ...resourcePerms]);
16866
17370
  return {
16867
17371
  canRead: allPerms.has("read"),
@@ -17004,7 +17508,7 @@ var PermissionService = class extends BaseService {
17004
17508
  action: "role.updated",
17005
17509
  actorId: this.userId,
17006
17510
  roleId,
17007
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _399 => _399.label]), () => ( roleId)),
17511
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _419 => _419.label]), () => ( roleId)),
17008
17512
  metadata: { permissionsUpdated: true, permissionCount: permissions.length }
17009
17513
  });
17010
17514
  }
@@ -17034,7 +17538,7 @@ var PermissionService = class extends BaseService {
17034
17538
  action: "role.assigned",
17035
17539
  actorId: this.userId,
17036
17540
  roleId,
17037
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _400 => _400.label]), () => ( roleId)),
17541
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _420 => _420.label]), () => ( roleId)),
17038
17542
  targetUserId: userProfileId
17039
17543
  });
17040
17544
  }
@@ -17052,7 +17556,7 @@ var PermissionService = class extends BaseService {
17052
17556
  action: "role.revoked",
17053
17557
  actorId: this.userId,
17054
17558
  roleId,
17055
- roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _401 => _401.label]), () => ( roleId)),
17559
+ roleLabel: _nullishCoalesce(_optionalChain([role, 'optionalAccess', _421 => _421.label]), () => ( roleId)),
17056
17560
  targetUserId: userProfileId
17057
17561
  });
17058
17562
  }
@@ -17060,6 +17564,74 @@ var PermissionService = class extends BaseService {
17060
17564
  // ============================================================================
17061
17565
  // INITIALIZATION
17062
17566
  // ============================================================================
17567
+ /**
17568
+ * Reset all roles and permissions to their default configuration.
17569
+ *
17570
+ * This will:
17571
+ * 1. Delete all custom (non-system) roles and reassign their users to the default member role
17572
+ * 2. Reset permissions on the default roles (owner, member) back to defaults
17573
+ * 3. Invalidate all permission caches
17574
+ *
17575
+ * @example
17576
+ * ```typescript
17577
+ * const service = new PermissionService(adapter);
17578
+ * await service.resetToDefaults();
17579
+ * ```
17580
+ */
17581
+ async resetToDefaults() {
17582
+ const { DEFAULT_ROLES, DEFAULT_ROLE_PERMISSIONS } = await Promise.resolve().then(() => _interopRequireWildcard(require("./default-roles-5K3GHJTS.js")));
17583
+ await this.initializeDefaultRoles();
17584
+ const allRoles = await this.getRoles();
17585
+ const memberRole = allRoles.find((r) => r.name === DEFAULT_ROLES.MEMBER);
17586
+ if (!memberRole) {
17587
+ throw new Error("Default member role not found after initialization");
17588
+ }
17589
+ const customRoles = allRoles.filter(
17590
+ (r) => !Object.values(DEFAULT_ROLES).includes(
17591
+ r.name
17592
+ )
17593
+ );
17594
+ for (const role of customRoles) {
17595
+ const usersWithRole = await this.permissionsRepo.countUsersWithRole(role.name);
17596
+ if (usersWithRole > 0) {
17597
+ }
17598
+ await this.permissionsRepo.deleteRole(role.id);
17599
+ }
17600
+ for (const roleName of Object.values(DEFAULT_ROLES)) {
17601
+ const role = allRoles.find((r) => r.name === roleName);
17602
+ if (!role) continue;
17603
+ const permConfig = DEFAULT_ROLE_PERMISSIONS[roleName];
17604
+ const permissionInputs = [];
17605
+ for (const perm of permConfig.system) {
17606
+ permissionInputs.push({
17607
+ scope: "system",
17608
+ target: perm.target,
17609
+ actions: perm.actions
17610
+ });
17611
+ }
17612
+ for (const perm of permConfig.object) {
17613
+ permissionInputs.push({
17614
+ scope: "object",
17615
+ target: perm.target,
17616
+ actions: perm.actions
17617
+ });
17618
+ }
17619
+ await this.permissionsRepo.setPermissions(role.id, permissionInputs);
17620
+ }
17621
+ await this.invalidateAllCache();
17622
+ if (this.auditService && this.userId) {
17623
+ await this.auditService.logRoleAction({
17624
+ action: "role.updated",
17625
+ actorId: this.userId,
17626
+ roleId: "all",
17627
+ roleLabel: "All roles",
17628
+ metadata: {
17629
+ resetToDefaults: true,
17630
+ customRolesDeleted: customRoles.length
17631
+ }
17632
+ });
17633
+ }
17634
+ }
17063
17635
  /**
17064
17636
  * Initialize default roles for the tenant if they don't exist.
17065
17637
  *
@@ -17526,7 +18098,7 @@ var ViewService = class extends BaseService {
17526
18098
  dbView.objectName,
17527
18099
  dbView.type,
17528
18100
  objectDefinition,
17529
- dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _402 => _402.config, 'optionalAccess', _403 => _403.layout]), () => ( "page")) : void 0
18101
+ dbView.type === "detail" ? _nullishCoalesce(_optionalChain([dbView, 'access', _422 => _422.config, 'optionalAccess', _423 => _423.layout]), () => ( "page")) : void 0
17530
18102
  );
17531
18103
  const newConfig = generated.config;
17532
18104
  const updated = await this.adapter.views.update(viewId, { config: newConfig });
@@ -18429,4 +19001,15 @@ var NoopGeocodingAdapter = class {
18429
19001
 
18430
19002
 
18431
19003
 
18432
- exports.IDENTITY_PROPERTIES = IDENTITY_PROPERTIES; exports.BEHAVIOR_PROPERTIES = BEHAVIOR_PROPERTIES; exports.PRESENTATION_PROPERTIES = PRESENTATION_PROPERTIES; exports.isIdentityProperty = isIdentityProperty; exports.isBehaviorProperty = isBehaviorProperty; exports.isPresentationProperty = isPresentationProperty; exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.isBilateralRelation = isBilateralRelation; exports.inferInverseCardinality = inferInverseCardinality; exports.NON_SORTABLE_TYPES = NON_SORTABLE_TYPES; exports.isAttributeSortable = isAttributeSortable; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.getErrorMessage = getErrorMessage; exports.isFlowFieldsRow = isFlowFieldsRow; exports.isLayoutRow = isLayoutRow; exports.isFlowDefinition = isFlowDefinition; exports.isFlowPublished = isFlowPublished; exports.isSystemFlow = isSystemFlow; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.FORBIDDEN_PROPERTY_TYPES = FORBIDDEN_PROPERTY_TYPES; exports.hasOptions = hasOptions2; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.nodeTypeRegistry = nodeTypeRegistry; exports.getNodeOutputs = getNodeOutputs; exports.setNodeNext = setNodeNext; exports.getNodeSlotIds = getNodeSlotIds; exports.validateNode = validateNode; exports.getFormFieldRefs = getFormFieldRefs; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isAssignNode = isAssignNode; exports.isEndNode = isEndNode; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isInvitationValid = isInvitationValid; exports.isInvitationAccepted = isInvitationAccepted; exports.isInvitationExpired = isInvitationExpired; exports.isGrantValid = isGrantValid; exports.isGrantRevoked = isGrantRevoked; exports.isTokenRevoked = isTokenRevoked; exports.isGrantExpired = isGrantExpired; exports.canAccessNode = canAccessNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.isFormFieldsRow = isFormFieldsRow; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isInvitationOrGrantEvent = isInvitationOrGrantEvent; exports.ZONE_ORDER = ZONE_ORDER; exports.ZONE_CONFIG = ZONE_CONFIG; exports.assignNodeZones = assignNodeZones; exports.groupNodesByZone = groupNodesByZone; exports.getZoneAllowedTypes = getZoneAllowedTypes; 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.AssignmentSourceSchema = AssignmentSourceSchema; exports.AssignmentMappingSchema = AssignmentMappingSchema; exports.AssignNodeSchema = AssignNodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.AuthMethodSchema = AuthMethodSchema; exports.ShareStatusSchema = ShareStatusSchema; exports.WorkflowShareSchema = WorkflowShareSchema; exports.CreateShareInputSchema = CreateShareInputSchema; 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.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.toUndefinedIfEmpty = toUndefinedIfEmpty; exports.hasProperties = hasProperties; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; 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.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.ConcurrentModificationError = ConcurrentModificationError; 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.document = document; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.RelationGroupBuilder = RelationGroupBuilder; exports.TableTabConfig = TableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.RichtextTabConfig = RichtextTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.DocumentsTabConfig = DocumentsTabConfig; exports.TabBuilder = TabBuilder; exports.DetailViewBuilder = DetailViewBuilder; exports.ViewBuilder = ViewBuilder; exports.detailView = detailView; exports.view = view; exports.ListViewBuilder = ListViewBuilder; exports.ListViewTabConfigBuilder = ListViewTabConfigBuilder; exports.listView = listView; exports.group = group; exports.relationGroup = relationGroup; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowAssignBuilder = WorkflowAssignBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.WorkflowJwtService = WorkflowJwtService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.FeatureFlagsContextError = FeatureFlagsContextError; exports.isFeatureEnabled = isFeatureEnabled; exports.getFeatureValue = getFeatureValue; exports.getFeatureFlags = getFeatureFlags; exports.tryGetFeatureValue = tryGetFeatureValue; exports.hasFeatureFlagsContext = hasFeatureFlagsContext; exports.runWithFeatureFlags = runWithFeatureFlags; exports.withFeatureFlags = withFeatureFlags; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext2; 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.AssignExecutor = AssignExecutor; 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.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.SORTABLE_ATTRIBUTE_TYPES = SORTABLE_ATTRIBUTE_TYPES; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.checkSharedObjectWriteAccess = checkSharedObjectWriteAccess; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RelationPropertiesService = RelationPropertiesService; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.GrantNotFoundError = GrantNotFoundError; exports.GrantExpiredError = GrantExpiredError; exports.GrantRevokedError = GrantRevokedError; exports.TokenRevokedError = TokenRevokedError; exports.WorkflowAccessGrantService = WorkflowAccessGrantService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.InvitationNotFoundError = InvitationNotFoundError; exports.InvitationExpiredError = InvitationExpiredError; exports.InvitationAlreadyAcceptedError = InvitationAlreadyAcceptedError; exports.InvitationRevokedError = InvitationRevokedError; exports.WorkflowInvitationService = WorkflowInvitationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.UserProfileService = UserProfileService; exports.DocumentService = DocumentService; exports.DocumentProcessingService = DocumentProcessingService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.seedRegistryViews = seedRegistryViews; exports.syncNativeViews = syncNativeViews; exports.verifyRegistryViewsSeeded = verifyRegistryViewsSeeded; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSeedPreview = getViewSeedPreview; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;
19004
+
19005
+
19006
+
19007
+
19008
+
19009
+
19010
+
19011
+
19012
+
19013
+
19014
+
19015
+ exports.IDENTITY_PROPERTIES = IDENTITY_PROPERTIES; exports.BEHAVIOR_PROPERTIES = BEHAVIOR_PROPERTIES; exports.PRESENTATION_PROPERTIES = PRESENTATION_PROPERTIES; exports.isIdentityProperty = isIdentityProperty; exports.isBehaviorProperty = isBehaviorProperty; exports.isPresentationProperty = isPresentationProperty; exports.RELATION_TARGET_ANY = RELATION_TARGET_ANY; exports.isUniversalRelation = isUniversalRelation; exports.isBilateralRelation = isBilateralRelation; exports.inferInverseCardinality = inferInverseCardinality; exports.NON_SORTABLE_TYPES = NON_SORTABLE_TYPES; exports.isAttributeSortable = isAttributeSortable; exports.RecordReferencedError = RecordReferencedError; exports.AttributeInUseError = AttributeInUseError; exports.ObjectReferencedError = ObjectReferencedError; exports.getErrorMessage = getErrorMessage; exports.isFlowFieldsRow = isFlowFieldsRow; exports.isLayoutRow = isLayoutRow; exports.isFlowDefinition = isFlowDefinition; exports.isFlowPublished = isFlowPublished; exports.isSystemFlow = isSystemFlow; exports.NoopGeocodingAdapter = NoopGeocodingAdapter; exports.SYSTEM_FIELD_NAMES = SYSTEM_FIELD_NAMES; exports.RESERVED_ATTRIBUTE_NAMES = RESERVED_ATTRIBUTE_NAMES; exports.PolicyViolationError = PolicyViolationError; exports.FORBIDDEN_PROPERTY_TYPES = FORBIDDEN_PROPERTY_TYPES; exports.hasOptions = hasOptions2; exports.SYSTEM_ATTRIBUTES = SYSTEM_ATTRIBUTES; exports.getSystemAttributeList = getSystemAttributeList; exports.isSystemAttribute = isSystemAttribute; exports.isSystemAttributeObject = isSystemAttributeObject; exports.nodeTypeRegistry = nodeTypeRegistry; exports.getNodeOutputs = getNodeOutputs; exports.setNodeNext = setNodeNext; exports.getNodeSlotIds = getNodeSlotIds; exports.validateNode = validateNode; exports.getFormFieldRefs = getFormFieldRefs; exports.isSimpleFormNode = isSimpleFormNode; exports.isAdvancedFormNode = isAdvancedFormNode; exports.isStartNode = isStartNode; exports.isFormNode = isFormNode; exports.isConditionNode = isConditionNode; exports.isAssignNode = isAssignNode; exports.isAINode = isAINode; exports.isEndNode = isEndNode; exports.isConditionRule = isConditionRule; exports.isConditionGroup = isConditionGroup; exports.eq = eq; exports.neq = neq; exports.and = and; exports.or = or; exports.inValues = inValues; exports.isWorkflowDefinition = isWorkflowDefinition; exports.isWorkflowPublished = isWorkflowPublished; exports.isSystemWorkflow = isSystemWorkflow; exports.isInstanceTerminal = isInstanceTerminal; exports.isInstanceWaiting = isInstanceWaiting; exports.canResumeInstance = canResumeInstance; exports.createStartTransition = createStartTransition; exports.isInvitationValid = isInvitationValid; exports.isInvitationAccepted = isInvitationAccepted; exports.isInvitationExpired = isInvitationExpired; exports.isGrantValid = isGrantValid; exports.isGrantRevoked = isGrantRevoked; exports.isTokenRevoked = isTokenRevoked; exports.isGrantExpired = isGrantExpired; exports.canAccessNode = canAccessNode; exports.createEmptyContext = createEmptyContext; exports.getContextValue = getContextValue; exports.setContextValue = setContextValue; exports.isFormFieldsRow = isFormFieldsRow; exports.DEFAULT_THEME = DEFAULT_THEME; exports.mergeWithDefaults = mergeWithDefaults; exports.generateCssVariables = generateCssVariables; exports.isInstanceEvent = isInstanceEvent; exports.isNodeEvent = isNodeEvent; exports.isInvitationOrGrantEvent = isInvitationOrGrantEvent; exports.ZONE_ORDER = ZONE_ORDER; exports.ZONE_CONFIG = ZONE_CONFIG; exports.assignNodeZones = assignNodeZones; exports.groupNodesByZone = groupNodesByZone; exports.getZoneAllowedTypes = getZoneAllowedTypes; 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.AssignmentSourceSchema = AssignmentSourceSchema; exports.AssignmentMappingSchema = AssignmentMappingSchema; exports.AssignNodeSchema = AssignNodeSchema; exports.DocumentGenerationActionSchema = DocumentGenerationActionSchema; exports.CodeExecutionActionSchema = CodeExecutionActionSchema; exports.AIActionConfigSchema = AIActionConfigSchema; exports.AINodeSchema = AINodeSchema; exports.EndNodeSchema = EndNodeSchema; exports.WorkflowNodeSchema = WorkflowNodeSchema; exports.SlotModeSchema = SlotModeSchema; exports.WorkflowSlotSchema = WorkflowSlotSchema; exports.AuthMethodSchema = AuthMethodSchema; exports.ShareStatusSchema = ShareStatusSchema; exports.WorkflowShareSchema = WorkflowShareSchema; exports.CreateShareInputSchema = CreateShareInputSchema; 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.isEmpty = isEmpty; exports.isNotEmpty = isNotEmpty; exports.toUndefinedIfEmpty = toUndefinedIfEmpty; exports.hasProperties = hasProperties; exports.EMPTY_VALUE_PLACEHOLDER = EMPTY_VALUE_PLACEHOLDER; exports.formatAttributeValue = formatAttributeValue; 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.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.ConcurrentModificationError = ConcurrentModificationError; 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.document = document; exports.ObjectBuilder = ObjectBuilder; exports.object = object; exports.GroupBuilder = GroupBuilder; exports.RelationGroupBuilder = RelationGroupBuilder; exports.TableTabConfig = TableTabConfig; exports.CustomTabConfig = CustomTabConfig; exports.RichtextTabConfig = RichtextTabConfig; exports.ActivityTabConfig = ActivityTabConfig; exports.FlowsTabConfig = FlowsTabConfig; exports.DocumentsTabConfig = DocumentsTabConfig; exports.TabBuilder = TabBuilder; exports.DetailViewBuilder = DetailViewBuilder; exports.ViewBuilder = ViewBuilder; exports.detailView = detailView; exports.view = view; exports.ListViewBuilder = ListViewBuilder; exports.ListViewTabConfigBuilder = ListViewTabConfigBuilder; exports.listView = listView; exports.group = group; exports.relationGroup = relationGroup; exports.WorkflowFormRowBuilder = WorkflowFormRowBuilder; exports.WorkflowFormBuilder = WorkflowFormBuilder; exports.WorkflowSimpleFormBuilder = WorkflowSimpleFormBuilder; exports.WorkflowConditionBuilder = WorkflowConditionBuilder; exports.WorkflowAssignBuilder = WorkflowAssignBuilder; exports.WorkflowAIBuilder = WorkflowAIBuilder; exports.WorkflowEndBuilder = WorkflowEndBuilder; exports.WorkflowStartBuilder = WorkflowStartBuilder; exports.WorkflowBuilder = WorkflowBuilder; exports.workflow = workflow; exports.registry = registry; exports.WorkflowJwtService = WorkflowJwtService; exports.hashOptions = hashOptions; exports.cacheKeys = cacheKeys; exports.cacheTtl = cacheTtl; exports.defaultTtl = defaultTtl; exports.NoopCacheAdapter = NoopCacheAdapter; exports.formatRecord = formatRecord; exports.formatRecords = formatRecords; exports.createDefaultState = createDefaultState; exports.SHORTCUT_TO_FILTER_OPERATOR = SHORTCUT_TO_FILTER_OPERATOR; exports.QueryNoResultError = QueryNoResultError; exports.QueryMultipleResultsError = QueryMultipleResultsError; exports.TenantContextError = TenantContextError; exports.FeatureFlagsContextError = FeatureFlagsContextError; exports.isFeatureEnabled = isFeatureEnabled; exports.getFeatureValue = getFeatureValue; exports.getFeatureFlags = getFeatureFlags; exports.tryGetFeatureValue = tryGetFeatureValue; exports.hasFeatureFlagsContext = hasFeatureFlagsContext; exports.runWithFeatureFlags = runWithFeatureFlags; exports.withFeatureFlags = withFeatureFlags; exports.getSchemaFromContext = getSchemaFromContext; exports.getSchemaByNameFromContext = getSchemaByNameFromContext; exports.hasSchemaContext = hasSchemaContext; exports.getSchemaContext = getSchemaContext; exports.addSchemaToContext = addSchemaToContext; exports.runWithSchemaContext = runWithSchemaContext; exports.runWithMergedSchemaContext = runWithMergedSchemaContext; exports.getContext = getContext2; 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.AssignExecutor = AssignExecutor; exports.AIExecutor = AIExecutor; exports.AIActionRegistry = AIActionRegistry; exports.DocumentGenerationHandler = DocumentGenerationHandler; exports.CodeExecutionHandler = CodeExecutionHandler; exports.createDefaultAIActionRegistry = createDefaultAIActionRegistry; 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.createMockAdapter = createMockAdapter; exports.PolicyRegistry = PolicyRegistry; exports.defaultPolicyRegistry = defaultPolicyRegistry; exports.SORTABLE_ATTRIBUTE_TYPES = SORTABLE_ATTRIBUTE_TYPES; exports.BaseService = BaseService; exports.BaseRepository = BaseRepository; exports.SchemaContextAwareRepository = SchemaContextAwareRepository; exports.buildAuditChanges = buildAuditChanges; exports.ObjectSchemaService = ObjectSchemaService; exports.AuditService = AuditService; exports.UserService = UserService; exports.applyDefaultValues = applyDefaultValues; exports.checkPermission = checkPermission; exports.getPolicy = getPolicy; exports.buildPolicyContext = buildPolicyContext; exports.checkRecordAccess = checkRecordAccess; exports.checkRecordModifyOrThrow = checkRecordModifyOrThrow; exports.checkRecordDeleteOrThrow = checkRecordDeleteOrThrow; exports.checkSharedObjectWriteAccess = checkSharedObjectWriteAccess; exports.computeLabel = computeLabel; exports.enrichWithFormulas = enrichWithFormulas; exports.enrichRecordsWithFormulas = enrichRecordsWithFormulas; exports.createContextForCreate = createContextForCreate; exports.createContextForUpdate = createContextForUpdate; exports.createContextForDelete = createContextForDelete; exports.createContextForRestore = createContextForRestore; exports.recalculateParentRollups = recalculateParentRollups; exports.RelationPropertiesService = RelationPropertiesService; exports.RecordQueryService = RecordQueryService; exports.RecordResolverService = RecordResolverService; exports.RelationService = RelationService; exports.RollupService = RollupService; exports.RecordService = RecordService; exports.FormulaResolverService = FormulaResolverService; exports.RollupScheduler = RollupScheduler; exports.GrantNotFoundError = GrantNotFoundError; exports.GrantExpiredError = GrantExpiredError; exports.GrantRevokedError = GrantRevokedError; exports.TokenRevokedError = TokenRevokedError; exports.WorkflowAccessGrantService = WorkflowAccessGrantService; exports.WorkflowInstanceService = WorkflowInstanceService; exports.InvitationNotFoundError = InvitationNotFoundError; exports.InvitationExpiredError = InvitationExpiredError; exports.InvitationAlreadyAcceptedError = InvitationAlreadyAcceptedError; exports.InvitationRevokedError = InvitationRevokedError; exports.WorkflowInvitationService = WorkflowInvitationService; exports.WorkflowRelationService = WorkflowRelationService; exports.WorkflowService = WorkflowService; exports.UserProfileService = UserProfileService; exports.DocumentService = DocumentService; exports.DocumentProcessingService = DocumentProcessingService; exports.FileService = FileService; exports.GeocodingService = GeocodingService; exports.GlobalSearchService = GlobalSearchService; exports.PermissionService = PermissionService; exports.ViewService = ViewService; exports.seedRegistryViews = seedRegistryViews; exports.syncNativeViews = syncNativeViews; exports.verifyRegistryViewsSeeded = verifyRegistryViewsSeeded; exports.verifyNativeViewsSync = verifyNativeViewsSync; exports.getViewSeedPreview = getViewSeedPreview; exports.getViewSyncPreview = getViewSyncPreview; exports.syncNativeObjects = syncNativeObjects; exports.verifyNativeObjectsSync = verifyNativeObjectsSync; exports.getSyncPreview = getSyncPreview; exports.syncAll = syncAll;