@rocapine/react-native-onboarding 1.72.0 → 1.74.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 +136 -3
- package/dist/OnboardingStudio.d.ts +82 -0
- package/dist/OnboardingStudio.d.ts.map +1 -0
- package/dist/OnboardingStudio.js +91 -0
- package/dist/OnboardingStudio.js.map +1 -0
- package/dist/OnboardingStudioClient.d.ts +14 -5
- package/dist/OnboardingStudioClient.d.ts.map +1 -1
- package/dist/OnboardingStudioClient.js +24 -9
- package/dist/OnboardingStudioClient.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -4
- package/dist/index.js.map +1 -1
- package/dist/infra/provider/OnboardingProvider.d.ts +11 -2
- package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
- package/dist/infra/provider/OnboardingProvider.js +26 -2
- package/dist/infra/provider/OnboardingProvider.js.map +1 -1
- package/dist/infra/queries/cacheKey.d.ts +41 -3
- package/dist/infra/queries/cacheKey.d.ts.map +1 -1
- package/dist/infra/queries/cacheKey.js +44 -8
- package/dist/infra/queries/cacheKey.js.map +1 -1
- package/dist/infra/queries/getOnboarding.query.d.ts.map +1 -1
- package/dist/infra/queries/getOnboarding.query.js +6 -1
- package/dist/infra/queries/getOnboarding.query.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +95 -5
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +121 -9
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/catalogSettleWaiter.d.ts +31 -0
- package/dist/paywalls/catalogSettleWaiter.d.ts.map +1 -0
- package/dist/paywalls/catalogSettleWaiter.js +58 -0
- package/dist/paywalls/catalogSettleWaiter.js.map +1 -0
- package/dist/paywalls/customScreens.d.ts +83 -0
- package/dist/paywalls/customScreens.d.ts.map +1 -0
- package/dist/paywalls/customScreens.js +3 -0
- package/dist/paywalls/customScreens.js.map +1 -0
- package/dist/paywalls/getPaywalls.query.d.ts.map +1 -1
- package/dist/paywalls/getPaywalls.query.js +6 -1
- package/dist/paywalls/getPaywalls.query.js.map +1 -1
- package/dist/paywalls/register.d.ts +105 -0
- package/dist/paywalls/register.d.ts.map +1 -0
- package/dist/paywalls/register.js +112 -0
- package/dist/paywalls/register.js.map +1 -0
- package/dist/paywalls/usePaywall.d.ts +43 -0
- package/dist/paywalls/usePaywall.d.ts.map +1 -1
- package/dist/paywalls/usePaywall.js +11 -2
- package/dist/paywalls/usePaywall.js.map +1 -1
- package/dist/steps/Paywall/types.d.ts +63 -0
- package/dist/steps/Paywall/types.d.ts.map +1 -0
- package/dist/steps/Paywall/types.js +29 -0
- package/dist/steps/Paywall/types.js.map +1 -0
- package/dist/steps/types.d.ts +2 -1
- package/dist/steps/types.d.ts.map +1 -1
- package/dist/userProperties/applyPatch.d.ts +18 -0
- package/dist/userProperties/applyPatch.d.ts.map +1 -0
- package/dist/userProperties/applyPatch.js +57 -0
- package/dist/userProperties/applyPatch.js.map +1 -0
- package/dist/userProperties/effectiveParams.d.ts +29 -0
- package/dist/userProperties/effectiveParams.d.ts.map +1 -0
- package/dist/userProperties/effectiveParams.js +56 -0
- package/dist/userProperties/effectiveParams.js.map +1 -0
- package/dist/userProperties/index.d.ts +9 -0
- package/dist/userProperties/index.d.ts.map +1 -0
- package/dist/userProperties/index.js +21 -0
- package/dist/userProperties/index.js.map +1 -0
- package/dist/userProperties/reserved.d.ts +33 -0
- package/dist/userProperties/reserved.d.ts.map +1 -0
- package/dist/userProperties/reserved.js +45 -0
- package/dist/userProperties/reserved.js.map +1 -0
- package/dist/userProperties/serialize.d.ts +38 -0
- package/dist/userProperties/serialize.d.ts.map +1 -0
- package/dist/userProperties/serialize.js +67 -0
- package/dist/userProperties/serialize.js.map +1 -0
- package/dist/userProperties/store.d.ts +63 -0
- package/dist/userProperties/store.d.ts.map +1 -0
- package/dist/userProperties/store.js +153 -0
- package/dist/userProperties/store.js.map +1 -0
- package/dist/userProperties/types.d.ts +21 -0
- package/dist/userProperties/types.d.ts.map +1 -0
- package/dist/userProperties/types.js +3 -0
- package/dist/userProperties/types.js.map +1 -0
- package/dist/userProperties/useUserProperties.d.ts +20 -0
- package/dist/userProperties/useUserProperties.d.ts.map +1 -0
- package/dist/userProperties/useUserProperties.js +30 -0
- package/dist/userProperties/useUserProperties.js.map +1 -0
- package/package.json +1 -1
- package/src/OnboardingStudio.ts +147 -0
- package/src/OnboardingStudioClient.ts +27 -11
- package/src/__tests__/OnboardingStudio.test.ts +208 -0
- package/src/__tests__/cacheKey.test.ts +71 -0
- package/src/__tests__/getOnboarding.query.test.ts +47 -8
- package/src/index.ts +51 -0
- package/src/infra/provider/OnboardingProvider.tsx +45 -4
- package/src/infra/queries/cacheKey.ts +54 -9
- package/src/infra/queries/getOnboarding.query.ts +9 -1
- package/src/paywalls/PaywallProvider.tsx +226 -9
- package/src/paywalls/__tests__/catalogSettleWaiter.test.ts +134 -0
- package/src/paywalls/__tests__/getPaywalls.test.ts +29 -11
- package/src/paywalls/__tests__/register.test.ts +266 -0
- package/src/paywalls/catalogSettleWaiter.ts +72 -0
- package/src/paywalls/customScreens.ts +82 -0
- package/src/paywalls/getPaywalls.query.ts +9 -1
- package/src/paywalls/register.ts +169 -0
- package/src/paywalls/usePaywall.ts +63 -3
- package/src/steps/Paywall/types.ts +29 -0
- package/src/steps/types.ts +2 -0
- package/src/userProperties/__tests__/effectiveParams.test.ts +51 -0
- package/src/userProperties/__tests__/primitives.test.ts +96 -0
- package/src/userProperties/__tests__/store.test.ts +181 -0
- package/src/userProperties/applyPatch.ts +68 -0
- package/src/userProperties/effectiveParams.ts +60 -0
- package/src/userProperties/index.ts +11 -0
- package/src/userProperties/reserved.ts +44 -0
- package/src/userProperties/serialize.ts +61 -0
- package/src/userProperties/store.ts +177 -0
- package/src/userProperties/types.ts +22 -0
- package/src/userProperties/useUserProperties.ts +26 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runRegister = exports.shouldRunFeature = exports.resolveRegisterDecision = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* `wait` is a DECISION rather than something the caller infers from
|
|
6
|
+
* `catalogStatus` itself, so "when may register block?" has exactly one answer in
|
|
7
|
+
* one tested place. The caller awaits the catalog settling and calls this again;
|
|
8
|
+
* the second call cannot return `wait`, because the wait resolves only on
|
|
9
|
+
* `"ready"`/`"error"` and a timeout is treated as `catalog-unavailable` without
|
|
10
|
+
* asking again.
|
|
11
|
+
*
|
|
12
|
+
* `"revalidating"` counts as usable. That is safe only because the AsyncStorage
|
|
13
|
+
* cache key is scoped by audience params: before that, a revalidating catalog
|
|
14
|
+
* might have been resolved under DIFFERENT params, so a missing moment could
|
|
15
|
+
* mean "not yet" rather than "absent". Now a served catalog always matches the
|
|
16
|
+
* current params.
|
|
17
|
+
*/
|
|
18
|
+
const resolveRegisterDecision = (catalog, catalogStatus, moment) => {
|
|
19
|
+
if (!catalog) {
|
|
20
|
+
// Nothing to decide against yet. "loading" is worth waiting for; anything
|
|
21
|
+
// else with no catalog is terminal.
|
|
22
|
+
return catalogStatus === "loading"
|
|
23
|
+
? { type: "wait" }
|
|
24
|
+
: { type: "run", reason: "catalog-unavailable" };
|
|
25
|
+
}
|
|
26
|
+
const paywall = catalog.paywalls[moment];
|
|
27
|
+
// A moment absent from a RESOLVED catalog is not a failure: it means the moment
|
|
28
|
+
// is not monetised, or is not authored yet. The feature is free.
|
|
29
|
+
if (!paywall)
|
|
30
|
+
return { type: "run", reason: "no-paywall" };
|
|
31
|
+
return { type: "present", paywall };
|
|
32
|
+
};
|
|
33
|
+
exports.resolveRegisterDecision = resolveRegisterDecision;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a completed presentation unlocks the feature. Only a purchase does.
|
|
36
|
+
*
|
|
37
|
+
* This one-liner is correct only because `resolvePresentedOutcome` already
|
|
38
|
+
* upgraded the generic `{status:"dismissed"}` that the canonical authoring shape
|
|
39
|
+
* — `{type:"purchase", onSuccess:[{type:"dismiss"}]}` — produces into
|
|
40
|
+
* `"purchased"` when the store actually charged. Without that upgrade this would
|
|
41
|
+
* refuse the feature to every user who bought.
|
|
42
|
+
*
|
|
43
|
+
* **A Stripe paywall never unlocks on the purchase alone.** `PresentResult` has
|
|
44
|
+
* no `"pending"` status — that belongs to `PurchaseResult` — so a Payment Link
|
|
45
|
+
* checkout surfaces here as whatever its action list reported, in practice
|
|
46
|
+
* `"dismissed"` via its `onPending` branch. The entitlement arrives out-of-band
|
|
47
|
+
* through RevenueCat, so grant access from that webhook rather than from
|
|
48
|
+
* `register`. `runRegister` warns when it is about to present one.
|
|
49
|
+
*/
|
|
50
|
+
const shouldRunFeature = (outcome) => outcome.status === "purchased";
|
|
51
|
+
exports.shouldRunFeature = shouldRunFeature;
|
|
52
|
+
/**
|
|
53
|
+
* `register(moment, feature)`'s whole orchestration.
|
|
54
|
+
*
|
|
55
|
+
* Lives here rather than inside `PaywallProvider` so every branch — both
|
|
56
|
+
* fail-open paths, the wait-once rule, the Stripe warning, and the
|
|
57
|
+
* withhold-on-dismiss case — is covered by a plain async test. This repo has no
|
|
58
|
+
* vitest config, so tests run without a DOM; a provider-rendering test would mean
|
|
59
|
+
* adding jsdom to assert control flow that has nothing to do with rendering.
|
|
60
|
+
*
|
|
61
|
+
* It delegates presentation to the injected `present`, which in the provider is
|
|
62
|
+
* the real one — so the wedge recovery, the purchase-generation race guard and
|
|
63
|
+
* outcome reconciliation all apply unchanged.
|
|
64
|
+
*/
|
|
65
|
+
const runRegister = async (deps, moment, feature) => {
|
|
66
|
+
let decision = (0, exports.resolveRegisterDecision)(deps.getCatalog(), deps.getCatalogStatus(), moment);
|
|
67
|
+
if (decision.type === "wait") {
|
|
68
|
+
// Called on a user tap, so it cannot simply fail because the catalog has not
|
|
69
|
+
// landed. In practice a returning user's catalog is already on disk and this
|
|
70
|
+
// resolves immediately.
|
|
71
|
+
await deps.waitForCatalogSettled(deps.timeoutMs);
|
|
72
|
+
decision = (0, exports.resolveRegisterDecision)(deps.getCatalog(), deps.getCatalogStatus(), moment);
|
|
73
|
+
// The wait timed out with the catalog still loading. Decide — never wait a
|
|
74
|
+
// second time, or a permanently-loading catalog would park the caller
|
|
75
|
+
// forever in `timeoutMs` increments.
|
|
76
|
+
if (decision.type === "wait")
|
|
77
|
+
decision = { type: "run", reason: "catalog-unavailable" };
|
|
78
|
+
}
|
|
79
|
+
if (decision.type === "run") {
|
|
80
|
+
if (decision.reason === "catalog-unavailable") {
|
|
81
|
+
// Failing OPEN. The alternative locks every gated feature behind a network
|
|
82
|
+
// call: an offline launch would make the app's features silently dead with
|
|
83
|
+
// no paywall to explain why, which is indistinguishable from a broken app.
|
|
84
|
+
// The cost is real — some sessions get a paid feature free — so it is
|
|
85
|
+
// logged, and the returned `reason` lets a host measure the rate.
|
|
86
|
+
console.warn(`[paywalls] register("${moment}") could not reach a verdict (no paywall catalog) ` +
|
|
87
|
+
"and ran the feature ungated. The catalog failed to load, or is still loading " +
|
|
88
|
+
"after the register timeout.");
|
|
89
|
+
}
|
|
90
|
+
await (feature === null || feature === void 0 ? void 0 : feature());
|
|
91
|
+
return { ran: true, presented: false, reason: decision.reason };
|
|
92
|
+
}
|
|
93
|
+
if (decision.paywall.billing === "stripe") {
|
|
94
|
+
// See `shouldRunFeature`: a Payment Link checkout never produces a
|
|
95
|
+
// "purchased" PresentResult, so the gated feature cannot unlock from it.
|
|
96
|
+
console.warn(`[paywalls] register("${moment}") will present a Stripe-billed paywall. A Payment ` +
|
|
97
|
+
'Link checkout never resolves as "purchased" — the entitlement arrives out-of-band ' +
|
|
98
|
+
"through RevenueCat — so the gated feature will NOT run on a successful checkout. " +
|
|
99
|
+
"Grant access from your RevenueCat entitlement webhook instead.");
|
|
100
|
+
}
|
|
101
|
+
const outcome = await deps.present(moment);
|
|
102
|
+
if ((0, exports.shouldRunFeature)(outcome)) {
|
|
103
|
+
await (feature === null || feature === void 0 ? void 0 : feature());
|
|
104
|
+
return { ran: true, presented: true, reason: "purchased", outcome };
|
|
105
|
+
}
|
|
106
|
+
// Covers dismissed, cancelled and every `present()` error — including
|
|
107
|
+
// "already-presenting", which needs no branch of its own: the feature does not
|
|
108
|
+
// run and the in-flight paywall is untouched.
|
|
109
|
+
return { ran: false, presented: true, reason: "not-purchased", outcome };
|
|
110
|
+
};
|
|
111
|
+
exports.runRegister = runRegister;
|
|
112
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/paywalls/register.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PaywallCatalog, PresentResult } from "./types";
|
|
2
2
|
import type { CatalogStatus } from "./present";
|
|
3
3
|
import type { ProductStatus } from "../products/types";
|
|
4
|
+
import type { CustomPaywallScreens } from "./customScreens";
|
|
5
|
+
import type { RegisterFeature, RegisterResult } from "./register";
|
|
4
6
|
export type UsePaywallResult = {
|
|
5
7
|
/**
|
|
6
8
|
* Present a paywall by moment. Never fetches — the catalog and its
|
|
@@ -13,6 +15,34 @@ export type UsePaywallResult = {
|
|
|
13
15
|
* presented. See `resolvePresentDecision` in `present.ts`.
|
|
14
16
|
*/
|
|
15
17
|
present: (moment: string) => Promise<PresentResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Gate a feature on a moment — Superwall's `registerPlacement`, in this SDK's
|
|
20
|
+
* vocabulary:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* await register("unlock_stats", () => router.push("/stats"));
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* - The moment has **no paywall** (not monetised, or not authored yet) → runs
|
|
27
|
+
* the feature immediately.
|
|
28
|
+
* - The moment **has** a paywall → presents it, and runs the feature **only**
|
|
29
|
+
* on a purchase. A dismiss or a cancel withholds it.
|
|
30
|
+
* - **No catalog is reachable** → fails OPEN: runs the feature and warns. An
|
|
31
|
+
* offline launch must not silently disable the app's features. Read
|
|
32
|
+
* `reason: "catalog-unavailable"` off the result to measure how often this
|
|
33
|
+
* happens.
|
|
34
|
+
*
|
|
35
|
+
* Gates on the moment **alone** — there is no entitlement check. Exclude
|
|
36
|
+
* paying users by setting a user property
|
|
37
|
+
* (`OnboardingStudio.setUserProperty("plan", "pro")`)
|
|
38
|
+
* and authoring an audience filter on it.
|
|
39
|
+
*
|
|
40
|
+
* **A Stripe-billed paywall never runs the feature**, even on a successful
|
|
41
|
+
* checkout: a Payment Link resolves out-of-band through RevenueCat, so the
|
|
42
|
+
* presentation never reports `"purchased"`. Grant access from your RevenueCat
|
|
43
|
+
* entitlement webhook. `register` warns when it presents one.
|
|
44
|
+
*/
|
|
45
|
+
register: (moment: string, feature?: RegisterFeature) => Promise<RegisterResult>;
|
|
16
46
|
/**
|
|
17
47
|
* `true` once BOTH the catalog and its products have resolved — the one
|
|
18
48
|
* flag meaning "calling `present()` now will not show a spinner".
|
|
@@ -33,6 +63,19 @@ export type UsePaywallResult = {
|
|
|
33
63
|
* host tell "still waiting on the store" from "still waiting on us".
|
|
34
64
|
*/
|
|
35
65
|
productsStatus: ProductStatus;
|
|
66
|
+
/**
|
|
67
|
+
* Whether a real `PaywallProvider` is above this consumer — see the field's
|
|
68
|
+
* doc on `PaywallContextValue`. Needed by any consumer that renders a
|
|
69
|
+
* spinner while the catalog loads, because with no provider
|
|
70
|
+
* `catalogStatus` reports `"loading"` and nothing ever arrives.
|
|
71
|
+
*/
|
|
72
|
+
isProviderMounted: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Host-registered screens for `renderMode: "custom"` paywalls, keyed by
|
|
75
|
+
* `customScreenId`. Exposed here because the inline `Paywall` onboarding
|
|
76
|
+
* step renders them itself, never going through `PaywallHost`.
|
|
77
|
+
*/
|
|
78
|
+
customScreens: CustomPaywallScreens;
|
|
36
79
|
};
|
|
37
80
|
/**
|
|
38
81
|
* Read the paywall runtime published by an ancestor `PaywallProvider`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACjF;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B;;;;;OAKG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAqB7B,CAAC"}
|
|
@@ -10,8 +10,17 @@ const PaywallProvider_1 = require("./PaywallProvider");
|
|
|
10
10
|
* `useProductRuntime()` degrades to `null` with no ancestor.
|
|
11
11
|
*/
|
|
12
12
|
const usePaywall = () => {
|
|
13
|
-
const { present, isReady, catalog, catalogStatus, productsStatus } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
|
|
14
|
-
return {
|
|
13
|
+
const { present, register, isReady, catalog, catalogStatus, productsStatus, isProviderMounted, customScreens, } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
|
|
14
|
+
return {
|
|
15
|
+
present,
|
|
16
|
+
register,
|
|
17
|
+
isReady,
|
|
18
|
+
catalog,
|
|
19
|
+
catalogStatus,
|
|
20
|
+
productsStatus,
|
|
21
|
+
isProviderMounted,
|
|
22
|
+
customScreens,
|
|
23
|
+
};
|
|
15
24
|
};
|
|
16
25
|
exports.usePaywall = usePaywall;
|
|
17
26
|
//# sourceMappingURL=usePaywall.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;
|
|
1
|
+
{"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;AAkFnD;;;;;GAKG;AACI,MAAM,UAAU,GAAG,GAAqB,EAAE;IAC/C,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,GAAG,IAAA,kBAAU,EAAC,gCAAc,CAAC,CAAC;IAC/B,OAAO;QACL,OAAO;QACP,QAAQ;QACR,OAAO;QACP,OAAO;QACP,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,UAAU,cAqBrB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A step that IS a paywall.
|
|
4
|
+
*
|
|
5
|
+
* `moment` is a `moments.key` — the same address a host passes to `present()`.
|
|
6
|
+
* It resolves through the catalog `get-paywalls` already returns keyed by
|
|
7
|
+
* moment, which means the audience waterfall has ALREADY picked the variant:
|
|
8
|
+
* targeting and weighted A/B come for free, and this payload needs exactly one
|
|
9
|
+
* field. No wire change was required anywhere for this step type.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately not a paywall id: that would bypass the waterfall, so
|
|
12
|
+
* A/B-testing a paywall inside an onboarding would mean duplicating the whole
|
|
13
|
+
* onboarding.
|
|
14
|
+
*
|
|
15
|
+
* Rendered inline by the UI package's `Pages/Paywall/Renderer.tsx`, and
|
|
16
|
+
* HARD-GATED — only a purchase advances past it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PaywallStepPayloadSchema: z.ZodObject<{
|
|
19
|
+
moment: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const PaywallStepTypeSchema: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
displayProgressHeader: z.ZodBoolean;
|
|
25
|
+
customPayload: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
26
|
+
continueButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
27
|
+
buttonSection: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
label: z.ZodOptional<z.ZodString>;
|
|
29
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
figmaUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
nextStep: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
33
|
+
defaultTargetStepId: z.ZodString;
|
|
34
|
+
branches: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
35
|
+
condition: z.ZodDefault<z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
variable: z.ZodString;
|
|
37
|
+
operator: z.ZodEnum<{
|
|
38
|
+
in: "in";
|
|
39
|
+
eq: "eq";
|
|
40
|
+
neq: "neq";
|
|
41
|
+
gt: "gt";
|
|
42
|
+
lt: "lt";
|
|
43
|
+
gte: "gte";
|
|
44
|
+
lte: "lte";
|
|
45
|
+
contains: "contains";
|
|
46
|
+
not_in: "not_in";
|
|
47
|
+
is_empty: "is_empty";
|
|
48
|
+
is_not_empty: "is_not_empty";
|
|
49
|
+
is_null: "is_null";
|
|
50
|
+
is_not_null: "is_not_null";
|
|
51
|
+
}>;
|
|
52
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
|
|
53
|
+
}, z.core.$strip>, z.ZodType<import("../common.types").ConditionGroup, unknown, z.core.$ZodTypeInternals<import("../common.types").ConditionGroup, unknown>>]>>>;
|
|
54
|
+
targetStepId: z.ZodString;
|
|
55
|
+
}, z.core.$strip>>>;
|
|
56
|
+
}, z.core.$strip>>>;
|
|
57
|
+
type: z.ZodLiteral<"Paywall">;
|
|
58
|
+
payload: z.ZodObject<{
|
|
59
|
+
moment: z.ZodString;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type PaywallStepType = z.infer<typeof PaywallStepTypeSchema>;
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/steps/Paywall/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB;;iBAEnC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaywallStepTypeSchema = exports.PaywallStepPayloadSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_types_1 = require("../common.types");
|
|
6
|
+
/**
|
|
7
|
+
* A step that IS a paywall.
|
|
8
|
+
*
|
|
9
|
+
* `moment` is a `moments.key` — the same address a host passes to `present()`.
|
|
10
|
+
* It resolves through the catalog `get-paywalls` already returns keyed by
|
|
11
|
+
* moment, which means the audience waterfall has ALREADY picked the variant:
|
|
12
|
+
* targeting and weighted A/B come for free, and this payload needs exactly one
|
|
13
|
+
* field. No wire change was required anywhere for this step type.
|
|
14
|
+
*
|
|
15
|
+
* Deliberately not a paywall id: that would bypass the waterfall, so
|
|
16
|
+
* A/B-testing a paywall inside an onboarding would mean duplicating the whole
|
|
17
|
+
* onboarding.
|
|
18
|
+
*
|
|
19
|
+
* Rendered inline by the UI package's `Pages/Paywall/Renderer.tsx`, and
|
|
20
|
+
* HARD-GATED — only a purchase advances past it.
|
|
21
|
+
*/
|
|
22
|
+
exports.PaywallStepPayloadSchema = zod_1.z.object({
|
|
23
|
+
moment: zod_1.z.string().min(1),
|
|
24
|
+
});
|
|
25
|
+
exports.PaywallStepTypeSchema = common_types_1.BaseStepTypeSchema.extend({
|
|
26
|
+
type: zod_1.z.literal("Paywall"),
|
|
27
|
+
payload: exports.PaywallStepPayloadSchema,
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/steps/Paywall/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,kDAAqD;AAErD;;;;;;;;;;;;;;;GAeG;AACU,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1B,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,iCAAkB,CAAC,MAAM,CAAC;IAC7D,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,gCAAwB;CAClC,CAAC,CAAC"}
|
package/dist/steps/types.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { CommitmentStepType } from "./Commitment/types";
|
|
|
3
3
|
import { LoaderStepType } from "./Loader/types";
|
|
4
4
|
import { MediaContentStepType } from "./MediaContent/types";
|
|
5
5
|
import { ComposableScreenStepType } from "./ComposableScreen/types";
|
|
6
|
+
import { PaywallStepType } from "./Paywall/types";
|
|
6
7
|
import { PickerStepType } from "./Picker/types";
|
|
7
8
|
import { QuestionStepType } from "./Question/types";
|
|
8
9
|
import { RatingsStepType } from "./Ratings/types";
|
|
9
|
-
export type OnboardingStepType = CarouselStepType | CommitmentStepType | LoaderStepType | MediaContentStepType | ComposableScreenStepType | PickerStepType | QuestionStepType | RatingsStepType;
|
|
10
|
+
export type OnboardingStepType = CarouselStepType | CommitmentStepType | LoaderStepType | MediaContentStepType | ComposableScreenStepType | PaywallStepType | PickerStepType | QuestionStepType | RatingsStepType;
|
|
10
11
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/steps/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,cAAc,GACd,gBAAgB,GAChB,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/steps/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,eAAe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UserProperties, UserPropertyPatch } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The store's entire mutation logic, as a pure function — so merge semantics,
|
|
4
|
+
* deletion, and every rejection rule are covered by an importable test rather
|
|
5
|
+
* than through AsyncStorage and React.
|
|
6
|
+
*
|
|
7
|
+
* Warnings are RETURNED rather than logged here, so the same rules can be
|
|
8
|
+
* asserted without spying on `console`. The store logs them.
|
|
9
|
+
*
|
|
10
|
+
* Returns the SAME `current` object when nothing changed, so a no-op `set` does
|
|
11
|
+
* not notify subscribers or trigger a refetch — a host calling `set({ plan })`
|
|
12
|
+
* on every render must not re-key the catalog query each time.
|
|
13
|
+
*/
|
|
14
|
+
export declare const applyUserPropertyPatch: (current: UserProperties, patch: UserPropertyPatch) => {
|
|
15
|
+
next: UserProperties;
|
|
16
|
+
warnings: string[];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=applyPatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyPatch.d.ts","sourceRoot":"","sources":["../../src/userProperties/applyPatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,cAAc,EACvB,OAAO,iBAAiB,KACvB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAiD5C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyUserPropertyPatch = void 0;
|
|
4
|
+
const reserved_1 = require("./reserved");
|
|
5
|
+
/**
|
|
6
|
+
* The store's entire mutation logic, as a pure function — so merge semantics,
|
|
7
|
+
* deletion, and every rejection rule are covered by an importable test rather
|
|
8
|
+
* than through AsyncStorage and React.
|
|
9
|
+
*
|
|
10
|
+
* Warnings are RETURNED rather than logged here, so the same rules can be
|
|
11
|
+
* asserted without spying on `console`. The store logs them.
|
|
12
|
+
*
|
|
13
|
+
* Returns the SAME `current` object when nothing changed, so a no-op `set` does
|
|
14
|
+
* not notify subscribers or trigger a refetch — a host calling `set({ plan })`
|
|
15
|
+
* on every render must not re-key the catalog query each time.
|
|
16
|
+
*/
|
|
17
|
+
const applyUserPropertyPatch = (current, patch) => {
|
|
18
|
+
const warnings = [];
|
|
19
|
+
const next = Object.assign({}, current);
|
|
20
|
+
let changed = false;
|
|
21
|
+
for (const key of Object.keys(patch)) {
|
|
22
|
+
if ((0, reserved_1.isReservedUserPropertyKey)(key)) {
|
|
23
|
+
warnings.push(`[user-properties] Ignoring "${key}" — the SDK puts that name on the ` +
|
|
24
|
+
"request querystring itself, and a duplicate silently breaks the request. " +
|
|
25
|
+
"Rename the property.");
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const value = patch[key];
|
|
29
|
+
if (value === null || value === undefined) {
|
|
30
|
+
if (key in next) {
|
|
31
|
+
delete next[key];
|
|
32
|
+
changed = true;
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const type = typeof value;
|
|
37
|
+
if (type === "number") {
|
|
38
|
+
if (!Number.isFinite(value)) {
|
|
39
|
+
warnings.push(`[user-properties] Ignoring "${key}" — ${String(value)} is not a finite ` +
|
|
40
|
+
'number and would reach the server as "NaN"/"Infinity", matching nothing.');
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (type !== "string" && type !== "boolean") {
|
|
45
|
+
warnings.push(`[user-properties] Ignoring "${key}" — a user property must be a string, ` +
|
|
46
|
+
`number or boolean, not ${type}. Audience filters compare scalars.`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (next[key] !== value) {
|
|
50
|
+
next[key] = value;
|
|
51
|
+
changed = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { next: changed ? next : current, warnings };
|
|
55
|
+
};
|
|
56
|
+
exports.applyUserPropertyPatch = applyUserPropertyPatch;
|
|
57
|
+
//# sourceMappingURL=applyPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyPatch.js","sourceRoot":"","sources":["../../src/userProperties/applyPatch.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AAGvD;;;;;;;;;;;GAWG;AACI,MAAM,sBAAsB,GAAG,CACpC,OAAuB,EACvB,KAAwB,EACsB,EAAE;IAChD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,IAAI,qBAAwB,OAAO,CAAE,CAAC;IAC5C,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,IAAA,oCAAyB,EAAC,GAAG,CAAC,EAAE,CAAC;YACnC,QAAQ,CAAC,IAAI,CACX,+BAA+B,GAAG,oCAAoC;gBACpE,2EAA2E;gBAC3E,sBAAsB,CACzB,CAAC;YACF,SAAS;QACX,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAEzB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;gBACjB,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,SAAS;QACX,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;QAC1B,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,QAAQ,CAAC,IAAI,CACX,+BAA+B,GAAG,OAAO,MAAM,CAAC,KAAK,CAAC,mBAAmB;oBACvE,0EAA0E,CAC7E,CAAC;gBACF,SAAS;YACX,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACnD,QAAQ,CAAC,IAAI,CACX,+BAA+B,GAAG,wCAAwC;gBACxE,0BAA0B,IAAI,qCAAqC,CACtE,CAAC;YACF,SAAS;QACX,CAAC;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAClB,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC,CAAC;AApDW,QAAA,sBAAsB,0BAoDjC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { UserProperties } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The audience params a provider actually sends: the `customAudienceParams` prop
|
|
4
|
+
* as a static baseline, with the user-property store merged OVER it.
|
|
5
|
+
*
|
|
6
|
+
* Precedence is the store, per key. `customAudienceParams` is where build-time
|
|
7
|
+
* facts live (an `onboardingId`, a build channel) — set once at mount — and the
|
|
8
|
+
* store is where anything that changes at runtime lives. A runtime value losing
|
|
9
|
+
* to a mount-time prop would make the store useless for the case it exists for.
|
|
10
|
+
*
|
|
11
|
+
* The prop is neither deprecated nor removed: merging means every existing host
|
|
12
|
+
* keeps working untouched.
|
|
13
|
+
*
|
|
14
|
+
* Everything is serialized to a string here, once, so the query key, the cache
|
|
15
|
+
* key hash and the querystring all see the same bytes.
|
|
16
|
+
*
|
|
17
|
+
* The prop is typed `Record<string, any>` and predates this module, so its values
|
|
18
|
+
* are treated conservatively:
|
|
19
|
+
*
|
|
20
|
+
* - a reserved name is DROPPED, because it would break the request outright (the
|
|
21
|
+
* client puts that name on the querystring itself — see `reserved.ts`);
|
|
22
|
+
* - `null`/`undefined` is OMITTED rather than sent as the string `"null"`, which
|
|
23
|
+
* would match an audience filter testing for absence;
|
|
24
|
+
* - anything else non-scalar is stringified with `String(...)` rather than
|
|
25
|
+
* dropped, so a host already passing something exotic keeps the exact wire
|
|
26
|
+
* behaviour it had before this module existed.
|
|
27
|
+
*/
|
|
28
|
+
export declare const resolveEffectiveParams: (baseline: Record<string, any>, properties: UserProperties) => Record<string, string>;
|
|
29
|
+
//# sourceMappingURL=effectiveParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectiveParams.d.ts","sourceRoot":"","sources":["../../src/userProperties/effectiveParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,YAAY,cAAc,KACzB,MAAM,CAAC,MAAM,EAAE,MAAM,CA0BvB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveEffectiveParams = void 0;
|
|
4
|
+
const reserved_1 = require("./reserved");
|
|
5
|
+
const serialize_1 = require("./serialize");
|
|
6
|
+
/**
|
|
7
|
+
* The audience params a provider actually sends: the `customAudienceParams` prop
|
|
8
|
+
* as a static baseline, with the user-property store merged OVER it.
|
|
9
|
+
*
|
|
10
|
+
* Precedence is the store, per key. `customAudienceParams` is where build-time
|
|
11
|
+
* facts live (an `onboardingId`, a build channel) — set once at mount — and the
|
|
12
|
+
* store is where anything that changes at runtime lives. A runtime value losing
|
|
13
|
+
* to a mount-time prop would make the store useless for the case it exists for.
|
|
14
|
+
*
|
|
15
|
+
* The prop is neither deprecated nor removed: merging means every existing host
|
|
16
|
+
* keeps working untouched.
|
|
17
|
+
*
|
|
18
|
+
* Everything is serialized to a string here, once, so the query key, the cache
|
|
19
|
+
* key hash and the querystring all see the same bytes.
|
|
20
|
+
*
|
|
21
|
+
* The prop is typed `Record<string, any>` and predates this module, so its values
|
|
22
|
+
* are treated conservatively:
|
|
23
|
+
*
|
|
24
|
+
* - a reserved name is DROPPED, because it would break the request outright (the
|
|
25
|
+
* client puts that name on the querystring itself — see `reserved.ts`);
|
|
26
|
+
* - `null`/`undefined` is OMITTED rather than sent as the string `"null"`, which
|
|
27
|
+
* would match an audience filter testing for absence;
|
|
28
|
+
* - anything else non-scalar is stringified with `String(...)` rather than
|
|
29
|
+
* dropped, so a host already passing something exotic keeps the exact wire
|
|
30
|
+
* behaviour it had before this module existed.
|
|
31
|
+
*/
|
|
32
|
+
const resolveEffectiveParams = (baseline, properties) => {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const key of Object.keys(baseline !== null && baseline !== void 0 ? baseline : {})) {
|
|
35
|
+
if ((0, reserved_1.isReservedUserPropertyKey)(key)) {
|
|
36
|
+
console.warn(`[user-properties] Ignoring customAudienceParams."${key}" — the SDK puts ` +
|
|
37
|
+
"that name on the request querystring itself, and a duplicate silently " +
|
|
38
|
+
"breaks the request.");
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const value = baseline[key];
|
|
42
|
+
if (value === null || value === undefined)
|
|
43
|
+
continue;
|
|
44
|
+
out[key] =
|
|
45
|
+
typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
46
|
+
? (0, serialize_1.serializeUserPropertyValue)(value)
|
|
47
|
+
: String(value);
|
|
48
|
+
}
|
|
49
|
+
// The store wins.
|
|
50
|
+
for (const key of Object.keys(properties)) {
|
|
51
|
+
out[key] = (0, serialize_1.serializeUserPropertyValue)(properties[key]);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
};
|
|
55
|
+
exports.resolveEffectiveParams = resolveEffectiveParams;
|
|
56
|
+
//# sourceMappingURL=effectiveParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectiveParams.js","sourceRoot":"","sources":["../../src/userProperties/effectiveParams.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AACvD,2CAAyD;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,sBAAsB,GAAG,CACpC,QAA6B,EAC7B,UAA0B,EACF,EAAE;IAC1B,MAAM,GAAG,GAA2B,EAAE,CAAC;IAEvC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,EAAE,CAAC;QAC9C,IAAI,IAAA,oCAAyB,EAAC,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CACV,oDAAoD,GAAG,mBAAmB;gBACxE,wEAAwE;gBACxE,qBAAqB,CACxB,CAAC;YACF,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QACpD,GAAG,CAAC,GAAG,CAAC;YACN,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;gBAClF,CAAC,CAAC,IAAA,sCAA0B,EAAC,KAAK,CAAC;gBACnC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,kBAAkB;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAA0B,EAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AA7BW,QAAA,sBAAsB,0BA6BjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { UserProperties, UserPropertyPatch, UserPropertyValue } from "./types";
|
|
2
|
+
export { RESERVED_USER_PROPERTY_KEYS, isReservedUserPropertyKey } from "./reserved";
|
|
3
|
+
export type { ReservedUserPropertyKey } from "./reserved";
|
|
4
|
+
export { serializeUserPropertyValue, toQueryParams, paramsHash } from "./serialize";
|
|
5
|
+
export { applyUserPropertyPatch } from "./applyPatch";
|
|
6
|
+
export { createUserPropertyStore, USER_PROPERTIES_STORAGE_KEY } from "./store";
|
|
7
|
+
export type { UserPropertySnapshot, UserPropertyStorage, UserPropertyStore } from "./store";
|
|
8
|
+
export { useUserProperties } from "./useUserProperties";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/userProperties/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACpF,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUserProperties = exports.USER_PROPERTIES_STORAGE_KEY = exports.createUserPropertyStore = exports.applyUserPropertyPatch = exports.paramsHash = exports.toQueryParams = exports.serializeUserPropertyValue = exports.isReservedUserPropertyKey = exports.RESERVED_USER_PROPERTY_KEYS = void 0;
|
|
4
|
+
var reserved_1 = require("./reserved");
|
|
5
|
+
Object.defineProperty(exports, "RESERVED_USER_PROPERTY_KEYS", { enumerable: true, get: function () { return reserved_1.RESERVED_USER_PROPERTY_KEYS; } });
|
|
6
|
+
Object.defineProperty(exports, "isReservedUserPropertyKey", { enumerable: true, get: function () { return reserved_1.isReservedUserPropertyKey; } });
|
|
7
|
+
var serialize_1 = require("./serialize");
|
|
8
|
+
Object.defineProperty(exports, "serializeUserPropertyValue", { enumerable: true, get: function () { return serialize_1.serializeUserPropertyValue; } });
|
|
9
|
+
Object.defineProperty(exports, "toQueryParams", { enumerable: true, get: function () { return serialize_1.toQueryParams; } });
|
|
10
|
+
Object.defineProperty(exports, "paramsHash", { enumerable: true, get: function () { return serialize_1.paramsHash; } });
|
|
11
|
+
var applyPatch_1 = require("./applyPatch");
|
|
12
|
+
Object.defineProperty(exports, "applyUserPropertyPatch", { enumerable: true, get: function () { return applyPatch_1.applyUserPropertyPatch; } });
|
|
13
|
+
// `userPropertyStore` — the process-wide instance — is deliberately NOT
|
|
14
|
+
// re-exported for hosts: `OnboardingStudio` is the front door. It is imported
|
|
15
|
+
// directly by `OnboardingStudio.ts` and `useUserProperties.ts`.
|
|
16
|
+
var store_1 = require("./store");
|
|
17
|
+
Object.defineProperty(exports, "createUserPropertyStore", { enumerable: true, get: function () { return store_1.createUserPropertyStore; } });
|
|
18
|
+
Object.defineProperty(exports, "USER_PROPERTIES_STORAGE_KEY", { enumerable: true, get: function () { return store_1.USER_PROPERTIES_STORAGE_KEY; } });
|
|
19
|
+
var useUserProperties_1 = require("./useUserProperties");
|
|
20
|
+
Object.defineProperty(exports, "useUserProperties", { enumerable: true, get: function () { return useUserProperties_1.useUserProperties; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/userProperties/index.ts"],"names":[],"mappings":";;;AACA,uCAAoF;AAA3E,uHAAA,2BAA2B,OAAA;AAAE,qHAAA,yBAAyB,OAAA;AAE/D,yCAAoF;AAA3E,uHAAA,0BAA0B,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAC9D,2CAAsD;AAA7C,oHAAA,sBAAsB,OAAA;AAC/B,wEAAwE;AACxE,8EAA8E;AAC9E,gEAAgE;AAChE,iCAA+E;AAAtE,gHAAA,uBAAuB,OAAA;AAAE,oHAAA,2BAA2B,OAAA;AAE7D,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Property names a host may NOT use, because `OnboardingStudioClient` puts them
|
|
3
|
+
* on the querystring itself.
|
|
4
|
+
*
|
|
5
|
+
* Two of them — `moment` and `now` — mirror the server's own
|
|
6
|
+
* `RESERVED_AUDIENCE_VARS`, which strips them because they are server-owned (a
|
|
7
|
+
* client supplying `now` is self-selecting into a time-gated audience).
|
|
8
|
+
*
|
|
9
|
+
* The other six close a collision that is live today and merely unreachable,
|
|
10
|
+
* because nobody hand-writes these names into `customAudienceParams`. The
|
|
11
|
+
* client appends user params FIRST, then its own:
|
|
12
|
+
*
|
|
13
|
+
* Object.entries(userDefinedParams).forEach(([k, v]) => urlParams.append(k, v));
|
|
14
|
+
* urlParams.append("projectId", this.projectId);
|
|
15
|
+
*
|
|
16
|
+
* `URLSearchParams.append` permits duplicates, and the two server-side readers
|
|
17
|
+
* disagree about which one wins: `url.searchParams.get("projectId")` returns the
|
|
18
|
+
* FIRST occurrence (the user's value — so the request resolves the wrong
|
|
19
|
+
* project, or 400s), while `Object.fromEntries(...)` is last-wins (so the
|
|
20
|
+
* json-logic data still holds the real one). The result is a failed or
|
|
21
|
+
* cross-project request with no diagnostic pointing at the property that caused
|
|
22
|
+
* it.
|
|
23
|
+
*
|
|
24
|
+
* A store whose whole purpose is to let a host name keys freely makes that a
|
|
25
|
+
* plausible accident, so this is where it gets refused. Refusing — rather than
|
|
26
|
+
* prefixing or escaping — keeps the wire format unchanged and puts the warning
|
|
27
|
+
* at the call site responsible.
|
|
28
|
+
*/
|
|
29
|
+
export declare const RESERVED_USER_PROPERTY_KEYS: readonly ["projectId", "platform", "appVersion", "draft", "locale", "omitNulls", "moment", "now"];
|
|
30
|
+
export type ReservedUserPropertyKey = (typeof RESERVED_USER_PROPERTY_KEYS)[number];
|
|
31
|
+
/** Exact match, never a prefix — `projectIdentifier` is a perfectly good property. */
|
|
32
|
+
export declare const isReservedUserPropertyKey: (key: string) => boolean;
|
|
33
|
+
//# sourceMappingURL=reserved.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/userProperties/reserved.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,mGAS9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnF,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,GAAI,KAAK,MAAM,KAAG,OACU,CAAC"}
|