@saastro/forms 0.3.0 → 0.4.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 +39 -23
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3781,36 +3781,48 @@ interface TemplateMeta {
|
|
|
3781
3781
|
declare const TEMPLATE_META: readonly TemplateMeta[];
|
|
3782
3782
|
|
|
3783
3783
|
/**
|
|
3784
|
-
* Build a `CustomSubmitConfig` that routes form submissions to
|
|
3785
|
-
* Saastro
|
|
3786
|
-
*
|
|
3784
|
+
* Build a `CustomSubmitConfig` that routes form submissions to the
|
|
3785
|
+
* Saastro ingestion endpoint (`submit.saastro.io/v1` by default).
|
|
3786
|
+
* Used by Astro / React sites whose forms are authored in Hub
|
|
3787
|
+
* (`builder.saastro.io` embed mode) and stored there.
|
|
3787
3788
|
*
|
|
3788
3789
|
* The flow is:
|
|
3789
3790
|
*
|
|
3790
3791
|
* 1. Walk the field values and split into `payload` (scalar/JSON-safe)
|
|
3791
|
-
* and `files` (instances of File).
|
|
3792
|
-
* files take a separate path.
|
|
3793
|
-
* 2. For each file, POST
|
|
3794
|
-
*
|
|
3795
|
-
*
|
|
3796
|
-
* 3. POST
|
|
3797
|
-
*
|
|
3798
|
-
*
|
|
3799
|
-
*
|
|
3800
|
-
*
|
|
3801
|
-
*
|
|
3802
|
-
* the host app must render the
|
|
3803
|
-
* via the special `
|
|
3804
|
-
* extracts it before sending.
|
|
3792
|
+
* and `files` (instances of File). The endpoint keeps text fields
|
|
3793
|
+
* together; files take a separate path.
|
|
3794
|
+
* 2. For each file, POST `/:siteId/:slug/upload-url` to get a
|
|
3795
|
+
* presigned R2 PUT URL, then PUT the binary directly to that URL.
|
|
3796
|
+
* The Worker never touches the file body — R2 receives it.
|
|
3797
|
+
* 3. POST `/:siteId/:slug/submit` with the textual payload + an
|
|
3798
|
+
* `attachments` array describing the uploaded R2 keys. The Worker
|
|
3799
|
+
* inserts the submission row and dispatches integrations (Sheets
|
|
3800
|
+
* / Resend / etc.) per the form's schema.
|
|
3801
|
+
*
|
|
3802
|
+
* Captcha: if the form schema declares `meta.captchaProvider`
|
|
3803
|
+
* ('turnstile' or 'recaptcha-v3'), the host app must render the widget
|
|
3804
|
+
* and pass the token via the special `_captchaToken` field (legacy
|
|
3805
|
+
* `_turnstile` is accepted too). The helper extracts it before sending.
|
|
3805
3806
|
*
|
|
3806
3807
|
* Honeypot: pass via `_hp` (or whatever `meta.honeypotField` says).
|
|
3807
|
-
* The
|
|
3808
|
+
* The endpoint will silently 200 the request and not store anything if
|
|
3808
3809
|
* the honeypot is non-empty.
|
|
3810
|
+
*
|
|
3811
|
+
* Endpoint history:
|
|
3812
|
+
* - v0.3.x and earlier: `https://hub.saastro.io/api/public/forms/...`
|
|
3813
|
+
* - v0.4.0+: `https://submit.saastro.io/v1/...` (dedicated worker)
|
|
3814
|
+
* See https://docs.forms.saastro.io/migration/v0.4 for details.
|
|
3809
3815
|
*/
|
|
3810
3816
|
|
|
3817
|
+
/** Default canonical ingestion endpoint. Override via `hubUrl` for self-hosting. */
|
|
3818
|
+
declare const DEFAULT_HUB_URL = "https://submit.saastro.io/v1";
|
|
3811
3819
|
interface CreateHubFormSubmitOptions {
|
|
3812
|
-
/**
|
|
3813
|
-
|
|
3820
|
+
/**
|
|
3821
|
+
* Ingestion endpoint base URL (no trailing slash). Defaults to
|
|
3822
|
+
* `https://submit.saastro.io/v1` — the canonical CF Worker.
|
|
3823
|
+
* Override for self-hosted Hub deployments or test envs.
|
|
3824
|
+
*/
|
|
3825
|
+
hubUrl?: string;
|
|
3814
3826
|
siteId: string;
|
|
3815
3827
|
formSlug: string;
|
|
3816
3828
|
}
|
|
@@ -3826,8 +3838,12 @@ interface CreateHubFormSubmitOptions {
|
|
|
3826
3838
|
declare function createHubFormSubmit(opts: CreateHubFormSubmitOptions): CustomSubmitConfig;
|
|
3827
3839
|
|
|
3828
3840
|
interface HubFormProps {
|
|
3829
|
-
/**
|
|
3830
|
-
|
|
3841
|
+
/**
|
|
3842
|
+
* Ingestion endpoint base URL (no trailing slash). Defaults to
|
|
3843
|
+
* `https://submit.saastro.io/v1` — the canonical hosted endpoint.
|
|
3844
|
+
* Override for self-hosted Hub or test envs.
|
|
3845
|
+
*/
|
|
3846
|
+
hubUrl?: string;
|
|
3831
3847
|
siteId: string;
|
|
3832
3848
|
formSlug: string;
|
|
3833
3849
|
/** Custom UI while the schema is being fetched. Defaults to a skeleton. */
|
|
@@ -3918,4 +3934,4 @@ declare function getFieldClass(formLayout?: {
|
|
|
3918
3934
|
*/
|
|
3919
3935
|
declare function getHiddenClasses(hidden?: Partial<Record<Breakpoint, 'visible' | 'hidden'>>): string;
|
|
3920
3936
|
|
|
3921
|
-
export { type AccordionContentProps, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, BUILD_METHODS, BUILTIN_RESOLVERS, type BaseFieldProps, type Breakpoint$1 as Breakpoint, type BuiltinTransform, type ButtonCardFieldProps, type ButtonCardOption, type ButtonCheckboxFieldProps, type ButtonConfig, type ButtonProps, type ButtonRadioFieldProps, COMMON_CLASSES, COMMON_METHODS, COMMON_STRINGS, type CalendarProps, type CheckboxFieldProps, type CheckboxGroupFieldProps, type CheckboxProps, type ColumnsValue, type ComboboxFieldProps, type CommandEmptyProps, type CommandFieldProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, type ComponentName, type ComponentOverrides, ComponentProvider, type ComponentProviderProps, type ComponentRegistry, type ComponentRegistryInput, ComponentResolver, type ComponentResolverConfig, type Condition, type ConditionGroup, type ConditionOperator, type CreateHubFormSubmitOptions, type CurrencyFieldProps, type CustomSubmitAction, type CustomSubmitConfig, type DatabowlConfig, type DateFieldProps, type DateRangeFieldProps, type DefaultSubmitConfig, type DefinePlugin, type DialogContentProps, type DialogDescriptionProps, type DialogHeaderProps, type DialogProps, type DialogTitleProps, type DialogTriggerProps, type EmailProvider, type EmailSubmitAction, type EndpointConfig, FIELD_DEFAULTS, FieldBuilder, type FieldConfig, type FieldDescriptionProps, type FieldErrorProps, type FieldLabelProps, type FieldLayoutConfig, type FieldMapEntry, type FieldMapping, type FieldMappingConfig, type FieldProps, FieldRenderer, type FieldResolver, type FieldTransformFn, type Fields, type FileFieldProps, Form, FormBuilder, type FormButtonProps, type FormButtons, FormComponentsProvider, type FormComponentsProviderProps, type FormConfig, type FormControlProps, type FormFieldProps, type FormLayout, type FormPlugin, type FormProps, type FormRef, type FormStepsInfo, type GapValue, type GlobModules, type HiddenFieldProps, type HtmlFieldProps, type HttpAuthConfig, type HttpBodyConfig, type HttpEndpointConfig, type HttpRetryConfig, type HttpSubmitAction, HubForm, type HubFormProps, type InputGroupFieldProps, type InputOTPGroupProps, type InputOTPProps, type InputOTPSlotProps, type InputProps, type InputSize, type IntegrationSubmitAction, InternalComponentProvider, type InternalComponentProviderProps, type LabelProps, MissingComponentFallback, type MissingComponentFallbackProps, type NativeSelectFieldProps, type NativeSelectProps, OPTION_BASED_TYPES, type Option, type OtpFieldProps, type PartialComponentRegistry, PluginManager, type PopoverContentProps, type PopoverProps, type PopoverTriggerProps, type PropertyMapping, type RadioFieldProps, type RadioGroupItemProps, type RadioGroupProps, type RangeFieldProps, type RecaptchaConfig, type RecaptchaPluginConfig, type RepeaterFieldProps, type ResolvedComponents, SUSPENSE_CONFIG, type SchemaType, type SelectContentProps, type SelectFieldProps, type SelectItemProps, type SelectProps, type SelectTriggerProps, type SelectValueProps, type SeparatorProps, type SerializableFieldResolver, type SerializationHint, type SliderFieldProps, type SliderProps, type Step, type StepCondition, type StepInfo, type StepStatus, type Steps, StepsAccordion, StepsNavigation, StepsProgress, type SubmitAction, type SubmitActionCondition, type SubmitActionNode, type SubmitActionResult, type SubmitActionType, type SubmitActionsResult, type SubmitConfig, type SubmitConfirmationConfig, type SubmitExecutionConfig, type SubmitTrigger, type SubmitTriggerType, type SubmitType, type SwitchFieldProps, type SwitchGroupFieldProps, type SwitchProps, TEMPLATES, TEMPLATE_META, TYPE_SPECIFIC_PROPERTIES, type TemplateId, type TemplateMeta, type TestDataLocale, type TestDataOptions, type TextFieldProps, type TextareaFieldProps, type TextareaProps, type TooltipContentProps, type TooltipProps, type TooltipProviderProps, type TooltipTriggerProps, type UseSubmitConfirmationReturn, VALIDATION_METHODS, type ValidateComponentRegistry, type ValidationContext, type ValidationPresetMeta, type ValidationRules, type WebhookSubmitAction, analyticsPlugin, applyBuiltinTransform, applyFieldMapping, applyFieldMappingSync, applyFieldTransforms, applyTransform, autosavePlugin, compileValidationRules, configureComponents, coreComponents, createComponentRegistry, createContactTemplate, createEventRsvpTemplate, createHubFormSubmit, createLeadGenTemplate, createMissingComponentPlaceholder, createNewsletterTemplate, createQuoteRequestTemplate, createShadcnRegistry, databowlAction, databowlPlugin, defaultSubmit, definePlugin, detectLocale, executeCustomAction, executeEmailAction, executeHttpAction, executeSubmitAction, executeSubmitActions, executeSubmitActionsByTrigger, executeWebhookAction, fieldTypeComponents, generateFieldValue, generateTestData, getActionsByTrigger, getAllKnownMethods, getAvailablePresets, getComponentResolver, getFieldClass, getFormGridClass, getHiddenClasses, getInstallCommand, getMinDelayMs, getMissingComponents, getRequiredComponents, globalPluginManager, groupMissingByPackage, iconVariants, iconVariantsConfig, inputVariants, inputVariantsConfig, isAdvancedMapping, isValidationRules, isZodSchema, localStoragePlugin, mergeComponentRegistries, parseGlobModules, pxToRem, recaptchaPlugin, registerPreset, resolvePreset, resolveValue, resolveValueSync, textareaVariants, textareaVariantsConfig, useComponentMode, useComponents, useComputedFields, useFormLayout, useFormState, useFormStepsInfo, useHasComponentProvider, useHiddenFieldResolvers, usePartialComponents, useRecaptcha, useSubmitActionTriggers, useSubmitConfirmation, withComponents };
|
|
3937
|
+
export { type AccordionContentProps, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, BUILD_METHODS, BUILTIN_RESOLVERS, type BaseFieldProps, type Breakpoint$1 as Breakpoint, type BuiltinTransform, type ButtonCardFieldProps, type ButtonCardOption, type ButtonCheckboxFieldProps, type ButtonConfig, type ButtonProps, type ButtonRadioFieldProps, COMMON_CLASSES, COMMON_METHODS, COMMON_STRINGS, type CalendarProps, type CheckboxFieldProps, type CheckboxGroupFieldProps, type CheckboxProps, type ColumnsValue, type ComboboxFieldProps, type CommandEmptyProps, type CommandFieldProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, type ComponentName, type ComponentOverrides, ComponentProvider, type ComponentProviderProps, type ComponentRegistry, type ComponentRegistryInput, ComponentResolver, type ComponentResolverConfig, type Condition, type ConditionGroup, type ConditionOperator, type CreateHubFormSubmitOptions, type CurrencyFieldProps, type CustomSubmitAction, type CustomSubmitConfig, DEFAULT_HUB_URL, type DatabowlConfig, type DateFieldProps, type DateRangeFieldProps, type DefaultSubmitConfig, type DefinePlugin, type DialogContentProps, type DialogDescriptionProps, type DialogHeaderProps, type DialogProps, type DialogTitleProps, type DialogTriggerProps, type EmailProvider, type EmailSubmitAction, type EndpointConfig, FIELD_DEFAULTS, FieldBuilder, type FieldConfig, type FieldDescriptionProps, type FieldErrorProps, type FieldLabelProps, type FieldLayoutConfig, type FieldMapEntry, type FieldMapping, type FieldMappingConfig, type FieldProps, FieldRenderer, type FieldResolver, type FieldTransformFn, type Fields, type FileFieldProps, Form, FormBuilder, type FormButtonProps, type FormButtons, FormComponentsProvider, type FormComponentsProviderProps, type FormConfig, type FormControlProps, type FormFieldProps, type FormLayout, type FormPlugin, type FormProps, type FormRef, type FormStepsInfo, type GapValue, type GlobModules, type HiddenFieldProps, type HtmlFieldProps, type HttpAuthConfig, type HttpBodyConfig, type HttpEndpointConfig, type HttpRetryConfig, type HttpSubmitAction, HubForm, type HubFormProps, type InputGroupFieldProps, type InputOTPGroupProps, type InputOTPProps, type InputOTPSlotProps, type InputProps, type InputSize, type IntegrationSubmitAction, InternalComponentProvider, type InternalComponentProviderProps, type LabelProps, MissingComponentFallback, type MissingComponentFallbackProps, type NativeSelectFieldProps, type NativeSelectProps, OPTION_BASED_TYPES, type Option, type OtpFieldProps, type PartialComponentRegistry, PluginManager, type PopoverContentProps, type PopoverProps, type PopoverTriggerProps, type PropertyMapping, type RadioFieldProps, type RadioGroupItemProps, type RadioGroupProps, type RangeFieldProps, type RecaptchaConfig, type RecaptchaPluginConfig, type RepeaterFieldProps, type ResolvedComponents, SUSPENSE_CONFIG, type SchemaType, type SelectContentProps, type SelectFieldProps, type SelectItemProps, type SelectProps, type SelectTriggerProps, type SelectValueProps, type SeparatorProps, type SerializableFieldResolver, type SerializationHint, type SliderFieldProps, type SliderProps, type Step, type StepCondition, type StepInfo, type StepStatus, type Steps, StepsAccordion, StepsNavigation, StepsProgress, type SubmitAction, type SubmitActionCondition, type SubmitActionNode, type SubmitActionResult, type SubmitActionType, type SubmitActionsResult, type SubmitConfig, type SubmitConfirmationConfig, type SubmitExecutionConfig, type SubmitTrigger, type SubmitTriggerType, type SubmitType, type SwitchFieldProps, type SwitchGroupFieldProps, type SwitchProps, TEMPLATES, TEMPLATE_META, TYPE_SPECIFIC_PROPERTIES, type TemplateId, type TemplateMeta, type TestDataLocale, type TestDataOptions, type TextFieldProps, type TextareaFieldProps, type TextareaProps, type TooltipContentProps, type TooltipProps, type TooltipProviderProps, type TooltipTriggerProps, type UseSubmitConfirmationReturn, VALIDATION_METHODS, type ValidateComponentRegistry, type ValidationContext, type ValidationPresetMeta, type ValidationRules, type WebhookSubmitAction, analyticsPlugin, applyBuiltinTransform, applyFieldMapping, applyFieldMappingSync, applyFieldTransforms, applyTransform, autosavePlugin, compileValidationRules, configureComponents, coreComponents, createComponentRegistry, createContactTemplate, createEventRsvpTemplate, createHubFormSubmit, createLeadGenTemplate, createMissingComponentPlaceholder, createNewsletterTemplate, createQuoteRequestTemplate, createShadcnRegistry, databowlAction, databowlPlugin, defaultSubmit, definePlugin, detectLocale, executeCustomAction, executeEmailAction, executeHttpAction, executeSubmitAction, executeSubmitActions, executeSubmitActionsByTrigger, executeWebhookAction, fieldTypeComponents, generateFieldValue, generateTestData, getActionsByTrigger, getAllKnownMethods, getAvailablePresets, getComponentResolver, getFieldClass, getFormGridClass, getHiddenClasses, getInstallCommand, getMinDelayMs, getMissingComponents, getRequiredComponents, globalPluginManager, groupMissingByPackage, iconVariants, iconVariantsConfig, inputVariants, inputVariantsConfig, isAdvancedMapping, isValidationRules, isZodSchema, localStoragePlugin, mergeComponentRegistries, parseGlobModules, pxToRem, recaptchaPlugin, registerPreset, resolvePreset, resolveValue, resolveValueSync, textareaVariants, textareaVariantsConfig, useComponentMode, useComponents, useComputedFields, useFormLayout, useFormState, useFormStepsInfo, useHasComponentProvider, useHiddenFieldResolvers, usePartialComponents, useRecaptcha, useSubmitActionTriggers, useSubmitConfirmation, withComponents };
|
package/dist/index.js
CHANGED
|
@@ -6959,9 +6959,10 @@ var TEMPLATE_META = [
|
|
|
6959
6959
|
];
|
|
6960
6960
|
|
|
6961
6961
|
// src/lib/createHubFormSubmit.ts
|
|
6962
|
+
var DEFAULT_HUB_URL = "https://submit.saastro.io/v1";
|
|
6962
6963
|
function publicBase({ hubUrl, siteId, formSlug }) {
|
|
6963
|
-
const
|
|
6964
|
-
return `${
|
|
6964
|
+
const base = (hubUrl ?? DEFAULT_HUB_URL).replace(/\/+$/, "");
|
|
6965
|
+
return `${base}/${encodeURIComponent(siteId)}/${encodeURIComponent(formSlug)}`;
|
|
6965
6966
|
}
|
|
6966
6967
|
async function presignAndUpload(base, file) {
|
|
6967
6968
|
const presignRes = await fetch(`${base}/upload-url`, {
|
|
@@ -6999,7 +7000,7 @@ function partitionValues(values) {
|
|
|
6999
7000
|
let turnstileToken = null;
|
|
7000
7001
|
const honeypotEntries = [];
|
|
7001
7002
|
for (const [key, value] of Object.entries(values)) {
|
|
7002
|
-
if (key === "_turnstile") {
|
|
7003
|
+
if (key === "_captchaToken" || key === "_turnstile") {
|
|
7003
7004
|
if (typeof value === "string") turnstileToken = value;
|
|
7004
7005
|
continue;
|
|
7005
7006
|
}
|
|
@@ -7039,7 +7040,10 @@ function createHubFormSubmit(opts) {
|
|
|
7039
7040
|
body: JSON.stringify({
|
|
7040
7041
|
payload,
|
|
7041
7042
|
attachments,
|
|
7042
|
-
|
|
7043
|
+
// Send under the canonical name. The worker also accepts the
|
|
7044
|
+
// legacy `turnstile` field for old SDK callers, but new sends
|
|
7045
|
+
// should use `captchaToken`.
|
|
7046
|
+
captchaToken: turnstileToken ?? void 0,
|
|
7043
7047
|
...honeypotEntry
|
|
7044
7048
|
})
|
|
7045
7049
|
});
|
|
@@ -7083,8 +7087,8 @@ function HubForm({
|
|
|
7083
7087
|
const [state, setState] = useState5({ status: "loading" });
|
|
7084
7088
|
useEffect8(() => {
|
|
7085
7089
|
let cancelled = false;
|
|
7086
|
-
const cleanHub = hubUrl.replace(/\/+$/, "");
|
|
7087
|
-
const url = `${cleanHub}
|
|
7090
|
+
const cleanHub = (hubUrl ?? DEFAULT_HUB_URL).replace(/\/+$/, "");
|
|
7091
|
+
const url = `${cleanHub}/${encodeURIComponent(siteId)}/${encodeURIComponent(formSlug)}.json`;
|
|
7088
7092
|
fetch(url, { headers: { accept: "application/json" } }).then(async (res) => {
|
|
7089
7093
|
if (!res.ok) throw new Error(`schema fetch failed: ${res.status} ${res.statusText}`);
|
|
7090
7094
|
return res.json();
|
|
@@ -7408,6 +7412,7 @@ export {
|
|
|
7408
7412
|
COMMON_STRINGS,
|
|
7409
7413
|
ComponentProvider,
|
|
7410
7414
|
ComponentResolver,
|
|
7415
|
+
DEFAULT_HUB_URL,
|
|
7411
7416
|
FIELD_DEFAULTS,
|
|
7412
7417
|
FieldBuilder,
|
|
7413
7418
|
FieldRenderer,
|