@turbofy-ai/app-runtime 0.0.19 → 0.0.20
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/src/dsl.d.ts +53 -33
- package/dist/src/dsl.js +332 -92
- package/dist/src/lib/preview-auth.d.ts +1 -0
- package/package.json +1 -1
package/dist/src/dsl.d.ts
CHANGED
|
@@ -826,6 +826,34 @@ export interface IPageMetaDictionary {
|
|
|
826
826
|
"twitter:url"?: string;
|
|
827
827
|
[key: string]: LocalizationValue | undefined;
|
|
828
828
|
}
|
|
829
|
+
export interface IBranchParams {
|
|
830
|
+
branches: {
|
|
831
|
+
[k: string]: boolean;
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
export interface IBranchResult {
|
|
835
|
+
matchedSteps: string[];
|
|
836
|
+
}
|
|
837
|
+
export interface IForEachParams {
|
|
838
|
+
/**
|
|
839
|
+
* @maxItems 10000
|
|
840
|
+
*/
|
|
841
|
+
items: unknown[];
|
|
842
|
+
bodyStep: string | null;
|
|
843
|
+
}
|
|
844
|
+
export type IForEachResult = {
|
|
845
|
+
/**
|
|
846
|
+
* @maxItems 10000
|
|
847
|
+
*/
|
|
848
|
+
items: unknown[];
|
|
849
|
+
/**
|
|
850
|
+
* @maxItems 10000
|
|
851
|
+
*/
|
|
852
|
+
result?: unknown[];
|
|
853
|
+
} | {
|
|
854
|
+
item: unknown;
|
|
855
|
+
index: number;
|
|
856
|
+
};
|
|
829
857
|
export interface IBatchCreateTypeParams {
|
|
830
858
|
ofType: string;
|
|
831
859
|
namespace: string;
|
|
@@ -1138,31 +1166,6 @@ export interface INotifyWebSocketParams {
|
|
|
1138
1166
|
export interface INotifyWebSocketResult {
|
|
1139
1167
|
[k: string]: unknown;
|
|
1140
1168
|
}
|
|
1141
|
-
export type IOpenAIImageGenerationParams = {
|
|
1142
|
-
model: "dall-e-3";
|
|
1143
|
-
prompt: string;
|
|
1144
|
-
quality?: "standard" | "hd";
|
|
1145
|
-
size?: "1024x1024" | "1792x1024" | "1024x1792";
|
|
1146
|
-
style?: "vivid" | "natural";
|
|
1147
|
-
outputFilename?: string;
|
|
1148
|
-
apiKey?: string;
|
|
1149
|
-
} | {
|
|
1150
|
-
model: "dall-e-2";
|
|
1151
|
-
prompt: string;
|
|
1152
|
-
size?: "256x256" | "512x512" | "1024x1024";
|
|
1153
|
-
n?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
1154
|
-
outputFilename?: string;
|
|
1155
|
-
apiKey?: string;
|
|
1156
|
-
};
|
|
1157
|
-
export type IOpenAIImageGenerationResult = {
|
|
1158
|
-
type: "result";
|
|
1159
|
-
url: string;
|
|
1160
|
-
key: string;
|
|
1161
|
-
mimeType: string;
|
|
1162
|
-
} | {
|
|
1163
|
-
type: "error";
|
|
1164
|
-
value: string;
|
|
1165
|
-
};
|
|
1166
1169
|
export interface ITypeParams {
|
|
1167
1170
|
id: string;
|
|
1168
1171
|
ofType: string;
|
|
@@ -1694,6 +1697,8 @@ export interface IStripeSyncResult {
|
|
|
1694
1697
|
recordId?: string;
|
|
1695
1698
|
}
|
|
1696
1699
|
export type IStepParamsMap = {
|
|
1700
|
+
branch: IBranchParams;
|
|
1701
|
+
forEach: IForEachParams;
|
|
1697
1702
|
batchCreateType: IBatchCreateTypeParams;
|
|
1698
1703
|
batchGetType: IBatchGetTypeParams;
|
|
1699
1704
|
createType: ICreateTypeParams;
|
|
@@ -1707,7 +1712,6 @@ export type IStepParamsMap = {
|
|
|
1707
1712
|
listTypeByParent: IListTypeByParentParams;
|
|
1708
1713
|
listType: IListTypeParams;
|
|
1709
1714
|
notifyWebSocket: INotifyWebSocketParams;
|
|
1710
|
-
openAIImageGeneration: IOpenAIImageGenerationParams;
|
|
1711
1715
|
type: ITypeParams;
|
|
1712
1716
|
updateType: IUpdateTypeParams;
|
|
1713
1717
|
extractImageMetadata: IExtractImageMetadataParams;
|
|
@@ -1716,6 +1720,8 @@ export type IStepParamsMap = {
|
|
|
1716
1720
|
stripeSync: IStripeSyncParams;
|
|
1717
1721
|
};
|
|
1718
1722
|
export type IStepResultMap = {
|
|
1723
|
+
branch: IBranchResult;
|
|
1724
|
+
forEach: IForEachResult;
|
|
1719
1725
|
batchCreateType: IBatchCreateTypeResult;
|
|
1720
1726
|
batchGetType: IBatchGetTypeResult;
|
|
1721
1727
|
createType: ICreateTypeResult;
|
|
@@ -1729,7 +1735,6 @@ export type IStepResultMap = {
|
|
|
1729
1735
|
listTypeByParent: IListTypeByParentResult;
|
|
1730
1736
|
listType: IListTypeResult;
|
|
1731
1737
|
notifyWebSocket: INotifyWebSocketResult;
|
|
1732
|
-
openAIImageGeneration: IOpenAIImageGenerationResult;
|
|
1733
1738
|
type: ITypeResult;
|
|
1734
1739
|
updateType: IUpdateTypeResult;
|
|
1735
1740
|
extractImageMetadata: IExtractImageMetadataResult;
|
|
@@ -1738,6 +1743,8 @@ export type IStepResultMap = {
|
|
|
1738
1743
|
stripeSync: IStripeSyncResult;
|
|
1739
1744
|
};
|
|
1740
1745
|
declare enum StepType {
|
|
1746
|
+
branch = "branch",
|
|
1747
|
+
forEach = "forEach",
|
|
1741
1748
|
batchCreateType = "batchCreateType",
|
|
1742
1749
|
batchGetType = "batchGetType",
|
|
1743
1750
|
createType = "createType",
|
|
@@ -1751,7 +1758,6 @@ declare enum StepType {
|
|
|
1751
1758
|
listTypeByParent = "listTypeByParent",
|
|
1752
1759
|
listType = "listType",
|
|
1753
1760
|
notifyWebSocket = "notifyWebSocket",
|
|
1754
|
-
openAIImageGeneration = "openAIImageGeneration",
|
|
1755
1761
|
type = "type",
|
|
1756
1762
|
updateType = "updateType",
|
|
1757
1763
|
extractImageMetadata = "extractImageMetadata",
|
|
@@ -2274,11 +2280,24 @@ export interface IFlowStepDefinition<T extends StepType = StepType> {
|
|
|
2274
2280
|
type: T;
|
|
2275
2281
|
description?: string;
|
|
2276
2282
|
params: Record<string, unknown>;
|
|
2283
|
+
branches?: IFlowBranchDefinition[];
|
|
2284
|
+
steps?: IFlowStepDefinition[];
|
|
2277
2285
|
next?: string | null;
|
|
2278
2286
|
skipIf?: string;
|
|
2279
2287
|
continueIf?: string;
|
|
2280
2288
|
passThroughCondition?: string;
|
|
2281
2289
|
}
|
|
2290
|
+
export interface IFlowBranchDefinition {
|
|
2291
|
+
when: DeepParam<boolean>;
|
|
2292
|
+
steps: IFlowStepDefinition[];
|
|
2293
|
+
}
|
|
2294
|
+
export interface IFlowBranchOptions extends Omit<IFlowStepOptions<StepType.branch>, "params" | "next"> {
|
|
2295
|
+
branches: IFlowBranchDefinition[];
|
|
2296
|
+
}
|
|
2297
|
+
export interface IFlowForEachOptions extends Omit<IFlowStepOptions<StepType.forEach>, "params"> {
|
|
2298
|
+
items: DeepParam<unknown[]>;
|
|
2299
|
+
steps: IFlowStepDefinition[];
|
|
2300
|
+
}
|
|
2282
2301
|
declare const step: {
|
|
2283
2302
|
batchCreateType: (name: string, opts: IFlowStepOptions<StepType.batchCreateType>) => IFlowStepDefinition<StepType.batchCreateType>;
|
|
2284
2303
|
batchGetType: (name: string, opts: IFlowStepOptions<StepType.batchGetType>) => IFlowStepDefinition<StepType.batchGetType>;
|
|
@@ -2293,13 +2312,14 @@ declare const step: {
|
|
|
2293
2312
|
listTypeByParent: (name: string, opts: IFlowStepOptions<StepType.listTypeByParent>) => IFlowStepDefinition<StepType.listTypeByParent>;
|
|
2294
2313
|
listType: (name: string, opts: IFlowStepOptions<StepType.listType>) => IFlowStepDefinition<StepType.listType>;
|
|
2295
2314
|
notifyWebSocket: (name: string, opts: IFlowStepOptions<StepType.notifyWebSocket>) => IFlowStepDefinition<StepType.notifyWebSocket>;
|
|
2296
|
-
openAIImageGeneration: (name: string, opts: IFlowStepOptions<StepType.openAIImageGeneration>) => IFlowStepDefinition<StepType.openAIImageGeneration>;
|
|
2297
2315
|
type: (name: string, opts: IFlowStepOptions<StepType.type>) => IFlowStepDefinition<StepType.type>;
|
|
2298
2316
|
updateType: (name: string, opts: IFlowStepOptions<StepType.updateType>) => IFlowStepDefinition<StepType.updateType>;
|
|
2299
2317
|
extractImageMetadata: (name: string, opts: IFlowStepOptions<StepType.extractImageMetadata>) => IFlowStepDefinition<StepType.extractImageMetadata>;
|
|
2300
2318
|
cloudFunction: (name: string, opts: IFlowStepOptions<StepType.cloudFunction>) => IFlowStepDefinition<StepType.cloudFunction>;
|
|
2301
2319
|
genericAI: (name: string, opts: IFlowStepOptions<StepType.genericAI>) => IFlowStepDefinition<StepType.genericAI>;
|
|
2302
2320
|
stripeSync: (name: string, opts: IFlowStepOptions<StepType.stripeSync>) => IFlowStepDefinition<StepType.stripeSync>;
|
|
2321
|
+
forEach(name: string, opts: IFlowForEachOptions): IFlowStepDefinition<StepType.forEach>;
|
|
2322
|
+
branch(name: string, opts: IFlowBranchOptions): IFlowStepDefinition<StepType.branch>;
|
|
2303
2323
|
};
|
|
2304
2324
|
export interface IFlowOptions {
|
|
2305
2325
|
/** Flow record name — stored next to the declaration, not inside it. */
|
|
@@ -2308,8 +2328,8 @@ export interface IFlowOptions {
|
|
|
2308
2328
|
/** Executed in order; each step's nextStep defaults to the next entry. */
|
|
2309
2329
|
steps: IFlowStepDefinition[];
|
|
2310
2330
|
/**
|
|
2311
|
-
*
|
|
2312
|
-
*
|
|
2331
|
+
* Unconnected steps preserved on pull/push (each needs an explicit `next`).
|
|
2332
|
+
* Branch paths belong in the branch step's nested `branches` sequences.
|
|
2313
2333
|
*/
|
|
2314
2334
|
detachedSteps?: IFlowStepDefinition[];
|
|
2315
2335
|
debug?: boolean;
|
|
@@ -2354,7 +2374,7 @@ export interface IValidateFlowContext {
|
|
|
2354
2374
|
*/
|
|
2355
2375
|
export declare function collectSecretIds(declaration: INonGenericIFlowDeclaration): string[];
|
|
2356
2376
|
/**
|
|
2357
|
-
* Validates a single flow declaration:
|
|
2377
|
+
* Validates a single flow declaration: step graph integrity, param
|
|
2358
2378
|
* shapes, secret hygiene, and self-retriggering write steps.
|
|
2359
2379
|
*/
|
|
2360
2380
|
export declare function validateFlow(declaration: INonGenericIFlowDeclaration, ctx?: IValidateFlowContext): IFlowValidationResult;
|
|
@@ -2378,7 +2398,7 @@ export interface IValidateFlowsOptions {
|
|
|
2378
2398
|
export declare function validateFlows(flows: IValidatableFlow[], opts?: IValidateFlowsOptions): IFlowValidationResult;
|
|
2379
2399
|
|
|
2380
2400
|
declare namespace flowBuilder {
|
|
2381
|
-
export { IFlowOptions, IFlowOutput, IFlowStepDefinition, IFlowStepOptions, IFlowTriggerDefinition, IScheduleTriggerOptions, ISharedTriggerOptions, IStepParamsInput, ITableDataChangeTriggerOptions, TABLE_ID_PARAM_NAMES, buildFlow, js, secret, step, trigger };
|
|
2401
|
+
export { IFlowBranchDefinition, IFlowBranchOptions, IFlowForEachOptions, IFlowOptions, IFlowOutput, IFlowStepDefinition, IFlowStepOptions, IFlowTriggerDefinition, IScheduleTriggerOptions, ISharedTriggerOptions, IStepParamsInput, ITableDataChangeTriggerOptions, TABLE_ID_PARAM_NAMES, buildFlow, js, secret, step, trigger };
|
|
2382
2402
|
}
|
|
2383
2403
|
declare namespace dataBuilder {
|
|
2384
2404
|
export { TableDef, TableOpts, TableSearchConfig, build, enumType, fields, table };
|
package/dist/src/dsl.js
CHANGED
|
@@ -15028,6 +15028,36 @@ function build(schema) {
|
|
|
15028
15028
|
return finalSchema;
|
|
15029
15029
|
}
|
|
15030
15030
|
|
|
15031
|
+
// ../declarations/src/flows/schemas/branch.schema.ts
|
|
15032
|
+
var branchSchema = {
|
|
15033
|
+
params: external_exports.object({
|
|
15034
|
+
branches: external_exports.record(external_exports.string().min(1), external_exports.boolean())
|
|
15035
|
+
}),
|
|
15036
|
+
result: external_exports.object({
|
|
15037
|
+
matchedSteps: external_exports.array(external_exports.string())
|
|
15038
|
+
})
|
|
15039
|
+
};
|
|
15040
|
+
|
|
15041
|
+
// ../declarations/src/flows/schemas/for-each.schema.ts
|
|
15042
|
+
var MAX_FLOW_ITERATIONS = 1e4;
|
|
15043
|
+
var itemsSchema = external_exports.array(external_exports.unknown()).max(
|
|
15044
|
+
MAX_FLOW_ITERATIONS,
|
|
15045
|
+
`For-each supports at most ${MAX_FLOW_ITERATIONS} items`
|
|
15046
|
+
);
|
|
15047
|
+
var forEachSchema = {
|
|
15048
|
+
params: external_exports.object({
|
|
15049
|
+
items: itemsSchema,
|
|
15050
|
+
bodyStep: external_exports.string().min(1).nullable()
|
|
15051
|
+
}),
|
|
15052
|
+
result: external_exports.union([
|
|
15053
|
+
external_exports.object({
|
|
15054
|
+
items: itemsSchema,
|
|
15055
|
+
result: itemsSchema.optional()
|
|
15056
|
+
}),
|
|
15057
|
+
external_exports.object({ item: external_exports.unknown(), index: external_exports.number().int().nonnegative() })
|
|
15058
|
+
])
|
|
15059
|
+
};
|
|
15060
|
+
|
|
15031
15061
|
// ../declarations/src/flows/schemas/stripe-sync.schema.ts
|
|
15032
15062
|
var field = external_exports.string().min(1).optional();
|
|
15033
15063
|
var destination = external_exports.object({
|
|
@@ -15911,52 +15941,14 @@ var notifyWebSocketSchema = {
|
|
|
15911
15941
|
result: resultSchema16
|
|
15912
15942
|
};
|
|
15913
15943
|
|
|
15914
|
-
// ../declarations/src/flows/schemas/openai-image-generation.schema.ts
|
|
15915
|
-
var dallE3ParamsSchema = external_exports.object({
|
|
15916
|
-
model: external_exports.literal("dall-e-3"),
|
|
15917
|
-
prompt: external_exports.string(),
|
|
15918
|
-
quality: external_exports.enum(["standard", "hd"]).optional(),
|
|
15919
|
-
size: external_exports.enum(["1024x1024", "1792x1024", "1024x1792"]).optional(),
|
|
15920
|
-
style: external_exports.enum(["vivid", "natural"]).optional(),
|
|
15921
|
-
outputFilename: external_exports.string().optional(),
|
|
15922
|
-
apiKey: external_exports.string().optional()
|
|
15923
|
-
});
|
|
15924
|
-
var dallE2ParamsSchema = external_exports.object({
|
|
15925
|
-
model: external_exports.literal("dall-e-2"),
|
|
15926
|
-
prompt: external_exports.string(),
|
|
15927
|
-
size: external_exports.enum(["256x256", "512x512", "1024x1024"]).optional(),
|
|
15928
|
-
n: external_exports.literal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).optional(),
|
|
15929
|
-
outputFilename: external_exports.string().optional(),
|
|
15930
|
-
apiKey: external_exports.string().optional()
|
|
15931
|
-
});
|
|
15932
|
-
var paramsSchema17 = external_exports.discriminatedUnion("model", [
|
|
15933
|
-
dallE3ParamsSchema,
|
|
15934
|
-
dallE2ParamsSchema
|
|
15935
|
-
]);
|
|
15936
|
-
var resultSuccessSchema = external_exports.object({
|
|
15937
|
-
type: external_exports.literal("result"),
|
|
15938
|
-
url: external_exports.string(),
|
|
15939
|
-
key: external_exports.string(),
|
|
15940
|
-
mimeType: external_exports.string()
|
|
15941
|
-
});
|
|
15942
|
-
var resultErrorSchema = external_exports.object({
|
|
15943
|
-
type: external_exports.literal("error"),
|
|
15944
|
-
value: external_exports.string()
|
|
15945
|
-
});
|
|
15946
|
-
var resultSchema17 = external_exports.union([resultSuccessSchema, resultErrorSchema]);
|
|
15947
|
-
var openAIImageGenerationSchema = {
|
|
15948
|
-
params: paramsSchema17,
|
|
15949
|
-
result: resultSchema17
|
|
15950
|
-
};
|
|
15951
|
-
|
|
15952
15944
|
// ../declarations/src/flows/schemas/type.schema.ts
|
|
15953
|
-
var
|
|
15945
|
+
var paramsSchema17 = external_exports.object({
|
|
15954
15946
|
id: external_exports.string(),
|
|
15955
15947
|
ofType: external_exports.string(),
|
|
15956
15948
|
namespace: external_exports.string().optional(),
|
|
15957
15949
|
dynamicArgs: external_exports.looseObject({}).optional()
|
|
15958
15950
|
});
|
|
15959
|
-
var
|
|
15951
|
+
var resultSchema17 = external_exports.object({
|
|
15960
15952
|
id: external_exports.string(),
|
|
15961
15953
|
createdAt: external_exports.string(),
|
|
15962
15954
|
updatedAt: external_exports.string(),
|
|
@@ -15966,12 +15958,12 @@ var resultSchema18 = external_exports.object({
|
|
|
15966
15958
|
directives: external_exports.array(external_exports.string())
|
|
15967
15959
|
});
|
|
15968
15960
|
var typeSchema = {
|
|
15969
|
-
params:
|
|
15970
|
-
result:
|
|
15961
|
+
params: paramsSchema17,
|
|
15962
|
+
result: resultSchema17
|
|
15971
15963
|
};
|
|
15972
15964
|
|
|
15973
15965
|
// ../declarations/src/flows/schemas/update-type.schema.ts
|
|
15974
|
-
var
|
|
15966
|
+
var paramsSchema18 = external_exports.object({
|
|
15975
15967
|
id: external_exports.string(),
|
|
15976
15968
|
ofType: external_exports.string(),
|
|
15977
15969
|
fields: external_exports.looseObject({}).optional(),
|
|
@@ -15980,7 +15972,7 @@ var paramsSchema19 = external_exports.object({
|
|
|
15980
15972
|
directives: external_exports.array(external_exports.string()).optional(),
|
|
15981
15973
|
dynamicArgs: external_exports.looseObject({}).optional()
|
|
15982
15974
|
});
|
|
15983
|
-
var
|
|
15975
|
+
var resultSchema18 = external_exports.object({
|
|
15984
15976
|
id: external_exports.string(),
|
|
15985
15977
|
createdAt: external_exports.string(),
|
|
15986
15978
|
updatedAt: external_exports.string(),
|
|
@@ -15989,12 +15981,14 @@ var resultSchema19 = external_exports.object({
|
|
|
15989
15981
|
namespace: external_exports.string()
|
|
15990
15982
|
});
|
|
15991
15983
|
var updateTypeSchema = {
|
|
15992
|
-
params:
|
|
15993
|
-
result:
|
|
15984
|
+
params: paramsSchema18,
|
|
15985
|
+
result: resultSchema18
|
|
15994
15986
|
};
|
|
15995
15987
|
|
|
15996
15988
|
// ../declarations/src/flows/schemas/index.ts
|
|
15997
15989
|
var schemas = {
|
|
15990
|
+
branch: branchSchema,
|
|
15991
|
+
forEach: forEachSchema,
|
|
15998
15992
|
batchCreateType: batchCreateTypeSchema,
|
|
15999
15993
|
batchGetType: batchGetTypeSchema,
|
|
16000
15994
|
createType: createTypeSchema,
|
|
@@ -16008,7 +16002,6 @@ var schemas = {
|
|
|
16008
16002
|
listTypeByParent: listTypeByParentSchema,
|
|
16009
16003
|
listType: listTypeSchema,
|
|
16010
16004
|
notifyWebSocket: notifyWebSocketSchema,
|
|
16011
|
-
openAIImageGeneration: openAIImageGenerationSchema,
|
|
16012
16005
|
type: typeSchema,
|
|
16013
16006
|
updateType: updateTypeSchema,
|
|
16014
16007
|
extractImageMetadata: extractImageMetadataSchema,
|
|
@@ -16163,6 +16156,124 @@ var webhookConfigSchema = external_exports.object({
|
|
|
16163
16156
|
}
|
|
16164
16157
|
});
|
|
16165
16158
|
|
|
16159
|
+
// ../declarations/src/flows/branch.ts
|
|
16160
|
+
var getBranchTargets = (step2) => {
|
|
16161
|
+
if (step2.type !== "branch" /* branch */) return [];
|
|
16162
|
+
const branches = step2.params.branches;
|
|
16163
|
+
if (!branches || typeof branches !== "object" || Array.isArray(branches)) {
|
|
16164
|
+
return [];
|
|
16165
|
+
}
|
|
16166
|
+
return Object.keys(branches);
|
|
16167
|
+
};
|
|
16168
|
+
var getForEachBodyTarget = (step2) => step2.type === "forEach" /* forEach */ && typeof step2.params.bodyStep === "string" ? step2.params.bodyStep : null;
|
|
16169
|
+
var getFlowStepTargets = (step2) => {
|
|
16170
|
+
if (step2.type === "branch" /* branch */) return getBranchTargets(step2);
|
|
16171
|
+
if (step2.type === "forEach" /* forEach */) {
|
|
16172
|
+
const body = getForEachBodyTarget(step2);
|
|
16173
|
+
return [body, step2.nextStep].filter(
|
|
16174
|
+
(target) => target !== null
|
|
16175
|
+
);
|
|
16176
|
+
}
|
|
16177
|
+
return step2.nextStep === null ? [] : [step2.nextStep];
|
|
16178
|
+
};
|
|
16179
|
+
var getBranchOwnershipErrors = (declaration) => {
|
|
16180
|
+
const owners = /* @__PURE__ */ new Map();
|
|
16181
|
+
const errors = [];
|
|
16182
|
+
const visit = (name, scope) => {
|
|
16183
|
+
const step2 = declaration.steps[name];
|
|
16184
|
+
if (!Object.hasOwn(declaration.steps, name)) return;
|
|
16185
|
+
const owner = JSON.stringify(scope);
|
|
16186
|
+
const previousOwner = owners.get(name);
|
|
16187
|
+
if (previousOwner !== void 0) {
|
|
16188
|
+
if (previousOwner !== owner) {
|
|
16189
|
+
errors.push({
|
|
16190
|
+
stepName: name,
|
|
16191
|
+
message: `Step "${name}" is reached from different branch paths; each step must belong to a single path`
|
|
16192
|
+
});
|
|
16193
|
+
}
|
|
16194
|
+
return;
|
|
16195
|
+
}
|
|
16196
|
+
owners.set(name, owner);
|
|
16197
|
+
if (step2.type === "forEach" /* forEach */) {
|
|
16198
|
+
const body = getForEachBodyTarget(step2);
|
|
16199
|
+
if (body !== null) visit(body, [...scope, name, body]);
|
|
16200
|
+
if (step2.nextStep !== null) visit(step2.nextStep, scope);
|
|
16201
|
+
return;
|
|
16202
|
+
}
|
|
16203
|
+
for (const target of getFlowStepTargets(step2)) {
|
|
16204
|
+
visit(
|
|
16205
|
+
target,
|
|
16206
|
+
step2.type === "branch" /* branch */ ? [...scope, name, target] : scope
|
|
16207
|
+
);
|
|
16208
|
+
}
|
|
16209
|
+
};
|
|
16210
|
+
if (declaration.startStep) visit(declaration.startStep, []);
|
|
16211
|
+
const names = Object.keys(declaration.steps);
|
|
16212
|
+
const targets = new Set(
|
|
16213
|
+
Object.values(declaration.steps).flatMap(getFlowStepTargets)
|
|
16214
|
+
);
|
|
16215
|
+
for (const name of [
|
|
16216
|
+
...names.filter((name2) => !targets.has(name2)),
|
|
16217
|
+
...names
|
|
16218
|
+
]) {
|
|
16219
|
+
if (!owners.has(name)) visit(name, []);
|
|
16220
|
+
}
|
|
16221
|
+
return errors;
|
|
16222
|
+
};
|
|
16223
|
+
var getFlowReferenceErrors = (declaration) => {
|
|
16224
|
+
const errors = [];
|
|
16225
|
+
if (declaration.startStep && !Object.hasOwn(declaration.steps, declaration.startStep)) {
|
|
16226
|
+
errors.push({
|
|
16227
|
+
stepName: declaration.startStep,
|
|
16228
|
+
message: `Unknown start step "${declaration.startStep}"`
|
|
16229
|
+
});
|
|
16230
|
+
}
|
|
16231
|
+
for (const [name, step2] of Object.entries(declaration.steps)) {
|
|
16232
|
+
if (step2.type === "branch" /* branch */ && step2.nextStep !== null) {
|
|
16233
|
+
errors.push({
|
|
16234
|
+
stepName: name,
|
|
16235
|
+
message: `Branch "${name}" must have nextStep: null`
|
|
16236
|
+
});
|
|
16237
|
+
}
|
|
16238
|
+
for (const target of getFlowStepTargets(step2)) {
|
|
16239
|
+
if (!Object.hasOwn(declaration.steps, target)) {
|
|
16240
|
+
errors.push({
|
|
16241
|
+
stepName: name,
|
|
16242
|
+
message: `Step "${name}" points to unknown step "${target}"`
|
|
16243
|
+
});
|
|
16244
|
+
}
|
|
16245
|
+
}
|
|
16246
|
+
}
|
|
16247
|
+
return errors;
|
|
16248
|
+
};
|
|
16249
|
+
var getFlowCycleErrors = (declaration) => {
|
|
16250
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
16251
|
+
const visited = /* @__PURE__ */ new Set();
|
|
16252
|
+
const errors = [];
|
|
16253
|
+
const visit = (name) => {
|
|
16254
|
+
if (visiting.has(name)) {
|
|
16255
|
+
errors.push({
|
|
16256
|
+
stepName: name,
|
|
16257
|
+
message: `Flow contains a cycle at step "${name}"`
|
|
16258
|
+
});
|
|
16259
|
+
return;
|
|
16260
|
+
}
|
|
16261
|
+
if (visited.has(name) || !Object.hasOwn(declaration.steps, name)) return;
|
|
16262
|
+
visiting.add(name);
|
|
16263
|
+
for (const target of getFlowStepTargets(declaration.steps[name]))
|
|
16264
|
+
visit(target);
|
|
16265
|
+
visiting.delete(name);
|
|
16266
|
+
visited.add(name);
|
|
16267
|
+
};
|
|
16268
|
+
for (const name of Object.keys(declaration.steps)) visit(name);
|
|
16269
|
+
return errors;
|
|
16270
|
+
};
|
|
16271
|
+
var getFlowGraphErrors = (declaration) => [
|
|
16272
|
+
...getFlowReferenceErrors(declaration),
|
|
16273
|
+
...getFlowCycleErrors(declaration),
|
|
16274
|
+
...getBranchOwnershipErrors(declaration)
|
|
16275
|
+
];
|
|
16276
|
+
|
|
16166
16277
|
// .tmp/declarations.ts
|
|
16167
16278
|
var PAGE_VISIBILITY = ["public", "guest", "authenticated", "group", "user"];
|
|
16168
16279
|
|
|
@@ -22521,7 +22632,6 @@ function lowerParams(params) {
|
|
|
22521
22632
|
var KNOWN_SECRET_PARAMS = {
|
|
22522
22633
|
["elevenLabsTTS" /* elevenLabsTTS */]: ["apiKey"],
|
|
22523
22634
|
["googleSearch" /* googleSearch */]: ["apiKey"],
|
|
22524
|
-
["openAIImageGeneration" /* openAIImageGeneration */]: ["apiKey"],
|
|
22525
22635
|
["genericAI" /* genericAI */]: ["apiKey"],
|
|
22526
22636
|
["stripeSync" /* stripeSync */]: ["secretId"]
|
|
22527
22637
|
};
|
|
@@ -22681,6 +22791,63 @@ function validateStepParams(step2, issue2, errors, warnings) {
|
|
|
22681
22791
|
function tableIdsMatch(a, b) {
|
|
22682
22792
|
return a.toLowerCase() === b.toLowerCase();
|
|
22683
22793
|
}
|
|
22794
|
+
function collectReachableSteps(startStep, steps) {
|
|
22795
|
+
const reachable = /* @__PURE__ */ new Set();
|
|
22796
|
+
const visit = (name) => {
|
|
22797
|
+
if (reachable.has(name) || !Object.hasOwn(steps, name)) return;
|
|
22798
|
+
reachable.add(name);
|
|
22799
|
+
getFlowStepTargets(steps[name]).forEach(visit);
|
|
22800
|
+
};
|
|
22801
|
+
if (startStep !== null) visit(startStep);
|
|
22802
|
+
return reachable;
|
|
22803
|
+
}
|
|
22804
|
+
function validateControlStep(step2, issue2, errors) {
|
|
22805
|
+
if (step2.type === "forEach" /* forEach */) {
|
|
22806
|
+
const body = step2.params.bodyStep;
|
|
22807
|
+
if (body !== null && typeof body !== "string" || !isStaticParamConfig(step2.paramsConfig?.bodyStep)) {
|
|
22808
|
+
errors.push(
|
|
22809
|
+
issue2(
|
|
22810
|
+
`steps.${step2.name}.params.bodyStep`,
|
|
22811
|
+
`For-each "${step2.name}" must have a fixed bodyStep pointing to an existing step, or null`
|
|
22812
|
+
)
|
|
22813
|
+
);
|
|
22814
|
+
}
|
|
22815
|
+
if (isStaticParamConfig(step2.paramsConfig?.items)) {
|
|
22816
|
+
const items = schemas.forEach.params.shape.items.safeParse(
|
|
22817
|
+
step2.params.items
|
|
22818
|
+
);
|
|
22819
|
+
if (!items.success) {
|
|
22820
|
+
for (const error48 of items.error.issues) {
|
|
22821
|
+
errors.push(issue2(`steps.${step2.name}.params.items`, error48.message));
|
|
22822
|
+
}
|
|
22823
|
+
}
|
|
22824
|
+
}
|
|
22825
|
+
return;
|
|
22826
|
+
}
|
|
22827
|
+
if (step2.type !== "branch" /* branch */) return;
|
|
22828
|
+
const branches = step2.params.branches;
|
|
22829
|
+
const config2 = step2.paramsConfig?.branches;
|
|
22830
|
+
if (!branches || typeof branches !== "object" || Array.isArray(branches) || config2 && config2.type !== "object" && !isStaticParamConfig(config2)) {
|
|
22831
|
+
errors.push(
|
|
22832
|
+
issue2(
|
|
22833
|
+
`steps.${step2.name}.params.branches`,
|
|
22834
|
+
"Branches must be an object with fixed target step names and a condition for each target"
|
|
22835
|
+
)
|
|
22836
|
+
);
|
|
22837
|
+
return;
|
|
22838
|
+
}
|
|
22839
|
+
for (const [target, condition] of Object.entries(branches)) {
|
|
22840
|
+
const conditionConfig = config2?.type === "object" ? config2.subParams?.[target] : void 0;
|
|
22841
|
+
if (isStaticParamConfig(conditionConfig) && typeof condition !== "boolean") {
|
|
22842
|
+
errors.push(
|
|
22843
|
+
issue2(
|
|
22844
|
+
`steps.${step2.name}.params.branches.${target}`,
|
|
22845
|
+
"Branch conditions must be booleans or dynamic expressions"
|
|
22846
|
+
)
|
|
22847
|
+
);
|
|
22848
|
+
}
|
|
22849
|
+
}
|
|
22850
|
+
}
|
|
22684
22851
|
function validateFlow(declaration, ctx) {
|
|
22685
22852
|
const errors = [];
|
|
22686
22853
|
const warnings = [];
|
|
@@ -22713,7 +22880,7 @@ function validateFlow(declaration, ctx) {
|
|
|
22713
22880
|
)
|
|
22714
22881
|
);
|
|
22715
22882
|
}
|
|
22716
|
-
} else if (!(declaration.startStep
|
|
22883
|
+
} else if (!Object.hasOwn(steps, declaration.startStep)) {
|
|
22717
22884
|
errors.push(
|
|
22718
22885
|
issue2(
|
|
22719
22886
|
"startStep",
|
|
@@ -22722,32 +22889,15 @@ function validateFlow(declaration, ctx) {
|
|
|
22722
22889
|
);
|
|
22723
22890
|
}
|
|
22724
22891
|
for (const step2 of Object.values(steps)) {
|
|
22725
|
-
|
|
22726
|
-
errors.push(
|
|
22727
|
-
issue2(
|
|
22728
|
-
`steps.${step2.name}.nextStep`,
|
|
22729
|
-
`Step "${step2.name}" points to unknown step "${step2.nextStep}"`
|
|
22730
|
-
)
|
|
22731
|
-
);
|
|
22732
|
-
}
|
|
22892
|
+
validateControlStep(step2, issue2, errors);
|
|
22733
22893
|
}
|
|
22734
|
-
const
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
if (visited.has(current2)) {
|
|
22738
|
-
errors.push(
|
|
22739
|
-
issue2(
|
|
22740
|
-
`steps.${current2}.nextStep`,
|
|
22741
|
-
`Step "${current2}" is executed twice \u2014 steps must form a linked list; nextStep must not point to itself or a previous step`
|
|
22742
|
-
)
|
|
22743
|
-
);
|
|
22744
|
-
break;
|
|
22745
|
-
}
|
|
22746
|
-
visited.add(current2);
|
|
22747
|
-
current2 = steps[current2].nextStep;
|
|
22894
|
+
for (const error48 of getFlowGraphErrors({ ...declaration, steps })) {
|
|
22895
|
+
if (!Object.hasOwn(steps, error48.stepName)) continue;
|
|
22896
|
+
errors.push(issue2(`steps.${error48.stepName}`, error48.message));
|
|
22748
22897
|
}
|
|
22898
|
+
const reachable = collectReachableSteps(declaration.startStep, steps);
|
|
22749
22899
|
for (const name of stepNames) {
|
|
22750
|
-
if (!
|
|
22900
|
+
if (!reachable.has(name)) {
|
|
22751
22901
|
warnings.push(
|
|
22752
22902
|
issue2(
|
|
22753
22903
|
`steps.${name}`,
|
|
@@ -23004,14 +23154,110 @@ var step = {
|
|
|
23004
23154
|
listTypeByParent: createStepFactory("listTypeByParent" /* listTypeByParent */),
|
|
23005
23155
|
listType: createStepFactory("listType" /* listType */),
|
|
23006
23156
|
notifyWebSocket: createStepFactory("notifyWebSocket" /* notifyWebSocket */),
|
|
23007
|
-
openAIImageGeneration: createStepFactory("openAIImageGeneration" /* openAIImageGeneration */),
|
|
23008
23157
|
type: createStepFactory("type" /* type */),
|
|
23009
23158
|
updateType: createStepFactory("updateType" /* updateType */),
|
|
23010
23159
|
extractImageMetadata: createStepFactory("extractImageMetadata" /* extractImageMetadata */),
|
|
23011
23160
|
cloudFunction: createStepFactory("cloudFunction" /* cloudFunction */),
|
|
23012
23161
|
genericAI: createStepFactory("genericAI" /* genericAI */),
|
|
23013
|
-
stripeSync: createStepFactory("stripeSync" /* stripeSync */)
|
|
23162
|
+
stripeSync: createStepFactory("stripeSync" /* stripeSync */),
|
|
23163
|
+
forEach(name, opts) {
|
|
23164
|
+
return {
|
|
23165
|
+
...createStepFactory("forEach" /* forEach */)(name, {
|
|
23166
|
+
...opts,
|
|
23167
|
+
params: { items: opts.items }
|
|
23168
|
+
}),
|
|
23169
|
+
steps: opts.steps
|
|
23170
|
+
};
|
|
23171
|
+
},
|
|
23172
|
+
branch(name, opts) {
|
|
23173
|
+
return {
|
|
23174
|
+
...createStepFactory("branch" /* branch */)(name, { ...opts, params: {} }),
|
|
23175
|
+
branches: opts.branches
|
|
23176
|
+
};
|
|
23177
|
+
}
|
|
23014
23178
|
};
|
|
23179
|
+
function flattenLoopBody(parent, errors) {
|
|
23180
|
+
const { definition } = parent;
|
|
23181
|
+
if (!definition.steps)
|
|
23182
|
+
errors.push(`For-each "${definition.name}" requires nested "steps"`);
|
|
23183
|
+
const body = definition.steps ?? [];
|
|
23184
|
+
return [
|
|
23185
|
+
{
|
|
23186
|
+
...parent,
|
|
23187
|
+
definition: {
|
|
23188
|
+
...definition,
|
|
23189
|
+
params: { ...definition.params, bodyStep: body[0]?.name ?? null }
|
|
23190
|
+
}
|
|
23191
|
+
},
|
|
23192
|
+
...flattenSequence(body, errors, JSON.stringify([definition.name, "body"]))
|
|
23193
|
+
];
|
|
23194
|
+
}
|
|
23195
|
+
function flattenBranchPaths(parent, hasFollowingStep, errors) {
|
|
23196
|
+
const { definition } = parent;
|
|
23197
|
+
if (!definition.branches) {
|
|
23198
|
+
errors.push(
|
|
23199
|
+
`Branch "${definition.name}" requires branch-local steps in "branches"`
|
|
23200
|
+
);
|
|
23201
|
+
}
|
|
23202
|
+
if (parent.nextStep !== null || hasFollowingStep) {
|
|
23203
|
+
errors.push(
|
|
23204
|
+
`Branch "${definition.name}" must end its sequence; continuations belong inside its branches`
|
|
23205
|
+
);
|
|
23206
|
+
}
|
|
23207
|
+
const paths = definition.branches ?? [];
|
|
23208
|
+
const nested = paths.flatMap((path, pathIndex) => {
|
|
23209
|
+
if (path.steps.length === 0)
|
|
23210
|
+
errors.push(
|
|
23211
|
+
`Branch "${definition.name}" path ${pathIndex + 1} must contain at least one step`
|
|
23212
|
+
);
|
|
23213
|
+
if (typeof path.when !== "boolean" && !isFlowParamMarker(path.when)) {
|
|
23214
|
+
errors.push(
|
|
23215
|
+
`Branch "${definition.name}" path ${pathIndex + 1} requires a boolean or dynamic condition`
|
|
23216
|
+
);
|
|
23217
|
+
}
|
|
23218
|
+
return flattenSequence(
|
|
23219
|
+
path.steps,
|
|
23220
|
+
errors,
|
|
23221
|
+
JSON.stringify([definition.name, pathIndex])
|
|
23222
|
+
);
|
|
23223
|
+
});
|
|
23224
|
+
return [
|
|
23225
|
+
{
|
|
23226
|
+
...parent,
|
|
23227
|
+
definition: {
|
|
23228
|
+
...definition,
|
|
23229
|
+
params: {
|
|
23230
|
+
branches: Object.fromEntries(
|
|
23231
|
+
paths.filter((path) => path.steps.length).map((path) => [path.steps[0].name, path.when])
|
|
23232
|
+
)
|
|
23233
|
+
}
|
|
23234
|
+
},
|
|
23235
|
+
nextStep: null
|
|
23236
|
+
},
|
|
23237
|
+
...nested
|
|
23238
|
+
];
|
|
23239
|
+
}
|
|
23240
|
+
function flattenSequence(definitions, errors, scope = "flow", detached = false) {
|
|
23241
|
+
return definitions.flatMap((definition, index) => {
|
|
23242
|
+
const nextStep = definition.next !== void 0 ? definition.next : detached || definition.type === "branch" /* branch */ ? null : definitions[index + 1]?.name ?? null;
|
|
23243
|
+
const parent = { definition, nextStep, scope };
|
|
23244
|
+
if (definition.type === "forEach" /* forEach */)
|
|
23245
|
+
return flattenLoopBody(parent, errors);
|
|
23246
|
+
if (definition.type === "branch" /* branch */) {
|
|
23247
|
+
return flattenBranchPaths(
|
|
23248
|
+
parent,
|
|
23249
|
+
!detached && index < definitions.length - 1,
|
|
23250
|
+
errors
|
|
23251
|
+
);
|
|
23252
|
+
}
|
|
23253
|
+
if (detached && definition.next === void 0) {
|
|
23254
|
+
errors.push(
|
|
23255
|
+
`Detached step "${definition.name}" requires an explicit "next" (step name or null)`
|
|
23256
|
+
);
|
|
23257
|
+
}
|
|
23258
|
+
return [parent];
|
|
23259
|
+
});
|
|
23260
|
+
}
|
|
23015
23261
|
function buildDeclarationStep(definition, nextStep, errors) {
|
|
23016
23262
|
for (const paramName of KNOWN_SECRET_PARAMS[definition.type] ?? []) {
|
|
23017
23263
|
const value = definition.params[paramName];
|
|
@@ -23058,31 +23304,25 @@ function buildFlow(opts) {
|
|
|
23058
23304
|
const errors = [];
|
|
23059
23305
|
const chainSteps = opts.steps;
|
|
23060
23306
|
const detachedSteps = opts.detachedSteps ?? [];
|
|
23061
|
-
const allSteps = [
|
|
23062
|
-
|
|
23063
|
-
|
|
23064
|
-
|
|
23307
|
+
const allSteps = [
|
|
23308
|
+
...flattenSequence(chainSteps, errors),
|
|
23309
|
+
...flattenSequence(detachedSteps, errors, "flow", true)
|
|
23310
|
+
];
|
|
23311
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
23312
|
+
for (const { definition, scope } of allSteps) {
|
|
23313
|
+
if (scopes.has(definition.name)) {
|
|
23065
23314
|
errors.push(`Duplicate step name "${definition.name}"`);
|
|
23066
23315
|
}
|
|
23067
|
-
|
|
23316
|
+
scopes.set(definition.name, scope);
|
|
23068
23317
|
}
|
|
23069
23318
|
const steps = {};
|
|
23070
|
-
for (
|
|
23071
|
-
|
|
23072
|
-
const nextStep = definition.next !== void 0 ? definition.next : chainSteps[i + 1]?.name ?? null;
|
|
23073
|
-
steps[definition.name] = buildDeclarationStep(definition, nextStep, errors);
|
|
23074
|
-
}
|
|
23075
|
-
for (const definition of detachedSteps) {
|
|
23076
|
-
if (definition.next === void 0) {
|
|
23319
|
+
for (const { definition, nextStep, scope } of allSteps) {
|
|
23320
|
+
if (nextStep && scopes.has(nextStep) && scopes.get(nextStep) !== scope) {
|
|
23077
23321
|
errors.push(
|
|
23078
|
-
`
|
|
23322
|
+
`Step "${definition.name}" cannot point to "${nextStep}" outside its own branch sequence`
|
|
23079
23323
|
);
|
|
23080
23324
|
}
|
|
23081
|
-
steps[definition.name] = buildDeclarationStep(
|
|
23082
|
-
definition,
|
|
23083
|
-
definition.next ?? null,
|
|
23084
|
-
errors
|
|
23085
|
-
);
|
|
23325
|
+
steps[definition.name] = buildDeclarationStep(definition, nextStep, errors);
|
|
23086
23326
|
}
|
|
23087
23327
|
const triggers = {};
|
|
23088
23328
|
for (const [name, definition] of Object.entries(opts.triggers)) {
|