@turbofy-ai/app-runtime 0.0.7 → 0.0.9

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.js CHANGED
@@ -430,7 +430,26 @@ function pageLocalizedConfigCode() {
430
430
  const slugConfig = $$self.slugConfig;
431
431
  const appId = $$self.appId ?? '';
432
432
  const lang = $$args.lang ?? 'en';
433
- const activeSlug = slugConfig?.[lang]?.slug ?? slugConfig?.en?.slug ?? '/';
433
+ const resolveFallbackLocale = () => {
434
+ if (!appId) return 'en';
435
+ const appRecord = $$std.getRecord('cmsapp', appId);
436
+ if (!appRecord || typeof appRecord !== 'object') return 'en';
437
+ const settings = $$std.get(appRecord, 'settings');
438
+ const i18n = settings && typeof settings === 'object' ? settings.i18n : null;
439
+ if (!i18n || typeof i18n !== 'object') return 'en';
440
+ if (typeof i18n.fallback === 'string' && i18n.fallback) return i18n.fallback;
441
+ if (typeof i18n.default === 'string' && i18n.default) return i18n.default;
442
+ if (Array.isArray(i18n.locales) && typeof i18n.locales[0] === 'string' && i18n.locales[0]) {
443
+ return i18n.locales[0];
444
+ }
445
+ return 'en';
446
+ };
447
+ const fallbackLocale = resolveFallbackLocale();
448
+ const activeSlug =
449
+ slugConfig?.[lang]?.slug ??
450
+ slugConfig?.[fallbackLocale]?.slug ??
451
+ slugConfig?.en?.slug ??
452
+ '/';
434
453
  const activeSlugArray = activeSlug.split('/').filter(Boolean);
435
454
 
436
455
  const canonicalPathArray = [lang, ...activeSlugArray];
@@ -524,8 +543,8 @@ function pageLocalizedConfigCode() {
524
543
 
525
544
  const layers = [];
526
545
  for (const suffix of suffixes) {
527
- if (lang !== 'en') {
528
- const fallbackLayer = fetchLocalizationDictionary('en', suffix);
546
+ if (lang !== fallbackLocale) {
547
+ const fallbackLayer = fetchLocalizationDictionary(fallbackLocale, suffix);
529
548
  if (fallbackLayer) layers.push(fallbackLayer);
530
549
  }
531
550
  const activeLayer = fetchLocalizationDictionary(lang, suffix);
@@ -1331,8 +1350,8 @@ function cleanRegex(source) {
1331
1350
  const end = source.endsWith("$") ? source.length - 1 : source.length;
1332
1351
  return source.slice(start, end);
1333
1352
  }
1334
- function floatSafeRemainder(val, step) {
1335
- const ratio = val / step;
1353
+ function floatSafeRemainder(val, step2) {
1354
+ const ratio = val / step2;
1336
1355
  const roundedRatio = Math.round(ratio);
1337
1356
  const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
1338
1357
  if (Math.abs(ratio - roundedRatio) < tolerance)
@@ -12904,7 +12923,7 @@ function toJSONSchema(input, params) {
12904
12923
  const [_, schema] = entry;
12905
12924
  process(schema, ctx2);
12906
12925
  }
12907
- const schemas = {};
12926
+ const schemas2 = {};
12908
12927
  const external = {
12909
12928
  registry: registry2,
12910
12929
  uri: params?.uri,
@@ -12914,15 +12933,15 @@ function toJSONSchema(input, params) {
12914
12933
  for (const entry of registry2._idmap.entries()) {
12915
12934
  const [key, schema] = entry;
12916
12935
  extractDefs(ctx2, schema);
12917
- schemas[key] = finalize(ctx2, schema);
12936
+ schemas2[key] = finalize(ctx2, schema);
12918
12937
  }
12919
12938
  if (Object.keys(defs).length > 0) {
12920
12939
  const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
12921
- schemas.__shared = {
12940
+ schemas2.__shared = {
12922
12941
  [defsSegment]: defs
12923
12942
  };
12924
12943
  }
12925
- return { schemas };
12944
+ return { schemas: schemas2 };
12926
12945
  }
12927
12946
  const ctx = initializeContext({ ...params, processors: allProcessors });
12928
12947
  process(input, ctx);
@@ -14797,8 +14816,8 @@ function convertBaseSchema(schema, ctx) {
14797
14816
  const type = schema.type;
14798
14817
  if (Array.isArray(type)) {
14799
14818
  const typeSchemas = type.map((t) => {
14800
- const typeSchema = { ...schema, type: t };
14801
- return convertBaseSchema(typeSchema, ctx);
14819
+ const typeSchema2 = { ...schema, type: t };
14820
+ return convertBaseSchema(typeSchema2, ctx);
14802
14821
  });
14803
14822
  if (typeSchemas.length === 0) {
14804
14823
  return z.never();
@@ -15132,6 +15151,9 @@ function date4(params) {
15132
15151
  // ../../node_modules/zod/v4/classic/external.js
15133
15152
  config(en_default());
15134
15153
 
15154
+ // ../../node_modules/zod/index.js
15155
+ var zod_default = external_exports;
15156
+
15135
15157
  // ../declarations/src/api/field-type.schema.ts
15136
15158
  var FieldTypeEnum = /* @__PURE__ */ ((FieldTypeEnum2) => {
15137
15159
  FieldTypeEnum2["Boolean"] = "Boolean";
@@ -15630,7 +15652,8 @@ function table(name, fieldsDef, opts = {}) {
15630
15652
  directives,
15631
15653
  publishingTypes,
15632
15654
  searchConfig,
15633
- defaultFieldIds
15655
+ defaultFieldIds,
15656
+ defaultFieldTypes
15634
15657
  } = opts;
15635
15658
  if (firstParent && secondParent && firstParent.name === secondParent.name) {
15636
15659
  throw new Error(
@@ -15659,19 +15682,19 @@ function table(name, fieldsDef, opts = {}) {
15659
15682
  {
15660
15683
  id: defaultFieldIds?.id ?? randomUuid(),
15661
15684
  name: "id",
15662
- type: "ID" /* ID */,
15685
+ type: defaultFieldTypes?.id ?? "ID" /* ID */,
15663
15686
  directives: ["@connector" /* CONNECTOR */]
15664
15687
  },
15665
15688
  {
15666
15689
  id: defaultFieldIds?.createdAt ?? randomUuid(),
15667
15690
  name: "createdAt",
15668
- type: "String" /* String */,
15691
+ type: defaultFieldTypes?.createdAt ?? "String" /* String */,
15669
15692
  directives: []
15670
15693
  },
15671
15694
  {
15672
15695
  id: defaultFieldIds?.updatedAt ?? randomUuid(),
15673
15696
  name: "updatedAt",
15674
- type: "String" /* String */,
15697
+ type: defaultFieldTypes?.updatedAt ?? "String" /* String */,
15675
15698
  directives: []
15676
15699
  }
15677
15700
  ];
@@ -15739,6 +15762,885 @@ function build(schema) {
15739
15762
  return finalSchema;
15740
15763
  }
15741
15764
 
15765
+ // ../declarations/src/flows/schemas/batch-create-type.schema.ts
15766
+ var paramsSchema = external_exports.object({
15767
+ ofType: external_exports.string(),
15768
+ namespace: external_exports.string(),
15769
+ input: external_exports.array(
15770
+ external_exports.object({
15771
+ id: external_exports.string(),
15772
+ fields: external_exports.looseObject({}).optional(),
15773
+ directives: external_exports.array(external_exports.string()).optional(),
15774
+ connections: external_exports.object({
15775
+ first: external_exports.object({
15776
+ with: external_exports.string(),
15777
+ link: external_exports.string()
15778
+ }).optional(),
15779
+ second: external_exports.object({
15780
+ with: external_exports.string(),
15781
+ link: external_exports.string()
15782
+ }).optional()
15783
+ }).optional()
15784
+ })
15785
+ ),
15786
+ dynamicArgs: external_exports.looseObject({}).optional()
15787
+ });
15788
+ var resultSchema = external_exports.record(
15789
+ external_exports.string(),
15790
+ external_exports.object({
15791
+ id: external_exports.string(),
15792
+ createdAt: external_exports.string(),
15793
+ updatedAt: external_exports.string(),
15794
+ ofType: external_exports.string(),
15795
+ fields: external_exports.looseObject({}),
15796
+ namespace: external_exports.string(),
15797
+ directives: external_exports.array(external_exports.string())
15798
+ })
15799
+ );
15800
+ var batchCreateTypeSchema = {
15801
+ params: paramsSchema,
15802
+ result: resultSchema
15803
+ };
15804
+
15805
+ // ../declarations/src/flows/schemas/batch-get-type.schema.ts
15806
+ var paramsSchema2 = external_exports.object({
15807
+ ids: external_exports.array(external_exports.string()),
15808
+ ofType: external_exports.string(),
15809
+ namespace: external_exports.string().optional(),
15810
+ dynamicArgs: external_exports.looseObject({}).optional()
15811
+ });
15812
+ var resultSchema2 = external_exports.record(
15813
+ external_exports.string(),
15814
+ external_exports.object({
15815
+ id: external_exports.string(),
15816
+ createdAt: external_exports.string(),
15817
+ updatedAt: external_exports.string(),
15818
+ ofType: external_exports.string(),
15819
+ fields: external_exports.looseObject({}),
15820
+ namespace: external_exports.string(),
15821
+ directives: external_exports.array(external_exports.string())
15822
+ })
15823
+ );
15824
+ var batchGetTypeSchema = {
15825
+ params: paramsSchema2,
15826
+ result: resultSchema2
15827
+ };
15828
+
15829
+ // ../declarations/src/flows/schemas/cloud-function-type.schema.ts
15830
+ var paramsSchema3 = external_exports.looseObject({
15831
+ cloudFunctionUrl: external_exports.string()
15832
+ });
15833
+ var resultSchema3 = external_exports.discriminatedUnion("type", [
15834
+ external_exports.object({
15835
+ type: external_exports.literal("success"),
15836
+ status: external_exports.number().optional(),
15837
+ headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
15838
+ body: external_exports.union([external_exports.string(), external_exports.looseObject({}), external_exports.array(external_exports.any())]).optional(),
15839
+ statusText: external_exports.string().optional()
15840
+ }),
15841
+ external_exports.object({
15842
+ type: external_exports.literal("error"),
15843
+ content: external_exports.string()
15844
+ })
15845
+ ]);
15846
+ var cloudFunctionTypeSchema = {
15847
+ params: paramsSchema3,
15848
+ result: resultSchema3
15849
+ };
15850
+
15851
+ // ../declarations/src/flows/schemas/create-type.schema.ts
15852
+ var paramsSchema4 = external_exports.object({
15853
+ id: external_exports.string().optional(),
15854
+ ofType: external_exports.string(),
15855
+ fields: external_exports.looseObject({}).optional(),
15856
+ namespace: external_exports.string().optional(),
15857
+ directives: external_exports.array(external_exports.string()).optional(),
15858
+ connections: external_exports.looseObject({}).optional(),
15859
+ dynamicArgs: external_exports.looseObject({}).optional()
15860
+ });
15861
+ var resultSchema4 = external_exports.object({
15862
+ id: external_exports.string(),
15863
+ createdAt: external_exports.string(),
15864
+ updatedAt: external_exports.string(),
15865
+ ofType: external_exports.string(),
15866
+ fields: external_exports.looseObject({}),
15867
+ namespace: external_exports.string(),
15868
+ directives: external_exports.array(external_exports.string()),
15869
+ connections: external_exports.looseObject({}).optional()
15870
+ });
15871
+ var createTypeSchema = {
15872
+ params: paramsSchema4,
15873
+ result: resultSchema4
15874
+ };
15875
+
15876
+ // ../declarations/src/flows/schemas/delete-type.schema.ts
15877
+ var paramsSchema5 = external_exports.object({
15878
+ id: external_exports.string(),
15879
+ ofType: external_exports.string(),
15880
+ namespace: external_exports.string().optional(),
15881
+ dynamicArgs: external_exports.looseObject({}).optional()
15882
+ });
15883
+ var resultSchema5 = external_exports.object({
15884
+ id: external_exports.string(),
15885
+ createdAt: external_exports.string(),
15886
+ updatedAt: external_exports.string(),
15887
+ fields: external_exports.looseObject({})
15888
+ });
15889
+ var deleteTypeSchema = {
15890
+ params: paramsSchema5,
15891
+ result: resultSchema5
15892
+ };
15893
+
15894
+ // ../declarations/src/flows/schemas/elevenlabs-tts.schema.ts
15895
+ var paramsSchema6 = external_exports.object({
15896
+ text: external_exports.string(),
15897
+ model: external_exports.string().meta({
15898
+ type: "string",
15899
+ format: "looseEnum",
15900
+ values: [
15901
+ "eleven_monolingual_v1",
15902
+ "eleven_multilingual_v1",
15903
+ "eleven_multilingual_v2",
15904
+ "eleven_turbo_v2",
15905
+ "eleven_turbo_v2_5",
15906
+ "eleven_flash_v2",
15907
+ "eleven_flash_v2_5"
15908
+ ]
15909
+ }).optional(),
15910
+ stream: external_exports.boolean().optional(),
15911
+ outputFormat: external_exports.string().optional(),
15912
+ voiceId: external_exports.string().optional(),
15913
+ apiKey: external_exports.string().optional(),
15914
+ similarityBoost: external_exports.number().optional(),
15915
+ stability: external_exports.number().optional(),
15916
+ style: external_exports.number().optional()
15917
+ });
15918
+ var errorResultSchema = external_exports.object({
15919
+ type: external_exports.literal("error"),
15920
+ value: external_exports.string().optional()
15921
+ });
15922
+ var characterStartTimeSchema = external_exports.object({
15923
+ c: external_exports.string(),
15924
+ s: external_exports.number()
15925
+ });
15926
+ var successResultSchema = external_exports.object({
15927
+ type: external_exports.literal("success"),
15928
+ url: external_exports.string(),
15929
+ key: external_exports.string(),
15930
+ mimeType: external_exports.string(),
15931
+ durationSeconds: external_exports.number(),
15932
+ characterStartTimes: external_exports.array(characterStartTimeSchema)
15933
+ });
15934
+ var streamResultSchema = external_exports.object({
15935
+ type: external_exports.literal("stream"),
15936
+ data: external_exports.string(),
15937
+ characterStartTimes: external_exports.array(characterStartTimeSchema),
15938
+ index: external_exports.number()
15939
+ });
15940
+ var resultSchema6 = external_exports.union([
15941
+ errorResultSchema,
15942
+ successResultSchema,
15943
+ streamResultSchema
15944
+ ]);
15945
+ var elevenlabsTTSSchema = {
15946
+ params: paramsSchema6,
15947
+ result: resultSchema6
15948
+ };
15949
+
15950
+ // ../declarations/src/flows/schemas/extract-image-metadata.schema.ts
15951
+ var paramsSchema7 = external_exports.object({
15952
+ url: external_exports.string().optional()
15953
+ });
15954
+ var resultSchema7 = external_exports.object({
15955
+ "Bits Per Sample": external_exports.string().optional(),
15956
+ "Image Height": external_exports.string().regex(/^[0-9]+px$/),
15957
+ "Image Width": external_exports.string().regex(/^[0-9]+px$/),
15958
+ "Color Components": external_exports.string(),
15959
+ Subsampling: external_exports.string().optional(),
15960
+ "JFIF Version": external_exports.string().optional(),
15961
+ "Resolution Unit": external_exports.string().optional(),
15962
+ XResolution: external_exports.string().optional(),
15963
+ YResolution: external_exports.string().optional(),
15964
+ "JFIF Thumbnail Width": external_exports.string().regex(/^[0-9]+px$/).optional(),
15965
+ "JFIF Thumbnail Height": external_exports.string().regex(/^[0-9]+px$/).optional(),
15966
+ ImageDescription: external_exports.string().optional(),
15967
+ ResolutionUnit: external_exports.string().optional(),
15968
+ YCbCrPositioning: external_exports.string().optional(),
15969
+ "Exif IFD Pointer": external_exports.number().optional(),
15970
+ XPTitle: external_exports.string().optional(),
15971
+ XPKeywords: external_exports.string().optional(),
15972
+ XPSubject: external_exports.string().optional(),
15973
+ ExifVersion: external_exports.string().optional(),
15974
+ ComponentsConfiguration: external_exports.string().optional(),
15975
+ UserComment: external_exports.string().optional(),
15976
+ FlashpixVersion: external_exports.string().optional(),
15977
+ ColorSpace: external_exports.string().optional(),
15978
+ "Model Version": external_exports.string().optional(),
15979
+ "Coded Character Set": external_exports.string().optional(),
15980
+ "Object Name": external_exports.string().optional(),
15981
+ Keywords: external_exports.array(external_exports.string()).optional(),
15982
+ "Country/Primary Location Name": external_exports.string().optional(),
15983
+ Headline: external_exports.string().optional(),
15984
+ Credit: external_exports.string().optional(),
15985
+ Source: external_exports.string().optional(),
15986
+ "Caption/Abstract": external_exports.string().optional(),
15987
+ "Record Version": external_exports.string().optional(),
15988
+ about: external_exports.string().optional(),
15989
+ LastKeywordXMP: external_exports.string().optional(),
15990
+ description: external_exports.string().optional(),
15991
+ subject: external_exports.string().optional(),
15992
+ title: external_exports.string().optional(),
15993
+ creditLine: external_exports.string().optional(),
15994
+ BitsPerSample: external_exports.string().optional(),
15995
+ ImageLength: external_exports.string().optional(),
15996
+ ImageWidth: external_exports.string().optional(),
15997
+ YCbCrSubSampling: external_exports.string().optional(),
15998
+ FileType: external_exports.string()
15999
+ });
16000
+ var extractImageMetadataSchema = {
16001
+ params: paramsSchema7,
16002
+ result: resultSchema7
16003
+ };
16004
+
16005
+ // ../declarations/src/flows/schemas/generic-ai-step.schema.ts
16006
+ var systemMessageSchema = zod_default.object({
16007
+ role: zod_default.literal("system"),
16008
+ content: zod_default.string(),
16009
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16010
+ });
16011
+ var userMessageContentTextPartSchema = zod_default.object({
16012
+ type: zod_default.literal("text"),
16013
+ text: zod_default.string(),
16014
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16015
+ });
16016
+ var userMessageContentImagePartSchema = zod_default.object({
16017
+ type: zod_default.literal("image"),
16018
+ imageUrl: zod_default.string(),
16019
+ mimeType: zod_default.string().optional(),
16020
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16021
+ });
16022
+ var userMessageContentFilePartSchema = zod_default.object({
16023
+ type: zod_default.literal("file"),
16024
+ fileUrl: zod_default.string(),
16025
+ filename: zod_default.string().optional(),
16026
+ mimeType: zod_default.string(),
16027
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16028
+ });
16029
+ var userMessageContentSchema = zod_default.union([
16030
+ userMessageContentTextPartSchema,
16031
+ userMessageContentImagePartSchema,
16032
+ userMessageContentFilePartSchema
16033
+ ]);
16034
+ var userMessageSchema = zod_default.object({
16035
+ role: zod_default.literal("user"),
16036
+ content: zod_default.union([zod_default.string(), zod_default.array(userMessageContentSchema)]),
16037
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16038
+ });
16039
+ var assistantMessageContentTextPartSchema = zod_default.object({
16040
+ type: zod_default.literal("text"),
16041
+ text: zod_default.string(),
16042
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16043
+ });
16044
+ var assistantMessageToolCallPartSchema = zod_default.object({
16045
+ type: zod_default.literal("tool-call"),
16046
+ toolCallId: zod_default.string(),
16047
+ toolName: zod_default.string(),
16048
+ args: zod_default.any(),
16049
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16050
+ });
16051
+ var assistantMessageContentSchema = zod_default.union([
16052
+ assistantMessageContentTextPartSchema,
16053
+ assistantMessageToolCallPartSchema
16054
+ ]);
16055
+ var assistantMessageSchema = zod_default.object({
16056
+ role: zod_default.literal("assistant"),
16057
+ content: zod_default.union([zod_default.string(), zod_default.array(assistantMessageContentSchema)]),
16058
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16059
+ });
16060
+ var toolMessageSchema = zod_default.object({
16061
+ role: zod_default.literal("tool"),
16062
+ content: zod_default.array(
16063
+ zod_default.object({
16064
+ type: zod_default.literal("tool-result"),
16065
+ toolCallId: zod_default.string(),
16066
+ toolName: zod_default.string(),
16067
+ result: zod_default.any()
16068
+ })
16069
+ )
16070
+ });
16071
+ var messageSchema = zod_default.union([
16072
+ systemMessageSchema,
16073
+ userMessageSchema,
16074
+ assistantMessageSchema,
16075
+ toolMessageSchema
16076
+ ]);
16077
+ var toolSchema = zod_default.discriminatedUnion("type", [
16078
+ zod_default.object({
16079
+ description: zod_default.string().optional(),
16080
+ parameters: zod_default.any(),
16081
+ type: zod_default.literal("function")
16082
+ }),
16083
+ zod_default.object({
16084
+ type: zod_default.literal("provider-defined"),
16085
+ parameters: zod_default.any(),
16086
+ id: zod_default.string().regex(/^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$/),
16087
+ args: zod_default.record(zod_default.string(), zod_default.unknown())
16088
+ })
16089
+ ]);
16090
+ var openAITextModelsSchema = zod_default.object({
16091
+ model: zod_default.string()
16092
+ });
16093
+ var anthropicTextModelsSchema = zod_default.object({
16094
+ model: zod_default.string()
16095
+ });
16096
+ var mistralTextModelsSchema = zod_default.object({
16097
+ model: zod_default.string()
16098
+ });
16099
+ var cohereTextModelsSchema = zod_default.object({
16100
+ model: zod_default.string()
16101
+ });
16102
+ var googleTextModelsSchema = zod_default.object({
16103
+ model: zod_default.string()
16104
+ });
16105
+ var openAIEmbedModelsSchema = zod_default.object({
16106
+ model: zod_default.string()
16107
+ });
16108
+ var anthropicEmbedModelsSchema = zod_default.object({
16109
+ model: zod_default.string()
16110
+ });
16111
+ var mistralEmbedModelsSchema = zod_default.object({
16112
+ model: zod_default.string()
16113
+ });
16114
+ var cohereEmbedModelsSchema = zod_default.object({
16115
+ model: zod_default.string()
16116
+ });
16117
+ var googleEmbedModelsSchema = zod_default.object({
16118
+ model: zod_default.string()
16119
+ });
16120
+ var openaiProviderSchema = zod_default.object({
16121
+ provider: zod_default.literal("openai")
16122
+ });
16123
+ var anthropicProviderSchema = zod_default.object({
16124
+ provider: zod_default.literal("anthropic")
16125
+ });
16126
+ var mistralProviderSchema = zod_default.object({
16127
+ provider: zod_default.literal("mistral")
16128
+ });
16129
+ var cohereProviderSchema = zod_default.object({
16130
+ provider: zod_default.literal("cohere")
16131
+ });
16132
+ var googleProviderSchema = zod_default.object({
16133
+ provider: zod_default.literal("google")
16134
+ });
16135
+ var sharedParamsSchema = zod_default.object({
16136
+ apiKey: zod_default.string(),
16137
+ temperature: zod_default.number().optional()
16138
+ });
16139
+ var generateTextParamsSchema = zod_default.object({
16140
+ operation: zod_default.literal("generateText")
16141
+ });
16142
+ var generateObjectParamsSchema = zod_default.object({
16143
+ operation: zod_default.literal("generateObject")
16144
+ });
16145
+ var streamTextParamsSchema = zod_default.object({
16146
+ operation: zod_default.literal("streamText")
16147
+ });
16148
+ var embedParamsSchema = zod_default.object({
16149
+ operation: zod_default.literal("embed")
16150
+ });
16151
+ var textModelsSchema = zod_default.object({
16152
+ model: zod_default.discriminatedUnion("provider", [
16153
+ openaiProviderSchema.merge(openAITextModelsSchema),
16154
+ anthropicProviderSchema.merge(anthropicTextModelsSchema),
16155
+ mistralProviderSchema.merge(mistralTextModelsSchema),
16156
+ cohereProviderSchema.merge(cohereTextModelsSchema),
16157
+ googleProviderSchema.merge(googleTextModelsSchema)
16158
+ ])
16159
+ });
16160
+ var embedModelsSchema = zod_default.object({
16161
+ model: zod_default.discriminatedUnion("provider", [
16162
+ openaiProviderSchema.merge(openAIEmbedModelsSchema),
16163
+ anthropicProviderSchema.merge(anthropicEmbedModelsSchema),
16164
+ mistralProviderSchema.merge(mistralEmbedModelsSchema),
16165
+ cohereProviderSchema.merge(cohereEmbedModelsSchema),
16166
+ googleProviderSchema.merge(googleEmbedModelsSchema)
16167
+ ])
16168
+ });
16169
+ var fullStreamTextParamsSchema = streamTextParamsSchema.extend({
16170
+ ...sharedParamsSchema.shape,
16171
+ ...textModelsSchema.shape,
16172
+ messages: zod_default.array(messageSchema).optional().describe("jsOnly"),
16173
+ system: zod_default.string().optional(),
16174
+ prompt: zod_default.string().optional(),
16175
+ tools: zod_default.record(zod_default.string(), toolSchema).describe("jsOnly"),
16176
+ toolChoice: zod_default.enum(["auto", "required", "none"]).optional(),
16177
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16178
+ });
16179
+ var paramsSchema8 = zod_default.discriminatedUnion("operation", [
16180
+ generateObjectParamsSchema.merge(sharedParamsSchema).merge(textModelsSchema).extend({
16181
+ prompt: zod_default.string(),
16182
+ schema: zod_default.any().describe("jsOnly"),
16183
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16184
+ }),
16185
+ generateTextParamsSchema.merge(sharedParamsSchema).merge(textModelsSchema).extend({
16186
+ messages: zod_default.array(messageSchema).optional().describe("jsOnly"),
16187
+ system: zod_default.string().optional(),
16188
+ prompt: zod_default.string().optional(),
16189
+ tools: zod_default.record(zod_default.string(), toolSchema).describe("jsOnly"),
16190
+ toolChoice: zod_default.enum(["auto", "required", "none"]).optional(),
16191
+ providerOptions: zod_default.record(zod_default.string(), zod_default.any()).optional()
16192
+ }),
16193
+ fullStreamTextParamsSchema,
16194
+ embedParamsSchema.merge(sharedParamsSchema).merge(embedModelsSchema).extend({
16195
+ value: zod_default.string()
16196
+ })
16197
+ ]);
16198
+ var paramsNestedSchemas = {
16199
+ messages: messageSchema,
16200
+ userMessageContent: userMessageContentSchema,
16201
+ userMessage: userMessageSchema,
16202
+ message: messageSchema,
16203
+ tool: toolSchema,
16204
+ userMessageContentTextPart: userMessageContentTextPartSchema,
16205
+ userMessageContentImagePart: userMessageContentImagePartSchema,
16206
+ userMessageContentFilePart: userMessageContentFilePartSchema,
16207
+ assistantMessageContent: assistantMessageContentSchema,
16208
+ assistantMessage: assistantMessageSchema,
16209
+ assistantMessageContentTextPart: assistantMessageContentTextPartSchema,
16210
+ assistantMessageToolCallPart: assistantMessageToolCallPartSchema,
16211
+ toolMessage: toolMessageSchema
16212
+ };
16213
+ var resultSchema8 = zod_default.discriminatedUnion("type", [
16214
+ zod_default.object({
16215
+ type: zod_default.literal("result"),
16216
+ value: zod_default.object({
16217
+ reasoning: zod_default.string().optional(),
16218
+ text: zod_default.string(),
16219
+ toolCalls: zod_default.array(
16220
+ zod_default.object({
16221
+ type: zod_default.enum(["function", "tool-call"]),
16222
+ toolName: zod_default.string(),
16223
+ toolCallId: zod_default.string(),
16224
+ id: zod_default.string().optional(),
16225
+ args: zod_default.any().optional()
16226
+ })
16227
+ )
16228
+ })
16229
+ }),
16230
+ zod_default.object({
16231
+ type: zod_default.literal("objectResult"),
16232
+ value: zod_default.any()
16233
+ }),
16234
+ zod_default.object({
16235
+ type: zod_default.literal("streamChunk"),
16236
+ value: zod_default.string()
16237
+ }),
16238
+ zod_default.object({
16239
+ type: zod_default.literal("streamResult"),
16240
+ value: zod_default.object({
16241
+ text: zod_default.string(),
16242
+ toolCalls: zod_default.array(
16243
+ zod_default.object({
16244
+ type: zod_default.enum(["function", "tool-call"]),
16245
+ toolName: zod_default.string(),
16246
+ toolCallId: zod_default.string(),
16247
+ id: zod_default.string().optional(),
16248
+ args: zod_default.any()
16249
+ })
16250
+ )
16251
+ })
16252
+ }),
16253
+ zod_default.object({
16254
+ type: zod_default.literal("embeddingResult"),
16255
+ value: zod_default.array(zod_default.number())
16256
+ }),
16257
+ zod_default.object({
16258
+ type: zod_default.literal("error"),
16259
+ error: zod_default.string()
16260
+ })
16261
+ ]);
16262
+ var genericAIStepSchema = {
16263
+ params: paramsSchema8,
16264
+ result: resultSchema8,
16265
+ paramsNestedSchemas,
16266
+ fullStreamTextParamsSchema
16267
+ };
16268
+
16269
+ // ../declarations/src/flows/schemas/google-search.schema.ts
16270
+ var paramsSchema9 = external_exports.object({
16271
+ searchTerms: external_exports.string(),
16272
+ searchEngineId: external_exports.string().optional(),
16273
+ lang: external_exports.enum([
16274
+ "lang_ar",
16275
+ "lang_bg",
16276
+ "lang_ca",
16277
+ "lang_cs",
16278
+ "lang_da",
16279
+ "lang_de",
16280
+ "lang_el",
16281
+ "lang_en",
16282
+ "lang_es",
16283
+ "lang_et",
16284
+ "lang_fi",
16285
+ "lang_fr",
16286
+ "lang_hr",
16287
+ "lang_hu",
16288
+ "lang_id",
16289
+ "lang_is",
16290
+ "lang_it",
16291
+ "lang_iw",
16292
+ "lang_ja",
16293
+ "lang_ko",
16294
+ "lang_lt",
16295
+ "lang_lv",
16296
+ "lang_nl",
16297
+ "lang_no",
16298
+ "lang_pl",
16299
+ "lang_pt",
16300
+ "lang_ro",
16301
+ "lang_ru",
16302
+ "lang_sk",
16303
+ "lang_sl",
16304
+ "lang_sr",
16305
+ "lang_sv",
16306
+ "lang_tr",
16307
+ "lang_zh-CN",
16308
+ "lang_zh-TW"
16309
+ ]).optional(),
16310
+ apiKey: external_exports.string().optional(),
16311
+ numOfResults: external_exports.number().int().optional(),
16312
+ searchType: external_exports.enum(["image"]).optional(),
16313
+ siteSearch: external_exports.string().optional(),
16314
+ siteSearchFilter: external_exports.enum(["exclude", "include"]).optional(),
16315
+ dateRestrict: external_exports.string().optional()
16316
+ });
16317
+ var metatagSchema = external_exports.record(external_exports.string(), external_exports.string());
16318
+ var websiteResponseSchema = external_exports.object({
16319
+ title: external_exports.string(),
16320
+ link: external_exports.string(),
16321
+ snippet: external_exports.string(),
16322
+ metatags: external_exports.array(metatagSchema).optional()
16323
+ });
16324
+ var imageResponseSchema = external_exports.object({
16325
+ title: external_exports.string().optional(),
16326
+ link: external_exports.string().optional(),
16327
+ snippet: external_exports.string().optional(),
16328
+ mime: external_exports.string().optional(),
16329
+ image: external_exports.object({
16330
+ contextLink: external_exports.string(),
16331
+ height: external_exports.number().int().optional(),
16332
+ width: external_exports.number().int().optional(),
16333
+ byteSize: external_exports.number().int().optional(),
16334
+ thumbnailLink: external_exports.string().optional(),
16335
+ thumbnailHeight: external_exports.number().int().optional(),
16336
+ thumbnailWidth: external_exports.number().int().optional()
16337
+ }).optional()
16338
+ });
16339
+ var resultSchema9 = external_exports.union([
16340
+ external_exports.array(websiteResponseSchema),
16341
+ external_exports.array(imageResponseSchema)
16342
+ ]);
16343
+ var googleSearchSchema = {
16344
+ params: paramsSchema9,
16345
+ result: resultSchema9
16346
+ };
16347
+
16348
+ // ../declarations/src/flows/schemas/html-to-pdf.schema.ts
16349
+ var paramsSchema10 = external_exports.object({
16350
+ htmlString: external_exports.string(),
16351
+ outputFilename: external_exports.string().optional(),
16352
+ format: external_exports.enum([
16353
+ "letter",
16354
+ "legal",
16355
+ "tabloid",
16356
+ "ledger",
16357
+ "a0",
16358
+ "a1",
16359
+ "a2",
16360
+ "a3",
16361
+ "a4",
16362
+ "a5",
16363
+ "a6"
16364
+ ]).optional(),
16365
+ margin: external_exports.object({
16366
+ top: external_exports.string().optional(),
16367
+ right: external_exports.string().optional(),
16368
+ bottom: external_exports.string().optional(),
16369
+ left: external_exports.string().optional()
16370
+ }).optional()
16371
+ });
16372
+ var errorResultSchema2 = external_exports.object({
16373
+ type: external_exports.literal("error"),
16374
+ value: external_exports.string().optional()
16375
+ });
16376
+ var successResultSchema2 = external_exports.object({
16377
+ type: external_exports.literal("success"),
16378
+ url: external_exports.string(),
16379
+ key: external_exports.string(),
16380
+ mimeType: external_exports.string()
16381
+ });
16382
+ var resultSchema10 = external_exports.union([errorResultSchema2, successResultSchema2]);
16383
+ var htmlToPdfSchema = {
16384
+ params: paramsSchema10,
16385
+ result: resultSchema10
16386
+ };
16387
+
16388
+ // ../declarations/src/flows/schemas/http-request.schema.ts
16389
+ var urlSchema = external_exports.url();
16390
+ var parametersSchema = external_exports.record(external_exports.string(), external_exports.string());
16391
+ var headersSchema = external_exports.record(external_exports.string(), external_exports.string());
16392
+ var contentMediaTypeSchema = external_exports.enum([
16393
+ "application/json",
16394
+ "text/plain",
16395
+ "application/xml",
16396
+ "application/x-www-form-urlencoded",
16397
+ "multipart/form-data"
16398
+ ]);
16399
+ var getDeleteParamsSchema = external_exports.object({
16400
+ httpMethod: external_exports.enum(["GET", "DELETE"]),
16401
+ url: urlSchema,
16402
+ parameters: parametersSchema.optional(),
16403
+ headers: headersSchema.optional(),
16404
+ contentMediaType: contentMediaTypeSchema.optional()
16405
+ });
16406
+ var postPutPatchParamsSchema = external_exports.object({
16407
+ httpMethod: external_exports.enum(["POST", "PUT", "PATCH"]),
16408
+ url: urlSchema,
16409
+ parameters: parametersSchema.optional(),
16410
+ headers: headersSchema.optional(),
16411
+ contentMediaType: contentMediaTypeSchema.optional(),
16412
+ body: external_exports.string()
16413
+ });
16414
+ var paramsSchema11 = external_exports.discriminatedUnion("httpMethod", [
16415
+ getDeleteParamsSchema,
16416
+ postPutPatchParamsSchema
16417
+ ]);
16418
+ var resultSchema11 = external_exports.discriminatedUnion("type", [
16419
+ external_exports.object({
16420
+ type: external_exports.literal("success"),
16421
+ status: external_exports.number().optional(),
16422
+ headers: headersSchema.optional(),
16423
+ body: external_exports.union([external_exports.string(), external_exports.looseObject({}), external_exports.array(external_exports.any())]).optional(),
16424
+ statusText: external_exports.string().optional()
16425
+ }),
16426
+ external_exports.object({
16427
+ type: external_exports.literal("error"),
16428
+ content: external_exports.string()
16429
+ })
16430
+ ]);
16431
+ var httpRequestSchema = {
16432
+ params: paramsSchema11,
16433
+ result: resultSchema11
16434
+ };
16435
+
16436
+ // ../declarations/src/flows/schemas/link-scraper.schema.ts
16437
+ var paramsSchema12 = external_exports.object({
16438
+ websiteUrl: external_exports.string(),
16439
+ selectors: external_exports.string().optional(),
16440
+ resultType: external_exports.enum(["text", "html"]).optional(),
16441
+ numOfResults: external_exports.number().int().optional()
16442
+ });
16443
+ var resultSchema12 = external_exports.record(external_exports.string(), external_exports.array(external_exports.string()));
16444
+ var linkScraperSchema = {
16445
+ params: paramsSchema12,
16446
+ result: resultSchema12
16447
+ };
16448
+
16449
+ // ../declarations/src/flows/schemas/list-type-by-parent.schema.ts
16450
+ var paramsSchema13 = external_exports.object({
16451
+ ofType: external_exports.string(),
16452
+ parentType: external_exports.string(),
16453
+ limit: external_exports.number().optional(),
16454
+ nextToken: external_exports.string().nullable().optional(),
16455
+ parentId: external_exports.string(),
16456
+ parentKey: external_exports.enum(["SECOND", "FIRST"]),
16457
+ sortOrder: external_exports.enum(["ASC", "DESC"]).optional(),
16458
+ namespace: external_exports.string().optional(),
16459
+ dynamicArgs: external_exports.looseObject({}).optional()
16460
+ });
16461
+ var resultItemSchema = external_exports.object({
16462
+ id: external_exports.string(),
16463
+ createdAt: external_exports.string(),
16464
+ updatedAt: external_exports.string(),
16465
+ ofType: external_exports.string(),
16466
+ fields: external_exports.looseObject({}),
16467
+ namespace: external_exports.string(),
16468
+ directives: external_exports.array(external_exports.string())
16469
+ });
16470
+ var resultSchema13 = external_exports.object({
16471
+ nextToken: external_exports.string().nullable(),
16472
+ items: external_exports.array(resultItemSchema)
16473
+ });
16474
+ var listTypeByParentSchema = {
16475
+ params: paramsSchema13,
16476
+ result: resultSchema13
16477
+ };
16478
+
16479
+ // ../declarations/src/flows/schemas/list-type.schema.ts
16480
+ var paramsSchema14 = external_exports.object({
16481
+ ofType: external_exports.string(),
16482
+ limit: external_exports.number().optional(),
16483
+ nextToken: external_exports.string().optional(),
16484
+ sortOrder: external_exports.enum(["ASC", "DESC"]).optional(),
16485
+ namespace: external_exports.string().optional(),
16486
+ dynamicArgs: external_exports.looseObject({}).optional()
16487
+ });
16488
+ var resultItemSchema2 = external_exports.object({
16489
+ id: external_exports.string(),
16490
+ createdAt: external_exports.string(),
16491
+ updatedAt: external_exports.string(),
16492
+ ofType: external_exports.string(),
16493
+ fields: external_exports.looseObject({}),
16494
+ namespace: external_exports.string(),
16495
+ directives: external_exports.array(external_exports.string())
16496
+ });
16497
+ var resultSchema14 = external_exports.object({
16498
+ nextToken: external_exports.string().nullable(),
16499
+ items: external_exports.array(resultItemSchema2)
16500
+ });
16501
+ var listTypeSchema = {
16502
+ params: paramsSchema14,
16503
+ result: resultSchema14
16504
+ };
16505
+
16506
+ // ../declarations/src/flows/schemas/logic.schema.ts
16507
+ var paramsSchema15 = external_exports.looseObject({});
16508
+ var resultSchema15 = external_exports.looseObject({});
16509
+ var logicSchema = {
16510
+ params: paramsSchema15,
16511
+ result: resultSchema15
16512
+ };
16513
+
16514
+ // ../declarations/src/flows/schemas/notify-websocket.schema.ts
16515
+ var paramsSchema16 = external_exports.object({
16516
+ record: external_exports.object({
16517
+ id: external_exports.string().optional(),
16518
+ ofType: external_exports.string().optional(),
16519
+ namespace: external_exports.string().optional(),
16520
+ connections: external_exports.object({
16521
+ first: external_exports.object({
16522
+ with: external_exports.string(),
16523
+ link: external_exports.string()
16524
+ }).optional(),
16525
+ second: external_exports.object({
16526
+ with: external_exports.string(),
16527
+ link: external_exports.string()
16528
+ }).optional()
16529
+ }).optional()
16530
+ }).optional(),
16531
+ operation: external_exports.enum(["INSERT", "UPDATE", "DELETE"]).optional()
16532
+ });
16533
+ var resultSchema16 = external_exports.looseObject({});
16534
+ var notifyWebSocketSchema = {
16535
+ params: paramsSchema16,
16536
+ result: resultSchema16
16537
+ };
16538
+
16539
+ // ../declarations/src/flows/schemas/openai-image-generation.schema.ts
16540
+ var dallE3ParamsSchema = external_exports.object({
16541
+ model: external_exports.literal("dall-e-3"),
16542
+ prompt: external_exports.string(),
16543
+ quality: external_exports.enum(["standard", "hd"]).optional(),
16544
+ size: external_exports.enum(["1024x1024", "1792x1024", "1024x1792"]).optional(),
16545
+ style: external_exports.enum(["vivid", "natural"]).optional(),
16546
+ outputFilename: external_exports.string().optional(),
16547
+ apiKey: external_exports.string().optional()
16548
+ });
16549
+ var dallE2ParamsSchema = external_exports.object({
16550
+ model: external_exports.literal("dall-e-2"),
16551
+ prompt: external_exports.string(),
16552
+ size: external_exports.enum(["256x256", "512x512", "1024x1024"]).optional(),
16553
+ n: external_exports.literal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).optional(),
16554
+ outputFilename: external_exports.string().optional(),
16555
+ apiKey: external_exports.string().optional()
16556
+ });
16557
+ var paramsSchema17 = external_exports.discriminatedUnion("model", [
16558
+ dallE3ParamsSchema,
16559
+ dallE2ParamsSchema
16560
+ ]);
16561
+ var resultSuccessSchema = external_exports.object({
16562
+ type: external_exports.literal("result"),
16563
+ url: external_exports.string(),
16564
+ key: external_exports.string(),
16565
+ mimeType: external_exports.string()
16566
+ });
16567
+ var resultErrorSchema = external_exports.object({
16568
+ type: external_exports.literal("error"),
16569
+ value: external_exports.string()
16570
+ });
16571
+ var resultSchema17 = external_exports.union([resultSuccessSchema, resultErrorSchema]);
16572
+ var openAIImageGenerationSchema = {
16573
+ params: paramsSchema17,
16574
+ result: resultSchema17
16575
+ };
16576
+
16577
+ // ../declarations/src/flows/schemas/type.schema.ts
16578
+ var paramsSchema18 = external_exports.object({
16579
+ id: external_exports.string(),
16580
+ ofType: external_exports.string(),
16581
+ namespace: external_exports.string().optional(),
16582
+ dynamicArgs: external_exports.looseObject({}).optional()
16583
+ });
16584
+ var resultSchema18 = external_exports.object({
16585
+ id: external_exports.string(),
16586
+ createdAt: external_exports.string(),
16587
+ updatedAt: external_exports.string(),
16588
+ ofType: external_exports.string(),
16589
+ fields: external_exports.looseObject({}),
16590
+ namespace: external_exports.string(),
16591
+ directives: external_exports.array(external_exports.string())
16592
+ });
16593
+ var typeSchema = {
16594
+ params: paramsSchema18,
16595
+ result: resultSchema18
16596
+ };
16597
+
16598
+ // ../declarations/src/flows/schemas/update-type.schema.ts
16599
+ var paramsSchema19 = external_exports.object({
16600
+ id: external_exports.string(),
16601
+ ofType: external_exports.string(),
16602
+ fields: external_exports.looseObject({}).optional(),
16603
+ connections: external_exports.looseObject({}).optional(),
16604
+ namespace: external_exports.string().optional(),
16605
+ directives: external_exports.array(external_exports.string()).optional(),
16606
+ dynamicArgs: external_exports.looseObject({}).optional()
16607
+ });
16608
+ var resultSchema19 = external_exports.object({
16609
+ id: external_exports.string(),
16610
+ createdAt: external_exports.string(),
16611
+ updatedAt: external_exports.string(),
16612
+ ofType: external_exports.string(),
16613
+ fields: external_exports.looseObject({}),
16614
+ namespace: external_exports.string()
16615
+ });
16616
+ var updateTypeSchema = {
16617
+ params: paramsSchema19,
16618
+ result: resultSchema19
16619
+ };
16620
+
16621
+ // ../declarations/src/flows/schemas/index.ts
16622
+ var schemas = {
16623
+ batchCreateType: batchCreateTypeSchema,
16624
+ batchGetType: batchGetTypeSchema,
16625
+ createType: createTypeSchema,
16626
+ deleteType: deleteTypeSchema,
16627
+ elevenLabsTTS: elevenlabsTTSSchema,
16628
+ googleSearch: googleSearchSchema,
16629
+ htmlToPdf: htmlToPdfSchema,
16630
+ httpRequest: httpRequestSchema,
16631
+ logic: logicSchema,
16632
+ linkScraper: linkScraperSchema,
16633
+ listTypeByParent: listTypeByParentSchema,
16634
+ listType: listTypeSchema,
16635
+ notifyWebSocket: notifyWebSocketSchema,
16636
+ openAIImageGeneration: openAIImageGenerationSchema,
16637
+ type: typeSchema,
16638
+ updateType: updateTypeSchema,
16639
+ extractImageMetadata: extractImageMetadataSchema,
16640
+ cloudFunction: cloudFunctionTypeSchema,
16641
+ genericAI: genericAIStepSchema
16642
+ };
16643
+
15742
16644
  // ../dsl-builders/src/apps/app-builder.ts
15743
16645
  var app_builder_exports = {};
15744
16646
  __export(app_builder_exports, {
@@ -21933,10 +22835,636 @@ function validateBlockLocalizations(pages, supportedLocales) {
21933
22835
  visit(p.blocks, p.name);
21934
22836
  }
21935
22837
  }
22838
+
22839
+ // ../dsl-builders/src/flows/flow-builder.ts
22840
+ var flow_builder_exports = {};
22841
+ __export(flow_builder_exports, {
22842
+ TABLE_ID_PARAM_NAMES: () => TABLE_ID_PARAM_NAMES,
22843
+ buildFlow: () => buildFlow,
22844
+ js: () => js,
22845
+ secret: () => secret,
22846
+ step: () => step,
22847
+ trigger: () => trigger
22848
+ });
22849
+
22850
+ // ../dsl-builders/src/flows/params.ts
22851
+ var SECRET_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
22852
+ function js(code) {
22853
+ if (typeof code !== "string" || code.trim().length === 0) {
22854
+ throw new Error("js() requires a non-empty code string");
22855
+ }
22856
+ return { __flowParam: "js", code };
22857
+ }
22858
+ function secret(secretId) {
22859
+ if (typeof secretId !== "string" || !SECRET_ID_PATTERN.test(secretId)) {
22860
+ throw new Error(
22861
+ `secret() expects a secret record ID (a UUID \u2014 discover secrets via data_list with ofType "secret"), got ${JSON.stringify(
22862
+ secretId
22863
+ )}. Never pass secret values directly.`
22864
+ );
22865
+ }
22866
+ return { __flowParam: "secret", secretId };
22867
+ }
22868
+ function isJsParam(value) {
22869
+ return typeof value === "object" && value !== null && value.__flowParam === "js";
22870
+ }
22871
+ function isSecretParam(value) {
22872
+ return typeof value === "object" && value !== null && value.__flowParam === "secret";
22873
+ }
22874
+ function isFlowParamMarker(value) {
22875
+ return isJsParam(value) || isSecretParam(value);
22876
+ }
22877
+ function isPlainObject2(value) {
22878
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !isFlowParamMarker(value);
22879
+ }
22880
+ function containsMarker(value) {
22881
+ if (isFlowParamMarker(value)) return true;
22882
+ if (Array.isArray(value)) return value.some(containsMarker);
22883
+ if (typeof value === "object" && value !== null) {
22884
+ return Object.values(value).some(containsMarker);
22885
+ }
22886
+ return false;
22887
+ }
22888
+ function lowerParamValue(value, path) {
22889
+ if (isSecretParam(value)) {
22890
+ return { value: value.secretId, config: { type: "secret" } };
22891
+ }
22892
+ if (isJsParam(value)) {
22893
+ return { value: value.code, config: { type: "logic", language: "js" } };
22894
+ }
22895
+ if (Array.isArray(value)) {
22896
+ if (value.some(containsMarker)) {
22897
+ throw new Error(
22898
+ `Param "${path}": js()/secret() markers inside arrays are not supported \u2014 wrap the whole array in js(...)`
22899
+ );
22900
+ }
22901
+ return { value, config: { type: "logic", language: "static" } };
22902
+ }
22903
+ if (isPlainObject2(value)) {
22904
+ if (!containsMarker(value)) {
22905
+ return { value, config: { type: "logic", language: "static" } };
22906
+ }
22907
+ const loweredValue = {};
22908
+ const subParams = {};
22909
+ for (const [key, entry] of Object.entries(value)) {
22910
+ const lowered = lowerParamValue(entry, `${path}.${key}`);
22911
+ loweredValue[key] = lowered.value;
22912
+ if (lowered.config) {
22913
+ subParams[key] = lowered.config;
22914
+ }
22915
+ }
22916
+ return { value: loweredValue, config: { type: "object", subParams } };
22917
+ }
22918
+ return { value };
22919
+ }
22920
+ function lowerParams(params) {
22921
+ const loweredParams = {};
22922
+ const paramsConfig = {};
22923
+ for (const [key, value] of Object.entries(params)) {
22924
+ if (value === void 0) continue;
22925
+ const lowered = lowerParamValue(value, key);
22926
+ loweredParams[key] = lowered.value;
22927
+ if (lowered.config) {
22928
+ paramsConfig[key] = lowered.config;
22929
+ }
22930
+ }
22931
+ return Object.keys(paramsConfig).length > 0 ? { params: loweredParams, paramsConfig } : { params: loweredParams };
22932
+ }
22933
+
22934
+ // ../dsl-builders/src/flows/validate.ts
22935
+ var KNOWN_SECRET_PARAMS = {
22936
+ ["elevenLabsTTS" /* elevenLabsTTS */]: ["apiKey"],
22937
+ ["googleSearch" /* googleSearch */]: ["apiKey"],
22938
+ ["openAIImageGeneration" /* openAIImageGeneration */]: ["apiKey"],
22939
+ ["genericAI" /* genericAI */]: ["apiKey"]
22940
+ };
22941
+ var WRITE_STEP_OPERATIONS = {
22942
+ ["createType" /* createType */]: "INSERT",
22943
+ ["batchCreateType" /* batchCreateType */]: "INSERT",
22944
+ ["updateType" /* updateType */]: "MODIFY",
22945
+ ["deleteType" /* deleteType */]: "REMOVE"
22946
+ };
22947
+ function isStaticParamConfig(config2) {
22948
+ return !config2 || config2.type !== "secret" && config2.type !== "object" && config2.language === "static";
22949
+ }
22950
+ function collectWriteSteps(declaration) {
22951
+ const staticWrites = [];
22952
+ const dynamicWrites = [];
22953
+ for (const step2 of Object.values(declaration.steps)) {
22954
+ if (step2.type === "cloudFunction" /* cloudFunction */) {
22955
+ dynamicWrites.push({
22956
+ stepName: step2.name,
22957
+ reason: "cloudFunction steps can perform arbitrary writes"
22958
+ });
22959
+ continue;
22960
+ }
22961
+ const operation = WRITE_STEP_OPERATIONS[step2.type];
22962
+ if (!operation) continue;
22963
+ const params = step2.params;
22964
+ const ofTypeConfig = step2.paramsConfig?.ofType;
22965
+ if (isStaticParamConfig(ofTypeConfig) && typeof params.ofType === "string") {
22966
+ staticWrites.push({ stepName: step2.name, ofType: params.ofType, operation });
22967
+ } else {
22968
+ dynamicWrites.push({
22969
+ stepName: step2.name,
22970
+ reason: `"ofType" is dynamic, so the written table cannot be determined statically`
22971
+ });
22972
+ }
22973
+ }
22974
+ return { staticWrites, dynamicWrites };
22975
+ }
22976
+ function hasNonEmptyCondition(condition) {
22977
+ if (condition === void 0 || condition === null) return false;
22978
+ if (typeof condition === "string") return condition.trim().length > 0;
22979
+ if (typeof condition === "object") return Object.keys(condition).length > 0;
22980
+ return true;
22981
+ }
22982
+ function collectTableDataChangeTriggers(declaration) {
22983
+ const triggers = [];
22984
+ for (const [triggerName, trigger2] of Object.entries(declaration.triggers)) {
22985
+ if (trigger2.variant !== "TABLE_DATA_CHANGE" /* TABLE_DATA_CHANGE */) continue;
22986
+ triggers.push({
22987
+ triggerName,
22988
+ tableId: trigger2.tableId,
22989
+ operation: trigger2.operation,
22990
+ hasCondition: hasNonEmptyCondition(trigger2.condition)
22991
+ });
22992
+ }
22993
+ return triggers;
22994
+ }
22995
+ function collectNonStaticPaths(paramsConfig, prefix = "") {
22996
+ if (!paramsConfig) return [];
22997
+ const paths = [];
22998
+ for (const [key, config2] of Object.entries(paramsConfig)) {
22999
+ const path = prefix ? `${prefix}.${key}` : key;
23000
+ if (config2.type === "object") {
23001
+ paths.push(...collectNonStaticPaths(config2.subParams, path));
23002
+ } else if (config2.type === "secret" || config2.language === "js") {
23003
+ paths.push(path);
23004
+ }
23005
+ }
23006
+ return paths;
23007
+ }
23008
+ function walkSecretLeaves(params, paramsConfig, visit, prefix = "") {
23009
+ if (!paramsConfig) return;
23010
+ for (const [key, config2] of Object.entries(paramsConfig)) {
23011
+ const path = prefix ? `${prefix}.${key}` : key;
23012
+ const value = params?.[key];
23013
+ if (config2.type === "object") {
23014
+ walkSecretLeaves(
23015
+ value ?? {},
23016
+ config2.subParams,
23017
+ visit,
23018
+ path
23019
+ );
23020
+ } else if (config2.type === "secret") {
23021
+ visit(path, value);
23022
+ }
23023
+ }
23024
+ }
23025
+ function collectSecretIds(declaration) {
23026
+ const ids = /* @__PURE__ */ new Set();
23027
+ for (const step2 of Object.values(declaration.steps ?? {})) {
23028
+ walkSecretLeaves(
23029
+ step2.params,
23030
+ step2.paramsConfig,
23031
+ (_path, value) => {
23032
+ if (typeof value === "string") {
23033
+ ids.add(value);
23034
+ }
23035
+ }
23036
+ );
23037
+ }
23038
+ return [...ids];
23039
+ }
23040
+ function validateStepParams(step2, issue2, errors, warnings) {
23041
+ const params = step2.params;
23042
+ const paramsConfig = step2.paramsConfig;
23043
+ walkSecretLeaves(params, paramsConfig, (path, value) => {
23044
+ if (typeof value !== "string" || !SECRET_ID_PATTERN.test(value)) {
23045
+ errors.push(
23046
+ issue2(
23047
+ `steps.${step2.name}.params.${path}`,
23048
+ `Step "${step2.name}": secret param "${path}" does not look like a secret record ID \u2014 secret values must never be embedded in the declaration`
23049
+ )
23050
+ );
23051
+ }
23052
+ });
23053
+ for (const paramName of KNOWN_SECRET_PARAMS[step2.type] ?? []) {
23054
+ if (params?.[paramName] === void 0) continue;
23055
+ const config2 = paramsConfig?.[paramName];
23056
+ const isProtected = config2 && (config2.type === "secret" || config2.type !== "object" && config2.language === "js");
23057
+ if (!isProtected) {
23058
+ errors.push(
23059
+ issue2(
23060
+ `steps.${step2.name}.params.${paramName}`,
23061
+ `Step "${step2.name}": param "${paramName}" holds a credential and must be a secret reference, not a plain value`
23062
+ )
23063
+ );
23064
+ }
23065
+ }
23066
+ const schema = schemas[step2.type];
23067
+ if (!schema) return;
23068
+ const parsed = schema.params.safeParse(params);
23069
+ if (parsed.success) return;
23070
+ const nonStaticPaths = collectNonStaticPaths(paramsConfig);
23071
+ for (const zodIssue of parsed.error.issues) {
23072
+ const issuePath = zodIssue.path.map(String).join(".");
23073
+ const coveredByDynamicValue = nonStaticPaths.some(
23074
+ (path) => path === issuePath || path.startsWith(`${issuePath}.`) || issuePath.startsWith(`${path}.`)
23075
+ );
23076
+ if (coveredByDynamicValue) continue;
23077
+ warnings.push(
23078
+ issue2(
23079
+ `steps.${step2.name}.params${issuePath ? `.${issuePath}` : ""}`,
23080
+ `Step "${step2.name}": params do not match the "${step2.type}" schema${issuePath ? ` at "${issuePath}"` : ""}: ${zodIssue.message}`
23081
+ )
23082
+ );
23083
+ }
23084
+ }
23085
+ function tableIdsMatch(a, b) {
23086
+ return a.toLowerCase() === b.toLowerCase();
23087
+ }
23088
+ function validateFlow(declaration, ctx) {
23089
+ const errors = [];
23090
+ const warnings = [];
23091
+ const issue2 = (path, message) => ({
23092
+ ...ctx?.flowId !== void 0 ? { flowId: ctx.flowId } : {},
23093
+ ...ctx?.name !== void 0 ? { flowName: ctx.name } : {},
23094
+ path,
23095
+ message
23096
+ });
23097
+ const steps = declaration.steps ?? {};
23098
+ const stepNames = Object.keys(steps);
23099
+ for (const [key, step2] of Object.entries(steps)) {
23100
+ if (step2.name !== key) {
23101
+ errors.push(
23102
+ issue2(
23103
+ `steps.${key}`,
23104
+ `Step key "${key}" does not match its name "${step2.name}"`
23105
+ )
23106
+ );
23107
+ }
23108
+ }
23109
+ if (declaration.startStep === null) {
23110
+ if (stepNames.length === 0) {
23111
+ warnings.push(issue2("startStep", "Flow has no steps and does nothing"));
23112
+ } else {
23113
+ warnings.push(
23114
+ issue2(
23115
+ "startStep",
23116
+ "startStep is null \u2014 the declared steps are never executed"
23117
+ )
23118
+ );
23119
+ }
23120
+ } else if (!(declaration.startStep in steps)) {
23121
+ errors.push(
23122
+ issue2(
23123
+ "startStep",
23124
+ `startStep "${declaration.startStep}" does not exist in steps`
23125
+ )
23126
+ );
23127
+ }
23128
+ for (const step2 of Object.values(steps)) {
23129
+ if (step2.nextStep !== null && !(step2.nextStep in steps)) {
23130
+ errors.push(
23131
+ issue2(
23132
+ `steps.${step2.name}.nextStep`,
23133
+ `Step "${step2.name}" points to unknown step "${step2.nextStep}"`
23134
+ )
23135
+ );
23136
+ }
23137
+ }
23138
+ const visited = /* @__PURE__ */ new Set();
23139
+ let current2 = declaration.startStep;
23140
+ while (current2 !== null && current2 in steps) {
23141
+ if (visited.has(current2)) {
23142
+ errors.push(
23143
+ issue2(
23144
+ `steps.${current2}.nextStep`,
23145
+ `Step "${current2}" is executed twice \u2014 steps must form a linked list; nextStep must not point to itself or a previous step`
23146
+ )
23147
+ );
23148
+ break;
23149
+ }
23150
+ visited.add(current2);
23151
+ current2 = steps[current2].nextStep;
23152
+ }
23153
+ for (const name of stepNames) {
23154
+ if (!visited.has(name)) {
23155
+ warnings.push(
23156
+ issue2(
23157
+ `steps.${name}`,
23158
+ `Step "${name}" is not reachable from startStep`
23159
+ )
23160
+ );
23161
+ }
23162
+ }
23163
+ for (const step2 of Object.values(steps)) {
23164
+ validateStepParams(step2, issue2, errors, warnings);
23165
+ }
23166
+ const { staticWrites, dynamicWrites } = collectWriteSteps(declaration);
23167
+ const tableTriggers = collectTableDataChangeTriggers(declaration);
23168
+ for (const write of staticWrites) {
23169
+ for (const trigger2 of tableTriggers) {
23170
+ if (trigger2.operation !== write.operation || !tableIdsMatch(trigger2.tableId, write.ofType)) {
23171
+ continue;
23172
+ }
23173
+ const message = `Step "${write.stepName}" writes table "${write.ofType}" (${write.operation}) which retriggers this flow via trigger "${trigger2.triggerName}"`;
23174
+ if (trigger2.hasCondition) {
23175
+ warnings.push(
23176
+ issue2(
23177
+ `steps.${write.stepName}`,
23178
+ `${message} \u2014 the trigger condition may not terminate the recursion`
23179
+ )
23180
+ );
23181
+ } else {
23182
+ errors.push(issue2(`steps.${write.stepName}`, message));
23183
+ }
23184
+ }
23185
+ }
23186
+ for (const write of dynamicWrites) {
23187
+ warnings.push(
23188
+ issue2(
23189
+ `steps.${write.stepName}`,
23190
+ `Step "${write.stepName}": ${write.reason} \u2014 recursion cannot be statically verified`
23191
+ )
23192
+ );
23193
+ }
23194
+ return { errors, warnings };
23195
+ }
23196
+ function describeCycle(cycle, edges, flowsById) {
23197
+ const parts = [];
23198
+ for (let i = 0; i < cycle.length; i++) {
23199
+ const fromId = cycle[i];
23200
+ const toId = cycle[(i + 1) % cycle.length];
23201
+ const edge = (edges.get(fromId) ?? []).find((e) => e.toId === toId);
23202
+ const fromLabel = flowsById.get(fromId)?.name ?? fromId;
23203
+ const toLabel = flowsById.get(toId)?.name ?? toId;
23204
+ if (!edge) {
23205
+ parts.push(`"${fromLabel}" \u2192 "${toLabel}"`);
23206
+ continue;
23207
+ }
23208
+ parts.push(
23209
+ `"${fromLabel}" step "${edge.stepName}" writes "${edge.tableId}" (${edge.operation}) \u2192 "${toLabel}" trigger "${edge.triggerName}"${edge.hasCondition ? " [conditioned]" : ""}`
23210
+ );
23211
+ }
23212
+ return parts.join("; ");
23213
+ }
23214
+ function validateFlowGraph(flows) {
23215
+ const errors = [];
23216
+ const flowsById = new Map(flows.map((flow) => [flow.id, flow]));
23217
+ const edges = /* @__PURE__ */ new Map();
23218
+ for (const from of flows) {
23219
+ if (from.declaration.disabled === true) continue;
23220
+ const { staticWrites } = collectWriteSteps(from.declaration);
23221
+ const outgoing = [];
23222
+ for (const write of staticWrites) {
23223
+ for (const to of flows) {
23224
+ if (to.id === from.id || to.declaration.disabled === true) continue;
23225
+ for (const trigger2 of collectTableDataChangeTriggers(to.declaration)) {
23226
+ if (trigger2.operation !== write.operation || !tableIdsMatch(trigger2.tableId, write.ofType)) {
23227
+ continue;
23228
+ }
23229
+ outgoing.push({
23230
+ fromId: from.id,
23231
+ toId: to.id,
23232
+ stepName: write.stepName,
23233
+ triggerName: trigger2.triggerName,
23234
+ tableId: write.ofType,
23235
+ operation: write.operation,
23236
+ hasCondition: trigger2.hasCondition
23237
+ });
23238
+ }
23239
+ }
23240
+ }
23241
+ edges.set(from.id, outgoing);
23242
+ }
23243
+ const reportedCycles = /* @__PURE__ */ new Set();
23244
+ const visiting = /* @__PURE__ */ new Set();
23245
+ const done = /* @__PURE__ */ new Set();
23246
+ const stack = [];
23247
+ const visit = (id) => {
23248
+ if (done.has(id)) return;
23249
+ visiting.add(id);
23250
+ stack.push(id);
23251
+ for (const edge of edges.get(id) ?? []) {
23252
+ if (visiting.has(edge.toId)) {
23253
+ const cycle = stack.slice(stack.indexOf(edge.toId));
23254
+ const canonicalStart = cycle.indexOf([...cycle].sort()[0]);
23255
+ const canonical = [
23256
+ ...cycle.slice(canonicalStart),
23257
+ ...cycle.slice(0, canonicalStart)
23258
+ ];
23259
+ const key = canonical.join("\u2192");
23260
+ if (!reportedCycles.has(key)) {
23261
+ reportedCycles.add(key);
23262
+ const flow = flowsById.get(canonical[0]);
23263
+ errors.push({
23264
+ flowId: canonical[0],
23265
+ ...flow?.name !== void 0 ? { flowName: flow.name } : {},
23266
+ path: "triggers",
23267
+ message: `Circular flow chain detected: ${describeCycle(canonical, edges, flowsById)}`
23268
+ });
23269
+ }
23270
+ continue;
23271
+ }
23272
+ if (!done.has(edge.toId)) {
23273
+ visit(edge.toId);
23274
+ }
23275
+ }
23276
+ stack.pop();
23277
+ visiting.delete(id);
23278
+ done.add(id);
23279
+ };
23280
+ for (const flow of flows) {
23281
+ visit(flow.id);
23282
+ }
23283
+ return { errors, warnings: [] };
23284
+ }
23285
+ function validateFlows(flows, opts) {
23286
+ const errors = [];
23287
+ const warnings = [];
23288
+ const idsToValidate = opts?.flowIdsToValidate ? new Set(opts.flowIdsToValidate) : null;
23289
+ for (const flow of flows) {
23290
+ if (idsToValidate && !idsToValidate.has(flow.id)) continue;
23291
+ const result = validateFlow(flow.declaration, {
23292
+ flowId: flow.id,
23293
+ name: flow.name
23294
+ });
23295
+ errors.push(...result.errors);
23296
+ warnings.push(...result.warnings);
23297
+ }
23298
+ const graphResult = validateFlowGraph(flows);
23299
+ errors.push(...graphResult.errors);
23300
+ warnings.push(...graphResult.warnings);
23301
+ return { errors, warnings };
23302
+ }
23303
+
23304
+ // ../dsl-builders/src/flows/flow-builder.ts
23305
+ var trigger = {
23306
+ tableDataChange(opts) {
23307
+ return {
23308
+ variant: "TABLE_DATA_CHANGE" /* TABLE_DATA_CHANGE */,
23309
+ // The webapp stores lowercase table ids (its pickers match on them);
23310
+ // the runtime matches case-insensitively either way.
23311
+ tableId: opts.tableId.toLowerCase(),
23312
+ operation: opts.operation,
23313
+ ...opts.condition !== void 0 ? { condition: opts.condition } : {}
23314
+ };
23315
+ },
23316
+ schedule(opts) {
23317
+ return {
23318
+ variant: "SCHEDULE" /* SCHEDULE */,
23319
+ ...opts?.condition !== void 0 ? { condition: opts.condition } : {}
23320
+ };
23321
+ },
23322
+ manual(opts) {
23323
+ return {
23324
+ variant: "MANUAL" /* MANUAL */,
23325
+ ...opts?.condition !== void 0 ? { condition: opts.condition } : {}
23326
+ };
23327
+ }
23328
+ };
23329
+ function createStepFactory(type) {
23330
+ return (name, opts) => ({
23331
+ name,
23332
+ type,
23333
+ ...opts.description !== void 0 ? { description: opts.description } : {},
23334
+ params: opts.params,
23335
+ ...opts.next !== void 0 ? { next: opts.next } : {},
23336
+ ...opts.skipIf !== void 0 ? { skipIf: opts.skipIf } : {},
23337
+ ...opts.continueIf !== void 0 ? { continueIf: opts.continueIf } : {},
23338
+ ...opts.passThroughCondition !== void 0 ? { passThroughCondition: opts.passThroughCondition } : {}
23339
+ });
23340
+ }
23341
+ var step = {
23342
+ batchCreateType: createStepFactory("batchCreateType" /* batchCreateType */),
23343
+ batchGetType: createStepFactory("batchGetType" /* batchGetType */),
23344
+ createType: createStepFactory("createType" /* createType */),
23345
+ deleteType: createStepFactory("deleteType" /* deleteType */),
23346
+ elevenLabsTTS: createStepFactory("elevenLabsTTS" /* elevenLabsTTS */),
23347
+ googleSearch: createStepFactory("googleSearch" /* googleSearch */),
23348
+ htmlToPdf: createStepFactory("htmlToPdf" /* htmlToPdf */),
23349
+ httpRequest: createStepFactory("httpRequest" /* httpRequest */),
23350
+ logic: createStepFactory("logic" /* logic */),
23351
+ linkScraper: createStepFactory("linkScraper" /* linkScraper */),
23352
+ listTypeByParent: createStepFactory("listTypeByParent" /* listTypeByParent */),
23353
+ listType: createStepFactory("listType" /* listType */),
23354
+ notifyWebSocket: createStepFactory("notifyWebSocket" /* notifyWebSocket */),
23355
+ openAIImageGeneration: createStepFactory("openAIImageGeneration" /* openAIImageGeneration */),
23356
+ type: createStepFactory("type" /* type */),
23357
+ updateType: createStepFactory("updateType" /* updateType */),
23358
+ extractImageMetadata: createStepFactory("extractImageMetadata" /* extractImageMetadata */),
23359
+ cloudFunction: createStepFactory("cloudFunction" /* cloudFunction */),
23360
+ genericAI: createStepFactory("genericAI" /* genericAI */)
23361
+ };
23362
+ function buildDeclarationStep(definition, nextStep, errors) {
23363
+ for (const paramName of KNOWN_SECRET_PARAMS[definition.type] ?? []) {
23364
+ const value = definition.params[paramName];
23365
+ if (value !== void 0 && !isFlowParamMarker(value)) {
23366
+ errors.push(
23367
+ `Step "${definition.name}": param "${paramName}" holds a credential and must use secret("<secretRecordId>") instead of a plain value`
23368
+ );
23369
+ }
23370
+ }
23371
+ const { params, paramsConfig } = lowerParams(definition.params);
23372
+ lowercaseStaticTableIdParams(params, paramsConfig);
23373
+ return {
23374
+ // The webapp stores id === key on every step; keep that convention.
23375
+ id: definition.name,
23376
+ name: definition.name,
23377
+ type: definition.type,
23378
+ ...definition.description !== void 0 ? { description: definition.description } : {},
23379
+ params,
23380
+ nextStep,
23381
+ ...paramsConfig ? { paramsConfig } : {},
23382
+ // Conditions are always explicit — the webapp step form expects them and
23383
+ // treats an absent skipCondition as "always skip".
23384
+ skipCondition: definition.skipIf ?? "false;",
23385
+ skipConditionLanguage: "js",
23386
+ continueCondition: definition.continueIf ?? "true;",
23387
+ continueConditionLanguage: "js",
23388
+ ...definition.passThroughCondition !== void 0 ? { passThroughCondition: definition.passThroughCondition } : {}
23389
+ };
23390
+ }
23391
+ var TABLE_ID_PARAM_NAMES = ["ofType", "parentType"];
23392
+ function isStaticConfig(config2) {
23393
+ if (!config2) return true;
23394
+ return config2.type !== "secret" && config2.type !== "object" && config2.language === "static";
23395
+ }
23396
+ function lowercaseStaticTableIdParams(params, paramsConfig) {
23397
+ for (const paramName of TABLE_ID_PARAM_NAMES) {
23398
+ const value = params[paramName];
23399
+ if (typeof value === "string" && isStaticConfig(paramsConfig?.[paramName])) {
23400
+ params[paramName] = value.toLowerCase();
23401
+ }
23402
+ }
23403
+ }
23404
+ function buildFlow(opts) {
23405
+ const errors = [];
23406
+ const chainSteps = opts.steps;
23407
+ const detachedSteps = opts.detachedSteps ?? [];
23408
+ const allSteps = [...chainSteps, ...detachedSteps];
23409
+ const seenNames = /* @__PURE__ */ new Set();
23410
+ for (const definition of allSteps) {
23411
+ if (seenNames.has(definition.name)) {
23412
+ errors.push(`Duplicate step name "${definition.name}"`);
23413
+ }
23414
+ seenNames.add(definition.name);
23415
+ }
23416
+ const steps = {};
23417
+ for (let i = 0; i < chainSteps.length; i++) {
23418
+ const definition = chainSteps[i];
23419
+ const nextStep = definition.next !== void 0 ? definition.next : chainSteps[i + 1]?.name ?? null;
23420
+ steps[definition.name] = buildDeclarationStep(definition, nextStep, errors);
23421
+ }
23422
+ for (const definition of detachedSteps) {
23423
+ if (definition.next === void 0) {
23424
+ errors.push(
23425
+ `Detached step "${definition.name}" requires an explicit "next" (step name or null)`
23426
+ );
23427
+ }
23428
+ steps[definition.name] = buildDeclarationStep(
23429
+ definition,
23430
+ definition.next ?? null,
23431
+ errors
23432
+ );
23433
+ }
23434
+ const triggers = {};
23435
+ for (const [name, definition] of Object.entries(opts.triggers)) {
23436
+ triggers[name] = { name, ...definition };
23437
+ }
23438
+ const declaration = {
23439
+ triggers,
23440
+ startStep: chainSteps.length > 0 ? chainSteps[0].name : null,
23441
+ steps,
23442
+ ...opts.debug !== void 0 ? { debug: opts.debug } : {},
23443
+ ...opts.disabled !== void 0 ? { disabled: opts.disabled } : {}
23444
+ };
23445
+ const validation = validateFlow(declaration, { name: opts.name });
23446
+ errors.push(...validation.errors.map((issue2) => issue2.message));
23447
+ if (errors.length > 0) {
23448
+ const label = opts.name ? `Flow "${opts.name}"` : "Flow";
23449
+ throw new Error(
23450
+ `${label} is invalid:
23451
+ ${errors.map((message) => `- ${message}`).join("\n")}`
23452
+ );
23453
+ }
23454
+ return {
23455
+ ...opts.name !== void 0 ? { name: opts.name } : {},
23456
+ declaration
23457
+ };
23458
+ }
21936
23459
  export {
21937
23460
  PublishingTypeEnum,
21938
23461
  app_builder_exports as appBuilder,
23462
+ collectSecretIds,
21939
23463
  builder_exports as dataBuilder,
21940
23464
  dataSchemaDeclarationSchema,
21941
- macros_exports as macros
23465
+ flow_builder_exports as flowBuilder,
23466
+ macros_exports as macros,
23467
+ validateFlow,
23468
+ validateFlowGraph,
23469
+ validateFlows
21942
23470
  };