@amplifyup/sdk 0.1.33 → 0.1.35
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 +30 -1
- package/dist/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +30 -5
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +30 -5
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +208 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -11
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +22 -0
- package/dist/middleware.d.ts +22 -0
- package/dist/middleware.js +198 -0
- package/dist/middleware.js.map +1 -0
- package/dist/middleware.mjs +193 -0
- package/dist/middleware.mjs.map +1 -0
- package/dist/query-6BmINKLR.d.mts +157 -0
- package/dist/query-DjIuJ71C.d.ts +157 -0
- package/dist/react.d.mts +7 -3
- package/dist/react.d.ts +7 -3
- package/dist/react.js +272 -19
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +267 -20
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +42 -5
- package/dist/server.d.ts +42 -5
- package/dist/server.js +278 -7
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +265 -8
- package/dist/server.mjs.map +1 -1
- package/dist/{types-npF_lNoq.d.mts → types-CBoVIFI8.d.mts} +6 -0
- package/dist/{types-npF_lNoq.d.ts → types-CBoVIFI8.d.ts} +6 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -84,9 +84,38 @@ Field names must match the component registry in AmplifyUp. Connect CMS document
|
|
|
84
84
|
| Mode | Source | When |
|
|
85
85
|
|------|--------|------|
|
|
86
86
|
| Production visitors | Edge `/v1/resolve` | Default |
|
|
87
|
+
| Next.js SSG / ISR | Edge `/v1/routes` then `/v1/resolve` | `generateAmplifyStaticParams` + `fetchPageConfigServer` |
|
|
87
88
|
| Composer preview | Orchestrator layout provider | `?preview=true` / Composer iframe |
|
|
89
|
+
| Runtime queries | Edge `/v1/query` | `queryContent` — search, load more, pickers |
|
|
88
90
|
|
|
89
|
-
The SDK maps Edge’s resolved tree into `layoutTree` and renders it. Edge already applies personalization and CMS projection — the site does not call CMS or Decision APIs for layout.
|
|
91
|
+
The SDK maps Edge’s resolved tree into `layoutTree` and renders it. Edge already applies personalization and CMS projection — the site does not call CMS or Decision APIs for layout. After paint, the overlay calls `POST /v1/select` (or `selectVariants()`) then `/v1/resolve?variants=` so decisions stay on the edge (`clientPersonalization`).
|
|
92
|
+
|
|
93
|
+
## Runtime queries
|
|
94
|
+
|
|
95
|
+
Page resolve covers data known at Deploy. For data a visitor asks for — search, load more, a picker — use `queryContent`. The browser asks AmplifyUp, AmplifyUp asks your content source, so no CMS credentials or query syntax live in your site.
|
|
96
|
+
|
|
97
|
+
Mark a query connection **paginated** in Composer and the list prop gains pagination meta, including the published query spec:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
'use client';
|
|
101
|
+
import { queryContent, nextPageSpec, searchSpec } from '@amplifyup/sdk/react';
|
|
102
|
+
|
|
103
|
+
// next page
|
|
104
|
+
const more = await queryContent({
|
|
105
|
+
trackingId,
|
|
106
|
+
route: '/insights',
|
|
107
|
+
spec: nextPageSpec(postsPagination),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// search — keep `?q=` as input only; do not read searchParams on the server page
|
|
111
|
+
const hits = await queryContent({
|
|
112
|
+
trackingId,
|
|
113
|
+
route: '/insights',
|
|
114
|
+
spec: searchSpec(postsPagination, 'title', term),
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Only entities published with that route can be queried, and visitors only see published content. Also available from `@amplifyup/sdk/server`. See the [runtime queries guide](../../docs/sdk-site-setup.md#8-runtime-content-queries).
|
|
90
119
|
|
|
91
120
|
## Track events
|
|
92
121
|
|
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -208,6 +208,7 @@ var AWSAdapter = class {
|
|
|
208
208
|
// src/storage.ts
|
|
209
209
|
var INSTANCE_ID_KEY = "amplifyup_instance_id";
|
|
210
210
|
var USER_ID_KEY = "amplifyup_user_id";
|
|
211
|
+
var ANON_COOKIE_NAME = "amplifyup_anon_id";
|
|
211
212
|
function generateGuid() {
|
|
212
213
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
213
214
|
return crypto.randomUUID();
|
|
@@ -218,16 +219,39 @@ function generateGuid() {
|
|
|
218
219
|
return v.toString(16);
|
|
219
220
|
});
|
|
220
221
|
}
|
|
222
|
+
function readCookie(name) {
|
|
223
|
+
if (typeof document === "undefined") return null;
|
|
224
|
+
const parts = document.cookie.split(";");
|
|
225
|
+
for (const part of parts) {
|
|
226
|
+
const idx = part.indexOf("=");
|
|
227
|
+
if (idx === -1) continue;
|
|
228
|
+
if (part.slice(0, idx).trim() !== name) continue;
|
|
229
|
+
const value = part.slice(idx + 1).trim();
|
|
230
|
+
try {
|
|
231
|
+
return value ? decodeURIComponent(value) : null;
|
|
232
|
+
} catch {
|
|
233
|
+
return value || null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
function writeCookie(name, value) {
|
|
239
|
+
if (typeof document === "undefined") return;
|
|
240
|
+
document.cookie = `${name}=${encodeURIComponent(value)}; Path=/; Max-Age=31536000; SameSite=Lax`;
|
|
241
|
+
}
|
|
221
242
|
function getInstanceId() {
|
|
222
243
|
if (typeof window === "undefined") {
|
|
223
244
|
return "";
|
|
224
245
|
}
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
246
|
+
const fromCookie = readCookie(ANON_COOKIE_NAME);
|
|
247
|
+
const fromLs = localStorage.getItem(INSTANCE_ID_KEY);
|
|
248
|
+
const instanceId = fromLs || fromCookie || `browser_${generateGuid()}`;
|
|
249
|
+
if (fromLs !== instanceId) {
|
|
250
|
+
localStorage.setItem(INSTANCE_ID_KEY, instanceId);
|
|
251
|
+
}
|
|
252
|
+
if (fromCookie !== instanceId) {
|
|
253
|
+
writeCookie(ANON_COOKIE_NAME, instanceId);
|
|
228
254
|
}
|
|
229
|
-
const instanceId = `browser_${generateGuid()}`;
|
|
230
|
-
localStorage.setItem(INSTANCE_ID_KEY, instanceId);
|
|
231
255
|
return instanceId;
|
|
232
256
|
}
|
|
233
257
|
function getUserId() {
|
|
@@ -248,6 +272,7 @@ function clearIds() {
|
|
|
248
272
|
}
|
|
249
273
|
localStorage.removeItem(INSTANCE_ID_KEY);
|
|
250
274
|
localStorage.removeItem(USER_ID_KEY);
|
|
275
|
+
document.cookie = `${ANON_COOKIE_NAME}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
251
276
|
}
|
|
252
277
|
|
|
253
278
|
// src/targets.ts
|