@superblocksteam/cli 2.0.78-next.1 → 2.0.78-next.3

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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/{acorn-QNZSI57H.js → acorn-EJA5B7FP.js} +3 -3
  3. package/dist/{angular-7GLMKT4B.js → angular-QQ2WOG6C.js} +3 -3
  4. package/dist/{api-MW4QAIKQ.js → api-7L7HXK2Z.js} +4 -4
  5. package/dist/{babel-XQ6PH5O6.js → babel-NVPZF666.js} +3 -3
  6. package/dist/{chunk-LMLFDJMT.js → chunk-57CSOFCV.js} +2 -2
  7. package/dist/{chunk-VXXN7VAS.js → chunk-HFNLESLL.js} +3 -3
  8. package/dist/{chunk-MNG6L2B7.js → chunk-IS6Q74C4.js} +4 -4
  9. package/dist/{chunk-HJDBL2HA.js → chunk-NFYAKJB4.js} +3 -3
  10. package/dist/{chunk-YQJDTEQK.js → chunk-PLLSDKTJ.js} +3 -3
  11. package/dist/{chunk-EE6CKE6T.js → chunk-PM5NBNL6.js} +3 -3
  12. package/dist/{chunk-VH6NHAEM.js → chunk-S5EPDX4F.js} +3 -3
  13. package/dist/{chunk-LGNYNJ5L.js → chunk-UBEDKAGT.js} +4 -4
  14. package/dist/{chunk-64EHFXFV.js → chunk-VVRV7UV6.js} +3 -3
  15. package/dist/{chunk-QQG4FNHC.js → chunk-XJJXWXNQ.js} +3 -3
  16. package/dist/{cli-truncate-U6OXMKNW.js → cli-truncate-U73CWGQU.js} +5 -5
  17. package/dist/commands/dev-parent.js +2 -2
  18. package/dist/{embedded-playwright-mcp-server-4WD5ISA6.js → embedded-playwright-mcp-server-Q5Q7ZEGQ.js} +3 -3
  19. package/dist/{enquirer-QUEJAKCK.js → enquirer-J65AFP3I.js} +4 -4
  20. package/dist/{estree-7SXRLI5I.js → estree-ADKPQFNO.js} +3 -3
  21. package/dist/{flow-CVSSBGEP.js → flow-V6WNZYJM.js} +3 -3
  22. package/dist/{getMachineId-bsd-ZPWHUTI7.js → getMachineId-bsd-7END53IL.js} +5 -5
  23. package/dist/{getMachineId-darwin-DQ6EFB3W.js → getMachineId-darwin-JNUXDADV.js} +5 -5
  24. package/dist/{getMachineId-linux-X2ORZCWZ.js → getMachineId-linux-KRZF2UV7.js} +4 -4
  25. package/dist/{getMachineId-unsupported-QU74FCZZ.js → getMachineId-unsupported-TAQP2SYG.js} +4 -4
  26. package/dist/{getMachineId-win-3QIEGI2M.js → getMachineId-win-TNE5Z3HM.js} +5 -5
  27. package/dist/{glimmer-5GCQJXOY.js → glimmer-DHGQ6PNF.js} +3 -3
  28. package/dist/{graphql-3HSRKBX7.js → graphql-H56NIUJ6.js} +3 -3
  29. package/dist/{html-IQZPOTBM.js → html-SH62JMIZ.js} +3 -3
  30. package/dist/index.js +445 -160
  31. package/dist/index.js.map +1 -1
  32. package/dist/{jiti-FEG3RQVN.js → jiti-LBBXQX3J.js} +3 -3
  33. package/dist/{log-update-WREO4XZW.js → log-update-ZA35WCU2.js} +6 -6
  34. package/dist/{markdown-O5SQIL7M.js → markdown-FAL4TQWL.js} +3 -3
  35. package/dist/{meriyah-T32DYUAK.js → meriyah-L75AUO6W.js} +3 -3
  36. package/dist/{postcss-AJG6TRN6.js → postcss-545WOE37.js} +3 -3
  37. package/dist/{read-pkg-A6FS4QAJ.js → read-pkg-2KLNX5TL.js} +4 -4
  38. package/dist/{spans-UK3VDT2L.js → spans-BJZB75HQ.js} +4 -4
  39. package/dist/{src-TQFTP2OE.js → src-24P2RGTU.js} +3 -3
  40. package/dist/{typescript-RFGACGWX.js → typescript-OIYGWQQM.js} +3 -3
  41. package/dist/{wrap-ansi-4CW7YZCW.js → wrap-ansi-FLLI5RM7.js} +5 -5
  42. package/dist/{yaml-RVRXF4QM.js → yaml-OVN7LRUL.js} +3 -3
  43. package/oclif.manifest.json +1 -1
  44. package/package.json +4 -4
  45. /package/dist/{acorn-QNZSI57H.js.map → acorn-EJA5B7FP.js.map} +0 -0
  46. /package/dist/{angular-7GLMKT4B.js.map → angular-QQ2WOG6C.js.map} +0 -0
  47. /package/dist/{api-MW4QAIKQ.js.map → api-7L7HXK2Z.js.map} +0 -0
  48. /package/dist/{babel-XQ6PH5O6.js.map → babel-NVPZF666.js.map} +0 -0
  49. /package/dist/{chunk-LMLFDJMT.js.map → chunk-57CSOFCV.js.map} +0 -0
  50. /package/dist/{chunk-VXXN7VAS.js.map → chunk-HFNLESLL.js.map} +0 -0
  51. /package/dist/{chunk-MNG6L2B7.js.map → chunk-IS6Q74C4.js.map} +0 -0
  52. /package/dist/{chunk-HJDBL2HA.js.map → chunk-NFYAKJB4.js.map} +0 -0
  53. /package/dist/{chunk-YQJDTEQK.js.map → chunk-PLLSDKTJ.js.map} +0 -0
  54. /package/dist/{chunk-EE6CKE6T.js.map → chunk-PM5NBNL6.js.map} +0 -0
  55. /package/dist/{chunk-VH6NHAEM.js.map → chunk-S5EPDX4F.js.map} +0 -0
  56. /package/dist/{chunk-LGNYNJ5L.js.map → chunk-UBEDKAGT.js.map} +0 -0
  57. /package/dist/{chunk-64EHFXFV.js.map → chunk-VVRV7UV6.js.map} +0 -0
  58. /package/dist/{chunk-QQG4FNHC.js.map → chunk-XJJXWXNQ.js.map} +0 -0
  59. /package/dist/{cli-truncate-U6OXMKNW.js.map → cli-truncate-U73CWGQU.js.map} +0 -0
  60. /package/dist/{embedded-playwright-mcp-server-4WD5ISA6.js.map → embedded-playwright-mcp-server-Q5Q7ZEGQ.js.map} +0 -0
  61. /package/dist/{enquirer-QUEJAKCK.js.map → enquirer-J65AFP3I.js.map} +0 -0
  62. /package/dist/{estree-7SXRLI5I.js.map → estree-ADKPQFNO.js.map} +0 -0
  63. /package/dist/{flow-CVSSBGEP.js.map → flow-V6WNZYJM.js.map} +0 -0
  64. /package/dist/{getMachineId-bsd-ZPWHUTI7.js.map → getMachineId-bsd-7END53IL.js.map} +0 -0
  65. /package/dist/{getMachineId-darwin-DQ6EFB3W.js.map → getMachineId-darwin-JNUXDADV.js.map} +0 -0
  66. /package/dist/{getMachineId-linux-X2ORZCWZ.js.map → getMachineId-linux-KRZF2UV7.js.map} +0 -0
  67. /package/dist/{getMachineId-unsupported-QU74FCZZ.js.map → getMachineId-unsupported-TAQP2SYG.js.map} +0 -0
  68. /package/dist/{getMachineId-win-3QIEGI2M.js.map → getMachineId-win-TNE5Z3HM.js.map} +0 -0
  69. /package/dist/{glimmer-5GCQJXOY.js.map → glimmer-DHGQ6PNF.js.map} +0 -0
  70. /package/dist/{graphql-3HSRKBX7.js.map → graphql-H56NIUJ6.js.map} +0 -0
  71. /package/dist/{html-IQZPOTBM.js.map → html-SH62JMIZ.js.map} +0 -0
  72. /package/dist/{jiti-FEG3RQVN.js.map → jiti-LBBXQX3J.js.map} +0 -0
  73. /package/dist/{log-update-WREO4XZW.js.map → log-update-ZA35WCU2.js.map} +0 -0
  74. /package/dist/{markdown-O5SQIL7M.js.map → markdown-FAL4TQWL.js.map} +0 -0
  75. /package/dist/{meriyah-T32DYUAK.js.map → meriyah-L75AUO6W.js.map} +0 -0
  76. /package/dist/{postcss-AJG6TRN6.js.map → postcss-545WOE37.js.map} +0 -0
  77. /package/dist/{read-pkg-A6FS4QAJ.js.map → read-pkg-2KLNX5TL.js.map} +0 -0
  78. /package/dist/{spans-UK3VDT2L.js.map → spans-BJZB75HQ.js.map} +0 -0
  79. /package/dist/{src-TQFTP2OE.js.map → src-24P2RGTU.js.map} +0 -0
  80. /package/dist/{typescript-RFGACGWX.js.map → typescript-OIYGWQQM.js.map} +0 -0
  81. /package/dist/{wrap-ansi-4CW7YZCW.js.map → wrap-ansi-FLLI5RM7.js.map} +0 -0
  82. /package/dist/{yaml-RVRXF4QM.js.map → yaml-OVN7LRUL.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  if (typeof process === 'object' && process !== null &&
2
2
  process.env !== null && typeof process.env === 'object') {
3
3
  process.env.DD_GIT_REPOSITORY_URL = 'https://token@github.com/superblocksteam/superblocks.git';
4
- process.env.DD_GIT_COMMIT_SHA = '9e39b4cf55ecb117bc4a7b01a99a1954f1d98942';
4
+ process.env.DD_GIT_COMMIT_SHA = 'a0ebb4b4dc75e81690d97ae08a971571748be1b0';
5
5
  }
6
6
  import { createRequire as $dd_createRequire } from 'module';
7
7
  import { fileURLToPath as $dd_fileURLToPath } from 'url';
@@ -23,10 +23,10 @@ import {
23
23
  require_re,
24
24
  require_semver,
25
25
  require_valid
26
- } from "./chunk-64EHFXFV.js";
26
+ } from "./chunk-VVRV7UV6.js";
27
27
  import {
28
28
  require_enquirer
29
- } from "./chunk-QQG4FNHC.js";
29
+ } from "./chunk-XJJXWXNQ.js";
30
30
  import {
31
31
  debounce_default,
32
32
  get_default,
@@ -40,7 +40,7 @@ import {
40
40
  require_dist,
41
41
  require_lib,
42
42
  require_slugify
43
- } from "./chunk-YQJDTEQK.js";
43
+ } from "./chunk-PLLSDKTJ.js";
44
44
  import {
45
45
  SpanKind,
46
46
  SpanStatusCode,
@@ -48,7 +48,7 @@ import {
48
48
  esm_exports,
49
49
  init_esm,
50
50
  trace
51
- } from "./chunk-VXXN7VAS.js";
51
+ } from "./chunk-HFNLESLL.js";
52
52
  import {
53
53
  require_agent_info_exporter,
54
54
  require_base,
@@ -77,7 +77,7 @@ import {
77
77
  require_utils,
78
78
  require_writer,
79
79
  require_writers
80
- } from "./chunk-VH6NHAEM.js";
80
+ } from "./chunk-S5EPDX4F.js";
81
81
  import {
82
82
  __commonJS,
83
83
  __esm,
@@ -86,7 +86,7 @@ import {
86
86
  __toCommonJS,
87
87
  __toESM,
88
88
  init_cjs_shims
89
- } from "./chunk-LMLFDJMT.js";
89
+ } from "./chunk-57CSOFCV.js";
90
90
 
91
91
  // ../../../../node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/lib/TemplateTag/TemplateTag.js
92
92
  var require_TemplateTag = __commonJS({
@@ -68519,19 +68519,19 @@ var require_getMachineId = __commonJS({
68519
68519
  if (!getMachineIdImpl) {
68520
68520
  switch (process5.platform) {
68521
68521
  case "darwin":
68522
- getMachineIdImpl = (await import("./getMachineId-darwin-DQ6EFB3W.js")).getMachineId;
68522
+ getMachineIdImpl = (await import("./getMachineId-darwin-JNUXDADV.js")).getMachineId;
68523
68523
  break;
68524
68524
  case "linux":
68525
- getMachineIdImpl = (await import("./getMachineId-linux-X2ORZCWZ.js")).getMachineId;
68525
+ getMachineIdImpl = (await import("./getMachineId-linux-KRZF2UV7.js")).getMachineId;
68526
68526
  break;
68527
68527
  case "freebsd":
68528
- getMachineIdImpl = (await import("./getMachineId-bsd-ZPWHUTI7.js")).getMachineId;
68528
+ getMachineIdImpl = (await import("./getMachineId-bsd-7END53IL.js")).getMachineId;
68529
68529
  break;
68530
68530
  case "win32":
68531
- getMachineIdImpl = (await import("./getMachineId-win-3QIEGI2M.js")).getMachineId;
68531
+ getMachineIdImpl = (await import("./getMachineId-win-TNE5Z3HM.js")).getMachineId;
68532
68532
  break;
68533
68533
  default:
68534
- getMachineIdImpl = (await import("./getMachineId-unsupported-QU74FCZZ.js")).getMachineId;
68534
+ getMachineIdImpl = (await import("./getMachineId-unsupported-TAQP2SYG.js")).getMachineId;
68535
68535
  break;
68536
68536
  }
68537
68537
  }
@@ -304088,15 +304088,15 @@ var require_api_files = __commonJS({
304088
304088
  exports2.readAppApiYamlFile = readAppApiYamlFile4;
304089
304089
  exports2.resolveLanguageSpecificStepContentFromBlocks = resolveLanguageSpecificStepContentFromBlocks2;
304090
304090
  async function writeApiFiles3(...args) {
304091
- const esmFunction = await import("./api-MW4QAIKQ.js");
304091
+ const esmFunction = await import("./api-7L7HXK2Z.js");
304092
304092
  return esmFunction.writeApiFiles(...args);
304093
304093
  }
304094
304094
  async function readAppApiYamlFile4(...args) {
304095
- const esmFunction = await import("./api-MW4QAIKQ.js");
304095
+ const esmFunction = await import("./api-7L7HXK2Z.js");
304096
304096
  return esmFunction.readAppApiYamlFile(...args);
304097
304097
  }
304098
304098
  async function resolveLanguageSpecificStepContentFromBlocks2(...args) {
304099
- const esmFunction = await import("./api-MW4QAIKQ.js");
304099
+ const esmFunction = await import("./api-7L7HXK2Z.js");
304100
304100
  return esmFunction.resolveLanguageSpecificStepContentFromBlocks(...args);
304101
304101
  }
304102
304102
  }
@@ -451403,7 +451403,7 @@ var require_config_loader = __commonJS({
451403
451403
  * @returns {Promise<{createJiti: Function|undefined, version: string;}>} A promise that fulfills with an object containing the jiti module's createJiti function and version.
451404
451404
  */
451405
451405
  static async loadJiti() {
451406
- const { createJiti } = await import("./jiti-FEG3RQVN.js");
451406
+ const { createJiti } = await import("./jiti-LBBXQX3J.js");
451407
451407
  const version5 = require_package7().version;
451408
451408
  return { createJiti, version: version5 };
451409
451409
  }
@@ -451732,7 +451732,7 @@ var require_eslint_helpers = __commonJS({
451732
451732
  }
451733
451733
  async function globMatch({ basePath, pattern }) {
451734
451734
  let found = false;
451735
- const { hfs } = await import("./src-TQFTP2OE.js");
451735
+ const { hfs } = await import("./src-24P2RGTU.js");
451736
451736
  const patternToUse = normalizeToPosix(path84.relative(basePath, pattern));
451737
451737
  const matcher = new Minimatch2(patternToUse, MINIMATCH_OPTIONS);
451738
451738
  const walkSettings = {
@@ -451772,7 +451772,7 @@ var require_eslint_helpers = __commonJS({
451772
451772
  return new Minimatch2(patternToUse, MINIMATCH_OPTIONS);
451773
451773
  });
451774
451774
  const unmatchedPatterns = /* @__PURE__ */ new Set([...relativeToPatterns.keys()]);
451775
- const { hfs } = await import("./src-TQFTP2OE.js");
451775
+ const { hfs } = await import("./src-24P2RGTU.js");
451776
451776
  const walk2 = hfs.walk(basePath, {
451777
451777
  async directoryFilter(entry) {
451778
451778
  if (!matchers.some((matcher) => matcher.match(entry.path, true))) {
@@ -583951,7 +583951,7 @@ import os2 from "node:os";
583951
583951
  // ../sdk/package.json
583952
583952
  var package_default = {
583953
583953
  name: "@superblocksteam/sdk",
583954
- version: "2.0.78-next.1",
583954
+ version: "2.0.78-next.3",
583955
583955
  type: "module",
583956
583956
  description: "Superblocks JS SDK",
583957
583957
  homepage: "https://www.superblocks.com",
@@ -584330,7 +584330,7 @@ init_cjs_shims();
584330
584330
  init_cjs_shims();
584331
584331
  import { randomUUID as randomUUID2 } from "node:crypto";
584332
584332
  import os4 from "node:os";
584333
- import path38 from "node:path";
584333
+ import path39 from "node:path";
584334
584334
 
584335
584335
  // ../../../library-shared/dist/types/index.js
584336
584336
  init_cjs_shims();
@@ -637407,7 +637407,7 @@ init_esm();
637407
637407
  var LLMObsSpanWriter = null;
637408
637408
  async function loadLLMObsSpanWriter() {
637409
637409
  if (!LLMObsSpanWriter) {
637410
- const module2 = await import("./spans-UK3VDT2L.js");
637410
+ const module2 = await import("./spans-BJZB75HQ.js");
637411
637411
  LLMObsSpanWriter = module2.default;
637412
637412
  }
637413
637413
  return LLMObsSpanWriter;
@@ -652468,6 +652468,7 @@ function matchPhysicalApiPath(physicalPath) {
652468
652468
  }
652469
652469
  var ApiFileHandler = class {
652470
652470
  type = "api";
652471
+ logger = getLogger();
652471
652472
  matches(virtualPath) {
652472
652473
  const match2 = generatedApisMatch(virtualPath);
652473
652474
  return match2.matched && match2.params.apiName.endsWith(".ts");
@@ -652517,18 +652518,21 @@ var ApiFileHandler = class {
652517
652518
  scratchExists = true;
652518
652519
  scratchMtime = scratchStat.mtime;
652519
652520
  } catch {
652521
+ this.logger.debug(`Scratch file does not exist: ${fullScratchPath}`);
652520
652522
  }
652521
652523
  try {
652522
652524
  const yamlStat = await stat4(fullYamlPath);
652523
652525
  yamlExists = true;
652524
652526
  yamlMtime = yamlStat.mtime;
652525
652527
  } catch {
652528
+ this.logger.debug(`YAML file does not exist: ${fullYamlPath}`);
652526
652529
  }
652527
652530
  const scratchIsFresh = scratchExists && scratchMtime && (!yamlExists || !yamlMtime || scratchMtime >= yamlMtime);
652528
652531
  if (scratchIsFresh) {
652529
652532
  return await readFile3(fullScratchPath, "utf-8");
652530
652533
  }
652531
652534
  if (!yamlExists) {
652535
+ this.logger.debug(`YAML file does not exist: ${fullYamlPath}`);
652532
652536
  return void 0;
652533
652537
  }
652534
652538
  if (!templateRenderer) {
@@ -652547,6 +652551,14 @@ var ApiFileHandler = class {
652547
652551
  templateRenderer
652548
652552
  })
652549
652553
  ]);
652554
+ if (sdkArtifact?.content) {
652555
+ try {
652556
+ await mkdir(path23.dirname(fullScratchPath), { recursive: true });
652557
+ await writeFile2(fullScratchPath, sdkArtifact.content, "utf-8");
652558
+ } catch (err) {
652559
+ getLogger().warn(`Failed to cache transformed API to scratch: ${fullScratchPath}`, getErrorMeta(err));
652560
+ }
652561
+ }
652550
652562
  return sdkArtifact?.content;
652551
652563
  }
652552
652564
  async write(virtualPath, content2, options8) {
@@ -678072,7 +678084,7 @@ var PlaywrightMcpServerManager = class {
678072
678084
  this.logger.info(`Starting embedded Playwright MCP server: browser=${options8?.browser || "chromium"}, headless=${options8?.headless !== false}`);
678073
678085
  }
678074
678086
  try {
678075
- const { startEmbeddedPlaywrightMcpServer } = await import("./embedded-playwright-mcp-server-4WD5ISA6.js");
678087
+ const { startEmbeddedPlaywrightMcpServer } = await import("./embedded-playwright-mcp-server-Q5Q7ZEGQ.js");
678076
678088
  this.server = await startEmbeddedPlaywrightMcpServer({
678077
678089
  storageStatePath: options8?.storageStatePath,
678078
678090
  jwt: options8?.jwt,
@@ -679863,7 +679875,7 @@ var doIdle = (clark2, { chatSessionStore, clarkProfiler }) => {
679863
679875
 
679864
679876
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/handlers/llm-generating.js
679865
679877
  init_cjs_shims();
679866
- import path34 from "node:path";
679878
+ import path35 from "node:path";
679867
679879
 
679868
679880
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/prompts/build-base-system-prompt.js
679869
679881
  init_cjs_shims();
@@ -680662,7 +680674,7 @@ var DEFAULT_SAFETY_GUIDANCE = (
680662
680674
 
680663
680675
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/tools.js
680664
680676
  init_cjs_shims();
680665
- import path33 from "node:path";
680677
+ import path34 from "node:path";
680666
680678
 
680667
680679
  // ../../../vite-plugin-file-sync/dist/ai-service/mcp/adapter/mcp-tool-adapter.js
680668
680680
  init_cjs_shims();
@@ -681261,6 +681273,8 @@ init_cjs_shims();
681261
681273
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/tools/apis/build-api-artifact.js
681262
681274
  init_cjs_shims();
681263
681275
  var import_yaml2 = __toESM(require_dist());
681276
+ import { utimes } from "node:fs/promises";
681277
+ import path31 from "node:path";
681264
681278
 
681265
681279
  // ../../../vite-plugin-file-sync/dist/binding-extraction/extract-identifiers.js
681266
681280
  init_cjs_shims();
@@ -687867,6 +687881,15 @@ ${analysisWarnings.join("\n\n")}`);
687867
687881
  await services.draftInterface.createDraftFile(apiYaml.filePath, apiYaml.content);
687868
687882
  const typesPath = renderPath(Paths.ApiYamls, { apiName }).replace("api.yaml", "types.d.ts");
687869
687883
  await services.draftInterface.createDraftFile(typesPath, typesContent);
687884
+ const scratchPath = renderPath(Paths.Scratch, {
687885
+ path: `apis/${apiName}.ts`
687886
+ });
687887
+ const fullScratchPath = path31.join(services.appShell.appRootDirPath, scratchPath);
687888
+ try {
687889
+ const now = /* @__PURE__ */ new Date();
687890
+ await utimes(fullScratchPath, now, now);
687891
+ } catch {
687892
+ }
687870
687893
  });
687871
687894
  } catch (error40) {
687872
687895
  logger12.error("Failed to build API or generate types", getErrorMeta(error40));
@@ -689642,6 +689665,8 @@ new DynamoDb("ListTables", dynamoIntegrationId, {
689642
689665
  headers?: { key: Binding<string>; value: Binding<string> }[];
689643
689666
  /** Request body (for POST, PUT, PATCH) */
689644
689667
  body?: Binding<string>;
689668
+ /** Body content type: jsonBody (default), rawBody, formData, or fileForm */
689669
+ bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";
689645
689670
  }
689646
689671
  );
689647
689672
 
@@ -690074,6 +690099,8 @@ new Salesforce("GetAccounts", salesforceIntegrationId, {
690074
690099
  params?: { key: Binding<string>; value: Binding<string> }[];
690075
690100
  /** Request body (for POST, PUT, PATCH) */
690076
690101
  body?: Binding<string>;
690102
+ /** Body content type: jsonBody (default), rawBody, formData, or fileForm */
690103
+ bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";
690077
690104
  }
690078
690105
  openapi?: {
690079
690106
  /** Endpoint path from OpenApi spec */
@@ -690985,7 +691012,7 @@ export declare class Parallel extends Block {
690985
691012
  | {
690986
691013
  mode: "dynamic";
690987
691014
  over: Binding<JsonValue[]>;
690988
- variables: { item: string };
691015
+ // variables defaults to { item: "item" } - only specify if you need a different name
690989
691016
  blocks: Block[];
690990
691017
  }
690991
691018
  | {
@@ -694827,7 +694854,7 @@ Returns matching file paths and count. Patterns use glob syntax.
694827
694854
  init_cjs_shims();
694828
694855
  import { exec as exec3 } from "node:child_process";
694829
694856
  import { existsSync as existsSync4 } from "node:fs";
694830
- import path31 from "node:path";
694857
+ import path32 from "node:path";
694831
694858
  import { promisify as promisify3 } from "node:util";
694832
694859
  var execAsync2 = promisify3(exec3);
694833
694860
  var shellEscape = (arg) => {
@@ -694892,7 +694919,7 @@ Usage:
694892
694919
  if (searchPath) {
694893
694920
  args.push(shellEscape(searchPath));
694894
694921
  }
694895
- const scratchPath = path31.resolve(process.cwd(), ".superblocks/scratch");
694922
+ const scratchPath = path32.resolve(process.cwd(), ".superblocks/scratch");
694896
694923
  if (existsSync4(scratchPath)) {
694897
694924
  args.push("'.superblocks/scratch/'");
694898
694925
  }
@@ -694948,7 +694975,7 @@ Usage:
694948
694975
 
694949
694976
  // ../../../vite-plugin-file-sync/dist/ai-service/agent/tools2/tools/ls.js
694950
694977
  init_cjs_shims();
694951
- import path32 from "node:path";
694978
+ import path33 from "node:path";
694952
694979
  function formatSize(bytes) {
694953
694980
  if (bytes < 1024)
694954
694981
  return `${bytes}`;
@@ -694984,7 +695011,7 @@ function formatMetadataLine(meta2) {
694984
695011
  const perms = "rw-r--r--";
694985
695012
  const size = formatSize(meta2.size);
694986
695013
  const date5 = formatDate(meta2.mtime);
694987
- const name16 = path32.basename(meta2.path);
695014
+ const name16 = path33.basename(meta2.path);
694988
695015
  return `${type}${perms} 1 user staff ${size.padStart(6)} ${date5} ${name16}`;
694989
695016
  }
694990
695017
  var lsToolFactory = createToolFactory("ls", (services) => ({
@@ -695009,11 +695036,11 @@ Returns formatted output similar to ls -lh. Call multiple times on subdirectorie
695009
695036
  readOnly: true,
695010
695037
  execute: async ({ path: dirPath = ".", includeHidden = false }) => {
695011
695038
  const appRoot = services.appShell.appRootDirPath;
695012
- const resolvedPath = path32.resolve(appRoot, dirPath);
695039
+ const resolvedPath = path33.resolve(appRoot, dirPath);
695013
695040
  if (!resolvedPath.startsWith(appRoot)) {
695014
695041
  throw new Error(`Access denied: path '${dirPath}' is outside the application directory`);
695015
695042
  }
695016
- const relativeDirPath = path32.relative(appRoot, resolvedPath);
695043
+ const relativeDirPath = path33.relative(appRoot, resolvedPath);
695017
695044
  const pattern = relativeDirPath ? `${relativeDirPath}/*` : "*";
695018
695045
  const fileEntries = await services.appShell.listFiles([pattern], {
695019
695046
  includeMetadata: true,
@@ -695021,10 +695048,10 @@ Returns formatted output similar to ls -lh. Call multiple times on subdirectorie
695021
695048
  dot: includeHidden
695022
695049
  });
695023
695050
  const directChildren = fileEntries.filter((entry) => {
695024
- const entryDir = path32.dirname(entry.path);
695051
+ const entryDir = path33.dirname(entry.path);
695025
695052
  return entryDir === relativeDirPath || entryDir === "." && !relativeDirPath;
695026
695053
  });
695027
- const allEntries = directChildren.sort((a, b) => path32.basename(a.path).localeCompare(path32.basename(b.path)));
695054
+ const allEntries = directChildren.sort((a, b) => path33.basename(a.path).localeCompare(path33.basename(b.path)));
695028
695055
  if (allEntries.length === 0) {
695029
695056
  return { output: "" };
695030
695057
  }
@@ -709537,7 +709564,7 @@ var fileToolConfig2 = {
709537
709564
  extractDisplayName: (parameters) => {
709538
709565
  const params = parameters;
709539
709566
  if (params.filePath && typeof params.filePath === "string") {
709540
- const fileName = path33.basename(params.filePath);
709567
+ const fileName = path34.basename(params.filePath);
709541
709568
  return `:${fileName}`;
709542
709569
  }
709543
709570
  return "";
@@ -709754,6 +709781,7 @@ var buildTools = async (clark2, services) => {
709754
709781
  const errorMessage = String(error40);
709755
709782
  services.logger.error(`[Playwright] \u274C Error initializing Playwright MCP server: ${errorMessage}`);
709756
709783
  }
709784
+ registry2.addMiddleware(outputLimiter(25e3));
709757
709785
  const storeSummary = (toolCallId, summary) => {
709758
709786
  try {
709759
709787
  const context = getActiveContext(clark2, services);
@@ -709762,7 +709790,6 @@ var buildTools = async (clark2, services) => {
709762
709790
  }
709763
709791
  };
709764
709792
  registry2.addMiddleware(summaryInjector(storeSummary));
709765
- registry2.addMiddleware(outputLimiter(25e3));
709766
709793
  registry2.addMiddleware(secretScanningMiddleware({
709767
709794
  enabled: services.features.secretRedactionEnabled
709768
709795
  }));
@@ -709899,25 +709926,25 @@ var buildUserMessage = (userPrompt, promptContext, planContext, mode, services,
709899
709926
  const changeDescriptions = userChanges.map((change) => {
709900
709927
  switch (change.type) {
709901
709928
  case "deleteComponents":
709902
- return `- Deleted ${change.componentCount} component(s) from ${path34.relative(appRootDirPath, change.path)}`;
709929
+ return `- Deleted ${change.componentCount} component(s) from ${path35.relative(appRootDirPath, change.path)}`;
709903
709930
  case "createComponent":
709904
- return `- Added a new component to ${path34.relative(appRootDirPath, change.path)}`;
709931
+ return `- Added a new component to ${path35.relative(appRootDirPath, change.path)}`;
709905
709932
  case "reparent":
709906
- return `- Moved components in ${path34.relative(appRootDirPath, change.path)}`;
709933
+ return `- Moved components in ${path35.relative(appRootDirPath, change.path)}`;
709907
709934
  case "batchUpdate": {
709908
- const relativePaths = change.paths.map((p) => path34.relative(appRootDirPath, p));
709935
+ const relativePaths = change.paths.map((p) => path35.relative(appRootDirPath, p));
709909
709936
  return `- Made ${change.updateCount} changes to ${relativePaths.length > 1 ? `${relativePaths.length} files` : relativePaths[0]}`;
709910
709937
  }
709911
709938
  case "addPage":
709912
- return `- Created a new page at ${path34.relative(appRootDirPath, change.path)}`;
709939
+ return `- Created a new page at ${path35.relative(appRootDirPath, change.path)}`;
709913
709940
  case "deletePage":
709914
- return `- Deleted page at ${path34.relative(appRootDirPath, change.path)}`;
709941
+ return `- Deleted page at ${path35.relative(appRootDirPath, change.path)}`;
709915
709942
  case "apiUpdate":
709916
709943
  return `- Modified API "${change.apiName}"`;
709917
709944
  case "apiDelete":
709918
709945
  return `- Deleted API "${change.apiName}"`;
709919
709946
  case "fileChanged":
709920
- return `- Edited code in ${path34.relative(appRootDirPath, change.filePath)}`;
709947
+ return `- Edited code in ${path35.relative(appRootDirPath, change.filePath)}`;
709921
709948
  }
709922
709949
  });
709923
709950
  content2.push({
@@ -710267,7 +710294,7 @@ var playDead = () => async ({ event }) => {
710267
710294
  init_cjs_shims();
710268
710295
  var import_core9 = __toESM(require_lib41());
710269
710296
  var import_parser11 = __toESM(require_lib6());
710270
- import path35 from "path";
710297
+ import path36 from "path";
710271
710298
  init_lodash();
710272
710299
 
710273
710300
  // ../../../vite-plugin-file-sync/dist/parsing/jsx.js
@@ -711369,7 +711396,7 @@ var doPostProcessing = (clark2, { draftInterface, appShell, chatSessionStore, fi
711369
711396
  const changes = await sourceTrackerInterface.getAndFlushChanges();
711370
711397
  const changesFileArtifacts = changes.map((change) => ({
711371
711398
  type: "file",
711372
- filePath: path35.relative(appShell.appRootDirPath, change.fileName),
711399
+ filePath: path36.relative(appShell.appRootDirPath, change.fileName),
711373
711400
  content: change.source
711374
711401
  }));
711375
711402
  await createDraftFiles(changesFileArtifacts);
@@ -711689,12 +711716,12 @@ import { spawn as spawn5 } from "child_process";
711689
711716
  import { randomUUID } from "crypto";
711690
711717
  import * as fs16 from "fs/promises";
711691
711718
  import * as os3 from "os";
711692
- import * as path37 from "path";
711719
+ import * as path38 from "path";
711693
711720
 
711694
711721
  // ../../../ai-service-templates/reify-template.js
711695
711722
  init_cjs_shims();
711696
711723
  import fs15 from "fs";
711697
- import path36 from "path";
711724
+ import path37 from "path";
711698
711725
  function reifyTemplate(targetDirectoryPath, fileMap) {
711699
711726
  if (typeof targetDirectoryPath !== "string") {
711700
711727
  throw new Error("targetDirectoryPath must be a string.");
@@ -711702,14 +711729,14 @@ function reifyTemplate(targetDirectoryPath, fileMap) {
711702
711729
  if (typeof fileMap !== "object" || fileMap === null) {
711703
711730
  throw new Error("fileMap must be a non-null object.");
711704
711731
  }
711705
- const resolvedTargetDirectory = path36.resolve(targetDirectoryPath);
711732
+ const resolvedTargetDirectory = path37.resolve(targetDirectoryPath);
711706
711733
  console.log(`Recreating structure in: ${resolvedTargetDirectory}`);
711707
711734
  for (const relativeFilePath in fileMap) {
711708
711735
  if (Object.hasOwnProperty.call(fileMap, relativeFilePath)) {
711709
711736
  const content2 = fileMap[relativeFilePath];
711710
711737
  const fileContent = typeof content2 === "string" ? content2 : String(content2);
711711
- const absoluteFilePath = path36.join(resolvedTargetDirectory, relativeFilePath);
711712
- const directoryForFile = path36.dirname(absoluteFilePath);
711738
+ const absoluteFilePath = path37.join(resolvedTargetDirectory, relativeFilePath);
711739
+ const directoryForFile = path37.dirname(absoluteFilePath);
711713
711740
  try {
711714
711741
  if (!fs15.existsSync(directoryForFile)) {
711715
711742
  fs15.mkdirSync(directoryForFile, { recursive: true });
@@ -711733,7 +711760,7 @@ var templates = {
711733
711760
  "shim-loader.mjs": 'import path from "path";\nimport { pathToFileURL } from "url";\n\nconst overrideMap = {\n "@superblocksteam/library": "./dist/superblocks-library-shim/index.js",\n};\n\nexport async function resolve(specifier, context, nextResolve) {\n if (overrideMap[specifier]) {\n const fullPath = path.resolve(overrideMap[specifier]);\n return {\n shortCircuit: true,\n url: pathToFileURL(fullPath).href,\n };\n }\n\n return nextResolve(specifier, context);\n}\n',
711734
711761
  "src/do-eval-to-sdk.ts": 'import fs from "fs";\nimport path from "path";\nimport { fileURLToPath } from "url";\n\n// finds all JavaScript files in the specified directory,\n// imports each module, converts its JSON representation to SDK,\n// and returns a map with filenames as keys and SDK content as values.\nexport async function processSdkFiles(\n apisDir: string,\n): Promise<Record<string, string>> {\n const files = fs.readdirSync(apisDir);\n const jsFiles = files.filter(\n (file) => file.endsWith(".js") && file !== "__template__.js",\n );\n const results: Record<string, string> = {};\n\n for (const jsFile of jsFiles) {\n const filePath = path.join(apisDir, jsFile);\n const absolutePath = path.resolve(filePath);\n\n try {\n const fileUrl = new URL(`file://${absolutePath}`);\n const module = await import(fileUrl.href);\n\n const defaultExport = module.default;\n\n if (defaultExport && typeof defaultExport.toSDK === "function") {\n const sdkData = await defaultExport.toSDK();\n\n results[jsFile] = sdkData;\n } else {\n console.warn(`${jsFile}: Default export doesn\'t have a toSDK method`);\n }\n } catch (error) {\n console.error(`Error processing ${jsFile}:`, error);\n }\n }\n\n return results;\n}\n\nasync function main() {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const apisDir = path.resolve(__dirname, "./to-sdk");\n\n const results = await processSdkFiles(apisDir);\n console.log(JSON.stringify(results, null, 2));\n}\n\nmain().catch((error) => {\n console.error("Error:", error);\n process.exit(1);\n});\n',
711735
711762
  "src/do-eval-to-yaml.ts": 'import fs from "fs";\nimport path from "path";\nimport { fileURLToPath } from "url";\nimport yaml from "yaml";\nimport { Global } from "./superblocks-library-shim/index.js";\n\n/**\n * Initialize global context from environment variables.\n * This allows the transformer to pass plugin version information\n * to the shim classes for version-aware output generation.\n *\n * The PLUGIN_EXECUTION_VERSIONS env var is set by ApiBuilderToYamlTransformer\n * (in to-yaml-transformer.ts) when spawning the eval process. The versions\n * originate from the SDK/UserInfo and flow through AiService -> IntegrationStore.\n */\nfunction initializeGlobalContext(): void {\n const pluginVersionsEnv = process.env.PLUGIN_EXECUTION_VERSIONS;\n if (pluginVersionsEnv) {\n try {\n Global.pluginExecutionVersions = JSON.parse(pluginVersionsEnv);\n } catch {\n console.warn(\n "Failed to parse PLUGIN_EXECUTION_VERSIONS environment variable",\n );\n }\n }\n}\n\n// finds all JavaScript files in the specified directory,\n// imports each module, converts its JSON representation to YAML,\n// and returns a map with filenames as keys and YAML content as values.\n\nexport async function processYamlFiles(\n apisDir: string,\n): Promise<Record<string, string>> {\n const files = fs.readdirSync(apisDir);\n const jsFiles = files.filter((file) => file.endsWith(".js"));\n const results: Record<string, string> = {};\n\n for (const jsFile of jsFiles) {\n const filePath = path.join(apisDir, jsFile);\n const absolutePath = path.resolve(filePath);\n\n try {\n const fileUrl = new URL(`file://${absolutePath}`);\n const module = await import(fileUrl.href);\n\n const defaultExport = module.default;\n\n if (defaultExport && typeof defaultExport.toJSON === "function") {\n const jsonData = await defaultExport.toJSON();\n const yamlContent = yaml.stringify(jsonData);\n results[jsFile] = yamlContent;\n } else {\n console.warn(`${jsFile}: Default export doesn\'t have a toJSON method`);\n }\n } catch (error) {\n console.error(`Error processing ${jsFile}:`, error);\n }\n }\n\n return results;\n}\n\nasync function main() {\n // Initialize global context before processing\n initializeGlobalContext();\n\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const apisDir = path.resolve(__dirname, "./to-yaml");\n\n const results = await processYamlFiles(apisDir);\n console.log(JSON.stringify(results, null, 2));\n}\n\nmain().catch((error) => {\n console.error("Error:", error);\n process.exit(1);\n});\n',
711736
- "src/superblocks-library-shim/ast-utils.ts": 'import { Node, parse, Program } from "acorn";\n\n/**\n * Creates an AST from a string value.\n * If the value starts and ends with braces, wraps it in parentheses to parse as an object literal.\n */\nexport function createAst(value: string): Program {\n if (value.startsWith("{") && value.endsWith("}")) {\n value = `(${value})`;\n }\n\n return parse(value, {\n ecmaVersion: "latest",\n sourceType: "script",\n preserveParens: false,\n });\n}\n\n/**\n * Finds entity references in a code string using AST parsing.\n * Returns an array of entity names that are referenced in the code.\n */\nexport function referenced(data: string, entities: string[]): string[] {\n if (!data || entities.length === 0) {\n return [];\n }\n\n const entitySet = new Set(entities);\n const found = new Set<string>();\n\n // Walk the AST to find identifier references\n const walkNode = (node: Node): void => {\n if (!node) return;\n\n // Only capture Identifier nodes that are variable references\n if (node.type === "Identifier") {\n const name = (node as any).name;\n if (entitySet.has(name)) {\n found.add(name);\n }\n }\n\n // Handle MemberExpression - only care about the object (leftmost identifier)\n if (node.type === "MemberExpression") {\n const memberExpr = node as any;\n walkNode(memberExpr.object);\n // Don\'t walk the property - it\'s not a variable reference\n return;\n }\n\n // Handle Property nodes in object literals - skip the key (unless shorthand or computed)\n if (node.type === "Property") {\n const prop = node as any;\n if (prop.shorthand) {\n // Shorthand { foo } means { foo: foo }, so key is a reference\n if (prop.key?.type === "Identifier" && entitySet.has(prop.key.name)) {\n found.add(prop.key.name);\n }\n } else {\n // For computed properties { [expr]: value }, walk the key expression\n if (prop.computed) {\n walkNode(prop.key);\n }\n // Always process the value\n walkNode(prop.value);\n }\n return;\n }\n\n // Recursively process child nodes\n for (const key in node) {\n const value = (node as any)[key];\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n walkNode(item);\n }\n }\n } else if (value.type) {\n walkNode(value);\n }\n }\n }\n };\n\n // Try parsing strategies in order of likelihood\n const parseStrategies = data.startsWith("{")\n ? [\n // For code starting with {, try as object literal first (wrapped in parens)\n () =>\n parse(`(${data})`, { ecmaVersion: "latest", sourceType: "script" }),\n // Then try as block statement (for code like { const x = ...; return x; })\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ]\n : [\n // Parse as script (handles statements like const, return, etc.)\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ];\n\n for (const strategy of parseStrategies) {\n try {\n const ast = strategy();\n if (ast) {\n walkNode(ast);\n return Array.from(found);\n }\n } catch {\n // Try next strategy\n }\n }\n\n return [];\n}\n\n/**\n * Collect identifiers from destructuring patterns (ObjectPattern, ArrayPattern)\n */\nexport function collectPatternIdentifiers(\n pattern: Node,\n identifiers: Set<string>,\n): void {\n if (!pattern) return;\n\n if ((pattern as any).type === "Identifier") {\n identifiers.add((pattern as any).name);\n } else if ((pattern as any).type === "ObjectPattern") {\n for (const prop of (pattern as any).properties || []) {\n if (prop.type === "Property") {\n collectPatternIdentifiers(prop.value, identifiers);\n } else if (prop.type === "RestElement") {\n collectPatternIdentifiers(prop.argument, identifiers);\n }\n }\n } else if ((pattern as any).type === "ArrayPattern") {\n for (const elem of (pattern as any).elements || []) {\n if (elem) {\n collectPatternIdentifiers(elem, identifiers);\n }\n }\n } else if ((pattern as any).type === "RestElement") {\n collectPatternIdentifiers((pattern as any).argument, identifiers);\n } else if ((pattern as any).type === "AssignmentPattern") {\n collectPatternIdentifiers((pattern as any).left, identifiers);\n }\n}\n\n/**\n * Collect function parameter names into a set\n */\nexport function collectFunctionParams(fn: any, params: Set<string>): void {\n for (const param of fn.params || []) {\n if (param.type === "Identifier") {\n params.add(param.name);\n } else if (\n param.type === "ObjectPattern" ||\n param.type === "ArrayPattern"\n ) {\n collectPatternIdentifiers(param, params);\n } else if (param.type === "AssignmentPattern" && param.left) {\n if (param.left.type === "Identifier") {\n params.add(param.left.name);\n } else if (\n param.left.type === "ObjectPattern" ||\n param.left.type === "ArrayPattern"\n ) {\n collectPatternIdentifiers(param.left, params);\n }\n }\n }\n}\n\n/**\n * Check if a node is a function node (arrow function, function expression, or function declaration)\n */\nexport function isFunctionNode(node: any): boolean {\n return (\n node.type === "ArrowFunctionExpression" ||\n node.type === "FunctionExpression" ||\n node.type === "FunctionDeclaration"\n );\n}\n\n/**\n * Collect variable declarations at the current scope level only.\n * Does NOT recurse into nested functions (their declarations are their own scope).\n */\nexport function collectCurrentScopeLocals(\n node: Node,\n locals: Set<string>,\n): void {\n if (!node) return;\n\n // VariableDeclarator: const foo = ...\n if (node.type === "VariableDeclarator") {\n const decl = node as any;\n if (decl.id?.type === "Identifier") {\n locals.add(decl.id.name);\n }\n if (decl.id?.type === "ObjectPattern" || decl.id?.type === "ArrayPattern") {\n collectPatternIdentifiers(decl.id, locals);\n }\n // Process the init value for nested declarations (but not function bodies)\n if (decl.init && !isFunctionNode(decl.init)) {\n collectCurrentScopeLocals(decl.init, locals);\n }\n return;\n }\n\n // FunctionDeclaration: function foo() {} - the name is local, but don\'t process body\n if (node.type === "FunctionDeclaration") {\n const fn = node as any;\n if (fn.id?.type === "Identifier") {\n locals.add(fn.id.name);\n }\n // Don\'t recurse into function body - its locals are scoped to it\n return;\n }\n\n // ArrowFunctionExpression / FunctionExpression - don\'t recurse, their scope is separate\n if (\n node.type === "ArrowFunctionExpression" ||\n node.type === "FunctionExpression"\n ) {\n return;\n }\n\n // CatchClause param is local to the catch block\n if (node.type === "CatchClause") {\n const catchClause = node as any;\n if (catchClause.param?.type === "Identifier") {\n locals.add(catchClause.param.name);\n }\n // Continue to process the body\n if (catchClause.body) {\n collectCurrentScopeLocals(catchClause.body, locals);\n }\n return;\n }\n\n // Recursively process child nodes (except functions)\n for (const key in node) {\n const value = (node as any)[key];\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n collectCurrentScopeLocals(item, locals);\n }\n }\n } else if (value.type) {\n collectCurrentScopeLocals(value, locals);\n }\n }\n }\n}\n\n/**\n * Extract references from a node, handling nested functions with their own scope.\n */\nexport function extractRefsFromNode(\n node: Node,\n locals: Set<string>,\n refs: Set<string>,\n): void {\n if (!node) return;\n\n // Handle nested functions - recurse with their params added to locals\n if (\n node.type === "ArrowFunctionExpression" ||\n node.type === "FunctionExpression" ||\n node.type === "FunctionDeclaration"\n ) {\n const fn = node as any;\n // Create new scope with outer locals + this function\'s params\n const innerLocals = new Set(locals);\n collectFunctionParams(fn, innerLocals);\n // Also collect locals declared inside the function body\n if (fn.body) {\n collectCurrentScopeLocals(fn.body, innerLocals);\n }\n // Extract refs from function body with the inner scope\n if (fn.body) {\n extractRefsFromNode(fn.body, innerLocals, refs);\n }\n return;\n }\n\n // MemberExpression: only care about the root object\n if (node.type === "MemberExpression") {\n const memberExpr = node as any;\n extractRefsFromNode(memberExpr.object, locals, refs);\n return;\n }\n\n // Property in object literal: skip key, only process value\n if (node.type === "Property") {\n const prop = node as any;\n if (prop.shorthand && prop.key?.type === "Identifier") {\n // { foo } is shorthand for { foo: foo } - foo is a reference\n if (!locals.has(prop.key.name)) {\n refs.add(prop.key.name);\n }\n } else {\n // Process computed keys and values\n if (prop.computed) {\n extractRefsFromNode(prop.key, locals, refs);\n }\n extractRefsFromNode(prop.value, locals, refs);\n }\n return;\n }\n\n // VariableDeclarator: only process the init, not the id\n if (node.type === "VariableDeclarator") {\n const decl = node as any;\n if (decl.init) {\n extractRefsFromNode(decl.init, locals, refs);\n }\n return;\n }\n\n // Identifier: add if not a local\n if (node.type === "Identifier") {\n const name = (node as any).name;\n if (!locals.has(name)) {\n refs.add(name);\n }\n return;\n }\n\n // Recursively process child nodes\n for (const key in node) {\n const value = (node as any)[key];\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n extractRefsFromNode(item, locals, refs);\n }\n }\n } else if (value.type) {\n extractRefsFromNode(value, locals, refs);\n }\n }\n }\n}\n\n/**\n * Extract external variable references from AST with proper scope handling.\n *\n * This function:\n * - Tracks local declarations at each scope level\n * - Properly handles nested functions (their params are local to them, not outer scope)\n * - Extracts references from nested function bodies that refer to outer scope variables\n * - Excludes object literal property keys\n * - Only extracts root object from member expressions (Step1.value -> Step1)\n */\nexport function extractExternalReferencesWithScope(\n node: Node,\n outerLocals: Set<string>,\n refs: Set<string> = new Set(),\n): Set<string> {\n if (!node) return refs;\n\n // Collect locals at current scope level (not including nested function scopes)\n const currentLocals = new Set(outerLocals);\n collectCurrentScopeLocals(node, currentLocals);\n\n // Now extract references\n extractRefsFromNode(node, currentLocals, refs);\n\n return refs;\n}\n\n/**\n * Extract variable reference identifiers from a function body using AST parsing.\n * Properly handles nested scopes - inner function params don\'t leak to outer scope.\n */\nexport function extractVariableReferences(node: Node): Set<string> {\n return extractExternalReferencesWithScope(node, new Set());\n}\n\n/**\n * JavaScript built-in globals that should not be treated as external variable references.\n * These are available in any JavaScript context and don\'t need to be destructured from parameters.\n */\nexport const JS_GLOBALS = new Set([\n // Constructors / Type converters\n "String",\n "Number",\n "Boolean",\n "Object",\n "Array",\n "Function",\n "Symbol",\n "BigInt",\n "Date",\n "RegExp",\n "Error",\n "TypeError",\n "ReferenceError",\n "SyntaxError",\n "RangeError",\n "URIError",\n "EvalError",\n "Map",\n "Set",\n "WeakMap",\n "WeakSet",\n "Promise",\n "Proxy",\n "Reflect",\n "ArrayBuffer",\n "SharedArrayBuffer",\n "DataView",\n "Int8Array",\n "Uint8Array",\n "Uint8ClampedArray",\n "Int16Array",\n "Uint16Array",\n "Int32Array",\n "Uint32Array",\n "Float32Array",\n "Float64Array",\n "BigInt64Array",\n "BigUint64Array",\n // Global functions\n "parseInt",\n "parseFloat",\n "isNaN",\n "isFinite",\n "encodeURI",\n "encodeURIComponent",\n "decodeURI",\n "decodeURIComponent",\n "eval",\n // Global objects\n "Math",\n "JSON",\n "console",\n "Intl",\n "Atomics",\n // Global values\n "undefined",\n "NaN",\n "Infinity",\n "globalThis",\n // Node.js globals (commonly used)\n "Buffer",\n "process",\n "setTimeout",\n "setInterval",\n "setImmediate",\n "clearTimeout",\n "clearInterval",\n "clearImmediate",\n "queueMicrotask",\n]);\n\n/**\n * Extract identifiers from a function body using AST parsing.\n * Falls back to entity-based filtering if parsing fails.\n * Filters out JavaScript built-in globals.\n */\nexport function extractReferencedIdentifiers(\n data: string,\n entities: string[],\n): string[] {\n // First try entity-based references\n const entityRefs = referenced(data, entities);\n\n // Also try to extract identifiers from the code itself using AST parsing\n // This catches parameters that aren\'t in the entities list (like API inputs)\n try {\n // Try parsing strategies - handle both expressions and statements with return\n const parseStrategies = data.startsWith("{")\n ? [\n // For code starting with {, try as object literal first\n () =>\n parse(`(${data})`, {\n ecmaVersion: "latest",\n sourceType: "script",\n }),\n // Then try as block statement\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ]\n : [\n // For other code, try with allowReturnOutsideFunction for function bodies\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ];\n\n let ast: Node | null = null;\n for (const strategy of parseStrategies) {\n try {\n ast = strategy();\n if (ast) break;\n } catch {\n // Try next strategy\n }\n }\n\n if (!ast) {\n return entityRefs;\n }\n\n const astIdentifiers = Array.from(extractVariableReferences(ast));\n\n // Filter out JavaScript globals - they don\'t need to be destructured\n const filteredAstIdentifiers = astIdentifiers.filter(\n (id) => !JS_GLOBALS.has(id),\n );\n\n // Combine entity refs with AST-extracted identifiers (deduplicated)\n const combined = new Set([...entityRefs, ...filteredAstIdentifiers]);\n return Array.from(combined);\n } catch {\n // If parsing fails, fall back to entity-based references only\n return entityRefs;\n }\n}\n\n/**\n * Creates a function signature with destructured parameters for the SDK.\n * Example: signatureV2("hasMore.value", ["hasMore", "offset"]) => "({ hasMore }) => hasMore.value"\n */\nexport function signatureV2(data: string, entities: string[] = []): string {\n return `({ ${extractReferencedIdentifiers(data, entities).join(", ")} }) => ${data}`;\n}\n\n/**\n * Creates an async function signature with destructured parameters for the SDK.\n * Example: signatureV2Async("await fetch()", ["url"]) => "async ({ url }) => await fetch()"\n */\nexport function signatureV2Async(\n data: string,\n entities: string[] = [],\n): string {\n return `async ({ ${extractReferencedIdentifiers(data, entities).join(", ")} }) => ${data}`;\n}\n\n/**\n * Extracts identifier names from an AST by walking the tree.\n */\nexport function extractIdentifiers(\n node: Node,\n identifiers: Set<string> = new Set(),\n): Set<string> {\n if (!node) {\n return identifiers;\n }\n\n // we only care about the root of the expression, so we gotta unwind the subtree\n if (node.type === "MemberExpression") {\n const memberExpr = node as any;\n extractIdentifiers(memberExpr.object, identifiers);\n return identifiers;\n }\n\n if (node.type === "Identifier") {\n identifiers.add((node as any).name);\n }\n\n for (const key in node) {\n const value = (node as any)[key];\n\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n extractIdentifiers(item, identifiers);\n }\n }\n } else if (value.type) {\n extractIdentifiers(value, identifiers);\n }\n }\n }\n\n return identifiers;\n}\n',
711763
+ "src/superblocks-library-shim/ast-utils.ts": 'import { Node, parse, Program } from "acorn";\n\n/**\n * Creates an AST from a string value.\n * If the value starts and ends with braces, wraps it in parentheses to parse as an object literal.\n */\nexport function createAst(value: string): Program {\n if (value.startsWith("{") && value.endsWith("}")) {\n value = `(${value})`;\n }\n\n return parse(value, {\n ecmaVersion: "latest",\n sourceType: "script",\n preserveParens: false,\n });\n}\n\n/**\n * Finds entity references in a code string using AST parsing.\n * Returns an array of entity names that are referenced in the code.\n *\n * IMPORTANT: This function excludes identifiers that are declared locally\n * within the code (e.g., `const item = ...` means `item` won\'t be returned\n * even if it\'s in the entities list). This prevents duplicate declarations\n * when the result is used to create function parameters.\n */\nexport function referenced(data: string, entities: string[]): string[] {\n if (!data || entities.length === 0) {\n return [];\n }\n\n const entitySet = new Set(entities);\n\n // Try parsing strategies in order of likelihood\n const parseStrategies = data.startsWith("{")\n ? [\n // For code starting with {, try as object literal first (wrapped in parens)\n () =>\n parse(`(${data})`, { ecmaVersion: "latest", sourceType: "script" }),\n // Then try as block statement (for code like { const x = ...; return x; })\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ]\n : [\n // Parse as script (handles statements like const, return, etc.)\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ];\n\n for (const strategy of parseStrategies) {\n try {\n const ast = strategy();\n if (ast) {\n // Use scope-aware extraction to properly handle local declarations\n const allRefs = extractExternalReferencesWithScope(ast, new Set());\n // Filter to only include entities that are referenced AND not locally declared\n return Array.from(allRefs).filter((ref) => entitySet.has(ref));\n }\n } catch {\n // Try next strategy\n }\n }\n\n return [];\n}\n\n/**\n * Collect identifiers from destructuring patterns (ObjectPattern, ArrayPattern)\n */\nexport function collectPatternIdentifiers(\n pattern: Node,\n identifiers: Set<string>,\n): void {\n if (!pattern) return;\n\n if ((pattern as any).type === "Identifier") {\n identifiers.add((pattern as any).name);\n } else if ((pattern as any).type === "ObjectPattern") {\n for (const prop of (pattern as any).properties || []) {\n if (prop.type === "Property") {\n collectPatternIdentifiers(prop.value, identifiers);\n } else if (prop.type === "RestElement") {\n collectPatternIdentifiers(prop.argument, identifiers);\n }\n }\n } else if ((pattern as any).type === "ArrayPattern") {\n for (const elem of (pattern as any).elements || []) {\n if (elem) {\n collectPatternIdentifiers(elem, identifiers);\n }\n }\n } else if ((pattern as any).type === "RestElement") {\n collectPatternIdentifiers((pattern as any).argument, identifiers);\n } else if ((pattern as any).type === "AssignmentPattern") {\n collectPatternIdentifiers((pattern as any).left, identifiers);\n }\n}\n\n/**\n * Collect function parameter names into a set\n */\nexport function collectFunctionParams(fn: any, params: Set<string>): void {\n for (const param of fn.params || []) {\n if (param.type === "Identifier") {\n params.add(param.name);\n } else if (\n param.type === "ObjectPattern" ||\n param.type === "ArrayPattern"\n ) {\n collectPatternIdentifiers(param, params);\n } else if (param.type === "AssignmentPattern" && param.left) {\n if (param.left.type === "Identifier") {\n params.add(param.left.name);\n } else if (\n param.left.type === "ObjectPattern" ||\n param.left.type === "ArrayPattern"\n ) {\n collectPatternIdentifiers(param.left, params);\n }\n }\n }\n}\n\n/**\n * Check if a node is a function node (arrow function, function expression, or function declaration)\n */\nexport function isFunctionNode(node: any): boolean {\n return (\n node.type === "ArrowFunctionExpression" ||\n node.type === "FunctionExpression" ||\n node.type === "FunctionDeclaration"\n );\n}\n\n/**\n * Collect variable declarations at the current scope level only.\n * Does NOT recurse into nested functions (their declarations are their own scope).\n */\nexport function collectCurrentScopeLocals(\n node: Node,\n locals: Set<string>,\n): void {\n if (!node) return;\n\n // VariableDeclarator: const foo = ...\n if (node.type === "VariableDeclarator") {\n const decl = node as any;\n if (decl.id?.type === "Identifier") {\n locals.add(decl.id.name);\n }\n if (decl.id?.type === "ObjectPattern" || decl.id?.type === "ArrayPattern") {\n collectPatternIdentifiers(decl.id, locals);\n }\n // Process the init value for nested declarations (but not function bodies)\n if (decl.init && !isFunctionNode(decl.init)) {\n collectCurrentScopeLocals(decl.init, locals);\n }\n return;\n }\n\n // FunctionDeclaration: function foo() {} - the name is local, but don\'t process body\n if (node.type === "FunctionDeclaration") {\n const fn = node as any;\n if (fn.id?.type === "Identifier") {\n locals.add(fn.id.name);\n }\n // Don\'t recurse into function body - its locals are scoped to it\n return;\n }\n\n // ArrowFunctionExpression / FunctionExpression - don\'t recurse, their scope is separate\n if (\n node.type === "ArrowFunctionExpression" ||\n node.type === "FunctionExpression"\n ) {\n return;\n }\n\n // CatchClause param is local to the catch block\n if (node.type === "CatchClause") {\n const catchClause = node as any;\n if (catchClause.param?.type === "Identifier") {\n locals.add(catchClause.param.name);\n }\n // Continue to process the body\n if (catchClause.body) {\n collectCurrentScopeLocals(catchClause.body, locals);\n }\n return;\n }\n\n // Recursively process child nodes (except functions)\n for (const key in node) {\n const value = (node as any)[key];\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n collectCurrentScopeLocals(item, locals);\n }\n }\n } else if (value.type) {\n collectCurrentScopeLocals(value, locals);\n }\n }\n }\n}\n\n/**\n * Extract references from a node, handling nested functions with their own scope.\n */\nexport function extractRefsFromNode(\n node: Node,\n locals: Set<string>,\n refs: Set<string>,\n): void {\n if (!node) return;\n\n // Handle nested functions - recurse with their params added to locals\n if (\n node.type === "ArrowFunctionExpression" ||\n node.type === "FunctionExpression" ||\n node.type === "FunctionDeclaration"\n ) {\n const fn = node as any;\n // Create new scope with outer locals + this function\'s params\n const innerLocals = new Set(locals);\n collectFunctionParams(fn, innerLocals);\n // Also collect locals declared inside the function body\n if (fn.body) {\n collectCurrentScopeLocals(fn.body, innerLocals);\n }\n // Extract refs from function body with the inner scope\n if (fn.body) {\n extractRefsFromNode(fn.body, innerLocals, refs);\n }\n return;\n }\n\n // MemberExpression: only care about the root object\n if (node.type === "MemberExpression") {\n const memberExpr = node as any;\n extractRefsFromNode(memberExpr.object, locals, refs);\n return;\n }\n\n // Property in object literal: skip key, only process value\n if (node.type === "Property") {\n const prop = node as any;\n if (prop.shorthand && prop.key?.type === "Identifier") {\n // { foo } is shorthand for { foo: foo } - foo is a reference\n if (!locals.has(prop.key.name)) {\n refs.add(prop.key.name);\n }\n } else {\n // Process computed keys and values\n if (prop.computed) {\n extractRefsFromNode(prop.key, locals, refs);\n }\n extractRefsFromNode(prop.value, locals, refs);\n }\n return;\n }\n\n // VariableDeclarator: only process the init, not the id\n if (node.type === "VariableDeclarator") {\n const decl = node as any;\n if (decl.init) {\n extractRefsFromNode(decl.init, locals, refs);\n }\n return;\n }\n\n // Identifier: add if not a local\n if (node.type === "Identifier") {\n const name = (node as any).name;\n if (!locals.has(name)) {\n refs.add(name);\n }\n return;\n }\n\n // Recursively process child nodes\n for (const key in node) {\n const value = (node as any)[key];\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n extractRefsFromNode(item, locals, refs);\n }\n }\n } else if (value.type) {\n extractRefsFromNode(value, locals, refs);\n }\n }\n }\n}\n\n/**\n * Extract external variable references from AST with proper scope handling.\n *\n * This function:\n * - Tracks local declarations at each scope level\n * - Properly handles nested functions (their params are local to them, not outer scope)\n * - Extracts references from nested function bodies that refer to outer scope variables\n * - Excludes object literal property keys\n * - Only extracts root object from member expressions (Step1.value -> Step1)\n */\nexport function extractExternalReferencesWithScope(\n node: Node,\n outerLocals: Set<string>,\n refs: Set<string> = new Set(),\n): Set<string> {\n if (!node) return refs;\n\n // Collect locals at current scope level (not including nested function scopes)\n const currentLocals = new Set(outerLocals);\n collectCurrentScopeLocals(node, currentLocals);\n\n // Now extract references\n extractRefsFromNode(node, currentLocals, refs);\n\n return refs;\n}\n\n/**\n * Extract variable reference identifiers from a function body using AST parsing.\n * Properly handles nested scopes - inner function params don\'t leak to outer scope.\n */\nexport function extractVariableReferences(node: Node): Set<string> {\n return extractExternalReferencesWithScope(node, new Set());\n}\n\n/**\n * JavaScript built-in globals that should not be treated as external variable references.\n * These are available in any JavaScript context and don\'t need to be destructured from parameters.\n */\nexport const JS_GLOBALS = new Set([\n // Constructors / Type converters\n "String",\n "Number",\n "Boolean",\n "Object",\n "Array",\n "Function",\n "Symbol",\n "BigInt",\n "Date",\n "RegExp",\n "Error",\n "TypeError",\n "ReferenceError",\n "SyntaxError",\n "RangeError",\n "URIError",\n "EvalError",\n "Map",\n "Set",\n "WeakMap",\n "WeakSet",\n "Promise",\n "Proxy",\n "Reflect",\n "ArrayBuffer",\n "SharedArrayBuffer",\n "DataView",\n "Int8Array",\n "Uint8Array",\n "Uint8ClampedArray",\n "Int16Array",\n "Uint16Array",\n "Int32Array",\n "Uint32Array",\n "Float32Array",\n "Float64Array",\n "BigInt64Array",\n "BigUint64Array",\n // Global functions\n "parseInt",\n "parseFloat",\n "isNaN",\n "isFinite",\n "encodeURI",\n "encodeURIComponent",\n "decodeURI",\n "decodeURIComponent",\n "eval",\n // Global objects\n "Math",\n "JSON",\n "console",\n "Intl",\n "Atomics",\n // Global values\n "undefined",\n "NaN",\n "Infinity",\n "globalThis",\n // Node.js globals (commonly used)\n "Buffer",\n "process",\n "setTimeout",\n "setInterval",\n "setImmediate",\n "clearTimeout",\n "clearInterval",\n "clearImmediate",\n "queueMicrotask",\n]);\n\n/**\n * Extract identifiers from a function body using AST parsing.\n * Falls back to entity-based filtering if parsing fails.\n * Filters out JavaScript built-in globals.\n */\nexport function extractReferencedIdentifiers(\n data: string,\n entities: string[],\n): string[] {\n // First try entity-based references\n const entityRefs = referenced(data, entities);\n\n // Also try to extract identifiers from the code itself using AST parsing\n // This catches parameters that aren\'t in the entities list (like API inputs)\n try {\n // Try parsing strategies - handle both expressions and statements with return\n const parseStrategies = data.startsWith("{")\n ? [\n // For code starting with {, try as object literal first\n () =>\n parse(`(${data})`, {\n ecmaVersion: "latest",\n sourceType: "script",\n }),\n // Then try as block statement\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ]\n : [\n // For other code, try with allowReturnOutsideFunction for function bodies\n () =>\n parse(data, {\n ecmaVersion: "latest",\n sourceType: "script",\n allowReturnOutsideFunction: true,\n }),\n ];\n\n let ast: Node | null = null;\n for (const strategy of parseStrategies) {\n try {\n ast = strategy();\n if (ast) break;\n } catch {\n // Try next strategy\n }\n }\n\n if (!ast) {\n return entityRefs;\n }\n\n const astIdentifiers = Array.from(extractVariableReferences(ast));\n\n // Filter out JavaScript globals - they don\'t need to be destructured\n const filteredAstIdentifiers = astIdentifiers.filter(\n (id) => !JS_GLOBALS.has(id),\n );\n\n // Combine entity refs with AST-extracted identifiers (deduplicated)\n const combined = new Set([...entityRefs, ...filteredAstIdentifiers]);\n return Array.from(combined);\n } catch {\n // If parsing fails, fall back to entity-based references only\n return entityRefs;\n }\n}\n\n/**\n * Creates a function signature with destructured parameters for the SDK.\n * Example: signatureV2("hasMore.value", ["hasMore", "offset"]) => "({ hasMore }) => hasMore.value"\n */\nexport function signatureV2(data: string, entities: string[] = []): string {\n return `({ ${extractReferencedIdentifiers(data, entities).join(", ")} }) => ${data}`;\n}\n\n/**\n * Creates an async function signature with destructured parameters for the SDK.\n * Example: signatureV2Async("await fetch()", ["url"]) => "async ({ url }) => await fetch()"\n */\nexport function signatureV2Async(\n data: string,\n entities: string[] = [],\n): string {\n return `async ({ ${extractReferencedIdentifiers(data, entities).join(", ")} }) => ${data}`;\n}\n\n/**\n * Extracts identifier names from an AST by walking the tree.\n */\nexport function extractIdentifiers(\n node: Node,\n identifiers: Set<string> = new Set(),\n): Set<string> {\n if (!node) {\n return identifiers;\n }\n\n // we only care about the root of the expression, so we gotta unwind the subtree\n if (node.type === "MemberExpression") {\n const memberExpr = node as any;\n extractIdentifiers(memberExpr.object, identifiers);\n return identifiers;\n }\n\n if (node.type === "Identifier") {\n identifiers.add((node as any).name);\n }\n\n for (const key in node) {\n const value = (node as any)[key];\n\n if (value && typeof value === "object") {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === "object" && item.type) {\n extractIdentifiers(item, identifiers);\n }\n }\n } else if (value.type) {\n extractIdentifiers(value, identifiers);\n }\n }\n }\n\n return identifiers;\n}\n',
711737
711764
  "src/superblocks-library-shim/index.d.ts": `export type JsonValue = any;
711738
711765
 
711739
711766
  export type State = { [key: string]: JsonValue };
@@ -711918,6 +711945,7 @@ export declare class RestApi extends Integration {
711918
711945
  headers?: { key: Binding<string>; value: Binding<string> }[];
711919
711946
  params?: { key: Binding<string>; value: Binding<string> }[];
711920
711947
  body?: Binding<string>;
711948
+ bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";
711921
711949
  },
711922
711950
  openapi?: {
711923
711951
  path: string;
@@ -711989,6 +712017,7 @@ export declare class OpenApi extends RestApi {
711989
712017
  headers?: { key: Binding<string>; value: Binding<string> }[];
711990
712018
  params?: { key: Binding<string>; value: Binding<string> }[];
711991
712019
  body?: Binding<string>;
712020
+ bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";
711992
712021
  },
711993
712022
  openapi?: {
711994
712023
  path: string;
@@ -712004,6 +712033,7 @@ export declare class OpenApi extends RestApi {
712004
712033
  headers?: { key: Binding<string>; value: Binding<string> }[];
712005
712034
  params?: { key: Binding<string>; value: Binding<string> }[];
712006
712035
  body?: Binding<string>;
712036
+ bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";
712007
712037
  };
712008
712038
 
712009
712039
  public static openapiFromJSON(json: any):
@@ -712099,6 +712129,255 @@ export declare class Databricks extends Integration {
712099
712129
  public static fromJSON(json: any, entities: string[]): Databricks;
712100
712130
  }
712101
712131
 
712132
+ // Object Storage Integrations
712133
+
712134
+ export type GCSAction =
712135
+ | "LIST_OBJECTS"
712136
+ | "GET_OBJECT"
712137
+ | "DELETE_OBJECT"
712138
+ | "UPLOAD_OBJECT"
712139
+ | "LIST_BUCKETS"
712140
+ | "CREATE_BUCKET"
712141
+ | "UPLOAD_MULTIPLE_OBJECTS"
712142
+ | "GENERATE_PRESIGNED_URL";
712143
+
712144
+ export interface GoogleCloudStorageConfig {
712145
+ action: GCSAction;
712146
+ /** Bucket name */
712147
+ resource?: Binding<string>;
712148
+ /** Object path within the bucket */
712149
+ path?: Binding<string>;
712150
+ /** Prefix for listing objects */
712151
+ prefix?: Binding<string>;
712152
+ /** Content to upload */
712153
+ body?: Binding<string>;
712154
+ /** Multiple files to upload */
712155
+ fileObjects?: Binding<any[]>;
712156
+ /** Response format */
712157
+ responseType?: "AUTO" | "JSON" | "TEXT" | "BINARY";
712158
+ custom?: {
712159
+ presignedExpiration?: { value: number };
712160
+ };
712161
+ }
712162
+
712163
+ export declare class GoogleCloudStorage extends Integration {
712164
+ constructor(
712165
+ name: string,
712166
+ integration: string,
712167
+ config: GoogleCloudStorageConfig,
712168
+ );
712169
+
712170
+ public toJSON(): Promise<JsonValue>;
712171
+ public toSDK(entities: string[]): Promise<string>;
712172
+ public static fromJSON(json: any, entities: string[]): GoogleCloudStorage;
712173
+ }
712174
+
712175
+ export type S3Action =
712176
+ | "LIST_OBJECTS"
712177
+ | "LIST_BUCKET_OBJECTS"
712178
+ | "GET_OBJECT"
712179
+ | "DELETE_OBJECT"
712180
+ | "UPLOAD_OBJECT"
712181
+ | "LIST_BUCKETS"
712182
+ | "CREATE_BUCKET"
712183
+ | "UPLOAD_MULTIPLE_OBJECTS"
712184
+ | "GENERATE_PRESIGNED_URL";
712185
+
712186
+ export interface S3Config {
712187
+ action: S3Action;
712188
+ /** Bucket name */
712189
+ resource?: Binding<string>;
712190
+ /** Object path/key within the bucket */
712191
+ path?: Binding<string>;
712192
+ /** Content to upload */
712193
+ body?: Binding<string>;
712194
+ /** Multiple files to upload */
712195
+ fileObjects?: Binding<any[]>;
712196
+ /** Configuration for listing files */
712197
+ listFilesConfig?: {
712198
+ prefix?: Binding<string>;
712199
+ delimiter?: Binding<string>;
712200
+ };
712201
+ custom?: {
712202
+ presignedMethod?:
712203
+ | "PRESIGNED_METHOD_UNSPECIFIED"
712204
+ | "PRESIGNED_METHOD_GET"
712205
+ | "PRESIGNED_METHOD_PUT";
712206
+ presignedExpiration?: { value: number };
712207
+ };
712208
+ }
712209
+
712210
+ export declare class S3 extends Integration {
712211
+ constructor(name: string, integration: string, config: S3Config);
712212
+
712213
+ public toJSON(): Promise<JsonValue>;
712214
+ public toSDK(entities: string[]): Promise<string>;
712215
+ public static fromJSON(json: any, entities: string[]): S3;
712216
+ }
712217
+
712218
+ // Additional SQL Database Integrations
712219
+
712220
+ export interface CockroachDBConfig {
712221
+ statement: Binding<string>;
712222
+ /** Parameters for the SQL query (PostgreSQL-compatible $1, $2, etc.) */
712223
+ parameters?: Binding<string>;
712224
+ }
712225
+
712226
+ export declare class CockroachDB extends Integration {
712227
+ constructor(name: string, integration: string, config: CockroachDBConfig);
712228
+
712229
+ public toJSON(): Promise<JsonValue>;
712230
+ public toSDK(entities: string[]): Promise<string>;
712231
+ public static fromJSON(json: any, entities: string[]): CockroachDB;
712232
+ }
712233
+
712234
+ export interface OracleDBConfig {
712235
+ statement: Binding<string>;
712236
+ parameters?: Binding<string>;
712237
+ }
712238
+
712239
+ export declare class OracleDB extends Integration {
712240
+ constructor(name: string, integration: string, config: OracleDBConfig);
712241
+
712242
+ public toJSON(): Promise<JsonValue>;
712243
+ public toSDK(entities: string[]): Promise<string>;
712244
+ public static fromJSON(json: any, entities: string[]): OracleDB;
712245
+ }
712246
+
712247
+ // GraphQL Integration
712248
+
712249
+ export interface GraphQLConfig {
712250
+ /** GraphQL query or mutation */
712251
+ query: Binding<string>;
712252
+ /** Variables for the query */
712253
+ variables?: Binding<string>;
712254
+ /** Additional headers */
712255
+ headers?: { key: Binding<string>; value: Binding<string> }[];
712256
+ }
712257
+
712258
+ export declare class GraphQL extends Integration {
712259
+ constructor(name: string, integration: string, config: GraphQLConfig);
712260
+
712261
+ public toJSON(): Promise<JsonValue>;
712262
+ public toSDK(entities: string[]): Promise<string>;
712263
+ public static fromJSON(json: any, entities: string[]): GraphQL;
712264
+ }
712265
+
712266
+ // NoSQL Database Integrations
712267
+
712268
+ export type MongoDBOperation =
712269
+ | "aggregate"
712270
+ | "count"
712271
+ | "deleteOne"
712272
+ | "deleteMany"
712273
+ | "distinct"
712274
+ | "find"
712275
+ | "findOne"
712276
+ | "insertOne"
712277
+ | "insertMany"
712278
+ | "listCollections"
712279
+ | "replaceOne"
712280
+ | "updateOne"
712281
+ | "updateMany";
712282
+
712283
+ export interface MongoDBConfig {
712284
+ operation: MongoDBOperation;
712285
+ /** Collection name */
712286
+ collection?: Binding<string>;
712287
+ /** Query filter */
712288
+ query?: Binding<any>;
712289
+ /** Filter for update/delete operations */
712290
+ filter?: Binding<any>;
712291
+ /** Update document for update operations */
712292
+ update?: Binding<any>;
712293
+ /** Replacement document */
712294
+ replacement?: Binding<any>;
712295
+ /** Document to insert */
712296
+ document?: Binding<any>;
712297
+ /** Aggregation pipeline */
712298
+ pipeline?: Binding<any[]>;
712299
+ /** Field name for distinct operation */
712300
+ field?: Binding<string>;
712301
+ /** Fields to return */
712302
+ projection?: Binding<any>;
712303
+ /** Sort specification */
712304
+ sortby?: Binding<any>;
712305
+ /** Maximum documents to return */
712306
+ limit?: Binding<number>;
712307
+ /** Documents to skip */
712308
+ skip?: Binding<number>;
712309
+ /** Additional options */
712310
+ options?: Binding<any>;
712311
+ }
712312
+
712313
+ export declare class MongoDB extends Integration {
712314
+ constructor(name: string, integration: string, config: MongoDBConfig);
712315
+
712316
+ public toJSON(): Promise<JsonValue>;
712317
+ public toSDK(entities: string[]): Promise<string>;
712318
+ public static fromJSON(json: any, entities: string[]): MongoDB;
712319
+ }
712320
+
712321
+ export type CouchbaseAction = "runSql" | "insert" | "get" | "remove";
712322
+
712323
+ export interface CouchbaseConfig {
712324
+ action: CouchbaseAction;
712325
+ /** Bucket name */
712326
+ bucket?: Binding<string>;
712327
+ /** Scope within the bucket */
712328
+ scope?: Binding<string>;
712329
+ /** Collection within the scope */
712330
+ collection?: Binding<string>;
712331
+ /** SQL++ query (for runSql action) */
712332
+ sqlBody?: Binding<string>;
712333
+ /** Document key (for get/insert/remove) */
712334
+ key?: Binding<string>;
712335
+ /** Document to insert */
712336
+ document?: Binding<any>;
712337
+ }
712338
+
712339
+ export declare class Couchbase extends Integration {
712340
+ constructor(name: string, integration: string, config: CouchbaseConfig);
712341
+
712342
+ public toJSON(): Promise<JsonValue>;
712343
+ public toSDK(entities: string[]): Promise<string>;
712344
+ public static fromJSON(json: any, entities: string[]): Couchbase;
712345
+ }
712346
+
712347
+ export type CosmosDBActionType = "sql" | "pointOperation";
712348
+ export type CosmosDBPointAction =
712349
+ | "create"
712350
+ | "read"
712351
+ | "upsert"
712352
+ | "replace"
712353
+ | "delete";
712354
+
712355
+ export interface CosmosDBConfig {
712356
+ actionType: CosmosDBActionType;
712357
+ /** Container ID */
712358
+ containerId?: Binding<string>;
712359
+ /** SQL query (for sql action type) */
712360
+ query?: Binding<string>;
712361
+ /** Enable cross-partition queries */
712362
+ crossPartition?: boolean;
712363
+ /** Partition key value */
712364
+ partitionKey?: Binding<string>;
712365
+ /** Point operation action (for pointOperation action type) */
712366
+ pointAction?: CosmosDBPointAction;
712367
+ /** Item ID (for point operations) */
712368
+ itemId?: Binding<string>;
712369
+ /** Document body (for create/upsert/replace) */
712370
+ body?: Binding<any>;
712371
+ }
712372
+
712373
+ export declare class CosmosDB extends Integration {
712374
+ constructor(name: string, integration: string, config: CosmosDBConfig);
712375
+
712376
+ public toJSON(): Promise<JsonValue>;
712377
+ public toSDK(entities: string[]): Promise<string>;
712378
+ public static fromJSON(json: any, entities: string[]): CosmosDB;
712379
+ }
712380
+
712102
712381
  export type Condition = {
712103
712382
  when: Binding<boolean>;
712104
712383
  then: Block[];
@@ -712123,11 +712402,17 @@ export declare class Conditional extends Block {
712123
712402
  export declare class Parallel extends Block {
712124
712403
  constructor(
712125
712404
  name: string,
712126
- config: {
712127
- over: Binding<JsonValue[]>;
712128
- variables: { item: string };
712129
- blocks: Block[];
712130
- },
712405
+ config:
712406
+ | {
712407
+ mode?: "dynamic";
712408
+ over: Binding<JsonValue[]>;
712409
+ variables?: { item: string }; // Optional - defaults to { item: "item" }
712410
+ blocks: Block[];
712411
+ }
712412
+ | {
712413
+ mode: "static";
712414
+ paths: Record<string, Block[]>;
712415
+ },
712131
712416
  );
712132
712417
 
712133
712418
  public toJSON(): Promise<JsonValue>;
@@ -712241,7 +712526,7 @@ export declare class Api {
712241
712526
  public static fromJSON(json: any, entities: string[]): Api;
712242
712527
  }
712243
712528
  `,
712244
- "src/superblocks-library-shim/index.ts": '/* eslint-disable */\nimport typescript_eslint_parser from "@typescript-eslint/parser";\nimport {\n CallExpression,\n ExpressionStatement,\n FunctionExpression,\n Literal,\n Node,\n parse,\n UnaryExpression,\n} from "acorn";\nimport { ESLint } from "eslint";\nimport { format } from "prettier";\nimport {\n createAst,\n extractIdentifiers,\n referenced,\n signatureV2,\n signatureV2Async,\n} from "./ast-utils.js";\n\n// Re-export AST utilities for external use\nexport { referenced, signatureV2, signatureV2Async } from "./ast-utils.js";\n\n/**\n * Global context for version-aware output generation.\n * pluginExecutionVersions is populated from the PLUGIN_EXECUTION_VERSIONS environment variable.\n */\nexport const Global: {\n /** Map of plugin ID to version string, used for version-aware output generation */\n pluginExecutionVersions?: Record<string, string>;\n} = {};\n\nexport type JsonValue = any;\n\n// This is the ideal type, but it\'s too restrictive when we use it for generating code,\n// because the builder side is doing access like `someVar.value`, but JsonValue is not\n// strict enough to avoid type errors, so you see a lot of:\n// error TS2551: Property \'value\' does not exist on type \'JsonValue\'. Did you mean \'valueOf\'?\n// Property \'value\' does not exist on type \'string\'.\n//\n// export type JsonValue =\n// | undefined\n// | null\n// | number\n// | string\n// | boolean\n// | Array<JsonValue>\n// | { [key: string]: JsonValue };\nexport type State = { [key: string]: JsonValue };\nexport type Binding<T> = T | ((state: State) => T);\n\nexport function trimSqlSpaces(content: string): string {\n if (!content) return "";\n return content\n .replace(/[ \\t]+/g, " ") // Replace multiple spaces/tabs with single space\n .replace(/[ \\t]*\\n[ \\t]*/g, "\\n") // Remove spaces around line breaks\n .replace(/^\\s+|\\s+$/g, "") // Trim leading and trailing whitespace\n .trim();\n}\nasync function binding(binding: Binding<any>): Promise<string> {\n if (typeof binding === "function") {\n const { body, node } = await toJS(binding);\n\n if (\n node?.type === "Literal" &&\n typeof (node as Literal).value === "string"\n ) {\n return `\\`${(node as Literal).value}\\``;\n }\n\n if (node?.type === "TemplateLiteral") {\n return body;\n }\n\n return `\\`\\$\\{${body}\\}\\``;\n }\n\n return `\\`${binding}\\``;\n}\n\nasync function formatGraphQLQuery(query: string): Promise<string> {\n if (!query || typeof query !== "string") {\n return query;\n }\n\n try {\n const formatted = await format(query, {\n parser: "graphql",\n printWidth: 80,\n tabWidth: 2,\n useTabs: false,\n });\n return formatted.trim();\n } catch (error) {\n // if prettier fails to format, return the original query\n return query;\n }\n}\n\nexport async function bindingSql(binding: Binding<string>): Promise<string> {\n if (typeof binding === "function") {\n const ret = await toJSBody(binding as (state: State) => string, {\n condense: false,\n });\n const { body, iife, node } = ret;\n\n if (\n node?.type === "Literal" &&\n typeof (node as Literal).value === "string"\n ) {\n const escapedValue = (node as Literal).value as string;\n // Escape backticks in the SQL string\n const escaped = escapedValue.replace(/`/g, "\\\\`");\n return `\\`${trimSqlSpaces(escaped)}\\``;\n }\n\n if (node?.type === "TemplateLiteral") {\n const trimmedBody = trimSqlSpaces(body);\n return iife ? `(() => ${trimmedBody})()` : trimmedBody;\n }\n\n let finalBody = body;\n\n if (iife) {\n finalBody = `(() => ${body})()`;\n }\n\n finalBody = trimSqlSpaces(finalBody);\n\n // Special handling for template literals - trim content within backticks\n finalBody = finalBody.replace(/`([^`]*)`/g, (_match, content) => {\n const trimmedContent = trimSqlSpaces(content);\n return `\\`${trimmedContent}\\``;\n });\n\n return `\\`\\$\\{${finalBody}\\}\\``;\n }\n\n const trimmedBinding = trimSqlSpaces(binding);\n // Escape backticks in the SQL string\n const escaped = trimmedBinding.replace(/`/g, "\\\\`");\n return `\\`${escaped}\\``;\n}\n\nexport async function bindingGraphQL(\n binding: Binding<string>,\n): Promise<string> {\n if (typeof binding === "function") {\n const ret = await toJSBody(binding as (state: State) => string, {\n condense: false,\n });\n const { body, iife, node } = ret;\n\n if (\n node?.type === "Literal" &&\n typeof (node as Literal).value === "string"\n ) {\n const formatted = await formatGraphQLQuery(\n (node as Literal).value as string,\n );\n return `\\`${formatted}\\``;\n }\n\n if (node?.type === "TemplateLiteral") {\n return iife ? `(() => ${body})()` : body;\n }\n\n let finalBody = body;\n\n if (iife) {\n finalBody = `(() => ${body})()`;\n }\n\n return `\\`\\$\\{${finalBody}\\}\\``;\n }\n\n const formatted = await formatGraphQLQuery(binding);\n return `\\`${formatted}\\``;\n}\n\ninterface Codec {\n toJSON(): Promise<JsonValue>;\n toSDK(entities: string[]): Promise<string>;\n}\n\nexport abstract class Block implements Codec {\n protected name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n public abstract toJSON(): Promise<JsonValue>;\n public abstract toSDK(entities: string[]): Promise<string>;\n\n public static fromJSON(json: any, entities: string[]): Block {\n if (json?.step) {\n return Integration.fromJSON(json, entities);\n }\n\n if ("conditional" in json) {\n return Conditional.fromJSON(json, entities);\n }\n\n if ("loop" in json) {\n return Loop.fromJSON(json, entities);\n }\n\n if ("parallel" in json) {\n return Parallel.fromJSON(json, entities);\n }\n\n if ("tryCatch" in json) {\n return TryCatch.fromJSON(json, entities);\n }\n\n if ("variables" in json) {\n return Variables.fromJSON(json, entities);\n }\n\n if ("throw" in json) {\n return Throw.fromJSON(json, entities);\n }\n\n if ("return" in json) {\n return Return.fromJSON(json, entities);\n }\n\n if ("break" in json) {\n return Break.fromJSON(json, entities);\n }\n\n throw new Error("Unknown block");\n }\n}\n\nexport abstract class Integration extends Block {\n protected integration: string;\n\n constructor(name: string, integration: string) {\n super(name);\n\n this.integration = integration;\n }\n\n public abstract toJSON(): Promise<JsonValue>;\n public abstract toSDK(entities: string[]): Promise<string>;\n\n private static integrationRegistry: Record<string, any> = {};\n\n public static registerIntegration(key: string, integrationClass: any) {\n this.integrationRegistry[key] = integrationClass;\n }\n\n public static getRegisteredIntegrationClasses(): any[] {\n return Object.values(this.integrationRegistry);\n }\n\n public static getRegisteredIntegrationClassNames(): string[] {\n return Object.values(this.integrationRegistry).map((cls) => cls.name);\n }\n\n /**\n * Returns a map of pluginId -> className for all registered integrations.\n * @internal Used only for consistency tests - not part of the public API.\n */\n public static getRegisteredIntegrationMap(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(this.integrationRegistry).map(([key, cls]) => [\n key,\n cls.name,\n ]),\n );\n }\n\n public static fromJSON(json: any, entities: string[]): Block {\n if ("restapi" in json?.step || "restapiintegration" in json?.step) {\n return RestApi.fromJSON(json, entities);\n }\n\n for (const [key, IntegrationClass] of Object.entries(\n this.integrationRegistry,\n )) {\n if (key in json?.step) {\n return IntegrationClass.fromJSON(json, entities);\n }\n }\n\n console.error("Unknown integration", json?.step);\n throw new Error("Unknown integration");\n }\n}\n\nexport class Python extends Integration {\n private fn: string;\n\n constructor(\n name: string,\n config: {\n fn: string;\n },\n ) {\n super(name, "python");\n\n this.fn = config.fn;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: "python",\n python: {\n body: this.fn,\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Python("${this.name}", { fn: ${this.fn} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Python {\n return new Python(json?.name, {\n fn: json?.step?.python?.body,\n });\n }\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/AsyncFunction\nconst AsyncFunction: any = async function () {}.constructor;\n\nexport class JavaScript extends Integration {\n private fn: (_: State) => JsonValue;\n\n constructor(\n name: string,\n config: {\n fn: (_: State) => JsonValue;\n },\n ) {\n super(name, "javascript");\n\n this.fn = config.fn;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: "javascript",\n javascript: {\n body: (await toJSBody(this.fn, { block: false, function: true }))\n .body,\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new JavaScript("${this.name}", { fn: ${signatureV2Async((await toJSBody(this.fn)).body, entities)} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): JavaScript {\n const args = [json?.step?.javascript?.body];\n const references = referenced(json?.step?.javascript?.body, entities);\n\n if (references.length > 0) {\n args.unshift(`{ ${references.join(", ")} }`);\n }\n\n return new JavaScript(json?.name, {\n fn: new AsyncFunction(...args) as (_: State) => JsonValue,\n });\n }\n}\n\nexport interface AthenaConfig {\n sqlBody: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Athena extends Integration {\n private sqlBody: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: AthenaConfig) {\n super(name, integration);\n\n this.sqlBody = config.sqlBody;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n athena: {\n runSql: {\n sqlBody: await bindingSql(this.sqlBody),\n },\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.athena.runSql.parameters = bound.replace(/^`|`$/g, "");\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.sqlBody === "function"\n ? signatureV2(\n (await toJSBody(this.sqlBody, { condense: false })).body,\n entities,\n )\n : `\\`${this.sqlBody}\\``;\n\n const parts = [`sqlBody: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Athena("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Athena {\n const athena = json?.step?.athena?.runSql;\n\n return new Athena(json?.name, json?.step?.integration, {\n sqlBody: fromBinding(athena?.sqlBody, entities),\n parameters:\n athena?.parameters !== undefined\n ? fromBinding(athena.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface BigQueryConfig {\n sqlBody: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class BigQuery extends Integration {\n private sqlBody: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: BigQueryConfig) {\n super(name, integration);\n\n this.sqlBody = config.sqlBody;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n bigquery: {\n body: await bindingSql(this.sqlBody),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.bigquery.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.bigquery.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.sqlBody === "function"\n ? signatureV2(\n (await toJSBody(this.sqlBody, { condense: false })).body,\n entities,\n )\n : `\\`${this.sqlBody}\\``;\n\n const parts = [`sqlBody: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new BigQuery("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): BigQuery {\n const bigquery = json?.step?.bigquery;\n\n return new BigQuery(json?.name, json?.step?.integration, {\n sqlBody: fromBinding(bigquery?.body, entities),\n parameters:\n bigquery?.parameters !== undefined\n ? fromBinding(bigquery.parameters, entities)\n : undefined,\n });\n }\n}\n\ntype DynamoDbAction =\n | "getItem"\n | "updateItem"\n | "putItem"\n | "batchWriteItem"\n | "deleteItem"\n | "query"\n | "scan"\n | "executeStatement"\n | "executeTransaction"\n | "listTagsOfResource"\n | "tagResource"\n | "listTables"\n | "describeTable"\n | "createTable"\n | "updateTable"\n | "deleteTable";\n\nexport class DynamoDb extends Integration {\n private action: DynamoDbAction;\n private paramsJson: Binding<string>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: DynamoDbAction;\n paramsJson: Binding<string>;\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.paramsJson = config.paramsJson;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n dynamodb: {\n action: this.action,\n body: await binding(this.paramsJson),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new DynamoDb("${this.name}", "${this.integration}", { action: "${this.action}", paramsJson: ${typeof this.paramsJson === "function" ? signatureV2((await toJSBody(this.paramsJson)).body, entities) : `"${this.paramsJson}"`} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): DynamoDb {\n return new DynamoDb(json?.name, json?.step?.integration, {\n action: json?.step?.dynamodb?.action,\n paramsJson: fromBinding(json?.step?.dynamodb?.body, entities),\n });\n }\n}\n\ntype S3Action =\n | "LIST_OBJECTS"\n | "LIST_BUCKET_OBJECTS"\n | "GET_OBJECT"\n | "DELETE_OBJECT"\n | "UPLOAD_OBJECT"\n | "LIST_BUCKETS"\n | "CREATE_BUCKET"\n | "UPLOAD_MULTIPLE_OBJECTS"\n | "GENERATE_PRESIGNED_URL";\n\n// File object type for S3 uploads\ntype FileObject = {\n name: string;\n contents: string | Buffer;\n type: string;\n size?: number;\n encoding?: string;\n};\n\ntype GCSAction =\n | "LIST_OBJECTS"\n | "GET_OBJECT"\n | "DELETE_OBJECT"\n | "UPLOAD_OBJECT"\n | "LIST_BUCKETS"\n | "CREATE_BUCKET"\n | "UPLOAD_MULTIPLE_OBJECTS"\n | "GENERATE_PRESIGNED_URL";\n\nexport class GoogleCloudStorage extends Integration {\n private action: GCSAction;\n private resource?: Binding<string>;\n private path?: Binding<string>;\n private prefix?: Binding<string>;\n private body?: Binding<string | FileObject>;\n private fileObjects?: Binding<FileObject[]>;\n private responseType?: "AUTO" | "JSON" | "TEXT" | "BINARY";\n private custom?: {\n presignedExpiration?: { value: number };\n };\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: GCSAction;\n resource?: Binding<string>;\n path?: Binding<string>;\n prefix?: Binding<string>;\n body?: Binding<string | FileObject>;\n fileObjects?: Binding<FileObject[]>;\n responseType?: "AUTO" | "JSON" | "TEXT" | "BINARY";\n custom?: {\n presignedExpiration?: { value: number };\n };\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.resource = config.resource;\n this.path = config.path;\n this.prefix = config.prefix;\n this.body = config.body;\n this.fileObjects = config.fileObjects;\n this.responseType = config.responseType;\n this.custom = config.custom;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n gcs: {\n action: this.action,\n ...(this.resource ? { resource: await binding(this.resource) } : {}),\n ...(this.path ? { path: await binding(this.path) } : {}),\n ...(this.prefix ? { prefix: await binding(this.prefix) } : {}),\n ...(this.body ? { body: await binding(this.body) } : {}),\n ...(this.fileObjects\n ? { fileObjects: await binding(this.fileObjects) }\n : {}),\n ...(this.responseType ? { responseType: this.responseType } : {}),\n ...(this.custom\n ? {\n custom: {\n ...(this.custom.presignedExpiration\n ? { presignedExpiration: this.custom.presignedExpiration }\n : {}),\n },\n }\n : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [`action: "${this.action}"`];\n\n if (this.resource) {\n parts.push(\n `resource: ${\n typeof this.resource === "function"\n ? signatureV2((await toJSBody(this.resource)).body, entities)\n : `"${this.resource}"`\n }`,\n );\n }\n\n if (this.path) {\n parts.push(\n `path: ${\n typeof this.path === "function"\n ? signatureV2((await toJSBody(this.path)).body, entities)\n : `"${this.path}"`\n }`,\n );\n }\n\n if (this.prefix) {\n parts.push(\n `prefix: ${\n typeof this.prefix === "function"\n ? signatureV2((await toJSBody(this.prefix)).body, entities)\n : `"${this.prefix}"`\n }`,\n );\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : `"${this.body}"`\n }`,\n );\n }\n\n if (this.fileObjects) {\n parts.push(\n `fileObjects: ${\n typeof this.fileObjects === "function"\n ? signatureV2((await toJSBody(this.fileObjects)).body, entities)\n : `"${this.fileObjects}"`\n }`,\n );\n }\n\n if (this.responseType) {\n parts.push(`responseType: "${this.responseType}"`);\n }\n\n if (this.custom) {\n const customParts: string[] = [];\n if (this.custom.presignedExpiration) {\n customParts.push(\n `presignedExpiration: { value: ${this.custom.presignedExpiration.value} }`,\n );\n }\n if (customParts.length > 0) {\n parts.push(`custom: { ${customParts.join(", ")} }`);\n }\n }\n\n return `new GoogleCloudStorage("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): GoogleCloudStorage {\n return new GoogleCloudStorage(json?.name, json?.step?.integration, {\n action: json?.step?.gcs?.action,\n resource: json?.step?.gcs?.resource\n ? fromBinding(json?.step?.gcs?.resource, entities)\n : undefined,\n path: json?.step?.gcs?.path\n ? fromBinding(json?.step?.gcs?.path, entities)\n : undefined,\n prefix: json?.step?.gcs?.prefix\n ? fromBinding(json?.step?.gcs?.prefix, entities)\n : undefined,\n body: json?.step?.gcs?.body\n ? fromBinding(json?.step?.gcs?.body, entities)\n : undefined,\n fileObjects: json?.step?.gcs?.fileObjects\n ? (fromBinding(\n json?.step?.gcs?.fileObjects,\n entities,\n ) as unknown as Binding<FileObject[]>)\n : undefined,\n responseType: json?.step?.gcs?.responseType,\n custom: json?.step?.gcs?.custom\n ? {\n presignedExpiration: json?.step?.gcs?.custom?.presignedExpiration,\n }\n : undefined,\n });\n }\n}\n\nexport class S3 extends Integration {\n private action: S3Action;\n private resource?: Binding<string>;\n private path?: Binding<string>;\n private body?: Binding<string | FileObject>;\n private fileObjects?: Binding<FileObject[]>;\n private listFilesConfig?: {\n prefix?: Binding<string>;\n delimiter?: Binding<string>;\n };\n private custom?: {\n /** Enum name for presigned URL method */\n presignedMethod?:\n | "PRESIGNED_METHOD_UNSPECIFIED"\n | "PRESIGNED_METHOD_GET"\n | "PRESIGNED_METHOD_PUT";\n presignedExpiration?: { value: number };\n };\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: S3Action;\n resource?: Binding<string>;\n path?: Binding<string>;\n body?: Binding<string | FileObject>;\n fileObjects?: Binding<FileObject[]>;\n listFilesConfig?: {\n prefix?: Binding<string>;\n delimiter?: Binding<string>;\n };\n custom?: {\n /** Enum name for presigned URL method */\n presignedMethod?:\n | "PRESIGNED_METHOD_UNSPECIFIED"\n | "PRESIGNED_METHOD_GET"\n | "PRESIGNED_METHOD_PUT";\n presignedExpiration?: { value: number };\n };\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.resource = config.resource;\n this.path = config.path;\n this.body = config.body;\n this.fileObjects = config.fileObjects;\n this.listFilesConfig = config.listFilesConfig;\n this.custom = config.custom;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n s3: {\n action: this.action,\n ...(this.resource ? { resource: await binding(this.resource) } : {}),\n ...(this.path ? { path: await binding(this.path) } : {}),\n ...(this.body ? { body: await binding(this.body) } : {}),\n ...(this.fileObjects\n ? { fileObjects: await binding(this.fileObjects) }\n : {}),\n ...(this.listFilesConfig\n ? {\n listFilesConfig: {\n ...(this.listFilesConfig.prefix\n ? { prefix: await binding(this.listFilesConfig.prefix) }\n : {}),\n ...(this.listFilesConfig.delimiter\n ? {\n delimiter: await binding(\n this.listFilesConfig.delimiter,\n ),\n }\n : {}),\n },\n }\n : {}),\n ...(this.custom\n ? {\n custom: {\n ...(this.custom.presignedMethod\n ? { presignedMethod: this.custom.presignedMethod }\n : {}),\n ...(this.custom.presignedExpiration\n ? { presignedExpiration: this.custom.presignedExpiration }\n : {}),\n },\n }\n : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [`action: "${this.action}"`];\n\n if (this.resource) {\n parts.push(\n `resource: ${\n typeof this.resource === "function"\n ? signatureV2((await toJSBody(this.resource)).body, entities)\n : `"${this.resource}"`\n }`,\n );\n }\n\n if (this.path) {\n parts.push(\n `path: ${\n typeof this.path === "function"\n ? signatureV2((await toJSBody(this.path)).body, entities)\n : `"${this.path}"`\n }`,\n );\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : `"${this.body}"`\n }`,\n );\n }\n\n if (this.fileObjects) {\n parts.push(\n `fileObjects: ${\n typeof this.fileObjects === "function"\n ? signatureV2((await toJSBody(this.fileObjects)).body, entities)\n : `"${this.fileObjects}"`\n }`,\n );\n }\n\n if (this.listFilesConfig) {\n const configParts: string[] = [];\n if (this.listFilesConfig.prefix) {\n configParts.push(\n `prefix: ${\n typeof this.listFilesConfig.prefix === "function"\n ? signatureV2(\n (await toJSBody(this.listFilesConfig.prefix)).body,\n entities,\n )\n : `"${this.listFilesConfig.prefix}"`\n }`,\n );\n }\n if (this.listFilesConfig.delimiter) {\n configParts.push(\n `delimiter: ${\n typeof this.listFilesConfig.delimiter === "function"\n ? signatureV2(\n (await toJSBody(this.listFilesConfig.delimiter)).body,\n entities,\n )\n : `"${this.listFilesConfig.delimiter}"`\n }`,\n );\n }\n if (configParts.length > 0) {\n parts.push(`listFilesConfig: { ${configParts.join(", ")} }`);\n }\n }\n\n if (this.custom) {\n const customParts: string[] = [];\n if (this.custom.presignedMethod) {\n customParts.push(`presignedMethod: "${this.custom.presignedMethod}"`);\n }\n if (this.custom.presignedExpiration) {\n customParts.push(\n `presignedExpiration: { value: ${this.custom.presignedExpiration.value} }`,\n );\n }\n if (customParts.length > 0) {\n parts.push(`custom: { ${customParts.join(", ")} }`);\n }\n }\n\n return `new S3("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): S3 {\n return new S3(json?.name, json?.step?.integration, {\n action: json?.step?.s3?.action,\n resource: json?.step?.s3?.resource\n ? fromBinding(json?.step?.s3?.resource, entities)\n : undefined,\n path: json?.step?.s3?.path\n ? fromBinding(json?.step?.s3?.path, entities)\n : undefined,\n body: json?.step?.s3?.body\n ? fromBinding(json?.step?.s3?.body, entities)\n : undefined,\n fileObjects: json?.step?.s3?.fileObjects\n ? (fromBinding(\n json?.step?.s3?.fileObjects,\n entities,\n ) as unknown as Binding<FileObject[]>)\n : undefined,\n listFilesConfig: json?.step?.s3?.listFilesConfig\n ? {\n prefix: json?.step?.s3?.listFilesConfig?.prefix\n ? fromBinding(json?.step?.s3?.listFilesConfig?.prefix, entities)\n : undefined,\n delimiter: json?.step?.s3?.listFilesConfig?.delimiter\n ? fromBinding(\n json?.step?.s3?.listFilesConfig?.delimiter,\n entities,\n )\n : undefined,\n }\n : undefined,\n custom: json?.step?.s3?.custom\n ? {\n presignedMethod: json?.step?.s3?.custom?.presignedMethod,\n presignedExpiration: json?.step?.s3?.custom?.presignedExpiration,\n }\n : undefined,\n });\n }\n}\n\nexport interface SnowflakeConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Snowflake extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: SnowflakeConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n snowflake: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.snowflake.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.snowflake.usePreparedSql = false;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Snowflake("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Snowflake {\n const snowflake = json?.step?.snowflake;\n\n return new Snowflake(json?.name, json?.step?.integration, {\n statement: fromBinding(snowflake?.body as string | undefined, entities),\n parameters:\n snowflake?.parameters !== undefined\n ? fromBinding(snowflake.parameters, entities)\n : undefined,\n });\n }\n}\n\n/**\n * Helper to compare semver versions.\n * Returns true if version >= minVersion.\n */\nfunction semverGte(version: string, minVersion: string): boolean {\n const parseVersion = (v: string): number[] => {\n return v.replace(/^v/, "").split(".").map(Number);\n };\n const [major1, minor1, patch1] = parseVersion(version);\n const [major2, minor2, patch2] = parseVersion(minVersion);\n\n if (major1 !== major2) return major1 > major2;\n if (minor1 !== minor2) return minor1 > minor2;\n return patch1 >= patch2;\n}\n\nexport interface PostgreSQLConfig {\n statement: Binding<string>;\n /** Parameters for the SQL query. */\n parameters?: Binding<string>;\n}\n\nexport class PostgreSQL extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: PostgreSQLConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n postgres: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.postgres.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.postgres.usePreparedSql = false;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new PostgreSQL("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): PostgreSQL {\n const postgres = json?.step?.postgres;\n\n return new PostgreSQL(json?.name, json?.step?.integration, {\n statement: fromBinding(postgres?.body as string | undefined, entities),\n parameters:\n postgres?.parameters !== undefined\n ? fromBinding(postgres.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface CockroachDBConfig {\n statement: Binding<string>;\n /** Parameters for the SQL query (PostgreSQL-compatible $1, $2, etc.) */\n parameters?: Binding<string>;\n}\n\nexport class CockroachDB extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: CockroachDBConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n cockroachdb: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.cockroachdb.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.cockroachdb.usePreparedSql = false;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new CockroachDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): CockroachDB {\n const cockroachdb = json?.step?.cockroachdb;\n\n return new CockroachDB(json?.name, json?.step?.integration, {\n statement: fromBinding(cockroachdb?.body as string | undefined, entities),\n parameters:\n cockroachdb?.parameters !== undefined\n ? fromBinding(cockroachdb.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface OracleDBConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class OracleDB extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: OracleDBConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n oracledb: {\n runSql: {\n sqlBody: await bindingSql(this.statement),\n },\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.oracledb.runSql.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.oracledb.runSql.useParameterized = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new OracleDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): OracleDB {\n const oracledb = json?.step?.oracledb;\n\n return new OracleDB(json?.name, json?.step?.integration, {\n statement: fromBinding(\n oracledb?.runSql?.sqlBody as string | undefined,\n entities,\n ),\n parameters:\n oracledb?.runSql?.parameters !== undefined\n ? fromBinding(oracledb.runSql.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface RedshiftConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Redshift extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: RedshiftConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n redshift: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.redshift.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.redshift.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Redshift("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Redshift {\n const redshift = json?.step?.redshift;\n\n return new Redshift(json?.name, json?.step?.integration, {\n statement: fromBinding(redshift?.body as string | undefined, entities),\n parameters:\n redshift?.parameters !== undefined\n ? fromBinding(redshift.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface MicrosoftSqlConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class MicrosoftSql extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: MicrosoftSqlConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n mssql: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.mssql.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.mssql.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new MicrosoftSql("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MicrosoftSql {\n const mssql = json?.step?.mssql;\n\n return new MicrosoftSql(json?.name, json?.step?.integration, {\n statement: fromBinding(mssql?.body as string | undefined, entities),\n parameters:\n mssql?.parameters !== undefined\n ? fromBinding(mssql.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface MariaDBConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class MariaDB extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: MariaDBConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n mariadb: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.mariadb.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.mariadb.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new MariaDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MariaDB {\n const mariadb = json?.step?.mariadb;\n\n return new MariaDB(json?.name, json?.step?.integration, {\n statement: fromBinding(mariadb?.body as string | undefined, entities),\n parameters:\n mariadb?.parameters !== undefined\n ? fromBinding(mariadb.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface MySQLConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class MySQL extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: MySQLConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n mysql: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.mysql.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.mysql.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new MySQL("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MySQL {\n const mysql = json?.step?.mysql;\n\n return new MySQL(json?.name, json?.step?.integration, {\n statement: fromBinding(mysql?.body as string | undefined, entities),\n parameters:\n mysql?.parameters !== undefined\n ? fromBinding(mysql.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport class GraphQL extends Integration {\n private body: Binding<string>;\n private variables?: Binding<string>;\n private headers?: { key: Binding<string>; value: Binding<string> }[];\n\n constructor(\n name: string,\n integration: string,\n config: {\n query: Binding<string>;\n variables?: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n },\n ) {\n super(name, integration);\n\n this.body = config.query;\n this.variables = config.variables;\n this.headers = config.headers;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n graphqlintegration: {\n body: await bindingGraphQL(this.body),\n ...(this.variables\n ? {\n custom: {\n variables: {\n value: await binding(this.variables),\n },\n },\n }\n : {}),\n ...(this.headers && Array.isArray(this.headers)\n ? {\n headers: await Promise.all(\n this.headers.map(async (header) => ({\n key: await binding(header.key),\n value: await binding(header.value),\n })),\n ),\n }\n : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [\n `query: ${typeof this.body === "function" ? signatureV2((await toJSBody(this.body)).body, entities) : `"${this.body}"`}`,\n ];\n\n if (this.variables) {\n parts.push(\n `variables: ${typeof this.variables === "function" ? signatureV2((await toJSBody(this.variables)).body, entities) : `"${this.variables}"`}`,\n );\n }\n\n if (this.headers) {\n const headers = (\n await Promise.all(\n this.headers.map(\n async (h) =>\n `{ key: ${\n typeof h.key === "function"\n ? signatureV2((await toJSBody(h.key)).body, entities)\n : `"${h.key}"`\n }, value: ${\n typeof h.value === "function"\n ? signatureV2((await toJSBody(h.value)).body, entities)\n : `"${h.value}"`\n } }`,\n ),\n )\n ).join(", ");\n parts.push(`headers: [${headers}]`);\n }\n\n return `new GraphQL("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): GraphQL {\n const graphql = json?.step?.graphqlintegration;\n\n return new GraphQL(json?.name, json?.step?.integration, {\n query: fromBinding(graphql?.body, entities),\n variables: graphql?.custom?.variables?.value\n ? fromBinding(graphql?.custom?.variables?.value, entities)\n : undefined,\n headers: graphql?.headers?.map((header: any) => ({\n key: fromBinding(header.key, entities),\n value: fromBinding(header.value, entities),\n })),\n });\n }\n}\n\nexport class RestApi extends Integration {\n private method: string;\n private url: Binding<string>;\n private headers?: { key: Binding<string>; value: Binding<string> }[];\n private params?: { key: Binding<string>; value: Binding<string> }[];\n private body?: Binding<string>;\n private bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";\n private openapi?: {\n path: string;\n };\n\n protected type: string;\n\n constructor(\n name: string,\n integration: string = "restapi",\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration);\n\n this.method = config.method;\n this.url = config.url;\n this.headers = config.headers;\n this.params = config.params;\n this.body = config.body;\n this.openapi = openapi;\n this.type = this.isIntegration() ? "restapiintegration" : "restapi";\n this.bodyType = config.bodyType;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const openApiAction = (): string => {\n if (!this.isIntegration()) {\n return undefined;\n }\n\n if (this.openapi?.path) {\n let path: string = this.openapi.path.trim();\n\n if (path.startsWith("`") && path.endsWith("`")) {\n path = path.slice(1, -1);\n }\n\n return `${this.method} ${path}`;\n }\n\n return "genericHttpRequest";\n };\n\n const method = this.method?.toString().toUpperCase();\n const supportedMethods = [\n "GET",\n "POST",\n "PUT",\n "DELETE",\n "PATCH",\n "HEAD",\n "OPTIONS",\n ];\n\n return {\n name: this.name,\n step: {\n integration: this.integration,\n [this.type]: {\n httpMethod: supportedMethods.includes(method) ? method : "GET",\n openApiAction: openApiAction(),\n ...(this.url\n ? {\n [this.isIntegration() ? "urlPath" : "path"]: await binding(\n this.url,\n ),\n }\n : {}),\n ...(this.headers && Array.isArray(this.headers)\n ? {\n headers: await Promise.all(\n this.headers.map(async (header) => ({\n key: await binding(header.key),\n value: await binding(header.value),\n })),\n ),\n }\n : {}),\n ...(this.params && Array.isArray(this.params)\n ? {\n params: await Promise.all(\n this.params.map(async (param) => ({\n key: await binding(param.key),\n value: await binding(param.value),\n })),\n ),\n }\n : {}),\n ...(this.body ? { body: await binding(this.body) } : {}),\n bodyType: this.bodyType ?? "jsonBody",\n\n // Other params that I might need to add.\n responseType: "auto",\n },\n },\n };\n }\n\n private isIntegration(): boolean {\n return this.integration !== "restapi";\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new RestApi(${await this.constructorParametersString(entities)})`;\n }\n\n protected async constructorParametersString(\n entities: string[],\n ): Promise<string> {\n const parts: string[] = [`method: "${this.method}"`];\n\n if (this.url) {\n parts.push(\n `url: ${\n typeof this.url === "function"\n ? signatureV2((await toJSBody(this.url)).body, entities)\n : `"${this.url}"`\n }`,\n );\n }\n\n if (this.headers) {\n const headers = (\n await Promise.all(\n this.headers.map(\n async (h) =>\n `{ key: ${\n typeof h.key === "function"\n ? signatureV2((await toJSBody(h.key)).body, entities)\n : `"${h.key}"`\n }, value: ${\n typeof h.value === "function"\n ? signatureV2((await toJSBody(h.value)).body, entities)\n : `"${h.value}"`\n } }`,\n ),\n )\n ).join(", ");\n parts.push(`headers: [${headers}]`);\n }\n\n if (this.params) {\n const params = (\n await Promise.all(\n this.params.map(\n async (p) =>\n `{ key: ${\n typeof p.key === "function"\n ? signatureV2((await toJSBody(p.key)).body, entities)\n : `"${p.key}"`\n }, value: ${\n typeof p.value === "function"\n ? signatureV2((await toJSBody(p.value)).body, entities)\n : `"${p.value}"`\n } }`,\n ),\n )\n ).join(", ");\n parts.push(`params: [${params}]`);\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : JSON.stringify(this.body)\n }`,\n );\n }\n\n if (this.bodyType) {\n parts.push(`bodyType: ${this.bodyType}`);\n }\n\n return `"${this.name}", "${this.integration}", { ${parts.join(", ")} }, ${JSON.stringify(this.openapi)}`;\n }\n\n public static fromJSON(json: any, entities: string[]): RestApi {\n const config =\n json?.step?.[\n json?.step?.integration === "restapi" ? "restapi" : "restapiintegration"\n ];\n\n if (json?.step?.integration === "restapiintegration") {\n return new RestApi(\n json?.name,\n json?.step?.integration,\n OpenApi.configFromJSON(config, entities),\n OpenApi.openapiFromJSON(config),\n );\n }\n\n return new RestApi(\n json?.name,\n json?.step?.integration,\n {\n method: config?.httpMethod,\n url: fromBinding(config?.path, entities),\n headers: config?.headers?.map((header: any) => ({\n key: fromBinding(header.key, entities),\n value: fromBinding(header.value, entities),\n })),\n params: config?.params?.map((param: any) => ({\n key: fromBinding(param.key, entities),\n value: fromBinding(param.value, entities),\n })),\n body: fromBinding(config?.body, entities),\n bodyType: config?.bodyType,\n },\n OpenApi.openapiFromJSON(config),\n );\n }\n}\n\ntype SalesforceAction =\n | { action: "SOQL_ACTION_SOQL"; soqlBody: Binding<string> }\n | {\n action: "CRUD_ACTION_READ";\n resourceType: Binding<string>;\n resourceId: Binding<string>;\n }\n | {\n action: "CRUD_ACTION_CREATE";\n resourceType: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "CRUD_ACTION_UPDATE";\n resourceType: Binding<string>;\n resourceId: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "CRUD_ACTION_DELETE";\n resourceType: Binding<string>;\n resourceId: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "BULK_ACTION_CREATE";\n resourceType: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "BULK_ACTION_UPDATE";\n resourceType: Binding<string>;\n resourceBody: Binding<string>;\n };\n\nexport class Salesforce extends Integration {\n private action: SalesforceAction;\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: SalesforceAction;\n },\n ) {\n super(name, integration);\n this.action = config.action;\n }\n\n public async toJSON(): Promise<JsonValue> {\n let salesforce;\n switch (this.action.action) {\n case "SOQL_ACTION_SOQL":\n salesforce = {\n soql: {\n action: this.action.action,\n sqlBody: await binding(this.action.soqlBody),\n },\n };\n break;\n\n case "CRUD_ACTION_READ":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceId: await binding(this.action.resourceId),\n },\n };\n break;\n\n case "CRUD_ACTION_CREATE":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "CRUD_ACTION_UPDATE":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceId: await binding(this.action.resourceId),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "CRUD_ACTION_DELETE":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceId: await binding(this.action.resourceId),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "BULK_ACTION_CREATE":\n salesforce = {\n bulk: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "BULK_ACTION_UPDATE":\n salesforce = {\n bulk: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n }\n return {\n name: this.name,\n step: {\n integration: this.integration,\n salesforce,\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n switch (this.action.action) {\n case "SOQL_ACTION_SOQL":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "SOQL_ACTION_SOQL", soqlBody: ${typeof this.action.soqlBody === "function" ? signatureV2((await toJSBody(this.action.soqlBody, { condense: false })).body, entities) : `"${this.action.soqlBody}"`} } })`;\n\n case "CRUD_ACTION_READ":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_READ", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceId: ${typeof this.action.resourceId === "function" ? signatureV2((await toJSBody(this.action.resourceId, { condense: false })).body, entities) : `"${this.action.resourceId}"`} } })`;\n\n case "CRUD_ACTION_CREATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_CREATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "CRUD_ACTION_UPDATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_UPDATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceId: ${typeof this.action.resourceId === "function" ? signatureV2((await toJSBody(this.action.resourceId, { condense: false })).body, entities) : `"${this.action.resourceId}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "CRUD_ACTION_DELETE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_DELETE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceId: ${typeof this.action.resourceId === "function" ? signatureV2((await toJSBody(this.action.resourceId, { condense: false })).body, entities) : `"${this.action.resourceId}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "BULK_ACTION_CREATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "BULK_ACTION_CREATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "BULK_ACTION_UPDATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "BULK_ACTION_UPDATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n }\n }\n\n public static fromJSON(json: any, entities: string[]): Salesforce {\n // NOTE: @joeyagreco - we use if statements instead of switch statements here since the json field is at different places (proto oneofs dont be the most annoying thing to work around challenge: impossible)\n if (json?.step?.salesforce?.soql?.action === "SOQL_ACTION_SOQL") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "SOQL_ACTION_SOQL",\n // NOTE: The proto field is `sqlBody`, but the SDK config type uses `soqlBody`\n soqlBody: fromBinding(\n json?.step?.salesforce?.soql?.sqlBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_READ") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_READ",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceId: fromBinding(\n json?.step?.salesforce?.crud?.resourceId,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_CREATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_CREATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.crud?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_UPDATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_UPDATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceId: fromBinding(\n json?.step?.salesforce?.crud?.resourceId,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.crud?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_DELETE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_DELETE",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceId: fromBinding(\n json?.step?.salesforce?.crud?.resourceId,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.crud?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.bulk?.action === "BULK_ACTION_CREATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "BULK_ACTION_CREATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.bulk?.resourceType,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.bulk?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.bulk?.action === "BULK_ACTION_UPDATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "BULK_ACTION_UPDATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.bulk?.resourceType,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.bulk?.resourceBody,\n entities,\n ),\n },\n });\n }\n }\n}\n\nexport class OpenApi extends RestApi {\n constructor(\n name: string,\n integration: string,\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration, config, openapi);\n }\n\n public static configFromJSON(\n json: any,\n entities: string[],\n ): {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n } {\n return {\n method: json?.httpMethod,\n url: fromBinding(json?.urlPath, entities),\n headers: json?.headers?.map((header: any) => ({\n key: fromBinding(header.key, entities),\n value: fromBinding(header.value, entities),\n })),\n params: json?.params?.map((param: any) => ({\n key: fromBinding(param.key, entities),\n value: fromBinding(param.value, entities),\n })),\n body: fromBinding(json?.body, entities),\n };\n }\n\n public static openapiFromJSON(json: any): {\n path: string;\n } {\n return json?.openApiAction &&\n json.openApiAction !== "" &&\n json.openApiAction !== "genericHttpRequest"\n ? { path: json.openApiAction.split(" ")[1] }\n : undefined;\n }\n}\n\nexport class Jira extends OpenApi {\n constructor(\n name: string,\n integration: string,\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration, config, openapi);\n this.type = "jira";\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Jira(${await this.constructorParametersString(entities)})`;\n }\n\n public static fromJSON(json: any, entities: string[]): Jira {\n return new Jira(\n json?.name,\n json?.step?.integration,\n OpenApi.configFromJSON(json?.step?.jira, entities),\n OpenApi.openapiFromJSON(json?.step?.jira),\n );\n }\n}\n\nfunction createOpenApiIntegrationClass(\n className: string,\n integrationName: string,\n) {\n const cls = class extends OpenApi {\n constructor(\n name: string,\n integration: string,\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration, config, openapi);\n this.type = integrationName;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new ${className}(${await this.constructorParametersString(entities)})`;\n }\n\n public static fromJSON(json: any, entities: string[]) {\n return new this(\n json?.name,\n json?.step?.integration,\n OpenApi.configFromJSON(json?.step?.[integrationName], entities),\n OpenApi.openapiFromJSON(json?.step?.[integrationName]),\n );\n }\n };\n // Set the class name for debugging and testing purposes\n Object.defineProperty(cls, "name", { value: className });\n return cls;\n}\n\n// All of the openapi integrations should go here\nexport const Airtable = createOpenApiIntegrationClass("Airtable", "airtable");\nexport const Anthropic = createOpenApiIntegrationClass(\n "Anthropic",\n "anthropic",\n);\nexport const Asana = createOpenApiIntegrationClass("Asana", "asana");\nexport const Bitbucket = createOpenApiIntegrationClass(\n "Bitbucket",\n "bitbucket",\n);\nexport const Box = createOpenApiIntegrationClass("Box", "box");\nexport const CircleCI = createOpenApiIntegrationClass("CircleCI", "circleci");\nexport const Cohere = createOpenApiIntegrationClass("Cohere", "cohere");\nexport const Confluence = createOpenApiIntegrationClass(\n "Confluence",\n "confluence",\n);\nexport const Datadog = createOpenApiIntegrationClass("Datadog", "datadog");\nexport const Dropbox = createOpenApiIntegrationClass("Dropbox", "dropbox");\nexport const Elasticsearch = createOpenApiIntegrationClass(\n "Elasticsearch",\n "elasticsearch",\n);\nexport const Fireworks = createOpenApiIntegrationClass(\n "Fireworks",\n "fireworks",\n);\nexport const Front = createOpenApiIntegrationClass("Front", "front");\nexport const Gemini = createOpenApiIntegrationClass("Gemini", "gemini");\nexport const GitHub = createOpenApiIntegrationClass("GitHub", "github");\nexport const GoogleAnalytics = createOpenApiIntegrationClass(\n "GoogleAnalytics",\n "googleanalytics",\n);\nexport const GoogleDrive = createOpenApiIntegrationClass(\n "GoogleDrive",\n "googledrive",\n);\nexport const Groq = createOpenApiIntegrationClass("Groq", "groq");\nexport const HubSpot = createOpenApiIntegrationClass("HubSpot", "hubspot");\nexport const Intercom = createOpenApiIntegrationClass("Intercom", "intercom");\nexport const LaunchDarkly = createOpenApiIntegrationClass(\n "LaunchDarkly",\n "launchdarkly",\n);\nexport const Mistral = createOpenApiIntegrationClass("Mistral", "mistral");\nexport const Notion = createOpenApiIntegrationClass("Notion", "notion");\nexport const OpenAI = createOpenApiIntegrationClass("OpenAI", "openai_v2");\nexport const PagerDuty = createOpenApiIntegrationClass(\n "PagerDuty",\n "pagerduty",\n);\nexport const Perplexity = createOpenApiIntegrationClass(\n "Perplexity",\n "perplexity",\n);\nexport const Segment = createOpenApiIntegrationClass("Segment", "segment");\nexport const SendGrid = createOpenApiIntegrationClass("SendGrid", "sendgrid");\nexport const Slack = createOpenApiIntegrationClass("Slack", "slack");\nexport const StabilityAI = createOpenApiIntegrationClass(\n "StabilityAI",\n "stabilityai",\n);\nexport const Stripe = createOpenApiIntegrationClass("Stripe", "stripe");\nexport const Twilio = createOpenApiIntegrationClass("Twilio", "twilio");\nexport const Zendesk = createOpenApiIntegrationClass("Zendesk", "zendesk");\nexport const Zoom = createOpenApiIntegrationClass("Zoom", "zoom");\n\nexport class Email extends Integration {\n private subject: Binding<string>;\n private from: Binding<string>; // comma separated list\n private to: Binding<string>; // comma separated list\n private cc?: Binding<string>; // comma separated list\n private bcc?: Binding<string>; // comma separated list\n private body: Binding<string>;\n\n constructor(\n name: string,\n config: {\n from: Binding<string>;\n to: Binding<string>;\n subject: Binding<string>;\n cc?: Binding<string>;\n bcc?: Binding<string>;\n body?: Binding<string>;\n },\n ) {\n super(name, "email");\n\n this.from = config.from;\n this.to = config.to;\n this.subject = config.subject;\n this.cc = config.cc;\n this.bcc = config.bcc;\n this.body = config.body;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: "email",\n email: {\n ...(this.from ? { emailFrom: await binding(this.from) } : {}),\n ...(this.to ? { emailTo: await binding(this.to) } : {}),\n ...(this.cc ? { emailCc: await binding(this.cc) } : {}),\n ...(this.bcc ? { emailBcc: await binding(this.bcc) } : {}),\n ...(this.subject\n ? { emailSubject: await binding(this.subject) }\n : {}),\n ...(this.body ? { emailBody: await binding(this.body) } : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [];\n\n if (this.from) {\n parts.push(\n `from: ${\n typeof this.from === "function"\n ? signatureV2((await toJSBody(this.from)).body, entities)\n : `"${this.from}"`\n }`,\n );\n }\n\n if (this.to) {\n parts.push(\n `to: ${\n typeof this.to === "function"\n ? signatureV2((await toJSBody(this.to)).body, entities)\n : `"${this.to}"`\n }`,\n );\n }\n\n if (this.cc) {\n parts.push(\n `cc: ${\n typeof this.cc === "function"\n ? signatureV2((await toJSBody(this.cc)).body, entities)\n : `"${this.cc}"`\n }`,\n );\n }\n\n if (this.bcc) {\n parts.push(\n `bcc: ${\n typeof this.bcc === "function"\n ? signatureV2((await toJSBody(this.bcc)).body, entities)\n : `"${this.bcc}"`\n }`,\n );\n }\n\n if (this.subject) {\n parts.push(\n `subject: ${\n typeof this.subject === "function"\n ? signatureV2((await toJSBody(this.subject)).body, entities)\n : `"${this.subject}"`\n }`,\n );\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : `"${this.body}"`\n }`,\n );\n }\n\n return `new Email("${this.name}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Email {\n return new Email(json?.name, {\n from: fromBinding(json?.step?.email?.emailFrom, entities),\n to: fromBinding(json?.step?.email?.emailTo, entities),\n subject: fromBinding(json?.step?.email?.emailSubject, entities),\n body: fromBinding(json?.step?.email?.emailBody, entities),\n cc: json?.step?.email?.emailCc\n ? fromBinding(json?.step?.email?.emailCc, entities)\n : undefined,\n bcc: json?.step?.email?.emailBcc\n ? fromBinding(json?.step?.email?.emailBcc, entities)\n : undefined,\n });\n }\n}\n\nexport interface DatabricksConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Databricks extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: DatabricksConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n databricks: {\n operation: "SQL_OPERATION_RUN_SQL",\n runSql: {\n sqlBody: await bindingSql(this.statement),\n },\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.databricks.runSql.parameters = bound.replace(/^`|`$/g, "");\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Databricks("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Databricks {\n const databricksConfig = json?.step?.databricks;\n const databricks = databricksConfig?.runSql;\n\n return new Databricks(json?.name, json?.step?.integration, {\n statement: fromBinding(databricks?.sqlBody as string, entities),\n parameters:\n databricks?.parameters !== undefined\n ? fromBinding(databricks.parameters, entities)\n : undefined,\n });\n }\n}\n\ntype MongoDBOperation =\n | "aggregate"\n | "count"\n | "deleteOne"\n | "deleteMany"\n | "distinct"\n | "find"\n | "findOne"\n | "insertOne"\n | "insertMany"\n | "listCollections"\n | "replaceOne"\n | "updateOne"\n | "updateMany";\n\nexport class MongoDB extends Integration {\n private operation: MongoDBOperation;\n private collection?: Binding<string>;\n private query?: Binding<any>;\n private filter?: Binding<any>;\n private update?: Binding<any>;\n private replacement?: Binding<any>;\n private document?: Binding<any>;\n private pipeline?: Binding<any[]>;\n private field?: Binding<string>;\n private projection?: Binding<any>;\n private sortby?: Binding<any>;\n private limit?: Binding<number>;\n private skip?: Binding<number>;\n private options?: Binding<any>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n operation: MongoDBOperation;\n collection?: Binding<string>;\n query?: Binding<any>;\n filter?: Binding<any>;\n update?: Binding<any>;\n replacement?: Binding<any>;\n document?: Binding<any>;\n pipeline?: Binding<any[]>;\n field?: Binding<string>;\n projection?: Binding<any>;\n sortby?: Binding<any>;\n limit?: Binding<number>;\n skip?: Binding<number>;\n options?: Binding<any>;\n },\n ) {\n super(name, integration);\n this.operation = config.operation;\n this.collection = config.collection;\n this.query = config.query;\n this.filter = config.filter;\n this.update = config.update;\n this.replacement = config.replacement;\n this.document = config.document;\n this.pipeline = config.pipeline;\n this.field = config.field;\n this.projection = config.projection;\n this.sortby = config.sortby;\n this.limit = config.limit;\n this.skip = config.skip;\n this.options = config.options;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n mongodb: {\n action: this.operation,\n ...(this.collection\n ? { resource: await binding(this.collection) }\n : {}),\n ...(this.query ? { query: await binding(this.query) } : {}),\n ...(this.filter ? { filter: await binding(this.filter) } : {}),\n ...(this.update ? { update: await binding(this.update) } : {}),\n ...(this.replacement\n ? { replacement: await binding(this.replacement) }\n : {}),\n ...(this.document ? { document: await binding(this.document) } : {}),\n ...(this.pipeline ? { pipeline: await binding(this.pipeline) } : {}),\n ...(this.field ? { field: await binding(this.field) } : {}),\n ...(this.projection\n ? { projection: await binding(this.projection) }\n : {}),\n ...(this.sortby ? { sortby: await binding(this.sortby) } : {}),\n ...(this.limit ? { limit: await binding(this.limit) } : {}),\n ...(this.skip ? { skip: await binding(this.skip) } : {}),\n ...(this.options ? { options: await binding(this.options) } : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [`operation: "${this.operation}"`];\n\n if (this.collection) {\n parts.push(\n `collection: ${\n typeof this.collection === "function"\n ? signatureV2((await toJSBody(this.collection)).body, entities)\n : `"${this.collection}"`\n }`,\n );\n }\n\n if (this.query) {\n parts.push(\n `query: ${\n typeof this.query === "function"\n ? signatureV2((await toJSBody(this.query)).body, entities)\n : JSON.stringify(this.query)\n }`,\n );\n }\n\n if (this.filter) {\n parts.push(\n `filter: ${\n typeof this.filter === "function"\n ? signatureV2((await toJSBody(this.filter)).body, entities)\n : JSON.stringify(this.filter)\n }`,\n );\n }\n\n if (this.update) {\n parts.push(\n `update: ${\n typeof this.update === "function"\n ? signatureV2((await toJSBody(this.update)).body, entities)\n : JSON.stringify(this.update)\n }`,\n );\n }\n\n if (this.replacement) {\n parts.push(\n `replacement: ${\n typeof this.replacement === "function"\n ? signatureV2((await toJSBody(this.replacement)).body, entities)\n : JSON.stringify(this.replacement)\n }`,\n );\n }\n\n if (this.document) {\n parts.push(\n `document: ${\n typeof this.document === "function"\n ? signatureV2((await toJSBody(this.document)).body, entities)\n : JSON.stringify(this.document)\n }`,\n );\n }\n\n if (this.pipeline) {\n parts.push(\n `pipeline: ${\n typeof this.pipeline === "function"\n ? signatureV2((await toJSBody(this.pipeline)).body, entities)\n : JSON.stringify(this.pipeline)\n }`,\n );\n }\n\n if (this.field) {\n parts.push(\n `field: ${\n typeof this.field === "function"\n ? signatureV2((await toJSBody(this.field)).body, entities)\n : `"${this.field}"`\n }`,\n );\n }\n\n if (this.projection) {\n parts.push(\n `projection: ${\n typeof this.projection === "function"\n ? signatureV2((await toJSBody(this.projection)).body, entities)\n : JSON.stringify(this.projection)\n }`,\n );\n }\n\n if (this.sortby) {\n parts.push(\n `sortby: ${\n typeof this.sortby === "function"\n ? signatureV2((await toJSBody(this.sortby)).body, entities)\n : JSON.stringify(this.sortby)\n }`,\n );\n }\n\n if (this.limit !== undefined) {\n parts.push(\n `limit: ${\n typeof this.limit === "function"\n ? signatureV2((await toJSBody(this.limit)).body, entities)\n : this.limit\n }`,\n );\n }\n\n if (this.skip !== undefined) {\n parts.push(\n `skip: ${\n typeof this.skip === "function"\n ? signatureV2((await toJSBody(this.skip)).body, entities)\n : this.skip\n }`,\n );\n }\n\n if (this.options) {\n parts.push(\n `options: ${\n typeof this.options === "function"\n ? signatureV2((await toJSBody(this.options)).body, entities)\n : JSON.stringify(this.options)\n }`,\n );\n }\n\n return `new MongoDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MongoDB {\n return new MongoDB(json?.name, json?.step?.integration, {\n operation: json?.step?.mongodb?.action,\n collection: json?.step?.mongodb?.resource\n ? fromBinding(json?.step?.mongodb?.resource, entities)\n : undefined,\n query: json?.step?.mongodb?.query\n ? fromBinding(json?.step?.mongodb?.query, entities)\n : undefined,\n filter: json?.step?.mongodb?.filter\n ? fromBinding(json?.step?.mongodb?.filter, entities)\n : undefined,\n update: json?.step?.mongodb?.update\n ? fromBinding(json?.step?.mongodb?.update, entities)\n : undefined,\n replacement: json?.step?.mongodb?.replacement\n ? fromBinding(json?.step?.mongodb?.replacement, entities)\n : undefined,\n document: json?.step?.mongodb?.document\n ? fromBinding(json?.step?.mongodb?.document, entities)\n : undefined,\n pipeline: json?.step?.mongodb?.pipeline\n ? (fromBinding(\n json?.step?.mongodb?.pipeline,\n entities,\n ) as unknown as Binding<any[]>)\n : undefined,\n field: json?.step?.mongodb?.field\n ? fromBinding(json?.step?.mongodb?.field, entities)\n : undefined,\n projection: json?.step?.mongodb?.projection\n ? fromBinding(json?.step?.mongodb?.projection, entities)\n : undefined,\n sortby: json?.step?.mongodb?.sortby\n ? fromBinding(json?.step?.mongodb?.sortby, entities)\n : undefined,\n limit: json?.step?.mongodb?.limit\n ? (fromBinding(\n json?.step?.mongodb?.limit,\n entities,\n ) as unknown as Binding<number>)\n : undefined,\n skip: json?.step?.mongodb?.skip\n ? (fromBinding(\n json?.step?.mongodb?.skip,\n entities,\n ) as unknown as Binding<number>)\n : undefined,\n options: json?.step?.mongodb?.options\n ? fromBinding(json?.step?.mongodb?.options, entities)\n : undefined,\n });\n }\n}\n\ntype CouchbaseAction = "runSql" | "insert" | "get" | "remove";\n\nexport class Couchbase extends Integration {\n private action: CouchbaseAction;\n private bucket?: Binding<string>;\n private scope?: Binding<string>;\n private collection?: Binding<string>;\n private sqlBody?: Binding<string>;\n private key?: Binding<string>;\n private document?: Binding<any>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: CouchbaseAction;\n bucket?: Binding<string>;\n scope?: Binding<string>;\n collection?: Binding<string>;\n sqlBody?: Binding<string>;\n key?: Binding<string>;\n document?: Binding<any>;\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.bucket = config.bucket;\n this.scope = config.scope;\n this.collection = config.collection;\n this.sqlBody = config.sqlBody;\n this.key = config.key;\n this.document = config.document;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const actionValue: Record<string, JsonValue> = {};\n\n if (this.action === "runSql" && this.sqlBody !== undefined) {\n actionValue.sqlBody = await bindingSql(this.sqlBody);\n } else {\n if (this.scope !== undefined || this.collection !== undefined) {\n actionValue.identifier = {\n scope: this.scope ? await binding(this.scope) : undefined,\n collection: this.collection\n ? await binding(this.collection)\n : undefined,\n };\n }\n if (this.key !== undefined) {\n actionValue.key = await binding(this.key);\n }\n if (this.action === "insert" && this.document !== undefined) {\n actionValue.value = await binding(this.document);\n }\n }\n\n return {\n name: this.name,\n step: {\n integration: this.integration,\n couchbase: {\n bucketName: this.bucket ? await binding(this.bucket) : undefined,\n couchbaseAction: {\n case: this.action,\n value: actionValue,\n },\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const configParts: string[] = [];\n configParts.push(`action: "${this.action}"`);\n\n if (this.bucket !== undefined) {\n configParts.push(\n `bucket: ${typeof this.bucket === "function" ? signatureV2((await toJSBody(this.bucket, { condense: false })).body, entities) : `"${this.bucket}"`}`,\n );\n }\n if (this.scope !== undefined) {\n configParts.push(\n `scope: ${typeof this.scope === "function" ? signatureV2((await toJSBody(this.scope, { condense: false })).body, entities) : `"${this.scope}"`}`,\n );\n }\n if (this.collection !== undefined) {\n configParts.push(\n `collection: ${typeof this.collection === "function" ? signatureV2((await toJSBody(this.collection, { condense: false })).body, entities) : `"${this.collection}"`}`,\n );\n }\n if (this.sqlBody !== undefined) {\n configParts.push(\n `sqlBody: ${typeof this.sqlBody === "function" ? signatureV2((await toJSBody(this.sqlBody, { condense: false })).body, entities) : `"${this.sqlBody}"`}`,\n );\n }\n if (this.key !== undefined) {\n configParts.push(\n `key: ${typeof this.key === "function" ? signatureV2((await toJSBody(this.key, { condense: false })).body, entities) : `"${this.key}"`}`,\n );\n }\n if (this.document !== undefined) {\n configParts.push(\n `document: ${typeof this.document === "function" ? signatureV2((await toJSBody(this.document, { condense: false })).body, entities) : JSON.stringify(this.document)}`,\n );\n }\n\n return `new Couchbase("${this.name}", "${this.integration}", { ${configParts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Couchbase {\n const couchbase = json?.step?.couchbase;\n const action = couchbase?.couchbaseAction?.case as CouchbaseAction;\n const actionValue = couchbase?.couchbaseAction?.value;\n\n return new Couchbase(json?.name, json?.step?.integration, {\n action,\n bucket: couchbase?.bucketName\n ? fromBinding(couchbase?.bucketName, entities)\n : undefined,\n scope: actionValue?.identifier?.scope\n ? fromBinding(actionValue?.identifier?.scope, entities)\n : undefined,\n collection: actionValue?.identifier?.collection\n ? fromBinding(actionValue?.identifier?.collection, entities)\n : undefined,\n sqlBody: actionValue?.sqlBody\n ? fromBinding(actionValue?.sqlBody, entities)\n : undefined,\n key: actionValue?.key\n ? fromBinding(actionValue?.key, entities)\n : undefined,\n document: actionValue?.value\n ? fromBinding(actionValue?.value, entities)\n : undefined,\n });\n }\n}\n\ntype CosmosDBActionType = "sql" | "pointOperation";\ntype CosmosDBPointAction = "create" | "read" | "upsert" | "replace" | "delete";\n\nexport class CosmosDB extends Integration {\n private actionType: CosmosDBActionType;\n private containerId?: Binding<string>;\n private query?: Binding<string>;\n private crossPartition?: boolean;\n private partitionKey?: Binding<string>;\n private pointAction?: CosmosDBPointAction;\n private itemId?: Binding<string>;\n private body?: Binding<any>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n actionType: CosmosDBActionType;\n containerId?: Binding<string>;\n query?: Binding<string>;\n crossPartition?: boolean;\n partitionKey?: Binding<string>;\n pointAction?: CosmosDBPointAction;\n itemId?: Binding<string>;\n body?: Binding<any>;\n },\n ) {\n super(name, integration);\n this.actionType = config.actionType;\n this.containerId = config.containerId;\n this.query = config.query;\n this.crossPartition = config.crossPartition;\n this.partitionKey = config.partitionKey;\n this.pointAction = config.pointAction;\n this.itemId = config.itemId;\n this.body = config.body;\n }\n\n public async toJSON(): Promise<JsonValue> {\n if (this.actionType === "sql") {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n cosmosdb: {\n cosmosdbAction: {\n case: "sql",\n value: {\n action: {\n case: "singleton",\n value: {\n containerId: this.containerId\n ? await binding(this.containerId)\n : undefined,\n query: this.query\n ? await bindingSql(this.query)\n : undefined,\n crossPartition: this.crossPartition ?? true,\n partitionKey: this.partitionKey\n ? await binding(this.partitionKey)\n : undefined,\n },\n },\n },\n },\n },\n },\n };\n }\n\n // Point operation\n return {\n name: this.name,\n step: {\n integration: this.integration,\n cosmosdb: {\n cosmosdbAction: {\n case: "pointOperation",\n value: {\n containerId: this.containerId\n ? await binding(this.containerId)\n : undefined,\n action: {\n case: this.pointAction,\n value: {\n id: this.itemId ? await binding(this.itemId) : undefined,\n partitionKey: this.partitionKey\n ? await binding(this.partitionKey)\n : undefined,\n body: this.body ? await binding(this.body) : undefined,\n },\n },\n },\n },\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const configParts: string[] = [];\n configParts.push(`actionType: "${this.actionType}"`);\n\n if (this.containerId !== undefined) {\n configParts.push(\n `containerId: ${typeof this.containerId === "function" ? signatureV2((await toJSBody(this.containerId, { condense: false })).body, entities) : `"${this.containerId}"`}`,\n );\n }\n if (this.query !== undefined) {\n configParts.push(\n `query: ${typeof this.query === "function" ? signatureV2((await toJSBody(this.query, { condense: false })).body, entities) : `"${this.query}"`}`,\n );\n }\n if (this.crossPartition !== undefined) {\n configParts.push(`crossPartition: ${this.crossPartition}`);\n }\n if (this.partitionKey !== undefined) {\n configParts.push(\n `partitionKey: ${typeof this.partitionKey === "function" ? signatureV2((await toJSBody(this.partitionKey, { condense: false })).body, entities) : `"${this.partitionKey}"`}`,\n );\n }\n if (this.pointAction !== undefined) {\n configParts.push(`pointAction: "${this.pointAction}"`);\n }\n if (this.itemId !== undefined) {\n configParts.push(\n `itemId: ${typeof this.itemId === "function" ? signatureV2((await toJSBody(this.itemId, { condense: false })).body, entities) : `"${this.itemId}"`}`,\n );\n }\n if (this.body !== undefined) {\n configParts.push(\n `body: ${typeof this.body === "function" ? signatureV2((await toJSBody(this.body, { condense: false })).body, entities) : JSON.stringify(this.body)}`,\n );\n }\n\n return `new CosmosDB("${this.name}", "${this.integration}", { ${configParts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): CosmosDB {\n const cosmosdb = json?.step?.cosmosdb;\n const actionType = cosmosdb?.cosmosdbAction?.case as CosmosDBActionType;\n const actionValue = cosmosdb?.cosmosdbAction?.value;\n\n if (actionType === "sql") {\n const sqlAction = actionValue?.action?.value;\n return new CosmosDB(json?.name, json?.step?.integration, {\n actionType,\n containerId: sqlAction?.containerId\n ? fromBinding(sqlAction?.containerId, entities)\n : undefined,\n query: sqlAction?.query\n ? fromBinding(sqlAction?.query, entities)\n : undefined,\n crossPartition: sqlAction?.crossPartition,\n partitionKey: sqlAction?.partitionKey\n ? fromBinding(sqlAction?.partitionKey, entities)\n : undefined,\n });\n }\n\n // Point operation\n const pointAction = actionValue?.action?.case as CosmosDBPointAction;\n const pointValue = actionValue?.action?.value;\n return new CosmosDB(json?.name, json?.step?.integration, {\n actionType,\n containerId: actionValue?.containerId\n ? fromBinding(actionValue?.containerId, entities)\n : undefined,\n pointAction,\n itemId: pointValue?.id\n ? fromBinding(pointValue?.id, entities)\n : undefined,\n partitionKey: pointValue?.partitionKey\n ? fromBinding(pointValue?.partitionKey, entities)\n : undefined,\n body: pointValue?.body\n ? fromBinding(pointValue?.body, entities)\n : undefined,\n });\n }\n}\n\nexport type Condition = {\n when: Binding<boolean>;\n then: Block[];\n};\n\nasync function conditionToSDK(\n condition: Condition,\n entities: string[],\n): Promise<string> {\n return `{ when: ${typeof condition.when === "function" ? signatureV2((await toJSBody(condition.when)).body, entities) : condition.when}, then: [${(await Promise.all(condition.then.map(async (block) => await block.toSDK(entities)))).join(",")}] }`;\n}\n\nexport type Conditions = {\n if: Condition;\n elif?: Condition[];\n else?: Block[];\n};\n\nexport class Conditional extends Block {\n public conditions: Conditions;\n\n constructor(name: string, config: Conditions) {\n super(name);\n\n this.conditions = config;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n conditional: {\n if: {\n condition: ensureIIFE(\n (await toJS<boolean>(this.conditions.if.when)).body,\n ),\n blocks: await Promise.all(\n this.conditions.if.then.map(async (block) => await block.toJSON()),\n ),\n },\n ...(await (async () =>\n this.conditions.elif\n ? {\n elseIf: await Promise.all(\n this.conditions.elif.map(async (condition) => ({\n condition: ensureIIFE(\n (await toJS<boolean>(condition.when)).body,\n ),\n blocks: await Promise.all(\n condition.then.map(async (block) => await block.toJSON()),\n ),\n })),\n ),\n }\n : { elseIf: [] })()),\n else: this.conditions.else\n ? {\n blocks: await Promise.all(\n this.conditions.else.map(async (block) => await block.toJSON()),\n ),\n }\n : undefined,\n },\n };\n }\n\n public static fromJSON(json: any, entities: string[]): Conditional {\n return new Conditional(json?.name, {\n if: {\n when: fromJS<boolean>(json?.conditional?.if?.condition, entities),\n then: json?.conditional?.if?.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n },\n elif: json?.conditional?.elseIf\n ? json?.conditional?.elseIf?.map((condition: any) => ({\n when: fromJS<boolean>(condition.condition, entities),\n then: condition.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n }))\n : [],\n else: json?.conditional?.else\n ? json?.conditional?.else?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n )\n : [],\n });\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const elseBlocks = this.conditions.else\n ? await Promise.all(\n this.conditions.else.map(\n async (block) => await block.toSDK(entities),\n ),\n )\n : [];\n return `new Conditional("${this.name}", { if: ${await conditionToSDK(this.conditions.if, entities)}, elif: [${this.conditions.elif ? (await Promise.all(this.conditions.elif?.map(async (condition) => await conditionToSDK(condition, entities)))).join(",") : ""}], else: [${elseBlocks.join(",")}] })`;\n }\n}\n\ntype ParallelMode = "dynamic" | "static";\n\ntype DynamicParallelConfig = {\n mode: "dynamic";\n over: Binding<JsonValue[]>;\n variables: { item: string };\n blocks: Block[];\n};\n\ntype StaticParallelConfig = {\n mode: "static";\n paths: Record<string, Block[]>;\n};\n\ntype ParallelConfig = DynamicParallelConfig | StaticParallelConfig;\n\nexport class Parallel extends Block {\n private config: ParallelConfig;\n\n constructor(name: string, config: ParallelConfig) {\n super(name);\n this.config = config;\n }\n\n public async toJSON(): Promise<JsonValue> {\n if (this.config.mode === "static") {\n const paths: Record<string, { blocks: JsonValue[] }> = {};\n for (const [pathName, blocks] of Object.entries(this.config.paths)) {\n paths[pathName] = {\n blocks: await Promise.all(\n blocks.map(async (block) => await block.toJSON()),\n ),\n };\n }\n return {\n name: this.name,\n parallel: {\n static: { paths },\n wait: "WAIT_ALL",\n },\n };\n }\n\n // Dynamic mode\n return {\n name: this.name,\n parallel: {\n dynamic: {\n blocks: await Promise.all(\n this.config.blocks?.map(async (block) => await block.toJSON()),\n ),\n paths: ensureIIFE((await toJS<JsonValue[]>(this.config.over)).body),\n variables: this.config.variables,\n },\n wait: "WAIT_ALL",\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n if (this.config.mode === "static") {\n const pathsEntries = await Promise.all(\n Object.entries(this.config.paths).map(async ([pathName, blocks]) => {\n const blocksSdk = await Promise.all(\n blocks.map(async (block) => await block.toSDK(entities)),\n );\n return `"${pathName}": [${blocksSdk.join(", ")}]`;\n }),\n );\n return `new Parallel("${this.name}", { mode: "static", paths: { ${pathsEntries.join(", ")} } })`;\n }\n\n // Dynamic mode\n const variables = JSON.stringify(this.config.variables);\n const blocks = await Promise.all(\n this.config.blocks.map(async (block) => await block.toSDK(entities)),\n );\n return `new Parallel("${this.name}", { mode: "dynamic", over: ${typeof this.config.over === "function" ? signatureV2((await toJSBody(this.config.over)).body, entities) : this.config.over}, variables: ${variables}, blocks: [${blocks.join(", ")}] })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Parallel {\n // Check if it\'s a static parallel\n if (json?.parallel?.static?.paths) {\n const paths: Record<string, Block[]> = {};\n for (const [pathName, pathConfig] of Object.entries(\n json.parallel.static.paths as Record<string, { blocks: any[] }>,\n )) {\n paths[pathName] = pathConfig.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n );\n }\n return new Parallel(json?.name, {\n mode: "static",\n paths,\n });\n }\n\n // Dynamic mode\n return new Parallel(json?.name, {\n mode: "dynamic",\n over: fromJS<JsonValue[]>(\n json?.parallel?.dynamic?.paths ?? "\'\'",\n entities,\n ),\n variables: {\n item: json?.parallel?.dynamic?.variables?.item ?? "",\n },\n blocks:\n json?.parallel?.dynamic?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n ) ?? [],\n });\n }\n}\n\ntype LoopType = "TYPE_FOREACH" | "TYPE_WHILE";\n\ntype ForEachLoopConfig = {\n type?: "TYPE_FOREACH"; // Optional - defaults to TYPE_FOREACH\n over: Binding<JsonValue[]>;\n variables: { item: string; index: string };\n blocks: Block[];\n};\n\ntype WhileLoopConfig = {\n type: "TYPE_WHILE"; // Required for TYPE_WHILE\n condition: Binding<boolean>;\n variables?: { index: string }; // Optional - defaults to { index: \'index\' }\n blocks: Block[];\n};\n\ntype LoopConfig = ForEachLoopConfig | WhileLoopConfig;\n\nexport class Loop extends Block {\n private config: LoopConfig;\n\n constructor(name: string, config: LoopConfig) {\n super(name);\n this.config = config;\n }\n\n public async toJSON(): Promise<JsonValue> {\n if (this.config.type === "TYPE_WHILE") {\n // TYPE_WHILE loops have both item and index variables (matching UI defaults)\n const indexName = this.config.variables?.index ?? "index";\n return {\n name: this.name,\n loop: {\n range: ensureIIFE((await toJS<boolean>(this.config.condition)).body),\n type: "TYPE_WHILE",\n variables: { index: indexName, item: "item" },\n blocks: await Promise.all(\n this.config.blocks.map(async (block) => await block.toJSON()),\n ),\n },\n };\n }\n\n // TYPE_FOREACH\n return {\n name: this.name,\n loop: {\n range: ensureIIFE((await toJS<JsonValue[]>(this.config.over)).body),\n type: "TYPE_FOREACH",\n variables: this.config.variables,\n blocks: await Promise.all(\n this.config.blocks.map(async (block) => await block.toJSON()),\n ),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const blocks = await Promise.all(\n this.config.blocks.map(async (block) => await block.toSDK(entities)),\n );\n\n if (this.config.type === "TYPE_WHILE") {\n const condition =\n typeof this.config.condition === "function"\n ? signatureV2((await toJSBody(this.config.condition)).body, entities)\n : this.config.condition;\n const indexName = this.config.variables?.index ?? "index";\n // Only include variables if a custom index name is specified\n const variablesStr =\n indexName !== "index"\n ? `, variables: { index: "${indexName}" }`\n : "";\n return `new Loop("${this.name}", { type: "TYPE_WHILE", condition: ${condition}${variablesStr}, blocks: [${blocks.join(", ")}] })`;\n }\n\n // TYPE_FOREACH\n const variables = JSON.stringify(this.config.variables);\n const over =\n typeof this.config.over === "function"\n ? signatureV2((await toJSBody(this.config.over)).body, entities)\n : this.config.over;\n return `new Loop("${this.name}", { type: "TYPE_FOREACH", over: ${over}, variables: ${variables}, blocks: [${blocks.join(", ")}] })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Loop {\n const loopType = json?.loop?.type as LoopType | undefined;\n\n if (loopType === "TYPE_WHILE") {\n // Extract index variable name from JSON, default to \'index\'\n const indexName = json?.loop?.variables?.index || "index";\n return new Loop(json?.name, {\n type: "TYPE_WHILE",\n condition: fromJS<boolean>(json?.loop?.range, entities),\n variables: { index: indexName },\n blocks:\n json?.loop?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n ) ?? [],\n });\n }\n\n // Default to TYPE_FOREACH\n return new Loop(json?.name, {\n type: "TYPE_FOREACH",\n over: fromJS<JsonValue[]>(json?.loop?.range, entities),\n variables: {\n item: json?.loop?.variables?.item,\n index: json?.loop?.variables?.index,\n },\n blocks: json?.loop?.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n });\n }\n}\n\nexport class Variables extends Block {\n private variables: { key: string; value: Binding<JsonValue> }[];\n\n constructor(\n name: string,\n variables: { key: string; value: Binding<JsonValue> }[],\n ) {\n super(name);\n\n this.variables = variables;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n variables: {\n items: await Promise.all(\n this.variables.map(async (variable) => {\n return {\n key: variable.key,\n value: ensureIIFE((await toJS<JsonValue[]>(variable.value)).body),\n type: "TYPE_SIMPLE",\n mode: "MODE_READWRITE",\n };\n }),\n ),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Variables("${this.name}", [${(\n await Promise.all(\n this.variables?.map(\n async (variable) =>\n `{ key: "${variable.key}", value: ${typeof variable.value === "function" ? signatureV2((await toJSBody(variable.value)).body, entities) : variable.value} }`,\n ),\n )\n ).join(",")}])`;\n }\n\n public static fromJSON(json: any, entities: string[]): Variables {\n return new Variables(\n json?.name,\n json?.variables?.items?.map((variable: any) => ({\n key: variable.key,\n value: fromBinding(variable.value, entities),\n })),\n );\n }\n}\n\nexport class TryCatch extends Block {\n private try: Block[];\n private catch: Block[];\n private finally?: Block[];\n private variables: { error: string };\n\n constructor(\n name: string,\n config: {\n try: Block[];\n catch: Block[];\n finally?: Block[];\n variables: { error: string };\n },\n ) {\n super(name);\n\n this.try = config.try;\n this.catch = config.catch;\n this.finally = config.finally;\n this.variables = config.variables;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n tryCatch: {\n try: {\n blocks: await Promise.all(\n this.try.map(async (block) => await block.toJSON()),\n ),\n },\n catch: {\n blocks: await Promise.all(\n this.catch.map(async (block) => await block.toJSON()),\n ),\n },\n finally: {\n blocks: this.finally\n ? await Promise.all(\n this.finally.map(async (block) => await block.toJSON()),\n )\n : undefined,\n },\n variables: this.variables,\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const tryBlocks = await Promise.all(\n this.try.map(async (block) => await block.toSDK(entities)),\n );\n const catchBlocks = await Promise.all(\n this.catch.map(async (block) => await block.toSDK(entities)),\n );\n const finallyBlocks = this.finally\n ? await Promise.all(\n this.finally.map(async (block) => await block.toSDK(entities)),\n )\n : undefined;\n return `new TryCatch("${this.name}", { try: [${tryBlocks.join(",")}], catch: [${catchBlocks.join(",")}], finally: [${finallyBlocks ? finallyBlocks.join(", ") : ""}], variables: { error: "${this.variables.error}" } })`;\n }\n\n public static fromJSON(json: any, entities: string[]): TryCatch {\n return new TryCatch(json?.name, {\n try: json?.tryCatch?.try.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n catch: json?.tryCatch?.catch.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n finally: json?.tryCatch?.finally?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n variables: {\n error: json?.tryCatch?.variables?.error,\n },\n });\n }\n}\n\nexport class Throw extends Block {\n private error: Binding<JsonValue>;\n\n constructor(\n name: string,\n config: {\n error: Binding<JsonValue>;\n },\n ) {\n super(name);\n\n this.error = config.error;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n throw: {\n error: (await toJS<JsonValue>(this.error)).body,\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Throw("${this.name}", { error: ${typeof this.error === "function" ? signatureV2((await toJSBody(this.error)).body, entities) : ensureIIFE(JSON.stringify(this.error))} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Throw {\n return new Throw(json?.name, {\n error: fromJS(json?.throw?.error, entities),\n });\n }\n}\n\nexport class Return extends Block {\n private data: Binding<JsonValue>;\n\n constructor(\n name: string,\n config: {\n data: Binding<JsonValue>;\n },\n ) {\n super(name);\n\n this.data = config.data;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n return: {\n data: ensureIIFE((await toJS<JsonValue>(this.data)).body),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const dataFn =\n typeof this.data === "function"\n ? signatureV2((await toJSBody(this.data)).body, entities)\n : ensureIIFE(JSON.stringify(this.data));\n return `new Return("${this.name}", { data: ${dataFn} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Return {\n return new Return(json?.name, {\n data: fromJS(json?.return?.data, entities),\n });\n }\n}\n\nexport class Break extends Block {\n private condition: Binding<JsonValue>;\n\n constructor(\n name: string,\n config: {\n condition: Binding<JsonValue>;\n },\n ) {\n super(name);\n\n this.condition = config.condition;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n break: {\n condition: ensureIIFE((await toJS<JsonValue[]>(this.condition)).body),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Break("${this.name}", { condition: ${typeof this.condition === "function" ? signatureV2((await toJSBody(this.condition)).body, entities) : ensureIIFE(JSON.stringify(this.condition))} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Break {\n return new Break(json?.name, {\n condition: fromJS(json?.break?.condition, entities),\n });\n }\n}\n\nexport type Authorization =\n | {\n type: "AUTHORIZATION_TYPE_APP_USERS";\n }\n | {\n type: "AUTHORIZATION_TYPE_JS_EXPRESSION";\n expression: Binding<boolean>;\n };\n\nexport class Api {\n private blocks: Block[];\n private name: string;\n private authorization?: Authorization;\n\n constructor(\n name: string,\n blocks: Block[] = [],\n authorization: Authorization = { type: "AUTHORIZATION_TYPE_APP_USERS" },\n ) {\n this.name = name;\n this.blocks = blocks;\n this.authorization = authorization;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `${getSdkImports()}\\n\\nexport default new Api("${this.name}", [${(await Promise.all(this.blocks.map(async (block) => await block.toSDK(entities)))).join(",")}], ${this.authorization.type === "AUTHORIZATION_TYPE_JS_EXPRESSION" ? `{ type: "AUTHORIZATION_TYPE_JS_EXPRESSION", expression: ${typeof this.authorization.expression === "function" ? signatureV2((await toJSBody(this.authorization.expression)).body, entities) : this.authorization.expression} }` : `{ type: "AUTHORIZATION_TYPE_APP_USERS" }`})`;\n }\n\n public static fromJSON(json: any, entities: string[]): Api {\n // NOTE(Frank): Would probs unmarshal this into the protobuf types and then do the conversion.\n return new Api(\n json?.metadata?.name as string,\n (json.blocks as any[]).map((block) => Block.fromJSON(block, entities)),\n {\n type: json.authorization.type,\n expression:\n json.authorization.type === "AUTHORIZATION_TYPE_JS_EXPRESSION"\n ? fromJS(json.authorization.expression, entities)\n : undefined,\n },\n );\n }\n\n public async toJSON(): Promise<JsonValue> {\n const api: {\n metadata: {\n name: string;\n timestamps: {\n updated: string;\n };\n };\n authorization: {\n type:\n | "AUTHORIZATION_TYPE_APP_USERS"\n | "AUTHORIZATION_TYPE_JS_EXPRESSION";\n expression?: string;\n };\n trigger: {\n application: {};\n };\n blocks: JsonValue[];\n } = {\n metadata: {\n name: this.name,\n timestamps: {\n updated: new Date().toISOString(),\n },\n },\n authorization: {\n type: this.authorization.type,\n ...{\n expression:\n this.authorization.type === "AUTHORIZATION_TYPE_JS_EXPRESSION"\n ? `(() => ${(await toJS<boolean>(this.authorization.expression)).body})()`\n : undefined,\n },\n },\n trigger: {\n application: {},\n },\n blocks: [],\n };\n\n api.blocks = await Promise.all(\n this.blocks.map(async (block) => await block.toJSON()),\n );\n\n return api;\n }\n}\n\n/**\n * Converts a string binding, which comprise 99% of dynamic integration fields, into a function returning an interpolated string.\n *\n * fromBinding(`https://${ \'goo\' + \'gle\' }.com/${ Dropdown1.value }`, [\'Dropdown1\']) -> ({ Dropdown1 }) => `https://${\'goo\' + \'gle\'}.com/${Dropdown1.value}`\n *\n * @param value - The value to convert.\n * @param entities - The master list of possible entities that could be referenced in the binding.\n *\n * @returns The converted value.\n */\nexport function fromBinding(\n value: string,\n entities: string[],\n): Binding<string> {\n if (!value) {\n return "";\n }\n\n // Handle IIFE expressions like "(() => 0)()" or "(() => { return x; })()"\n // These are used by Variables block and need to be converted back to functions\n if (value.startsWith("(() =>") && value.endsWith(")()")) {\n try {\n // Extract the body from the IIFE: "(() => BODY)()" -> "BODY"\n const iifeBody = value.slice(6, -3).trim(); // Remove "(() =>" and ")()"\n\n // Parse to extract any identifiers referenced in the body\n const ast = parse(iifeBody.startsWith("{") ? iifeBody : `(${iifeBody})`, {\n ecmaVersion: "latest",\n sourceType: "script",\n });\n const identifiers = Array.from(extractIdentifiers(ast));\n\n // Filter to only include known entities if provided\n const refs =\n entities.length > 0\n ? identifiers.filter((id) => entities.includes(id))\n : identifiers;\n\n // Create a function that returns the IIFE body\n return new Function(`{ ${refs.join(", ")} }`, `return ${iifeBody}`) as (\n _: State,\n ) => string;\n } catch {\n // If parsing fails, return the value as-is\n return value;\n }\n }\n\n if (!value.startsWith("`") || !value.endsWith("`")) {\n return value;\n }\n\n const args: string[] = [`return ${value}`];\n const references: string[] = referenced(value, entities);\n\n if (references.length === 0) {\n try {\n const ast = parse(value, {\n ecmaVersion: "latest",\n sourceType: "script",\n });\n\n const identifiers = Array.from(extractIdentifiers(ast));\n\n return new Function(\n `{ ${identifiers.join(", ")} }`,\n `return (${value})`,\n ) as (_: State) => string;\n } catch (e) {\n // can\'t extract identifiers for whatever reason, just return the value.\n return value;\n }\n }\n\n // only add the arguments if we have references\n args.unshift(`{ ${references} }`);\n\n return new Function(...args) as (_: State) => string;\n}\n\nasync function beautifyAndOptionallyCondense<T extends JsonValue>(\n value: (state: State) => T,\n node: Node,\n options: { condense?: boolean; block?: boolean } = {\n condense: true,\n block: true,\n },\n) {\n let start: number = node.start;\n let end: number = node.end;\n\n if (!options.block) {\n start += 1;\n end -= 1;\n }\n\n const beautified = await beautify(value.toString().slice(start, end));\n\n if (options.condense) {\n return beautified.replace(/\\s*\\n\\s*/g, " ").trim();\n }\n\n return beautified;\n}\n\nexport async function toJSBody<T extends JsonValue>(\n value: (state: State) => T,\n options: { block?: boolean; condense?: boolean; function?: boolean } = {\n block: true,\n condense: true,\n function: false,\n },\n): Promise<{ body: string; iife: boolean; node?: Node }> {\n if (typeof value !== "function") {\n return {\n body: `\\`${JSON.stringify(value)}\\``,\n iife: true,\n };\n }\n\n // parse the code\n const ast = createAst(value.toString());\n const program = ast.body[0];\n\n switch (program.type) {\n case "ExpressionStatement":\n const body = (\n (program as ExpressionStatement).expression as FunctionExpression\n ).body;\n\n if (body.type === "BlockStatement") {\n return {\n body: await beautifyAndOptionallyCondense(value, body, {\n ...options,\n block: options.block !== false, // Use the provided block option\n }),\n iife: true,\n node: body,\n };\n }\n\n let bodyText = safeBodyText(\n value.toString().slice(body.start, body.end),\n body,\n );\n if (options.condense) {\n bodyText = bodyText\n .replace(/\\s*\\n\\s*/g, " ")\n .replace(/\\s+/g, " ")\n .trim();\n }\n\n return {\n body: `${options.function ? "return " : ""}${bodyText}`,\n iife: options.function,\n node: body,\n };\n case "FunctionDeclaration":\n let contents = value\n .toString()\n .slice(program.body.start, program.body.end);\n\n if (program.body.type !== "BlockStatement") {\n return {\n body: contents,\n iife: false,\n node: program.body,\n };\n }\n\n if (\n !options.function &&\n program.body.body.length === 1 &&\n program.body.body[0].type === "ReturnStatement"\n ) {\n const argument = program.body.body[0].argument;\n if (!argument) {\n return {\n body: ``,\n iife: false,\n node: program.body.body[0],\n };\n }\n\n let bodyText = safeBodyText(\n value.toString().slice(argument.start, argument.end),\n argument,\n );\n\n return {\n body: bodyText,\n iife: false, // This should be false but we need to deal with the nested string template case.\n node: argument,\n };\n }\n\n return {\n body: await beautifyAndOptionallyCondense(value, program.body, options),\n iife: true,\n node: program.body,\n };\n default:\n throw new Error("you found a case we haven\'t handled yet");\n }\n}\n\nexport async function toJS<T extends JsonValue>(\n value: Binding<T>,\n): Promise<{ body: string; node?: Node }> {\n if (typeof value !== "function") {\n return {\n body: JSON.stringify(value),\n };\n }\n\n const { body, iife, node } = await toJSBody(value as (state: State) => T);\n\n if (iife) {\n return {\n body: `(() => ${body})()`,\n node,\n };\n }\n\n return { body, node };\n}\n\nexport function fromJS<T extends JsonValue>(\n value: string,\n entities: string[] = [],\n): Binding<T> {\n try {\n // determine if there are entities referenced in the value\n const refs = referenced(value, entities).join(", ");\n\n // remove any surrounding whitespace\n value = value.trim();\n\n if (value.length === 0) {\n return new Function("return ") as (_: State) => T;\n }\n\n let unaryOps: string[] = [];\n const ast = createAst(value);\n\n if (ast.body.length === 0) {\n return new Function("return ") as (_: State) => T;\n }\n\n let call = (ast.body[0] as ExpressionStatement).expression;\n\n while (call?.type === "UnaryExpression") {\n unaryOps.push((call as UnaryExpression).operator);\n call = (call as unknown as UnaryExpression).argument as CallExpression;\n }\n\n const fn = (call as CallExpression).callee;\n let body = value;\n let prefix = "return ";\n\n // handle iife\n if (fn?.type === "ArrowFunctionExpression") {\n // i\'m not happy with this but I don\'t see another immediate way to handle this.\n // this will result in a correct result but one that isn\'t idemopotent.\n if (unaryOps.length > 0) {\n return new Function(`{ ${refs} }`, `${prefix}${body}`) as (\n _: State,\n ) => T;\n }\n\n body = value.slice(fn.body.start, fn.body.end);\n\n if (fn.body.type === "BlockStatement") {\n // drop the opening "{" and closing "}"\n body = body.slice(1, -1);\n prefix = "";\n }\n } else if (refs.length === 0) {\n const ast = createAst(value);\n\n const identifiers = Array.from(extractIdentifiers(ast));\n\n return new Function(\n `{ ${identifiers.join(", ")} }`,\n `return (${value})`,\n ) as (_: State) => T;\n }\n\n // we\'re either an iife or a static value with refs.\n return new Function(`{ ${refs} }`, `${prefix}${body}`) as (_: State) => T;\n } catch (e) {\n console.error("There was an error during parsing in fromJS", e);\n // fallback to an empty function so we don\'t crash\n return new Function("return \'\'") as (_: State) => T;\n }\n}\n\nexport async function beautify(code: string): Promise<string> {\n const eslint = new ESLint({\n fix: true,\n overrideConfigFile: true,\n baseConfig: {\n languageOptions: {\n parser: typescript_eslint_parser,\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: "module",\n },\n },\n rules: {\n "arrow-body-style": "error",\n },\n },\n });\n\n code = (await eslint.lintText(code))[0]?.output || code;\n\n return await format(code, {\n parser: "typescript",\n tabWidth: 2,\n // singleQuote: true,\n trailingComma: "none",\n semi: true,\n bracketSpacing: true,\n arrowParens: "always",\n bracketSameLine: false,\n embeddedLanguageFormatting: "auto",\n quoteProps: "as-needed",\n insertPragma: false,\n requirePragma: false,\n useTabs: false,\n endOfLine: "auto",\n arrowFunctionParentheses: "always",\n // plugins: ["prettier-plugin-organize-imports"],\n });\n}\n\nexport function ensureIIFE(value: string): string {\n // We write the IIFE so we can be loose with the fomratting here.\n // For example, we\'d never get ( ( ) =>)().\n if (value.startsWith("(() => ") && value.endsWith(")()")) {\n return value;\n }\n\n let safeValue = value.trim();\n if (safeValue.startsWith("{") && safeValue.endsWith("}")) {\n safeValue = `(${safeValue})`;\n }\n\n return `(() => ${safeValue})()`;\n}\n\nfunction safeBodyText(body: string, node: Node): string {\n if (node.type === "ObjectExpression") {\n return `(${body})`;\n }\n return body;\n}\n\n// All of the integrations (openapi and not) should be registered\n// NOTE: @joeyagreco - when adding support for an integration here, make sure to update:\n// NOTE: @joeyagreco - 1. to-sdk-transformer.ts\n// NOTE: @joeyagreco - 2. context-util.ts\n// NOTE: @joeyagreco - 3. the import statement in Api.toSDK()\n// NOTE: @joeyagreco - 4. superblocks-api.md\nIntegration.registerIntegration("airtable", Airtable);\nIntegration.registerIntegration("athena", Athena);\nIntegration.registerIntegration("anthropic", Anthropic);\nIntegration.registerIntegration("asana", Asana);\nIntegration.registerIntegration("bigquery", BigQuery);\nIntegration.registerIntegration("bitbucket", Bitbucket);\nIntegration.registerIntegration("box", Box);\nIntegration.registerIntegration("circleci", CircleCI);\nIntegration.registerIntegration("cockroachdb", CockroachDB);\nIntegration.registerIntegration("cohere", Cohere);\nIntegration.registerIntegration("confluence", Confluence);\nIntegration.registerIntegration("cosmosdb", CosmosDB);\nIntegration.registerIntegration("couchbase", Couchbase);\nIntegration.registerIntegration("databricks", Databricks);\nIntegration.registerIntegration("datadog", Datadog);\nIntegration.registerIntegration("dropbox", Dropbox);\nIntegration.registerIntegration("dynamodb", DynamoDb);\nIntegration.registerIntegration("elasticsearch", Elasticsearch);\nIntegration.registerIntegration("email", Email);\nIntegration.registerIntegration("fireworks", Fireworks);\nIntegration.registerIntegration("front", Front);\nIntegration.registerIntegration("gcs", GoogleCloudStorage);\nIntegration.registerIntegration("gemini", Gemini);\nIntegration.registerIntegration("github", GitHub);\nIntegration.registerIntegration("googleanalytics", GoogleAnalytics);\nIntegration.registerIntegration("googledrive", GoogleDrive);\nIntegration.registerIntegration("graphqlintegration", GraphQL);\nIntegration.registerIntegration("groq", Groq);\nIntegration.registerIntegration("hubspot", HubSpot);\nIntegration.registerIntegration("intercom", Intercom);\nIntegration.registerIntegration("javascript", JavaScript);\nIntegration.registerIntegration("jira", Jira);\nIntegration.registerIntegration("launchdarkly", LaunchDarkly);\nIntegration.registerIntegration("mistral", Mistral);\nIntegration.registerIntegration("mongodb", MongoDB);\nIntegration.registerIntegration("notion", Notion);\nIntegration.registerIntegration("openai_v2", OpenAI);\nIntegration.registerIntegration("oracledb", OracleDB);\nIntegration.registerIntegration("pagerduty", PagerDuty);\nIntegration.registerIntegration("perplexity", Perplexity);\nIntegration.registerIntegration("postgres", PostgreSQL);\nIntegration.registerIntegration("mssql", MicrosoftSql);\nIntegration.registerIntegration("mariadb", MariaDB);\nIntegration.registerIntegration("mysql", MySQL);\nIntegration.registerIntegration("python", Python);\nIntegration.registerIntegration("redshift", Redshift);\nIntegration.registerIntegration("s3", S3);\nIntegration.registerIntegration("salesforce", Salesforce);\nIntegration.registerIntegration("segment", Segment);\nIntegration.registerIntegration("sendgrid", SendGrid);\nIntegration.registerIntegration("slack", Slack);\nIntegration.registerIntegration("snowflake", Snowflake);\nIntegration.registerIntegration("stabilityai", StabilityAI);\nIntegration.registerIntegration("stripe", Stripe);\nIntegration.registerIntegration("twilio", Twilio);\nIntegration.registerIntegration("zendesk", Zendesk);\nIntegration.registerIntegration("zoom", Zoom);\n\n// Core block types that should always be in SDK imports (not registered as integrations)\nconst CORE_BLOCK_TYPES = [\n "Api",\n "Conditional",\n "Parallel",\n "Loop",\n "TryCatch",\n "Variables",\n "Throw",\n "Return",\n "Break",\n "RestApi", // Not in registry - handled specially in Integration.fromJSON\n];\n\nexport function getSdkImports(): string {\n const integrationNames = Integration.getRegisteredIntegrationClassNames();\n const allNames = [...CORE_BLOCK_TYPES, ...integrationNames];\n return `import { ${allNames.join(", ")} } from \'@superblocksteam/library\'`;\n}\n',
712529
+ "src/superblocks-library-shim/index.ts": '/* eslint-disable */\nimport typescript_eslint_parser from "@typescript-eslint/parser";\nimport {\n CallExpression,\n ExpressionStatement,\n FunctionExpression,\n Literal,\n Node,\n parse,\n UnaryExpression,\n} from "acorn";\nimport { ESLint } from "eslint";\nimport { format } from "prettier";\nimport {\n createAst,\n extractIdentifiers,\n referenced,\n signatureV2,\n signatureV2Async,\n} from "./ast-utils.js";\n\n// Re-export AST utilities for external use\nexport { referenced, signatureV2, signatureV2Async } from "./ast-utils.js";\n\n/**\n * Global context for version-aware output generation.\n * pluginExecutionVersions is populated from the PLUGIN_EXECUTION_VERSIONS environment variable.\n */\nexport const Global: {\n /** Map of plugin ID to version string, used for version-aware output generation */\n pluginExecutionVersions?: Record<string, string>;\n} = {};\n\nexport type JsonValue = any;\n\n// This is the ideal type, but it\'s too restrictive when we use it for generating code,\n// because the builder side is doing access like `someVar.value`, but JsonValue is not\n// strict enough to avoid type errors, so you see a lot of:\n// error TS2551: Property \'value\' does not exist on type \'JsonValue\'. Did you mean \'valueOf\'?\n// Property \'value\' does not exist on type \'string\'.\n//\n// export type JsonValue =\n// | undefined\n// | null\n// | number\n// | string\n// | boolean\n// | Array<JsonValue>\n// | { [key: string]: JsonValue };\nexport type State = { [key: string]: JsonValue };\nexport type Binding<T> = T | ((state: State) => T);\n\nexport function trimSqlSpaces(content: string): string {\n if (!content) return "";\n return content\n .replace(/[ \\t]+/g, " ") // Replace multiple spaces/tabs with single space\n .replace(/[ \\t]*\\n[ \\t]*/g, "\\n") // Remove spaces around line breaks\n .replace(/^\\s+|\\s+$/g, "") // Trim leading and trailing whitespace\n .trim();\n}\nasync function binding(binding: Binding<any>): Promise<string> {\n if (typeof binding === "function") {\n const { body, node } = await toJS(binding);\n\n if (\n node?.type === "Literal" &&\n typeof (node as Literal).value === "string"\n ) {\n return `\\`${(node as Literal).value}\\``;\n }\n\n if (node?.type === "TemplateLiteral") {\n return body;\n }\n\n return `\\`\\$\\{${body}\\}\\``;\n }\n\n return `\\`${binding}\\``;\n}\n\nasync function formatGraphQLQuery(query: string): Promise<string> {\n if (!query || typeof query !== "string") {\n return query;\n }\n\n try {\n const formatted = await format(query, {\n parser: "graphql",\n printWidth: 80,\n tabWidth: 2,\n useTabs: false,\n });\n return formatted.trim();\n } catch (error) {\n // if prettier fails to format, return the original query\n return query;\n }\n}\n\nexport async function bindingSql(binding: Binding<string>): Promise<string> {\n if (typeof binding === "function") {\n const ret = await toJSBody(binding as (state: State) => string, {\n condense: false,\n });\n const { body, iife, node } = ret;\n\n if (\n node?.type === "Literal" &&\n typeof (node as Literal).value === "string"\n ) {\n const escapedValue = (node as Literal).value as string;\n // Escape backticks in the SQL string\n const escaped = escapedValue.replace(/`/g, "\\\\`");\n return `\\`${trimSqlSpaces(escaped)}\\``;\n }\n\n if (node?.type === "TemplateLiteral") {\n const trimmedBody = trimSqlSpaces(body);\n return iife ? `(() => ${trimmedBody})()` : trimmedBody;\n }\n\n let finalBody = body;\n\n if (iife) {\n finalBody = `(() => ${body})()`;\n }\n\n finalBody = trimSqlSpaces(finalBody);\n\n // Special handling for template literals - trim content within backticks\n finalBody = finalBody.replace(/`([^`]*)`/g, (_match, content) => {\n const trimmedContent = trimSqlSpaces(content);\n return `\\`${trimmedContent}\\``;\n });\n\n return `\\`\\$\\{${finalBody}\\}\\``;\n }\n\n const trimmedBinding = trimSqlSpaces(binding);\n // Escape backticks in the SQL string\n const escaped = trimmedBinding.replace(/`/g, "\\\\`");\n return `\\`${escaped}\\``;\n}\n\nexport async function bindingGraphQL(\n binding: Binding<string>,\n): Promise<string> {\n if (typeof binding === "function") {\n const ret = await toJSBody(binding as (state: State) => string, {\n condense: false,\n });\n const { body, iife, node } = ret;\n\n if (\n node?.type === "Literal" &&\n typeof (node as Literal).value === "string"\n ) {\n const formatted = await formatGraphQLQuery(\n (node as Literal).value as string,\n );\n return `\\`${formatted}\\``;\n }\n\n if (node?.type === "TemplateLiteral") {\n return iife ? `(() => ${body})()` : body;\n }\n\n let finalBody = body;\n\n if (iife) {\n finalBody = `(() => ${body})()`;\n }\n\n return `\\`\\$\\{${finalBody}\\}\\``;\n }\n\n const formatted = await formatGraphQLQuery(binding);\n return `\\`${formatted}\\``;\n}\n\ninterface Codec {\n toJSON(): Promise<JsonValue>;\n toSDK(entities: string[]): Promise<string>;\n}\n\nexport abstract class Block implements Codec {\n protected name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n public abstract toJSON(): Promise<JsonValue>;\n public abstract toSDK(entities: string[]): Promise<string>;\n\n public static fromJSON(json: any, entities: string[]): Block {\n if (json?.step) {\n return Integration.fromJSON(json, entities);\n }\n\n if ("conditional" in json) {\n return Conditional.fromJSON(json, entities);\n }\n\n if ("loop" in json) {\n return Loop.fromJSON(json, entities);\n }\n\n if ("parallel" in json) {\n return Parallel.fromJSON(json, entities);\n }\n\n if ("tryCatch" in json) {\n return TryCatch.fromJSON(json, entities);\n }\n\n if ("variables" in json) {\n return Variables.fromJSON(json, entities);\n }\n\n if ("throw" in json) {\n return Throw.fromJSON(json, entities);\n }\n\n if ("return" in json) {\n return Return.fromJSON(json, entities);\n }\n\n if ("break" in json) {\n return Break.fromJSON(json, entities);\n }\n\n throw new Error("Unknown block");\n }\n}\n\nexport abstract class Integration extends Block {\n protected integration: string;\n\n constructor(name: string, integration: string) {\n super(name);\n\n this.integration = integration;\n }\n\n public abstract toJSON(): Promise<JsonValue>;\n public abstract toSDK(entities: string[]): Promise<string>;\n\n private static integrationRegistry: Record<string, any> = {};\n\n public static registerIntegration(key: string, integrationClass: any) {\n this.integrationRegistry[key] = integrationClass;\n }\n\n public static getRegisteredIntegrationClasses(): any[] {\n return Object.values(this.integrationRegistry);\n }\n\n public static getRegisteredIntegrationClassNames(): string[] {\n return Object.values(this.integrationRegistry).map((cls) => cls.name);\n }\n\n /**\n * Returns a map of pluginId -> className for all registered integrations.\n * @internal Used only for consistency tests - not part of the public API.\n */\n public static getRegisteredIntegrationMap(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(this.integrationRegistry).map(([key, cls]) => [\n key,\n cls.name,\n ]),\n );\n }\n\n public static fromJSON(json: any, entities: string[]): Block {\n if ("restapi" in json?.step || "restapiintegration" in json?.step) {\n return RestApi.fromJSON(json, entities);\n }\n\n for (const [key, IntegrationClass] of Object.entries(\n this.integrationRegistry,\n )) {\n if (key in json?.step) {\n return IntegrationClass.fromJSON(json, entities);\n }\n }\n\n console.error("Unknown integration", json?.step);\n throw new Error("Unknown integration");\n }\n}\n\nexport class Python extends Integration {\n private fn: string;\n\n constructor(\n name: string,\n config: {\n fn: string;\n },\n ) {\n super(name, "python");\n\n this.fn = config.fn;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: "python",\n python: {\n body: this.fn,\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Python("${this.name}", { fn: ${this.fn} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Python {\n return new Python(json?.name, {\n fn: json?.step?.python?.body,\n });\n }\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/AsyncFunction\nconst AsyncFunction: any = async function () {}.constructor;\n\nexport class JavaScript extends Integration {\n private fn: (_: State) => JsonValue;\n\n constructor(\n name: string,\n config: {\n fn: (_: State) => JsonValue;\n },\n ) {\n super(name, "javascript");\n\n this.fn = config.fn;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: "javascript",\n javascript: {\n body: (await toJSBody(this.fn, { block: false, function: true }))\n .body,\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new JavaScript("${this.name}", { fn: ${signatureV2Async((await toJSBody(this.fn)).body, entities)} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): JavaScript {\n const args = [json?.step?.javascript?.body];\n const references = referenced(json?.step?.javascript?.body, entities);\n\n if (references.length > 0) {\n args.unshift(`{ ${references.join(", ")} }`);\n }\n\n return new JavaScript(json?.name, {\n fn: new AsyncFunction(...args) as (_: State) => JsonValue,\n });\n }\n}\n\nexport interface AthenaConfig {\n sqlBody: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Athena extends Integration {\n private sqlBody: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: AthenaConfig) {\n super(name, integration);\n\n this.sqlBody = config.sqlBody;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n athena: {\n runSql: {\n sqlBody: await bindingSql(this.sqlBody),\n },\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.athena.runSql.parameters = bound.replace(/^`|`$/g, "");\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.sqlBody === "function"\n ? signatureV2(\n (await toJSBody(this.sqlBody, { condense: false })).body,\n entities,\n )\n : `\\`${this.sqlBody}\\``;\n\n const parts = [`sqlBody: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Athena("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Athena {\n const athena = json?.step?.athena?.runSql;\n\n return new Athena(json?.name, json?.step?.integration, {\n sqlBody: fromBinding(athena?.sqlBody, entities),\n parameters:\n athena?.parameters !== undefined\n ? fromBinding(athena.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface BigQueryConfig {\n sqlBody: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class BigQuery extends Integration {\n private sqlBody: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: BigQueryConfig) {\n super(name, integration);\n\n this.sqlBody = config.sqlBody;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n bigquery: {\n body: await bindingSql(this.sqlBody),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.bigquery.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.bigquery.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.sqlBody === "function"\n ? signatureV2(\n (await toJSBody(this.sqlBody, { condense: false })).body,\n entities,\n )\n : `\\`${this.sqlBody}\\``;\n\n const parts = [`sqlBody: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new BigQuery("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): BigQuery {\n const bigquery = json?.step?.bigquery;\n\n return new BigQuery(json?.name, json?.step?.integration, {\n sqlBody: fromBinding(bigquery?.body, entities),\n parameters:\n bigquery?.parameters !== undefined\n ? fromBinding(bigquery.parameters, entities)\n : undefined,\n });\n }\n}\n\ntype DynamoDbAction =\n | "getItem"\n | "updateItem"\n | "putItem"\n | "batchWriteItem"\n | "deleteItem"\n | "query"\n | "scan"\n | "executeStatement"\n | "executeTransaction"\n | "listTagsOfResource"\n | "tagResource"\n | "listTables"\n | "describeTable"\n | "createTable"\n | "updateTable"\n | "deleteTable";\n\nexport class DynamoDb extends Integration {\n private action: DynamoDbAction;\n private paramsJson: Binding<string>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: DynamoDbAction;\n paramsJson: Binding<string>;\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.paramsJson = config.paramsJson;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n dynamodb: {\n action: this.action,\n body: await binding(this.paramsJson),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new DynamoDb("${this.name}", "${this.integration}", { action: "${this.action}", paramsJson: ${typeof this.paramsJson === "function" ? signatureV2((await toJSBody(this.paramsJson)).body, entities) : `"${this.paramsJson}"`} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): DynamoDb {\n return new DynamoDb(json?.name, json?.step?.integration, {\n action: json?.step?.dynamodb?.action,\n paramsJson: fromBinding(json?.step?.dynamodb?.body, entities),\n });\n }\n}\n\ntype S3Action =\n | "LIST_OBJECTS"\n | "LIST_BUCKET_OBJECTS"\n | "GET_OBJECT"\n | "DELETE_OBJECT"\n | "UPLOAD_OBJECT"\n | "LIST_BUCKETS"\n | "CREATE_BUCKET"\n | "UPLOAD_MULTIPLE_OBJECTS"\n | "GENERATE_PRESIGNED_URL";\n\n// File object type for S3 uploads\ntype FileObject = {\n name: string;\n contents: string | Buffer;\n type: string;\n size?: number;\n encoding?: string;\n};\n\ntype GCSAction =\n | "LIST_OBJECTS"\n | "GET_OBJECT"\n | "DELETE_OBJECT"\n | "UPLOAD_OBJECT"\n | "LIST_BUCKETS"\n | "CREATE_BUCKET"\n | "UPLOAD_MULTIPLE_OBJECTS"\n | "GENERATE_PRESIGNED_URL";\n\nexport class GoogleCloudStorage extends Integration {\n private action: GCSAction;\n private resource?: Binding<string>;\n private path?: Binding<string>;\n private prefix?: Binding<string>;\n private body?: Binding<string | FileObject>;\n private fileObjects?: Binding<FileObject[]>;\n private responseType?: "AUTO" | "JSON" | "TEXT" | "BINARY";\n private custom?: {\n presignedExpiration?: { value: number };\n };\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: GCSAction;\n resource?: Binding<string>;\n path?: Binding<string>;\n prefix?: Binding<string>;\n body?: Binding<string | FileObject>;\n fileObjects?: Binding<FileObject[]>;\n responseType?: "AUTO" | "JSON" | "TEXT" | "BINARY";\n custom?: {\n presignedExpiration?: { value: number };\n };\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.resource = config.resource;\n this.path = config.path;\n this.prefix = config.prefix;\n this.body = config.body;\n this.fileObjects = config.fileObjects;\n this.responseType = config.responseType;\n this.custom = config.custom;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n gcs: {\n action: this.action,\n ...(this.resource ? { resource: await binding(this.resource) } : {}),\n ...(this.path ? { path: await binding(this.path) } : {}),\n ...(this.prefix ? { prefix: await binding(this.prefix) } : {}),\n ...(this.body ? { body: await binding(this.body) } : {}),\n ...(this.fileObjects\n ? { fileObjects: await binding(this.fileObjects) }\n : {}),\n ...(this.responseType ? { responseType: this.responseType } : {}),\n ...(this.custom\n ? {\n custom: {\n ...(this.custom.presignedExpiration\n ? { presignedExpiration: this.custom.presignedExpiration }\n : {}),\n },\n }\n : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [`action: "${this.action}"`];\n\n if (this.resource) {\n parts.push(\n `resource: ${\n typeof this.resource === "function"\n ? signatureV2((await toJSBody(this.resource)).body, entities)\n : `"${this.resource}"`\n }`,\n );\n }\n\n if (this.path) {\n parts.push(\n `path: ${\n typeof this.path === "function"\n ? signatureV2((await toJSBody(this.path)).body, entities)\n : `"${this.path}"`\n }`,\n );\n }\n\n if (this.prefix) {\n parts.push(\n `prefix: ${\n typeof this.prefix === "function"\n ? signatureV2((await toJSBody(this.prefix)).body, entities)\n : `"${this.prefix}"`\n }`,\n );\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : `"${this.body}"`\n }`,\n );\n }\n\n if (this.fileObjects) {\n parts.push(\n `fileObjects: ${\n typeof this.fileObjects === "function"\n ? signatureV2((await toJSBody(this.fileObjects)).body, entities)\n : `"${this.fileObjects}"`\n }`,\n );\n }\n\n if (this.responseType) {\n parts.push(`responseType: "${this.responseType}"`);\n }\n\n if (this.custom) {\n const customParts: string[] = [];\n if (this.custom.presignedExpiration) {\n customParts.push(\n `presignedExpiration: { value: ${this.custom.presignedExpiration.value} }`,\n );\n }\n if (customParts.length > 0) {\n parts.push(`custom: { ${customParts.join(", ")} }`);\n }\n }\n\n return `new GoogleCloudStorage("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): GoogleCloudStorage {\n return new GoogleCloudStorage(json?.name, json?.step?.integration, {\n action: json?.step?.gcs?.action,\n resource: json?.step?.gcs?.resource\n ? fromBinding(json?.step?.gcs?.resource, entities)\n : undefined,\n path: json?.step?.gcs?.path\n ? fromBinding(json?.step?.gcs?.path, entities)\n : undefined,\n prefix: json?.step?.gcs?.prefix\n ? fromBinding(json?.step?.gcs?.prefix, entities)\n : undefined,\n body: json?.step?.gcs?.body\n ? fromBinding(json?.step?.gcs?.body, entities)\n : undefined,\n fileObjects: json?.step?.gcs?.fileObjects\n ? (fromBinding(\n json?.step?.gcs?.fileObjects,\n entities,\n ) as unknown as Binding<FileObject[]>)\n : undefined,\n responseType: json?.step?.gcs?.responseType,\n custom: json?.step?.gcs?.custom\n ? {\n presignedExpiration: json?.step?.gcs?.custom?.presignedExpiration,\n }\n : undefined,\n });\n }\n}\n\nexport class S3 extends Integration {\n private action: S3Action;\n private resource?: Binding<string>;\n private path?: Binding<string>;\n private body?: Binding<string | FileObject>;\n private fileObjects?: Binding<FileObject[]>;\n private listFilesConfig?: {\n prefix?: Binding<string>;\n delimiter?: Binding<string>;\n };\n private custom?: {\n /** Enum name for presigned URL method */\n presignedMethod?:\n | "PRESIGNED_METHOD_UNSPECIFIED"\n | "PRESIGNED_METHOD_GET"\n | "PRESIGNED_METHOD_PUT";\n presignedExpiration?: { value: number };\n };\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: S3Action;\n resource?: Binding<string>;\n path?: Binding<string>;\n body?: Binding<string | FileObject>;\n fileObjects?: Binding<FileObject[]>;\n listFilesConfig?: {\n prefix?: Binding<string>;\n delimiter?: Binding<string>;\n };\n custom?: {\n /** Enum name for presigned URL method */\n presignedMethod?:\n | "PRESIGNED_METHOD_UNSPECIFIED"\n | "PRESIGNED_METHOD_GET"\n | "PRESIGNED_METHOD_PUT";\n presignedExpiration?: { value: number };\n };\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.resource = config.resource;\n this.path = config.path;\n this.body = config.body;\n this.fileObjects = config.fileObjects;\n this.listFilesConfig = config.listFilesConfig;\n this.custom = config.custom;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n s3: {\n action: this.action,\n ...(this.resource ? { resource: await binding(this.resource) } : {}),\n ...(this.path ? { path: await binding(this.path) } : {}),\n ...(this.body ? { body: await binding(this.body) } : {}),\n ...(this.fileObjects\n ? { fileObjects: await binding(this.fileObjects) }\n : {}),\n ...(this.listFilesConfig\n ? {\n listFilesConfig: {\n ...(this.listFilesConfig.prefix\n ? { prefix: await binding(this.listFilesConfig.prefix) }\n : {}),\n ...(this.listFilesConfig.delimiter\n ? {\n delimiter: await binding(\n this.listFilesConfig.delimiter,\n ),\n }\n : {}),\n },\n }\n : {}),\n ...(this.custom\n ? {\n custom: {\n ...(this.custom.presignedMethod\n ? { presignedMethod: this.custom.presignedMethod }\n : {}),\n ...(this.custom.presignedExpiration\n ? { presignedExpiration: this.custom.presignedExpiration }\n : {}),\n },\n }\n : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [`action: "${this.action}"`];\n\n if (this.resource) {\n parts.push(\n `resource: ${\n typeof this.resource === "function"\n ? signatureV2((await toJSBody(this.resource)).body, entities)\n : `"${this.resource}"`\n }`,\n );\n }\n\n if (this.path) {\n parts.push(\n `path: ${\n typeof this.path === "function"\n ? signatureV2((await toJSBody(this.path)).body, entities)\n : `"${this.path}"`\n }`,\n );\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : `"${this.body}"`\n }`,\n );\n }\n\n if (this.fileObjects) {\n parts.push(\n `fileObjects: ${\n typeof this.fileObjects === "function"\n ? signatureV2((await toJSBody(this.fileObjects)).body, entities)\n : `"${this.fileObjects}"`\n }`,\n );\n }\n\n if (this.listFilesConfig) {\n const configParts: string[] = [];\n if (this.listFilesConfig.prefix) {\n configParts.push(\n `prefix: ${\n typeof this.listFilesConfig.prefix === "function"\n ? signatureV2(\n (await toJSBody(this.listFilesConfig.prefix)).body,\n entities,\n )\n : `"${this.listFilesConfig.prefix}"`\n }`,\n );\n }\n if (this.listFilesConfig.delimiter) {\n configParts.push(\n `delimiter: ${\n typeof this.listFilesConfig.delimiter === "function"\n ? signatureV2(\n (await toJSBody(this.listFilesConfig.delimiter)).body,\n entities,\n )\n : `"${this.listFilesConfig.delimiter}"`\n }`,\n );\n }\n if (configParts.length > 0) {\n parts.push(`listFilesConfig: { ${configParts.join(", ")} }`);\n }\n }\n\n if (this.custom) {\n const customParts: string[] = [];\n if (this.custom.presignedMethod) {\n customParts.push(`presignedMethod: "${this.custom.presignedMethod}"`);\n }\n if (this.custom.presignedExpiration) {\n customParts.push(\n `presignedExpiration: { value: ${this.custom.presignedExpiration.value} }`,\n );\n }\n if (customParts.length > 0) {\n parts.push(`custom: { ${customParts.join(", ")} }`);\n }\n }\n\n return `new S3("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): S3 {\n return new S3(json?.name, json?.step?.integration, {\n action: json?.step?.s3?.action,\n resource: json?.step?.s3?.resource\n ? fromBinding(json?.step?.s3?.resource, entities)\n : undefined,\n path: json?.step?.s3?.path\n ? fromBinding(json?.step?.s3?.path, entities)\n : undefined,\n body: json?.step?.s3?.body\n ? fromBinding(json?.step?.s3?.body, entities)\n : undefined,\n fileObjects: json?.step?.s3?.fileObjects\n ? (fromBinding(\n json?.step?.s3?.fileObjects,\n entities,\n ) as unknown as Binding<FileObject[]>)\n : undefined,\n listFilesConfig: json?.step?.s3?.listFilesConfig\n ? {\n prefix: json?.step?.s3?.listFilesConfig?.prefix\n ? fromBinding(json?.step?.s3?.listFilesConfig?.prefix, entities)\n : undefined,\n delimiter: json?.step?.s3?.listFilesConfig?.delimiter\n ? fromBinding(\n json?.step?.s3?.listFilesConfig?.delimiter,\n entities,\n )\n : undefined,\n }\n : undefined,\n custom: json?.step?.s3?.custom\n ? {\n presignedMethod: json?.step?.s3?.custom?.presignedMethod,\n presignedExpiration: json?.step?.s3?.custom?.presignedExpiration,\n }\n : undefined,\n });\n }\n}\n\nexport interface SnowflakeConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Snowflake extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: SnowflakeConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n snowflake: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.snowflake.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.snowflake.usePreparedSql = false;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Snowflake("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Snowflake {\n const snowflake = json?.step?.snowflake;\n\n return new Snowflake(json?.name, json?.step?.integration, {\n statement: fromBinding(snowflake?.body as string | undefined, entities),\n parameters:\n snowflake?.parameters !== undefined\n ? fromBinding(snowflake.parameters, entities)\n : undefined,\n });\n }\n}\n\n/**\n * Helper to compare semver versions.\n * Returns true if version >= minVersion.\n */\nfunction semverGte(version: string, minVersion: string): boolean {\n const parseVersion = (v: string): number[] => {\n return v.replace(/^v/, "").split(".").map(Number);\n };\n const [major1, minor1, patch1] = parseVersion(version);\n const [major2, minor2, patch2] = parseVersion(minVersion);\n\n if (major1 !== major2) return major1 > major2;\n if (minor1 !== minor2) return minor1 > minor2;\n return patch1 >= patch2;\n}\n\nexport interface PostgreSQLConfig {\n statement: Binding<string>;\n /** Parameters for the SQL query. */\n parameters?: Binding<string>;\n}\n\nexport class PostgreSQL extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: PostgreSQLConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n postgres: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.postgres.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.postgres.usePreparedSql = false;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new PostgreSQL("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): PostgreSQL {\n const postgres = json?.step?.postgres;\n\n return new PostgreSQL(json?.name, json?.step?.integration, {\n statement: fromBinding(postgres?.body as string | undefined, entities),\n parameters:\n postgres?.parameters !== undefined\n ? fromBinding(postgres.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface CockroachDBConfig {\n statement: Binding<string>;\n /** Parameters for the SQL query (PostgreSQL-compatible $1, $2, etc.) */\n parameters?: Binding<string>;\n}\n\nexport class CockroachDB extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: CockroachDBConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n cockroachdb: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.cockroachdb.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.cockroachdb.usePreparedSql = false;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new CockroachDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): CockroachDB {\n const cockroachdb = json?.step?.cockroachdb;\n\n return new CockroachDB(json?.name, json?.step?.integration, {\n statement: fromBinding(cockroachdb?.body as string | undefined, entities),\n parameters:\n cockroachdb?.parameters !== undefined\n ? fromBinding(cockroachdb.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface OracleDBConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class OracleDB extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: OracleDBConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n oracledb: {\n runSql: {\n sqlBody: await bindingSql(this.statement),\n },\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.oracledb.runSql.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.oracledb.runSql.useParameterized = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new OracleDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): OracleDB {\n const oracledb = json?.step?.oracledb;\n\n return new OracleDB(json?.name, json?.step?.integration, {\n statement: fromBinding(\n oracledb?.runSql?.sqlBody as string | undefined,\n entities,\n ),\n parameters:\n oracledb?.runSql?.parameters !== undefined\n ? fromBinding(oracledb.runSql.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface RedshiftConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Redshift extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: RedshiftConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n redshift: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.redshift.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.redshift.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Redshift("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Redshift {\n const redshift = json?.step?.redshift;\n\n return new Redshift(json?.name, json?.step?.integration, {\n statement: fromBinding(redshift?.body as string | undefined, entities),\n parameters:\n redshift?.parameters !== undefined\n ? fromBinding(redshift.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface MicrosoftSqlConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class MicrosoftSql extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: MicrosoftSqlConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n mssql: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.mssql.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.mssql.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new MicrosoftSql("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MicrosoftSql {\n const mssql = json?.step?.mssql;\n\n return new MicrosoftSql(json?.name, json?.step?.integration, {\n statement: fromBinding(mssql?.body as string | undefined, entities),\n parameters:\n mssql?.parameters !== undefined\n ? fromBinding(mssql.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface MariaDBConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class MariaDB extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: MariaDBConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n mariadb: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.mariadb.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.mariadb.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new MariaDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MariaDB {\n const mariadb = json?.step?.mariadb;\n\n return new MariaDB(json?.name, json?.step?.integration, {\n statement: fromBinding(mariadb?.body as string | undefined, entities),\n parameters:\n mariadb?.parameters !== undefined\n ? fromBinding(mariadb.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport interface MySQLConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class MySQL extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: MySQLConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n mysql: {\n body: await bindingSql(this.statement),\n operation: "run_sql",\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.mysql.parameters = bound.replace(/^`|`$/g, "");\n } else {\n result.step.mysql.usePreparedSql = true;\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new MySQL("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MySQL {\n const mysql = json?.step?.mysql;\n\n return new MySQL(json?.name, json?.step?.integration, {\n statement: fromBinding(mysql?.body as string | undefined, entities),\n parameters:\n mysql?.parameters !== undefined\n ? fromBinding(mysql.parameters, entities)\n : undefined,\n });\n }\n}\n\nexport class GraphQL extends Integration {\n private body: Binding<string>;\n private variables?: Binding<string>;\n private headers?: { key: Binding<string>; value: Binding<string> }[];\n\n constructor(\n name: string,\n integration: string,\n config: {\n query: Binding<string>;\n variables?: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n },\n ) {\n super(name, integration);\n\n this.body = config.query;\n this.variables = config.variables;\n this.headers = config.headers;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n graphqlintegration: {\n body: await bindingGraphQL(this.body),\n ...(this.variables\n ? {\n custom: {\n variables: {\n value: await binding(this.variables),\n },\n },\n }\n : {}),\n ...(this.headers && Array.isArray(this.headers)\n ? {\n headers: await Promise.all(\n this.headers.map(async (header) => ({\n key: await binding(header.key),\n value: await binding(header.value),\n })),\n ),\n }\n : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [\n `query: ${typeof this.body === "function" ? signatureV2((await toJSBody(this.body)).body, entities) : `"${this.body}"`}`,\n ];\n\n if (this.variables) {\n parts.push(\n `variables: ${typeof this.variables === "function" ? signatureV2((await toJSBody(this.variables)).body, entities) : `"${this.variables}"`}`,\n );\n }\n\n if (this.headers) {\n const headers = (\n await Promise.all(\n this.headers.map(\n async (h) =>\n `{ key: ${\n typeof h.key === "function"\n ? signatureV2((await toJSBody(h.key)).body, entities)\n : `"${h.key}"`\n }, value: ${\n typeof h.value === "function"\n ? signatureV2((await toJSBody(h.value)).body, entities)\n : `"${h.value}"`\n } }`,\n ),\n )\n ).join(", ");\n parts.push(`headers: [${headers}]`);\n }\n\n return `new GraphQL("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): GraphQL {\n const graphql = json?.step?.graphqlintegration;\n\n return new GraphQL(json?.name, json?.step?.integration, {\n query: fromBinding(graphql?.body, entities),\n variables: graphql?.custom?.variables?.value\n ? fromBinding(graphql?.custom?.variables?.value, entities)\n : undefined,\n headers: graphql?.headers?.map((header: any) => ({\n key: fromBinding(header.key, entities),\n value: fromBinding(header.value, entities),\n })),\n });\n }\n}\n\nexport class RestApi extends Integration {\n private method: string;\n private url: Binding<string>;\n private headers?: { key: Binding<string>; value: Binding<string> }[];\n private params?: { key: Binding<string>; value: Binding<string> }[];\n private body?: Binding<string>;\n private bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";\n private openapi?: {\n path: string;\n };\n\n protected type: string;\n\n constructor(\n name: string,\n integration: string = "restapi",\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n bodyType?: "jsonBody" | "rawBody" | "formData" | "fileForm";\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration);\n\n this.method = config.method;\n this.url = config.url;\n this.headers = config.headers;\n this.params = config.params;\n this.body = config.body;\n this.openapi = openapi;\n this.type = this.isIntegration() ? "restapiintegration" : "restapi";\n this.bodyType = config.bodyType;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const openApiAction = (): string => {\n if (!this.isIntegration()) {\n return undefined;\n }\n\n if (this.openapi?.path) {\n let path: string = this.openapi.path.trim();\n\n if (path.startsWith("`") && path.endsWith("`")) {\n path = path.slice(1, -1);\n }\n\n return `${this.method} ${path}`;\n }\n\n return "genericHttpRequest";\n };\n\n const method = this.method?.toString().toUpperCase();\n const supportedMethods = [\n "GET",\n "POST",\n "PUT",\n "DELETE",\n "PATCH",\n "HEAD",\n "OPTIONS",\n ];\n\n return {\n name: this.name,\n step: {\n integration: this.integration,\n [this.type]: {\n httpMethod: supportedMethods.includes(method) ? method : "GET",\n openApiAction: openApiAction(),\n ...(this.url\n ? {\n [this.isIntegration() ? "urlPath" : "path"]: await binding(\n this.url,\n ),\n }\n : {}),\n ...(this.headers && Array.isArray(this.headers)\n ? {\n headers: await Promise.all(\n this.headers.map(async (header) => ({\n key: await binding(header.key),\n value: await binding(header.value),\n })),\n ),\n }\n : {}),\n ...(this.params && Array.isArray(this.params)\n ? {\n params: await Promise.all(\n this.params.map(async (param) => ({\n key: await binding(param.key),\n value: await binding(param.value),\n })),\n ),\n }\n : {}),\n ...(this.body ? { body: await binding(this.body) } : {}),\n bodyType: this.bodyType ?? "jsonBody",\n\n // Other params that I might need to add.\n responseType: "auto",\n },\n },\n };\n }\n\n private isIntegration(): boolean {\n return this.integration !== "restapi";\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new RestApi(${await this.constructorParametersString(entities)})`;\n }\n\n protected async constructorParametersString(\n entities: string[],\n ): Promise<string> {\n const parts: string[] = [`method: "${this.method}"`];\n\n if (this.url) {\n parts.push(\n `url: ${\n typeof this.url === "function"\n ? signatureV2((await toJSBody(this.url)).body, entities)\n : `"${this.url}"`\n }`,\n );\n }\n\n if (this.headers) {\n const headers = (\n await Promise.all(\n this.headers.map(\n async (h) =>\n `{ key: ${\n typeof h.key === "function"\n ? signatureV2((await toJSBody(h.key)).body, entities)\n : `"${h.key}"`\n }, value: ${\n typeof h.value === "function"\n ? signatureV2((await toJSBody(h.value)).body, entities)\n : `"${h.value}"`\n } }`,\n ),\n )\n ).join(", ");\n parts.push(`headers: [${headers}]`);\n }\n\n if (this.params) {\n const params = (\n await Promise.all(\n this.params.map(\n async (p) =>\n `{ key: ${\n typeof p.key === "function"\n ? signatureV2((await toJSBody(p.key)).body, entities)\n : `"${p.key}"`\n }, value: ${\n typeof p.value === "function"\n ? signatureV2((await toJSBody(p.value)).body, entities)\n : `"${p.value}"`\n } }`,\n ),\n )\n ).join(", ");\n parts.push(`params: [${params}]`);\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : JSON.stringify(this.body)\n }`,\n );\n }\n\n if (this.bodyType) {\n parts.push(`bodyType: ${this.bodyType}`);\n }\n\n return `"${this.name}", "${this.integration}", { ${parts.join(", ")} }, ${JSON.stringify(this.openapi)}`;\n }\n\n public static fromJSON(json: any, entities: string[]): RestApi {\n const config =\n json?.step?.[\n json?.step?.integration === "restapi" ? "restapi" : "restapiintegration"\n ];\n\n if (json?.step?.integration === "restapiintegration") {\n return new RestApi(\n json?.name,\n json?.step?.integration,\n OpenApi.configFromJSON(config, entities),\n OpenApi.openapiFromJSON(config),\n );\n }\n\n return new RestApi(\n json?.name,\n json?.step?.integration,\n {\n method: config?.httpMethod,\n url: fromBinding(config?.path, entities),\n headers: config?.headers?.map((header: any) => ({\n key: fromBinding(header.key, entities),\n value: fromBinding(header.value, entities),\n })),\n params: config?.params?.map((param: any) => ({\n key: fromBinding(param.key, entities),\n value: fromBinding(param.value, entities),\n })),\n body: fromBinding(config?.body, entities),\n bodyType: config?.bodyType,\n },\n OpenApi.openapiFromJSON(config),\n );\n }\n}\n\ntype SalesforceAction =\n | { action: "SOQL_ACTION_SOQL"; soqlBody: Binding<string> }\n | {\n action: "CRUD_ACTION_READ";\n resourceType: Binding<string>;\n resourceId: Binding<string>;\n }\n | {\n action: "CRUD_ACTION_CREATE";\n resourceType: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "CRUD_ACTION_UPDATE";\n resourceType: Binding<string>;\n resourceId: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "CRUD_ACTION_DELETE";\n resourceType: Binding<string>;\n resourceId: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "BULK_ACTION_CREATE";\n resourceType: Binding<string>;\n resourceBody: Binding<string>;\n }\n | {\n action: "BULK_ACTION_UPDATE";\n resourceType: Binding<string>;\n resourceBody: Binding<string>;\n };\n\nexport class Salesforce extends Integration {\n private action: SalesforceAction;\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: SalesforceAction;\n },\n ) {\n super(name, integration);\n this.action = config.action;\n }\n\n public async toJSON(): Promise<JsonValue> {\n let salesforce;\n switch (this.action.action) {\n case "SOQL_ACTION_SOQL":\n salesforce = {\n soql: {\n action: this.action.action,\n sqlBody: await binding(this.action.soqlBody),\n },\n };\n break;\n\n case "CRUD_ACTION_READ":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceId: await binding(this.action.resourceId),\n },\n };\n break;\n\n case "CRUD_ACTION_CREATE":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "CRUD_ACTION_UPDATE":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceId: await binding(this.action.resourceId),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "CRUD_ACTION_DELETE":\n salesforce = {\n crud: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceId: await binding(this.action.resourceId),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "BULK_ACTION_CREATE":\n salesforce = {\n bulk: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n\n case "BULK_ACTION_UPDATE":\n salesforce = {\n bulk: {\n action: this.action.action,\n resourceType: await binding(this.action.resourceType),\n resourceBody: await binding(this.action.resourceBody),\n },\n };\n break;\n }\n return {\n name: this.name,\n step: {\n integration: this.integration,\n salesforce,\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n switch (this.action.action) {\n case "SOQL_ACTION_SOQL":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "SOQL_ACTION_SOQL", soqlBody: ${typeof this.action.soqlBody === "function" ? signatureV2((await toJSBody(this.action.soqlBody, { condense: false })).body, entities) : `"${this.action.soqlBody}"`} } })`;\n\n case "CRUD_ACTION_READ":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_READ", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceId: ${typeof this.action.resourceId === "function" ? signatureV2((await toJSBody(this.action.resourceId, { condense: false })).body, entities) : `"${this.action.resourceId}"`} } })`;\n\n case "CRUD_ACTION_CREATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_CREATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "CRUD_ACTION_UPDATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_UPDATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceId: ${typeof this.action.resourceId === "function" ? signatureV2((await toJSBody(this.action.resourceId, { condense: false })).body, entities) : `"${this.action.resourceId}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "CRUD_ACTION_DELETE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "CRUD_ACTION_DELETE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceId: ${typeof this.action.resourceId === "function" ? signatureV2((await toJSBody(this.action.resourceId, { condense: false })).body, entities) : `"${this.action.resourceId}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "BULK_ACTION_CREATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "BULK_ACTION_CREATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n\n case "BULK_ACTION_UPDATE":\n return `new Salesforce("${this.name}", "${this.integration}", { action: { action: "BULK_ACTION_UPDATE", resourceType: ${typeof this.action.resourceType === "function" ? signatureV2((await toJSBody(this.action.resourceType, { condense: false })).body, entities) : `"${this.action.resourceType}"`}, resourceBody: ${typeof this.action.resourceBody === "function" ? signatureV2((await toJSBody(this.action.resourceBody, { condense: false })).body, entities) : `"${this.action.resourceBody}"`} } })`;\n }\n }\n\n public static fromJSON(json: any, entities: string[]): Salesforce {\n // NOTE: @joeyagreco - we use if statements instead of switch statements here since the json field is at different places (proto oneofs dont be the most annoying thing to work around challenge: impossible)\n if (json?.step?.salesforce?.soql?.action === "SOQL_ACTION_SOQL") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "SOQL_ACTION_SOQL",\n // NOTE: The proto field is `sqlBody`, but the SDK config type uses `soqlBody`\n soqlBody: fromBinding(\n json?.step?.salesforce?.soql?.sqlBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_READ") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_READ",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceId: fromBinding(\n json?.step?.salesforce?.crud?.resourceId,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_CREATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_CREATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.crud?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_UPDATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_UPDATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceId: fromBinding(\n json?.step?.salesforce?.crud?.resourceId,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.crud?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.crud?.action === "CRUD_ACTION_DELETE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "CRUD_ACTION_DELETE",\n resourceType: fromBinding(\n json?.step?.salesforce?.crud?.resourceType,\n entities,\n ),\n resourceId: fromBinding(\n json?.step?.salesforce?.crud?.resourceId,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.crud?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.bulk?.action === "BULK_ACTION_CREATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "BULK_ACTION_CREATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.bulk?.resourceType,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.bulk?.resourceBody,\n entities,\n ),\n },\n });\n } else if (json?.step?.salesforce?.bulk?.action === "BULK_ACTION_UPDATE") {\n return new Salesforce(json?.name, json?.step?.integration, {\n action: {\n action: "BULK_ACTION_UPDATE",\n resourceType: fromBinding(\n json?.step?.salesforce?.bulk?.resourceType,\n entities,\n ),\n resourceBody: fromBinding(\n json?.step?.salesforce?.bulk?.resourceBody,\n entities,\n ),\n },\n });\n }\n }\n}\n\nexport class OpenApi extends RestApi {\n constructor(\n name: string,\n integration: string,\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration, config, openapi);\n }\n\n public static configFromJSON(\n json: any,\n entities: string[],\n ): {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n } {\n return {\n method: json?.httpMethod,\n url: fromBinding(json?.urlPath, entities),\n headers: json?.headers?.map((header: any) => ({\n key: fromBinding(header.key, entities),\n value: fromBinding(header.value, entities),\n })),\n params: json?.params?.map((param: any) => ({\n key: fromBinding(param.key, entities),\n value: fromBinding(param.value, entities),\n })),\n body: fromBinding(json?.body, entities),\n };\n }\n\n public static openapiFromJSON(json: any): {\n path: string;\n } {\n return json?.openApiAction &&\n json.openApiAction !== "" &&\n json.openApiAction !== "genericHttpRequest"\n ? { path: json.openApiAction.split(" ")[1] }\n : undefined;\n }\n}\n\nexport class Jira extends OpenApi {\n constructor(\n name: string,\n integration: string,\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration, config, openapi);\n this.type = "jira";\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Jira(${await this.constructorParametersString(entities)})`;\n }\n\n public static fromJSON(json: any, entities: string[]): Jira {\n return new Jira(\n json?.name,\n json?.step?.integration,\n OpenApi.configFromJSON(json?.step?.jira, entities),\n OpenApi.openapiFromJSON(json?.step?.jira),\n );\n }\n}\n\nfunction createOpenApiIntegrationClass(\n className: string,\n integrationName: string,\n) {\n const cls = class extends OpenApi {\n constructor(\n name: string,\n integration: string,\n config: {\n method: string;\n url: Binding<string>;\n headers?: { key: Binding<string>; value: Binding<string> }[];\n params?: { key: Binding<string>; value: Binding<string> }[];\n body?: Binding<string>;\n },\n openapi?: {\n path: string;\n },\n ) {\n super(name, integration, config, openapi);\n this.type = integrationName;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new ${className}(${await this.constructorParametersString(entities)})`;\n }\n\n public static fromJSON(json: any, entities: string[]) {\n return new this(\n json?.name,\n json?.step?.integration,\n OpenApi.configFromJSON(json?.step?.[integrationName], entities),\n OpenApi.openapiFromJSON(json?.step?.[integrationName]),\n );\n }\n };\n // Set the class name for debugging and testing purposes\n Object.defineProperty(cls, "name", { value: className });\n return cls;\n}\n\n// All of the openapi integrations should go here\nexport const Airtable = createOpenApiIntegrationClass("Airtable", "airtable");\nexport const Anthropic = createOpenApiIntegrationClass(\n "Anthropic",\n "anthropic",\n);\nexport const Asana = createOpenApiIntegrationClass("Asana", "asana");\nexport const Bitbucket = createOpenApiIntegrationClass(\n "Bitbucket",\n "bitbucket",\n);\nexport const Box = createOpenApiIntegrationClass("Box", "box");\nexport const CircleCI = createOpenApiIntegrationClass("CircleCI", "circleci");\nexport const Cohere = createOpenApiIntegrationClass("Cohere", "cohere");\nexport const Confluence = createOpenApiIntegrationClass(\n "Confluence",\n "confluence",\n);\nexport const Datadog = createOpenApiIntegrationClass("Datadog", "datadog");\nexport const Dropbox = createOpenApiIntegrationClass("Dropbox", "dropbox");\nexport const Elasticsearch = createOpenApiIntegrationClass(\n "Elasticsearch",\n "elasticsearch",\n);\nexport const Fireworks = createOpenApiIntegrationClass(\n "Fireworks",\n "fireworks",\n);\nexport const Front = createOpenApiIntegrationClass("Front", "front");\nexport const Gemini = createOpenApiIntegrationClass("Gemini", "gemini");\nexport const GitHub = createOpenApiIntegrationClass("GitHub", "github");\nexport const GoogleAnalytics = createOpenApiIntegrationClass(\n "GoogleAnalytics",\n "googleanalytics",\n);\nexport const GoogleDrive = createOpenApiIntegrationClass(\n "GoogleDrive",\n "googledrive",\n);\nexport const Groq = createOpenApiIntegrationClass("Groq", "groq");\nexport const HubSpot = createOpenApiIntegrationClass("HubSpot", "hubspot");\nexport const Intercom = createOpenApiIntegrationClass("Intercom", "intercom");\nexport const LaunchDarkly = createOpenApiIntegrationClass(\n "LaunchDarkly",\n "launchdarkly",\n);\nexport const Mistral = createOpenApiIntegrationClass("Mistral", "mistral");\nexport const Notion = createOpenApiIntegrationClass("Notion", "notion");\nexport const OpenAI = createOpenApiIntegrationClass("OpenAI", "openai_v2");\nexport const PagerDuty = createOpenApiIntegrationClass(\n "PagerDuty",\n "pagerduty",\n);\nexport const Perplexity = createOpenApiIntegrationClass(\n "Perplexity",\n "perplexity",\n);\nexport const Segment = createOpenApiIntegrationClass("Segment", "segment");\nexport const SendGrid = createOpenApiIntegrationClass("SendGrid", "sendgrid");\nexport const Slack = createOpenApiIntegrationClass("Slack", "slack");\nexport const StabilityAI = createOpenApiIntegrationClass(\n "StabilityAI",\n "stabilityai",\n);\nexport const Stripe = createOpenApiIntegrationClass("Stripe", "stripe");\nexport const Twilio = createOpenApiIntegrationClass("Twilio", "twilio");\nexport const Zendesk = createOpenApiIntegrationClass("Zendesk", "zendesk");\nexport const Zoom = createOpenApiIntegrationClass("Zoom", "zoom");\n\nexport class Email extends Integration {\n private subject: Binding<string>;\n private from: Binding<string>; // comma separated list\n private to: Binding<string>; // comma separated list\n private cc?: Binding<string>; // comma separated list\n private bcc?: Binding<string>; // comma separated list\n private body: Binding<string>;\n\n constructor(\n name: string,\n config: {\n from: Binding<string>;\n to: Binding<string>;\n subject: Binding<string>;\n cc?: Binding<string>;\n bcc?: Binding<string>;\n body?: Binding<string>;\n },\n ) {\n super(name, "email");\n\n this.from = config.from;\n this.to = config.to;\n this.subject = config.subject;\n this.cc = config.cc;\n this.bcc = config.bcc;\n this.body = config.body;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: "email",\n email: {\n ...(this.from ? { emailFrom: await binding(this.from) } : {}),\n ...(this.to ? { emailTo: await binding(this.to) } : {}),\n ...(this.cc ? { emailCc: await binding(this.cc) } : {}),\n ...(this.bcc ? { emailBcc: await binding(this.bcc) } : {}),\n ...(this.subject\n ? { emailSubject: await binding(this.subject) }\n : {}),\n ...(this.body ? { emailBody: await binding(this.body) } : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [];\n\n if (this.from) {\n parts.push(\n `from: ${\n typeof this.from === "function"\n ? signatureV2((await toJSBody(this.from)).body, entities)\n : `"${this.from}"`\n }`,\n );\n }\n\n if (this.to) {\n parts.push(\n `to: ${\n typeof this.to === "function"\n ? signatureV2((await toJSBody(this.to)).body, entities)\n : `"${this.to}"`\n }`,\n );\n }\n\n if (this.cc) {\n parts.push(\n `cc: ${\n typeof this.cc === "function"\n ? signatureV2((await toJSBody(this.cc)).body, entities)\n : `"${this.cc}"`\n }`,\n );\n }\n\n if (this.bcc) {\n parts.push(\n `bcc: ${\n typeof this.bcc === "function"\n ? signatureV2((await toJSBody(this.bcc)).body, entities)\n : `"${this.bcc}"`\n }`,\n );\n }\n\n if (this.subject) {\n parts.push(\n `subject: ${\n typeof this.subject === "function"\n ? signatureV2((await toJSBody(this.subject)).body, entities)\n : `"${this.subject}"`\n }`,\n );\n }\n\n if (this.body) {\n parts.push(\n `body: ${\n typeof this.body === "function"\n ? signatureV2((await toJSBody(this.body)).body, entities)\n : `"${this.body}"`\n }`,\n );\n }\n\n return `new Email("${this.name}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Email {\n return new Email(json?.name, {\n from: fromBinding(json?.step?.email?.emailFrom, entities),\n to: fromBinding(json?.step?.email?.emailTo, entities),\n subject: fromBinding(json?.step?.email?.emailSubject, entities),\n body: fromBinding(json?.step?.email?.emailBody, entities),\n cc: json?.step?.email?.emailCc\n ? fromBinding(json?.step?.email?.emailCc, entities)\n : undefined,\n bcc: json?.step?.email?.emailBcc\n ? fromBinding(json?.step?.email?.emailBcc, entities)\n : undefined,\n });\n }\n}\n\nexport interface DatabricksConfig {\n statement: Binding<string>;\n parameters?: Binding<string>;\n}\n\nexport class Databricks extends Integration {\n private statement: Binding<string>;\n private parameters?: Binding<string>;\n\n constructor(name: string, integration: string, config: DatabricksConfig) {\n super(name, integration);\n\n this.statement = config.statement;\n this.parameters = config.parameters;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const result: JsonValue = {\n name: this.name,\n step: {\n integration: this.integration,\n databricks: {\n operation: "SQL_OPERATION_RUN_SQL",\n runSql: {\n sqlBody: await bindingSql(this.statement),\n },\n },\n },\n };\n\n if (this.parameters !== undefined) {\n const bound = await binding(this.parameters);\n result.step.databricks.runSql.parameters = bound.replace(/^`|`$/g, "");\n }\n\n return result;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const statementStr =\n typeof this.statement === "function"\n ? signatureV2(\n (await toJSBody(this.statement, { condense: false })).body,\n entities,\n )\n : `\\`${this.statement}\\``;\n\n const parts = [`statement: ${statementStr}`];\n if (this.parameters) {\n const parametersStr =\n typeof this.parameters === "function"\n ? (await toJSBody(this.parameters)).body\n : typeof this.parameters === "string"\n ? this.parameters\n : "";\n parts.push(`parameters: "${parametersStr.replace(/^`|`$/g, "")}"`);\n }\n\n return `new Databricks("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Databricks {\n const databricksConfig = json?.step?.databricks;\n const databricks = databricksConfig?.runSql;\n\n return new Databricks(json?.name, json?.step?.integration, {\n statement: fromBinding(databricks?.sqlBody as string, entities),\n parameters:\n databricks?.parameters !== undefined\n ? fromBinding(databricks.parameters, entities)\n : undefined,\n });\n }\n}\n\ntype MongoDBOperation =\n | "aggregate"\n | "count"\n | "deleteOne"\n | "deleteMany"\n | "distinct"\n | "find"\n | "findOne"\n | "insertOne"\n | "insertMany"\n | "listCollections"\n | "replaceOne"\n | "updateOne"\n | "updateMany";\n\nexport class MongoDB extends Integration {\n private operation: MongoDBOperation;\n private collection?: Binding<string>;\n private query?: Binding<any>;\n private filter?: Binding<any>;\n private update?: Binding<any>;\n private replacement?: Binding<any>;\n private document?: Binding<any>;\n private pipeline?: Binding<any[]>;\n private field?: Binding<string>;\n private projection?: Binding<any>;\n private sortby?: Binding<any>;\n private limit?: Binding<number>;\n private skip?: Binding<number>;\n private options?: Binding<any>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n operation: MongoDBOperation;\n collection?: Binding<string>;\n query?: Binding<any>;\n filter?: Binding<any>;\n update?: Binding<any>;\n replacement?: Binding<any>;\n document?: Binding<any>;\n pipeline?: Binding<any[]>;\n field?: Binding<string>;\n projection?: Binding<any>;\n sortby?: Binding<any>;\n limit?: Binding<number>;\n skip?: Binding<number>;\n options?: Binding<any>;\n },\n ) {\n super(name, integration);\n this.operation = config.operation;\n this.collection = config.collection;\n this.query = config.query;\n this.filter = config.filter;\n this.update = config.update;\n this.replacement = config.replacement;\n this.document = config.document;\n this.pipeline = config.pipeline;\n this.field = config.field;\n this.projection = config.projection;\n this.sortby = config.sortby;\n this.limit = config.limit;\n this.skip = config.skip;\n this.options = config.options;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n mongodb: {\n action: this.operation,\n ...(this.collection\n ? { resource: await binding(this.collection) }\n : {}),\n ...(this.query ? { query: await binding(this.query) } : {}),\n ...(this.filter ? { filter: await binding(this.filter) } : {}),\n ...(this.update ? { update: await binding(this.update) } : {}),\n ...(this.replacement\n ? { replacement: await binding(this.replacement) }\n : {}),\n ...(this.document ? { document: await binding(this.document) } : {}),\n ...(this.pipeline ? { pipeline: await binding(this.pipeline) } : {}),\n ...(this.field ? { field: await binding(this.field) } : {}),\n ...(this.projection\n ? { projection: await binding(this.projection) }\n : {}),\n ...(this.sortby ? { sortby: await binding(this.sortby) } : {}),\n ...(this.limit ? { limit: await binding(this.limit) } : {}),\n ...(this.skip ? { skip: await binding(this.skip) } : {}),\n ...(this.options ? { options: await binding(this.options) } : {}),\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const parts: string[] = [`operation: "${this.operation}"`];\n\n if (this.collection) {\n parts.push(\n `collection: ${\n typeof this.collection === "function"\n ? signatureV2((await toJSBody(this.collection)).body, entities)\n : `"${this.collection}"`\n }`,\n );\n }\n\n if (this.query) {\n parts.push(\n `query: ${\n typeof this.query === "function"\n ? signatureV2((await toJSBody(this.query)).body, entities)\n : JSON.stringify(this.query)\n }`,\n );\n }\n\n if (this.filter) {\n parts.push(\n `filter: ${\n typeof this.filter === "function"\n ? signatureV2((await toJSBody(this.filter)).body, entities)\n : JSON.stringify(this.filter)\n }`,\n );\n }\n\n if (this.update) {\n parts.push(\n `update: ${\n typeof this.update === "function"\n ? signatureV2((await toJSBody(this.update)).body, entities)\n : JSON.stringify(this.update)\n }`,\n );\n }\n\n if (this.replacement) {\n parts.push(\n `replacement: ${\n typeof this.replacement === "function"\n ? signatureV2((await toJSBody(this.replacement)).body, entities)\n : JSON.stringify(this.replacement)\n }`,\n );\n }\n\n if (this.document) {\n parts.push(\n `document: ${\n typeof this.document === "function"\n ? signatureV2((await toJSBody(this.document)).body, entities)\n : JSON.stringify(this.document)\n }`,\n );\n }\n\n if (this.pipeline) {\n parts.push(\n `pipeline: ${\n typeof this.pipeline === "function"\n ? signatureV2((await toJSBody(this.pipeline)).body, entities)\n : JSON.stringify(this.pipeline)\n }`,\n );\n }\n\n if (this.field) {\n parts.push(\n `field: ${\n typeof this.field === "function"\n ? signatureV2((await toJSBody(this.field)).body, entities)\n : `"${this.field}"`\n }`,\n );\n }\n\n if (this.projection) {\n parts.push(\n `projection: ${\n typeof this.projection === "function"\n ? signatureV2((await toJSBody(this.projection)).body, entities)\n : JSON.stringify(this.projection)\n }`,\n );\n }\n\n if (this.sortby) {\n parts.push(\n `sortby: ${\n typeof this.sortby === "function"\n ? signatureV2((await toJSBody(this.sortby)).body, entities)\n : JSON.stringify(this.sortby)\n }`,\n );\n }\n\n if (this.limit !== undefined) {\n parts.push(\n `limit: ${\n typeof this.limit === "function"\n ? signatureV2((await toJSBody(this.limit)).body, entities)\n : this.limit\n }`,\n );\n }\n\n if (this.skip !== undefined) {\n parts.push(\n `skip: ${\n typeof this.skip === "function"\n ? signatureV2((await toJSBody(this.skip)).body, entities)\n : this.skip\n }`,\n );\n }\n\n if (this.options) {\n parts.push(\n `options: ${\n typeof this.options === "function"\n ? signatureV2((await toJSBody(this.options)).body, entities)\n : JSON.stringify(this.options)\n }`,\n );\n }\n\n return `new MongoDB("${this.name}", "${this.integration}", { ${parts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): MongoDB {\n return new MongoDB(json?.name, json?.step?.integration, {\n operation: json?.step?.mongodb?.action,\n collection: json?.step?.mongodb?.resource\n ? fromBinding(json?.step?.mongodb?.resource, entities)\n : undefined,\n query: json?.step?.mongodb?.query\n ? fromBinding(json?.step?.mongodb?.query, entities)\n : undefined,\n filter: json?.step?.mongodb?.filter\n ? fromBinding(json?.step?.mongodb?.filter, entities)\n : undefined,\n update: json?.step?.mongodb?.update\n ? fromBinding(json?.step?.mongodb?.update, entities)\n : undefined,\n replacement: json?.step?.mongodb?.replacement\n ? fromBinding(json?.step?.mongodb?.replacement, entities)\n : undefined,\n document: json?.step?.mongodb?.document\n ? fromBinding(json?.step?.mongodb?.document, entities)\n : undefined,\n pipeline: json?.step?.mongodb?.pipeline\n ? (fromBinding(\n json?.step?.mongodb?.pipeline,\n entities,\n ) as unknown as Binding<any[]>)\n : undefined,\n field: json?.step?.mongodb?.field\n ? fromBinding(json?.step?.mongodb?.field, entities)\n : undefined,\n projection: json?.step?.mongodb?.projection\n ? fromBinding(json?.step?.mongodb?.projection, entities)\n : undefined,\n sortby: json?.step?.mongodb?.sortby\n ? fromBinding(json?.step?.mongodb?.sortby, entities)\n : undefined,\n limit: json?.step?.mongodb?.limit\n ? (fromBinding(\n json?.step?.mongodb?.limit,\n entities,\n ) as unknown as Binding<number>)\n : undefined,\n skip: json?.step?.mongodb?.skip\n ? (fromBinding(\n json?.step?.mongodb?.skip,\n entities,\n ) as unknown as Binding<number>)\n : undefined,\n options: json?.step?.mongodb?.options\n ? fromBinding(json?.step?.mongodb?.options, entities)\n : undefined,\n });\n }\n}\n\ntype CouchbaseAction = "runSql" | "insert" | "get" | "remove";\n\nexport class Couchbase extends Integration {\n private action: CouchbaseAction;\n private bucket?: Binding<string>;\n private scope?: Binding<string>;\n private collection?: Binding<string>;\n private sqlBody?: Binding<string>;\n private key?: Binding<string>;\n private document?: Binding<any>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n action: CouchbaseAction;\n bucket?: Binding<string>;\n scope?: Binding<string>;\n collection?: Binding<string>;\n sqlBody?: Binding<string>;\n key?: Binding<string>;\n document?: Binding<any>;\n },\n ) {\n super(name, integration);\n this.action = config.action;\n this.bucket = config.bucket;\n this.scope = config.scope;\n this.collection = config.collection;\n this.sqlBody = config.sqlBody;\n this.key = config.key;\n this.document = config.document;\n }\n\n public async toJSON(): Promise<JsonValue> {\n const actionValue: Record<string, JsonValue> = {};\n\n if (this.action === "runSql" && this.sqlBody !== undefined) {\n actionValue.sqlBody = await bindingSql(this.sqlBody);\n } else {\n if (this.scope !== undefined || this.collection !== undefined) {\n actionValue.identifier = {\n scope: this.scope ? await binding(this.scope) : undefined,\n collection: this.collection\n ? await binding(this.collection)\n : undefined,\n };\n }\n if (this.key !== undefined) {\n actionValue.key = await binding(this.key);\n }\n if (this.action === "insert" && this.document !== undefined) {\n actionValue.value = await binding(this.document);\n }\n }\n\n return {\n name: this.name,\n step: {\n integration: this.integration,\n couchbase: {\n bucketName: this.bucket ? await binding(this.bucket) : undefined,\n couchbaseAction: {\n case: this.action,\n value: actionValue,\n },\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const configParts: string[] = [];\n configParts.push(`action: "${this.action}"`);\n\n if (this.bucket !== undefined) {\n configParts.push(\n `bucket: ${typeof this.bucket === "function" ? signatureV2((await toJSBody(this.bucket, { condense: false })).body, entities) : `"${this.bucket}"`}`,\n );\n }\n if (this.scope !== undefined) {\n configParts.push(\n `scope: ${typeof this.scope === "function" ? signatureV2((await toJSBody(this.scope, { condense: false })).body, entities) : `"${this.scope}"`}`,\n );\n }\n if (this.collection !== undefined) {\n configParts.push(\n `collection: ${typeof this.collection === "function" ? signatureV2((await toJSBody(this.collection, { condense: false })).body, entities) : `"${this.collection}"`}`,\n );\n }\n if (this.sqlBody !== undefined) {\n configParts.push(\n `sqlBody: ${typeof this.sqlBody === "function" ? signatureV2((await toJSBody(this.sqlBody, { condense: false })).body, entities) : `"${this.sqlBody}"`}`,\n );\n }\n if (this.key !== undefined) {\n configParts.push(\n `key: ${typeof this.key === "function" ? signatureV2((await toJSBody(this.key, { condense: false })).body, entities) : `"${this.key}"`}`,\n );\n }\n if (this.document !== undefined) {\n configParts.push(\n `document: ${typeof this.document === "function" ? signatureV2((await toJSBody(this.document, { condense: false })).body, entities) : JSON.stringify(this.document)}`,\n );\n }\n\n return `new Couchbase("${this.name}", "${this.integration}", { ${configParts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Couchbase {\n const couchbase = json?.step?.couchbase;\n const action = couchbase?.couchbaseAction?.case as CouchbaseAction;\n const actionValue = couchbase?.couchbaseAction?.value;\n\n return new Couchbase(json?.name, json?.step?.integration, {\n action,\n bucket: couchbase?.bucketName\n ? fromBinding(couchbase?.bucketName, entities)\n : undefined,\n scope: actionValue?.identifier?.scope\n ? fromBinding(actionValue?.identifier?.scope, entities)\n : undefined,\n collection: actionValue?.identifier?.collection\n ? fromBinding(actionValue?.identifier?.collection, entities)\n : undefined,\n sqlBody: actionValue?.sqlBody\n ? fromBinding(actionValue?.sqlBody, entities)\n : undefined,\n key: actionValue?.key\n ? fromBinding(actionValue?.key, entities)\n : undefined,\n document: actionValue?.value\n ? fromBinding(actionValue?.value, entities)\n : undefined,\n });\n }\n}\n\ntype CosmosDBActionType = "sql" | "pointOperation";\ntype CosmosDBPointAction = "create" | "read" | "upsert" | "replace" | "delete";\n\nexport class CosmosDB extends Integration {\n private actionType: CosmosDBActionType;\n private containerId?: Binding<string>;\n private query?: Binding<string>;\n private crossPartition?: boolean;\n private partitionKey?: Binding<string>;\n private pointAction?: CosmosDBPointAction;\n private itemId?: Binding<string>;\n private body?: Binding<any>;\n\n constructor(\n name: string,\n integration: string,\n config: {\n actionType: CosmosDBActionType;\n containerId?: Binding<string>;\n query?: Binding<string>;\n crossPartition?: boolean;\n partitionKey?: Binding<string>;\n pointAction?: CosmosDBPointAction;\n itemId?: Binding<string>;\n body?: Binding<any>;\n },\n ) {\n super(name, integration);\n this.actionType = config.actionType;\n this.containerId = config.containerId;\n this.query = config.query;\n this.crossPartition = config.crossPartition;\n this.partitionKey = config.partitionKey;\n this.pointAction = config.pointAction;\n this.itemId = config.itemId;\n this.body = config.body;\n }\n\n public async toJSON(): Promise<JsonValue> {\n if (this.actionType === "sql") {\n return {\n name: this.name,\n step: {\n integration: this.integration,\n cosmosdb: {\n cosmosdbAction: {\n case: "sql",\n value: {\n action: {\n case: "singleton",\n value: {\n containerId: this.containerId\n ? await binding(this.containerId)\n : undefined,\n query: this.query\n ? await bindingSql(this.query)\n : undefined,\n crossPartition: this.crossPartition ?? true,\n partitionKey: this.partitionKey\n ? await binding(this.partitionKey)\n : undefined,\n },\n },\n },\n },\n },\n },\n };\n }\n\n // Point operation\n return {\n name: this.name,\n step: {\n integration: this.integration,\n cosmosdb: {\n cosmosdbAction: {\n case: "pointOperation",\n value: {\n containerId: this.containerId\n ? await binding(this.containerId)\n : undefined,\n action: {\n case: this.pointAction,\n value: {\n id: this.itemId ? await binding(this.itemId) : undefined,\n partitionKey: this.partitionKey\n ? await binding(this.partitionKey)\n : undefined,\n body: this.body ? await binding(this.body) : undefined,\n },\n },\n },\n },\n },\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const configParts: string[] = [];\n configParts.push(`actionType: "${this.actionType}"`);\n\n if (this.containerId !== undefined) {\n configParts.push(\n `containerId: ${typeof this.containerId === "function" ? signatureV2((await toJSBody(this.containerId, { condense: false })).body, entities) : `"${this.containerId}"`}`,\n );\n }\n if (this.query !== undefined) {\n configParts.push(\n `query: ${typeof this.query === "function" ? signatureV2((await toJSBody(this.query, { condense: false })).body, entities) : `"${this.query}"`}`,\n );\n }\n if (this.crossPartition !== undefined) {\n configParts.push(`crossPartition: ${this.crossPartition}`);\n }\n if (this.partitionKey !== undefined) {\n configParts.push(\n `partitionKey: ${typeof this.partitionKey === "function" ? signatureV2((await toJSBody(this.partitionKey, { condense: false })).body, entities) : `"${this.partitionKey}"`}`,\n );\n }\n if (this.pointAction !== undefined) {\n configParts.push(`pointAction: "${this.pointAction}"`);\n }\n if (this.itemId !== undefined) {\n configParts.push(\n `itemId: ${typeof this.itemId === "function" ? signatureV2((await toJSBody(this.itemId, { condense: false })).body, entities) : `"${this.itemId}"`}`,\n );\n }\n if (this.body !== undefined) {\n configParts.push(\n `body: ${typeof this.body === "function" ? signatureV2((await toJSBody(this.body, { condense: false })).body, entities) : JSON.stringify(this.body)}`,\n );\n }\n\n return `new CosmosDB("${this.name}", "${this.integration}", { ${configParts.join(", ")} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): CosmosDB {\n const cosmosdb = json?.step?.cosmosdb;\n const actionType = cosmosdb?.cosmosdbAction?.case as CosmosDBActionType;\n const actionValue = cosmosdb?.cosmosdbAction?.value;\n\n if (actionType === "sql") {\n const sqlAction = actionValue?.action?.value;\n return new CosmosDB(json?.name, json?.step?.integration, {\n actionType,\n containerId: sqlAction?.containerId\n ? fromBinding(sqlAction?.containerId, entities)\n : undefined,\n query: sqlAction?.query\n ? fromBinding(sqlAction?.query, entities)\n : undefined,\n crossPartition: sqlAction?.crossPartition,\n partitionKey: sqlAction?.partitionKey\n ? fromBinding(sqlAction?.partitionKey, entities)\n : undefined,\n });\n }\n\n // Point operation\n const pointAction = actionValue?.action?.case as CosmosDBPointAction;\n const pointValue = actionValue?.action?.value;\n return new CosmosDB(json?.name, json?.step?.integration, {\n actionType,\n containerId: actionValue?.containerId\n ? fromBinding(actionValue?.containerId, entities)\n : undefined,\n pointAction,\n itemId: pointValue?.id\n ? fromBinding(pointValue?.id, entities)\n : undefined,\n partitionKey: pointValue?.partitionKey\n ? fromBinding(pointValue?.partitionKey, entities)\n : undefined,\n body: pointValue?.body\n ? fromBinding(pointValue?.body, entities)\n : undefined,\n });\n }\n}\n\nexport type Condition = {\n when: Binding<boolean>;\n then: Block[];\n};\n\nasync function conditionToSDK(\n condition: Condition,\n entities: string[],\n): Promise<string> {\n return `{ when: ${typeof condition.when === "function" ? signatureV2((await toJSBody(condition.when)).body, entities) : condition.when}, then: [${(await Promise.all(condition.then.map(async (block) => await block.toSDK(entities)))).join(",")}] }`;\n}\n\nexport type Conditions = {\n if: Condition;\n elif?: Condition[];\n else?: Block[];\n};\n\nexport class Conditional extends Block {\n public conditions: Conditions;\n\n constructor(name: string, config: Conditions) {\n super(name);\n\n this.conditions = config;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n conditional: {\n if: {\n condition: ensureIIFE(\n (await toJS<boolean>(this.conditions.if.when)).body,\n ),\n blocks: await Promise.all(\n this.conditions.if.then.map(async (block) => await block.toJSON()),\n ),\n },\n ...(await (async () =>\n this.conditions.elif\n ? {\n elseIf: await Promise.all(\n this.conditions.elif.map(async (condition) => ({\n condition: ensureIIFE(\n (await toJS<boolean>(condition.when)).body,\n ),\n blocks: await Promise.all(\n condition.then.map(async (block) => await block.toJSON()),\n ),\n })),\n ),\n }\n : { elseIf: [] })()),\n else: this.conditions.else\n ? {\n blocks: await Promise.all(\n this.conditions.else.map(async (block) => await block.toJSON()),\n ),\n }\n : undefined,\n },\n };\n }\n\n public static fromJSON(json: any, entities: string[]): Conditional {\n return new Conditional(json?.name, {\n if: {\n when: fromJS<boolean>(json?.conditional?.if?.condition, entities),\n then: json?.conditional?.if?.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n },\n elif: json?.conditional?.elseIf\n ? json?.conditional?.elseIf?.map((condition: any) => ({\n when: fromJS<boolean>(condition.condition, entities),\n then: condition.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n }))\n : [],\n else: json?.conditional?.else\n ? json?.conditional?.else?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n )\n : [],\n });\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const elseBlocks = this.conditions.else\n ? await Promise.all(\n this.conditions.else.map(\n async (block) => await block.toSDK(entities),\n ),\n )\n : [];\n return `new Conditional("${this.name}", { if: ${await conditionToSDK(this.conditions.if, entities)}, elif: [${this.conditions.elif ? (await Promise.all(this.conditions.elif?.map(async (condition) => await conditionToSDK(condition, entities)))).join(",") : ""}], else: [${elseBlocks.join(",")}] })`;\n }\n}\n\ntype ParallelMode = "dynamic" | "static";\n\ntype DynamicParallelConfig = {\n mode: "dynamic";\n over: Binding<JsonValue[]>;\n variables?: { item: string }; // Optional - defaults to { item: "item" }\n blocks: Block[];\n};\n\ntype StaticParallelConfig = {\n mode: "static";\n paths: Record<string, Block[]>;\n};\n\ntype ParallelConfig = DynamicParallelConfig | StaticParallelConfig;\n\nexport class Parallel extends Block {\n private config: ParallelConfig;\n\n constructor(name: string, config: ParallelConfig) {\n super(name);\n this.config = config;\n }\n\n public async toJSON(): Promise<JsonValue> {\n if (this.config.mode === "static") {\n const paths: Record<string, { blocks: JsonValue[] }> = {};\n for (const [pathName, blocks] of Object.entries(this.config.paths)) {\n paths[pathName] = {\n blocks: await Promise.all(\n blocks.map(async (block) => await block.toJSON()),\n ),\n };\n }\n return {\n name: this.name,\n parallel: {\n static: { paths },\n wait: "WAIT_ALL",\n },\n };\n }\n\n // Dynamic mode\n const variables = this.config.variables ?? { item: "item" };\n return {\n name: this.name,\n parallel: {\n dynamic: {\n blocks: await Promise.all(\n this.config.blocks?.map(async (block) => await block.toJSON()),\n ),\n paths: ensureIIFE((await toJS<JsonValue[]>(this.config.over)).body),\n variables,\n },\n wait: "WAIT_ALL",\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n if (this.config.mode === "static") {\n const pathsEntries = await Promise.all(\n Object.entries(this.config.paths).map(async ([pathName, blocks]) => {\n const blocksSdk = await Promise.all(\n blocks.map(async (block) => await block.toSDK(entities)),\n );\n return `"${pathName}": [${blocksSdk.join(", ")}]`;\n }),\n );\n return `new Parallel("${this.name}", { mode: "static", paths: { ${pathsEntries.join(", ")} } })`;\n }\n\n // Dynamic mode\n const blocks = await Promise.all(\n this.config.blocks.map(async (block) => await block.toSDK(entities)),\n );\n const itemName = this.config.variables?.item ?? "item";\n const variablesStr =\n itemName !== "item" ? `, variables: { item: "${itemName}" }` : "";\n return `new Parallel("${this.name}", { mode: "dynamic", over: ${typeof this.config.over === "function" ? signatureV2((await toJSBody(this.config.over)).body, entities) : this.config.over}${variablesStr}, blocks: [${blocks.join(", ")}] })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Parallel {\n // Check if it\'s a static parallel\n if (json?.parallel?.static?.paths) {\n const paths: Record<string, Block[]> = {};\n for (const [pathName, pathConfig] of Object.entries(\n json.parallel.static.paths as Record<string, { blocks: any[] }>,\n )) {\n paths[pathName] = pathConfig.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n );\n }\n return new Parallel(json?.name, {\n mode: "static",\n paths,\n });\n }\n\n // Dynamic mode\n return new Parallel(json?.name, {\n mode: "dynamic",\n over: fromJS<JsonValue[]>(\n json?.parallel?.dynamic?.paths ?? "\'\'",\n entities,\n ),\n variables: {\n item: json?.parallel?.dynamic?.variables?.item ?? "",\n },\n blocks:\n json?.parallel?.dynamic?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n ) ?? [],\n });\n }\n}\n\ntype LoopType = "TYPE_FOREACH" | "TYPE_WHILE";\n\ntype ForEachLoopConfig = {\n type?: "TYPE_FOREACH"; // Optional - defaults to TYPE_FOREACH\n over: Binding<JsonValue[]>;\n variables: { item: string; index: string };\n blocks: Block[];\n};\n\ntype WhileLoopConfig = {\n type: "TYPE_WHILE"; // Required for TYPE_WHILE\n condition: Binding<boolean>;\n variables?: { index: string }; // Optional - defaults to { index: \'index\' }\n blocks: Block[];\n};\n\ntype LoopConfig = ForEachLoopConfig | WhileLoopConfig;\n\nexport class Loop extends Block {\n private config: LoopConfig;\n\n constructor(name: string, config: LoopConfig) {\n super(name);\n this.config = config;\n }\n\n public async toJSON(): Promise<JsonValue> {\n if (this.config.type === "TYPE_WHILE") {\n // TYPE_WHILE loops have both item and index variables (matching UI defaults)\n const indexName = this.config.variables?.index ?? "index";\n return {\n name: this.name,\n loop: {\n range: ensureIIFE((await toJS<boolean>(this.config.condition)).body),\n type: "TYPE_WHILE",\n variables: { index: indexName, item: "item" },\n blocks: await Promise.all(\n this.config.blocks.map(async (block) => await block.toJSON()),\n ),\n },\n };\n }\n\n // TYPE_FOREACH\n return {\n name: this.name,\n loop: {\n range: ensureIIFE((await toJS<JsonValue[]>(this.config.over)).body),\n type: "TYPE_FOREACH",\n variables: this.config.variables,\n blocks: await Promise.all(\n this.config.blocks.map(async (block) => await block.toJSON()),\n ),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const blocks = await Promise.all(\n this.config.blocks.map(async (block) => await block.toSDK(entities)),\n );\n\n if (this.config.type === "TYPE_WHILE") {\n const condition =\n typeof this.config.condition === "function"\n ? signatureV2((await toJSBody(this.config.condition)).body, entities)\n : this.config.condition;\n const indexName = this.config.variables?.index ?? "index";\n // Only include variables if a custom index name is specified\n const variablesStr =\n indexName !== "index"\n ? `, variables: { index: "${indexName}" }`\n : "";\n return `new Loop("${this.name}", { type: "TYPE_WHILE", condition: ${condition}${variablesStr}, blocks: [${blocks.join(", ")}] })`;\n }\n\n // TYPE_FOREACH\n const variables = JSON.stringify(this.config.variables);\n const over =\n typeof this.config.over === "function"\n ? signatureV2((await toJSBody(this.config.over)).body, entities)\n : this.config.over;\n return `new Loop("${this.name}", { type: "TYPE_FOREACH", over: ${over}, variables: ${variables}, blocks: [${blocks.join(", ")}] })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Loop {\n const loopType = json?.loop?.type as LoopType | undefined;\n\n if (loopType === "TYPE_WHILE") {\n // Extract index variable name from JSON, default to \'index\'\n const indexName = json?.loop?.variables?.index || "index";\n return new Loop(json?.name, {\n type: "TYPE_WHILE",\n condition: fromJS<boolean>(json?.loop?.range, entities),\n variables: { index: indexName },\n blocks:\n json?.loop?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n ) ?? [],\n });\n }\n\n // Default to TYPE_FOREACH\n return new Loop(json?.name, {\n type: "TYPE_FOREACH",\n over: fromJS<JsonValue[]>(json?.loop?.range, entities),\n variables: {\n item: json?.loop?.variables?.item,\n index: json?.loop?.variables?.index,\n },\n blocks: json?.loop?.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n });\n }\n}\n\nexport class Variables extends Block {\n private variables: { key: string; value: Binding<JsonValue> }[];\n\n constructor(\n name: string,\n variables: { key: string; value: Binding<JsonValue> }[],\n ) {\n super(name);\n\n this.variables = variables;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n variables: {\n items: await Promise.all(\n this.variables.map(async (variable) => {\n return {\n key: variable.key,\n value: ensureIIFE((await toJS<JsonValue[]>(variable.value)).body),\n type: "TYPE_SIMPLE",\n mode: "MODE_READWRITE",\n };\n }),\n ),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Variables("${this.name}", [${(\n await Promise.all(\n this.variables?.map(\n async (variable) =>\n `{ key: "${variable.key}", value: ${typeof variable.value === "function" ? signatureV2((await toJSBody(variable.value)).body, entities) : variable.value} }`,\n ),\n )\n ).join(",")}])`;\n }\n\n public static fromJSON(json: any, entities: string[]): Variables {\n return new Variables(\n json?.name,\n json?.variables?.items?.map((variable: any) => ({\n key: variable.key,\n value: fromBinding(variable.value, entities),\n })),\n );\n }\n}\n\nexport class TryCatch extends Block {\n private try: Block[];\n private catch: Block[];\n private finally?: Block[];\n private variables: { error: string };\n\n constructor(\n name: string,\n config: {\n try: Block[];\n catch: Block[];\n finally?: Block[];\n variables: { error: string };\n },\n ) {\n super(name);\n\n this.try = config.try;\n this.catch = config.catch;\n this.finally = config.finally;\n this.variables = config.variables;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n tryCatch: {\n try: {\n blocks: await Promise.all(\n this.try.map(async (block) => await block.toJSON()),\n ),\n },\n catch: {\n blocks: await Promise.all(\n this.catch.map(async (block) => await block.toJSON()),\n ),\n },\n finally: {\n blocks: this.finally\n ? await Promise.all(\n this.finally.map(async (block) => await block.toJSON()),\n )\n : undefined,\n },\n variables: this.variables,\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const tryBlocks = await Promise.all(\n this.try.map(async (block) => await block.toSDK(entities)),\n );\n const catchBlocks = await Promise.all(\n this.catch.map(async (block) => await block.toSDK(entities)),\n );\n const finallyBlocks = this.finally\n ? await Promise.all(\n this.finally.map(async (block) => await block.toSDK(entities)),\n )\n : undefined;\n return `new TryCatch("${this.name}", { try: [${tryBlocks.join(",")}], catch: [${catchBlocks.join(",")}], finally: [${finallyBlocks ? finallyBlocks.join(", ") : ""}], variables: { error: "${this.variables.error}" } })`;\n }\n\n public static fromJSON(json: any, entities: string[]): TryCatch {\n return new TryCatch(json?.name, {\n try: json?.tryCatch?.try.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n catch: json?.tryCatch?.catch.blocks.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n finally: json?.tryCatch?.finally?.blocks?.map((block: any) =>\n Block.fromJSON(block, entities),\n ),\n variables: {\n error: json?.tryCatch?.variables?.error,\n },\n });\n }\n}\n\nexport class Throw extends Block {\n private error: Binding<JsonValue>;\n\n constructor(\n name: string,\n config: {\n error: Binding<JsonValue>;\n },\n ) {\n super(name);\n\n this.error = config.error;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n throw: {\n error: (await toJS<JsonValue>(this.error)).body,\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Throw("${this.name}", { error: ${typeof this.error === "function" ? signatureV2((await toJSBody(this.error)).body, entities) : ensureIIFE(JSON.stringify(this.error))} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Throw {\n return new Throw(json?.name, {\n error: fromJS(json?.throw?.error, entities),\n });\n }\n}\n\nexport class Return extends Block {\n private data: Binding<JsonValue>;\n\n constructor(\n name: string,\n config: {\n data: Binding<JsonValue>;\n },\n ) {\n super(name);\n\n this.data = config.data;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n return: {\n data: ensureIIFE((await toJS<JsonValue>(this.data)).body),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n const dataFn =\n typeof this.data === "function"\n ? signatureV2((await toJSBody(this.data)).body, entities)\n : ensureIIFE(JSON.stringify(this.data));\n return `new Return("${this.name}", { data: ${dataFn} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Return {\n return new Return(json?.name, {\n data: fromJS(json?.return?.data, entities),\n });\n }\n}\n\nexport class Break extends Block {\n private condition: Binding<JsonValue>;\n\n constructor(\n name: string,\n config: {\n condition: Binding<JsonValue>;\n },\n ) {\n super(name);\n\n this.condition = config.condition;\n }\n\n public async toJSON(): Promise<JsonValue> {\n return {\n name: this.name,\n break: {\n condition: ensureIIFE((await toJS<JsonValue[]>(this.condition)).body),\n },\n };\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `new Break("${this.name}", { condition: ${typeof this.condition === "function" ? signatureV2((await toJSBody(this.condition)).body, entities) : ensureIIFE(JSON.stringify(this.condition))} })`;\n }\n\n public static fromJSON(json: any, entities: string[]): Break {\n return new Break(json?.name, {\n condition: fromJS(json?.break?.condition, entities),\n });\n }\n}\n\nexport type Authorization =\n | {\n type: "AUTHORIZATION_TYPE_APP_USERS";\n }\n | {\n type: "AUTHORIZATION_TYPE_JS_EXPRESSION";\n expression: Binding<boolean>;\n };\n\nexport class Api {\n private blocks: Block[];\n private name: string;\n private authorization?: Authorization;\n\n constructor(\n name: string,\n blocks: Block[] = [],\n authorization: Authorization = { type: "AUTHORIZATION_TYPE_APP_USERS" },\n ) {\n this.name = name;\n this.blocks = blocks;\n this.authorization = authorization;\n }\n\n public async toSDK(entities: string[]): Promise<string> {\n return `${getSdkImports()}\\n\\nexport default new Api("${this.name}", [${(await Promise.all(this.blocks.map(async (block) => await block.toSDK(entities)))).join(",")}], ${this.authorization.type === "AUTHORIZATION_TYPE_JS_EXPRESSION" ? `{ type: "AUTHORIZATION_TYPE_JS_EXPRESSION", expression: ${typeof this.authorization.expression === "function" ? signatureV2((await toJSBody(this.authorization.expression)).body, entities) : this.authorization.expression} }` : `{ type: "AUTHORIZATION_TYPE_APP_USERS" }`})`;\n }\n\n public static fromJSON(json: any, entities: string[]): Api {\n // NOTE(Frank): Would probs unmarshal this into the protobuf types and then do the conversion.\n return new Api(\n json?.metadata?.name as string,\n (json.blocks as any[]).map((block) => Block.fromJSON(block, entities)),\n {\n type: json.authorization.type,\n expression:\n json.authorization.type === "AUTHORIZATION_TYPE_JS_EXPRESSION"\n ? fromJS(json.authorization.expression, entities)\n : undefined,\n },\n );\n }\n\n public async toJSON(): Promise<JsonValue> {\n const api: {\n metadata: {\n name: string;\n timestamps: {\n updated: string;\n };\n };\n authorization: {\n type:\n | "AUTHORIZATION_TYPE_APP_USERS"\n | "AUTHORIZATION_TYPE_JS_EXPRESSION";\n expression?: string;\n };\n trigger: {\n application: {};\n };\n blocks: JsonValue[];\n } = {\n metadata: {\n name: this.name,\n timestamps: {\n updated: new Date().toISOString(),\n },\n },\n authorization: {\n type: this.authorization.type,\n ...{\n expression:\n this.authorization.type === "AUTHORIZATION_TYPE_JS_EXPRESSION"\n ? `(() => ${(await toJS<boolean>(this.authorization.expression)).body})()`\n : undefined,\n },\n },\n trigger: {\n application: {},\n },\n blocks: [],\n };\n\n api.blocks = await Promise.all(\n this.blocks.map(async (block) => await block.toJSON()),\n );\n\n return api;\n }\n}\n\n/**\n * Converts a string binding, which comprise 99% of dynamic integration fields, into a function returning an interpolated string.\n *\n * fromBinding(`https://${ \'goo\' + \'gle\' }.com/${ Dropdown1.value }`, [\'Dropdown1\']) -> ({ Dropdown1 }) => `https://${\'goo\' + \'gle\'}.com/${Dropdown1.value}`\n *\n * @param value - The value to convert.\n * @param entities - The master list of possible entities that could be referenced in the binding.\n *\n * @returns The converted value.\n */\nexport function fromBinding(\n value: string,\n entities: string[],\n): Binding<string> {\n if (!value) {\n return "";\n }\n\n // Handle IIFE expressions like "(() => 0)()" or "(() => { return x; })()"\n // These are used by Variables block and need to be converted back to functions\n if (value.startsWith("(() =>") && value.endsWith(")()")) {\n try {\n // Extract the body from the IIFE: "(() => BODY)()" -> "BODY"\n const iifeBody = value.slice(6, -3).trim(); // Remove "(() =>" and ")()"\n\n // Parse to extract any identifiers referenced in the body\n const ast = parse(iifeBody.startsWith("{") ? iifeBody : `(${iifeBody})`, {\n ecmaVersion: "latest",\n sourceType: "script",\n });\n const identifiers = Array.from(extractIdentifiers(ast));\n\n // Filter to only include known entities if provided\n const refs =\n entities.length > 0\n ? identifiers.filter((id) => entities.includes(id))\n : identifiers;\n\n // Create a function that returns the IIFE body\n return new Function(`{ ${refs.join(", ")} }`, `return ${iifeBody}`) as (\n _: State,\n ) => string;\n } catch {\n // If parsing fails, return the value as-is\n return value;\n }\n }\n\n if (!value.startsWith("`") || !value.endsWith("`")) {\n return value;\n }\n\n const args: string[] = [`return ${value}`];\n const references: string[] = referenced(value, entities);\n\n if (references.length === 0) {\n try {\n const ast = parse(value, {\n ecmaVersion: "latest",\n sourceType: "script",\n });\n\n const identifiers = Array.from(extractIdentifiers(ast));\n\n return new Function(\n `{ ${identifiers.join(", ")} }`,\n `return (${value})`,\n ) as (_: State) => string;\n } catch (e) {\n // can\'t extract identifiers for whatever reason, just return the value.\n return value;\n }\n }\n\n // only add the arguments if we have references\n args.unshift(`{ ${references} }`);\n\n return new Function(...args) as (_: State) => string;\n}\n\nasync function beautifyAndOptionallyCondense<T extends JsonValue>(\n value: (state: State) => T,\n node: Node,\n options: { condense?: boolean; block?: boolean } = {\n condense: true,\n block: true,\n },\n) {\n let start: number = node.start;\n let end: number = node.end;\n\n if (!options.block) {\n start += 1;\n end -= 1;\n }\n\n const beautified = await beautify(value.toString().slice(start, end));\n\n if (options.condense) {\n return beautified.replace(/\\s*\\n\\s*/g, " ").trim();\n }\n\n return beautified;\n}\n\nexport async function toJSBody<T extends JsonValue>(\n value: (state: State) => T,\n options: { block?: boolean; condense?: boolean; function?: boolean } = {\n block: true,\n condense: true,\n function: false,\n },\n): Promise<{ body: string; iife: boolean; node?: Node }> {\n if (typeof value !== "function") {\n return {\n body: `\\`${JSON.stringify(value)}\\``,\n iife: true,\n };\n }\n\n // parse the code\n const ast = createAst(value.toString());\n const program = ast.body[0];\n\n switch (program.type) {\n case "ExpressionStatement":\n const body = (\n (program as ExpressionStatement).expression as FunctionExpression\n ).body;\n\n if (body.type === "BlockStatement") {\n return {\n body: await beautifyAndOptionallyCondense(value, body, {\n ...options,\n block: options.block !== false, // Use the provided block option\n }),\n iife: true,\n node: body,\n };\n }\n\n let bodyText = safeBodyText(\n value.toString().slice(body.start, body.end),\n body,\n );\n if (options.condense) {\n bodyText = bodyText\n .replace(/\\s*\\n\\s*/g, " ")\n .replace(/\\s+/g, " ")\n .trim();\n }\n\n return {\n body: `${options.function ? "return " : ""}${bodyText}`,\n iife: options.function,\n node: body,\n };\n case "FunctionDeclaration":\n let contents = value\n .toString()\n .slice(program.body.start, program.body.end);\n\n if (program.body.type !== "BlockStatement") {\n return {\n body: contents,\n iife: false,\n node: program.body,\n };\n }\n\n if (\n !options.function &&\n program.body.body.length === 1 &&\n program.body.body[0].type === "ReturnStatement"\n ) {\n const argument = program.body.body[0].argument;\n if (!argument) {\n return {\n body: ``,\n iife: false,\n node: program.body.body[0],\n };\n }\n\n let bodyText = safeBodyText(\n value.toString().slice(argument.start, argument.end),\n argument,\n );\n\n return {\n body: bodyText,\n iife: false, // This should be false but we need to deal with the nested string template case.\n node: argument,\n };\n }\n\n return {\n body: await beautifyAndOptionallyCondense(value, program.body, options),\n iife: true,\n node: program.body,\n };\n default:\n throw new Error("you found a case we haven\'t handled yet");\n }\n}\n\nexport async function toJS<T extends JsonValue>(\n value: Binding<T>,\n): Promise<{ body: string; node?: Node }> {\n if (typeof value !== "function") {\n return {\n body: JSON.stringify(value),\n };\n }\n\n const { body, iife, node } = await toJSBody(value as (state: State) => T);\n\n if (iife) {\n return {\n body: `(() => ${body})()`,\n node,\n };\n }\n\n return { body, node };\n}\n\nexport function fromJS<T extends JsonValue>(\n value: string,\n entities: string[] = [],\n): Binding<T> {\n try {\n // determine if there are entities referenced in the value\n const refs = referenced(value, entities).join(", ");\n\n // remove any surrounding whitespace\n value = value.trim();\n\n if (value.length === 0) {\n return new Function("return ") as (_: State) => T;\n }\n\n let unaryOps: string[] = [];\n const ast = createAst(value);\n\n if (ast.body.length === 0) {\n return new Function("return ") as (_: State) => T;\n }\n\n let call = (ast.body[0] as ExpressionStatement).expression;\n\n while (call?.type === "UnaryExpression") {\n unaryOps.push((call as UnaryExpression).operator);\n call = (call as unknown as UnaryExpression).argument as CallExpression;\n }\n\n const fn = (call as CallExpression).callee;\n let body = value;\n let prefix = "return ";\n\n // handle iife\n if (fn?.type === "ArrowFunctionExpression") {\n // i\'m not happy with this but I don\'t see another immediate way to handle this.\n // this will result in a correct result but one that isn\'t idemopotent.\n if (unaryOps.length > 0) {\n return new Function(`{ ${refs} }`, `${prefix}${body}`) as (\n _: State,\n ) => T;\n }\n\n body = value.slice(fn.body.start, fn.body.end);\n\n if (fn.body.type === "BlockStatement") {\n // drop the opening "{" and closing "}"\n body = body.slice(1, -1);\n prefix = "";\n }\n } else if (refs.length === 0) {\n const ast = createAst(value);\n\n const identifiers = Array.from(extractIdentifiers(ast));\n\n return new Function(\n `{ ${identifiers.join(", ")} }`,\n `return (${value})`,\n ) as (_: State) => T;\n }\n\n // we\'re either an iife or a static value with refs.\n return new Function(`{ ${refs} }`, `${prefix}${body}`) as (_: State) => T;\n } catch (e) {\n console.error("There was an error during parsing in fromJS", e);\n // fallback to an empty function so we don\'t crash\n return new Function("return \'\'") as (_: State) => T;\n }\n}\n\nexport async function beautify(code: string): Promise<string> {\n const eslint = new ESLint({\n fix: true,\n overrideConfigFile: true,\n baseConfig: {\n languageOptions: {\n parser: typescript_eslint_parser,\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: "module",\n },\n },\n rules: {\n "arrow-body-style": "error",\n },\n },\n });\n\n code = (await eslint.lintText(code))[0]?.output || code;\n\n return await format(code, {\n parser: "typescript",\n tabWidth: 2,\n // singleQuote: true,\n trailingComma: "none",\n semi: true,\n bracketSpacing: true,\n arrowParens: "always",\n bracketSameLine: false,\n embeddedLanguageFormatting: "auto",\n quoteProps: "as-needed",\n insertPragma: false,\n requirePragma: false,\n useTabs: false,\n endOfLine: "auto",\n arrowFunctionParentheses: "always",\n // plugins: ["prettier-plugin-organize-imports"],\n });\n}\n\nexport function ensureIIFE(value: string): string {\n // We write the IIFE so we can be loose with the fomratting here.\n // For example, we\'d never get ( ( ) =>)().\n if (value.startsWith("(() => ") && value.endsWith(")()")) {\n return value;\n }\n\n let safeValue = value.trim();\n if (safeValue.startsWith("{") && safeValue.endsWith("}")) {\n safeValue = `(${safeValue})`;\n }\n\n return `(() => ${safeValue})()`;\n}\n\nfunction safeBodyText(body: string, node: Node): string {\n if (node.type === "ObjectExpression") {\n return `(${body})`;\n }\n return body;\n}\n\n// All of the integrations (openapi and not) should be registered\n// NOTE: @joeyagreco - when adding support for an integration here, make sure to update:\n// NOTE: @joeyagreco - 1. to-sdk-transformer.ts\n// NOTE: @joeyagreco - 2. context-util.ts\n// NOTE: @joeyagreco - 3. the import statement in Api.toSDK()\n// NOTE: @joeyagreco - 4. superblocks-api.md\nIntegration.registerIntegration("airtable", Airtable);\nIntegration.registerIntegration("athena", Athena);\nIntegration.registerIntegration("anthropic", Anthropic);\nIntegration.registerIntegration("asana", Asana);\nIntegration.registerIntegration("bigquery", BigQuery);\nIntegration.registerIntegration("bitbucket", Bitbucket);\nIntegration.registerIntegration("box", Box);\nIntegration.registerIntegration("circleci", CircleCI);\nIntegration.registerIntegration("cockroachdb", CockroachDB);\nIntegration.registerIntegration("cohere", Cohere);\nIntegration.registerIntegration("confluence", Confluence);\nIntegration.registerIntegration("cosmosdb", CosmosDB);\nIntegration.registerIntegration("couchbase", Couchbase);\nIntegration.registerIntegration("databricks", Databricks);\nIntegration.registerIntegration("datadog", Datadog);\nIntegration.registerIntegration("dropbox", Dropbox);\nIntegration.registerIntegration("dynamodb", DynamoDb);\nIntegration.registerIntegration("elasticsearch", Elasticsearch);\nIntegration.registerIntegration("email", Email);\nIntegration.registerIntegration("fireworks", Fireworks);\nIntegration.registerIntegration("front", Front);\nIntegration.registerIntegration("gcs", GoogleCloudStorage);\nIntegration.registerIntegration("gemini", Gemini);\nIntegration.registerIntegration("github", GitHub);\nIntegration.registerIntegration("googleanalytics", GoogleAnalytics);\nIntegration.registerIntegration("googledrive", GoogleDrive);\nIntegration.registerIntegration("graphqlintegration", GraphQL);\nIntegration.registerIntegration("groq", Groq);\nIntegration.registerIntegration("hubspot", HubSpot);\nIntegration.registerIntegration("intercom", Intercom);\nIntegration.registerIntegration("javascript", JavaScript);\nIntegration.registerIntegration("jira", Jira);\nIntegration.registerIntegration("launchdarkly", LaunchDarkly);\nIntegration.registerIntegration("mistral", Mistral);\nIntegration.registerIntegration("mongodb", MongoDB);\nIntegration.registerIntegration("notion", Notion);\nIntegration.registerIntegration("openai_v2", OpenAI);\nIntegration.registerIntegration("oracledb", OracleDB);\nIntegration.registerIntegration("pagerduty", PagerDuty);\nIntegration.registerIntegration("perplexity", Perplexity);\nIntegration.registerIntegration("postgres", PostgreSQL);\nIntegration.registerIntegration("mssql", MicrosoftSql);\nIntegration.registerIntegration("mariadb", MariaDB);\nIntegration.registerIntegration("mysql", MySQL);\nIntegration.registerIntegration("python", Python);\nIntegration.registerIntegration("redshift", Redshift);\nIntegration.registerIntegration("s3", S3);\nIntegration.registerIntegration("salesforce", Salesforce);\nIntegration.registerIntegration("segment", Segment);\nIntegration.registerIntegration("sendgrid", SendGrid);\nIntegration.registerIntegration("slack", Slack);\nIntegration.registerIntegration("snowflake", Snowflake);\nIntegration.registerIntegration("stabilityai", StabilityAI);\nIntegration.registerIntegration("stripe", Stripe);\nIntegration.registerIntegration("twilio", Twilio);\nIntegration.registerIntegration("zendesk", Zendesk);\nIntegration.registerIntegration("zoom", Zoom);\n\n// Core block types that should always be in SDK imports (not registered as integrations)\nconst CORE_BLOCK_TYPES = [\n "Api",\n "Conditional",\n "Parallel",\n "Loop",\n "TryCatch",\n "Variables",\n "Throw",\n "Return",\n "Break",\n "RestApi", // Not in registry - handled specially in Integration.fromJSON\n];\n\nexport function getSdkImports(): string {\n const integrationNames = Integration.getRegisteredIntegrationClassNames();\n const allNames = [...CORE_BLOCK_TYPES, ...integrationNames];\n return `import { ${allNames.join(", ")} } from \'@superblocksteam/library\'`;\n}\n',
712245
712530
  "src/to-sdk/__template__.ts": 'import { Api } from "@superblocksteam/library";\n\nconst json = {};\n\nconst entities = [];\n\n/**\n * Extract all entity names from API JSON that need to be in the entities list\n * for signatureV2 to properly reconstruct destructured parameters during SDK round-trip.\n *\n * Extracts:\n * - Variables block keys (e.g., hasMore, offset, results)\n * - Block names (for referencing block outputs)\n * - Loop iteration variables (item, index names)\n * - TryCatch error variable name\n * - Parallel dynamic item variable name\n *\n * Without this, `({ hasMore }) => hasMore.value` becomes `({ }) => hasMore.value`\n */\nfunction extractVariableKeys(apiJson: any): string[] {\n const keys: string[] = [];\n\n const extractFromBlocks = (blocks: any[]) => {\n for (const block of blocks || []) {\n // Extract keys from Variables blocks\n if (block.variables?.items) {\n for (const item of block.variables.items) {\n if (item.key) {\n keys.push(item.key);\n }\n }\n }\n\n // Add block names as entities (for referencing block outputs)\n if (block.name) {\n keys.push(block.name);\n }\n\n // Extract Loop iteration variable names (item and index)\n if (block.loop?.variables) {\n if (block.loop.variables.item) {\n keys.push(block.loop.variables.item);\n }\n if (block.loop.variables.index) {\n keys.push(block.loop.variables.index);\n }\n }\n\n // Extract TryCatch error variable name\n if (block.tryCatch?.variables?.error) {\n keys.push(block.tryCatch.variables.error);\n }\n\n // Extract Parallel dynamic item variable name\n if (block.parallel?.dynamic?.variables?.item) {\n keys.push(block.parallel.dynamic.variables.item);\n }\n\n // Recursively check nested blocks\n if (block.loop?.blocks) {\n extractFromBlocks(block.loop.blocks);\n }\n if (block.conditional?.if?.blocks) {\n extractFromBlocks(block.conditional.if.blocks);\n }\n if (block.conditional?.else?.blocks) {\n extractFromBlocks(block.conditional.else.blocks);\n }\n if (block.conditional?.elseIf) {\n for (const elseIf of block.conditional.elseIf) {\n if (elseIf.blocks) {\n extractFromBlocks(elseIf.blocks);\n }\n }\n }\n if (block.tryCatch?.try?.blocks) {\n extractFromBlocks(block.tryCatch.try.blocks);\n }\n if (block.tryCatch?.catch?.blocks) {\n extractFromBlocks(block.tryCatch.catch.blocks);\n }\n if (block.tryCatch?.finally?.blocks) {\n extractFromBlocks(block.tryCatch.finally.blocks);\n }\n if (block.parallel?.static?.paths) {\n for (const pathKey of Object.keys(block.parallel.static.paths)) {\n const pathBlocks = block.parallel.static.paths[pathKey]?.blocks;\n if (pathBlocks) {\n extractFromBlocks(pathBlocks);\n }\n }\n }\n if (block.parallel?.dynamic?.blocks) {\n extractFromBlocks(block.parallel.dynamic.blocks);\n }\n }\n };\n\n extractFromBlocks(apiJson.blocks || []);\n return keys;\n}\n\n// Merge provided entities with extracted Variable keys\nconst variableKeys = extractVariableKeys(json);\nconst allEntities = [...new Set([...entities, ...variableKeys])];\n\nconst api = Api.fromJSON(json, allEntities);\n\nexport default {\n toSDK: async () => await api.toSDK(allEntities),\n};\n',
712246
712531
  "tsconfig.json": '{\n "compilerOptions": {\n "target": "ES2020",\n "module": "ESNext",\n "moduleResolution": "bundler",\n "baseUrl": ".",\n "outDir": "dist",\n "rootDir": "src",\n "esModuleInterop": true,\n "resolveJsonModule": true,\n "isolatedModules": true,\n "skipLibCheck": true,\n "types": ["node"],\n "paths": {\n "@superblocksteam/library": ["src/superblocks-library-shim"]\n }\n },\n "include": ["src"],\n "exclude": ["node_modules", "dist", "fixtures"]\n}\n'
712247
712532
  }
@@ -712301,7 +712586,7 @@ var TemplateRenderer = (() => {
712301
712586
  workDir = __runInitializers12(this, _instanceExtraInitializers);
712302
712587
  nodeModuleDirs;
712303
712588
  constructor({ prefetchNodeModules = false }) {
712304
- this.workDir = path37.join(os3.tmpdir(), `superblocks-ai-service`);
712589
+ this.workDir = path38.join(os3.tmpdir(), `superblocks-ai-service`);
712305
712590
  this.nodeModuleDirs = {};
712306
712591
  if (prefetchNodeModules) {
712307
712592
  for (const [templateName, template] of Object.entries(templates)) {
@@ -712321,11 +712606,11 @@ var TemplateRenderer = (() => {
712321
712606
  }
712322
712607
  const template = templates[templateName];
712323
712608
  const templateNodeModules = await this.templateModulesDir(templateName, template);
712324
- const templateDir = path37.join(this.workDir, templateName, `gen-${randomUUID()}`);
712609
+ const templateDir = path38.join(this.workDir, templateName, `gen-${randomUUID()}`);
712325
712610
  getLogger().debug(`[ai-service] Rendering template ${templateName} to ${templateDir}`);
712326
712611
  reifyTemplate(templateDir, templates[templateName]);
712327
712612
  if (templateNodeModules) {
712328
- await fs16.cp(templateNodeModules, path37.join(templateDir, "node_modules"), {
712613
+ await fs16.cp(templateNodeModules, path38.join(templateDir, "node_modules"), {
712329
712614
  recursive: true
712330
712615
  });
712331
712616
  }
@@ -712341,9 +712626,9 @@ var TemplateRenderer = (() => {
712341
712626
  return this.nodeModuleDirs[templateName];
712342
712627
  }
712343
712628
  const packageJson = template["package.json"];
712344
- const dir = path37.join(this.workDir, templateName, SHARED_DIR);
712629
+ const dir = path38.join(this.workDir, templateName, SHARED_DIR);
712345
712630
  await fs16.mkdir(dir, { recursive: true });
712346
- await fs16.writeFile(path37.join(dir, "package.json"), packageJson, "utf-8");
712631
+ await fs16.writeFile(path38.join(dir, "package.json"), packageJson, "utf-8");
712347
712632
  const installDfd = new Promise((resolve11, reject) => {
712348
712633
  const child = spawn5("npm", ["install", "--ignore-scripts"], {
712349
712634
  cwd: dir,
@@ -712353,7 +712638,7 @@ var TemplateRenderer = (() => {
712353
712638
  if (code2 !== 0) {
712354
712639
  reject(new Error(`npm install failed with code ${code2}`));
712355
712640
  }
712356
- resolve11(path37.join(dir, "node_modules"));
712641
+ resolve11(path38.join(dir, "node_modules"));
712357
712642
  });
712358
712643
  });
712359
712644
  this.nodeModuleDirs[templateName] = installDfd;
@@ -714180,7 +714465,7 @@ var AiService = class extends import_shared27.TracedEventEmitter {
714180
714465
  return;
714181
714466
  }
714182
714467
  const absoluteFilePath = this.fileSystemInterface.getElementToFilePath(request3.itemId);
714183
- const relativeFilePath = path38.relative(this.appShell.appRootDirPath, absoluteFilePath);
714468
+ const relativeFilePath = path39.relative(this.appShell.appRootDirPath, absoluteFilePath);
714184
714469
  const build_readFile = buildReadFileToolFactory.create({
714185
714470
  services: { appShell: this.appShell }
714186
714471
  });
@@ -714665,20 +714950,20 @@ ${attachment.content}
714665
714950
  let storageDir;
714666
714951
  let storageFilename;
714667
714952
  if (judgeStoragePath) {
714668
- const expandedPath = judgeStoragePath.startsWith("~/") ? path38.join(os4.homedir(), judgeStoragePath.slice(2)) : judgeStoragePath;
714953
+ const expandedPath = judgeStoragePath.startsWith("~/") ? path39.join(os4.homedir(), judgeStoragePath.slice(2)) : judgeStoragePath;
714669
714954
  if (expandedPath.endsWith(".csv")) {
714670
- storageDir = path38.dirname(expandedPath);
714671
- storageFilename = path38.basename(expandedPath);
714955
+ storageDir = path39.dirname(expandedPath);
714956
+ storageFilename = path39.basename(expandedPath);
714672
714957
  } else {
714673
714958
  storageDir = expandedPath;
714674
714959
  storageFilename = "evaluations.csv";
714675
714960
  }
714676
714961
  } else {
714677
- storageDir = path38.join(this.config.appRootDirPath, ".superblocks/judge-evaluations");
714962
+ storageDir = path39.join(this.config.appRootDirPath, ".superblocks/judge-evaluations");
714678
714963
  storageFilename = "evaluations.csv";
714679
714964
  }
714680
714965
  const judgeStorage = new CsvJudgeStorage(storageDir, storageFilename);
714681
- this.config.logger.info(`[ai-service] Judge storage configured: ${path38.join(storageDir, storageFilename)}`);
714966
+ this.config.logger.info(`[ai-service] Judge storage configured: ${path39.join(storageDir, storageFilename)}`);
714682
714967
  const judgeLlmProvider = createLLMProvider(this.getLLMProviderSettings(false, request3.llmConfig), () => this.getJwt(), request3.llmConfig, void 0);
714683
714968
  const judgeService = new JudgeService({
714684
714969
  llmClient: this.llmClient,
@@ -715167,16 +715452,16 @@ async function getDraftOrLiveDirectoryHash(rpcClient, applicationId, branch) {
715167
715452
  // ../../../vite-plugin-file-sync/dist/sync-service/draft-helpers.js
715168
715453
  init_cjs_shims();
715169
715454
  import * as fsp3 from "node:fs/promises";
715170
- import * as path39 from "node:path";
715455
+ import * as path40 from "node:path";
715171
715456
  var EDIT_EXT = ".sbswap.edit";
715172
715457
  var ADD_EXT = ".sbswap.add";
715173
715458
  var DELETE_EXT = ".sbswap.delete";
715174
715459
  function getMarkerFilePath(filePath, appRootDirPath, markerType) {
715175
- const relativePath = path39.relative(appRootDirPath, filePath);
715176
- return path39.join(getDraftsDirectoryPath(appRootDirPath), `${relativePath}${markerType}`);
715460
+ const relativePath = path40.relative(appRootDirPath, filePath);
715461
+ return path40.join(getDraftsDirectoryPath(appRootDirPath), `${relativePath}${markerType}`);
715177
715462
  }
715178
715463
  function getDraftsDirectoryPath(appRootDirPath) {
715179
- return path39.join(appRootDirPath, ".superblocks", "drafts");
715464
+ return path40.join(appRootDirPath, ".superblocks", "drafts");
715180
715465
  }
715181
715466
  async function getMarkerState(filePath, appRootDirPath) {
715182
715467
  const editMarkerPath = getMarkerFilePath(filePath, appRootDirPath, EDIT_EXT);
@@ -715210,14 +715495,14 @@ async function createDraftMarkerOnly(filePath, appRootDirPath) {
715210
715495
  switch (state) {
715211
715496
  case "FILE_EXISTS": {
715212
715497
  const editMarkerPath = getMarkerFilePath(filePath, appRootDirPath, EDIT_EXT);
715213
- const editMarkerDir = path39.dirname(editMarkerPath);
715498
+ const editMarkerDir = path40.dirname(editMarkerPath);
715214
715499
  await fsp3.mkdir(editMarkerDir, { recursive: true });
715215
715500
  await fsp3.copyFile(filePath, editMarkerPath);
715216
715501
  return;
715217
715502
  }
715218
715503
  case "NEW": {
715219
715504
  const addMarkerPath = getMarkerFilePath(filePath, appRootDirPath, ADD_EXT);
715220
- const addMarkerDir = path39.dirname(addMarkerPath);
715505
+ const addMarkerDir = path40.dirname(addMarkerPath);
715221
715506
  await fsp3.mkdir(addMarkerDir, { recursive: true });
715222
715507
  await fsp3.writeFile(addMarkerPath, "");
715223
715508
  return;
@@ -715232,13 +715517,13 @@ async function createDraft(filePath, draftContent, appRootDirPath) {
715232
715517
  const state = await getMarkerState(filePath, appRootDirPath);
715233
715518
  switch (state) {
715234
715519
  case "ADD_MARKER": {
715235
- const dirPath = path39.dirname(filePath);
715520
+ const dirPath = path40.dirname(filePath);
715236
715521
  await fsp3.mkdir(dirPath, { recursive: true });
715237
715522
  await fsp3.writeFile(filePath, draftContent);
715238
715523
  return "add";
715239
715524
  }
715240
715525
  case "EDIT_MARKER": {
715241
- const dirPath = path39.dirname(filePath);
715526
+ const dirPath = path40.dirname(filePath);
715242
715527
  await fsp3.mkdir(dirPath, { recursive: true });
715243
715528
  await fsp3.writeFile(filePath, draftContent);
715244
715529
  return "edit";
@@ -715250,7 +715535,7 @@ async function createDraft(filePath, draftContent, appRootDirPath) {
715250
715535
  await fsp3.rename(deleteMarkerPath, editMarkerPath);
715251
715536
  } catch {
715252
715537
  }
715253
- const dirPath = path39.dirname(filePath);
715538
+ const dirPath = path40.dirname(filePath);
715254
715539
  await fsp3.mkdir(dirPath, { recursive: true });
715255
715540
  await fsp3.writeFile(filePath, draftContent);
715256
715541
  return "edit";
@@ -715278,7 +715563,7 @@ async function createDraftEdit(filePath, draftContent, appRootDirPath) {
715278
715563
  return;
715279
715564
  } catch {
715280
715565
  }
715281
- const editMarkerDir = path39.dirname(editMarkerPath);
715566
+ const editMarkerDir = path40.dirname(editMarkerPath);
715282
715567
  await fsp3.mkdir(editMarkerDir, { recursive: true });
715283
715568
  await fsp3.copyFile(filePath, editMarkerPath);
715284
715569
  await fsp3.writeFile(filePath, draftContent);
@@ -715287,7 +715572,7 @@ async function createDraftAdd(filePath, content2, appRootDirPath) {
715287
715572
  const addMarkerPath = getMarkerFilePath(filePath, appRootDirPath, ADD_EXT);
715288
715573
  try {
715289
715574
  await fsp3.access(addMarkerPath);
715290
- const dirPath2 = path39.dirname(filePath);
715575
+ const dirPath2 = path40.dirname(filePath);
715291
715576
  await fsp3.mkdir(dirPath2, { recursive: true });
715292
715577
  await fsp3.writeFile(filePath, content2);
715293
715578
  return;
@@ -715301,9 +715586,9 @@ async function createDraftAdd(filePath, content2, appRootDirPath) {
715301
715586
  throw accessError;
715302
715587
  }
715303
715588
  }
715304
- const dirPath = path39.dirname(filePath);
715589
+ const dirPath = path40.dirname(filePath);
715305
715590
  await fsp3.mkdir(dirPath, { recursive: true });
715306
- const addMarkerDir = path39.dirname(addMarkerPath);
715591
+ const addMarkerDir = path40.dirname(addMarkerPath);
715307
715592
  await fsp3.mkdir(addMarkerDir, { recursive: true });
715308
715593
  await fsp3.writeFile(filePath, content2);
715309
715594
  await fsp3.writeFile(addMarkerPath, "");
@@ -715320,7 +715605,7 @@ async function createDraftDelete(filePath, appRootDirPath) {
715320
715605
  return;
715321
715606
  } catch {
715322
715607
  }
715323
- const deleteMarkerDir = path39.dirname(deleteMarkerPath);
715608
+ const deleteMarkerDir = path40.dirname(deleteMarkerPath);
715324
715609
  await fsp3.mkdir(deleteMarkerDir, { recursive: true });
715325
715610
  await fsp3.copyFile(filePath, deleteMarkerPath);
715326
715611
  await fsp3.unlink(filePath);
@@ -715340,11 +715625,11 @@ async function hasSwapFilesInDirectory(directoryPath, appRootDirPath) {
715340
715625
  const draftsDir = getDraftsDirectoryPath(appRootDirPath);
715341
715626
  for (const entry of entries) {
715342
715627
  if (entry.isFile()) {
715343
- const swapFilePath = path39.join(directoryPath, entry.name);
715628
+ const swapFilePath = path40.join(directoryPath, entry.name);
715344
715629
  if (entry.name.endsWith(EDIT_EXT)) {
715345
- const markerRelativePath = path39.relative(draftsDir, swapFilePath);
715630
+ const markerRelativePath = path40.relative(draftsDir, swapFilePath);
715346
715631
  const originalRelativePath = markerRelativePath.slice(0, -EDIT_EXT.length);
715347
- const originalPath = path39.join(appRootDirPath, originalRelativePath);
715632
+ const originalPath = path40.join(appRootDirPath, originalRelativePath);
715348
715633
  try {
715349
715634
  const [draftContent, originalContent] = await Promise.all([
715350
715635
  fsp3.readFile(swapFilePath, "utf8"),
@@ -715363,7 +715648,7 @@ async function hasSwapFilesInDirectory(directoryPath, appRootDirPath) {
715363
715648
  }
715364
715649
  }
715365
715650
  if (entry.isDirectory()) {
715366
- const subdirPath = path39.join(directoryPath, entry.name);
715651
+ const subdirPath = path40.join(directoryPath, entry.name);
715367
715652
  if (await hasSwapFilesInDirectory(subdirPath, appRootDirPath)) {
715368
715653
  return true;
715369
715654
  }
@@ -715395,30 +715680,30 @@ async function discardDraftsInDirectory(directoryPath, appRootDirPath) {
715395
715680
  try {
715396
715681
  const entries = await fsp3.readdir(directoryPath, { withFileTypes: true });
715397
715682
  for (const entry of entries) {
715398
- const fullPath = path39.join(directoryPath, entry.name);
715683
+ const fullPath = path40.join(directoryPath, entry.name);
715399
715684
  if (entry.isFile()) {
715400
715685
  if (entry.name.endsWith(EDIT_EXT)) {
715401
- const markerRelativePath = path39.relative(getDraftsDirectoryPath(appRootDirPath), fullPath);
715686
+ const markerRelativePath = path40.relative(getDraftsDirectoryPath(appRootDirPath), fullPath);
715402
715687
  const originalRelativePath = markerRelativePath.slice(0, -EDIT_EXT.length);
715403
- const originalPath = path39.join(appRootDirPath, originalRelativePath);
715688
+ const originalPath = path40.join(appRootDirPath, originalRelativePath);
715404
715689
  try {
715405
715690
  await fsp3.unlink(originalPath);
715406
715691
  } catch {
715407
715692
  }
715408
715693
  await fsp3.copyFile(fullPath, originalPath);
715409
715694
  } else if (entry.name.endsWith(ADD_EXT)) {
715410
- const markerRelativePath = path39.relative(getDraftsDirectoryPath(appRootDirPath), fullPath);
715695
+ const markerRelativePath = path40.relative(getDraftsDirectoryPath(appRootDirPath), fullPath);
715411
715696
  const addedFileRelativePath = markerRelativePath.slice(0, -ADD_EXT.length);
715412
- const addedFilePath = path39.join(appRootDirPath, addedFileRelativePath);
715697
+ const addedFilePath = path40.join(appRootDirPath, addedFileRelativePath);
715413
715698
  try {
715414
715699
  await fsp3.unlink(addedFilePath);
715415
715700
  } catch {
715416
715701
  }
715417
715702
  } else if (entry.name.endsWith(DELETE_EXT)) {
715418
- const markerRelativePath = path39.relative(getDraftsDirectoryPath(appRootDirPath), fullPath);
715703
+ const markerRelativePath = path40.relative(getDraftsDirectoryPath(appRootDirPath), fullPath);
715419
715704
  const deletedFileRelativePath = markerRelativePath.slice(0, -DELETE_EXT.length);
715420
- const deletedFilePath = path39.join(appRootDirPath, deletedFileRelativePath);
715421
- const dirPath = path39.dirname(deletedFilePath);
715705
+ const deletedFilePath = path40.join(appRootDirPath, deletedFileRelativePath);
715706
+ const dirPath = path40.dirname(deletedFilePath);
715422
715707
  await fsp3.mkdir(dirPath, { recursive: true });
715423
715708
  await fsp3.copyFile(fullPath, deletedFilePath);
715424
715709
  }
@@ -715456,18 +715741,18 @@ async function getDraftInfo(appRootDirPath) {
715456
715741
  try {
715457
715742
  const entries = await fsp3.readdir(currentPath, { withFileTypes: true });
715458
715743
  for (const entry of entries) {
715459
- const fullPath = path39.join(currentPath, entry.name);
715744
+ const fullPath = path40.join(currentPath, entry.name);
715460
715745
  if (entry.isFile()) {
715461
715746
  if (entry.name.endsWith(EDIT_EXT)) {
715462
- const markerRelativePath = path39.relative(draftsDir, fullPath);
715747
+ const markerRelativePath = path40.relative(draftsDir, fullPath);
715463
715748
  const originalRelativePath = markerRelativePath.slice(0, -EDIT_EXT.length);
715464
715749
  edits.push(originalRelativePath);
715465
715750
  } else if (entry.name.endsWith(ADD_EXT)) {
715466
- const markerRelativePath = path39.relative(draftsDir, fullPath);
715751
+ const markerRelativePath = path40.relative(draftsDir, fullPath);
715467
715752
  const addedFileRelativePath = markerRelativePath.slice(0, -ADD_EXT.length);
715468
715753
  additions.push(addedFileRelativePath);
715469
715754
  } else if (entry.name.endsWith(DELETE_EXT)) {
715470
- const markerRelativePath = path39.relative(draftsDir, fullPath);
715755
+ const markerRelativePath = path40.relative(draftsDir, fullPath);
715471
715756
  const deletedFileRelativePath = markerRelativePath.slice(0, -DELETE_EXT.length);
715472
715757
  deletions.push(deletedFileRelativePath);
715473
715758
  }
@@ -715498,7 +715783,7 @@ async function generateDraftDiff(appRootDirPath, specificPaths = []) {
715498
715783
  return "No draft changes found.";
715499
715784
  }
715500
715785
  for (const editPath of edits) {
715501
- const originalPath = path39.join(appRootDirPath, editPath);
715786
+ const originalPath = path40.join(appRootDirPath, editPath);
715502
715787
  const markerPath = getMarkerFilePath(originalPath, appRootDirPath, EDIT_EXT);
715503
715788
  try {
715504
715789
  const currentContent = await fsp3.readFile(originalPath, "utf8");
@@ -715511,7 +715796,7 @@ async function generateDraftDiff(appRootDirPath, specificPaths = []) {
715511
715796
  }
715512
715797
  }
715513
715798
  for (const addPath of additions) {
715514
- const filePath = path39.join(appRootDirPath, addPath);
715799
+ const filePath = path40.join(appRootDirPath, addPath);
715515
715800
  try {
715516
715801
  const content2 = await fsp3.readFile(filePath, "utf8");
715517
715802
  const patch = createPatch(addPath, "", content2);
@@ -715522,7 +715807,7 @@ async function generateDraftDiff(appRootDirPath, specificPaths = []) {
715522
715807
  }
715523
715808
  }
715524
715809
  for (const deletePath of deletions) {
715525
- const markerPath = getMarkerFilePath(path39.join(appRootDirPath, deletePath), appRootDirPath, DELETE_EXT);
715810
+ const markerPath = getMarkerFilePath(path40.join(appRootDirPath, deletePath), appRootDirPath, DELETE_EXT);
715526
715811
  try {
715527
715812
  const originalContent = await fsp3.readFile(markerPath, "utf8");
715528
715813
  const patch = createPatch(deletePath, originalContent, "");
@@ -717260,7 +717545,7 @@ var WriteStreamSync = class extends WriteStream {
717260
717545
  };
717261
717546
 
717262
717547
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/create.js
717263
- import path42 from "node:path";
717548
+ import path43 from "node:path";
717264
717549
 
717265
717550
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/list.js
717266
717551
  init_cjs_shims();
@@ -719290,7 +719575,7 @@ import fs20 from "fs";
719290
719575
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/write-entry.js
719291
719576
  init_cjs_shims();
719292
719577
  import fs19 from "fs";
719293
- import path40 from "path";
719578
+ import path41 from "path";
719294
719579
 
719295
719580
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/mode-fix.js
719296
719581
  init_cjs_shims();
@@ -719429,7 +719714,7 @@ var WriteEntry = class extends Minipass {
719429
719714
  this.path = decode(this.path.replace(/\\/g, "/"));
719430
719715
  p = p.replace(/\\/g, "/");
719431
719716
  }
719432
- this.absolute = normalizeWindowsPath(opt.absolute || path40.resolve(this.cwd, p));
719717
+ this.absolute = normalizeWindowsPath(opt.absolute || path41.resolve(this.cwd, p));
719433
719718
  if (this.path === "") {
719434
719719
  this.path = "./";
719435
719720
  }
@@ -719568,7 +719853,7 @@ var WriteEntry = class extends Minipass {
719568
719853
  throw new Error("cannot create link entry without stat");
719569
719854
  }
719570
719855
  this.type = "Link";
719571
- this.linkpath = normalizeWindowsPath(path40.relative(this.cwd, linkpath));
719856
+ this.linkpath = normalizeWindowsPath(path41.relative(this.cwd, linkpath));
719572
719857
  this.stat.size = 0;
719573
719858
  this[HEADER]();
719574
719859
  this.end();
@@ -719917,7 +720202,7 @@ var WriteEntryTar = class extends Minipass {
719917
720202
  var getType = (stat9) => stat9.isFile() ? "File" : stat9.isDirectory() ? "Directory" : stat9.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
719918
720203
 
719919
720204
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/pack.js
719920
- import path41 from "path";
720205
+ import path42 from "path";
719921
720206
  var PackJob = class {
719922
720207
  path;
719923
720208
  absolute;
@@ -720076,7 +720361,7 @@ var Pack = class extends Minipass {
720076
720361
  return this.flowing;
720077
720362
  }
720078
720363
  [ADDTARENTRY](p) {
720079
- const absolute = normalizeWindowsPath(path41.resolve(this.cwd, p.path));
720364
+ const absolute = normalizeWindowsPath(path42.resolve(this.cwd, p.path));
720080
720365
  if (!this.filter(p.path, p)) {
720081
720366
  p.resume();
720082
720367
  } else {
@@ -720089,7 +720374,7 @@ var Pack = class extends Minipass {
720089
720374
  this[PROCESS3]();
720090
720375
  }
720091
720376
  [ADDFSENTRY](p) {
720092
- const absolute = normalizeWindowsPath(path41.resolve(this.cwd, p));
720377
+ const absolute = normalizeWindowsPath(path42.resolve(this.cwd, p));
720093
720378
  this[QUEUE2].push(new PackJob(p, absolute));
720094
720379
  this[PROCESS3]();
720095
720380
  }
@@ -720347,7 +720632,7 @@ var addFilesSync = (p, files) => {
720347
720632
  files.forEach((file2) => {
720348
720633
  if (file2.charAt(0) === "@") {
720349
720634
  list({
720350
- file: path42.resolve(p.cwd, file2.slice(1)),
720635
+ file: path43.resolve(p.cwd, file2.slice(1)),
720351
720636
  sync: true,
720352
720637
  noResume: true,
720353
720638
  onReadEntry: (entry) => p.add(entry)
@@ -720363,7 +720648,7 @@ var addFilesAsync = async (p, files) => {
720363
720648
  const file2 = String(files[i]);
720364
720649
  if (file2.charAt(0) === "@") {
720365
720650
  await list({
720366
- file: path42.resolve(String(p.cwd), file2.slice(1)),
720651
+ file: path43.resolve(String(p.cwd), file2.slice(1)),
720367
720652
  noResume: true,
720368
720653
  onReadEntry: (entry) => {
720369
720654
  p.add(entry);
@@ -720400,7 +720685,7 @@ init_cjs_shims();
720400
720685
  import assert3 from "node:assert";
720401
720686
  import { randomBytes as randomBytes2 } from "node:crypto";
720402
720687
  import fs25 from "node:fs";
720403
- import path45 from "node:path";
720688
+ import path46 from "node:path";
720404
720689
 
720405
720690
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/get-write-flag.js
720406
720691
  init_cjs_shims();
@@ -720420,7 +720705,7 @@ init_cjs_shims();
720420
720705
  // ../../../../node_modules/.pnpm/chownr@3.0.0/node_modules/chownr/dist/esm/index.js
720421
720706
  init_cjs_shims();
720422
720707
  import fs23 from "node:fs";
720423
- import path43 from "node:path";
720708
+ import path44 from "node:path";
720424
720709
  var lchownSync = (path84, uid, gid) => {
720425
720710
  try {
720426
720711
  return fs23.lchownSync(path84, uid, gid);
@@ -720436,14 +720721,14 @@ var chown = (cpath, uid, gid, cb) => {
720436
720721
  };
720437
720722
  var chownrKid = (p, child, uid, gid, cb) => {
720438
720723
  if (child.isDirectory()) {
720439
- chownr(path43.resolve(p, child.name), uid, gid, (er) => {
720724
+ chownr(path44.resolve(p, child.name), uid, gid, (er) => {
720440
720725
  if (er)
720441
720726
  return cb(er);
720442
- const cpath = path43.resolve(p, child.name);
720727
+ const cpath = path44.resolve(p, child.name);
720443
720728
  chown(cpath, uid, gid, cb);
720444
720729
  });
720445
720730
  } else {
720446
- const cpath = path43.resolve(p, child.name);
720731
+ const cpath = path44.resolve(p, child.name);
720447
720732
  chown(cpath, uid, gid, cb);
720448
720733
  }
720449
720734
  };
@@ -720474,8 +720759,8 @@ var chownr = (p, uid, gid, cb) => {
720474
720759
  };
720475
720760
  var chownrKidSync = (p, child, uid, gid) => {
720476
720761
  if (child.isDirectory())
720477
- chownrSync(path43.resolve(p, child.name), uid, gid);
720478
- lchownSync(path43.resolve(p, child.name), uid, gid);
720762
+ chownrSync(path44.resolve(p, child.name), uid, gid);
720763
+ lchownSync(path44.resolve(p, child.name), uid, gid);
720479
720764
  };
720480
720765
  var chownrSync = (p, uid, gid) => {
720481
720766
  let children2;
@@ -720732,7 +721017,7 @@ var mkdirp = Object.assign(async (path84, opts) => {
720732
721017
  });
720733
721018
 
720734
721019
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/mkdir.js
720735
- import path44 from "node:path";
721020
+ import path45 from "node:path";
720736
721021
 
720737
721022
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/cwd-error.js
720738
721023
  init_cjs_shims();
@@ -720817,7 +721102,7 @@ var mkdir12 = (dir, opt, cb) => {
720817
721102
  done
720818
721103
  );
720819
721104
  }
720820
- const sub = normalizeWindowsPath(path44.relative(cwd, dir));
721105
+ const sub = normalizeWindowsPath(path45.relative(cwd, dir));
720821
721106
  const parts = sub.split("/");
720822
721107
  mkdir_(cwd, parts, mode, cache4, unlink6, cwd, void 0, done);
720823
721108
  };
@@ -720826,7 +721111,7 @@ var mkdir_ = (base, parts, mode, cache4, unlink6, cwd, created, cb) => {
720826
721111
  return cb(null, created);
720827
721112
  }
720828
721113
  const p = parts.shift();
720829
- const part = normalizeWindowsPath(path44.resolve(base + "/" + p));
721114
+ const part = normalizeWindowsPath(path45.resolve(base + "/" + p));
720830
721115
  if (cGet(cache4, part)) {
720831
721116
  return mkdir_(part, parts, mode, cache4, unlink6, cwd, created, cb);
720832
721117
  }
@@ -720902,11 +721187,11 @@ var mkdirSync4 = (dir, opt) => {
720902
721187
  if (preserve) {
720903
721188
  return done(mkdirpSync(dir, mode) ?? void 0);
720904
721189
  }
720905
- const sub = normalizeWindowsPath(path44.relative(cwd, dir));
721190
+ const sub = normalizeWindowsPath(path45.relative(cwd, dir));
720906
721191
  const parts = sub.split("/");
720907
721192
  let created = void 0;
720908
721193
  for (let p = parts.shift(), part = cwd; p && (part += "/" + p); p = parts.shift()) {
720909
- part = normalizeWindowsPath(path44.resolve(part));
721194
+ part = normalizeWindowsPath(path45.resolve(part));
720910
721195
  if (cGet(cache4, part)) {
720911
721196
  continue;
720912
721197
  }
@@ -721212,7 +721497,7 @@ var Unpack = class extends Parser4 {
721212
721497
  this.noMtime = !!opt.noMtime;
721213
721498
  this.preservePaths = !!opt.preservePaths;
721214
721499
  this.unlink = !!opt.unlink;
721215
- this.cwd = normalizeWindowsPath(path45.resolve(opt.cwd || process.cwd()));
721500
+ this.cwd = normalizeWindowsPath(path46.resolve(opt.cwd || process.cwd()));
721216
721501
  this.strip = Number(opt.strip) || 0;
721217
721502
  this.processUmask = !this.chmod ? 0 : typeof opt.processUmask === "number" ? opt.processUmask : process.umask();
721218
721503
  this.umask = typeof opt.umask === "number" ? opt.umask : this.processUmask;
@@ -721281,10 +721566,10 @@ var Unpack = class extends Parser4 {
721281
721566
  });
721282
721567
  }
721283
721568
  }
721284
- if (path45.isAbsolute(entry.path)) {
721285
- entry.absolute = normalizeWindowsPath(path45.resolve(entry.path));
721569
+ if (path46.isAbsolute(entry.path)) {
721570
+ entry.absolute = normalizeWindowsPath(path46.resolve(entry.path));
721286
721571
  } else {
721287
- entry.absolute = normalizeWindowsPath(path45.resolve(this.cwd, entry.path));
721572
+ entry.absolute = normalizeWindowsPath(path46.resolve(this.cwd, entry.path));
721288
721573
  }
721289
721574
  if (!this.preservePaths && typeof entry.absolute === "string" && entry.absolute.indexOf(this.cwd + "/") !== 0 && entry.absolute !== this.cwd) {
721290
721575
  this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
@@ -721299,9 +721584,9 @@ var Unpack = class extends Parser4 {
721299
721584
  return false;
721300
721585
  }
721301
721586
  if (this.win32) {
721302
- const { root: aRoot } = path45.win32.parse(String(entry.absolute));
721587
+ const { root: aRoot } = path46.win32.parse(String(entry.absolute));
721303
721588
  entry.absolute = aRoot + encode2(String(entry.absolute).slice(aRoot.length));
721304
- const { root: pRoot } = path45.win32.parse(entry.path);
721589
+ const { root: pRoot } = path46.win32.parse(entry.path);
721305
721590
  entry.path = pRoot + encode2(entry.path.slice(pRoot.length));
721306
721591
  }
721307
721592
  return true;
@@ -721469,7 +721754,7 @@ var Unpack = class extends Parser4 {
721469
721754
  this[LINK](entry, String(entry.linkpath), "symlink", done);
721470
721755
  }
721471
721756
  [HARDLINK2](entry, done) {
721472
- const linkpath = normalizeWindowsPath(path45.resolve(this.cwd, String(entry.linkpath)));
721757
+ const linkpath = normalizeWindowsPath(path46.resolve(this.cwd, String(entry.linkpath)));
721473
721758
  this[LINK](entry, linkpath, "link", done);
721474
721759
  }
721475
721760
  [PEND]() {
@@ -721524,7 +721809,7 @@ var Unpack = class extends Parser4 {
721524
721809
  };
721525
721810
  const start = () => {
721526
721811
  if (entry.absolute !== this.cwd) {
721527
- const parent2 = normalizeWindowsPath(path45.dirname(String(entry.absolute)));
721812
+ const parent2 = normalizeWindowsPath(path46.dirname(String(entry.absolute)));
721528
721813
  if (parent2 !== this.cwd) {
721529
721814
  return this[MKDIR](parent2, this.dmode, (er) => {
721530
721815
  if (er) {
@@ -721629,7 +721914,7 @@ var UnpackSync = class extends Unpack {
721629
721914
  this[CHECKED_CWD] = true;
721630
721915
  }
721631
721916
  if (entry.absolute !== this.cwd) {
721632
- const parent2 = normalizeWindowsPath(path45.dirname(String(entry.absolute)));
721917
+ const parent2 = normalizeWindowsPath(path46.dirname(String(entry.absolute)));
721633
721918
  if (parent2 !== this.cwd) {
721634
721919
  const mkParent = this[MKDIR](parent2, this.dmode);
721635
721920
  if (mkParent) {
@@ -721817,7 +722102,7 @@ var extract3 = makeCommand(extractFileSync, extractFile, (opt) => new UnpackSync
721817
722102
  // ../../../../node_modules/.pnpm/tar@7.4.3/node_modules/tar/dist/esm/replace.js
721818
722103
  init_cjs_shims();
721819
722104
  import fs27 from "node:fs";
721820
- import path46 from "node:path";
722105
+ import path47 from "node:path";
721821
722106
  var replaceSync = (opt, files) => {
721822
722107
  const p = new PackSync(opt);
721823
722108
  let threw = true;
@@ -721966,7 +722251,7 @@ var addFilesSync2 = (p, files) => {
721966
722251
  files.forEach((file2) => {
721967
722252
  if (file2.charAt(0) === "@") {
721968
722253
  list({
721969
- file: path46.resolve(p.cwd, file2.slice(1)),
722254
+ file: path47.resolve(p.cwd, file2.slice(1)),
721970
722255
  sync: true,
721971
722256
  noResume: true,
721972
722257
  onReadEntry: (entry) => p.add(entry)
@@ -721982,7 +722267,7 @@ var addFilesAsync2 = async (p, files) => {
721982
722267
  const file2 = String(files[i]);
721983
722268
  if (file2.charAt(0) === "@") {
721984
722269
  await list({
721985
- file: path46.resolve(String(p.cwd), file2.slice(1)),
722270
+ file: path47.resolve(String(p.cwd), file2.slice(1)),
721986
722271
  noResume: true,
721987
722272
  onReadEntry: (entry) => p.add(entry)
721988
722273
  });
@@ -722058,9 +722343,9 @@ var import_ws = __toESM(require_ws());
722058
722343
  init_cjs_shims();
722059
722344
  var import_util27 = __toESM(require_dist10());
722060
722345
  import { readdir as readdir9, readFile as readFile8 } from "node:fs/promises";
722061
- import * as path47 from "node:path";
722346
+ import * as path48 from "node:path";
722062
722347
  async function uploadContextToBucketeer({ applicationId, commitId, branchName, appRootDirPath, userId, superblocksBaseUrl, logger: logger12, jwt: jwt2 }) {
722063
- const contextDir = path47.join(appRootDirPath, ".superblocks", "context", userId);
722348
+ const contextDir = path48.join(appRootDirPath, ".superblocks", "context", userId);
722064
722349
  let contextFiles;
722065
722350
  try {
722066
722351
  const entries = await readdir9(contextDir, { withFileTypes: true });
@@ -722090,7 +722375,7 @@ async function uploadContextToBucketeer({ applicationId, commitId, branchName, a
722090
722375
  const formData = new FormData();
722091
722376
  const uploadedFiles = [];
722092
722377
  for (const fileName of contextFiles) {
722093
- const filePath = path47.join(contextDir, fileName);
722378
+ const filePath = path48.join(contextDir, fileName);
722094
722379
  try {
722095
722380
  const fileBuffer = await readFile8(filePath);
722096
722381
  const uint8Array = new Uint8Array(fileBuffer);
@@ -730098,10 +730383,10 @@ import { createRequire as __prettierCreateRequire } from "module";
730098
730383
  import { fileURLToPath as __prettierFileUrlToPath } from "url";
730099
730384
  import { dirname as __prettierDirname } from "path";
730100
730385
  import path102 from "path";
730101
- import * as path48 from "path";
730386
+ import * as path49 from "path";
730102
730387
  import * as url2 from "url";
730103
730388
  import path52 from "path";
730104
- import * as path49 from "path";
730389
+ import * as path410 from "path";
730105
730390
  import * as fs28 from "fs/promises";
730106
730391
  import * as path210 from "path";
730107
730392
  import process22 from "process";
@@ -741654,7 +741939,7 @@ var isUrlInstance = (value2) => value2 instanceof URL;
741654
741939
  var isUrlString = (value2) => typeof value2 === "string" && value2.startsWith(URL_STRING_PREFIX);
741655
741940
  var isUrl = (urlOrPath) => isUrlInstance(urlOrPath) || isUrlString(urlOrPath);
741656
741941
  var toPath = (urlOrPath) => isUrl(urlOrPath) ? url2.fileURLToPath(urlOrPath) : urlOrPath;
741657
- var toAbsolutePath = (urlOrPath) => urlOrPath ? path48.resolve(isUrl(urlOrPath) ? url2.fileURLToPath(urlOrPath) : urlOrPath) : urlOrPath;
741942
+ var toAbsolutePath = (urlOrPath) => urlOrPath ? path49.resolve(isUrl(urlOrPath) ? url2.fileURLToPath(urlOrPath) : urlOrPath) : urlOrPath;
741658
741943
  function partition2(array22, predicate) {
741659
741944
  const result = [[], []];
741660
741945
  for (const value2 of array22) {
@@ -741777,7 +742062,7 @@ async function findProjectRoot(startDirectory, options8) {
741777
742062
  const directory = await searcher.search(startDirectory, {
741778
742063
  cache: options8.shouldCache
741779
742064
  });
741780
- return directory ? path49.dirname(directory) : void 0;
742065
+ return directory ? path410.dirname(directory) : void 0;
741781
742066
  }
741782
742067
  function clearFindProjectRootCache() {
741783
742068
  searcher?.clearCache();
@@ -743827,7 +744112,7 @@ var parseYaml;
743827
744112
  async function loadYaml(file2) {
743828
744113
  const content2 = await read_file_default(file2);
743829
744114
  if (!parseYaml) {
743830
- ({ __parsePrettierYamlConfig: parseYaml } = await import("./yaml-RVRXF4QM.js"));
744115
+ ({ __parsePrettierYamlConfig: parseYaml } = await import("./yaml-OVN7LRUL.js"));
743831
744116
  }
743832
744117
  try {
743833
744118
  return parseYaml(content2);
@@ -749221,7 +749506,7 @@ function createParsersAndPrinters(modules) {
749221
749506
  }
749222
749507
  var estreePlugin = createParsersAndPrinters([
749223
749508
  {
749224
- importPlugin: () => import("./estree-7SXRLI5I.js"),
749509
+ importPlugin: () => import("./estree-ADKPQFNO.js"),
749225
749510
  printers: ["estree", "estree-json"]
749226
749511
  }
749227
749512
  ]);
@@ -749245,11 +749530,11 @@ var languages = [
749245
749530
  ];
749246
749531
  var { parsers, printers } = createParsersAndPrinters([
749247
749532
  {
749248
- importPlugin: () => import("./acorn-QNZSI57H.js"),
749533
+ importPlugin: () => import("./acorn-EJA5B7FP.js"),
749249
749534
  parsers: ["acorn", "espree"]
749250
749535
  },
749251
749536
  {
749252
- importPlugin: () => import("./angular-7GLMKT4B.js"),
749537
+ importPlugin: () => import("./angular-QQ2WOG6C.js"),
749253
749538
  parsers: [
749254
749539
  "__ng_action",
749255
749540
  "__ng_binding",
@@ -749258,7 +749543,7 @@ var { parsers, printers } = createParsersAndPrinters([
749258
749543
  ]
749259
749544
  },
749260
749545
  {
749261
- importPlugin: () => import("./babel-XQ6PH5O6.js"),
749546
+ importPlugin: () => import("./babel-NVPZF666.js"),
749262
749547
  parsers: [
749263
749548
  "babel",
749264
749549
  "babel-flow",
@@ -749277,44 +749562,44 @@ var { parsers, printers } = createParsersAndPrinters([
749277
749562
  ]
749278
749563
  },
749279
749564
  {
749280
- importPlugin: () => import("./flow-CVSSBGEP.js"),
749565
+ importPlugin: () => import("./flow-V6WNZYJM.js"),
749281
749566
  parsers: ["flow"]
749282
749567
  },
749283
749568
  {
749284
- importPlugin: () => import("./glimmer-5GCQJXOY.js"),
749569
+ importPlugin: () => import("./glimmer-DHGQ6PNF.js"),
749285
749570
  parsers: ["glimmer"],
749286
749571
  printers: ["glimmer"]
749287
749572
  },
749288
749573
  {
749289
- importPlugin: () => import("./graphql-3HSRKBX7.js"),
749574
+ importPlugin: () => import("./graphql-H56NIUJ6.js"),
749290
749575
  parsers: ["graphql"],
749291
749576
  printers: ["graphql"]
749292
749577
  },
749293
749578
  {
749294
- importPlugin: () => import("./html-IQZPOTBM.js"),
749579
+ importPlugin: () => import("./html-SH62JMIZ.js"),
749295
749580
  parsers: ["html", "angular", "vue", "lwc", "mjml"],
749296
749581
  printers: ["html"]
749297
749582
  },
749298
749583
  {
749299
- importPlugin: () => import("./markdown-O5SQIL7M.js"),
749584
+ importPlugin: () => import("./markdown-FAL4TQWL.js"),
749300
749585
  parsers: ["markdown", "mdx", "remark"],
749301
749586
  printers: ["mdast"]
749302
749587
  },
749303
749588
  {
749304
- importPlugin: () => import("./meriyah-T32DYUAK.js"),
749589
+ importPlugin: () => import("./meriyah-L75AUO6W.js"),
749305
749590
  parsers: ["meriyah"]
749306
749591
  },
749307
749592
  {
749308
- importPlugin: () => import("./postcss-AJG6TRN6.js"),
749593
+ importPlugin: () => import("./postcss-545WOE37.js"),
749309
749594
  parsers: ["css", "less", "scss"],
749310
749595
  printers: ["postcss"]
749311
749596
  },
749312
749597
  {
749313
- importPlugin: () => import("./typescript-RFGACGWX.js"),
749598
+ importPlugin: () => import("./typescript-OIYGWQQM.js"),
749314
749599
  parsers: ["typescript"]
749315
749600
  },
749316
749601
  {
749317
- importPlugin: () => import("./yaml-RVRXF4QM.js"),
749602
+ importPlugin: () => import("./yaml-OVN7LRUL.js"),
749318
749603
  parsers: ["yaml"],
749319
749604
  printers: ["yaml"]
749320
749605
  }
@@ -764943,7 +765228,7 @@ async function handleLockConflict(error40, lockSvc, span, logger12) {
764943
765228
  }
764944
765229
  async function readPkgJson(cwd) {
764945
765230
  try {
764946
- const { readPackage } = await import("./read-pkg-A6FS4QAJ.js");
765231
+ const { readPackage } = await import("./read-pkg-2KLNX5TL.js");
764947
765232
  return await readPackage({ cwd });
764948
765233
  } catch {
764949
765234
  return null;
@@ -766080,7 +766365,7 @@ async function createPrompt(options8, settings) {
766080
766365
  enquirer3 = settings.enquirer;
766081
766366
  } else {
766082
766367
  try {
766083
- enquirer3 = await import("./enquirer-QUEJAKCK.js").then((imported) => imported.default ? new imported.default() : new imported());
766368
+ enquirer3 = await import("./enquirer-J65AFP3I.js").then((imported) => imported.default ? new imported.default() : new imported());
766084
766369
  } catch (e) {
766085
766370
  if (this instanceof TaskWrapper) {
766086
766371
  this.task.prompt = new PromptError("Enquirer is a peer dependency that must be installed separately.");
@@ -766288,9 +766573,9 @@ var _DefaultRenderer = class {
766288
766573
  return typeof bottomBar === "number" && bottomBar !== 0 || typeof bottomBar === "boolean" && bottomBar !== false || !task.hasTitle();
766289
766574
  }
766290
766575
  async render() {
766291
- const { createLogUpdate } = await import("./log-update-WREO4XZW.js");
766292
- const { default: truncate } = await import("./cli-truncate-U6OXMKNW.js");
766293
- const { default: wrap2 } = await import("./wrap-ansi-4CW7YZCW.js");
766576
+ const { createLogUpdate } = await import("./log-update-ZA35WCU2.js");
766577
+ const { default: truncate } = await import("./cli-truncate-U73CWGQU.js");
766578
+ const { default: wrap2 } = await import("./wrap-ansi-FLLI5RM7.js");
766294
766579
  this.updater = createLogUpdate(this.logger.process.stdout);
766295
766580
  this.truncate = truncate;
766296
766581
  this.wrap = wrap2;