@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.mjs
CHANGED
|
@@ -420,7 +420,7 @@ function isComposerPreview() {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
// src/field-envelope.ts
|
|
423
|
-
var FIELDS_BRAND = Symbol("amplifyup.fields");
|
|
423
|
+
var FIELDS_BRAND = /* @__PURE__ */ Symbol("amplifyup.fields");
|
|
424
424
|
var IDENTIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
425
425
|
"id",
|
|
426
426
|
"_id",
|
|
@@ -1128,6 +1128,61 @@ async function fetchContent(options) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
|
+
// src/delivery/forms.ts
|
|
1132
|
+
var DeliveryRequestError = class extends Error {
|
|
1133
|
+
constructor(message, status) {
|
|
1134
|
+
super(message);
|
|
1135
|
+
this.name = "DeliveryRequestError";
|
|
1136
|
+
this.status = status;
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
var formUrl = (formId, suffix = "") => {
|
|
1140
|
+
const sdk = getSDK();
|
|
1141
|
+
const edgeUrl = sdk.getEdgeUrl();
|
|
1142
|
+
const trackingId = sdk.getTrackingId();
|
|
1143
|
+
if (!edgeUrl || !trackingId) {
|
|
1144
|
+
throw new DeliveryRequestError("Amplify UP is not set up yet: call init() with your tracking ID first.", 0);
|
|
1145
|
+
}
|
|
1146
|
+
const base = edgeUrl.replace(/\/+$/, "");
|
|
1147
|
+
const query = new URLSearchParams({ trackingId });
|
|
1148
|
+
return `${base}/v1/forms/${encodeURIComponent(formId)}${suffix}?${query.toString()}`;
|
|
1149
|
+
};
|
|
1150
|
+
var errorMessage = async (response, fallback) => {
|
|
1151
|
+
const body = await response.json().catch(() => ({}));
|
|
1152
|
+
return body.error || `${fallback} (${response.status})`;
|
|
1153
|
+
};
|
|
1154
|
+
var getFormDefinition = async (formId, options = {}) => {
|
|
1155
|
+
const fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1156
|
+
const response = await fetchFn(formUrl(formId), {
|
|
1157
|
+
method: "GET",
|
|
1158
|
+
headers: { Accept: "application/json" }
|
|
1159
|
+
});
|
|
1160
|
+
if (!response.ok) {
|
|
1161
|
+
throw new DeliveryRequestError(await errorMessage(response, "Form failed to load"), response.status);
|
|
1162
|
+
}
|
|
1163
|
+
return await response.json();
|
|
1164
|
+
};
|
|
1165
|
+
var submitForm = async (formId, values, options = {}) => {
|
|
1166
|
+
if (isComposerPreview()) {
|
|
1167
|
+
throw new DeliveryRequestError("Forms do not submit in preview.", 0);
|
|
1168
|
+
}
|
|
1169
|
+
const fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1170
|
+
const response = await fetchFn(formUrl(formId, "/submit"), {
|
|
1171
|
+
method: "POST",
|
|
1172
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
1173
|
+
body: JSON.stringify({ values })
|
|
1174
|
+
});
|
|
1175
|
+
if (response.status === 422) {
|
|
1176
|
+
const body2 = await response.json();
|
|
1177
|
+
return { ok: false, errors: body2.errors };
|
|
1178
|
+
}
|
|
1179
|
+
if (!response.ok) {
|
|
1180
|
+
throw new DeliveryRequestError(await errorMessage(response, "Form failed to submit"), response.status);
|
|
1181
|
+
}
|
|
1182
|
+
const body = await response.json();
|
|
1183
|
+
return { ok: true, onSuccess: body.onSuccess };
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1131
1186
|
// src/edge/select.ts
|
|
1132
1187
|
var SelectVariantsError = class extends Error {
|
|
1133
1188
|
constructor(message, status, body) {
|
|
@@ -3802,6 +3857,6 @@ var verifyAWSConnection = () => {
|
|
|
3802
3857
|
};
|
|
3803
3858
|
var src_default = getSDK();
|
|
3804
3859
|
|
|
3805
|
-
export { AMPLIFYUP_EDITOR_ROUTE, ANON_COOKIE_NAME, AmplifyUpSDK, DWELL_ACTIVITY_IDLE_MS, EdgeResolveError, QueryContentError, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, SelectVariantsError, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, src_default as default, fetchContent, fetchEdgeQuery, fetchEdgeResolve, fetchEdgeSelect, fetchPageConfig, getDiagnostics, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getSessionId2 as getSessionId, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpEditorRoute, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, isWorkingContentRequest, mapResolvedToPageConfig, nextPageSpec, normalizeAmplifyUpTarget, normalizeRoute, page, queryContent, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, routeChange, searchSpec, selectVariants, setProfileFields, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
3860
|
+
export { AMPLIFYUP_EDITOR_ROUTE, ANON_COOKIE_NAME, AmplifyUpSDK, DWELL_ACTIVITY_IDLE_MS, DeliveryRequestError, EdgeResolveError, QueryContentError, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, SelectVariantsError, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, src_default as default, fetchContent, fetchEdgeQuery, fetchEdgeResolve, fetchEdgeSelect, fetchPageConfig, getDiagnostics, getFormDefinition, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getSessionId2 as getSessionId, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpEditorRoute, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, isWorkingContentRequest, mapResolvedToPageConfig, nextPageSpec, normalizeAmplifyUpTarget, normalizeRoute, page, queryContent, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, routeChange, searchSpec, selectVariants, setProfileFields, setupComponentViewTracking, setupEventTracking, submitForm, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
3806
3861
|
//# sourceMappingURL=index.mjs.map
|
|
3807
3862
|
//# sourceMappingURL=index.mjs.map
|