@usefillo/core 0.2.1 → 0.2.3

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
@@ -435,6 +435,38 @@ declare class FilloClient {
435
435
  private s3PutUpload;
436
436
  }
437
437
  declare function createClient(options?: FilloClientOptions): FilloClient;
438
+ interface ProvisionWorkspaceResult {
439
+ /** Publishable key (pk_…) for the new workspace. Pass to createClient({ key }). */
440
+ key: string;
441
+ organizationId: string;
442
+ /** A claim link was emailed here so the owner can take ownership later. */
443
+ claim: {
444
+ email: string;
445
+ sent: boolean;
446
+ };
447
+ /** Caps applied until the workspace is claimed. */
448
+ limits: {
449
+ responses: number;
450
+ expiresAt: string;
451
+ };
452
+ }
453
+ /**
454
+ * Provision a Fillo workspace from an email — no signup — and get a publishable
455
+ * key back, so a form can collect real responses immediately. A claim link is
456
+ * emailed to `email`; until someone claims it the workspace runs as a capped
457
+ * preview (limited responses, for a limited time). Built for setup automation,
458
+ * e.g. a coding agent wiring Fillo into an app during integration.
459
+ *
460
+ * const { key } = await provisionWorkspace({ email: "you@co.com" });
461
+ * const client = createClient({ key });
462
+ */
463
+ declare function provisionWorkspace(options: {
464
+ email: string;
465
+ baseUrl?: string;
466
+ /** Free-form provenance label, e.g. "agent" | "cli". */
467
+ source?: string;
468
+ fetch?: typeof fetch;
469
+ }): Promise<ProvisionWorkspaceResult>;
438
470
 
439
471
  type FormStatus = "idle" | "submitting" | "submitted" | "error";
440
472
  interface FormControllerOptions {
@@ -551,4 +583,4 @@ declare function pipeBlock(block: Block, data: ResponseData, form: FormSchema):
551
583
  /** Dependency-free nanoid-style id with an unbiased alphabet. Crypto-random. */
552
584
  declare function createId(size?: number): string;
553
585
 
554
- export { BLOCK_KIND_META, type BaseField, type Block, type BlockKind, CONTENT_KINDS, type CheckboxField, type ChoiceField, type CodeForm, type Condition, type ConditionOp, type ContentBlock, type ContentKind, type CustomField, DRAFT_KINDS, type DateField, type DividerBlock, type Field, type FieldKind, type FieldSpec, type FieldValue, type FileUploadField, type FileValue, FilloClient, type FilloClientOptions, FilloError, type FormController, type FormControllerOptions, type FormControllerState, type FormDraftSpec, type FormPage, type FormSchema, type FormSettings, type FormStatus, type FormTheme, type HeadingBlock, type HiddenField, type JsonValue, type LinearScaleField, type MatrixField, type NumberField, type ParagraphBlock, type PublishedForm, type RankingField, type RatingField, type ResponseData, type SchemaValidationResult, type SelectOption, type SignatureField, type SubmitMeta, type SubmitResult, type TextField, type UploadFileOptions, type UploadProgress, type UploadSession, type UploadStatus, type UploadTransport, type ValidationResult, allFields, assembleForm, createBlock, createClient, createEmptyForm, createFormController, createId, defineForm, formatAnswer, isBlockVisible, isCodeForm, isField, pipeBlock, prefillFromParams, resolveText, syncCodeForm, validateField, validateFormSchema, validateResponse, visibleBlocks, visibleFields };
586
+ export { BLOCK_KIND_META, type BaseField, type Block, type BlockKind, CONTENT_KINDS, type CheckboxField, type ChoiceField, type CodeForm, type Condition, type ConditionOp, type ContentBlock, type ContentKind, type CustomField, DRAFT_KINDS, type DateField, type DividerBlock, type Field, type FieldKind, type FieldSpec, type FieldValue, type FileUploadField, type FileValue, FilloClient, type FilloClientOptions, FilloError, type FormController, type FormControllerOptions, type FormControllerState, type FormDraftSpec, type FormPage, type FormSchema, type FormSettings, type FormStatus, type FormTheme, type HeadingBlock, type HiddenField, type JsonValue, type LinearScaleField, type MatrixField, type NumberField, type ParagraphBlock, type ProvisionWorkspaceResult, type PublishedForm, type RankingField, type RatingField, type ResponseData, type SchemaValidationResult, type SelectOption, type SignatureField, type SubmitMeta, type SubmitResult, type TextField, type UploadFileOptions, type UploadProgress, type UploadSession, type UploadStatus, type UploadTransport, type ValidationResult, allFields, assembleForm, createBlock, createClient, createEmptyForm, createFormController, createId, defineForm, formatAnswer, isBlockVisible, isCodeForm, isField, pipeBlock, prefillFromParams, provisionWorkspace, resolveText, syncCodeForm, validateField, validateFormSchema, validateResponse, visibleBlocks, visibleFields };
package/dist/index.js CHANGED
@@ -839,6 +839,20 @@ var FilloClient = class {
839
839
  function createClient(options = {}) {
840
840
  return new FilloClient(options);
841
841
  }
842
+ async function provisionWorkspace(options) {
843
+ const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
844
+ const doFetch = options.fetch ?? ((...args) => globalThis.fetch(...args));
845
+ const res = await doFetch(`${baseUrl}/api/v1/workspaces/provision`, {
846
+ method: "POST",
847
+ headers: { "Content-Type": "application/json" },
848
+ body: JSON.stringify({ email: options.email, source: options.source ?? "sdk" })
849
+ });
850
+ if (!res.ok) {
851
+ const body = await res.text().catch(() => "");
852
+ throw new FilloError(body || `Provision failed: ${res.status}`, res.status);
853
+ }
854
+ return await res.json();
855
+ }
842
856
 
843
857
  // src/controller.ts
844
858
  var EMPTY_PAGE = { id: "empty", blocks: [] };
@@ -1133,6 +1147,7 @@ export {
1133
1147
  isField,
1134
1148
  pipeBlock,
1135
1149
  prefillFromParams,
1150
+ provisionWorkspace,
1136
1151
  resolveText,
1137
1152
  syncCodeForm,
1138
1153
  validateField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usefillo/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Form schema, validation, logic engine and JS client for Fillo. Framework-agnostic.",
5
5
  "license": "MIT",
6
6
  "keywords": [