@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
@@ -501,19 +501,34 @@ 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") {
517
+ if (step.fetchOptions) {
518
+ const options2 = await step.fetchOptions(state, runtime);
519
+ if (options2.length === 0) {
520
+ continue;
521
+ }
522
+ }
512
523
  return {
513
524
  type: "nextQuestion",
514
525
  questionSlug: step.slug,
515
526
  question: step.question[ctx.language],
516
- questionType: "text"
527
+ questionType: "text",
528
+ allowFreeText: resolvedAllowFreeText,
529
+ ...pendingParameterUpdates.length > 0 && {
530
+ parameterUpdates: pendingParameterUpdates
531
+ }
517
532
  };
518
533
  }
519
534
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -525,11 +540,21 @@ async function runSetupFlow(flow, params, ctx, config) {
525
540
  questionSlug: step.slug,
526
541
  question: step.question[ctx.language],
527
542
  questionType: step.type,
528
- options
543
+ options,
544
+ allowFreeText: resolvedAllowFreeText,
545
+ ...pendingParameterUpdates.length > 0 && {
546
+ parameterUpdates: pendingParameterUpdates
547
+ }
529
548
  };
530
549
  }
531
550
  const dataInvestigationResult = await flow.finalize(state, runtime);
532
- return { type: "fulfilled", dataInvestigationResult };
551
+ return {
552
+ type: "fulfilled",
553
+ dataInvestigationResult,
554
+ ...pendingParameterUpdates.length > 0 && {
555
+ parameterUpdates: pendingParameterUpdates
556
+ }
557
+ };
533
558
  }
534
559
  async function resolveSetupSelection(params) {
535
560
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -409,19 +409,34 @@ async function runSetupFlow(flow, params, ctx, config) {
409
409
  };
410
410
  let state = flow.initialState();
411
411
  let answerIdx = 0;
412
+ const pendingParameterUpdates = [];
412
413
  for (const step of flow.steps) {
413
414
  const ans = ctx.answers[answerIdx];
414
415
  if (ans && ans.questionSlug === step.slug) {
415
416
  state = step.applyAnswer(state, ans.answer);
417
+ if (step.toParameterUpdates) {
418
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
419
+ }
416
420
  answerIdx += 1;
417
421
  continue;
418
422
  }
423
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
419
424
  if (step.type === "text") {
425
+ if (step.fetchOptions) {
426
+ const options2 = await step.fetchOptions(state, runtime);
427
+ if (options2.length === 0) {
428
+ continue;
429
+ }
430
+ }
420
431
  return {
421
432
  type: "nextQuestion",
422
433
  questionSlug: step.slug,
423
434
  question: step.question[ctx.language],
424
- questionType: "text"
435
+ questionType: "text",
436
+ allowFreeText: resolvedAllowFreeText,
437
+ ...pendingParameterUpdates.length > 0 && {
438
+ parameterUpdates: pendingParameterUpdates
439
+ }
425
440
  };
426
441
  }
427
442
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -433,11 +448,21 @@ async function runSetupFlow(flow, params, ctx, config) {
433
448
  questionSlug: step.slug,
434
449
  question: step.question[ctx.language],
435
450
  questionType: step.type,
436
- options
451
+ options,
452
+ allowFreeText: resolvedAllowFreeText,
453
+ ...pendingParameterUpdates.length > 0 && {
454
+ parameterUpdates: pendingParameterUpdates
455
+ }
437
456
  };
438
457
  }
439
458
  const dataInvestigationResult = await flow.finalize(state, runtime);
440
- return { type: "fulfilled", dataInvestigationResult };
459
+ return {
460
+ type: "fulfilled",
461
+ dataInvestigationResult,
462
+ ...pendingParameterUpdates.length > 0 && {
463
+ parameterUpdates: pendingParameterUpdates
464
+ }
465
+ };
441
466
  }
442
467
  async function resolveSetupSelection(params) {
443
468
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -424,19 +424,34 @@ async function runSetupFlow(flow, params, ctx, config) {
424
424
  };
425
425
  let state = flow.initialState();
426
426
  let answerIdx = 0;
427
+ const pendingParameterUpdates = [];
427
428
  for (const step of flow.steps) {
428
429
  const ans = ctx.answers[answerIdx];
429
430
  if (ans && ans.questionSlug === step.slug) {
430
431
  state = step.applyAnswer(state, ans.answer);
432
+ if (step.toParameterUpdates) {
433
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
434
+ }
431
435
  answerIdx += 1;
432
436
  continue;
433
437
  }
438
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
434
439
  if (step.type === "text") {
440
+ if (step.fetchOptions) {
441
+ const options2 = await step.fetchOptions(state, runtime);
442
+ if (options2.length === 0) {
443
+ continue;
444
+ }
445
+ }
435
446
  return {
436
447
  type: "nextQuestion",
437
448
  questionSlug: step.slug,
438
449
  question: step.question[ctx.language],
439
- questionType: "text"
450
+ questionType: "text",
451
+ allowFreeText: resolvedAllowFreeText,
452
+ ...pendingParameterUpdates.length > 0 && {
453
+ parameterUpdates: pendingParameterUpdates
454
+ }
440
455
  };
441
456
  }
442
457
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -448,11 +463,21 @@ async function runSetupFlow(flow, params, ctx, config) {
448
463
  questionSlug: step.slug,
449
464
  question: step.question[ctx.language],
450
465
  questionType: step.type,
451
- options
466
+ options,
467
+ allowFreeText: resolvedAllowFreeText,
468
+ ...pendingParameterUpdates.length > 0 && {
469
+ parameterUpdates: pendingParameterUpdates
470
+ }
452
471
  };
453
472
  }
454
473
  const dataInvestigationResult = await flow.finalize(state, runtime);
455
- return { type: "fulfilled", dataInvestigationResult };
474
+ return {
475
+ type: "fulfilled",
476
+ dataInvestigationResult,
477
+ ...pendingParameterUpdates.length > 0 && {
478
+ parameterUpdates: pendingParameterUpdates
479
+ }
480
+ };
456
481
  }
457
482
  async function resolveSetupSelection(params) {
458
483
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -379,19 +379,34 @@ async function runSetupFlow(flow, params, ctx, config) {
379
379
  };
380
380
  let state = flow.initialState();
381
381
  let answerIdx = 0;
382
+ const pendingParameterUpdates = [];
382
383
  for (const step of flow.steps) {
383
384
  const ans = ctx.answers[answerIdx];
384
385
  if (ans && ans.questionSlug === step.slug) {
385
386
  state = step.applyAnswer(state, ans.answer);
387
+ if (step.toParameterUpdates) {
388
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
389
+ }
386
390
  answerIdx += 1;
387
391
  continue;
388
392
  }
393
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
389
394
  if (step.type === "text") {
395
+ if (step.fetchOptions) {
396
+ const options2 = await step.fetchOptions(state, runtime);
397
+ if (options2.length === 0) {
398
+ continue;
399
+ }
400
+ }
390
401
  return {
391
402
  type: "nextQuestion",
392
403
  questionSlug: step.slug,
393
404
  question: step.question[ctx.language],
394
- questionType: "text"
405
+ questionType: "text",
406
+ allowFreeText: resolvedAllowFreeText,
407
+ ...pendingParameterUpdates.length > 0 && {
408
+ parameterUpdates: pendingParameterUpdates
409
+ }
395
410
  };
396
411
  }
397
412
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -403,11 +418,21 @@ async function runSetupFlow(flow, params, ctx, config) {
403
418
  questionSlug: step.slug,
404
419
  question: step.question[ctx.language],
405
420
  questionType: step.type,
406
- options
421
+ options,
422
+ allowFreeText: resolvedAllowFreeText,
423
+ ...pendingParameterUpdates.length > 0 && {
424
+ parameterUpdates: pendingParameterUpdates
425
+ }
407
426
  };
408
427
  }
409
428
  const dataInvestigationResult = await flow.finalize(state, runtime);
410
- return { type: "fulfilled", dataInvestigationResult };
429
+ return {
430
+ type: "fulfilled",
431
+ dataInvestigationResult,
432
+ ...pendingParameterUpdates.length > 0 && {
433
+ parameterUpdates: pendingParameterUpdates
434
+ }
435
+ };
411
436
  }
412
437
  async function resolveSetupSelection(params) {
413
438
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -335,19 +335,34 @@ async function runSetupFlow(flow, params, ctx, config) {
335
335
  };
336
336
  let state = flow.initialState();
337
337
  let answerIdx = 0;
338
+ const pendingParameterUpdates = [];
338
339
  for (const step of flow.steps) {
339
340
  const ans = ctx.answers[answerIdx];
340
341
  if (ans && ans.questionSlug === step.slug) {
341
342
  state = step.applyAnswer(state, ans.answer);
343
+ if (step.toParameterUpdates) {
344
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
345
+ }
342
346
  answerIdx += 1;
343
347
  continue;
344
348
  }
349
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
345
350
  if (step.type === "text") {
351
+ if (step.fetchOptions) {
352
+ const options2 = await step.fetchOptions(state, runtime);
353
+ if (options2.length === 0) {
354
+ continue;
355
+ }
356
+ }
346
357
  return {
347
358
  type: "nextQuestion",
348
359
  questionSlug: step.slug,
349
360
  question: step.question[ctx.language],
350
- questionType: "text"
361
+ questionType: "text",
362
+ allowFreeText: resolvedAllowFreeText,
363
+ ...pendingParameterUpdates.length > 0 && {
364
+ parameterUpdates: pendingParameterUpdates
365
+ }
351
366
  };
352
367
  }
353
368
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -359,11 +374,21 @@ async function runSetupFlow(flow, params, ctx, config) {
359
374
  questionSlug: step.slug,
360
375
  question: step.question[ctx.language],
361
376
  questionType: step.type,
362
- options
377
+ options,
378
+ allowFreeText: resolvedAllowFreeText,
379
+ ...pendingParameterUpdates.length > 0 && {
380
+ parameterUpdates: pendingParameterUpdates
381
+ }
363
382
  };
364
383
  }
365
384
  const dataInvestigationResult = await flow.finalize(state, runtime);
366
- return { type: "fulfilled", dataInvestigationResult };
385
+ return {
386
+ type: "fulfilled",
387
+ dataInvestigationResult,
388
+ ...pendingParameterUpdates.length > 0 && {
389
+ parameterUpdates: pendingParameterUpdates
390
+ }
391
+ };
367
392
  }
368
393
  async function resolveSetupSelection(params) {
369
394
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -410,7 +435,7 @@ function apiFetch(params, path2, init) {
410
435
  // ../connectors/src/connectors/gamma/setup-flow.ts
411
436
  var ALL_FOLDERS = "__ALL_FOLDERS__";
412
437
  var GAMMA_SETUP_MAX_FOLDERS = 20;
413
- var FOLDERS_PAGE_LIMIT = 100;
438
+ var FOLDERS_PAGE_LIMIT = 50;
414
439
  async function listAllFolders(params) {
415
440
  const results = [];
416
441
  let after;
@@ -431,7 +456,7 @@ async function listAllFolders(params) {
431
456
  return results;
432
457
  }
433
458
  async function listThemes(params) {
434
- const res = await apiFetch(params, "/themes?limit=100");
459
+ const res = await apiFetch(params, "/themes?limit=50");
435
460
  if (!res.ok) {
436
461
  return [];
437
462
  }
@@ -468,19 +468,34 @@ async function runSetupFlow(flow, params, ctx, config) {
468
468
  };
469
469
  let state = flow.initialState();
470
470
  let answerIdx = 0;
471
+ const pendingParameterUpdates = [];
471
472
  for (const step of flow.steps) {
472
473
  const ans = ctx.answers[answerIdx];
473
474
  if (ans && ans.questionSlug === step.slug) {
474
475
  state = step.applyAnswer(state, ans.answer);
476
+ if (step.toParameterUpdates) {
477
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
478
+ }
475
479
  answerIdx += 1;
476
480
  continue;
477
481
  }
482
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
478
483
  if (step.type === "text") {
484
+ if (step.fetchOptions) {
485
+ const options2 = await step.fetchOptions(state, runtime);
486
+ if (options2.length === 0) {
487
+ continue;
488
+ }
489
+ }
479
490
  return {
480
491
  type: "nextQuestion",
481
492
  questionSlug: step.slug,
482
493
  question: step.question[ctx.language],
483
- questionType: "text"
494
+ questionType: "text",
495
+ allowFreeText: resolvedAllowFreeText,
496
+ ...pendingParameterUpdates.length > 0 && {
497
+ parameterUpdates: pendingParameterUpdates
498
+ }
484
499
  };
485
500
  }
486
501
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -492,11 +507,21 @@ async function runSetupFlow(flow, params, ctx, config) {
492
507
  questionSlug: step.slug,
493
508
  question: step.question[ctx.language],
494
509
  questionType: step.type,
495
- options
510
+ options,
511
+ allowFreeText: resolvedAllowFreeText,
512
+ ...pendingParameterUpdates.length > 0 && {
513
+ parameterUpdates: pendingParameterUpdates
514
+ }
496
515
  };
497
516
  }
498
517
  const dataInvestigationResult = await flow.finalize(state, runtime);
499
- return { type: "fulfilled", dataInvestigationResult };
518
+ return {
519
+ type: "fulfilled",
520
+ dataInvestigationResult,
521
+ ...pendingParameterUpdates.length > 0 && {
522
+ parameterUpdates: pendingParameterUpdates
523
+ }
524
+ };
500
525
  }
501
526
  async function resolveSetupSelection(params) {
502
527
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -278,19 +278,34 @@ async function runSetupFlow(flow, params, ctx, config) {
278
278
  };
279
279
  let state = flow.initialState();
280
280
  let answerIdx = 0;
281
+ const pendingParameterUpdates = [];
281
282
  for (const step of flow.steps) {
282
283
  const ans = ctx.answers[answerIdx];
283
284
  if (ans && ans.questionSlug === step.slug) {
284
285
  state = step.applyAnswer(state, ans.answer);
286
+ if (step.toParameterUpdates) {
287
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
288
+ }
285
289
  answerIdx += 1;
286
290
  continue;
287
291
  }
292
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
288
293
  if (step.type === "text") {
294
+ if (step.fetchOptions) {
295
+ const options2 = await step.fetchOptions(state, runtime);
296
+ if (options2.length === 0) {
297
+ continue;
298
+ }
299
+ }
289
300
  return {
290
301
  type: "nextQuestion",
291
302
  questionSlug: step.slug,
292
303
  question: step.question[ctx.language],
293
- questionType: "text"
304
+ questionType: "text",
305
+ allowFreeText: resolvedAllowFreeText,
306
+ ...pendingParameterUpdates.length > 0 && {
307
+ parameterUpdates: pendingParameterUpdates
308
+ }
294
309
  };
295
310
  }
296
311
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -302,11 +317,21 @@ async function runSetupFlow(flow, params, ctx, config) {
302
317
  questionSlug: step.slug,
303
318
  question: step.question[ctx.language],
304
319
  questionType: step.type,
305
- options
320
+ options,
321
+ allowFreeText: resolvedAllowFreeText,
322
+ ...pendingParameterUpdates.length > 0 && {
323
+ parameterUpdates: pendingParameterUpdates
324
+ }
306
325
  };
307
326
  }
308
327
  const dataInvestigationResult = await flow.finalize(state, runtime);
309
- return { type: "fulfilled", dataInvestigationResult };
328
+ return {
329
+ type: "fulfilled",
330
+ dataInvestigationResult,
331
+ ...pendingParameterUpdates.length > 0 && {
332
+ parameterUpdates: pendingParameterUpdates
333
+ }
334
+ };
310
335
  }
311
336
  async function resolveSetupSelection(params) {
312
337
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -290,19 +290,34 @@ async function runSetupFlow(flow, params, ctx, config) {
290
290
  };
291
291
  let state = flow.initialState();
292
292
  let answerIdx = 0;
293
+ const pendingParameterUpdates = [];
293
294
  for (const step of flow.steps) {
294
295
  const ans = ctx.answers[answerIdx];
295
296
  if (ans && ans.questionSlug === step.slug) {
296
297
  state = step.applyAnswer(state, ans.answer);
298
+ if (step.toParameterUpdates) {
299
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
300
+ }
297
301
  answerIdx += 1;
298
302
  continue;
299
303
  }
304
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
300
305
  if (step.type === "text") {
306
+ if (step.fetchOptions) {
307
+ const options2 = await step.fetchOptions(state, runtime);
308
+ if (options2.length === 0) {
309
+ continue;
310
+ }
311
+ }
301
312
  return {
302
313
  type: "nextQuestion",
303
314
  questionSlug: step.slug,
304
315
  question: step.question[ctx.language],
305
- questionType: "text"
316
+ questionType: "text",
317
+ allowFreeText: resolvedAllowFreeText,
318
+ ...pendingParameterUpdates.length > 0 && {
319
+ parameterUpdates: pendingParameterUpdates
320
+ }
306
321
  };
307
322
  }
308
323
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -314,11 +329,21 @@ async function runSetupFlow(flow, params, ctx, config) {
314
329
  questionSlug: step.slug,
315
330
  question: step.question[ctx.language],
316
331
  questionType: step.type,
317
- options
332
+ options,
333
+ allowFreeText: resolvedAllowFreeText,
334
+ ...pendingParameterUpdates.length > 0 && {
335
+ parameterUpdates: pendingParameterUpdates
336
+ }
318
337
  };
319
338
  }
320
339
  const dataInvestigationResult = await flow.finalize(state, runtime);
321
- return { type: "fulfilled", dataInvestigationResult };
340
+ return {
341
+ type: "fulfilled",
342
+ dataInvestigationResult,
343
+ ...pendingParameterUpdates.length > 0 && {
344
+ parameterUpdates: pendingParameterUpdates
345
+ }
346
+ };
322
347
  }
323
348
  async function resolveSetupSelection(params) {
324
349
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -338,19 +338,34 @@ async function runSetupFlow(flow, params, ctx, config) {
338
338
  };
339
339
  let state = flow.initialState();
340
340
  let answerIdx = 0;
341
+ const pendingParameterUpdates = [];
341
342
  for (const step of flow.steps) {
342
343
  const ans = ctx.answers[answerIdx];
343
344
  if (ans && ans.questionSlug === step.slug) {
344
345
  state = step.applyAnswer(state, ans.answer);
346
+ if (step.toParameterUpdates) {
347
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
348
+ }
345
349
  answerIdx += 1;
346
350
  continue;
347
351
  }
352
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
348
353
  if (step.type === "text") {
354
+ if (step.fetchOptions) {
355
+ const options2 = await step.fetchOptions(state, runtime);
356
+ if (options2.length === 0) {
357
+ continue;
358
+ }
359
+ }
349
360
  return {
350
361
  type: "nextQuestion",
351
362
  questionSlug: step.slug,
352
363
  question: step.question[ctx.language],
353
- questionType: "text"
364
+ questionType: "text",
365
+ allowFreeText: resolvedAllowFreeText,
366
+ ...pendingParameterUpdates.length > 0 && {
367
+ parameterUpdates: pendingParameterUpdates
368
+ }
354
369
  };
355
370
  }
356
371
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -362,11 +377,21 @@ async function runSetupFlow(flow, params, ctx, config) {
362
377
  questionSlug: step.slug,
363
378
  question: step.question[ctx.language],
364
379
  questionType: step.type,
365
- options
380
+ options,
381
+ allowFreeText: resolvedAllowFreeText,
382
+ ...pendingParameterUpdates.length > 0 && {
383
+ parameterUpdates: pendingParameterUpdates
384
+ }
366
385
  };
367
386
  }
368
387
  const dataInvestigationResult = await flow.finalize(state, runtime);
369
- return { type: "fulfilled", dataInvestigationResult };
388
+ return {
389
+ type: "fulfilled",
390
+ dataInvestigationResult,
391
+ ...pendingParameterUpdates.length > 0 && {
392
+ parameterUpdates: pendingParameterUpdates
393
+ }
394
+ };
370
395
  }
371
396
  async function resolveSetupSelection(params) {
372
397
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -319,19 +319,34 @@ async function runSetupFlow(flow, params, ctx, config) {
319
319
  };
320
320
  let state = flow.initialState();
321
321
  let answerIdx = 0;
322
+ const pendingParameterUpdates = [];
322
323
  for (const step of flow.steps) {
323
324
  const ans = ctx.answers[answerIdx];
324
325
  if (ans && ans.questionSlug === step.slug) {
325
326
  state = step.applyAnswer(state, ans.answer);
327
+ if (step.toParameterUpdates) {
328
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
329
+ }
326
330
  answerIdx += 1;
327
331
  continue;
328
332
  }
333
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
329
334
  if (step.type === "text") {
335
+ if (step.fetchOptions) {
336
+ const options2 = await step.fetchOptions(state, runtime);
337
+ if (options2.length === 0) {
338
+ continue;
339
+ }
340
+ }
330
341
  return {
331
342
  type: "nextQuestion",
332
343
  questionSlug: step.slug,
333
344
  question: step.question[ctx.language],
334
- questionType: "text"
345
+ questionType: "text",
346
+ allowFreeText: resolvedAllowFreeText,
347
+ ...pendingParameterUpdates.length > 0 && {
348
+ parameterUpdates: pendingParameterUpdates
349
+ }
335
350
  };
336
351
  }
337
352
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -343,11 +358,21 @@ async function runSetupFlow(flow, params, ctx, config) {
343
358
  questionSlug: step.slug,
344
359
  question: step.question[ctx.language],
345
360
  questionType: step.type,
346
- options
361
+ options,
362
+ allowFreeText: resolvedAllowFreeText,
363
+ ...pendingParameterUpdates.length > 0 && {
364
+ parameterUpdates: pendingParameterUpdates
365
+ }
347
366
  };
348
367
  }
349
368
  const dataInvestigationResult = await flow.finalize(state, runtime);
350
- return { type: "fulfilled", dataInvestigationResult };
369
+ return {
370
+ type: "fulfilled",
371
+ dataInvestigationResult,
372
+ ...pendingParameterUpdates.length > 0 && {
373
+ parameterUpdates: pendingParameterUpdates
374
+ }
375
+ };
351
376
  }
352
377
  async function resolveSetupSelection(params) {
353
378
  const { selected, allSentinel, fetchAll, limit } = params;