@wix/himalaya-cli 0.1324.0 → 0.1325.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/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/checkout/src/index.d.ts +6 -10
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/order-refs.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/purchase-fields.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +9 -35
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/display.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/checkout.mjs +30 -13
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +20 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +2890 -54
- package/dist/cli.mjs +4 -4
- package/fixtures/wix-canned.json +61 -6
- package/guides/iap-pricing.md +9 -0
- package/guides/iap-screen-adoption.md +77 -0
- package/guides/importable-sdks.md +2 -0
- package/guides/index.json +6 -0
- package/guides/sdk-reference.json +339 -1
- package/package.json +2 -2
- package/templates/beauty-salon/config.ts +1 -1
- package/templates/beauty-salon/dev/index.ts +46 -18
- package/templates/beauty-salon/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/beauty-salon/tier5-src/_shared/himi-store-collection.ts +1 -1
- package/templates/beauty-salon/tier5-src/_shared/home-service.ts +2 -1
- package/templates/beauty-salon/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/beauty-salon/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +48 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/beauty-salon/tier5-src/himi-branded-lite-order/index.ts +24 -3
- package/templates/beauty-salon/tier5-src/himi-branded-lite-plans/index.ts +153 -64
- package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +24 -3
- package/templates/beauty-salon/tier5-src/himi-store-saved/index.ts +8 -3
- package/templates/beauty-salon/tier5-src/himi-store-shop/index.ts +10 -0
- package/templates/beauty-salon/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/beauty-salon-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/branded-lite/config.ts +1 -1
- package/templates/branded-lite/dev/index.ts +46 -18
- package/templates/branded-lite/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/branded-lite/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/branded-lite/tier5-src/_shared/himi-store-collection.ts +1 -1
- package/templates/branded-lite/tier5-src/_shared/home-service.ts +2 -1
- package/templates/branded-lite/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +48 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/branded-lite/tier5-src/himi-branded-lite-order/index.ts +24 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-plans/index.ts +153 -64
- package/templates/branded-lite/tier5-src/himi-store-product/index.ts +24 -3
- package/templates/branded-lite/tier5-src/himi-store-saved/index.ts +8 -3
- package/templates/branded-lite/tier5-src/himi-store-shop/index.ts +10 -0
- package/templates/branded-lite/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
- package/templates/community-club/config.ts +1 -1
- package/templates/community-club/dev/index.ts +3 -1
- package/templates/community-club/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/community-club/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/community-club/tier5-src/_shared/home-service.ts +2 -1
- package/templates/community-club/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/community-club/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/community-club-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/community-club-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/events-meetups/config.ts +1 -1
- package/templates/events-meetups/dev/index.ts +3 -1
- package/templates/events-meetups/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/events-meetups/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/events-meetups/tier5-src/_shared/home-service.ts +2 -1
- package/templates/events-meetups/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/events-meetups/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/events-meetups-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/events-meetups-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/gym-fitness/config.ts +1 -1
- package/templates/gym-fitness/dev/index.ts +46 -18
- package/templates/gym-fitness/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/gym-fitness/tier5-src/_shared/himi-store-collection.ts +1 -1
- package/templates/gym-fitness/tier5-src/_shared/home-service.ts +2 -1
- package/templates/gym-fitness/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/gym-fitness/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +48 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/gym-fitness/tier5-src/himi-branded-lite-order/index.ts +24 -3
- package/templates/gym-fitness/tier5-src/himi-branded-lite-plans/index.ts +153 -64
- package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +24 -3
- package/templates/gym-fitness/tier5-src/himi-store-saved/index.ts +8 -3
- package/templates/gym-fitness/tier5-src/himi-store-shop/index.ts +10 -0
- package/templates/gym-fitness/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/gym-fitness-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/nonprofit-cause/config.ts +1 -1
- package/templates/nonprofit-cause/dev/index.ts +29 -13
- package/templates/nonprofit-cause/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/nonprofit-cause/tier5-src/_shared/home-service.ts +2 -1
- package/templates/nonprofit-cause/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/nonprofit-cause/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-plans/index.ts +153 -64
- package/templates/nonprofit-cause/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/nonprofit-cause-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/owner-lite/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/owner-lite/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/owner-lite/tier5-src/_shared/home-service.ts +2 -1
- package/templates/podcast-creator/config.ts +1 -1
- package/templates/podcast-creator/dev/index.ts +29 -13
- package/templates/podcast-creator/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/podcast-creator/tier5-src/_shared/home-service.ts +2 -1
- package/templates/podcast-creator/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/podcast-creator/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/podcast-creator/tier5-src/himi-branded-lite-plans/index.ts +153 -64
- package/templates/podcast-creator/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/podcast-creator-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/portfolio-creative/config.ts +1 -1
- package/templates/portfolio-creative/dev/index.ts +20 -6
- package/templates/portfolio-creative/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/portfolio-creative/tier5-src/_shared/himi-store-collection.ts +1 -1
- package/templates/portfolio-creative/tier5-src/_shared/home-service.ts +2 -1
- package/templates/portfolio-creative/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/portfolio-creative/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +48 -1
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-order/index.ts +24 -3
- package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +24 -3
- package/templates/portfolio-creative/tier5-src/himi-store-saved/index.ts +8 -3
- package/templates/portfolio-creative/tier5-src/himi-store-shop/index.ts +10 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/portfolio-creative-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/restaurant/config.ts +1 -1
- package/templates/restaurant/dev/index.ts +3 -1
- package/templates/restaurant/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/restaurant/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/restaurant/tier5-src/_shared/home-service.ts +2 -1
- package/templates/restaurant/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/restaurant/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/restaurant-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/restaurant-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/retail-store/config.ts +1 -1
- package/templates/retail-store/dev/index.ts +20 -6
- package/templates/retail-store/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/retail-store/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/retail-store/tier5-src/_shared/himi-store-collection.ts +1 -1
- package/templates/retail-store/tier5-src/_shared/home-service.ts +2 -1
- package/templates/retail-store/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/retail-store/tier5-src/_shared/iap-worker.ts +42 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +48 -1
- package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/retail-store/tier5-src/himi-branded-lite-order/index.ts +24 -3
- package/templates/retail-store/tier5-src/himi-store-product/index.ts +24 -3
- package/templates/retail-store/tier5-src/himi-store-saved/index.ts +8 -3
- package/templates/retail-store/tier5-src/himi-store-shop/index.ts +10 -0
- package/templates/retail-store-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/retail-store-owner/tier5-src/_shared/home-service.ts +2 -1
- package/templates/yoga-studio/config.ts +1 -1
- package/templates/yoga-studio/dev/index.ts +29 -13
- package/templates/yoga-studio/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/yoga-studio/tier5-src/_shared/home-service.ts +2 -1
- package/templates/yoga-studio/tier5-src/_shared/iap-presentation.ts +53 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +16 -2
- package/templates/yoga-studio/tier5-src/himi-branded-lite-plans/index.ts +153 -64
- package/templates/yoga-studio/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-contract.ts +1 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +3 -2
- package/templates/yoga-studio-owner/tier5-src/_shared/home-service.ts +2 -1
|
@@ -11,6 +11,8 @@ export interface Entitlement {
|
|
|
11
11
|
* rather than offering to sell it to them again. "" when not entitled. */
|
|
12
12
|
planId: string;
|
|
13
13
|
}
|
|
14
|
+
/** Active plan ids for one member-scoped catalog scan. An incomplete scan rejects so callers cannot offer a duplicate purchase. */
|
|
15
|
+
export declare function activePlanIds(): Promise<string[]>;
|
|
14
16
|
/**
|
|
15
17
|
* Does the signed-in member hold a plan that grants access right now?
|
|
16
18
|
*
|
|
@@ -23,16 +25,10 @@ export interface Entitlement {
|
|
|
23
25
|
* the wrong (owner) endpoint is so dangerous: the 403 is indistinguishable from
|
|
24
26
|
* an honest "no orders". Use this function and that cannot happen.
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* member collects a `DRAFT` order every time they abandon a checkout. Asking for
|
|
29
|
-
* everything and scanning it means the DRAFTs eventually crowd the single ACTIVE
|
|
30
|
-
* order off the page — and because this function fails closed, that reads as
|
|
31
|
-
* "never paid" and locks a paying member out with no error anywhere. Asking only
|
|
32
|
-
* for ACTIVE makes the page hold nothing but access, so the count of abandoned
|
|
33
|
-
* checkouts cannot decide whether someone gets what they bought.
|
|
28
|
+
* ACTIVE is filtered server-side so abandoned checkouts cannot crowd access
|
|
29
|
+
* off the page. When `planId` is supplied, page until that exact plan is found.
|
|
34
30
|
*/
|
|
35
|
-
export declare function entitlement(): Promise<Entitlement>;
|
|
31
|
+
export declare function entitlement(planId?: string): Promise<Entitlement>;
|
|
36
32
|
/** Shorthand for the common gate. Fails closed, like `entitlement`. */
|
|
37
33
|
export declare function isEntitled(): Promise<boolean>;
|
|
38
34
|
export type PayOutcome =
|
|
@@ -68,7 +64,7 @@ export interface PayRequest {
|
|
|
68
64
|
cashierUrl?: () => Promise<string | undefined>;
|
|
69
65
|
/** Re-read immediately before money moves (the wallet charge, the cashier opening). The caller's
|
|
70
66
|
* own route can change while a rail is being chosen; false stops the flow with nothing charged. */
|
|
71
|
-
mayCharge?: () => boolean
|
|
67
|
+
mayCharge?: () => boolean | Promise<boolean>;
|
|
72
68
|
}
|
|
73
69
|
/**
|
|
74
70
|
* Collect payment through the two sanctioned rails, in order.
|
|
@@ -14,4 +14,5 @@ export declare function pruneExpiredHolds(partition: OrderRefPartition, now: num
|
|
|
14
14
|
/** References one member keeps at once. When full, the oldest reference from before Apple's sheet
|
|
15
15
|
* is evicted; a partition full of handed-over payments refuses new sales instead. */
|
|
16
16
|
export declare const MAX_ORDER_REFS = 16;
|
|
17
|
+
/** Persists unfinished orders per app and member, using the host KV unless storage is supplied. */
|
|
17
18
|
export declare function createWorkerOrderRefStore(storage?: KeyValueStorage): OrderRefStore;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IapItemView } from "@wix/himalaya/iap";
|
|
2
2
|
import type { AppleIapCheckoutState } from "./apple-iap-contract.js";
|
|
3
3
|
import type { IapPurchaseCopy, IapPurchaseFields, IapPurchaseReadiness } from "./commerce-contract.js";
|
|
4
|
+
/** Projects a shared checkout into customer-facing action fields; a price alone never grants access. */
|
|
4
5
|
export declare function iapPurchaseFields(view: IapItemView, state: AppleIapCheckoutState, readiness: IapPurchaseReadiness, copy: IapPurchaseCopy): IapPurchaseFields;
|
|
@@ -126,38 +126,9 @@ export interface PlanRow {
|
|
|
126
126
|
joinedLabel: string;
|
|
127
127
|
/** Per-row CTA, so the template needs no conditional of its own. */
|
|
128
128
|
cta: string;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
isLoading: boolean;
|
|
133
|
-
notLoading: boolean;
|
|
134
|
-
rows: PlanRow[];
|
|
135
|
-
hasRows: boolean;
|
|
136
|
-
noRows: boolean;
|
|
137
|
-
/** Ready, and the site sells nothing. Distinct from `noRows`, which is also
|
|
138
|
-
* true while still loading — showing "no plans" during the first fetch would
|
|
139
|
-
* flash the wrong answer. `hiddenPath` binds a single path, so this decision
|
|
140
|
-
* is made HERE rather than by combining flags in the descriptor. */
|
|
141
|
-
emptyCatalog: boolean;
|
|
142
|
-
notEmptyCatalog: boolean;
|
|
143
|
-
headline: string;
|
|
144
|
-
subhead: string;
|
|
145
|
-
/** Result banner after a join attempt. */
|
|
146
|
-
notice: string;
|
|
147
|
-
noNotice: boolean;
|
|
148
|
-
error: string;
|
|
149
|
-
noError: boolean;
|
|
150
|
-
/** True once the member holds any access-granting plan. */
|
|
151
|
-
entitled: boolean;
|
|
152
|
-
notEntitled: boolean;
|
|
153
|
-
/** True ONLY when the current notice is "you must sign in". Distinct from
|
|
154
|
-
* `noNotice`: a successful join, a cancellation, a handoff and a backend
|
|
155
|
-
* failure all set a notice too, and routing any of those to a sign-in screen
|
|
156
|
-
* sends the member somewhere that cannot help them. Every action sets this
|
|
157
|
-
* explicitly rather than inheriting it, so a stale `true` cannot survive the
|
|
158
|
-
* next attempt. */
|
|
159
|
-
needsSignIn: boolean;
|
|
160
|
-
notNeedsSignIn: boolean;
|
|
129
|
+
appleSupported: boolean;
|
|
130
|
+
joinDisabled: boolean;
|
|
131
|
+
joinNote: string;
|
|
161
132
|
}
|
|
162
133
|
/** Every user-facing string on the paywall. Override any subset. */
|
|
163
134
|
export interface CheckoutCopy {
|
|
@@ -199,11 +170,14 @@ export interface CheckoutServiceOptions {
|
|
|
199
170
|
* const svc = createCheckoutService({ returnTo: "myapp://screen/library" });
|
|
200
171
|
* export default svc; export { svc };
|
|
201
172
|
*/
|
|
202
|
-
export declare function createCheckoutService(opts?: CheckoutServiceOptions): import("@wix/himalaya/state", { with: { "resolution-mode": "import" } }).ServiceHandle<
|
|
203
|
-
|
|
173
|
+
export declare function createCheckoutService(opts?: CheckoutServiceOptions): import("@wix/himalaya/state", { with: { "resolution-mode": "import" } }).ServiceHandle<any> & {
|
|
174
|
+
pricingPublish: () => Promise<any>;
|
|
175
|
+
pricingRefresh: (...args: never[]) => Promise<any>;
|
|
176
|
+
iapPoll: (...args: never[]) => Promise<any>;
|
|
177
|
+
load: (...args: never[]) => Promise<any>;
|
|
204
178
|
join: (input?: {
|
|
205
179
|
id?: string;
|
|
206
|
-
}) => Promise<
|
|
180
|
+
}) => Promise<any>;
|
|
207
181
|
};
|
|
208
182
|
export interface CheckoutScreenOptions {
|
|
209
183
|
/** Where the built worker bundle is served from. */
|
|
@@ -26,6 +26,7 @@ export type WixMediaSlot = string | {
|
|
|
26
26
|
export declare function mediaSlotUrl(value: WixMediaSlot | undefined, size?: WixImageSize | null): string;
|
|
27
27
|
export interface StoreProduct {
|
|
28
28
|
id?: string;
|
|
29
|
+
productType?: string;
|
|
29
30
|
name?: string;
|
|
30
31
|
slug?: string;
|
|
31
32
|
description?: string;
|
|
@@ -104,20 +104,36 @@ function listMyPlanOrders(opts = {}) {
|
|
|
104
104
|
|
|
105
105
|
// ../../stdlib/flows/checkout/src/index.ts
|
|
106
106
|
var GRANTS_ACCESS = "ACTIVE";
|
|
107
|
-
async function
|
|
107
|
+
async function activePlanIds() {
|
|
108
|
+
const ids = /* @__PURE__ */ new Set();
|
|
109
|
+
const pages = /* @__PURE__ */ new Set();
|
|
110
|
+
for (let offset = 0; ; offset += 50) {
|
|
111
|
+
const response = await listMyPlanOrders({ statuses: [GRANTS_ACCESS], limit: 50, offset });
|
|
112
|
+
const orders = response.orders ?? [];
|
|
113
|
+
const signature = JSON.stringify(orders);
|
|
114
|
+
if (pages.has(signature)) throw new Error("Active plan order pagination did not advance.");
|
|
115
|
+
pages.add(signature);
|
|
116
|
+
for (const order of orders) if (order.status === GRANTS_ACCESS && order.planId) ids.add(order.planId);
|
|
117
|
+
if (orders.length < 50) break;
|
|
118
|
+
}
|
|
119
|
+
return [...ids];
|
|
120
|
+
}
|
|
121
|
+
async function entitlement(planId) {
|
|
108
122
|
try {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
const pages = /* @__PURE__ */ new Set();
|
|
124
|
+
for (let offset = 0; ; offset += 50) {
|
|
125
|
+
const res = await listMyPlanOrders({ statuses: [GRANTS_ACCESS], limit: 50, offset });
|
|
126
|
+
const orders = res.orders ?? [];
|
|
127
|
+
const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
|
|
128
|
+
if (orders.length === 50 && pages.has(page)) break;
|
|
129
|
+
pages.add(page);
|
|
130
|
+
const active = orders.find((order) => order.status === GRANTS_ACCESS && (!planId || order.planId === planId));
|
|
131
|
+
if (active) return { entitled: true, planName: active.planName ?? "", planId: active.planId ?? "" };
|
|
132
|
+
if (orders.length < 50) break;
|
|
133
|
+
}
|
|
118
134
|
} catch {
|
|
119
|
-
return { entitled: false, planName: "", planId: "" };
|
|
120
135
|
}
|
|
136
|
+
return { entitled: false, planName: "", planId: "" };
|
|
121
137
|
}
|
|
122
138
|
async function isEntitled() {
|
|
123
139
|
return (await entitlement()).entitled;
|
|
@@ -129,7 +145,7 @@ async function payOrder(req) {
|
|
|
129
145
|
}
|
|
130
146
|
const availability = await isAvailable().catch(() => "unavailable");
|
|
131
147
|
if (availability === "full" && req.snapshotId) {
|
|
132
|
-
if (req.mayCharge?.() === false) return WITHDRAWN;
|
|
148
|
+
if (await req.mayCharge?.() === false) return WITHDRAWN;
|
|
133
149
|
const r = await proceedToPayment({
|
|
134
150
|
appId: req.appId,
|
|
135
151
|
snapshotId: req.snapshotId,
|
|
@@ -150,7 +166,7 @@ async function payOrder(req) {
|
|
|
150
166
|
if (req.cashierUrl) {
|
|
151
167
|
const url = await req.cashierUrl().catch(() => void 0);
|
|
152
168
|
if (url) {
|
|
153
|
-
if (req.mayCharge?.() === false) return WITHDRAWN;
|
|
169
|
+
if (await req.mayCharge?.() === false) return WITHDRAWN;
|
|
154
170
|
const opened = await open(url, "in_app_browser").catch(() => ({ opened: false }));
|
|
155
171
|
if (opened.opened) return { kind: "handoff" };
|
|
156
172
|
}
|
|
@@ -162,6 +178,7 @@ async function payOrder(req) {
|
|
|
162
178
|
}
|
|
163
179
|
export {
|
|
164
180
|
GRANTS_ACCESS,
|
|
181
|
+
activePlanIds,
|
|
165
182
|
entitlement,
|
|
166
183
|
isEntitled,
|
|
167
184
|
payOrder as payCashierOrder,
|
|
@@ -2779,8 +2779,26 @@ var pricingPlanOrders = {
|
|
|
2779
2779
|
eligibility: (item) => singleUnitOf(KIND2, item),
|
|
2780
2780
|
openOrder: openOrder2,
|
|
2781
2781
|
reopenOrder: reopenOrder2,
|
|
2782
|
-
readAccess: readAccess2
|
|
2782
|
+
readAccess: readAccess2,
|
|
2783
|
+
currentAccess: currentAccess2
|
|
2783
2784
|
};
|
|
2785
|
+
async function currentAccess2(item, bridge) {
|
|
2786
|
+
let pending = false;
|
|
2787
|
+
const pages = /* @__PURE__ */ new Set();
|
|
2788
|
+
for (let offset = 0; ; offset += 50) {
|
|
2789
|
+
const answer = await bridge.call("GET", `${MEMBER_ORDERS}?orderStatuses=ACTIVE&orderStatuses=PENDING&orderStatuses=DRAFT&limit=50&offset=${offset}`);
|
|
2790
|
+
if (isRefusal(answer)) return accessRefused(answer);
|
|
2791
|
+
const orders = answer.body?.orders;
|
|
2792
|
+
if (!Array.isArray(orders)) return "unavailable";
|
|
2793
|
+
const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
|
|
2794
|
+
if (orders.length === 50 && pages.has(page)) return "unavailable";
|
|
2795
|
+
pages.add(page);
|
|
2796
|
+
const selected = orders.filter((order) => order.planId === item.reference.id);
|
|
2797
|
+
if (selected.some((order) => order.status === "ACTIVE")) return "granted";
|
|
2798
|
+
pending || (pending = selected.some((order) => order.status === "PENDING" || order.status === "DRAFT"));
|
|
2799
|
+
if (orders.length < 50) return pending ? "pending" : "none";
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2784
2802
|
async function openOrder2(item, bridge) {
|
|
2785
2803
|
const planId = item.reference.id;
|
|
2786
2804
|
const preview = await bridge.call("POST", `${CHECKOUT}/preview-online`, { planId });
|
|
@@ -2805,7 +2823,7 @@ async function readAccess2(verticalRef, bridge) {
|
|
|
2805
2823
|
}
|
|
2806
2824
|
function accessOf2(order) {
|
|
2807
2825
|
if (order.status === "ACTIVE") return "granted";
|
|
2808
|
-
if (order.status === "PENDING") return
|
|
2826
|
+
if (order.status === "PENDING") return "pending";
|
|
2809
2827
|
if (order.status === "DRAFT") return "pending";
|
|
2810
2828
|
return NO_ACCESS.has(String(order.status)) ? "none" : "unavailable";
|
|
2811
2829
|
}
|