@usefillo/core 0.21.0 → 0.23.0

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.
package/dist/index.d.ts CHANGED
@@ -131,9 +131,11 @@ interface HiddenField extends BaseField {
131
131
  paramName?: string;
132
132
  defaultValue?: string;
133
133
  }
134
+ /** Maximum number of completed files in one upload-field answer. */
135
+ declare const MAX_FILES_PER_FIELD = 200;
134
136
  interface FileUploadField extends BaseField {
135
137
  kind: "file_upload";
136
- /** Max files, default 1. */
138
+ /** Max files, from 1 to 200. Default 1. */
137
139
  maxFiles?: number;
138
140
  /** Per-file size cap in MB. Default 500. */
139
141
  maxFileSizeMb?: number;
@@ -1324,6 +1326,8 @@ declare class FilloClient {
1324
1326
  /** Server origin this client targets, normalized (no trailing slash). */
1325
1327
  readonly baseUrl: string;
1326
1328
  private fetch;
1329
+ private activeUploads;
1330
+ private uploadQueue;
1327
1331
  /** Publishable project key, when configured. */
1328
1332
  readonly key?: string;
1329
1333
  constructor(options?: FilloClientOptions);
@@ -1407,6 +1411,8 @@ declare class FilloClient {
1407
1411
  * form owner's Drive and never touch the Fillo server.
1408
1412
  */
1409
1413
  uploadFile(formId: string, file: File | Blob, options: UploadFileOptions): Promise<FileValue>;
1414
+ private acquireUploadSlot;
1415
+ private performUpload;
1410
1416
  /**
1411
1417
  * Box direct upload with a folder-scoped token (Box UI Elements pattern).
1412
1418
  * Small files go up in one multipart POST; large files run Box's chunked
@@ -2246,4 +2252,4 @@ declare class Sha1 {
2246
2252
  }
2247
2253
  declare const sha1Base64: (bytes: Uint8Array) => string;
2248
2254
 
2249
- export { type AutoSubmitContext, BLOCK_KIND_META, type BaseField, type Block, type BlockKind, CONTENT_KINDS, type CalcExpr, type CalculatedField, type ChallengeConfig, type ChallengeTheme, type CheckboxField, type ChoiceField, type CodeForm, type Condition, type ConditionOp, type ContentBlock, type ContentKind, type CreatedDraft, type CustomField, DEFAULT_FIELD_STRINGS, DEFAULT_RESPONDENT_ERROR_STRINGS, DEFAULT_STRINGS, DRAFT_KINDS, type DateField, type DividerBlock, FILLO_CALC_MIN_SDK_VERSION, FILLO_CHALLENGE_MIN_SDK_VERSION, FILLO_DATA_ATTRS, FILLO_GROUP_MIN_SDK_VERSION, FILLO_MIN_SDK_VERSION, FILLO_SCHEMA_VERSION, FILLO_SDK_VERSION, FILLO_SLOTS, FILLO_THEME_VARS, type Field, type FieldKind, type FieldSpec, type FieldValue, type FileUploadField, type FileValue, type FilloAppearance, FilloClient, type FilloClientOptions, FilloError, type FilloFieldStrings, FilloJsxError, type FilloRendererStrings, type FilloRespondent, type FilloSlot, type FilloStrings, type FormBranding, type FormController, type FormControllerOptions, type FormControllerState, type FormDraftSpec, type FormPage, type FormSchema, type FormSettings, type FormStatus, type FormTheme, type GroupInstanceValue, type HeadingBlock, type HiddenField, JSX_BLOCK_COMPONENTS, JSX_BLOCK_SPECS, type JsonValue, type JsxFormMeta, type JumpRule, type LinearScaleField, type MatrixField, type NextPage, type NumberField, PHONE_COUNTRIES, PHONE_PICKER_COUNTRIES, PHONE_POPOVER_VIEWPORT_GAP, type ParagraphBlock, type ParsePhoneOptions, type ParsedPhone, type PhoneCountry, type PhoneField, type PhonePopoverPlacement, type ProvisionWorkspaceResult, type PublishedForm, REQUIRED_FIELD_MESSAGE, type RankingField, type RatingField, type RepeatingGroupField, type RespondentErrorOverrides, type RespondentErrorStrings, type ResponseData, type ResponseDraft, type ResponseLimit, type SchemaValidationResult, type SelectOption, Sha1, type SignatureField, type SlotClass, type SlotState, type SubmitMeta, type SubmitResult, type SyncFormResult, type SyncedForm, type TextField, type TrustPolicy, type UploadFileOptions, type UploadProgress, type UploadSession, type UploadStatus, type UploadTransport, type ValidationResult, type WhenBuilder, allFields, assembleForm, codeFormFromJsx, computeCalculated, conditionsMet, contentHash, countryByDialCode, countryByIso, countryByTimeZone, createBlock, createClient, createEmptyForm, createFormController, createId, defineForm, digitsOnly, evaluateCalc, flagEmoji, formSchemasEqual, formatAnswer, formatGroupedNumber, formatNational, isAutoSubmitBlock, isBlockVisible, isBuildTimeDevEnv, isCodeForm, isField, isFilloError, isLikelyDevEnv, isPossiblePhone, isTerminalPage, isValidPartialNumberText, localeForNotation, needsExplicitSubmit, normalizeFormSchema, normalizeFormTheme, normalizeSettings, parseGroupedNumber, parsePhone, pipeBlock, positionPhonePopover, prefillFromParams, provisionWorkspace, radioGroupStep, reachableFieldIds, reachableFields, reachablePageIds, reachablePageSequence, requiredFieldMessage, resolveNextPage, resolveSlotClass, resolveStrings, resolveText, resolveThemeAppearance, respondentErrorStringsFor, responseScopeValue, schemaFromJsx, sha1Base64, shouldAutoSubmit, slotClass, syncCodeForm, toE164, validateField, validateFormSchema, validateResponse, visibleBlocks, visibleFields, visibleGroupChildren, visiblePageBlocks, when };
2255
+ export { type AutoSubmitContext, BLOCK_KIND_META, type BaseField, type Block, type BlockKind, CONTENT_KINDS, type CalcExpr, type CalculatedField, type ChallengeConfig, type ChallengeTheme, type CheckboxField, type ChoiceField, type CodeForm, type Condition, type ConditionOp, type ContentBlock, type ContentKind, type CreatedDraft, type CustomField, DEFAULT_FIELD_STRINGS, DEFAULT_RESPONDENT_ERROR_STRINGS, DEFAULT_STRINGS, DRAFT_KINDS, type DateField, type DividerBlock, FILLO_CALC_MIN_SDK_VERSION, FILLO_CHALLENGE_MIN_SDK_VERSION, FILLO_DATA_ATTRS, FILLO_GROUP_MIN_SDK_VERSION, FILLO_MIN_SDK_VERSION, FILLO_SCHEMA_VERSION, FILLO_SDK_VERSION, FILLO_SLOTS, FILLO_THEME_VARS, type Field, type FieldKind, type FieldSpec, type FieldValue, type FileUploadField, type FileValue, type FilloAppearance, FilloClient, type FilloClientOptions, FilloError, type FilloFieldStrings, FilloJsxError, type FilloRendererStrings, type FilloRespondent, type FilloSlot, type FilloStrings, type FormBranding, type FormController, type FormControllerOptions, type FormControllerState, type FormDraftSpec, type FormPage, type FormSchema, type FormSettings, type FormStatus, type FormTheme, type GroupInstanceValue, type HeadingBlock, type HiddenField, JSX_BLOCK_COMPONENTS, JSX_BLOCK_SPECS, type JsonValue, type JsxFormMeta, type JumpRule, type LinearScaleField, MAX_FILES_PER_FIELD, type MatrixField, type NextPage, type NumberField, PHONE_COUNTRIES, PHONE_PICKER_COUNTRIES, PHONE_POPOVER_VIEWPORT_GAP, type ParagraphBlock, type ParsePhoneOptions, type ParsedPhone, type PhoneCountry, type PhoneField, type PhonePopoverPlacement, type ProvisionWorkspaceResult, type PublishedForm, REQUIRED_FIELD_MESSAGE, type RankingField, type RatingField, type RepeatingGroupField, type RespondentErrorOverrides, type RespondentErrorStrings, type ResponseData, type ResponseDraft, type ResponseLimit, type SchemaValidationResult, type SelectOption, Sha1, type SignatureField, type SlotClass, type SlotState, type SubmitMeta, type SubmitResult, type SyncFormResult, type SyncedForm, type TextField, type TrustPolicy, type UploadFileOptions, type UploadProgress, type UploadSession, type UploadStatus, type UploadTransport, type ValidationResult, type WhenBuilder, allFields, assembleForm, codeFormFromJsx, computeCalculated, conditionsMet, contentHash, countryByDialCode, countryByIso, countryByTimeZone, createBlock, createClient, createEmptyForm, createFormController, createId, defineForm, digitsOnly, evaluateCalc, flagEmoji, formSchemasEqual, formatAnswer, formatGroupedNumber, formatNational, isAutoSubmitBlock, isBlockVisible, isBuildTimeDevEnv, isCodeForm, isField, isFilloError, isLikelyDevEnv, isPossiblePhone, isTerminalPage, isValidPartialNumberText, localeForNotation, needsExplicitSubmit, normalizeFormSchema, normalizeFormTheme, normalizeSettings, parseGroupedNumber, parsePhone, pipeBlock, positionPhonePopover, prefillFromParams, provisionWorkspace, radioGroupStep, reachableFieldIds, reachableFields, reachablePageIds, reachablePageSequence, requiredFieldMessage, resolveNextPage, resolveSlotClass, resolveStrings, resolveText, resolveThemeAppearance, respondentErrorStringsFor, responseScopeValue, schemaFromJsx, sha1Base64, shouldAutoSubmit, slotClass, syncCodeForm, toE164, validateField, validateFormSchema, validateResponse, visibleBlocks, visibleFields, visibleGroupChildren, visiblePageBlocks, when };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/types.ts
2
+ var MAX_FILES_PER_FIELD = 200;
2
3
  var CONTENT_KINDS = ["heading", "paragraph", "divider"];
3
4
  function isField(block) {
4
5
  return !CONTENT_KINDS.includes(block.kind);
@@ -1113,7 +1114,7 @@ var schemaShape = z2.object({
1113
1114
  });
1114
1115
  var MAX_SCHEMA_VERSION = 1;
1115
1116
  var FILLO_SCHEMA_VERSION = 1;
1116
- var FILLO_SDK_VERSION = true ? "0.21.0" : "0.0.0-dev";
1117
+ var FILLO_SDK_VERSION = true ? "0.23.0" : "0.0.0-dev";
1117
1118
  var FILLO_MIN_SDK_VERSION = "0.4.0";
1118
1119
  var FILLO_CHALLENGE_MIN_SDK_VERSION = "0.9.0";
1119
1120
  var FILLO_CALC_MIN_SDK_VERSION = "0.11.0";
@@ -1735,7 +1736,7 @@ function normalizeBlock(input) {
1735
1736
  case "file_upload":
1736
1737
  return cleanObject({
1737
1738
  ...baseField(rec, kind),
1738
- maxFiles: int(rec.maxFiles, 1, 20, 1),
1739
+ maxFiles: int(rec.maxFiles, 1, MAX_FILES_PER_FIELD, 1),
1739
1740
  maxFileSizeMb: int(rec.maxFileSizeMb, 1, 5e3, 500),
1740
1741
  accept: Array.isArray(rec.accept) ? rec.accept.flatMap((v) => {
1741
1742
  const item = optionalStr(v, 100);
@@ -2472,6 +2473,7 @@ function retryAfterSec(res) {
2472
2473
  return Number.isFinite(raw) && raw > 0 ? raw : void 0;
2473
2474
  }
2474
2475
  var MAX_CHUNK_RETRIES = 3;
2476
+ var MAX_CONCURRENT_UPLOADS = 4;
2475
2477
  var DEFAULT_TIMEOUT_MS = 3e4;
2476
2478
  var S3_PART_TIMEOUT_MS = 5 * 6e4;
2477
2479
  var UPLOAD_CONTROL_TIMEOUT_MS = 10 * 6e4;
@@ -2545,6 +2547,8 @@ var FilloClient = class {
2545
2547
  /** Server origin this client targets, normalized (no trailing slash). */
2546
2548
  baseUrl;
2547
2549
  fetch;
2550
+ activeUploads = 0;
2551
+ uploadQueue = /* @__PURE__ */ new Set();
2548
2552
  /** Publishable project key, when configured. */
2549
2553
  key;
2550
2554
  constructor(options2 = {}) {
@@ -2751,6 +2755,40 @@ var FilloClient = class {
2751
2755
  * form owner's Drive and never touch the Fillo server.
2752
2756
  */
2753
2757
  async uploadFile(formId, file, options2) {
2758
+ await this.acquireUploadSlot(options2.signal);
2759
+ try {
2760
+ options2.signal?.throwIfAborted();
2761
+ return await this.performUpload(formId, file, options2);
2762
+ } finally {
2763
+ this.activeUploads -= 1;
2764
+ const next = this.uploadQueue.values().next().value;
2765
+ if (next) {
2766
+ this.uploadQueue.delete(next);
2767
+ next();
2768
+ }
2769
+ }
2770
+ }
2771
+ async acquireUploadSlot(signal) {
2772
+ signal?.throwIfAborted();
2773
+ if (this.activeUploads < MAX_CONCURRENT_UPLOADS) {
2774
+ this.activeUploads += 1;
2775
+ return;
2776
+ }
2777
+ await new Promise((resolve, reject) => {
2778
+ const start = () => {
2779
+ signal?.removeEventListener("abort", aborted);
2780
+ this.activeUploads += 1;
2781
+ resolve();
2782
+ };
2783
+ const aborted = () => {
2784
+ this.uploadQueue.delete(start);
2785
+ reject(signal?.reason);
2786
+ };
2787
+ this.uploadQueue.add(start);
2788
+ signal?.addEventListener("abort", aborted, { once: true });
2789
+ });
2790
+ }
2791
+ async performUpload(formId, file, options2) {
2754
2792
  const name = typeof File !== "undefined" && file instanceof File ? file.name : "upload.bin";
2755
2793
  const mime = (file.type || "application/octet-stream").trim().toLowerCase();
2756
2794
  let session;
@@ -4766,6 +4804,7 @@ export {
4766
4804
  FilloJsxError,
4767
4805
  JSX_BLOCK_COMPONENTS,
4768
4806
  JSX_BLOCK_SPECS,
4807
+ MAX_FILES_PER_FIELD,
4769
4808
  PHONE_COUNTRIES,
4770
4809
  PHONE_PICKER_COUNTRIES,
4771
4810
  PHONE_POPOVER_VIEWPORT_GAP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usefillo/core",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Form schema, validation, logic engine and JS client for Fillo. Framework-agnostic.",
5
5
  "license": "MIT",
6
6
  "keywords": [