@squadbase/vite-server 0.1.17-dev.24af54e → 0.1.17-dev.7408ec4

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 (73) hide show
  1. package/dist/cli/index.js +1682 -425
  2. package/dist/connectors/airtable-oauth.js +22 -3
  3. package/dist/connectors/airtable.js +22 -3
  4. package/dist/connectors/amplitude.js +22 -3
  5. package/dist/connectors/asana.js +22 -3
  6. package/dist/connectors/attio.js +22 -3
  7. package/dist/connectors/aws-billing.js +22 -3
  8. package/dist/connectors/azure-sql.js +25 -6
  9. package/dist/connectors/backlog-api-key.js +22 -3
  10. package/dist/connectors/clickup.js +22 -3
  11. package/dist/connectors/cosmosdb.js +22 -3
  12. package/dist/connectors/customerio.js +23 -4
  13. package/dist/connectors/dbt.js +22 -3
  14. package/dist/connectors/freshdesk.js +22 -3
  15. package/dist/connectors/freshsales.js +22 -3
  16. package/dist/connectors/freshservice.js +22 -3
  17. package/dist/connectors/gamma.js +24 -5
  18. package/dist/connectors/github.js +22 -3
  19. package/dist/connectors/gmail-oauth.js +22 -3
  20. package/dist/connectors/gmail.js +22 -3
  21. package/dist/connectors/google-ads.js +22 -3
  22. package/dist/connectors/google-analytics-oauth.js +22 -3
  23. package/dist/connectors/google-analytics.js +222 -68
  24. package/dist/connectors/google-audit-log.js +22 -3
  25. package/dist/connectors/google-calendar-oauth.js +22 -3
  26. package/dist/connectors/google-calendar.js +22 -3
  27. package/dist/connectors/google-docs.js +22 -3
  28. package/dist/connectors/google-drive.js +22 -3
  29. package/dist/connectors/google-search-console-oauth.js +22 -3
  30. package/dist/connectors/google-sheets.js +22 -3
  31. package/dist/connectors/google-slides.js +22 -3
  32. package/dist/connectors/grafana.js +22 -3
  33. package/dist/connectors/hubspot-oauth.js +22 -3
  34. package/dist/connectors/hubspot.js +22 -3
  35. package/dist/connectors/influxdb.js +22 -3
  36. package/dist/connectors/intercom-oauth.js +22 -3
  37. package/dist/connectors/intercom.js +22 -3
  38. package/dist/connectors/jdbc.js +22 -3
  39. package/dist/connectors/jira-api-key.js +22 -3
  40. package/dist/connectors/kintone-api-token.js +22 -3
  41. package/dist/connectors/kintone.js +22 -3
  42. package/dist/connectors/linear.js +22 -3
  43. package/dist/connectors/linkedin-ads.js +22 -3
  44. package/dist/connectors/mailchimp-oauth.js +22 -3
  45. package/dist/connectors/mailchimp.js +22 -3
  46. package/dist/connectors/meta-ads-oauth.js +22 -3
  47. package/dist/connectors/meta-ads.js +22 -3
  48. package/dist/connectors/mixpanel.js +22 -3
  49. package/dist/connectors/monday.js +22 -3
  50. package/dist/connectors/mongodb.js +22 -3
  51. package/dist/connectors/notion-oauth.js +22 -3
  52. package/dist/connectors/notion.js +22 -3
  53. package/dist/connectors/oracle.js +48 -14
  54. package/dist/connectors/outlook-oauth.js +22 -3
  55. package/dist/connectors/powerbi-oauth.js +303 -37
  56. package/dist/connectors/salesforce.js +22 -3
  57. package/dist/connectors/semrush.js +360 -46
  58. package/dist/connectors/sentry.js +22 -3
  59. package/dist/connectors/shopify-oauth.js +22 -3
  60. package/dist/connectors/shopify.js +22 -3
  61. package/dist/connectors/sqlserver.js +25 -6
  62. package/dist/connectors/stripe-api-key.js +22 -3
  63. package/dist/connectors/stripe-oauth.js +22 -3
  64. package/dist/connectors/supabase.js +25 -6
  65. package/dist/connectors/tableau.js +240 -78
  66. package/dist/connectors/tiktok-ads.js +22 -3
  67. package/dist/connectors/wix-store.js +22 -3
  68. package/dist/connectors/zendesk-oauth.js +22 -3
  69. package/dist/connectors/zendesk.js +22 -3
  70. package/dist/index.js +1682 -425
  71. package/dist/main.js +1682 -425
  72. package/dist/vite-plugin.js +1682 -425
  73. package/package.json +1 -1
@@ -251,19 +251,28 @@ async function runSetupFlow(flow, params, ctx, config) {
251
251
  };
252
252
  let state = flow.initialState();
253
253
  let answerIdx = 0;
254
+ const pendingParameterUpdates = [];
254
255
  for (const step of flow.steps) {
255
256
  const ans = ctx.answers[answerIdx];
256
257
  if (ans && ans.questionSlug === step.slug) {
257
258
  state = step.applyAnswer(state, ans.answer);
259
+ if (step.toParameterUpdates) {
260
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
261
+ }
258
262
  answerIdx += 1;
259
263
  continue;
260
264
  }
265
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
261
266
  if (step.type === "text") {
262
267
  return {
263
268
  type: "nextQuestion",
264
269
  questionSlug: step.slug,
265
270
  question: step.question[ctx.language],
266
- questionType: "text"
271
+ questionType: "text",
272
+ allowFreeText: resolvedAllowFreeText,
273
+ ...pendingParameterUpdates.length > 0 && {
274
+ parameterUpdates: pendingParameterUpdates
275
+ }
267
276
  };
268
277
  }
269
278
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -275,11 +284,21 @@ async function runSetupFlow(flow, params, ctx, config) {
275
284
  questionSlug: step.slug,
276
285
  question: step.question[ctx.language],
277
286
  questionType: step.type,
278
- options
287
+ options,
288
+ allowFreeText: resolvedAllowFreeText,
289
+ ...pendingParameterUpdates.length > 0 && {
290
+ parameterUpdates: pendingParameterUpdates
291
+ }
279
292
  };
280
293
  }
281
294
  const dataInvestigationResult = await flow.finalize(state, runtime);
282
- return { type: "fulfilled", dataInvestigationResult };
295
+ return {
296
+ type: "fulfilled",
297
+ dataInvestigationResult,
298
+ ...pendingParameterUpdates.length > 0 && {
299
+ parameterUpdates: pendingParameterUpdates
300
+ }
301
+ };
283
302
  }
284
303
  async function resolveSetupSelection(params) {
285
304
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -381,19 +381,28 @@ async function runSetupFlow(flow, params, ctx, config) {
381
381
  };
382
382
  let state = flow.initialState();
383
383
  let answerIdx = 0;
384
+ const pendingParameterUpdates = [];
384
385
  for (const step of flow.steps) {
385
386
  const ans = ctx.answers[answerIdx];
386
387
  if (ans && ans.questionSlug === step.slug) {
387
388
  state = step.applyAnswer(state, ans.answer);
389
+ if (step.toParameterUpdates) {
390
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
391
+ }
388
392
  answerIdx += 1;
389
393
  continue;
390
394
  }
395
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
391
396
  if (step.type === "text") {
392
397
  return {
393
398
  type: "nextQuestion",
394
399
  questionSlug: step.slug,
395
400
  question: step.question[ctx.language],
396
- questionType: "text"
401
+ questionType: "text",
402
+ allowFreeText: resolvedAllowFreeText,
403
+ ...pendingParameterUpdates.length > 0 && {
404
+ parameterUpdates: pendingParameterUpdates
405
+ }
397
406
  };
398
407
  }
399
408
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -405,11 +414,21 @@ async function runSetupFlow(flow, params, ctx, config) {
405
414
  questionSlug: step.slug,
406
415
  question: step.question[ctx.language],
407
416
  questionType: step.type,
408
- options
417
+ options,
418
+ allowFreeText: resolvedAllowFreeText,
419
+ ...pendingParameterUpdates.length > 0 && {
420
+ parameterUpdates: pendingParameterUpdates
421
+ }
409
422
  };
410
423
  }
411
424
  const dataInvestigationResult = await flow.finalize(state, runtime);
412
- return { type: "fulfilled", dataInvestigationResult };
425
+ return {
426
+ type: "fulfilled",
427
+ dataInvestigationResult,
428
+ ...pendingParameterUpdates.length > 0 && {
429
+ parameterUpdates: pendingParameterUpdates
430
+ }
431
+ };
413
432
  }
414
433
  async function resolveSetupSelection(params) {
415
434
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -341,19 +341,28 @@ async function runSetupFlow(flow, params, ctx, config) {
341
341
  };
342
342
  let state = flow.initialState();
343
343
  let answerIdx = 0;
344
+ const pendingParameterUpdates = [];
344
345
  for (const step of flow.steps) {
345
346
  const ans = ctx.answers[answerIdx];
346
347
  if (ans && ans.questionSlug === step.slug) {
347
348
  state = step.applyAnswer(state, ans.answer);
349
+ if (step.toParameterUpdates) {
350
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
351
+ }
348
352
  answerIdx += 1;
349
353
  continue;
350
354
  }
355
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
351
356
  if (step.type === "text") {
352
357
  return {
353
358
  type: "nextQuestion",
354
359
  questionSlug: step.slug,
355
360
  question: step.question[ctx.language],
356
- questionType: "text"
361
+ questionType: "text",
362
+ allowFreeText: resolvedAllowFreeText,
363
+ ...pendingParameterUpdates.length > 0 && {
364
+ parameterUpdates: pendingParameterUpdates
365
+ }
357
366
  };
358
367
  }
359
368
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -365,11 +374,21 @@ async function runSetupFlow(flow, params, ctx, config) {
365
374
  questionSlug: step.slug,
366
375
  question: step.question[ctx.language],
367
376
  questionType: step.type,
368
- options
377
+ options,
378
+ allowFreeText: resolvedAllowFreeText,
379
+ ...pendingParameterUpdates.length > 0 && {
380
+ parameterUpdates: pendingParameterUpdates
381
+ }
369
382
  };
370
383
  }
371
384
  const dataInvestigationResult = await flow.finalize(state, runtime);
372
- return { type: "fulfilled", dataInvestigationResult };
385
+ return {
386
+ type: "fulfilled",
387
+ dataInvestigationResult,
388
+ ...pendingParameterUpdates.length > 0 && {
389
+ parameterUpdates: pendingParameterUpdates
390
+ }
391
+ };
373
392
  }
374
393
 
375
394
  // ../connectors/src/auth-types.ts
@@ -378,19 +378,28 @@ async function runSetupFlow(flow, params, ctx, config) {
378
378
  };
379
379
  let state = flow.initialState();
380
380
  let answerIdx = 0;
381
+ const pendingParameterUpdates = [];
381
382
  for (const step of flow.steps) {
382
383
  const ans = ctx.answers[answerIdx];
383
384
  if (ans && ans.questionSlug === step.slug) {
384
385
  state = step.applyAnswer(state, ans.answer);
386
+ if (step.toParameterUpdates) {
387
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
388
+ }
385
389
  answerIdx += 1;
386
390
  continue;
387
391
  }
392
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
388
393
  if (step.type === "text") {
389
394
  return {
390
395
  type: "nextQuestion",
391
396
  questionSlug: step.slug,
392
397
  question: step.question[ctx.language],
393
- questionType: "text"
398
+ questionType: "text",
399
+ allowFreeText: resolvedAllowFreeText,
400
+ ...pendingParameterUpdates.length > 0 && {
401
+ parameterUpdates: pendingParameterUpdates
402
+ }
394
403
  };
395
404
  }
396
405
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -402,11 +411,21 @@ async function runSetupFlow(flow, params, ctx, config) {
402
411
  questionSlug: step.slug,
403
412
  question: step.question[ctx.language],
404
413
  questionType: step.type,
405
- options
414
+ options,
415
+ allowFreeText: resolvedAllowFreeText,
416
+ ...pendingParameterUpdates.length > 0 && {
417
+ parameterUpdates: pendingParameterUpdates
418
+ }
406
419
  };
407
420
  }
408
421
  const dataInvestigationResult = await flow.finalize(state, runtime);
409
- return { type: "fulfilled", dataInvestigationResult };
422
+ return {
423
+ type: "fulfilled",
424
+ dataInvestigationResult,
425
+ ...pendingParameterUpdates.length > 0 && {
426
+ parameterUpdates: pendingParameterUpdates
427
+ }
428
+ };
410
429
  }
411
430
  async function resolveSetupSelection(params) {
412
431
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -514,19 +514,28 @@ async function runSetupFlow(flow, params, ctx, config) {
514
514
  };
515
515
  let state = flow.initialState();
516
516
  let answerIdx = 0;
517
+ const pendingParameterUpdates = [];
517
518
  for (const step of flow.steps) {
518
519
  const ans = ctx.answers[answerIdx];
519
520
  if (ans && ans.questionSlug === step.slug) {
520
521
  state = step.applyAnswer(state, ans.answer);
522
+ if (step.toParameterUpdates) {
523
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
524
+ }
521
525
  answerIdx += 1;
522
526
  continue;
523
527
  }
528
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
524
529
  if (step.type === "text") {
525
530
  return {
526
531
  type: "nextQuestion",
527
532
  questionSlug: step.slug,
528
533
  question: step.question[ctx.language],
529
- questionType: "text"
534
+ questionType: "text",
535
+ allowFreeText: resolvedAllowFreeText,
536
+ ...pendingParameterUpdates.length > 0 && {
537
+ parameterUpdates: pendingParameterUpdates
538
+ }
530
539
  };
531
540
  }
532
541
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -538,11 +547,21 @@ async function runSetupFlow(flow, params, ctx, config) {
538
547
  questionSlug: step.slug,
539
548
  question: step.question[ctx.language],
540
549
  questionType: step.type,
541
- options
550
+ options,
551
+ allowFreeText: resolvedAllowFreeText,
552
+ ...pendingParameterUpdates.length > 0 && {
553
+ parameterUpdates: pendingParameterUpdates
554
+ }
542
555
  };
543
556
  }
544
557
  const dataInvestigationResult = await flow.finalize(state, runtime);
545
- return { type: "fulfilled", dataInvestigationResult };
558
+ return {
559
+ type: "fulfilled",
560
+ dataInvestigationResult,
561
+ ...pendingParameterUpdates.length > 0 && {
562
+ parameterUpdates: pendingParameterUpdates
563
+ }
564
+ };
546
565
  }
547
566
  async function resolveSetupSelection(params) {
548
567
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -280,19 +280,28 @@ async function runSetupFlow(flow, params, ctx, config) {
280
280
  };
281
281
  let state = flow.initialState();
282
282
  let answerIdx = 0;
283
+ const pendingParameterUpdates = [];
283
284
  for (const step of flow.steps) {
284
285
  const ans = ctx.answers[answerIdx];
285
286
  if (ans && ans.questionSlug === step.slug) {
286
287
  state = step.applyAnswer(state, ans.answer);
288
+ if (step.toParameterUpdates) {
289
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
290
+ }
287
291
  answerIdx += 1;
288
292
  continue;
289
293
  }
294
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
290
295
  if (step.type === "text") {
291
296
  return {
292
297
  type: "nextQuestion",
293
298
  questionSlug: step.slug,
294
299
  question: step.question[ctx.language],
295
- questionType: "text"
300
+ questionType: "text",
301
+ allowFreeText: resolvedAllowFreeText,
302
+ ...pendingParameterUpdates.length > 0 && {
303
+ parameterUpdates: pendingParameterUpdates
304
+ }
296
305
  };
297
306
  }
298
307
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -304,11 +313,21 @@ async function runSetupFlow(flow, params, ctx, config) {
304
313
  questionSlug: step.slug,
305
314
  question: step.question[ctx.language],
306
315
  questionType: step.type,
307
- options
316
+ options,
317
+ allowFreeText: resolvedAllowFreeText,
318
+ ...pendingParameterUpdates.length > 0 && {
319
+ parameterUpdates: pendingParameterUpdates
320
+ }
308
321
  };
309
322
  }
310
323
  const dataInvestigationResult = await flow.finalize(state, runtime);
311
- return { type: "fulfilled", dataInvestigationResult };
324
+ return {
325
+ type: "fulfilled",
326
+ dataInvestigationResult,
327
+ ...pendingParameterUpdates.length > 0 && {
328
+ parameterUpdates: pendingParameterUpdates
329
+ }
330
+ };
312
331
  }
313
332
  async function resolveSetupSelection(params) {
314
333
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -577,19 +577,28 @@ async function runSetupFlow(flow, params, ctx, config) {
577
577
  };
578
578
  let state = flow.initialState();
579
579
  let answerIdx = 0;
580
+ const pendingParameterUpdates = [];
580
581
  for (const step of flow.steps) {
581
582
  const ans = ctx.answers[answerIdx];
582
583
  if (ans && ans.questionSlug === step.slug) {
583
584
  state = step.applyAnswer(state, ans.answer);
585
+ if (step.toParameterUpdates) {
586
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
587
+ }
584
588
  answerIdx += 1;
585
589
  continue;
586
590
  }
591
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
587
592
  if (step.type === "text") {
588
593
  return {
589
594
  type: "nextQuestion",
590
595
  questionSlug: step.slug,
591
596
  question: step.question[ctx.language],
592
- questionType: "text"
597
+ questionType: "text",
598
+ allowFreeText: resolvedAllowFreeText,
599
+ ...pendingParameterUpdates.length > 0 && {
600
+ parameterUpdates: pendingParameterUpdates
601
+ }
593
602
  };
594
603
  }
595
604
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -601,11 +610,21 @@ async function runSetupFlow(flow, params, ctx, config) {
601
610
  questionSlug: step.slug,
602
611
  question: step.question[ctx.language],
603
612
  questionType: step.type,
604
- options
613
+ options,
614
+ allowFreeText: resolvedAllowFreeText,
615
+ ...pendingParameterUpdates.length > 0 && {
616
+ parameterUpdates: pendingParameterUpdates
617
+ }
605
618
  };
606
619
  }
607
620
  const dataInvestigationResult = await flow.finalize(state, runtime);
608
- return { type: "fulfilled", dataInvestigationResult };
621
+ return {
622
+ type: "fulfilled",
623
+ dataInvestigationResult,
624
+ ...pendingParameterUpdates.length > 0 && {
625
+ parameterUpdates: pendingParameterUpdates
626
+ }
627
+ };
609
628
  }
610
629
  async function resolveSetupSelection(params) {
611
630
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -700,8 +719,8 @@ function buildFlow(options) {
700
719
  slug: "tables",
701
720
  type: "multiSelect",
702
721
  question: {
703
- ja: "\u5BFE\u8C61\u30C6\u30FC\u30D6\u30EB\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
704
- en: "Select target tables (multi-select allowed)"
722
+ ja: "\u5BFE\u8C61\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
723
+ en: "Select target tables and views (multi-select allowed)"
705
724
  },
706
725
  async fetchOptions(state, rt) {
707
726
  if (!state.schema) return [];
@@ -710,7 +729,7 @@ function buildFlow(options) {
710
729
  return [
711
730
  {
712
731
  value: ALL_TABLES,
713
- label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C6\u30FC\u30D6\u30EB" : "All tables"
732
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC" : "All tables and views"
714
733
  },
715
734
  ...tableOptions
716
735
  ];
@@ -276,19 +276,28 @@ async function runSetupFlow(flow, params, ctx, config) {
276
276
  };
277
277
  let state = flow.initialState();
278
278
  let answerIdx = 0;
279
+ const pendingParameterUpdates = [];
279
280
  for (const step of flow.steps) {
280
281
  const ans = ctx.answers[answerIdx];
281
282
  if (ans && ans.questionSlug === step.slug) {
282
283
  state = step.applyAnswer(state, ans.answer);
284
+ if (step.toParameterUpdates) {
285
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
286
+ }
283
287
  answerIdx += 1;
284
288
  continue;
285
289
  }
290
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
286
291
  if (step.type === "text") {
287
292
  return {
288
293
  type: "nextQuestion",
289
294
  questionSlug: step.slug,
290
295
  question: step.question[ctx.language],
291
- questionType: "text"
296
+ questionType: "text",
297
+ allowFreeText: resolvedAllowFreeText,
298
+ ...pendingParameterUpdates.length > 0 && {
299
+ parameterUpdates: pendingParameterUpdates
300
+ }
292
301
  };
293
302
  }
294
303
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -300,11 +309,21 @@ async function runSetupFlow(flow, params, ctx, config) {
300
309
  questionSlug: step.slug,
301
310
  question: step.question[ctx.language],
302
311
  questionType: step.type,
303
- options
312
+ options,
313
+ allowFreeText: resolvedAllowFreeText,
314
+ ...pendingParameterUpdates.length > 0 && {
315
+ parameterUpdates: pendingParameterUpdates
316
+ }
304
317
  };
305
318
  }
306
319
  const dataInvestigationResult = await flow.finalize(state, runtime);
307
- return { type: "fulfilled", dataInvestigationResult };
320
+ return {
321
+ type: "fulfilled",
322
+ dataInvestigationResult,
323
+ ...pendingParameterUpdates.length > 0 && {
324
+ parameterUpdates: pendingParameterUpdates
325
+ }
326
+ };
308
327
  }
309
328
  async function resolveSetupSelection(params) {
310
329
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -412,19 +412,28 @@ async function runSetupFlow(flow, params, ctx, config) {
412
412
  };
413
413
  let state = flow.initialState();
414
414
  let answerIdx = 0;
415
+ const pendingParameterUpdates = [];
415
416
  for (const step of flow.steps) {
416
417
  const ans = ctx.answers[answerIdx];
417
418
  if (ans && ans.questionSlug === step.slug) {
418
419
  state = step.applyAnswer(state, ans.answer);
420
+ if (step.toParameterUpdates) {
421
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
422
+ }
419
423
  answerIdx += 1;
420
424
  continue;
421
425
  }
426
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
422
427
  if (step.type === "text") {
423
428
  return {
424
429
  type: "nextQuestion",
425
430
  questionSlug: step.slug,
426
431
  question: step.question[ctx.language],
427
- questionType: "text"
432
+ questionType: "text",
433
+ allowFreeText: resolvedAllowFreeText,
434
+ ...pendingParameterUpdates.length > 0 && {
435
+ parameterUpdates: pendingParameterUpdates
436
+ }
428
437
  };
429
438
  }
430
439
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -436,11 +445,21 @@ async function runSetupFlow(flow, params, ctx, config) {
436
445
  questionSlug: step.slug,
437
446
  question: step.question[ctx.language],
438
447
  questionType: step.type,
439
- options
448
+ options,
449
+ allowFreeText: resolvedAllowFreeText,
450
+ ...pendingParameterUpdates.length > 0 && {
451
+ parameterUpdates: pendingParameterUpdates
452
+ }
440
453
  };
441
454
  }
442
455
  const dataInvestigationResult = await flow.finalize(state, runtime);
443
- return { type: "fulfilled", dataInvestigationResult };
456
+ return {
457
+ type: "fulfilled",
458
+ dataInvestigationResult,
459
+ ...pendingParameterUpdates.length > 0 && {
460
+ parameterUpdates: pendingParameterUpdates
461
+ }
462
+ };
444
463
  }
445
464
  async function resolveSetupSelection(params) {
446
465
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -322,19 +322,28 @@ async function runSetupFlow(flow, params, ctx, config) {
322
322
  };
323
323
  let state = flow.initialState();
324
324
  let answerIdx = 0;
325
+ const pendingParameterUpdates = [];
325
326
  for (const step of flow.steps) {
326
327
  const ans = ctx.answers[answerIdx];
327
328
  if (ans && ans.questionSlug === step.slug) {
328
329
  state = step.applyAnswer(state, ans.answer);
330
+ if (step.toParameterUpdates) {
331
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
332
+ }
329
333
  answerIdx += 1;
330
334
  continue;
331
335
  }
336
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
332
337
  if (step.type === "text") {
333
338
  return {
334
339
  type: "nextQuestion",
335
340
  questionSlug: step.slug,
336
341
  question: step.question[ctx.language],
337
- questionType: "text"
342
+ questionType: "text",
343
+ allowFreeText: resolvedAllowFreeText,
344
+ ...pendingParameterUpdates.length > 0 && {
345
+ parameterUpdates: pendingParameterUpdates
346
+ }
338
347
  };
339
348
  }
340
349
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -346,11 +355,21 @@ async function runSetupFlow(flow, params, ctx, config) {
346
355
  questionSlug: step.slug,
347
356
  question: step.question[ctx.language],
348
357
  questionType: step.type,
349
- options
358
+ options,
359
+ allowFreeText: resolvedAllowFreeText,
360
+ ...pendingParameterUpdates.length > 0 && {
361
+ parameterUpdates: pendingParameterUpdates
362
+ }
350
363
  };
351
364
  }
352
365
  const dataInvestigationResult = await flow.finalize(state, runtime);
353
- return { type: "fulfilled", dataInvestigationResult };
366
+ return {
367
+ type: "fulfilled",
368
+ dataInvestigationResult,
369
+ ...pendingParameterUpdates.length > 0 && {
370
+ parameterUpdates: pendingParameterUpdates
371
+ }
372
+ };
354
373
  }
355
374
  async function resolveSetupSelection(params) {
356
375
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -359,19 +359,28 @@ async function runSetupFlow(flow, params, ctx, config) {
359
359
  };
360
360
  let state = flow.initialState();
361
361
  let answerIdx = 0;
362
+ const pendingParameterUpdates = [];
362
363
  for (const step of flow.steps) {
363
364
  const ans = ctx.answers[answerIdx];
364
365
  if (ans && ans.questionSlug === step.slug) {
365
366
  state = step.applyAnswer(state, ans.answer);
367
+ if (step.toParameterUpdates) {
368
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
369
+ }
366
370
  answerIdx += 1;
367
371
  continue;
368
372
  }
373
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
369
374
  if (step.type === "text") {
370
375
  return {
371
376
  type: "nextQuestion",
372
377
  questionSlug: step.slug,
373
378
  question: step.question[ctx.language],
374
- questionType: "text"
379
+ questionType: "text",
380
+ allowFreeText: resolvedAllowFreeText,
381
+ ...pendingParameterUpdates.length > 0 && {
382
+ parameterUpdates: pendingParameterUpdates
383
+ }
375
384
  };
376
385
  }
377
386
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -383,11 +392,21 @@ async function runSetupFlow(flow, params, ctx, config) {
383
392
  questionSlug: step.slug,
384
393
  question: step.question[ctx.language],
385
394
  questionType: step.type,
386
- options
395
+ options,
396
+ allowFreeText: resolvedAllowFreeText,
397
+ ...pendingParameterUpdates.length > 0 && {
398
+ parameterUpdates: pendingParameterUpdates
399
+ }
387
400
  };
388
401
  }
389
402
  const dataInvestigationResult = await flow.finalize(state, runtime);
390
- return { type: "fulfilled", dataInvestigationResult };
403
+ return {
404
+ type: "fulfilled",
405
+ dataInvestigationResult,
406
+ ...pendingParameterUpdates.length > 0 && {
407
+ parameterUpdates: pendingParameterUpdates
408
+ }
409
+ };
391
410
  }
392
411
 
393
412
  // ../connectors/src/auth-types.ts
@@ -820,7 +839,7 @@ export default async function handler(c: Context) {
820
839
  const region = params[parameters.region.slug];
821
840
  const baseUrl = region === "eu" ? "https://api-eu.customer.io" : "https://api.customer.io";
822
841
  try {
823
- const res = await fetch(`${baseUrl}/v1/accounts/region`, {
842
+ const res = await fetch(`${baseUrl}/v1/segments`, {
824
843
  method: "GET",
825
844
  headers: {
826
845
  Authorization: `Bearer ${appApiKey}`,
@@ -501,19 +501,28 @@ async function runSetupFlow(flow, params, ctx, config) {
501
501
  };
502
502
  let state = flow.initialState();
503
503
  let answerIdx = 0;
504
+ const pendingParameterUpdates = [];
504
505
  for (const step of flow.steps) {
505
506
  const ans = ctx.answers[answerIdx];
506
507
  if (ans && ans.questionSlug === step.slug) {
507
508
  state = step.applyAnswer(state, ans.answer);
509
+ if (step.toParameterUpdates) {
510
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
511
+ }
508
512
  answerIdx += 1;
509
513
  continue;
510
514
  }
515
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
511
516
  if (step.type === "text") {
512
517
  return {
513
518
  type: "nextQuestion",
514
519
  questionSlug: step.slug,
515
520
  question: step.question[ctx.language],
516
- questionType: "text"
521
+ questionType: "text",
522
+ allowFreeText: resolvedAllowFreeText,
523
+ ...pendingParameterUpdates.length > 0 && {
524
+ parameterUpdates: pendingParameterUpdates
525
+ }
517
526
  };
518
527
  }
519
528
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -525,11 +534,21 @@ async function runSetupFlow(flow, params, ctx, config) {
525
534
  questionSlug: step.slug,
526
535
  question: step.question[ctx.language],
527
536
  questionType: step.type,
528
- options
537
+ options,
538
+ allowFreeText: resolvedAllowFreeText,
539
+ ...pendingParameterUpdates.length > 0 && {
540
+ parameterUpdates: pendingParameterUpdates
541
+ }
529
542
  };
530
543
  }
531
544
  const dataInvestigationResult = await flow.finalize(state, runtime);
532
- return { type: "fulfilled", dataInvestigationResult };
545
+ return {
546
+ type: "fulfilled",
547
+ dataInvestigationResult,
548
+ ...pendingParameterUpdates.length > 0 && {
549
+ parameterUpdates: pendingParameterUpdates
550
+ }
551
+ };
533
552
  }
534
553
  async function resolveSetupSelection(params) {
535
554
  const { selected, allSentinel, fetchAll, limit } = params;