@stndrds/schema 1.0.0-alpha.92 → 1.0.0-alpha.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +405 -2124
- package/dist/index.d.ts +405 -2124
- package/dist/index.js +346 -117
- package/dist/index.mjs +311 -82
- package/dist/validation/validators.d.mts +1 -1
- package/dist/validation/validators.d.ts +1 -1
- package/dist/validators-5XMwJOlV.d.ts +3534 -0
- package/dist/validators-BCw4Sn01.d.mts +3534 -0
- package/package.json +2 -2
- package/dist/validators-BFgj3O3w.d.mts +0 -1576
- package/dist/validators-C7i6EpQK.d.ts +0 -1576
package/dist/index.mjs
CHANGED
|
@@ -153,7 +153,14 @@ var ObjectReferencedError = class extends Error {
|
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
function getErrorMessage(error) {
|
|
156
|
-
|
|
156
|
+
if (error instanceof Error) return error.message;
|
|
157
|
+
if (typeof error === "string") return error;
|
|
158
|
+
if (error && typeof error === "object") {
|
|
159
|
+
if ("message" in error && typeof error.message === "string")
|
|
160
|
+
return error.message;
|
|
161
|
+
return JSON.stringify(error);
|
|
162
|
+
}
|
|
163
|
+
return String(error);
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
// src/types/filters.ts
|
|
@@ -252,7 +259,10 @@ function isFlowFieldsRow(row) {
|
|
|
252
259
|
return !row.type || row.type === "fields";
|
|
253
260
|
}
|
|
254
261
|
function isLayoutRow(row) {
|
|
255
|
-
return !!row.type && row.type !== "fields";
|
|
262
|
+
return !!row.type && row.type !== "fields" && row.type !== "relationList";
|
|
263
|
+
}
|
|
264
|
+
function isFlowRelationListRow(row) {
|
|
265
|
+
return row.type === "relationList";
|
|
256
266
|
}
|
|
257
267
|
function isFlowDefinition(obj) {
|
|
258
268
|
return typeof obj === "object" && obj !== null && "slots" in obj && "pages" in obj && "relations" in obj && "status" in obj;
|
|
@@ -294,7 +304,9 @@ var RESERVED_ATTRIBUTE_NAMES = [
|
|
|
294
304
|
"completionStatus",
|
|
295
305
|
"values",
|
|
296
306
|
"metadata",
|
|
297
|
-
"deletedAt"
|
|
307
|
+
"deletedAt",
|
|
308
|
+
"schemaVersion",
|
|
309
|
+
"archivedValues"
|
|
298
310
|
];
|
|
299
311
|
|
|
300
312
|
// src/types/permissions.ts
|
|
@@ -711,28 +723,18 @@ var aiNodeType = {
|
|
|
711
723
|
},
|
|
712
724
|
getSlotIds(node) {
|
|
713
725
|
const slotIds = /* @__PURE__ */ new Set();
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
for (const id of action.inputSlotIds) slotIds.add(id);
|
|
717
|
-
for (const id of action.targetSlotIds) slotIds.add(id);
|
|
718
|
-
} else if (action.type === "code-execution") {
|
|
719
|
-
for (const id of action.inputSlotIds ?? []) slotIds.add(id);
|
|
720
|
-
}
|
|
726
|
+
for (const id of node.inputSlotIds ?? []) slotIds.add(id);
|
|
727
|
+
for (const id of node.targetSlotIds ?? []) slotIds.add(id);
|
|
721
728
|
return [...slotIds];
|
|
722
729
|
},
|
|
723
730
|
validate(node) {
|
|
724
731
|
const errors = [];
|
|
725
732
|
if (!node.label) errors.push("AINode must have a label");
|
|
726
|
-
if (!node.
|
|
733
|
+
if (!node.mode) errors.push("AINode must have a mode (sync or async)");
|
|
727
734
|
if (!node.next) errors.push("AINode must have a 'next' target");
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
errors.push("Document generation must have input slots");
|
|
732
|
-
if (!node.action.targetSlotIds?.length)
|
|
733
|
-
errors.push("Document generation must have target slots");
|
|
734
|
-
} else if (node.action?.type === "code-execution") {
|
|
735
|
-
if (!node.action.code) errors.push("Code execution must have code");
|
|
735
|
+
const hasAgentSource = !!node.definitionId || !!node.systemPrompt;
|
|
736
|
+
if (!hasAgentSource) {
|
|
737
|
+
errors.push("AINode must have either a definitionId or a systemPrompt");
|
|
736
738
|
}
|
|
737
739
|
return errors;
|
|
738
740
|
}
|
|
@@ -858,7 +860,8 @@ function createEmptyContext() {
|
|
|
858
860
|
documents: {},
|
|
859
861
|
variables: {},
|
|
860
862
|
conditionResults: {},
|
|
861
|
-
createdRecordIds: {}
|
|
863
|
+
createdRecordIds: {},
|
|
864
|
+
relationBuffers: {}
|
|
862
865
|
};
|
|
863
866
|
}
|
|
864
867
|
function getContextValue(context, path) {
|
|
@@ -1141,32 +1144,20 @@ var AssignNodeSchema = z.object({
|
|
|
1141
1144
|
assignments: z.array(AssignmentMappingSchema).min(1),
|
|
1142
1145
|
next: z.string().nullish()
|
|
1143
1146
|
});
|
|
1144
|
-
var DocumentGenerationActionSchema = z.object({
|
|
1145
|
-
type: z.literal("document-generation"),
|
|
1146
|
-
templateId: z.string().min(1, "Template ID is required"),
|
|
1147
|
-
inputSlotIds: z.array(z.string().min(1)).min(1, "At least one input slot is required"),
|
|
1148
|
-
targetSlotIds: z.array(z.string().min(1)).min(1, "At least one target slot is required"),
|
|
1149
|
-
outputFormat: z.enum(["pdf", "docx"]),
|
|
1150
|
-
aiInstructions: z.string().nullish()
|
|
1151
|
-
});
|
|
1152
|
-
var CodeExecutionActionSchema = z.object({
|
|
1153
|
-
type: z.literal("code-execution"),
|
|
1154
|
-
code: z.string().min(1, "Code is required"),
|
|
1155
|
-
language: z.enum(["javascript", "typescript", "python"]),
|
|
1156
|
-
inputSlotIds: z.array(z.string().min(1)).optional(),
|
|
1157
|
-
outputVariable: z.string().optional(),
|
|
1158
|
-
packages: z.array(z.string()).optional()
|
|
1159
|
-
});
|
|
1160
|
-
var AIActionConfigSchema = z.discriminatedUnion("type", [
|
|
1161
|
-
DocumentGenerationActionSchema,
|
|
1162
|
-
CodeExecutionActionSchema
|
|
1163
|
-
]);
|
|
1164
1147
|
var AINodeSchema = z.object({
|
|
1165
1148
|
type: z.literal("ai"),
|
|
1166
1149
|
id: z.string().min(1),
|
|
1167
1150
|
label: z.string().min(1),
|
|
1168
1151
|
description: z.string().nullish(),
|
|
1169
|
-
|
|
1152
|
+
mode: z.enum(["sync", "async"]),
|
|
1153
|
+
definitionId: z.string().optional(),
|
|
1154
|
+
systemPrompt: z.string().optional(),
|
|
1155
|
+
model: z.string().optional(),
|
|
1156
|
+
tools: z.array(z.string()).optional(),
|
|
1157
|
+
maxIterations: z.number().positive().optional(),
|
|
1158
|
+
instructions: z.string().optional(),
|
|
1159
|
+
inputSlotIds: z.array(z.string()).optional(),
|
|
1160
|
+
targetSlotIds: z.array(z.string()).optional(),
|
|
1170
1161
|
timeoutMs: z.number().positive().optional(),
|
|
1171
1162
|
next: z.string().nullish()
|
|
1172
1163
|
});
|
|
@@ -1316,6 +1307,14 @@ var WorkflowDefinitionSchema = z.object({
|
|
|
1316
1307
|
}
|
|
1317
1308
|
);
|
|
1318
1309
|
|
|
1310
|
+
// src/types/migrations.ts
|
|
1311
|
+
var DEFAULT_RETENTION_POLICY = {
|
|
1312
|
+
attributeData: 30,
|
|
1313
|
+
deletedObjects: 90,
|
|
1314
|
+
transforms: 365,
|
|
1315
|
+
migrationErrors: 30
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1319
1318
|
// src/lib/object-helpers.ts
|
|
1320
1319
|
function isEmpty2(obj) {
|
|
1321
1320
|
if (obj === null || obj === void 0) {
|
|
@@ -2834,8 +2833,146 @@ function document(config) {
|
|
|
2834
2833
|
|
|
2835
2834
|
// src/builders/object-builder.ts
|
|
2836
2835
|
import z2 from "zod";
|
|
2836
|
+
|
|
2837
|
+
// src/builders/migration-builder.ts
|
|
2838
|
+
function resolveBuiltInTransform(targetType) {
|
|
2839
|
+
const map = {
|
|
2840
|
+
text: "toString",
|
|
2841
|
+
textarea: "toString",
|
|
2842
|
+
richtext: "toString",
|
|
2843
|
+
number: "toNumber",
|
|
2844
|
+
currency: "toNumber",
|
|
2845
|
+
rating: "toNumber",
|
|
2846
|
+
date: "toDate",
|
|
2847
|
+
checkbox: "toBoolean"
|
|
2848
|
+
};
|
|
2849
|
+
return map[targetType];
|
|
2850
|
+
}
|
|
2851
|
+
function reverseOperation(op) {
|
|
2852
|
+
switch (op.type) {
|
|
2853
|
+
case "rename_attribute":
|
|
2854
|
+
return { type: "rename_attribute", from: op.to, to: op.from };
|
|
2855
|
+
case "add_attribute":
|
|
2856
|
+
return { type: "remove_attribute", name: op.attribute.name, backup_config: op.attribute };
|
|
2857
|
+
case "remove_attribute":
|
|
2858
|
+
return { type: "add_attribute", attribute: op.backup_config };
|
|
2859
|
+
case "change_type":
|
|
2860
|
+
return {
|
|
2861
|
+
type: "change_type",
|
|
2862
|
+
name: op.name,
|
|
2863
|
+
from: op.to,
|
|
2864
|
+
to: op.from,
|
|
2865
|
+
transform: op.transform ? resolveBuiltInTransform(op.from) : void 0
|
|
2866
|
+
};
|
|
2867
|
+
case "update_config":
|
|
2868
|
+
return { type: "update_config", name: op.name, from: op.to, to: op.from };
|
|
2869
|
+
case "rename_object":
|
|
2870
|
+
return { type: "rename_object", from: op.to, to: op.from };
|
|
2871
|
+
case "remove_object":
|
|
2872
|
+
return { type: "remove_object", backup: op.backup };
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
var MigrationBuilder = class {
|
|
2876
|
+
constructor(version) {
|
|
2877
|
+
this.operations = [];
|
|
2878
|
+
/** Tracks attribute names that have already been referenced in this migration */
|
|
2879
|
+
this.touchedAttributes = /* @__PURE__ */ new Set();
|
|
2880
|
+
this.version = version;
|
|
2881
|
+
}
|
|
2882
|
+
// --------------------------------------------------------------------------
|
|
2883
|
+
// CONFLICT GUARD
|
|
2884
|
+
// --------------------------------------------------------------------------
|
|
2885
|
+
assertNotTouched(name, operationType) {
|
|
2886
|
+
if (this.touchedAttributes.has(name)) {
|
|
2887
|
+
throw new Error(
|
|
2888
|
+
`[MigrationBuilder] Conflicting operations on attribute "${name}": it was already modified earlier in this migration (attempted: ${operationType}).`
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
// --------------------------------------------------------------------------
|
|
2893
|
+
// OPERATION METHODS
|
|
2894
|
+
// --------------------------------------------------------------------------
|
|
2895
|
+
/**
|
|
2896
|
+
* Rename an attribute.
|
|
2897
|
+
* The reverse operation will rename it back.
|
|
2898
|
+
*/
|
|
2899
|
+
renameAttribute(from, to) {
|
|
2900
|
+
this.assertNotTouched(from, "rename_attribute");
|
|
2901
|
+
this.touchedAttributes.add(from);
|
|
2902
|
+
this.operations.push({ type: "rename_attribute", from, to });
|
|
2903
|
+
return this;
|
|
2904
|
+
}
|
|
2905
|
+
/**
|
|
2906
|
+
* Change the type of an attribute.
|
|
2907
|
+
*
|
|
2908
|
+
* The `transform` option accepts a function — it is used only to signal
|
|
2909
|
+
* intent; the actual built-in transform is resolved from the target type.
|
|
2910
|
+
*/
|
|
2911
|
+
changeType(name, from, to, options) {
|
|
2912
|
+
this.assertNotTouched(name, "change_type");
|
|
2913
|
+
this.touchedAttributes.add(name);
|
|
2914
|
+
const transform = options?.transform ? resolveBuiltInTransform(to) : void 0;
|
|
2915
|
+
this.operations.push({ type: "change_type", name, from, to, transform });
|
|
2916
|
+
return this;
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* Remove an attribute.
|
|
2920
|
+
*
|
|
2921
|
+
* The `backup_config` is intentionally left empty — the sync engine will
|
|
2922
|
+
* populate it from current DB state before applying the migration.
|
|
2923
|
+
*/
|
|
2924
|
+
removeAttribute(name) {
|
|
2925
|
+
this.assertNotTouched(name, "remove_attribute");
|
|
2926
|
+
this.touchedAttributes.add(name);
|
|
2927
|
+
this.operations.push({
|
|
2928
|
+
type: "remove_attribute",
|
|
2929
|
+
name,
|
|
2930
|
+
backup_config: {}
|
|
2931
|
+
});
|
|
2932
|
+
return this;
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Add a new attribute.
|
|
2936
|
+
* The reverse operation will remove it (using the attribute definition as backup).
|
|
2937
|
+
*/
|
|
2938
|
+
addAttribute(attribute) {
|
|
2939
|
+
this.assertNotTouched(attribute.name, "add_attribute");
|
|
2940
|
+
this.touchedAttributes.add(attribute.name);
|
|
2941
|
+
this.operations.push({ type: "add_attribute", attribute });
|
|
2942
|
+
return this;
|
|
2943
|
+
}
|
|
2944
|
+
/**
|
|
2945
|
+
* Update the configuration of an attribute (partial patch).
|
|
2946
|
+
*
|
|
2947
|
+
* The `from` config is intentionally left empty — the sync engine will
|
|
2948
|
+
* populate it from current DB state before applying the migration.
|
|
2949
|
+
*/
|
|
2950
|
+
updateConfig(name, config) {
|
|
2951
|
+
this.assertNotTouched(name, "update_config");
|
|
2952
|
+
this.touchedAttributes.add(name);
|
|
2953
|
+
this.operations.push({ type: "update_config", name, from: {}, to: config });
|
|
2954
|
+
return this;
|
|
2955
|
+
}
|
|
2956
|
+
// --------------------------------------------------------------------------
|
|
2957
|
+
// BUILD
|
|
2958
|
+
// --------------------------------------------------------------------------
|
|
2959
|
+
/**
|
|
2960
|
+
* Produce the final MigrationDefinition with auto-generated reverse operations.
|
|
2961
|
+
*/
|
|
2962
|
+
build() {
|
|
2963
|
+
const reverse_operations = [...this.operations].reverse().map((op) => reverseOperation(op));
|
|
2964
|
+
return {
|
|
2965
|
+
version: this.version,
|
|
2966
|
+
operations: [...this.operations],
|
|
2967
|
+
reverse_operations
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
};
|
|
2971
|
+
|
|
2972
|
+
// src/builders/object-builder.ts
|
|
2837
2973
|
var ObjectBuilder = class {
|
|
2838
2974
|
constructor(config) {
|
|
2975
|
+
this._migrations = [];
|
|
2839
2976
|
this.validateName(config.name);
|
|
2840
2977
|
this.obj = {
|
|
2841
2978
|
name: config.name,
|
|
@@ -2932,6 +3069,37 @@ var ObjectBuilder = class {
|
|
|
2932
3069
|
this._labelExpression = template;
|
|
2933
3070
|
return this;
|
|
2934
3071
|
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Declare a schema migration for this object.
|
|
3074
|
+
*
|
|
3075
|
+
* - `version` must be >= 2 (version 1 is implicit — no migration needed).
|
|
3076
|
+
* - Versions must be declared in sequential order without gaps or duplicates.
|
|
3077
|
+
* - The callback receives a MigrationBuilder; call `.build()` is not required
|
|
3078
|
+
* (the ObjectBuilder calls it internally).
|
|
3079
|
+
*
|
|
3080
|
+
* @example
|
|
3081
|
+
* ```typescript
|
|
3082
|
+
* object({ name: "contacts", label: "Contact" })
|
|
3083
|
+
* .migration(2, (m) => m.renameAttribute("firstName", "first_name"))
|
|
3084
|
+
* .migration(3, (m) => m.changeType("age", "text", "number"))
|
|
3085
|
+
* .labelExpression("{{ first_name }}")
|
|
3086
|
+
* ```
|
|
3087
|
+
*/
|
|
3088
|
+
migration(version, callback) {
|
|
3089
|
+
if (version < 2) {
|
|
3090
|
+
throw new Error(
|
|
3091
|
+
`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${version}`
|
|
3092
|
+
);
|
|
3093
|
+
}
|
|
3094
|
+
const isDuplicate = this._migrations.some((m) => m.version === version);
|
|
3095
|
+
if (isDuplicate) {
|
|
3096
|
+
throw new Error(`[ObjectBuilder] Duplicate migration version: ${version}`);
|
|
3097
|
+
}
|
|
3098
|
+
const builder = new MigrationBuilder(version);
|
|
3099
|
+
callback(builder);
|
|
3100
|
+
this._migrations.push(builder.build());
|
|
3101
|
+
return this;
|
|
3102
|
+
}
|
|
2935
3103
|
/**
|
|
2936
3104
|
* Build the final ObjectDefinition
|
|
2937
3105
|
* @throws Error if required fields are missing or invalid
|
|
@@ -2951,10 +3119,22 @@ The labelExpression defines how records are displayed in lists and relations.
|
|
|
2951
3119
|
\u2705 Example: .labelExpression("{{ firstName }} {{ lastName }}")`
|
|
2952
3120
|
);
|
|
2953
3121
|
}
|
|
3122
|
+
const sortedVersions = [...this._migrations].sort((a, b) => a.version - b.version);
|
|
3123
|
+
for (let i = 0; i < sortedVersions.length; i++) {
|
|
3124
|
+
const expected = i + 2;
|
|
3125
|
+
if (sortedVersions[i].version !== expected) {
|
|
3126
|
+
throw new Error(
|
|
3127
|
+
`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${expected}, got ${sortedVersions[i].version}.`
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
const schema_version = sortedVersions.length > 0 ? sortedVersions[sortedVersions.length - 1].version : 1;
|
|
2954
3132
|
return {
|
|
2955
3133
|
...this.obj,
|
|
2956
3134
|
pluralLabel: this._pluralLabel,
|
|
2957
|
-
labelExpression: this._labelExpression
|
|
3135
|
+
labelExpression: this._labelExpression,
|
|
3136
|
+
schema_version,
|
|
3137
|
+
migrations: sortedVersions
|
|
2958
3138
|
};
|
|
2959
3139
|
}
|
|
2960
3140
|
/**
|
|
@@ -3622,6 +3802,7 @@ var TabBuilder = class {
|
|
|
3622
3802
|
};
|
|
3623
3803
|
var DetailViewBuilder = class {
|
|
3624
3804
|
constructor(name, label) {
|
|
3805
|
+
this._version = 1;
|
|
3625
3806
|
this.validateName(name);
|
|
3626
3807
|
this.data = {
|
|
3627
3808
|
name,
|
|
@@ -3683,6 +3864,17 @@ var DetailViewBuilder = class {
|
|
|
3683
3864
|
this.data.metadata = value;
|
|
3684
3865
|
return this;
|
|
3685
3866
|
}
|
|
3867
|
+
/**
|
|
3868
|
+
* Set the schema version for this view definition.
|
|
3869
|
+
* Increment when making breaking changes to force client updates.
|
|
3870
|
+
* @param v - Version number (must be >= 1)
|
|
3871
|
+
* @default 1
|
|
3872
|
+
*/
|
|
3873
|
+
version(v) {
|
|
3874
|
+
if (v < 1) throw new Error("View version must be >= 1");
|
|
3875
|
+
this._version = v;
|
|
3876
|
+
return this;
|
|
3877
|
+
}
|
|
3686
3878
|
/**
|
|
3687
3879
|
* Configure a side panel with flat attribute fields displayed alongside tab content.
|
|
3688
3880
|
* Not available for modal layout.
|
|
@@ -3755,7 +3947,8 @@ var DetailViewBuilder = class {
|
|
|
3755
3947
|
type: "detail",
|
|
3756
3948
|
config,
|
|
3757
3949
|
default: this.data.default,
|
|
3758
|
-
metadata: this.data.metadata
|
|
3950
|
+
metadata: this.data.metadata,
|
|
3951
|
+
schema_version: this._version
|
|
3759
3952
|
};
|
|
3760
3953
|
}
|
|
3761
3954
|
/**
|
|
@@ -3784,6 +3977,7 @@ function view(name, label) {
|
|
|
3784
3977
|
}
|
|
3785
3978
|
var ListViewBuilder = class {
|
|
3786
3979
|
constructor(name, label) {
|
|
3980
|
+
this._version = 1;
|
|
3787
3981
|
this.validateName(name);
|
|
3788
3982
|
this.data = {
|
|
3789
3983
|
name,
|
|
@@ -3827,6 +4021,17 @@ var ListViewBuilder = class {
|
|
|
3827
4021
|
this.data.metadata = value;
|
|
3828
4022
|
return this;
|
|
3829
4023
|
}
|
|
4024
|
+
/**
|
|
4025
|
+
* Set the schema version for this view definition.
|
|
4026
|
+
* Increment when making breaking changes to force client updates.
|
|
4027
|
+
* @param v - Version number (must be >= 1)
|
|
4028
|
+
* @default 1
|
|
4029
|
+
*/
|
|
4030
|
+
version(v) {
|
|
4031
|
+
if (v < 1) throw new Error("View version must be >= 1");
|
|
4032
|
+
this._version = v;
|
|
4033
|
+
return this;
|
|
4034
|
+
}
|
|
3830
4035
|
/**
|
|
3831
4036
|
* Set base filters applied to ALL tabs (scoping, tenant, etc.)
|
|
3832
4037
|
* @example .baseFilter({ combinator: "and", rules: [{ attribute: "tenant", operator: "is", value: "acme" }] })
|
|
@@ -3922,7 +4127,8 @@ var ListViewBuilder = class {
|
|
|
3922
4127
|
type: "list",
|
|
3923
4128
|
config,
|
|
3924
4129
|
default: this.data.default,
|
|
3925
|
-
metadata: this.data.metadata
|
|
4130
|
+
metadata: this.data.metadata,
|
|
4131
|
+
schema_version: this._version
|
|
3926
4132
|
};
|
|
3927
4133
|
}
|
|
3928
4134
|
/**
|
|
@@ -4264,14 +4470,42 @@ var WorkflowFormBuilder = class {
|
|
|
4264
4470
|
this.rows.push(row);
|
|
4265
4471
|
return this;
|
|
4266
4472
|
}
|
|
4473
|
+
/**
|
|
4474
|
+
* Add a relation list row to the form.
|
|
4475
|
+
* Renders an editable list of related records for a given slot and relation.
|
|
4476
|
+
*
|
|
4477
|
+
* @param id - Unique row identifier
|
|
4478
|
+
* @param slotId - The slot containing the relation
|
|
4479
|
+
* @param relationName - The relation attribute name
|
|
4480
|
+
* @param options - Display and preload options
|
|
4481
|
+
*/
|
|
4482
|
+
relationListField(id, slotId, relationName, options = {}) {
|
|
4483
|
+
this.rowOrder++;
|
|
4484
|
+
const row = {
|
|
4485
|
+
id,
|
|
4486
|
+
order: this.rowOrder,
|
|
4487
|
+
type: "relationList",
|
|
4488
|
+
slotId,
|
|
4489
|
+
relationName,
|
|
4490
|
+
preload: options.preload ?? true,
|
|
4491
|
+
columns: options.columns ?? [],
|
|
4492
|
+
qualifiersInline: options.qualifiersInline ?? true,
|
|
4493
|
+
modalFields: options.modalFields ?? "all",
|
|
4494
|
+
label: options.label
|
|
4495
|
+
};
|
|
4496
|
+
this.rows.push(row);
|
|
4497
|
+
return this;
|
|
4498
|
+
}
|
|
4267
4499
|
/**
|
|
4268
4500
|
* Set the next node and complete the form definition
|
|
4269
4501
|
*/
|
|
4270
4502
|
next(nodeId) {
|
|
4271
|
-
const hasFieldRows = this.rows.some(
|
|
4503
|
+
const hasFieldRows = this.rows.some(
|
|
4504
|
+
(r) => !r.type || r.type === "fields" || r.type === "relationList"
|
|
4505
|
+
);
|
|
4272
4506
|
if (!hasFieldRows) {
|
|
4273
4507
|
throw new Error(
|
|
4274
|
-
`[WorkflowBuilder] Form "${this.nodeId}" has no field rows. Use .row() to add fields.`
|
|
4508
|
+
`[WorkflowBuilder] Form "${this.nodeId}" has no field rows. Use .row() or .relationListField() to add fields.`
|
|
4275
4509
|
);
|
|
4276
4510
|
}
|
|
4277
4511
|
return this.workflowBuilder._addFormNode({
|
|
@@ -4482,52 +4716,48 @@ var WorkflowAssignBuilder = class {
|
|
|
4482
4716
|
var WorkflowAIBuilder = class {
|
|
4483
4717
|
/** @internal */
|
|
4484
4718
|
constructor(workflowBuilder, nodeId, label) {
|
|
4485
|
-
this.
|
|
4719
|
+
this.agentConfig = null;
|
|
4486
4720
|
this.workflowBuilder = workflowBuilder;
|
|
4487
4721
|
this.nodeId = nodeId;
|
|
4488
4722
|
this.label = label;
|
|
4489
4723
|
}
|
|
4490
|
-
/**
|
|
4491
|
-
* Set the description for this AI node
|
|
4492
|
-
*/
|
|
4493
4724
|
describe(description) {
|
|
4494
4725
|
this.nodeDescription = description;
|
|
4495
4726
|
return this;
|
|
4496
4727
|
}
|
|
4497
|
-
/**
|
|
4498
|
-
* Set a custom timeout (default: 120_000ms)
|
|
4499
|
-
*/
|
|
4500
4728
|
timeout(ms) {
|
|
4501
4729
|
this.nodeTimeoutMs = ms;
|
|
4502
4730
|
return this;
|
|
4503
4731
|
}
|
|
4504
4732
|
/**
|
|
4505
|
-
* Configure
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
}
|
|
4733
|
+
* Configure the agent for this node.
|
|
4734
|
+
*
|
|
4735
|
+
* @param definitionIdOrConfig - Either an existing agent definition ID (string),
|
|
4736
|
+
* or an inline agent config object.
|
|
4737
|
+
* @param options - Additional options merged on top (only used when first arg is a string)
|
|
4738
|
+
*/
|
|
4739
|
+
agent(definitionIdOrConfig, options) {
|
|
4740
|
+
if (typeof definitionIdOrConfig === "string") {
|
|
4741
|
+
this.agentConfig = {
|
|
4742
|
+
// Default to async when referencing a definition by ID
|
|
4743
|
+
mode: options?.mode ?? "async",
|
|
4744
|
+
definitionId: definitionIdOrConfig,
|
|
4745
|
+
instructions: options?.instructions,
|
|
4746
|
+
inputSlotIds: options?.inputSlotIds,
|
|
4747
|
+
targetSlotIds: options?.targetSlotIds
|
|
4748
|
+
};
|
|
4749
|
+
} else {
|
|
4750
|
+
this.agentConfig = definitionIdOrConfig;
|
|
4751
|
+
}
|
|
4522
4752
|
return this;
|
|
4523
4753
|
}
|
|
4524
4754
|
/**
|
|
4525
4755
|
* Set the next node and complete the AI node definition
|
|
4526
4756
|
*/
|
|
4527
4757
|
next(nodeId) {
|
|
4528
|
-
if (!this.
|
|
4758
|
+
if (!this.agentConfig) {
|
|
4529
4759
|
throw new Error(
|
|
4530
|
-
`[WorkflowBuilder] AI node "${this.nodeId}" must have an
|
|
4760
|
+
`[WorkflowBuilder] AI node "${this.nodeId}" must have an agent config. Call .agent() first.`
|
|
4531
4761
|
);
|
|
4532
4762
|
}
|
|
4533
4763
|
return this.workflowBuilder._addNode({
|
|
@@ -4535,9 +4765,9 @@ var WorkflowAIBuilder = class {
|
|
|
4535
4765
|
id: this.nodeId,
|
|
4536
4766
|
label: this.label,
|
|
4537
4767
|
description: this.nodeDescription,
|
|
4538
|
-
action: this.action,
|
|
4539
4768
|
timeoutMs: this.nodeTimeoutMs,
|
|
4540
|
-
next: nodeId
|
|
4769
|
+
next: nodeId,
|
|
4770
|
+
...this.agentConfig
|
|
4541
4771
|
});
|
|
4542
4772
|
}
|
|
4543
4773
|
};
|
|
@@ -4712,9 +4942,7 @@ var WorkflowBuilder = class {
|
|
|
4712
4942
|
assign(id, label, targetSlotId) {
|
|
4713
4943
|
return new WorkflowAssignBuilder(this, id, label, targetSlotId);
|
|
4714
4944
|
}
|
|
4715
|
-
/**
|
|
4716
|
-
* Define an AI node (run an AI action like document generation or code execution)
|
|
4717
|
-
*/
|
|
4945
|
+
/** Define an AI agent node (sync or async, inline or referenced from a definition) */
|
|
4718
4946
|
ai(id, label) {
|
|
4719
4947
|
return new WorkflowAIBuilder(this, id, label);
|
|
4720
4948
|
}
|
|
@@ -5809,7 +6037,8 @@ function generateDefaultDetailView(object2, options = {}) {
|
|
|
5809
6037
|
object: object2.name,
|
|
5810
6038
|
type: "detail",
|
|
5811
6039
|
config,
|
|
5812
|
-
default: true
|
|
6040
|
+
default: true,
|
|
6041
|
+
schema_version: 1
|
|
5813
6042
|
};
|
|
5814
6043
|
}
|
|
5815
6044
|
function generateDefaultListView(object2, options = {}) {
|
|
@@ -5834,7 +6063,8 @@ function generateDefaultListView(object2, options = {}) {
|
|
|
5834
6063
|
object: object2.name,
|
|
5835
6064
|
type: "list",
|
|
5836
6065
|
config,
|
|
5837
|
-
default: true
|
|
6066
|
+
default: true,
|
|
6067
|
+
schema_version: 1
|
|
5838
6068
|
};
|
|
5839
6069
|
}
|
|
5840
6070
|
function generateFallbackView(object2, type, options = {}) {
|
|
@@ -5999,7 +6229,6 @@ function isViewCustomized(view2, object2) {
|
|
|
5999
6229
|
return true;
|
|
6000
6230
|
}
|
|
6001
6231
|
export {
|
|
6002
|
-
AIActionConfigSchema,
|
|
6003
6232
|
AINodeSchema,
|
|
6004
6233
|
ALL_ACTIONS,
|
|
6005
6234
|
ALL_SYSTEM_RESOURCES,
|
|
@@ -6011,7 +6240,6 @@ export {
|
|
|
6011
6240
|
AttributeNotFoundError,
|
|
6012
6241
|
AuthMethodSchema,
|
|
6013
6242
|
BEHAVIOR_PROPERTIES,
|
|
6014
|
-
CodeExecutionActionSchema,
|
|
6015
6243
|
ConcurrentModificationError,
|
|
6016
6244
|
ConditionGroupSchema,
|
|
6017
6245
|
ConditionNodeSchema,
|
|
@@ -6020,6 +6248,7 @@ export {
|
|
|
6020
6248
|
CreateShareInputSchema,
|
|
6021
6249
|
CustomTabConfig,
|
|
6022
6250
|
DEFAULT_LABEL_FALLBACK,
|
|
6251
|
+
DEFAULT_RETENTION_POLICY,
|
|
6023
6252
|
DEFAULT_ROLES,
|
|
6024
6253
|
DEFAULT_ROLE_DESCRIPTIONS,
|
|
6025
6254
|
DEFAULT_ROLE_FOR_NEW_USERS,
|
|
@@ -6028,7 +6257,6 @@ export {
|
|
|
6028
6257
|
DEFAULT_THEME,
|
|
6029
6258
|
DEFAULT_VALIDATION_MESSAGES,
|
|
6030
6259
|
DetailViewBuilder,
|
|
6031
|
-
DocumentGenerationActionSchema,
|
|
6032
6260
|
DocumentsTabConfig,
|
|
6033
6261
|
DuplicateError,
|
|
6034
6262
|
EMPTY_VALUE_PLACEHOLDER,
|
|
@@ -6212,6 +6440,7 @@ export {
|
|
|
6212
6440
|
isFlowDefinition,
|
|
6213
6441
|
isFlowFieldsRow,
|
|
6214
6442
|
isFlowPublished,
|
|
6443
|
+
isFlowRelationListRow,
|
|
6215
6444
|
isFlowsTab,
|
|
6216
6445
|
isForbiddenError,
|
|
6217
6446
|
isFormFieldsRow,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export {
|
|
2
|
+
export { aS as DEFAULT_VALIDATION_MESSAGES, c6 as ValidationMessages, c7 as ValidationResult, ce as attributeConfigSchemas, cg as checkboxConfigSchema, ch as computeRecordStatus, ci as createAttributeValidator, cj as createCheckboxValidator, ck as createCurrencyValidator, cl as createDateValidator, cm as createDraftValidator, co as createFileValidator, cp as createFormAttributeValidator, cq as createFormulaValidator, cr as createLocationValidator, cs as createMultiRelationValidator, ct as createMultiselectValidator, cu as createNumberValidator, cv as createObjectValidator, cw as createPhoneValidator, cx as createRatingValidator, cy as createRelationValidator, cz as createRichtextValidator, cA as createRollupValidator, cB as createSelectValidator, cC as createSingleRelationValidator, cE as createStatusValidator, cF as createTextAreaValidator, cG as createTextValidator, cH as createUserValidator, cI as currencyConfigSchema, cJ as dateConfigSchema, cK as documentConfigSchema, cM as fileConfigSchema, cN as formatZodErrors, cO as formulaConfigSchema, cQ as getAttributeConfigSchema, cS as getMissingRequiredAttributes, dp as isRecordComplete, dC as locationConfigSchema, dE as multiselectConfigSchema, dG as numberConfigSchema, dI as parseAttributeConfig, dJ as phoneConfigSchema, dK as ratingConfigSchema, dL as relationConfigSchema, dM as richtextConfigSchema, dN as rollupConfigSchema, dO as safeParseAttributeConfig, dP as selectConfigSchema, dR as statusConfigSchema, dS as textConfigSchema, dT as textareaConfigSchema, dU as userConfigSchema, dV as validateAttribute, dW as validateAttributeConfig, dX as validateDraft, dY as validateDraftOrThrow, dZ as validateObject, d_ as validateObjectOrThrow } from '../validators-BCw4Sn01.mjs';
|
|
3
3
|
import '@stndrds/constants';
|
|
4
4
|
import '../utils.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export {
|
|
2
|
+
export { aS as DEFAULT_VALIDATION_MESSAGES, c6 as ValidationMessages, c7 as ValidationResult, ce as attributeConfigSchemas, cg as checkboxConfigSchema, ch as computeRecordStatus, ci as createAttributeValidator, cj as createCheckboxValidator, ck as createCurrencyValidator, cl as createDateValidator, cm as createDraftValidator, co as createFileValidator, cp as createFormAttributeValidator, cq as createFormulaValidator, cr as createLocationValidator, cs as createMultiRelationValidator, ct as createMultiselectValidator, cu as createNumberValidator, cv as createObjectValidator, cw as createPhoneValidator, cx as createRatingValidator, cy as createRelationValidator, cz as createRichtextValidator, cA as createRollupValidator, cB as createSelectValidator, cC as createSingleRelationValidator, cE as createStatusValidator, cF as createTextAreaValidator, cG as createTextValidator, cH as createUserValidator, cI as currencyConfigSchema, cJ as dateConfigSchema, cK as documentConfigSchema, cM as fileConfigSchema, cN as formatZodErrors, cO as formulaConfigSchema, cQ as getAttributeConfigSchema, cS as getMissingRequiredAttributes, dp as isRecordComplete, dC as locationConfigSchema, dE as multiselectConfigSchema, dG as numberConfigSchema, dI as parseAttributeConfig, dJ as phoneConfigSchema, dK as ratingConfigSchema, dL as relationConfigSchema, dM as richtextConfigSchema, dN as rollupConfigSchema, dO as safeParseAttributeConfig, dP as selectConfigSchema, dR as statusConfigSchema, dS as textConfigSchema, dT as textareaConfigSchema, dU as userConfigSchema, dV as validateAttribute, dW as validateAttributeConfig, dX as validateDraft, dY as validateDraftOrThrow, dZ as validateObject, d_ as validateObjectOrThrow } from '../validators-5XMwJOlV.js';
|
|
3
3
|
import '@stndrds/constants';
|
|
4
4
|
import '../utils.js';
|