@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
@@ -311,19 +311,34 @@ async function runSetupFlow(flow, params, ctx, config) {
311
311
  };
312
312
  let state = flow.initialState();
313
313
  let answerIdx = 0;
314
+ const pendingParameterUpdates = [];
314
315
  for (const step of flow.steps) {
315
316
  const ans = ctx.answers[answerIdx];
316
317
  if (ans && ans.questionSlug === step.slug) {
317
318
  state = step.applyAnswer(state, ans.answer);
319
+ if (step.toParameterUpdates) {
320
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
321
+ }
318
322
  answerIdx += 1;
319
323
  continue;
320
324
  }
325
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
321
326
  if (step.type === "text") {
327
+ if (step.fetchOptions) {
328
+ const options2 = await step.fetchOptions(state, runtime);
329
+ if (options2.length === 0) {
330
+ continue;
331
+ }
332
+ }
322
333
  return {
323
334
  type: "nextQuestion",
324
335
  questionSlug: step.slug,
325
336
  question: step.question[ctx.language],
326
- questionType: "text"
337
+ questionType: "text",
338
+ allowFreeText: resolvedAllowFreeText,
339
+ ...pendingParameterUpdates.length > 0 && {
340
+ parameterUpdates: pendingParameterUpdates
341
+ }
327
342
  };
328
343
  }
329
344
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -335,11 +350,21 @@ async function runSetupFlow(flow, params, ctx, config) {
335
350
  questionSlug: step.slug,
336
351
  question: step.question[ctx.language],
337
352
  questionType: step.type,
338
- options
353
+ options,
354
+ allowFreeText: resolvedAllowFreeText,
355
+ ...pendingParameterUpdates.length > 0 && {
356
+ parameterUpdates: pendingParameterUpdates
357
+ }
339
358
  };
340
359
  }
341
360
  const dataInvestigationResult = await flow.finalize(state, runtime);
342
- return { type: "fulfilled", dataInvestigationResult };
361
+ return {
362
+ type: "fulfilled",
363
+ dataInvestigationResult,
364
+ ...pendingParameterUpdates.length > 0 && {
365
+ parameterUpdates: pendingParameterUpdates
366
+ }
367
+ };
343
368
  }
344
369
  async function resolveSetupSelection(params) {
345
370
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -226,19 +226,34 @@ async function runSetupFlow(flow, params, ctx, config) {
226
226
  };
227
227
  let state = flow.initialState();
228
228
  let answerIdx = 0;
229
+ const pendingParameterUpdates = [];
229
230
  for (const step of flow.steps) {
230
231
  const ans = ctx.answers[answerIdx];
231
232
  if (ans && ans.questionSlug === step.slug) {
232
233
  state = step.applyAnswer(state, ans.answer);
234
+ if (step.toParameterUpdates) {
235
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
236
+ }
233
237
  answerIdx += 1;
234
238
  continue;
235
239
  }
240
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
236
241
  if (step.type === "text") {
242
+ if (step.fetchOptions) {
243
+ const options2 = await step.fetchOptions(state, runtime);
244
+ if (options2.length === 0) {
245
+ continue;
246
+ }
247
+ }
237
248
  return {
238
249
  type: "nextQuestion",
239
250
  questionSlug: step.slug,
240
251
  question: step.question[ctx.language],
241
- questionType: "text"
252
+ questionType: "text",
253
+ allowFreeText: resolvedAllowFreeText,
254
+ ...pendingParameterUpdates.length > 0 && {
255
+ parameterUpdates: pendingParameterUpdates
256
+ }
242
257
  };
243
258
  }
244
259
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -250,11 +265,21 @@ async function runSetupFlow(flow, params, ctx, config) {
250
265
  questionSlug: step.slug,
251
266
  question: step.question[ctx.language],
252
267
  questionType: step.type,
253
- options
268
+ options,
269
+ allowFreeText: resolvedAllowFreeText,
270
+ ...pendingParameterUpdates.length > 0 && {
271
+ parameterUpdates: pendingParameterUpdates
272
+ }
254
273
  };
255
274
  }
256
275
  const dataInvestigationResult = await flow.finalize(state, runtime);
257
- return { type: "fulfilled", dataInvestigationResult };
276
+ return {
277
+ type: "fulfilled",
278
+ dataInvestigationResult,
279
+ ...pendingParameterUpdates.length > 0 && {
280
+ parameterUpdates: pendingParameterUpdates
281
+ }
282
+ };
258
283
  }
259
284
  async function resolveSetupSelection(params) {
260
285
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -315,19 +315,34 @@ async function runSetupFlow(flow, params, ctx, config) {
315
315
  };
316
316
  let state = flow.initialState();
317
317
  let answerIdx = 0;
318
+ const pendingParameterUpdates = [];
318
319
  for (const step of flow.steps) {
319
320
  const ans = ctx.answers[answerIdx];
320
321
  if (ans && ans.questionSlug === step.slug) {
321
322
  state = step.applyAnswer(state, ans.answer);
323
+ if (step.toParameterUpdates) {
324
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
325
+ }
322
326
  answerIdx += 1;
323
327
  continue;
324
328
  }
329
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
325
330
  if (step.type === "text") {
331
+ if (step.fetchOptions) {
332
+ const options2 = await step.fetchOptions(state, runtime);
333
+ if (options2.length === 0) {
334
+ continue;
335
+ }
336
+ }
326
337
  return {
327
338
  type: "nextQuestion",
328
339
  questionSlug: step.slug,
329
340
  question: step.question[ctx.language],
330
- questionType: "text"
341
+ questionType: "text",
342
+ allowFreeText: resolvedAllowFreeText,
343
+ ...pendingParameterUpdates.length > 0 && {
344
+ parameterUpdates: pendingParameterUpdates
345
+ }
331
346
  };
332
347
  }
333
348
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -339,11 +354,21 @@ async function runSetupFlow(flow, params, ctx, config) {
339
354
  questionSlug: step.slug,
340
355
  question: step.question[ctx.language],
341
356
  questionType: step.type,
342
- options
357
+ options,
358
+ allowFreeText: resolvedAllowFreeText,
359
+ ...pendingParameterUpdates.length > 0 && {
360
+ parameterUpdates: pendingParameterUpdates
361
+ }
343
362
  };
344
363
  }
345
364
  const dataInvestigationResult = await flow.finalize(state, runtime);
346
- return { type: "fulfilled", dataInvestigationResult };
365
+ return {
366
+ type: "fulfilled",
367
+ dataInvestigationResult,
368
+ ...pendingParameterUpdates.length > 0 && {
369
+ parameterUpdates: pendingParameterUpdates
370
+ }
371
+ };
347
372
  }
348
373
  async function resolveSetupSelection(params) {
349
374
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -320,19 +320,34 @@ async function runSetupFlow(flow, params, ctx, config) {
320
320
  };
321
321
  let state = flow.initialState();
322
322
  let answerIdx = 0;
323
+ const pendingParameterUpdates = [];
323
324
  for (const step of flow.steps) {
324
325
  const ans = ctx.answers[answerIdx];
325
326
  if (ans && ans.questionSlug === step.slug) {
326
327
  state = step.applyAnswer(state, ans.answer);
328
+ if (step.toParameterUpdates) {
329
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
330
+ }
327
331
  answerIdx += 1;
328
332
  continue;
329
333
  }
334
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
330
335
  if (step.type === "text") {
336
+ if (step.fetchOptions) {
337
+ const options2 = await step.fetchOptions(state, runtime);
338
+ if (options2.length === 0) {
339
+ continue;
340
+ }
341
+ }
331
342
  return {
332
343
  type: "nextQuestion",
333
344
  questionSlug: step.slug,
334
345
  question: step.question[ctx.language],
335
- questionType: "text"
346
+ questionType: "text",
347
+ allowFreeText: resolvedAllowFreeText,
348
+ ...pendingParameterUpdates.length > 0 && {
349
+ parameterUpdates: pendingParameterUpdates
350
+ }
336
351
  };
337
352
  }
338
353
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -344,11 +359,21 @@ async function runSetupFlow(flow, params, ctx, config) {
344
359
  questionSlug: step.slug,
345
360
  question: step.question[ctx.language],
346
361
  questionType: step.type,
347
- options
362
+ options,
363
+ allowFreeText: resolvedAllowFreeText,
364
+ ...pendingParameterUpdates.length > 0 && {
365
+ parameterUpdates: pendingParameterUpdates
366
+ }
348
367
  };
349
368
  }
350
369
  const dataInvestigationResult = await flow.finalize(state, runtime);
351
- return { type: "fulfilled", dataInvestigationResult };
370
+ return {
371
+ type: "fulfilled",
372
+ dataInvestigationResult,
373
+ ...pendingParameterUpdates.length > 0 && {
374
+ parameterUpdates: pendingParameterUpdates
375
+ }
376
+ };
352
377
  }
353
378
  async function resolveSetupSelection(params) {
354
379
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -307,19 +307,34 @@ async function runSetupFlow(flow, params, ctx, config) {
307
307
  };
308
308
  let state = flow.initialState();
309
309
  let answerIdx = 0;
310
+ const pendingParameterUpdates = [];
310
311
  for (const step of flow.steps) {
311
312
  const ans = ctx.answers[answerIdx];
312
313
  if (ans && ans.questionSlug === step.slug) {
313
314
  state = step.applyAnswer(state, ans.answer);
315
+ if (step.toParameterUpdates) {
316
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
317
+ }
314
318
  answerIdx += 1;
315
319
  continue;
316
320
  }
321
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
317
322
  if (step.type === "text") {
323
+ if (step.fetchOptions) {
324
+ const options2 = await step.fetchOptions(state, runtime);
325
+ if (options2.length === 0) {
326
+ continue;
327
+ }
328
+ }
318
329
  return {
319
330
  type: "nextQuestion",
320
331
  questionSlug: step.slug,
321
332
  question: step.question[ctx.language],
322
- questionType: "text"
333
+ questionType: "text",
334
+ allowFreeText: resolvedAllowFreeText,
335
+ ...pendingParameterUpdates.length > 0 && {
336
+ parameterUpdates: pendingParameterUpdates
337
+ }
323
338
  };
324
339
  }
325
340
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -331,11 +346,21 @@ async function runSetupFlow(flow, params, ctx, config) {
331
346
  questionSlug: step.slug,
332
347
  question: step.question[ctx.language],
333
348
  questionType: step.type,
334
- options
349
+ options,
350
+ allowFreeText: resolvedAllowFreeText,
351
+ ...pendingParameterUpdates.length > 0 && {
352
+ parameterUpdates: pendingParameterUpdates
353
+ }
335
354
  };
336
355
  }
337
356
  const dataInvestigationResult = await flow.finalize(state, runtime);
338
- return { type: "fulfilled", dataInvestigationResult };
357
+ return {
358
+ type: "fulfilled",
359
+ dataInvestigationResult,
360
+ ...pendingParameterUpdates.length > 0 && {
361
+ parameterUpdates: pendingParameterUpdates
362
+ }
363
+ };
339
364
  }
340
365
  async function resolveSetupSelection(params) {
341
366
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -238,19 +238,34 @@ async function runSetupFlow(flow, params, ctx, config) {
238
238
  };
239
239
  let state = flow.initialState();
240
240
  let answerIdx = 0;
241
+ const pendingParameterUpdates = [];
241
242
  for (const step of flow.steps) {
242
243
  const ans = ctx.answers[answerIdx];
243
244
  if (ans && ans.questionSlug === step.slug) {
244
245
  state = step.applyAnswer(state, ans.answer);
246
+ if (step.toParameterUpdates) {
247
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
248
+ }
245
249
  answerIdx += 1;
246
250
  continue;
247
251
  }
252
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
248
253
  if (step.type === "text") {
254
+ if (step.fetchOptions) {
255
+ const options2 = await step.fetchOptions(state, runtime);
256
+ if (options2.length === 0) {
257
+ continue;
258
+ }
259
+ }
249
260
  return {
250
261
  type: "nextQuestion",
251
262
  questionSlug: step.slug,
252
263
  question: step.question[ctx.language],
253
- questionType: "text"
264
+ questionType: "text",
265
+ allowFreeText: resolvedAllowFreeText,
266
+ ...pendingParameterUpdates.length > 0 && {
267
+ parameterUpdates: pendingParameterUpdates
268
+ }
254
269
  };
255
270
  }
256
271
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -262,11 +277,21 @@ async function runSetupFlow(flow, params, ctx, config) {
262
277
  questionSlug: step.slug,
263
278
  question: step.question[ctx.language],
264
279
  questionType: step.type,
265
- options
280
+ options,
281
+ allowFreeText: resolvedAllowFreeText,
282
+ ...pendingParameterUpdates.length > 0 && {
283
+ parameterUpdates: pendingParameterUpdates
284
+ }
266
285
  };
267
286
  }
268
287
  const dataInvestigationResult = await flow.finalize(state, runtime);
269
- return { type: "fulfilled", dataInvestigationResult };
288
+ return {
289
+ type: "fulfilled",
290
+ dataInvestigationResult,
291
+ ...pendingParameterUpdates.length > 0 && {
292
+ parameterUpdates: pendingParameterUpdates
293
+ }
294
+ };
270
295
  }
271
296
  async function resolveSetupSelection(params) {
272
297
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -347,19 +347,34 @@ async function runSetupFlow(flow, params, ctx, config) {
347
347
  };
348
348
  let state = flow.initialState();
349
349
  let answerIdx = 0;
350
+ const pendingParameterUpdates = [];
350
351
  for (const step of flow.steps) {
351
352
  const ans = ctx.answers[answerIdx];
352
353
  if (ans && ans.questionSlug === step.slug) {
353
354
  state = step.applyAnswer(state, ans.answer);
355
+ if (step.toParameterUpdates) {
356
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
357
+ }
354
358
  answerIdx += 1;
355
359
  continue;
356
360
  }
361
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
357
362
  if (step.type === "text") {
363
+ if (step.fetchOptions) {
364
+ const options2 = await step.fetchOptions(state, runtime);
365
+ if (options2.length === 0) {
366
+ continue;
367
+ }
368
+ }
358
369
  return {
359
370
  type: "nextQuestion",
360
371
  questionSlug: step.slug,
361
372
  question: step.question[ctx.language],
362
- questionType: "text"
373
+ questionType: "text",
374
+ allowFreeText: resolvedAllowFreeText,
375
+ ...pendingParameterUpdates.length > 0 && {
376
+ parameterUpdates: pendingParameterUpdates
377
+ }
363
378
  };
364
379
  }
365
380
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -371,11 +386,21 @@ async function runSetupFlow(flow, params, ctx, config) {
371
386
  questionSlug: step.slug,
372
387
  question: step.question[ctx.language],
373
388
  questionType: step.type,
374
- options
389
+ options,
390
+ allowFreeText: resolvedAllowFreeText,
391
+ ...pendingParameterUpdates.length > 0 && {
392
+ parameterUpdates: pendingParameterUpdates
393
+ }
375
394
  };
376
395
  }
377
396
  const dataInvestigationResult = await flow.finalize(state, runtime);
378
- return { type: "fulfilled", dataInvestigationResult };
397
+ return {
398
+ type: "fulfilled",
399
+ dataInvestigationResult,
400
+ ...pendingParameterUpdates.length > 0 && {
401
+ parameterUpdates: pendingParameterUpdates
402
+ }
403
+ };
379
404
  }
380
405
  async function resolveSetupSelection(params) {
381
406
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -180,19 +180,34 @@ async function runSetupFlow(flow, params, ctx, config) {
180
180
  };
181
181
  let state = flow.initialState();
182
182
  let answerIdx = 0;
183
+ const pendingParameterUpdates = [];
183
184
  for (const step of flow.steps) {
184
185
  const ans = ctx.answers[answerIdx];
185
186
  if (ans && ans.questionSlug === step.slug) {
186
187
  state = step.applyAnswer(state, ans.answer);
188
+ if (step.toParameterUpdates) {
189
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
190
+ }
187
191
  answerIdx += 1;
188
192
  continue;
189
193
  }
194
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
190
195
  if (step.type === "text") {
196
+ if (step.fetchOptions) {
197
+ const options2 = await step.fetchOptions(state, runtime);
198
+ if (options2.length === 0) {
199
+ continue;
200
+ }
201
+ }
191
202
  return {
192
203
  type: "nextQuestion",
193
204
  questionSlug: step.slug,
194
205
  question: step.question[ctx.language],
195
- questionType: "text"
206
+ questionType: "text",
207
+ allowFreeText: resolvedAllowFreeText,
208
+ ...pendingParameterUpdates.length > 0 && {
209
+ parameterUpdates: pendingParameterUpdates
210
+ }
196
211
  };
197
212
  }
198
213
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -204,11 +219,21 @@ async function runSetupFlow(flow, params, ctx, config) {
204
219
  questionSlug: step.slug,
205
220
  question: step.question[ctx.language],
206
221
  questionType: step.type,
207
- options
222
+ options,
223
+ allowFreeText: resolvedAllowFreeText,
224
+ ...pendingParameterUpdates.length > 0 && {
225
+ parameterUpdates: pendingParameterUpdates
226
+ }
208
227
  };
209
228
  }
210
229
  const dataInvestigationResult = await flow.finalize(state, runtime);
211
- return { type: "fulfilled", dataInvestigationResult };
230
+ return {
231
+ type: "fulfilled",
232
+ dataInvestigationResult,
233
+ ...pendingParameterUpdates.length > 0 && {
234
+ parameterUpdates: pendingParameterUpdates
235
+ }
236
+ };
212
237
  }
213
238
  async function resolveSetupSelection(params) {
214
239
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -321,19 +321,34 @@ async function runSetupFlow(flow, params, ctx, config) {
321
321
  };
322
322
  let state = flow.initialState();
323
323
  let answerIdx = 0;
324
+ const pendingParameterUpdates = [];
324
325
  for (const step of flow.steps) {
325
326
  const ans = ctx.answers[answerIdx];
326
327
  if (ans && ans.questionSlug === step.slug) {
327
328
  state = step.applyAnswer(state, ans.answer);
329
+ if (step.toParameterUpdates) {
330
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
331
+ }
328
332
  answerIdx += 1;
329
333
  continue;
330
334
  }
335
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
331
336
  if (step.type === "text") {
337
+ if (step.fetchOptions) {
338
+ const options2 = await step.fetchOptions(state, runtime);
339
+ if (options2.length === 0) {
340
+ continue;
341
+ }
342
+ }
332
343
  return {
333
344
  type: "nextQuestion",
334
345
  questionSlug: step.slug,
335
346
  question: step.question[ctx.language],
336
- questionType: "text"
347
+ questionType: "text",
348
+ allowFreeText: resolvedAllowFreeText,
349
+ ...pendingParameterUpdates.length > 0 && {
350
+ parameterUpdates: pendingParameterUpdates
351
+ }
337
352
  };
338
353
  }
339
354
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -345,11 +360,21 @@ async function runSetupFlow(flow, params, ctx, config) {
345
360
  questionSlug: step.slug,
346
361
  question: step.question[ctx.language],
347
362
  questionType: step.type,
348
- options
363
+ options,
364
+ allowFreeText: resolvedAllowFreeText,
365
+ ...pendingParameterUpdates.length > 0 && {
366
+ parameterUpdates: pendingParameterUpdates
367
+ }
349
368
  };
350
369
  }
351
370
  const dataInvestigationResult = await flow.finalize(state, runtime);
352
- return { type: "fulfilled", dataInvestigationResult };
371
+ return {
372
+ type: "fulfilled",
373
+ dataInvestigationResult,
374
+ ...pendingParameterUpdates.length > 0 && {
375
+ parameterUpdates: pendingParameterUpdates
376
+ }
377
+ };
353
378
  }
354
379
  async function resolveSetupSelection(params) {
355
380
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -380,19 +380,34 @@ async function runSetupFlow(flow, params, ctx, config) {
380
380
  };
381
381
  let state = flow.initialState();
382
382
  let answerIdx = 0;
383
+ const pendingParameterUpdates = [];
383
384
  for (const step of flow.steps) {
384
385
  const ans = ctx.answers[answerIdx];
385
386
  if (ans && ans.questionSlug === step.slug) {
386
387
  state = step.applyAnswer(state, ans.answer);
388
+ if (step.toParameterUpdates) {
389
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
390
+ }
387
391
  answerIdx += 1;
388
392
  continue;
389
393
  }
394
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
390
395
  if (step.type === "text") {
396
+ if (step.fetchOptions) {
397
+ const options2 = await step.fetchOptions(state, runtime);
398
+ if (options2.length === 0) {
399
+ continue;
400
+ }
401
+ }
391
402
  return {
392
403
  type: "nextQuestion",
393
404
  questionSlug: step.slug,
394
405
  question: step.question[ctx.language],
395
- questionType: "text"
406
+ questionType: "text",
407
+ allowFreeText: resolvedAllowFreeText,
408
+ ...pendingParameterUpdates.length > 0 && {
409
+ parameterUpdates: pendingParameterUpdates
410
+ }
396
411
  };
397
412
  }
398
413
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -404,11 +419,21 @@ async function runSetupFlow(flow, params, ctx, config) {
404
419
  questionSlug: step.slug,
405
420
  question: step.question[ctx.language],
406
421
  questionType: step.type,
407
- options
422
+ options,
423
+ allowFreeText: resolvedAllowFreeText,
424
+ ...pendingParameterUpdates.length > 0 && {
425
+ parameterUpdates: pendingParameterUpdates
426
+ }
408
427
  };
409
428
  }
410
429
  const dataInvestigationResult = await flow.finalize(state, runtime);
411
- return { type: "fulfilled", dataInvestigationResult };
430
+ return {
431
+ type: "fulfilled",
432
+ dataInvestigationResult,
433
+ ...pendingParameterUpdates.length > 0 && {
434
+ parameterUpdates: pendingParameterUpdates
435
+ }
436
+ };
412
437
  }
413
438
  async function resolveSetupSelection(params) {
414
439
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -180,19 +180,34 @@ async function runSetupFlow(flow, params, ctx, config) {
180
180
  };
181
181
  let state = flow.initialState();
182
182
  let answerIdx = 0;
183
+ const pendingParameterUpdates = [];
183
184
  for (const step of flow.steps) {
184
185
  const ans = ctx.answers[answerIdx];
185
186
  if (ans && ans.questionSlug === step.slug) {
186
187
  state = step.applyAnswer(state, ans.answer);
188
+ if (step.toParameterUpdates) {
189
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
190
+ }
187
191
  answerIdx += 1;
188
192
  continue;
189
193
  }
194
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
190
195
  if (step.type === "text") {
196
+ if (step.fetchOptions) {
197
+ const options2 = await step.fetchOptions(state, runtime);
198
+ if (options2.length === 0) {
199
+ continue;
200
+ }
201
+ }
191
202
  return {
192
203
  type: "nextQuestion",
193
204
  questionSlug: step.slug,
194
205
  question: step.question[ctx.language],
195
- questionType: "text"
206
+ questionType: "text",
207
+ allowFreeText: resolvedAllowFreeText,
208
+ ...pendingParameterUpdates.length > 0 && {
209
+ parameterUpdates: pendingParameterUpdates
210
+ }
196
211
  };
197
212
  }
198
213
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -204,11 +219,21 @@ async function runSetupFlow(flow, params, ctx, config) {
204
219
  questionSlug: step.slug,
205
220
  question: step.question[ctx.language],
206
221
  questionType: step.type,
207
- options
222
+ options,
223
+ allowFreeText: resolvedAllowFreeText,
224
+ ...pendingParameterUpdates.length > 0 && {
225
+ parameterUpdates: pendingParameterUpdates
226
+ }
208
227
  };
209
228
  }
210
229
  const dataInvestigationResult = await flow.finalize(state, runtime);
211
- return { type: "fulfilled", dataInvestigationResult };
230
+ return {
231
+ type: "fulfilled",
232
+ dataInvestigationResult,
233
+ ...pendingParameterUpdates.length > 0 && {
234
+ parameterUpdates: pendingParameterUpdates
235
+ }
236
+ };
212
237
  }
213
238
  async function resolveSetupSelection(params) {
214
239
  const { selected, allSentinel, fetchAll, limit } = params;