@squadbase/vite-server 0.1.17-dev.24af54e → 0.1.17-dev.3b633bb

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