@amplifyup/sdk 0.2.4 → 0.3.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/README.md +13 -1
- package/dist/{AmplifyRenderer-BNWBrFQN.d.ts → AmplifyRenderer-CwAYY8K1.d.mts} +4 -5
- package/dist/{AmplifyRenderer-CPUr9Bkc.d.mts → AmplifyRenderer-D40crBWY.d.ts} +4 -5
- package/dist/AmplifyRenderer.d.mts +2 -3
- package/dist/AmplifyRenderer.d.ts +2 -3
- package/dist/AmplifyRenderer.js +3 -30
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +3 -30
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +240 -4
- package/dist/index.d.ts +240 -4
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -2
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +101 -8
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +100 -8
- package/dist/next.mjs.map +1 -1
- package/dist/{query-Xo9cy-2F.d.ts → query-BeQibYGm.d.ts} +56 -56
- package/dist/{query-DYjs4LQQ.d.mts → query-CwtZtJX8.d.mts} +56 -56
- package/dist/react.d.mts +23 -17
- package/dist/react.d.ts +23 -17
- package/dist/react.js +4 -31
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +4 -31
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +1 -1
- package/dist/{types-ffQNIQCK.d.ts → types-CxucvIL6.d.mts} +1 -1
- package/dist/{types-ffQNIQCK.d.mts → types-CxucvIL6.d.ts} +1 -1
- package/package.json +8 -7
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -266
- package/dist/cli.js.map +0 -1
- package/dist/cli.mjs +0 -260
- package/dist/cli.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource,
|
|
2
|
-
export { Z as ZoneConfig,
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, R as ResolvedPageResourceRef, b as PageTaxonomies, c as CDPAdapter, d as AmplifyUpConfig, e as EventProperties, f as AmplifyPageContextInput, g as AttachedPageEventContext, I as IdentifyInput, h as IdentifyTraits, i as ProfileFieldsInput, j as AmplifyUpTarget } from './types-CxucvIL6.mjs';
|
|
2
|
+
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, l as resolveAmplifyUpUrls } from './types-CxucvIL6.mjs';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
4
4
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.mjs';
|
|
5
|
-
export {
|
|
5
|
+
export { F as FetchEdgeQueryOptions, a as FetchEdgeSelectOptions, Q as QueryContentError, b as QueryContentOptions, c as QueryFilter, d as QueryFilterOp, e as QueryPagination, f as QueryResult, g as QuerySort, h as QuerySpec, S as SelectVariantsError, i as SelectVariantsOptions, j as SelectVariantsResult, k as fetchEdgeQuery, l as fetchEdgeSelect, n as nextPageSpec, q as queryContent, s as searchSpec, m as selectVariants } from './query-CwtZtJX8.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -118,6 +118,242 @@ declare function fetchEdgeResolve(options: {
|
|
|
118
118
|
revalidate?: number | false;
|
|
119
119
|
}): Promise<EdgeResolvedPayload>;
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* This file was auto-generated by openapi-typescript.
|
|
123
|
+
* Do not make direct changes to the file.
|
|
124
|
+
*/
|
|
125
|
+
interface paths {
|
|
126
|
+
"/v1/forms/{formId}": {
|
|
127
|
+
parameters: {
|
|
128
|
+
query?: never;
|
|
129
|
+
header?: never;
|
|
130
|
+
path?: never;
|
|
131
|
+
cookie?: never;
|
|
132
|
+
};
|
|
133
|
+
get: operations["getFormDefinition"];
|
|
134
|
+
put?: never;
|
|
135
|
+
post?: never;
|
|
136
|
+
delete?: never;
|
|
137
|
+
options?: never;
|
|
138
|
+
head?: never;
|
|
139
|
+
patch?: never;
|
|
140
|
+
trace?: never;
|
|
141
|
+
};
|
|
142
|
+
"/v1/forms/{formId}/submit": {
|
|
143
|
+
parameters: {
|
|
144
|
+
query?: never;
|
|
145
|
+
header?: never;
|
|
146
|
+
path?: never;
|
|
147
|
+
cookie?: never;
|
|
148
|
+
};
|
|
149
|
+
get?: never;
|
|
150
|
+
put?: never;
|
|
151
|
+
post: operations["submitForm"];
|
|
152
|
+
delete?: never;
|
|
153
|
+
options?: never;
|
|
154
|
+
head?: never;
|
|
155
|
+
patch?: never;
|
|
156
|
+
trace?: never;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
interface components {
|
|
160
|
+
schemas: {
|
|
161
|
+
DeliveryErrorBody: {
|
|
162
|
+
error: string;
|
|
163
|
+
};
|
|
164
|
+
FormDefinition: {
|
|
165
|
+
id: string;
|
|
166
|
+
key: string;
|
|
167
|
+
version: number;
|
|
168
|
+
fields: components["schemas"]["FormField"][];
|
|
169
|
+
submit: components["schemas"]["FormSubmitSettings"];
|
|
170
|
+
onSuccess: components["schemas"]["FormOnSuccess"];
|
|
171
|
+
honeypot: components["schemas"]["FormHoneypot"];
|
|
172
|
+
};
|
|
173
|
+
FormField: {
|
|
174
|
+
/** @description Key the submitted value is posted under. */
|
|
175
|
+
key: string;
|
|
176
|
+
type: components["schemas"]["FormFieldType"];
|
|
177
|
+
label?: string;
|
|
178
|
+
required?: boolean;
|
|
179
|
+
placeholder?: string;
|
|
180
|
+
/** @description For `select`. */
|
|
181
|
+
options?: components["schemas"]["FormFieldOption"][];
|
|
182
|
+
/** @description Initial value; the posted value for `hidden`. */
|
|
183
|
+
defaultValue?: string;
|
|
184
|
+
};
|
|
185
|
+
FormFieldOption: {
|
|
186
|
+
label: string;
|
|
187
|
+
value: string;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* @description Delivery API for published forms, as the form packages see it. GET /v1/forms/{formId}?trackingId= → FormDefinition POST /v1/forms/{formId}/submit?trackingId= → SubmitFormSuccess | 422 SubmitFormValidationError
|
|
191
|
+
*
|
|
192
|
+
* Source of truth for `openapi/delivery.json` (scripts/generate-openapi.mjs). Never carries mapping metadata: what a submission writes to is platform-only.
|
|
193
|
+
* @enum {string}
|
|
194
|
+
*/
|
|
195
|
+
FormFieldType: "text" | "email" | "phone" | "textarea" | "select" | "checkbox" | "hidden";
|
|
196
|
+
FormHoneypot: {
|
|
197
|
+
/** @description Field name to post empty; bots that fill it are dropped. */
|
|
198
|
+
name: string;
|
|
199
|
+
};
|
|
200
|
+
FormOnSuccess: components["schemas"]["FormSuccessMessage"] | components["schemas"]["FormSuccessRedirect"];
|
|
201
|
+
FormSubmitSettings: {
|
|
202
|
+
label: string;
|
|
203
|
+
};
|
|
204
|
+
FormSuccessMessage: {
|
|
205
|
+
/** @constant */
|
|
206
|
+
type: "message";
|
|
207
|
+
message: string;
|
|
208
|
+
};
|
|
209
|
+
FormSuccessRedirect: {
|
|
210
|
+
/** @constant */
|
|
211
|
+
type: "redirect";
|
|
212
|
+
url: string;
|
|
213
|
+
};
|
|
214
|
+
FormValue: string | boolean;
|
|
215
|
+
SubmitFormRequest: {
|
|
216
|
+
/** @description Field values by key, including the honeypot key. */
|
|
217
|
+
values: {
|
|
218
|
+
[key: string]: components["schemas"]["FormValue"];
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
SubmitFormSuccess: {
|
|
222
|
+
onSuccess: components["schemas"]["FormOnSuccess"];
|
|
223
|
+
};
|
|
224
|
+
SubmitFormValidationError: {
|
|
225
|
+
/** @description Message per field key. */
|
|
226
|
+
errors: {
|
|
227
|
+
[key: string]: string;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
responses: never;
|
|
232
|
+
parameters: never;
|
|
233
|
+
requestBodies: never;
|
|
234
|
+
headers: never;
|
|
235
|
+
pathItems: never;
|
|
236
|
+
}
|
|
237
|
+
interface operations {
|
|
238
|
+
getFormDefinition: {
|
|
239
|
+
parameters: {
|
|
240
|
+
query: {
|
|
241
|
+
trackingId: string;
|
|
242
|
+
};
|
|
243
|
+
header?: never;
|
|
244
|
+
path: {
|
|
245
|
+
formId: string;
|
|
246
|
+
};
|
|
247
|
+
cookie?: never;
|
|
248
|
+
};
|
|
249
|
+
requestBody?: never;
|
|
250
|
+
responses: {
|
|
251
|
+
/** @description Published form definition */
|
|
252
|
+
200: {
|
|
253
|
+
headers: {
|
|
254
|
+
[name: string]: unknown;
|
|
255
|
+
};
|
|
256
|
+
content: {
|
|
257
|
+
"application/json": components["schemas"]["FormDefinition"];
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
/** @description Unknown tracking id or no published form */
|
|
261
|
+
404: {
|
|
262
|
+
headers: {
|
|
263
|
+
[name: string]: unknown;
|
|
264
|
+
};
|
|
265
|
+
content: {
|
|
266
|
+
"application/json": components["schemas"]["DeliveryErrorBody"];
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
submitForm: {
|
|
272
|
+
parameters: {
|
|
273
|
+
query: {
|
|
274
|
+
trackingId: string;
|
|
275
|
+
};
|
|
276
|
+
header?: never;
|
|
277
|
+
path: {
|
|
278
|
+
formId: string;
|
|
279
|
+
};
|
|
280
|
+
cookie?: never;
|
|
281
|
+
};
|
|
282
|
+
requestBody: {
|
|
283
|
+
content: {
|
|
284
|
+
"application/json": components["schemas"]["SubmitFormRequest"];
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
responses: {
|
|
288
|
+
/** @description Accepted */
|
|
289
|
+
200: {
|
|
290
|
+
headers: {
|
|
291
|
+
[name: string]: unknown;
|
|
292
|
+
};
|
|
293
|
+
content: {
|
|
294
|
+
"application/json": components["schemas"]["SubmitFormSuccess"];
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
/** @description Unknown tracking id or no published form */
|
|
298
|
+
404: {
|
|
299
|
+
headers: {
|
|
300
|
+
[name: string]: unknown;
|
|
301
|
+
};
|
|
302
|
+
content: {
|
|
303
|
+
"application/json": components["schemas"]["DeliveryErrorBody"];
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
/** @description Field errors */
|
|
307
|
+
422: {
|
|
308
|
+
headers: {
|
|
309
|
+
[name: string]: unknown;
|
|
310
|
+
};
|
|
311
|
+
content: {
|
|
312
|
+
"application/json": components["schemas"]["SubmitFormValidationError"];
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Typed client for published forms on the Amplify UP delivery API.
|
|
321
|
+
* Types are generated from the platform's API spec (see `npm run codegen`).
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
type Schemas = components['schemas'];
|
|
325
|
+
type FormDefinition = Schemas['FormDefinition'];
|
|
326
|
+
type FormField = Schemas['FormField'];
|
|
327
|
+
type FormFieldType = Schemas['FormFieldType'];
|
|
328
|
+
type FormFieldOption = Schemas['FormFieldOption'];
|
|
329
|
+
type FormOnSuccess = Schemas['FormOnSuccess'];
|
|
330
|
+
type FormValue = Schemas['FormValue'];
|
|
331
|
+
type FormValues = Schemas['SubmitFormRequest']['values'];
|
|
332
|
+
type SubmitOperation = paths['/v1/forms/{formId}/submit']['post'];
|
|
333
|
+
type SubmitAccepted = SubmitOperation['responses'][200]['content']['application/json'];
|
|
334
|
+
type SubmitRejected = SubmitOperation['responses'][422]['content']['application/json'];
|
|
335
|
+
type SubmitFormResult = {
|
|
336
|
+
ok: true;
|
|
337
|
+
onSuccess: SubmitAccepted['onSuccess'];
|
|
338
|
+
} | {
|
|
339
|
+
ok: false;
|
|
340
|
+
errors: SubmitRejected['errors'];
|
|
341
|
+
};
|
|
342
|
+
declare class DeliveryRequestError extends Error {
|
|
343
|
+
readonly status: number;
|
|
344
|
+
constructor(message: string, status: number);
|
|
345
|
+
}
|
|
346
|
+
type FormRequestOptions = {
|
|
347
|
+
fetch?: typeof fetch;
|
|
348
|
+
};
|
|
349
|
+
/** Load the published definition of a form. */
|
|
350
|
+
declare const getFormDefinition: (formId: string, options?: FormRequestOptions) => Promise<FormDefinition>;
|
|
351
|
+
/**
|
|
352
|
+
* Submit a form. Field errors (422) come back as `{ ok: false, errors }`;
|
|
353
|
+
* anything else that fails throws. Never submits from a Composer preview.
|
|
354
|
+
*/
|
|
355
|
+
declare const submitForm: (formId: string, values: FormValues, options?: FormRequestOptions) => Promise<SubmitFormResult>;
|
|
356
|
+
|
|
121
357
|
/**
|
|
122
358
|
* Map Edge /v1/resolve payload → PageConfig for AmplifyRenderer.
|
|
123
359
|
* Prefers `tree` (full page skeleton with zones spliced in); falls back to
|
|
@@ -593,4 +829,4 @@ declare const verifyAWSConnection: () => {
|
|
|
593
829
|
|
|
594
830
|
declare const _default: AmplifyUpSDK;
|
|
595
831
|
|
|
596
|
-
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, PageTaxonomies, ProfileFieldsInput, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getSessionId, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
832
|
+
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, DeliveryRequestError, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, type FormDefinition, type FormField, type FormFieldOption, type FormFieldType, type FormOnSuccess, type FormValue, type FormValues, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, PageTaxonomies, ProfileFieldsInput, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, type SubmitFormResult, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getFormDefinition, getInstanceId, getOrchestratorUrl, getSDK, getSessionId, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, submitForm, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PageConfig, C as ContentSource,
|
|
2
|
-
export { Z as ZoneConfig,
|
|
1
|
+
import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as PageDataSnapshot, R as ResolvedPageResourceRef, b as PageTaxonomies, c as CDPAdapter, d as AmplifyUpConfig, e as EventProperties, f as AmplifyPageContextInput, g as AttachedPageEventContext, I as IdentifyInput, h as IdentifyTraits, i as ProfileFieldsInput, j as AmplifyUpTarget } from './types-CxucvIL6.js';
|
|
2
|
+
export { Z as ZoneConfig, k as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, l as resolveAmplifyUpUrls } from './types-CxucvIL6.js';
|
|
3
3
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
|
|
4
4
|
export { A as AMPLIFYUP_EDITOR_ROUTE, i as isAmplifyUpEditorRoute } from './reservedRoutes-aGgViBDM.js';
|
|
5
|
-
export {
|
|
5
|
+
export { F as FetchEdgeQueryOptions, a as FetchEdgeSelectOptions, Q as QueryContentError, b as QueryContentOptions, c as QueryFilter, d as QueryFilterOp, e as QueryPagination, f as QueryResult, g as QuerySort, h as QuerySpec, S as SelectVariantsError, i as SelectVariantsOptions, j as SelectVariantsResult, k as fetchEdgeQuery, l as fetchEdgeSelect, n as nextPageSpec, q as queryContent, s as searchSpec, m as selectVariants } from './query-BeQibYGm.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Storage utilities for instance ID and user ID
|
|
@@ -118,6 +118,242 @@ declare function fetchEdgeResolve(options: {
|
|
|
118
118
|
revalidate?: number | false;
|
|
119
119
|
}): Promise<EdgeResolvedPayload>;
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* This file was auto-generated by openapi-typescript.
|
|
123
|
+
* Do not make direct changes to the file.
|
|
124
|
+
*/
|
|
125
|
+
interface paths {
|
|
126
|
+
"/v1/forms/{formId}": {
|
|
127
|
+
parameters: {
|
|
128
|
+
query?: never;
|
|
129
|
+
header?: never;
|
|
130
|
+
path?: never;
|
|
131
|
+
cookie?: never;
|
|
132
|
+
};
|
|
133
|
+
get: operations["getFormDefinition"];
|
|
134
|
+
put?: never;
|
|
135
|
+
post?: never;
|
|
136
|
+
delete?: never;
|
|
137
|
+
options?: never;
|
|
138
|
+
head?: never;
|
|
139
|
+
patch?: never;
|
|
140
|
+
trace?: never;
|
|
141
|
+
};
|
|
142
|
+
"/v1/forms/{formId}/submit": {
|
|
143
|
+
parameters: {
|
|
144
|
+
query?: never;
|
|
145
|
+
header?: never;
|
|
146
|
+
path?: never;
|
|
147
|
+
cookie?: never;
|
|
148
|
+
};
|
|
149
|
+
get?: never;
|
|
150
|
+
put?: never;
|
|
151
|
+
post: operations["submitForm"];
|
|
152
|
+
delete?: never;
|
|
153
|
+
options?: never;
|
|
154
|
+
head?: never;
|
|
155
|
+
patch?: never;
|
|
156
|
+
trace?: never;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
interface components {
|
|
160
|
+
schemas: {
|
|
161
|
+
DeliveryErrorBody: {
|
|
162
|
+
error: string;
|
|
163
|
+
};
|
|
164
|
+
FormDefinition: {
|
|
165
|
+
id: string;
|
|
166
|
+
key: string;
|
|
167
|
+
version: number;
|
|
168
|
+
fields: components["schemas"]["FormField"][];
|
|
169
|
+
submit: components["schemas"]["FormSubmitSettings"];
|
|
170
|
+
onSuccess: components["schemas"]["FormOnSuccess"];
|
|
171
|
+
honeypot: components["schemas"]["FormHoneypot"];
|
|
172
|
+
};
|
|
173
|
+
FormField: {
|
|
174
|
+
/** @description Key the submitted value is posted under. */
|
|
175
|
+
key: string;
|
|
176
|
+
type: components["schemas"]["FormFieldType"];
|
|
177
|
+
label?: string;
|
|
178
|
+
required?: boolean;
|
|
179
|
+
placeholder?: string;
|
|
180
|
+
/** @description For `select`. */
|
|
181
|
+
options?: components["schemas"]["FormFieldOption"][];
|
|
182
|
+
/** @description Initial value; the posted value for `hidden`. */
|
|
183
|
+
defaultValue?: string;
|
|
184
|
+
};
|
|
185
|
+
FormFieldOption: {
|
|
186
|
+
label: string;
|
|
187
|
+
value: string;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* @description Delivery API for published forms, as the form packages see it. GET /v1/forms/{formId}?trackingId= → FormDefinition POST /v1/forms/{formId}/submit?trackingId= → SubmitFormSuccess | 422 SubmitFormValidationError
|
|
191
|
+
*
|
|
192
|
+
* Source of truth for `openapi/delivery.json` (scripts/generate-openapi.mjs). Never carries mapping metadata: what a submission writes to is platform-only.
|
|
193
|
+
* @enum {string}
|
|
194
|
+
*/
|
|
195
|
+
FormFieldType: "text" | "email" | "phone" | "textarea" | "select" | "checkbox" | "hidden";
|
|
196
|
+
FormHoneypot: {
|
|
197
|
+
/** @description Field name to post empty; bots that fill it are dropped. */
|
|
198
|
+
name: string;
|
|
199
|
+
};
|
|
200
|
+
FormOnSuccess: components["schemas"]["FormSuccessMessage"] | components["schemas"]["FormSuccessRedirect"];
|
|
201
|
+
FormSubmitSettings: {
|
|
202
|
+
label: string;
|
|
203
|
+
};
|
|
204
|
+
FormSuccessMessage: {
|
|
205
|
+
/** @constant */
|
|
206
|
+
type: "message";
|
|
207
|
+
message: string;
|
|
208
|
+
};
|
|
209
|
+
FormSuccessRedirect: {
|
|
210
|
+
/** @constant */
|
|
211
|
+
type: "redirect";
|
|
212
|
+
url: string;
|
|
213
|
+
};
|
|
214
|
+
FormValue: string | boolean;
|
|
215
|
+
SubmitFormRequest: {
|
|
216
|
+
/** @description Field values by key, including the honeypot key. */
|
|
217
|
+
values: {
|
|
218
|
+
[key: string]: components["schemas"]["FormValue"];
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
SubmitFormSuccess: {
|
|
222
|
+
onSuccess: components["schemas"]["FormOnSuccess"];
|
|
223
|
+
};
|
|
224
|
+
SubmitFormValidationError: {
|
|
225
|
+
/** @description Message per field key. */
|
|
226
|
+
errors: {
|
|
227
|
+
[key: string]: string;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
responses: never;
|
|
232
|
+
parameters: never;
|
|
233
|
+
requestBodies: never;
|
|
234
|
+
headers: never;
|
|
235
|
+
pathItems: never;
|
|
236
|
+
}
|
|
237
|
+
interface operations {
|
|
238
|
+
getFormDefinition: {
|
|
239
|
+
parameters: {
|
|
240
|
+
query: {
|
|
241
|
+
trackingId: string;
|
|
242
|
+
};
|
|
243
|
+
header?: never;
|
|
244
|
+
path: {
|
|
245
|
+
formId: string;
|
|
246
|
+
};
|
|
247
|
+
cookie?: never;
|
|
248
|
+
};
|
|
249
|
+
requestBody?: never;
|
|
250
|
+
responses: {
|
|
251
|
+
/** @description Published form definition */
|
|
252
|
+
200: {
|
|
253
|
+
headers: {
|
|
254
|
+
[name: string]: unknown;
|
|
255
|
+
};
|
|
256
|
+
content: {
|
|
257
|
+
"application/json": components["schemas"]["FormDefinition"];
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
/** @description Unknown tracking id or no published form */
|
|
261
|
+
404: {
|
|
262
|
+
headers: {
|
|
263
|
+
[name: string]: unknown;
|
|
264
|
+
};
|
|
265
|
+
content: {
|
|
266
|
+
"application/json": components["schemas"]["DeliveryErrorBody"];
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
submitForm: {
|
|
272
|
+
parameters: {
|
|
273
|
+
query: {
|
|
274
|
+
trackingId: string;
|
|
275
|
+
};
|
|
276
|
+
header?: never;
|
|
277
|
+
path: {
|
|
278
|
+
formId: string;
|
|
279
|
+
};
|
|
280
|
+
cookie?: never;
|
|
281
|
+
};
|
|
282
|
+
requestBody: {
|
|
283
|
+
content: {
|
|
284
|
+
"application/json": components["schemas"]["SubmitFormRequest"];
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
responses: {
|
|
288
|
+
/** @description Accepted */
|
|
289
|
+
200: {
|
|
290
|
+
headers: {
|
|
291
|
+
[name: string]: unknown;
|
|
292
|
+
};
|
|
293
|
+
content: {
|
|
294
|
+
"application/json": components["schemas"]["SubmitFormSuccess"];
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
/** @description Unknown tracking id or no published form */
|
|
298
|
+
404: {
|
|
299
|
+
headers: {
|
|
300
|
+
[name: string]: unknown;
|
|
301
|
+
};
|
|
302
|
+
content: {
|
|
303
|
+
"application/json": components["schemas"]["DeliveryErrorBody"];
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
/** @description Field errors */
|
|
307
|
+
422: {
|
|
308
|
+
headers: {
|
|
309
|
+
[name: string]: unknown;
|
|
310
|
+
};
|
|
311
|
+
content: {
|
|
312
|
+
"application/json": components["schemas"]["SubmitFormValidationError"];
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Typed client for published forms on the Amplify UP delivery API.
|
|
321
|
+
* Types are generated from the platform's API spec (see `npm run codegen`).
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
type Schemas = components['schemas'];
|
|
325
|
+
type FormDefinition = Schemas['FormDefinition'];
|
|
326
|
+
type FormField = Schemas['FormField'];
|
|
327
|
+
type FormFieldType = Schemas['FormFieldType'];
|
|
328
|
+
type FormFieldOption = Schemas['FormFieldOption'];
|
|
329
|
+
type FormOnSuccess = Schemas['FormOnSuccess'];
|
|
330
|
+
type FormValue = Schemas['FormValue'];
|
|
331
|
+
type FormValues = Schemas['SubmitFormRequest']['values'];
|
|
332
|
+
type SubmitOperation = paths['/v1/forms/{formId}/submit']['post'];
|
|
333
|
+
type SubmitAccepted = SubmitOperation['responses'][200]['content']['application/json'];
|
|
334
|
+
type SubmitRejected = SubmitOperation['responses'][422]['content']['application/json'];
|
|
335
|
+
type SubmitFormResult = {
|
|
336
|
+
ok: true;
|
|
337
|
+
onSuccess: SubmitAccepted['onSuccess'];
|
|
338
|
+
} | {
|
|
339
|
+
ok: false;
|
|
340
|
+
errors: SubmitRejected['errors'];
|
|
341
|
+
};
|
|
342
|
+
declare class DeliveryRequestError extends Error {
|
|
343
|
+
readonly status: number;
|
|
344
|
+
constructor(message: string, status: number);
|
|
345
|
+
}
|
|
346
|
+
type FormRequestOptions = {
|
|
347
|
+
fetch?: typeof fetch;
|
|
348
|
+
};
|
|
349
|
+
/** Load the published definition of a form. */
|
|
350
|
+
declare const getFormDefinition: (formId: string, options?: FormRequestOptions) => Promise<FormDefinition>;
|
|
351
|
+
/**
|
|
352
|
+
* Submit a form. Field errors (422) come back as `{ ok: false, errors }`;
|
|
353
|
+
* anything else that fails throws. Never submits from a Composer preview.
|
|
354
|
+
*/
|
|
355
|
+
declare const submitForm: (formId: string, values: FormValues, options?: FormRequestOptions) => Promise<SubmitFormResult>;
|
|
356
|
+
|
|
121
357
|
/**
|
|
122
358
|
* Map Edge /v1/resolve payload → PageConfig for AmplifyRenderer.
|
|
123
359
|
* Prefers `tree` (full page skeleton with zones spliced in); falls back to
|
|
@@ -593,4 +829,4 @@ declare const verifyAWSConnection: () => {
|
|
|
593
829
|
|
|
594
830
|
declare const _default: AmplifyUpSDK;
|
|
595
831
|
|
|
596
|
-
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, PageTaxonomies, ProfileFieldsInput, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getSessionId, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
832
|
+
export { ANON_COOKIE_NAME, AmplifyContentMeta, AmplifyPageContextInput, AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, ContentSource, DWELL_ACTIVITY_IDLE_MS, DeliveryRequestError, EdgeResolveError, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, type FetchContentOptions, type FetchContentResult, type FormDefinition, type FormField, type FormFieldOption, type FormFieldType, type FormOnSuccess, type FormValue, type FormValues, IdentifyInput, IdentifyTraits, PageConfig, PageDataSnapshot, PageTaxonomies, ProfileFieldsInput, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, type SubmitFormResult, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchContent, fetchEdgeResolve, fetchPageConfig, getDiagnostics, getFormDefinition, getInstanceId, getOrchestratorUrl, getSDK, getSessionId, getStatus, getTarget, getTrackingId, getUserId, identify, init, mapResolvedToPageConfig, normalizeRoute, page, refreshEventTracking, reset, routeChange, setProfileFields, setupComponentViewTracking, setupEventTracking, submitForm, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
package/dist/index.js
CHANGED
|
@@ -424,7 +424,7 @@ function isComposerPreview() {
|
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
// src/field-envelope.ts
|
|
427
|
-
var FIELDS_BRAND = Symbol("amplifyup.fields");
|
|
427
|
+
var FIELDS_BRAND = /* @__PURE__ */ Symbol("amplifyup.fields");
|
|
428
428
|
var IDENTIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
429
429
|
"id",
|
|
430
430
|
"_id",
|
|
@@ -1132,6 +1132,61 @@ async function fetchContent(options) {
|
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
|
+
// src/delivery/forms.ts
|
|
1136
|
+
var DeliveryRequestError = class extends Error {
|
|
1137
|
+
constructor(message, status) {
|
|
1138
|
+
super(message);
|
|
1139
|
+
this.name = "DeliveryRequestError";
|
|
1140
|
+
this.status = status;
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
var formUrl = (formId, suffix = "") => {
|
|
1144
|
+
const sdk = getSDK();
|
|
1145
|
+
const edgeUrl = sdk.getEdgeUrl();
|
|
1146
|
+
const trackingId = sdk.getTrackingId();
|
|
1147
|
+
if (!edgeUrl || !trackingId) {
|
|
1148
|
+
throw new DeliveryRequestError("Amplify UP is not set up yet: call init() with your tracking ID first.", 0);
|
|
1149
|
+
}
|
|
1150
|
+
const base = edgeUrl.replace(/\/+$/, "");
|
|
1151
|
+
const query = new URLSearchParams({ trackingId });
|
|
1152
|
+
return `${base}/v1/forms/${encodeURIComponent(formId)}${suffix}?${query.toString()}`;
|
|
1153
|
+
};
|
|
1154
|
+
var errorMessage = async (response, fallback) => {
|
|
1155
|
+
const body = await response.json().catch(() => ({}));
|
|
1156
|
+
return body.error || `${fallback} (${response.status})`;
|
|
1157
|
+
};
|
|
1158
|
+
var getFormDefinition = async (formId, options = {}) => {
|
|
1159
|
+
const fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1160
|
+
const response = await fetchFn(formUrl(formId), {
|
|
1161
|
+
method: "GET",
|
|
1162
|
+
headers: { Accept: "application/json" }
|
|
1163
|
+
});
|
|
1164
|
+
if (!response.ok) {
|
|
1165
|
+
throw new DeliveryRequestError(await errorMessage(response, "Form failed to load"), response.status);
|
|
1166
|
+
}
|
|
1167
|
+
return await response.json();
|
|
1168
|
+
};
|
|
1169
|
+
var submitForm = async (formId, values, options = {}) => {
|
|
1170
|
+
if (isComposerPreview()) {
|
|
1171
|
+
throw new DeliveryRequestError("Forms do not submit in preview.", 0);
|
|
1172
|
+
}
|
|
1173
|
+
const fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1174
|
+
const response = await fetchFn(formUrl(formId, "/submit"), {
|
|
1175
|
+
method: "POST",
|
|
1176
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
1177
|
+
body: JSON.stringify({ values })
|
|
1178
|
+
});
|
|
1179
|
+
if (response.status === 422) {
|
|
1180
|
+
const body2 = await response.json();
|
|
1181
|
+
return { ok: false, errors: body2.errors };
|
|
1182
|
+
}
|
|
1183
|
+
if (!response.ok) {
|
|
1184
|
+
throw new DeliveryRequestError(await errorMessage(response, "Form failed to submit"), response.status);
|
|
1185
|
+
}
|
|
1186
|
+
const body = await response.json();
|
|
1187
|
+
return { ok: true, onSuccess: body.onSuccess };
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1135
1190
|
// src/edge/select.ts
|
|
1136
1191
|
var SelectVariantsError = class extends Error {
|
|
1137
1192
|
constructor(message, status, body) {
|
|
@@ -3810,6 +3865,7 @@ exports.AMPLIFYUP_EDITOR_ROUTE = AMPLIFYUP_EDITOR_ROUTE;
|
|
|
3810
3865
|
exports.ANON_COOKIE_NAME = ANON_COOKIE_NAME;
|
|
3811
3866
|
exports.AmplifyUpSDK = AmplifyUpSDK;
|
|
3812
3867
|
exports.DWELL_ACTIVITY_IDLE_MS = DWELL_ACTIVITY_IDLE_MS;
|
|
3868
|
+
exports.DeliveryRequestError = DeliveryRequestError;
|
|
3813
3869
|
exports.EdgeResolveError = EdgeResolveError;
|
|
3814
3870
|
exports.QueryContentError = QueryContentError;
|
|
3815
3871
|
exports.SESSION_COOKIE_NAME = SESSION_COOKIE_NAME;
|
|
@@ -3825,6 +3881,7 @@ exports.fetchEdgeResolve = fetchEdgeResolve;
|
|
|
3825
3881
|
exports.fetchEdgeSelect = fetchEdgeSelect;
|
|
3826
3882
|
exports.fetchPageConfig = fetchPageConfig;
|
|
3827
3883
|
exports.getDiagnostics = getDiagnostics;
|
|
3884
|
+
exports.getFormDefinition = getFormDefinition;
|
|
3828
3885
|
exports.getInstanceId = getInstanceId2;
|
|
3829
3886
|
exports.getOrchestratorUrl = getOrchestratorUrl;
|
|
3830
3887
|
exports.getSDK = getSDK;
|
|
@@ -3856,6 +3913,7 @@ exports.selectVariants = selectVariants;
|
|
|
3856
3913
|
exports.setProfileFields = setProfileFields;
|
|
3857
3914
|
exports.setupComponentViewTracking = setupComponentViewTracking;
|
|
3858
3915
|
exports.setupEventTracking = setupEventTracking;
|
|
3916
|
+
exports.submitForm = submitForm;
|
|
3859
3917
|
exports.testTracking = testTracking;
|
|
3860
3918
|
exports.track = track;
|
|
3861
3919
|
exports.trackClick = trackClick;
|