@plitzi/sdk-server 0.39.11 → 0.39.12
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/CHANGELOG.md +12 -0
- package/dist/cache.js +1 -1
- package/dist/chunks/{buildBody-Bm398uxH.js → buildBody-Q0Io6XUw.js} +64 -9
- package/dist/chunks/{core-CoKORAOg.js → core-BJJ2GK64.js} +124 -5
- package/dist/chunks/{createServer-DyjYdSq0.js → createServer-Bjy25_Ha.js} +12 -5
- package/dist/chunks/{platform-B6C07M-P.js → platform-CZ2ShKb7.js} +1 -1
- package/dist/chunks/{token-XEz1n4jp.js → token-COq-ufTp.js} +1 -1
- package/dist/deploy.js +1 -1
- package/dist/handlers.js +1 -1
- package/dist/helpers/audiences.d.ts +19 -0
- package/dist/helpers/cache/keys.d.ts +18 -4
- package/dist/helpers/experiments.d.ts +35 -0
- package/dist/helpers/rollout.d.ts +15 -0
- package/dist/helpers/timeWindows.d.ts +5 -0
- package/dist/index.js +3 -3
- package/dist/modules/ssr/Component.d.ts +16 -1
- package/dist/modules/ssr/buildBody.d.ts +2 -0
- package/dist/modules/ssr/prepareRender.d.ts +5 -0
- package/dist/oauth.js +1 -1
- package/dist/platform.js +1 -1
- package/dist/project.js +3 -3
- package/dist/spaces.js +1 -1
- package/dist/ssr.js +1 -1
- package/package.json +6 -6
- package/skills/plitzi-authoring/reference/authoring-errors.md +14 -0
- package/skills/plitzi-authoring/reference/feature-flags.md +61 -0
- package/skills/plitzi-authoring/reference/index.md +1 -1
- package/skills/plitzi-authoring/reference/templates.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @plitzi/sdk-server
|
|
2
2
|
|
|
3
|
+
## 0.39.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f5b44d: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [2f5b44d]
|
|
10
|
+
- @plitzi/plitzi-sdk@0.39.12
|
|
11
|
+
- @plitzi/sdk-actions@0.39.12
|
|
12
|
+
- @plitzi/sdk-kernel@0.39.12
|
|
13
|
+
- @plitzi/sdk-shared@0.39.12
|
|
14
|
+
|
|
3
15
|
## 0.39.11
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { _t as DEFAULT_IGNORED_QUERY_PARAMS, U as createCacheInvalidator, t as createRedisPageStore } from "./chunks/core-BJJ2GK64.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as googleFontsUrlOf, C as resolveDebugMode, D as requestVisitorFacts, F as partTextOf, I as sentInParts, J as hydrationPayload, L as createOfflineDataLoader, M as scriptTemplateParams, O as spaceAudiences, P as pageSchemaOf, S as requestRollout, T as buildServerInfo, X as spaceDocument, Y as offlineDataWith, ht as readCookie, mt as visitorScheme, q as digest$1, ut as offlineDataCacheKeyOf, w as requestExperiments, x as spaceTimeWindows, yt as requestPaintedStateWithDefaults } from "./core-BJJ2GK64.js";
|
|
2
2
|
import { n as pageAssets, r as resolveSdkAssetsDir } from "./sdkAssets-CXGoc_WE.js";
|
|
3
3
|
import { fetchOutbound, privateOriginsOf } from "@plitzi/sdk-kernel/outbound";
|
|
4
4
|
import { collectServerElements, isOgType, jsonForScript, mayReceive, notFoundProvider, pageElementTypes, pageHeadTags, pageNotFound, pageSeoText, pageServerContext, pageStructuredData, pageWithheldOf, spaceIdentity, withholdPages } from "@plitzi/sdk-shared/schema";
|
|
@@ -1296,7 +1296,7 @@ var withRefusal = (result, refused) => {
|
|
|
1296
1296
|
if (refused && result.redirect === void 0 && result.status === void 0) result.status = refused === "unauthenticated" ? 401 : 403;
|
|
1297
1297
|
};
|
|
1298
1298
|
// src/modules/ssr/Component.tsx
|
|
1299
|
-
var Component = ({ server, renderMode = "raw", previewMode = true, offlineData, environment = "main", plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode = false, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags }) => {
|
|
1299
|
+
var Component = ({ server, renderMode = "raw", previewMode = true, offlineData, environment = "main", plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode = false, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags, serverExperiments, forcedExperiments, drawnExperiments, serverRollout, serverVisitor, renderedAt }) => {
|
|
1300
1300
|
const serverWithResult = {
|
|
1301
1301
|
...server,
|
|
1302
1302
|
ssr: {
|
|
@@ -1322,6 +1322,12 @@ var Component = ({ server, renderMode = "raw", previewMode = true, offlineData,
|
|
|
1322
1322
|
...state === void 0 ? {} : { state },
|
|
1323
1323
|
...serverFlags === void 0 ? {} : { serverFlags },
|
|
1324
1324
|
...forcedFlags === void 0 ? {} : { forcedFlags },
|
|
1325
|
+
...serverExperiments === void 0 ? {} : { serverExperiments },
|
|
1326
|
+
...forcedExperiments === void 0 ? {} : { forcedExperiments },
|
|
1327
|
+
...drawnExperiments === void 0 ? {} : { drawnExperiments },
|
|
1328
|
+
...serverRollout === void 0 ? {} : { serverRollout },
|
|
1329
|
+
...serverVisitor === void 0 ? {} : { serverVisitor },
|
|
1330
|
+
...renderedAt === void 0 ? {} : { renderedAt },
|
|
1325
1331
|
children: plugins && Object.keys(plugins).map((key) => /* @__PURE__ */ jsx(PlitziSdk.Plugin, {
|
|
1326
1332
|
renderType: key,
|
|
1327
1333
|
component: plugins[key].component,
|
|
@@ -1895,7 +1901,40 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
1895
1901
|
const pageMatch = schema !== void 0 ? matchRscPage(schema, req.path, req.ctx.user) : void 0;
|
|
1896
1902
|
const refused = pageMatch ? pageWithheldOf(schema?.flat[pageMatch.pageId]?.attributes) : void 0;
|
|
1897
1903
|
const rscEnabled = rscPath !== void 0 && schema !== void 0 && schema.rsc?.enabled !== false;
|
|
1898
|
-
const
|
|
1904
|
+
const isPreviewRender = Boolean(req.query[PREVIEW_TOKEN_PARAM]);
|
|
1905
|
+
const debugAuthorized = !isPreviewRender && authorizesDebugging(config, schema?.settings);
|
|
1906
|
+
/**
|
|
1907
|
+
* The variant of each of the space's A/B tests this visitor is shown: kept in their cookie, or drawn now and kept from
|
|
1908
|
+
* this response on — and over them, on a page allowed to debug, what a tester forced. The server draws only that
|
|
1909
|
+
* variant, and the page hydrates with the same — never a draw of its own.
|
|
1910
|
+
*/
|
|
1911
|
+
const experiments = requestExperiments(req, rawOfflineData?.schema, {
|
|
1912
|
+
draws: !isPreviewRender && offlineDataOverride === void 0,
|
|
1913
|
+
debugAuthorized
|
|
1914
|
+
});
|
|
1915
|
+
const serverExperiments = Object.keys(experiments.assignments).length > 0 ? experiments.assignments : void 0;
|
|
1916
|
+
const forcedExperiments = experiments.forced;
|
|
1917
|
+
const drawnExperiments = experiments.drawn;
|
|
1918
|
+
/**
|
|
1919
|
+
* Where the visitor stands in the space's gradual rollouts: the places their cookie kept, or drawn now — kept from this
|
|
1920
|
+
* response on, and told to the server data read alongside (`ctx.rolloutBuckets`), which their cookie cannot tell yet.
|
|
1921
|
+
*/
|
|
1922
|
+
const rollout = requestRollout(req, rawOfflineData?.schema.flags, !isPreviewRender && offlineDataOverride === void 0);
|
|
1923
|
+
req.ctx.rolloutBuckets = rollout.buckets;
|
|
1924
|
+
const serverRollout = Object.keys(rollout.buckets).length > 0 ? rollout.buckets : void 0;
|
|
1925
|
+
const setCookies = [experiments.setCookie, rollout.setCookie].filter((cookie) => cookie !== void 0);
|
|
1926
|
+
/**
|
|
1927
|
+
* What the space's audiences read of the visitor — returning, language, device — from this request, handed to the
|
|
1928
|
+
* browser so it hydrates the variant drawn. A page they drew is kept only under those facts (`ctx.audienceKey`, set
|
|
1929
|
+
* when this server already held the space); asked before the space was held, it is kept for nobody.
|
|
1930
|
+
*/
|
|
1931
|
+
const audiences = rawOfflineData ? spaceAudiences(rawOfflineData.schema) : {
|
|
1932
|
+
has: false,
|
|
1933
|
+
used: []
|
|
1934
|
+
};
|
|
1935
|
+
const serverVisitor = audiences.has ? requestVisitorFacts(req) : void 0;
|
|
1936
|
+
const audienceUnkeyed = audiences.used.length > 0 && req.ctx.audienceKey === void 0;
|
|
1937
|
+
const renderedAt = rawOfflineData && spaceTimeWindows(rawOfflineData.schema) ? Date.now() : void 0;
|
|
1899
1938
|
const flagOverrides = await requestFlagOverrides(config, {
|
|
1900
1939
|
cookie: req.headers.cookie,
|
|
1901
1940
|
authority: requestAuthority(req)
|
|
@@ -1908,7 +1947,8 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
1908
1947
|
hostname: req.hostname,
|
|
1909
1948
|
routeParams: pageMatch.routeParams,
|
|
1910
1949
|
queryParams: req.query,
|
|
1911
|
-
user: flagUserFromSSR(req.ctx.user)
|
|
1950
|
+
user: flagUserFromSSR(req.ctx.user),
|
|
1951
|
+
rollout: rollout.buckets
|
|
1912
1952
|
}, flagOverrides)) : void 0;
|
|
1913
1953
|
const serverElements = rscEnabled && pageMatch !== void 0 ? collectServerElements(schema, pageMatch.pageId, void 0, pageFlags) : [];
|
|
1914
1954
|
const hasTargets = serverElements.length > 0;
|
|
@@ -2074,7 +2114,13 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
2074
2114
|
...runStatus ? { runStatus } : {},
|
|
2075
2115
|
...inspector ? { inspector } : {},
|
|
2076
2116
|
...serverFlags ? { serverFlags } : {},
|
|
2077
|
-
...forcedFlags ? { forcedFlags } : {}
|
|
2117
|
+
...forcedFlags ? { forcedFlags } : {},
|
|
2118
|
+
...serverExperiments ? { serverExperiments } : {},
|
|
2119
|
+
...forcedExperiments ? { forcedExperiments } : {},
|
|
2120
|
+
...drawnExperiments ? { drawnExperiments } : {},
|
|
2121
|
+
...serverRollout ? { serverRollout } : {},
|
|
2122
|
+
...serverVisitor ? { serverVisitor } : {},
|
|
2123
|
+
...renderedAt === void 0 ? {} : { renderedAt }
|
|
2078
2124
|
}, {
|
|
2079
2125
|
apart: spaceDocumentPath !== void 0,
|
|
2080
2126
|
linkStyle
|
|
@@ -2145,7 +2191,13 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
2145
2191
|
...scheme ? { scheme } : {},
|
|
2146
2192
|
...paintedState ? { state: paintedState } : {},
|
|
2147
2193
|
...serverFlags ? { serverFlags } : {},
|
|
2148
|
-
...forcedFlags ? { forcedFlags } : {}
|
|
2194
|
+
...forcedFlags ? { forcedFlags } : {},
|
|
2195
|
+
...serverExperiments ? { serverExperiments } : {},
|
|
2196
|
+
...forcedExperiments ? { forcedExperiments } : {},
|
|
2197
|
+
...drawnExperiments ? { drawnExperiments } : {},
|
|
2198
|
+
...serverRollout ? { serverRollout } : {},
|
|
2199
|
+
...serverVisitor ? { serverVisitor } : {},
|
|
2200
|
+
...renderedAt === void 0 ? {} : { renderedAt }
|
|
2149
2201
|
},
|
|
2150
2202
|
entries,
|
|
2151
2203
|
templateParams: {
|
|
@@ -2190,8 +2242,9 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
2190
2242
|
...config.livePages === true && offlineDataOverride !== void 0 ? { liveDraft: readDraftToken(req) } : {},
|
|
2191
2243
|
offlineData: offlineDataStr
|
|
2192
2244
|
},
|
|
2193
|
-
cacheable: actionRuns === void 0 && forcedFlags === void 0 && req.ctx.readAsVisitor !== true && !(environment === "main" && hasTargets),
|
|
2245
|
+
cacheable: actionRuns === void 0 && forcedFlags === void 0 && req.ctx.readAsVisitor !== true && !(environment === "main" && hasTargets) && setCookies.length === 0 && !audienceUnkeyed && forcedExperiments === void 0,
|
|
2194
2246
|
notFound,
|
|
2247
|
+
...setCookies.length > 0 ? { setCookies } : {},
|
|
2195
2248
|
...refused ? { refused } : {}
|
|
2196
2249
|
};
|
|
2197
2250
|
};
|
|
@@ -2210,7 +2263,8 @@ var buildBody = async (req, config, spaceId, environment, revision, renderFn, pl
|
|
|
2210
2263
|
if (result.redirect !== void 0) return {
|
|
2211
2264
|
result,
|
|
2212
2265
|
cacheable: prep.cacheable,
|
|
2213
|
-
nonce: ""
|
|
2266
|
+
nonce: "",
|
|
2267
|
+
...prep.setCookies ? { setCookies: prep.setCookies } : {}
|
|
2214
2268
|
};
|
|
2215
2269
|
const templateStart = metrics ? performance.now() : 0;
|
|
2216
2270
|
const body = renderFn({
|
|
@@ -2223,7 +2277,8 @@ var buildBody = async (req, config, spaceId, environment, revision, renderFn, pl
|
|
|
2223
2277
|
body,
|
|
2224
2278
|
result,
|
|
2225
2279
|
cacheable: prep.cacheable,
|
|
2226
|
-
nonce: prep.templateParams.nonce ?? ""
|
|
2280
|
+
nonce: prep.templateParams.nonce ?? "",
|
|
2281
|
+
...prep.setCookies ? { setCookies: prep.setCookies } : {}
|
|
2227
2282
|
};
|
|
2228
2283
|
};
|
|
2229
2284
|
export { DRAFT_STORE_METHODS as C, invalidatePluginComponentCache as D, takeDraftOverride as E, matchRscPage as O, PluginManager as S, draftSessionCookie as T, resolveServices as _, applySSRResult as a, spaceIconsOf as b, withNotFound as c, SPACE_DOCUMENT_PATH as d, answerCurrentSpacePreflight as f, resolveRscEndpoint as g, meterPage as h, Component as i, withRefusal as l, handleSpaceDocument as m, prepareRender as n, isReusable as o, handleCurrentSpace as p, imagesStage as r, renderParamsOf as s, buildBody as t, CURRENT_SPACE_PATH as u, resolvePageSeo as v, createMemoryDraftStore as w, iconGlyphsAt as x, ICONS_PATH as y };
|
|
@@ -2,18 +2,22 @@ import { schemaForPage, schemaFromWire, splitSchema } from "@plitzi/sdk-shared/s
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { compressBody, frameAncestorsOf, requestAuthority, requestOrigin } from "@plitzi/sdk-kernel/http";
|
|
4
4
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
5
|
-
import { flagsCookieName } from "@plitzi/sdk-shared/flags";
|
|
5
|
+
import { assignRollout, flagsCookieName, keptRollout, rolloutCookie, rolloutCookieName } from "@plitzi/sdk-shared/flags";
|
|
6
6
|
import { TRUSTED_TYPES_POLICIES, getKeyDecoded, isRecord } from "@plitzi/sdk-shared/helpers";
|
|
7
7
|
import { paintedKeys, paintedStateCookieName, paintedStateFor, pickPainted } from "@plitzi/sdk-shared/state";
|
|
8
8
|
import { frameAncestors, sessionCookieParams, sessionHintCookieName } from "@plitzi/sdk-kernel/identity";
|
|
9
9
|
import { TtlCache } from "@plitzi/sdk-kernel/cache";
|
|
10
10
|
import { debugCookieName } from "@plitzi/sdk-shared/devTools";
|
|
11
|
+
import { FORCED_EXPERIMENTS_PARAM, assignExperiments, declaredExperiments, experimentsCookie, experimentsCookieName, forcedExperimentsCookieName, forcedExperimentsFor, forcedExperimentsOf, keptExperiments } from "@plitzi/sdk-shared/experiments";
|
|
11
12
|
import { requestScheme, themeFromCookies } from "@plitzi/sdk-shared/theme/cookie";
|
|
12
13
|
import { brotliDecompressSync, gunzipSync } from "node:zlib";
|
|
13
14
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
14
15
|
import { styleSheetCss, styleSheetHref, styleSheetLinkable } from "@plitzi/sdk-shared/style";
|
|
15
16
|
import { fileURLToPath } from "node:url";
|
|
16
17
|
import { readFileSync, statSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { audienceFactsUsed, audienceKeyOf, visitorFactsOf } from "@plitzi/sdk-shared/audiences";
|
|
19
|
+
import { chooseByOf, variantsElementsOf } from "@plitzi/sdk-shared/variants";
|
|
20
|
+
import { hasTimeWindows } from "@plitzi/sdk-shared/timeWindows";
|
|
17
21
|
import { CLIENT_HEADER, CURRENT_HEADER, behindText, clientHeaderValue } from "@plitzi/sdk-shared/clients";
|
|
18
22
|
// src/helpers/paintedCookie.ts
|
|
19
23
|
/**
|
|
@@ -174,8 +178,12 @@ var HTML_KEY_FIELDS = [
|
|
|
174
178
|
"theme",
|
|
175
179
|
"scheme",
|
|
176
180
|
"painted",
|
|
181
|
+
"experiments",
|
|
182
|
+
"rollout",
|
|
183
|
+
"audience",
|
|
177
184
|
"debugHidden",
|
|
178
185
|
"forcedFlags",
|
|
186
|
+
"forcedExperiments",
|
|
179
187
|
"hostname",
|
|
180
188
|
"path",
|
|
181
189
|
"search"
|
|
@@ -196,9 +204,16 @@ var HTML_KEY_FIELDS = [
|
|
|
196
204
|
* values, so a page drawn with one visitor's toolbar must not be served to the next. Keyed by its raw value — this
|
|
197
205
|
* key does not know which keys a space declares, and a space that declares none has no such cookie to split on.
|
|
198
206
|
*
|
|
199
|
-
* So are the
|
|
200
|
-
* the
|
|
201
|
-
*
|
|
207
|
+
* So are the variants of the space's A/B tests the visitor keeps: the page draws only the one each shows them. Keyed by
|
|
208
|
+
* the cookie's raw value, so visitors shown the same variants share a page. A visitor with none of a test kept is drawn
|
|
209
|
+
* one there and then, and that page is never kept (`prepareRender`'s `cacheable`): the next such visitor is drawn their
|
|
210
|
+
* own. The same for the visitor's places in the space's gradual rollouts (`plitzi_rollout`): the flags they answer are
|
|
211
|
+
* drawn into the page. And for what the space's audiences read of the visitor (`ctx.audienceKey`: their device, their
|
|
212
|
+
* language, whether they came before), only where its audiences read it.
|
|
213
|
+
*
|
|
214
|
+
* So are the feature flags and the A/B variants a tester forced from the dev tools, on a page that authorizes
|
|
215
|
+
* debugging: drawn with them, the page is not everybody's, and a tester holding the cookie must never be handed a page
|
|
216
|
+
* drawn without it. Keyed by its raw value, like the kept state.
|
|
202
217
|
*
|
|
203
218
|
* So is what the space's flags are at (`flagsVersion` on the resolved deployment), for a deployment that changes them
|
|
204
219
|
* apart from its revisions: a flag turned in production must reach the next visitor, while the revision is the same.
|
|
@@ -219,8 +234,12 @@ var buildHtmlCacheKey = (accessToken = "anonymous", spaceId, environment, revisi
|
|
|
219
234
|
theme: themeFromCookies(req.headers.cookie) ?? "",
|
|
220
235
|
scheme: [void 0, "system"].includes(themeFromCookies(req.headers.cookie)) ? visitorScheme(req) ?? "" : "",
|
|
221
236
|
painted: readCookie(req.headers.cookie, ssrPaintedCookieName(requestAuthority(req))) ?? "",
|
|
237
|
+
experiments: readCookie(req.headers.cookie, experimentsCookieName(requestAuthority(req))) ?? "",
|
|
238
|
+
rollout: readCookie(req.headers.cookie, rolloutCookieName(requestAuthority(req))) ?? "",
|
|
239
|
+
audience: req.ctx?.audienceKey ?? "",
|
|
222
240
|
debugHidden: readCookie(req.headers.cookie, debugCookieName(requestAuthority(req))) === "false" ? "debug-off" : "",
|
|
223
241
|
forcedFlags: readCookie(req.headers.cookie, flagsCookieName(requestAuthority(req))) ?? "",
|
|
242
|
+
forcedExperiments: readCookie(req.headers.cookie, forcedExperimentsCookieName(requestAuthority(req))) ?? "",
|
|
224
243
|
hostname: req.hostname,
|
|
225
244
|
path: req.path,
|
|
226
245
|
search: canonicalSearch(req.search, ignoredQueryParams)
|
|
@@ -277,6 +296,7 @@ var RSC_KEY_FIELDS = [
|
|
|
277
296
|
"environment",
|
|
278
297
|
"revision",
|
|
279
298
|
"flags",
|
|
299
|
+
"rollout",
|
|
280
300
|
"user",
|
|
281
301
|
"ids",
|
|
282
302
|
"hostname",
|
|
@@ -289,6 +309,7 @@ var buildRscCacheKey = (spaceId, environment, revision, userId, idsParam, req) =
|
|
|
289
309
|
environment,
|
|
290
310
|
revision: String(revision),
|
|
291
311
|
flags: flagsVersionOf(req),
|
|
312
|
+
rollout: readCookie(req.headers.cookie, rolloutCookieName(requestAuthority(req))) ?? "",
|
|
292
313
|
user: userId === void 0 ? "anon" : String(userId),
|
|
293
314
|
ids: idsParam ?? "",
|
|
294
315
|
hostname: req.hostname,
|
|
@@ -1162,6 +1183,39 @@ var googleFontsStage = async (ctx) => {
|
|
|
1162
1183
|
ctx.res.send(answer.body);
|
|
1163
1184
|
return true;
|
|
1164
1185
|
};
|
|
1186
|
+
// src/helpers/audiences.ts
|
|
1187
|
+
/** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
|
|
1188
|
+
var audiencesOf = /* @__PURE__ */ new WeakMap();
|
|
1189
|
+
/** Whether a space has Variants elements chosen by rules (its audiences) at all, and the visitor facts their rules read. */
|
|
1190
|
+
var spaceAudiences = (schema) => {
|
|
1191
|
+
const known = audiencesOf.get(schema);
|
|
1192
|
+
if (known) return known;
|
|
1193
|
+
const found = {
|
|
1194
|
+
has: variantsElementsOf(schema).some(({ element }) => chooseByOf(element.attributes) === "rules"),
|
|
1195
|
+
used: audienceFactsUsed(schema)
|
|
1196
|
+
};
|
|
1197
|
+
audiencesOf.set(schema, found);
|
|
1198
|
+
return found;
|
|
1199
|
+
};
|
|
1200
|
+
var headerOf = (value) => Array.isArray(value) ? value[0] : value;
|
|
1201
|
+
/** This request's visitor, as an audience's rules read them: their first visit's cookie, their agent, their languages. */
|
|
1202
|
+
var requestVisitorFacts = (req) => visitorFactsOf({
|
|
1203
|
+
cookies: req.headers.cookie,
|
|
1204
|
+
host: requestAuthority(req),
|
|
1205
|
+
userAgent: headerOf(req.headers["user-agent"]),
|
|
1206
|
+
mobileHint: headerOf(req.headers["sec-ch-ua-mobile"]),
|
|
1207
|
+
acceptLanguage: headerOf(req.headers["accept-language"]),
|
|
1208
|
+
now: Date.now()
|
|
1209
|
+
});
|
|
1210
|
+
/**
|
|
1211
|
+
* What a page of this space is kept apart by for this request, asked before the cache is: the facts its audiences read,
|
|
1212
|
+
* from the space this server holds already. `undefined` when it holds none — the render that reads it keeps nothing.
|
|
1213
|
+
*/
|
|
1214
|
+
var audienceKeyFor = (req, held) => {
|
|
1215
|
+
if (!held) return;
|
|
1216
|
+
const { used } = spaceAudiences(held);
|
|
1217
|
+
return used.length > 0 ? audienceKeyOf(requestVisitorFacts(req), used) : "";
|
|
1218
|
+
};
|
|
1165
1219
|
// src/helpers/buildServerInfo.ts
|
|
1166
1220
|
var getEnvironment = (env = "production", server) => {
|
|
1167
1221
|
switch (env) {
|
|
@@ -1249,6 +1303,43 @@ var buildServerInfo = (req, config, ssr) => {
|
|
|
1249
1303
|
ssr
|
|
1250
1304
|
});
|
|
1251
1305
|
};
|
|
1306
|
+
// src/helpers/experiments.ts
|
|
1307
|
+
/** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
|
|
1308
|
+
var declaredOf = /* @__PURE__ */ new WeakMap();
|
|
1309
|
+
var experimentsOf = (schema) => {
|
|
1310
|
+
const known = declaredOf.get(schema);
|
|
1311
|
+
if (known) return known;
|
|
1312
|
+
const declared = declaredExperiments(schema);
|
|
1313
|
+
declaredOf.set(schema, declared);
|
|
1314
|
+
return declared;
|
|
1315
|
+
};
|
|
1316
|
+
/**
|
|
1317
|
+
* The variant of each of the space's A/B tests for this request — every one in the space, not this page's alone, so a
|
|
1318
|
+
* visitor who goes on to the next page in the browser finds theirs already kept: what their cookie holds, and a draw
|
|
1319
|
+
* for what it does not. Over them, what a tester forced (`plitzi_ab_qa`, `?ab=`) — read only where `debugAuthorized`,
|
|
1320
|
+
* shown and never kept as the visitor's.
|
|
1321
|
+
*
|
|
1322
|
+
* A render nobody visits — a preview for a picture, a draft's unsaved edits — draws nothing and keeps nothing: what
|
|
1323
|
+
* the visitor has not kept is shown as its first variant still shown (A, the control), the same in every picture.
|
|
1324
|
+
*/
|
|
1325
|
+
var requestExperiments = (req, schema, { draws, debugAuthorized }) => {
|
|
1326
|
+
const declared = schema ? experimentsOf(schema) : {};
|
|
1327
|
+
if (Object.keys(declared).length === 0) return { assignments: {} };
|
|
1328
|
+
const host = requestAuthority(req);
|
|
1329
|
+
const { assignments, kept, drawn } = assignExperiments(declared, keptExperiments(req.headers.cookie, host), draws ? Math.random : () => 0);
|
|
1330
|
+
const forced = debugAuthorized ? forcedExperimentsFor(declared, forcedExperimentsOf(req.headers.cookie, host, req.query[FORCED_EXPERIMENTS_PARAM])).applied : {};
|
|
1331
|
+
const tested = Object.keys(forced).length > 0 ? { forced } : {};
|
|
1332
|
+
if (!draws || drawn.length === 0) return {
|
|
1333
|
+
assignments,
|
|
1334
|
+
...tested
|
|
1335
|
+
};
|
|
1336
|
+
return {
|
|
1337
|
+
assignments,
|
|
1338
|
+
setCookie: experimentsCookie(host, kept, { secure: req.protocol === "https" }),
|
|
1339
|
+
drawn,
|
|
1340
|
+
...tested
|
|
1341
|
+
};
|
|
1342
|
+
};
|
|
1252
1343
|
// src/helpers/resolveDebugMode.ts
|
|
1253
1344
|
/**
|
|
1254
1345
|
* Whether a render may expose debugging: the panel, element ids in the markup, the store.
|
|
@@ -1260,6 +1351,34 @@ var buildServerInfo = (req, config, ssr) => {
|
|
|
1260
1351
|
* and get the debug render.
|
|
1261
1352
|
*/
|
|
1262
1353
|
var resolveDebugMode = (authorized, debugCookie) => Boolean(authorized) && debugCookie !== "false";
|
|
1354
|
+
// src/helpers/rollout.ts
|
|
1355
|
+
/**
|
|
1356
|
+
* Where this request's visitor stands in the space's gradual rollouts: the places their cookie kept, and one drawn now
|
|
1357
|
+
* for a flag it does not hold — kept from this response on. A render nobody visits (a picture, a draft's unsaved edits)
|
|
1358
|
+
* draws nothing: a rollout's flag answers its own value there.
|
|
1359
|
+
*/
|
|
1360
|
+
var requestRollout = (req, flags, draws) => {
|
|
1361
|
+
const host = requestAuthority(req);
|
|
1362
|
+
const kept = keptRollout(req.headers.cookie, host);
|
|
1363
|
+
if (!draws) return { buckets: kept };
|
|
1364
|
+
const { buckets, drawn } = assignRollout(flags, kept);
|
|
1365
|
+
if (drawn.length === 0) return { buckets };
|
|
1366
|
+
return {
|
|
1367
|
+
buckets,
|
|
1368
|
+
setCookie: rolloutCookie(host, buckets, { secure: req.protocol === "https" })
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
// src/helpers/timeWindows.ts
|
|
1372
|
+
/** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
|
|
1373
|
+
var known = /* @__PURE__ */ new WeakMap();
|
|
1374
|
+
/** Whether a space shows things by the time — a page of it is drawn at an instant the browser hydrates at. */
|
|
1375
|
+
var spaceTimeWindows = (schema) => {
|
|
1376
|
+
const found = known.get(schema);
|
|
1377
|
+
if (found !== void 0) return found;
|
|
1378
|
+
const has = hasTimeWindows(schema);
|
|
1379
|
+
known.set(schema, has);
|
|
1380
|
+
return has;
|
|
1381
|
+
};
|
|
1263
1382
|
// src/helpers/escapeHtml.ts
|
|
1264
1383
|
/** Text set inside HTML as text: never markup, whatever it holds. */
|
|
1265
1384
|
var escapeHtml = (value) => value.replace(/[&<>"']/gu, (character) => {
|
|
@@ -2323,4 +2442,4 @@ var createRedisPageStore = (client, { prefix = "plitzi:{pages}:", maxBytes = byt
|
|
|
2323
2442
|
return typeof count === "number" ? count : 0;
|
|
2324
2443
|
}
|
|
2325
2444
|
});
|
|
2326
|
-
export {
|
|
2445
|
+
export { DEFAULT_RENDER_WAIT_MS as $, googleFontsUrlOf as A, normalizePlugins as B, resolveDebugMode as C, requestVisitorFacts as D, audienceKeyFor as E, partTextOf as F, createServerCaches as G, cacheFilterOf as H, sentInParts as I, hydrationPayload as J, destroyServerCaches as K, createOfflineDataLoader as L, scriptTemplateParams as M, sendScriptPolicy as N, spaceAudiences as O, pageSchemaOf as P, escapeJson as Q, reportReactBuild as R, requestRollout as S, buildServerInfo as T, createCacheInvalidator as U, cacheLimitsOf as V, shareCache as W, spaceDocument as X, offlineDataWith as Y, styleSheetOf as Z, createCloudAdapters as _, DEFAULT_IGNORED_QUERY_PARAMS as _t, previewLabel as a, toSharedPage as at, escapeHtml as b, fixedSpace as c, buildRscCacheKey as ct, verifiedDomain as d, ignoredQueryParamsOf as dt, renderLimitFor as et, wildcardSubdomain as f, renderedQuery as ft, createJsonAdapters as g, DEFAULT_CACHE_BYTES as gt, createAuthAdapters as h, readCookie as ht, parsePreviewLabel as i, pageHtml as it, CSP_REPORT_PATH as j, googleFontsStage as k, presentsCredential as l, keepsVersion as lt, refuse as m, visitorScheme as mt, createSpaceAdapters as n, fromSharedPage as nt, snapshotPreview as o, buildCacheManager as ot, createMemoryCache as p, SCHEME_HINT_HEADER as pt, digest as q, PREVIEW_KEY_LENGTH as r, keepPage as rt, authoringPreview as s, buildHtmlCacheKey as st, createRedisPageStore as t, renderLimitOf as tt, renderGrant as u, offlineDataCacheKeyOf as ut, ownVersion as v, DEFAULT_TTL_MS as vt, requestExperiments as w, spaceTimeWindows as x, RequestMetrics as y, requestPaintedStateWithDefaults as yt, normalizePluginSource as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as DRAFT_STORE_METHODS, D as invalidatePluginComponentCache, E as takeDraftOverride, O as matchRscPage, S as PluginManager, T as draftSessionCookie, _ as resolveServices, a as applySSRResult, b as spaceIconsOf, c as withNotFound, f as answerCurrentSpacePreflight, g as resolveRscEndpoint, h as meterPage, i as Component, l as withRefusal, m as handleSpaceDocument, n as prepareRender, o as isReusable, p as handleCurrentSpace, r as imagesStage, s as renderParamsOf, t as buildBody, v as resolvePageSeo, w as createMemoryDraftStore, x as iconGlyphsAt, y as ICONS_PATH } from "./buildBody-
|
|
2
|
-
import {
|
|
1
|
+
import { C as DRAFT_STORE_METHODS, D as invalidatePluginComponentCache, E as takeDraftOverride, O as matchRscPage, S as PluginManager, T as draftSessionCookie, _ as resolveServices, a as applySSRResult, b as spaceIconsOf, c as withNotFound, f as answerCurrentSpacePreflight, g as resolveRscEndpoint, h as meterPage, i as Component, l as withRefusal, m as handleSpaceDocument, n as prepareRender, o as isReusable, p as handleCurrentSpace, r as imagesStage, s as renderParamsOf, t as buildBody, v as resolvePageSeo, w as createMemoryDraftStore, x as iconGlyphsAt, y as ICONS_PATH } from "./buildBody-Q0Io6XUw.js";
|
|
2
|
+
import { B as normalizePlugins, E as audienceKeyFor, G as createServerCaches, H as cacheFilterOf, K as destroyServerCaches, L as createOfflineDataLoader, N as sendScriptPolicy, R as reportReactBuild, V as cacheLimitsOf, W as shareCache, Z as styleSheetOf, at as toSharedPage, b as escapeHtml, ct as buildRscCacheKey, dt as ignoredQueryParamsOf, et as renderLimitFor, ft as renderedQuery, gt as DEFAULT_CACHE_BYTES, it as pageHtml, k as googleFontsStage, lt as keepsVersion, nt as fromSharedPage, ot as buildCacheManager, pt as SCHEME_HINT_HEADER, rt as keepPage, st as buildHtmlCacheKey, tt as renderLimitOf, ut as offlineDataCacheKeyOf, vt as DEFAULT_TTL_MS, y as RequestMetrics, yt as requestPaintedStateWithDefaults, z as normalizePluginSource } from "./core-BJJ2GK64.js";
|
|
3
3
|
import { n as renewForNavigation, t as isDocumentNavigation } from "./renewal-D98v6-Jd.js";
|
|
4
4
|
import { t as compileTemplate } from "./template-M3IEZ6os.js";
|
|
5
5
|
import { n as createRateLimit, t as RATE_LIMIT_METHODS } from "./throttle-CRiZB6_A.js";
|
|
@@ -17,7 +17,7 @@ import { configureServerLog, defaultLogLevel, isLogged, logLevelOf, serverLog }
|
|
|
17
17
|
import { evaluateRuleGroup } from "@plitzi/sdk-shared/conditions";
|
|
18
18
|
import { getSourceName } from "@plitzi/sdk-shared/dataSource/helpers";
|
|
19
19
|
import { resolveVariables } from "@plitzi/sdk-shared/dataSource/variables";
|
|
20
|
-
import { flagUserFromSSR, flagValues, forcedFlagsFromCookies, requestFlagOverrides, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
20
|
+
import { flagUserFromSSR, flagValues, forcedFlagsFromCookies, keptRollout, requestFlagOverrides, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
21
21
|
import { sitemapPages, sitemapPaths } from "@plitzi/sdk-shared/navigation";
|
|
22
22
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
23
23
|
import { knowHostDeployment } from "@plitzi/sdk-kernel/deployment";
|
|
@@ -337,7 +337,8 @@ var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, reso
|
|
|
337
337
|
hostname: req.hostname,
|
|
338
338
|
routeParams,
|
|
339
339
|
queryParams: req.query,
|
|
340
|
-
user: flagUserFromSSR(user)
|
|
340
|
+
user: flagUserFromSSR(user),
|
|
341
|
+
rollout: req.ctx.rolloutBuckets ?? keptRollout(req.headers.cookie, requestAuthority(req))
|
|
341
342
|
}, flagOverrides));
|
|
342
343
|
const all = collectServerElements(drawn, pageId, void 0, flags);
|
|
343
344
|
const asked = ids ? new Set(ids) : void 0;
|
|
@@ -1435,6 +1436,7 @@ var renderingNow = (slot) => slot.caches.rendering.get(slot.key);
|
|
|
1435
1436
|
var SSR_SENTINEL = "<!--SSR_CONTENT-->";
|
|
1436
1437
|
var streamBody = async (req, res, config, spaceId, environment, revision, renderFn, pluginManager, offlineDataCache, keep, metrics, offlineDataOverride, published) => {
|
|
1437
1438
|
const prep = await prepareRender(req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics, offlineDataOverride, published);
|
|
1439
|
+
if (prep.setCookies) res.setHeader("Set-Cookie", prep.setCookies);
|
|
1438
1440
|
const templateStart = metrics ? performance.now() : 0;
|
|
1439
1441
|
const fullTemplate = renderFn({
|
|
1440
1442
|
...prep.templateParams,
|
|
@@ -1553,7 +1555,11 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches, publis
|
|
|
1553
1555
|
}
|
|
1554
1556
|
const htmlCache = keepsVersion(req.ctx.spaceDeployment) && !offlineDataOverride ? caches.html : void 0;
|
|
1555
1557
|
const ignored = ignoredQueryParamsOf(config);
|
|
1556
|
-
if (htmlCache)
|
|
1558
|
+
if (htmlCache) {
|
|
1559
|
+
req.query = renderedQuery(req.query, ignored);
|
|
1560
|
+
const held = caches.offlineData?.get(offlineDataCacheKeyOf(req.ctx.spaceDeployment) ?? "");
|
|
1561
|
+
req.ctx.audienceKey = audienceKeyFor(req, held?.schema);
|
|
1562
|
+
}
|
|
1557
1563
|
const compression = resolveCompression(config.compression);
|
|
1558
1564
|
const slot = htmlCache ? pageSlot(config, caches, buildHtmlCacheKey(req.ctx.user?.token, spaceId, environment, revision, req, ignored), {
|
|
1559
1565
|
spaceId,
|
|
@@ -1608,6 +1614,7 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches, publis
|
|
|
1608
1614
|
res.setHeader("Server-Timing", metrics.toServerTimingHeader());
|
|
1609
1615
|
metrics.log(`${req.method} ${req.path}`);
|
|
1610
1616
|
}
|
|
1617
|
+
if (rendered.setCookies) res.setHeader("Set-Cookie", rendered.setCookies);
|
|
1611
1618
|
if (applySSRResult(res, rendered.result, renderParamsOf(req.query))) return;
|
|
1612
1619
|
sendScriptPolicy(res, config, rendered.nonce, req.ctx.spaceDeployment);
|
|
1613
1620
|
res.send(rendered.body ?? "", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createServer } from "./createServer-
|
|
1
|
+
import { t as createServer } from "./createServer-Bjy25_Ha.js";
|
|
2
2
|
import { dataDirLookup } from "@plitzi/sdk-kernel/data";
|
|
3
3
|
import { createPageEngine } from "@plitzi/sdk-actions/worker";
|
|
4
4
|
// src/core/platform.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as escapeHtml } from "./core-
|
|
1
|
+
import { b as escapeHtml } from "./core-BJJ2GK64.js";
|
|
2
2
|
import { forwardedIp, requestAuthority, requestOrigin } from "@plitzi/sdk-kernel/http";
|
|
3
3
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
4
4
|
// src/core/oauth/consentPage.ts
|
package/dist/deploy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as resolveSdkAssetsDir } from "./chunks/sdkAssets-CXGoc_WE.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Q as escapeJson, b as escapeHtml, v as ownVersion } from "./chunks/core-BJJ2GK64.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
package/dist/handlers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as authRoutes, n as renewForNavigation, r as applySessionOutcome, t as isDocumentNavigation } from "./chunks/renewal-D98v6-Jd.js";
|
|
2
|
-
import { a as handleRegister, b as protectedResourceMetadata, i as handleAuthorizeSubmit, l as sendErrorJson, n as handleToken, r as handleAuthorizeStart, t as handleRevoke, y as authorizationServerMetadata } from "./chunks/token-
|
|
2
|
+
import { a as handleRegister, b as protectedResourceMetadata, i as handleAuthorizeSubmit, l as sendErrorJson, n as handleToken, r as handleAuthorizeStart, t as handleRevoke, y as authorizationServerMetadata } from "./chunks/token-COq-ufTp.js";
|
|
3
3
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
4
4
|
import { authFailureMessage, carrierOf, createAuthorizer, csrfFailureMessage } from "@plitzi/sdk-kernel/identity";
|
|
5
5
|
// src/core/handlers/authRouteHandlers.ts
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
2
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
3
|
+
import { VisitorFact, VisitorFacts } from '@plitzi/sdk-shared/audiences';
|
|
4
|
+
/** What the experiments are read off: the pages' tree and the components'. */
|
|
5
|
+
type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>>;
|
|
6
|
+
type SpaceAudiences = {
|
|
7
|
+
has: boolean;
|
|
8
|
+
used: VisitorFact[];
|
|
9
|
+
};
|
|
10
|
+
/** Whether a space has Variants elements chosen by rules (its audiences) at all, and the visitor facts their rules read. */
|
|
11
|
+
export declare const spaceAudiences: (schema: SpaceTrees) => SpaceAudiences;
|
|
12
|
+
/** This request's visitor, as an audience's rules read them: their first visit's cookie, their agent, their languages. */
|
|
13
|
+
export declare const requestVisitorFacts: (req: Pick<SSRRequest, "headers">) => VisitorFacts;
|
|
14
|
+
/**
|
|
15
|
+
* What a page of this space is kept apart by for this request, asked before the cache is: the facts its audiences read,
|
|
16
|
+
* from the space this server holds already. `undefined` when it holds none — the render that reads it keeps nothing.
|
|
17
|
+
*/
|
|
18
|
+
export declare const audienceKeyFor: (req: Pick<SSRRequest, "headers">, held: SpaceTrees | undefined) => string | undefined;
|
|
19
|
+
export {};
|
|
@@ -8,6 +8,7 @@ type CacheKeyRequest = {
|
|
|
8
8
|
flagsVersion?: string;
|
|
9
9
|
draftVersion?: string;
|
|
10
10
|
};
|
|
11
|
+
audienceKey?: string;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
@@ -26,9 +27,16 @@ type CacheKeyRequest = {
|
|
|
26
27
|
* values, so a page drawn with one visitor's toolbar must not be served to the next. Keyed by its raw value — this
|
|
27
28
|
* key does not know which keys a space declares, and a space that declares none has no such cookie to split on.
|
|
28
29
|
*
|
|
29
|
-
* So are the
|
|
30
|
-
* the
|
|
31
|
-
*
|
|
30
|
+
* So are the variants of the space's A/B tests the visitor keeps: the page draws only the one each shows them. Keyed by
|
|
31
|
+
* the cookie's raw value, so visitors shown the same variants share a page. A visitor with none of a test kept is drawn
|
|
32
|
+
* one there and then, and that page is never kept (`prepareRender`'s `cacheable`): the next such visitor is drawn their
|
|
33
|
+
* own. The same for the visitor's places in the space's gradual rollouts (`plitzi_rollout`): the flags they answer are
|
|
34
|
+
* drawn into the page. And for what the space's audiences read of the visitor (`ctx.audienceKey`: their device, their
|
|
35
|
+
* language, whether they came before), only where its audiences read it.
|
|
36
|
+
*
|
|
37
|
+
* So are the feature flags and the A/B variants a tester forced from the dev tools, on a page that authorizes
|
|
38
|
+
* debugging: drawn with them, the page is not everybody's, and a tester holding the cookie must never be handed a page
|
|
39
|
+
* drawn without it. Keyed by its raw value, like the kept state.
|
|
32
40
|
*
|
|
33
41
|
* So is what the space's flags are at (`flagsVersion` on the resolved deployment), for a deployment that changes them
|
|
34
42
|
* apart from its revisions: a flag turned in production must reach the next visitor, while the revision is the same.
|
|
@@ -83,6 +91,12 @@ export declare const keepsVersion: (deployment: DeploymentVersion | undefined) =
|
|
|
83
91
|
/** Where the space a request resolves to is kept between renders, or nothing when it may not be (`keepsVersion`). */
|
|
84
92
|
export declare const offlineDataCacheKeyOf: (deployment: DeploymentVersion | undefined) => string | undefined;
|
|
85
93
|
export declare const readOfflineDataCacheKey: (key: string) => CacheKeyFacts;
|
|
86
|
-
export declare const buildRscCacheKey: (spaceId: number, environment: string, revision: number, userId: string | number | undefined, idsParam: string | undefined, req: CacheKeyRequest
|
|
94
|
+
export declare const buildRscCacheKey: (spaceId: number, environment: string, revision: number, userId: string | number | undefined, idsParam: string | undefined, req: CacheKeyRequest & {
|
|
95
|
+
headers: {
|
|
96
|
+
cookie?: string;
|
|
97
|
+
host?: string;
|
|
98
|
+
":authority"?: string;
|
|
99
|
+
};
|
|
100
|
+
}) => string;
|
|
87
101
|
export declare const readRscCacheKey: (key: string) => CacheKeyFacts;
|
|
88
102
|
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
2
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
3
|
+
import { ExperimentAssignments } from '@plitzi/sdk-shared/experiments';
|
|
4
|
+
/** What the experiments are read off: the pages' tree and the components'. */
|
|
5
|
+
type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>>;
|
|
6
|
+
export type RequestExperiments = {
|
|
7
|
+
/**
|
|
8
|
+
* Every A/B test's variant for this visitor — theirs, never a tester's: the page hydrates with them as the variants it
|
|
9
|
+
* keeps, and shows what a tester forced over them (`forced`).
|
|
10
|
+
*/
|
|
11
|
+
assignments: ExperimentAssignments;
|
|
12
|
+
/**
|
|
13
|
+
* The `Set-Cookie` that keeps the variants drawn for this visitor just now. Its page is theirs alone: never kept for
|
|
14
|
+
* anybody else, who would be shown a variant they were never drawn.
|
|
15
|
+
*/
|
|
16
|
+
setCookie?: string;
|
|
17
|
+
/** The variants a tester forced that this space can show: shown over `assignments`, never kept as the visitor's. */
|
|
18
|
+
forced?: ExperimentAssignments;
|
|
19
|
+
/** The experiments drawn for this visitor just now — what the page reports to the space's analytics, once. */
|
|
20
|
+
drawn?: string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The variant of each of the space's A/B tests for this request — every one in the space, not this page's alone, so a
|
|
24
|
+
* visitor who goes on to the next page in the browser finds theirs already kept: what their cookie holds, and a draw
|
|
25
|
+
* for what it does not. Over them, what a tester forced (`plitzi_ab_qa`, `?ab=`) — read only where `debugAuthorized`,
|
|
26
|
+
* shown and never kept as the visitor's.
|
|
27
|
+
*
|
|
28
|
+
* A render nobody visits — a preview for a picture, a draft's unsaved edits — draws nothing and keeps nothing: what
|
|
29
|
+
* the visitor has not kept is shown as its first variant still shown (A, the control), the same in every picture.
|
|
30
|
+
*/
|
|
31
|
+
export declare const requestExperiments: (req: Pick<SSRRequest, "headers" | "protocol" | "query">, schema: SpaceTrees | undefined, { draws, debugAuthorized }: {
|
|
32
|
+
draws: boolean;
|
|
33
|
+
debugAuthorized: boolean;
|
|
34
|
+
}) => RequestExperiments;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
2
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
3
|
+
import { RolloutBuckets } from '@plitzi/sdk-shared/flags';
|
|
4
|
+
export type RequestRollout = {
|
|
5
|
+
/** The visitor's place in every flag the space rolls out to part of its visitors. */
|
|
6
|
+
buckets: RolloutBuckets;
|
|
7
|
+
/** The `Set-Cookie` that keeps the places drawn for this visitor just now: their page is theirs alone. */
|
|
8
|
+
setCookie?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Where this request's visitor stands in the space's gradual rollouts: the places their cookie kept, and one drawn now
|
|
12
|
+
* for a flag it does not hold — kept from this response on. A render nobody visits (a picture, a draft's unsaved edits)
|
|
13
|
+
* draws nothing: a rollout's flag answers its own value there.
|
|
14
|
+
*/
|
|
15
|
+
export declare const requestRollout: (req: Pick<SSRRequest, "headers" | "protocol">, flags: Schema["flags"], draws: boolean) => RequestRollout;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
2
|
+
type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>>;
|
|
3
|
+
/** Whether a space shows things by the time — a page of it is drawn at an instant the browser hydrates at. */
|
|
4
|
+
export declare const spaceTimeWindows: (schema: SpaceTrees) => boolean;
|
|
5
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as resolveRscData, t as createServer } from "./chunks/createServer-
|
|
2
|
-
import {
|
|
3
|
-
import { E as takeDraftOverride, _ as resolveServices, w as createMemoryDraftStore } from "./chunks/buildBody-
|
|
1
|
+
import { r as resolveRscData, t as createServer } from "./chunks/createServer-Bjy25_Ha.js";
|
|
2
|
+
import { U as createCacheInvalidator, _ as createCloudAdapters, _t as DEFAULT_IGNORED_QUERY_PARAMS, c as fixedSpace, d as verifiedDomain, f as wildcardSubdomain, g as createJsonAdapters, h as createAuthAdapters, l as presentsCredential, m as refuse, n as createSpaceAdapters, p as createMemoryCache, s as authoringPreview, t as createRedisPageStore, u as renderGrant } from "./chunks/core-BJJ2GK64.js";
|
|
3
|
+
import { E as takeDraftOverride, _ as resolveServices, w as createMemoryDraftStore } from "./chunks/buildBody-Q0Io6XUw.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
6
6
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { SSRPlugin } from '../../types';
|
|
2
2
|
import { BadgeLinks, OfflineDataRaw, Environment, RenderMode, Server, SSRRenderResult, Theme, ColorScheme } from '@plitzi/sdk-shared';
|
|
3
|
+
import { VisitorFacts } from '@plitzi/sdk-shared/audiences';
|
|
4
|
+
import { ExperimentAssignments } from '@plitzi/sdk-shared/experiments';
|
|
5
|
+
import { RolloutBuckets } from '@plitzi/sdk-shared/flags';
|
|
3
6
|
export type ComponentProps = {
|
|
4
7
|
server: Partial<Server>;
|
|
5
8
|
renderMode?: Extract<RenderMode, 'raw'>;
|
|
@@ -27,6 +30,18 @@ export type ComponentProps = {
|
|
|
27
30
|
serverFlags?: Record<string, boolean>;
|
|
28
31
|
/** The flags a tester forced, for a page allowed to debug. See `prepareRender`. */
|
|
29
32
|
forcedFlags?: Record<string, boolean>;
|
|
33
|
+
/** The variant each of the space's A/B tests is drawn with for this visitor. See `prepareRender`. */
|
|
34
|
+
serverExperiments?: ExperimentAssignments;
|
|
35
|
+
/** The variants a tester forced, for a page allowed to debug. See `prepareRender`. */
|
|
36
|
+
forcedExperiments?: ExperimentAssignments;
|
|
37
|
+
/** The experiments drawn for this visitor by this render. See `prepareRender`. */
|
|
38
|
+
drawnExperiments?: string[];
|
|
39
|
+
/** The visitor's places in the space's gradual rollouts. See `prepareRender`. */
|
|
40
|
+
serverRollout?: RolloutBuckets;
|
|
41
|
+
/** What the space's audiences read of the visitor. See `prepareRender`. */
|
|
42
|
+
serverVisitor?: VisitorFacts;
|
|
43
|
+
/** The instant the page is drawn at, for a space that shows things by the time. See `prepareRender`. */
|
|
44
|
+
renderedAt?: number;
|
|
30
45
|
};
|
|
31
|
-
declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags }: ComponentProps) => import('react').JSX.Element;
|
|
46
|
+
declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags, serverExperiments, forcedExperiments, drawnExperiments, serverRollout, serverVisitor, renderedAt }: ComponentProps) => import('react').JSX.Element;
|
|
32
47
|
export default Component;
|
|
@@ -12,5 +12,7 @@ export type BuildBodyResult = {
|
|
|
12
12
|
cacheable: boolean;
|
|
13
13
|
/** The nonce the page's own scripts were rendered with — what its script policy names; empty without one. */
|
|
14
14
|
nonce: string;
|
|
15
|
+
/** What the page is sent with for this visitor alone (`RenderPrep.setCookies`). */
|
|
16
|
+
setCookies?: string[];
|
|
15
17
|
};
|
|
16
18
|
export declare const buildBody: (req: SSRRequest, config: SSRPageServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<OfflineDataRaw>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw, published?: PageEngine["published"]) => Promise<BuildBodyResult>;
|
|
@@ -20,6 +20,11 @@ export type RenderPrep = {
|
|
|
20
20
|
cacheable: boolean;
|
|
21
21
|
/** A server provider of the page said its address shows nothing (`notFound`): sent with status 404. */
|
|
22
22
|
notFound: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Sent with the page: what was drawn for this visitor just now and is kept in their cookies — the variants of the
|
|
25
|
+
* space's A/B tests, their places in its gradual rollouts.
|
|
26
|
+
*/
|
|
27
|
+
setCookies?: string[];
|
|
23
28
|
/** The page asked for was withheld from this visitor (`access`): sent with 401 or 403, its refusal drawn. */
|
|
24
29
|
refused?: PageWithheld;
|
|
25
30
|
};
|
package/dist/oauth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as dropPending, D as putCode, E as getPending, O as putPending, S as scopesOf, T as getClient, a as handleRegister, b as protectedResourceMetadata, c as redirectWithError, d as randomId, f as verifyChallenge, g as REGISTER_PATH, h as PROTECTED_RESOURCE_PATH, i as handleAuthorizeSubmit, l as sendErrorJson, m as AUTHORIZE_PATH, n as handleToken, o as redirectToSignIn, p as AUTHORIZATION_SERVER_PATH, r as handleAuthorizeStart, s as redirectWithCode, t as handleRevoke, u as sendJson, v as TOKEN_PATH, w as getAccess, x as resourceMetadataUrl, y as authorizationServerMetadata } from "./chunks/token-
|
|
1
|
+
import { C as dropPending, D as putCode, E as getPending, O as putPending, S as scopesOf, T as getClient, a as handleRegister, b as protectedResourceMetadata, c as redirectWithError, d as randomId, f as verifyChallenge, g as REGISTER_PATH, h as PROTECTED_RESOURCE_PATH, i as handleAuthorizeSubmit, l as sendErrorJson, m as AUTHORIZE_PATH, n as handleToken, o as redirectToSignIn, p as AUTHORIZATION_SERVER_PATH, r as handleAuthorizeStart, s as redirectWithCode, t as handleRevoke, u as sendJson, v as TOKEN_PATH, w as getAccess, x as resourceMetadataUrl, y as authorizationServerMetadata } from "./chunks/token-COq-ufTp.js";
|
|
2
2
|
import { readRawBody } from "@plitzi/sdk-kernel/http";
|
|
3
3
|
// src/core/oauth/challenge.ts
|
|
4
4
|
/** The credential on an MCP request. `Authorization: Bearer` is what RFC 6750 defines and what a remote host
|
package/dist/platform.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createPlatform } from "./chunks/platform-
|
|
1
|
+
export { t as createPlatform } from "./chunks/platform-CZ2ShKb7.js";
|
package/dist/project.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as LIVE_PAGES_PATH } from "./chunks/createServer-
|
|
2
|
-
import { _ as createCloudAdapters, b as escapeHtml, g as createJsonAdapters } from "./chunks/core-
|
|
3
|
-
import { t as createPlatform } from "./chunks/platform-
|
|
1
|
+
import { n as LIVE_PAGES_PATH } from "./chunks/createServer-Bjy25_Ha.js";
|
|
2
|
+
import { _ as createCloudAdapters, b as escapeHtml, g as createJsonAdapters } from "./chunks/core-BJJ2GK64.js";
|
|
3
|
+
import { t as createPlatform } from "./chunks/platform-CZ2ShKb7.js";
|
|
4
4
|
import { reachOwnServer } from "@plitzi/sdk-kernel/outbound";
|
|
5
5
|
import { EMPTY_SCHEMA } from "@plitzi/sdk-shared/schema";
|
|
6
6
|
import { mkdir, writeFile } from "node:fs/promises";
|
package/dist/spaces.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as PREVIEW_KEY_LENGTH, s as authoringPreview, p as createMemoryCache, n as createSpaceAdapters, c as fixedSpace, i as parsePreviewLabel, l as presentsCredential, a as previewLabel, m as refuse, u as renderGrant, o as snapshotPreview, d as verifiedDomain, f as wildcardSubdomain } from "./chunks/core-
|
|
1
|
+
export { r as PREVIEW_KEY_LENGTH, s as authoringPreview, p as createMemoryCache, n as createSpaceAdapters, c as fixedSpace, i as parsePreviewLabel, l as presentsCredential, a as previewLabel, m as refuse, u as renderGrant, o as snapshotPreview, d as verifiedDomain, f as wildcardSubdomain } from "./chunks/core-BJJ2GK64.js";
|
package/dist/ssr.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { S as PluginManager, t as buildBody, w as createMemoryDraftStore, E as takeDraftOverride } from "./chunks/buildBody-
|
|
1
|
+
export { S as PluginManager, t as buildBody, w as createMemoryDraftStore, E as takeDraftOverride } from "./chunks/buildBody-Q0Io6XUw.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.12",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
"./dist/env.js"
|
|
96
96
|
],
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@plitzi/plitzi-sdk": "0.39.
|
|
99
|
-
"@plitzi/sdk-actions": "0.39.
|
|
100
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
101
|
-
"@plitzi/sdk-shared": "0.39.
|
|
98
|
+
"@plitzi/plitzi-sdk": "0.39.12",
|
|
99
|
+
"@plitzi/sdk-actions": "0.39.12",
|
|
100
|
+
"@plitzi/sdk-kernel": "0.39.12",
|
|
101
|
+
"@plitzi/sdk-shared": "0.39.12",
|
|
102
102
|
"ejs": "^7.0.2",
|
|
103
103
|
"esbuild": "^0.28.2",
|
|
104
104
|
"jsonwebtoken": "^9.0.3",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
|
-
"@plitzi/sdk-runtime": "0.39.
|
|
118
|
+
"@plitzi/sdk-runtime": "0.39.12",
|
|
119
119
|
"@types/ejs": "^3.1.5",
|
|
120
120
|
"@types/jsonwebtoken": "^9.0.10",
|
|
121
121
|
"@types/node": "^26.6.6",
|
|
@@ -76,8 +76,12 @@ The space is not written until these are fixed.
|
|
|
76
76
|
| `element-runtime` | a `runtime` the element does not run in | one of the values the message lists |
|
|
77
77
|
| `element-shape` | an element that is not an object with a `type`, `attributes` and a list of `children` | build elements with their factories — `text(…)`, `container(…)` |
|
|
78
78
|
| `element-slot-unknown` | a `slots` key the element type does not have — its class would dress nothing | one of the slots `plitzi explain <type>` lists; the element itself takes `class` |
|
|
79
|
+
| `experiment-name` | by chance, a `variants`' `experiment` that a template cannot read as `experiments.x` | letters, digits and `_`, starting with a letter or `_` — or empty, for the element's own name |
|
|
80
|
+
| `experiment-unknown` | a template, a binding or a `when` reading an experiment no `variants` chosen by chance runs | the name it suggests, or a `variants` with that `experiment` |
|
|
81
|
+
| `experiment-weight` | by chance, a `variantItem`'s `weight` that is not a whole number from 0 to 100, or variants that all weigh 0 | `weight: 50`; 0 shows a variant to nobody, and at least one has to show |
|
|
79
82
|
| `flag-gate` | an element's or a page's `flag` that is not a flag name | `flag: 'newCheckout'`, or `flag: '!newCheckout'` for "only while off" |
|
|
80
83
|
| `flag-name` | a flag whose name a template cannot read as `flags.x` | letters, digits and `_` |
|
|
84
|
+
| `flag-rollout` | a flag's `rollout` that is not `{ percent, value }` — a whole share from 0 to 100 and the answer it gives | `rollout: { percent: 10, value: true }` |
|
|
81
85
|
| `flag-rule-shape` | a flag rule that is not `{ when, value }`, or whose `value` is not `true` or `false` | `{ when: { … }, value: true }` |
|
|
82
86
|
| `flag-shape` | a flag whose `value` is not `true` or `false` | `{ value: false, rules: [] }` |
|
|
83
87
|
| `flag-undeclared` | a gate on a flag the space does not declare — it reads as off, so the element never (or always) renders | declare it in `flags`, or remove the gate |
|
|
@@ -180,6 +184,7 @@ The space is not written until these are fixed.
|
|
|
180
184
|
| `template-text-into-value` | a template, which renders text, feeding an attribute that holds a list or an object | `bindTemplate('items', source, '{{ … }}', { returns: 'value' })` |
|
|
181
185
|
| `template-unknown-name` | a name in a template that is not a source, a variable or a route param | the full source name (`list_rows.item`), `navigation.queryParams.x`, or `source` for the bound value |
|
|
182
186
|
| `template-unreadable` | a template with an operator, a filter or a function that does not exist, or broken syntax | an operator, a filter or a function the interpreter has — the message names the one it could not read; `matches` never exists |
|
|
187
|
+
| `time-window-bound` | a `timeWindow`'s `startsAt` or `endsAt` that is not an instant with its offset — never read, so no bound | `startsAt: '2026-12-01T09:00:00Z'` (or `+01:00`); empty for no bound |
|
|
183
188
|
| `transformer-params` | a transformer param that does not exist, or a value outside its options | the params and values it lists |
|
|
184
189
|
| `trigger-interval` | an `onInterval` that never ticks: not a whole number of milliseconds, or below 250 | `onInterval(5000)` |
|
|
185
190
|
| `trigger-keys` | an `onKey` shortcut that cannot fire: two keys at once, only modifiers, or a name that is not a key | `onKey('f')`, `onKey('shift+f')`, `onKey('mod+k, escape')` |
|
|
@@ -193,6 +198,9 @@ The space is not written until these are fixed.
|
|
|
193
198
|
| `unknown-transformer` | a transformer that does not exist | one of the transformers it lists |
|
|
194
199
|
| `utility-module` | a utility sent to a module — a utility takes none | drop the `on` |
|
|
195
200
|
| `variant-bound-twice` | two bindings (`variantFrom`, `activeOn`, `activeWhen`) setting the variant of one class on one element — the second always wins | one `variantFrom` whose template answers every case: `{{ wide ? 'roomy' : current ? 'active' : 'idle' }}`; two things that change apart (a size, a lit state) are two classes, each with its own `variantFrom` |
|
|
201
|
+
| `variants-choose-by` | a `variants`' `chooseBy` that is neither `'chance'` nor `'rules'` — it chooses by chance | `chooseBy: 'chance'` or `chooseBy: 'rules'` |
|
|
202
|
+
| `variants-items` | a `variants` holding something beside its `variantItem`s, or too few — two to five by chance, one by rules | `variants({ children: [variantItem([…]), variantItem([…])] })` |
|
|
203
|
+
| `variants-rule` | a `variantItem`'s `when` that is not a rule group | `when: { combinator: 'and', rules: [{ field: 'visitor.device', operator: '=', value: 'mobile' }] }` |
|
|
196
204
|
| `visibility-as-attribute` | `visibility` bound as an attribute, which no element reads | `visible: { source, template }` |
|
|
197
205
|
| `visible-expression` | `visible` written as an expression (`"state.plan == 'pro'"`, `"a && !b"`) — it takes a source, read as one, which resolves to nothing | `visible: { source: 'state.plan', template: "{{ state.plan == 'pro' }}" }` — or a source alone, `'state.open'`, `'!state.open'` |
|
|
198
206
|
| `visitor-roles` | `settings.visitorRoles` written in a shape the runtime does not read | the shape the message gives |
|
|
@@ -218,6 +226,8 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
218
226
|
| `default-content-beside-children` | a button printing its default "Button" beside its children | `content: ''` |
|
|
219
227
|
| `dropdown-without-control` | a dropdown opened from a box or an icon — no keyboard opens it | a `button` as what opens it (`title` if it is only an icon) |
|
|
220
228
|
| `embed-without-title` | an `embed` with no `title` — a frame a screen reader cannot describe | say what it shows in `title` |
|
|
229
|
+
| `experiment-weights-differ` | two `variants` running the same test with different weights — they share it, so one set is ignored | the same weights on both, or a test name of its own for each |
|
|
230
|
+
| `experiment-weights-total` | by chance, `variant`s whose `weight`s do not add up to 100 — each is read as its part of their total | percents adding up to 100: 50/25/20/5, or the proportions the warning gives |
|
|
221
231
|
| `flag-rule-empty` | a flag rule with no conditions — skipped, never read as "always" | give it a condition, or set the flag's `value` instead |
|
|
222
232
|
| `flag-unused` | a declared flag nothing gates on and no template reads | gate what it switches (`flag: 'x'`), or remove it once the feature has shipped |
|
|
223
233
|
| `focus-on-field-box` | a `focus` or `focus-visible` state on a text field's or a select's `input` slot — the box the field is drawn in, which never takes focus, so no ring is ever shown | `'focus-within'` on the same class, or the state on the `field` slot |
|
|
@@ -259,12 +269,16 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
259
269
|
| `template-or-value` | a template's `or` (or `and`) beside a text or a number — `sort or 'listeners'` — which answers true or false, never the value | a fallback value with `??`: `sort ?? 'listeners'`; a test with `or` between two conditions |
|
|
260
270
|
| `test-account-role-gone` | a test account holds a visitor role the space does not declare in `settings.visitorRoles` — removed since, or never there: a journey plays it without that role, and one that needed what it gave fails | one of the space’s roles for the account — or the role declared again |
|
|
261
271
|
| `test-unreadable` | a test of the space — an element check or a flow — that cannot be read as it is written: a page no page of the space answers, an element it no longer has, a relation that is none. A snapshot and a publish wait for it | the test as the message says — or the space back to what the test expects |
|
|
272
|
+
| `time-window-empty` | a `timeWindow` that ends before it starts — it never shows what it holds | `endsAt` after `startsAt` |
|
|
262
273
|
| `transient-state-without-keep-state` | `transientState` without `keepState` — nothing is kept in the first place | `settings.keepState: true`, or remove `transientState` |
|
|
263
274
|
| `unknown-element-type` | a type no built-in element has | the built-in it suggests; a plugin's declaration goes in `authorSpace(space, { plugins: [declaration] })` |
|
|
264
275
|
| `unknown-global-callback` | a global callback no built-in source declares — it runs only if something registers it | the built-in it suggests, or make sure a plugin or module of the space registers it |
|
|
265
276
|
| `unknown-utility` | a utility that is not one of the built-in ones | one of the built-in utilities |
|
|
266
277
|
| `unknown-variable` | a `var(--x)` nothing in the space declares — the property it is in is dropped | declare it under `variables`, fix the name, or give it a fallback: `var(--x, …)` |
|
|
267
278
|
| `unknown-variant` | a variant no class of the element and no style of its type declares — nothing applies | declare it (`styles(name, { variants: { … } })`), or name one that is |
|
|
279
|
+
| `variants-builder-variant` | a `variants`' `builderVariant` that is not the place of one of its variants — the builder shows the first | the place of a variant it has, from 0 |
|
|
280
|
+
| `variants-no-fallback` | by rules, a `variants` whose every variant has a rule: a visitor matching none is shown nothing | end it with a `variantItem` with no `when`, for everybody else |
|
|
281
|
+
| `variants-unreachable` | by rules, a `variantItem` after one with no rule, which takes everybody left — it is never shown | move the variant with no rule last, or give it one |
|
|
268
282
|
|
|
269
283
|
## Suggested
|
|
270
284
|
|
|
@@ -58,6 +58,13 @@ declare is an error (`flag-unknown`).
|
|
|
58
58
|
Prefer a gate to `visible: 'flags.x'`: a visibility bound to a flag still renders the hidden half and ships it in the
|
|
59
59
|
HTML. Reach for the source only for what a gate cannot say — a label that changes, a step that branches.
|
|
60
60
|
|
|
61
|
+
## Rolling out gradually
|
|
62
|
+
|
|
63
|
+
`rollout: { percent: 10, value: true }` on a flag turns it on for 10% of the visitors when none of its rules matches;
|
|
64
|
+
the rest get its `value`. Each visitor keeps their place (a cookie), so raising the percent keeps everyone who was in —
|
|
65
|
+
10, then 50, then 100, then remove the flag. Rules still come first: a rule for staff answers before the rollout. Not
|
|
66
|
+
access control — a visitor's place is theirs to change. A malformed one is `flag-rollout`.
|
|
67
|
+
|
|
61
68
|
## Who decides
|
|
62
69
|
|
|
63
70
|
The space's declaration answers first. Above it, in order, each may override a flag — only one the space declares:
|
|
@@ -76,3 +83,57 @@ and a self-hosted server keeps the last ones it fetched — so a published site
|
|
|
76
83
|
|
|
77
84
|
Remove the gate from what stays, delete what it replaced, and remove the flag. A declared flag nothing reads is a
|
|
78
85
|
warning (`flag-unused`): it is a switch nobody can see the effect of.
|
|
86
|
+
|
|
87
|
+
## Variants: A/B tests and audiences
|
|
88
|
+
|
|
89
|
+
A flag shows the same side to everyone its rules match; `variants` shows each visitor one of its `variantItem`s, chosen
|
|
90
|
+
**by chance** (an A/B test, the default) or **by rules** (who the visitor is). Only the variant shown is drawn.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
variants({
|
|
94
|
+
children: [
|
|
95
|
+
variantItem({ weight: 90, children: [heading({ content: 'Build faster' })] }), // A: 90% of the visitors
|
|
96
|
+
variantItem({ weight: 10, children: [heading({ content: 'Ship today' })] }) // B: 10%
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**By chance**, it holds two to five variants — A first, then B… A `weight` is the percent of the visitors it
|
|
102
|
+
is shown to, and the variants' add up to 100 — 50/25/20/5, any split (`experiment-weights-total` warns otherwise; 50
|
|
103
|
+
each by default). The server draws the visitor's variant and keeps it in a cookie, so a reload or a later visit shows the same,
|
|
104
|
+
and a visitor keeps theirs when the shares change; 0 shows a variant to nobody, one left with a share ends the test. Its
|
|
105
|
+
`experiment` names the test — left empty, the element's id does (`pricing-test` runs `pricing_test`) — and two with the
|
|
106
|
+
same name show a visitor the same variant (`experiment-weights-differ` warns when their shares disagree). Count a
|
|
107
|
+
conversion with the `reachGoal('signup')` step: Plitzi's analytics shows each variant's visitors, conversions and rate
|
|
108
|
+
against A's. `{{ experiments.<name> }}` is `'a'`, `'b'`… for a flow. To see a variant you were not drawn, where debugging
|
|
109
|
+
is authorized: the dev tools' **Experiments** tab, or `?ab=heroTest:b` in the address.
|
|
110
|
+
|
|
111
|
+
**By rules** — `chooseBy: 'rules'` — it shows the first variant whose `when` the visitor matches: a rule group over what a
|
|
112
|
+
flag's rules see, `queryParams.utm_source` included, and the visitor: `visitor.returning`, `visitor.language` (`es`),
|
|
113
|
+
`visitor.device` (`mobile`, `tablet`, `desktop`). End it with a variant with no `when`, for everybody else
|
|
114
|
+
(`variants-no-fallback` warns otherwise):
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
variants({
|
|
118
|
+
chooseBy: 'rules',
|
|
119
|
+
children: [
|
|
120
|
+
variantItem({
|
|
121
|
+
when: { combinator: 'and', rules: [{ field: 'visitor.device', operator: '=', value: 'mobile' }] },
|
|
122
|
+
children: [text({ content: 'Get the app' })]
|
|
123
|
+
}),
|
|
124
|
+
variantItem([text({ content: 'Welcome' })])
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
A variant keeps its `weight` and its `when` whichever way it chooses, so switching loses neither. In the builder its
|
|
130
|
+
settings list the variants with their share or their rule; the canvas shows the one picked there (`builderVariant`, its
|
|
131
|
+
place from 0) while editing, and the preview the visitor chosen in the State Manager's **Visitor** tab.
|
|
132
|
+
|
|
133
|
+
## Showing something for a while
|
|
134
|
+
|
|
135
|
+
`timeWindow({ startsAt: '2026-12-01T09:00:00Z', endsAt: '2026-12-08T09:00:00Z', children })` shows what it holds only
|
|
136
|
+
between the two instants — ISO 8601 with the offset, never a local time (`time-window-bound`); either empty is no
|
|
137
|
+
bound. An open page shows or hides it when the window opens or closes. In the builder it always shows while editing;
|
|
138
|
+
the preview reads it at the date chosen in the Visitor tab.
|
|
139
|
+
|
|
@@ -15,7 +15,7 @@ Read one only when the task names its subject.
|
|
|
15
15
|
| [data-and-visibility.md](data-and-visibility.md) | Bindings, providers, offline data, loading/empty/error states, live data, caching, showing and hiding, kept state |
|
|
16
16
|
| [kept-state.md](kept-state.md) | State that outlives a reload: `keepState`, transient and painted keys |
|
|
17
17
|
| [auth.md](auth.md) | Signing people in: providers, `authLogin`, `auth.*`, visitor roles |
|
|
18
|
-
| [feature-flags.md](feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships |
|
|
18
|
+
| [feature-flags.md](feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships; an A/B test; an audience; a time window |
|
|
19
19
|
| [lists.md](lists.md) | Rendering rows, filtering and sorting them, a detail page for one record, carousels |
|
|
20
20
|
| [typed-sources.md](typed-sources.md) | Data typed by a sample of it: `source()`, typed rows, `twig` for templates |
|
|
21
21
|
| [validation.md](validation.md) | How `authorSpace` checks, the loop that wastes no attempts, and what it cannot see |
|
|
@@ -39,7 +39,7 @@ A text template feeding `items` is refused: the list would receive the array wri
|
|
|
39
39
|
## Naming sources inside a template
|
|
40
40
|
|
|
41
41
|
Always the full name — the element's kind, an underscore, its id: `apiContainer_stats`, `list_rows`,
|
|
42
|
-
`modalContainer_credits`. The globals (`state`, `auth`, `navigation`, `variables`, `host`, `theme`, `flags`, `computed`) are
|
|
42
|
+
`modalContainer_credits`. The globals (`state`, `auth`, `navigation`, `variables`, `host`, `theme`, `flags`, `experiments`, `computed`) are
|
|
43
43
|
named as themselves — `{{ flags.newCheckout }}` is `true` or `false`, see [feature flags](feature-flags.md). In a flow, an earlier step is read by the name given with `named('quote', …)`: `{{ quote.output.total }}`.
|
|
44
44
|
|
|
45
45
|
An id with a hyphen is one name inside a template — `{{ apiContainer_tn-data.data.total }}` reads that provider. So
|