@wix/himalaya-cli 0.1320.0 → 0.1322.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.
Files changed (64) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +1 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/biometrics/src/index.d.ts +11 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/catalog-pricing-contract.d.ts +4 -0
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/host-session.d.ts +4 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/index.d.ts +13 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/mapping-source.d.ts +8 -3
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments.d.ts +5 -4
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/webview/src/index.d.ts +4 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/webview-page/src/index.d.ts +16 -1
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/tokens.d.ts +9 -1
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/apple-iap-contract.d.ts +5 -0
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/apple-iap-core.d.ts +3 -1
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/checkout-source.d.ts +4 -0
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/commerce-contract.d.ts +83 -0
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/commerce-core.d.ts +36 -0
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/commerce.d.ts +8 -0
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/index.d.ts +3 -0
  20. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/purchase-fields.d.ts +4 -0
  21. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/display.d.ts +21 -0
  22. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  23. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  24. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  25. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
  26. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +1205 -71
  27. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +125 -13
  28. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  29. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -1
  30. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  31. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  32. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +1 -0
  33. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  34. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/webview-page.mjs +78 -0
  35. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/webview.mjs +16 -0
  36. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-stores.mjs +13 -4
  37. package/dist/cli.mjs +87 -23
  38. package/dist/preview-assets.generated.bin +0 -0
  39. package/guides/getting-started.md +4 -2
  40. package/guides/himi-skill.md +4 -2
  41. package/guides/iap-pricing.md +33 -26
  42. package/guides/index.json +2 -1
  43. package/guides/sdk-reference.json +50 -8
  44. package/guides/tokens.md +22 -1
  45. package/guides/web-page-native-sdk.md +154 -33
  46. package/guides/webview-page-sdk.md +11 -0
  47. package/package.json +2 -2
  48. package/templates/beauty-salon/dev/index.ts +492 -0
  49. package/templates/beauty-salon/tier5-src/wix-spaces-collection-detail/index.ts +146 -30
  50. package/templates/branded-lite/dev/index.ts +533 -0
  51. package/templates/branded-lite/tier5-src/_shared/iap-worker.ts +21 -44
  52. package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +77 -47
  53. package/templates/branded-lite/tier5-src/himi-branded-lite-programs/index.ts +24 -38
  54. package/templates/branded-lite/tier5-src/wix-spaces-collection-detail/index.ts +146 -30
  55. package/templates/gym-fitness/dev/index.ts +492 -0
  56. package/templates/gym-fitness/tier5-src/wix-spaces-collection-detail/index.ts +146 -30
  57. package/templates/portfolio-creative/dev/index.ts +492 -0
  58. package/templates/portfolio-creative/tier5-src/wix-spaces-collection-detail/index.ts +146 -30
  59. package/templates/retail-store/dev/index.ts +492 -0
  60. package/templates/retail-store/tier5-src/wix-spaces-collection-detail/index.ts +146 -30
  61. package/templates/yoga-studio/dev/index.ts +41 -0
  62. package/templates/yoga-studio/tier5-src/_shared/iap-worker.ts +21 -44
  63. package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +77 -47
  64. package/templates/yoga-studio/tier5-src/himi-branded-lite-programs/index.ts +24 -38
@@ -84,6 +84,7 @@ export interface NavigationConfig {
84
84
  iapConfig?: import("@wix/himalaya/core").IapConfig;
85
85
  cashierConfig?: import("@wix/himalaya/core").CashierConfig;
86
86
  base44Config?: import("@wix/himalaya/core").Base44Config;
87
+ wixIapConfig?: import("@wix/himalaya/core").WixIapConfig;
87
88
  wixPlatformConfig?: WixPlatformConfig;
88
89
  devGatewayConfig?: DevGatewayConfig;
89
90
  dataSchema?: import("@wix/himalaya/core").DataSchemaConfig;
@@ -258,6 +258,9 @@ export interface DerivedAppMeta {
258
258
  * `@himalaya/base44` talks to; the web host reads it, native boots install it). Public ids
259
259
  * only — the access token never leaves the device. */
260
260
  base44?: import("@wix/himalaya/core").Base44Config;
261
+ /** Forwarded from AppConfig.wixIap — feeds the served `wixIapConfig`, which serve-control
262
+ * projects into the dist contract's `native.iapBinding` (baked at build time, never OTA-read). */
263
+ wixIap?: import("@wix/himalaya/core").WixIapConfig;
261
264
  /** Forwarded from AppConfig.wixPlatform — feeds the OTA `wixPlatformConfig`
262
265
  * block (RFC 0042 Phase 2 per-member productionization; read natively by
263
266
  * WixPlatformCapability at boot, like iapConfig). */
@@ -7,7 +7,17 @@ export interface ConfirmOptions {
7
7
  /** Optional fallback button label (e.g. "Use passcode"). */
8
8
  fallbackLabel?: string;
9
9
  }
10
- export type BiometricKind = "face" | "fingerprint" | "iris" | "none";
10
+ /**
11
+ * The enrolled biometric, as far as the platform can tell:
12
+ * - `"face"` / `"fingerprint"` / `"iris"` — that modality.
13
+ * - `"biometric"` — a biometric is enrolled but the platform can't say which
14
+ * (Android phones with both face and fingerprint hardware; the web). Label
15
+ * the unlock neutrally ("Use biometrics") rather than guessing a modality.
16
+ * - `"none"` — nothing enrolled, or no hardware.
17
+ *
18
+ * Additive: treat any value you don't recognise like `"biometric"`.
19
+ */
20
+ export type BiometricKind = "face" | "fingerprint" | "iris" | "biometric" | "none";
11
21
  /** Returns the kind of biometric the device supports. `"none"` if the user
12
22
  * has not enrolled or hardware is missing. */
13
23
  export declare function available(): Promise<BiometricKind>;
@@ -49,6 +49,10 @@ export interface IapCheckoutDecision {
49
49
  /** A deployed Wix→Apple mapping backend. Never supplied by a screen. */
50
50
  export interface IapMappingSource {
51
51
  mapping: PricingMappingProvider;
52
+ /** Whether this app sells through the App Store at all — the binary carries a purchases-app binding.
53
+ * When it answers false, every item reads `disabled` with no lookup, exactly as with no source, so the
54
+ * screen's own commerce applies; asked again on every load. Absent means always active. */
55
+ active?(): Promise<boolean>;
52
56
  /** The site this backend serves, used when the caller passes no site. */
53
57
  siteId?: string;
54
58
  }
@@ -11,6 +11,10 @@ export interface HostSessionView extends SessionSnapshot {
11
11
  export interface HostIdentitySource {
12
12
  readonly identityBound: boolean;
13
13
  identity(session: SessionSnapshot): HostCallExpectation | null;
14
+ /** The site the native bridge fences protected calls to, from the latest ready snapshot. Null
15
+ * when the host installed no session source: iOS publishes the bridge (`identityBound`) to
16
+ * every worker that has `wix_api`, with or without one. */
17
+ site(): string | null;
14
18
  }
15
19
  export interface HostSessionProvider extends SessionProvider, HostIdentitySource {
16
20
  }
@@ -1,4 +1,5 @@
1
1
  import type { TransactionStore } from "./delivery-contract.js";
2
+ import type { AppBindingSource } from "./wix-payments-contract.js";
2
3
  export * from "./delivery-contract.js";
3
4
  export * from "./delivery.js";
4
5
  export * from "./pricing-contract.js";
@@ -146,3 +147,15 @@ export declare function finishTransaction(input: {
146
147
  }): Promise<FinishTransactionResult>;
147
148
  /** The managed native verbs as the delivery coordinator's store. */
148
149
  export declare const appleManagedStore: TransactionStore;
150
+ /** The purchases-service binding the host baked into this binary at build time (the app's build
151
+ * contract → Info.plist), checked natively against the running bundle, app and site. Never read
152
+ * from a screen, OTA config or navigation param: a worker cannot choose which purchases app it
153
+ * sells through. Null means not provisioned: an unbound build, an older binary without the verb,
154
+ * or a platform with no managed App Store purchasing. A host that has the verb and fails to answer
155
+ * proves neither, so that read rejects and is not kept: the caller must not fall back to the
156
+ * unbound app's commerce. The binding cannot change while the process runs, so a source asks the
157
+ * host once. */
158
+ export declare function hostAppBindingSource(): AppBindingSource;
159
+ /** One binding source per worker, shared by pricing and checkout, so one screen never acts on two
160
+ * different answers to the same question. */
161
+ export declare function sharedHostAppBindingSource(): AppBindingSource;
@@ -1,5 +1,10 @@
1
1
  import type { IapMappingSource } from "./catalog-pricing-contract.js";
2
- /** The single activation switch for catalog pricing. No Wix→Apple mapping backend is deployed,
3
- * so every screen stays on its existing commerce flow. Only automated tests substitute this module
4
- * (at bundle-build time); the backend adapter replaces it when it exists. */
2
+ import { type AppBindingSource } from "./wix-payments-contract.js";
3
+ export type WixBridgeCall = (method: string, path: string, body: unknown, headers?: Record<string, string>) => Promise<unknown>;
4
+ export interface WixIapMappingSourceDependencies {
5
+ binding: AppBindingSource;
6
+ call: WixBridgeCall;
7
+ }
8
+ /** The connected source. Tests substitute this module at bundle-build time (`mappingSourceSeam`). */
5
9
  export declare function iapMappingSource(): IapMappingSource | undefined;
10
+ export declare function createWixIapMappingSource(deps: WixIapMappingSourceDependencies): IapMappingSource;
@@ -30,15 +30,16 @@ export interface WixIapClient {
30
30
  * Creates a client for Wix's in-app-purchase payments service (`mobile-apps-wix-iap`), which pays
31
31
  * a Wix order with a store purchase the member makes in the app.
32
32
  *
33
- * NOT ENABLED and not production-ready. No app wires it, and no call reaches the service: it has
34
- * no public gateway route yet, so `route` must be supplied and there is no default. It calls
33
+ * The shared checkout (`createIapCommerce`) builds it with Serve's IAP route for an app whose binary
34
+ * carries a purchases-app binding; `route` stays a parameter with no default. It calls
35
35
  * StartPayment (`POST …/payments/start`), CompletePayment (`POST …/payments/complete`)
36
36
  * and GetPayment (`GET …/payments/{id}`) through the
37
37
  * `wix_api` bridge. A matched or approved Payment is not durable access and never finishes the
38
38
  * store transaction.
39
39
  *
40
- * Production use stays blocked: there is no public route or member authorization on the service,
41
- * no trusted app-binding source, and checkout stays disabled. When this client uses the host
40
+ * A sale needs the binding baked into the binary and an active mapping for the item; without them
41
+ * nothing is offered, and before a production Serve release carries the IAP routes the mapping read
42
+ * fails, so nothing is offered either. When this client uses the host
42
43
  * bridge, it also requires the host's identity clock and passes that captured expectation
43
44
  * through the bridge. An injected transport keeps the previous call shape unless the session
44
45
  * itself exposes an identity.
@@ -16,7 +16,7 @@ export declare const CAPABILITY_REGISTRY: {
16
16
  readonly haptic: readonly ["play"];
17
17
  readonly health: readonly ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"];
18
18
  readonly himi_apps: readonly ["canOpen", "current", "hostInfo", "open"];
19
- readonly iap: readonly ["consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"];
19
+ readonly iap: readonly ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"];
20
20
  readonly keyboard: readonly ["dismiss"];
21
21
  readonly live_activity: readonly ["end", "start", "update"];
22
22
  readonly local_database: readonly ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"];
@@ -28,6 +28,10 @@ export interface PageCapabilityResponse {
28
28
  code?: string;
29
29
  };
30
30
  }
31
+ /** `call("himalaya", "capabilities")` answers `{ v: 1, capabilities: { <id>: [<method>…] } }`:
32
+ * exactly the allowlist this worker was given. Reserved, so no real capability can take it. */
33
+ export declare const PAGE_HANDSHAKE_CAPABILITY = "himalaya";
34
+ export declare const PAGE_HANDSHAKE_METHOD = "capabilities";
31
35
  export interface ExposedPageCapability {
32
36
  module: Record<string, unknown>;
33
37
  methods: readonly string[];
@@ -18,8 +18,23 @@ export interface WebViewPageResponse {
18
18
  result?: unknown;
19
19
  error?: WebViewPageError;
20
20
  }
21
- /** Invoke one method through the companion worker. Primarily useful to generated bindings. */
21
+ /** Invoke one method through the companion worker. Primarily useful to generated bindings.
22
+ * A call that shows native UI (a permission prompt, the share sheet) answers only when the user
23
+ * is done with it: pass a long `timeoutMs` (e.g. 120_000) rather than the 30-second default. */
22
24
  export declare function call<T>(capability: string, method: string, args?: unknown[], timeoutMs?: number): Promise<T>;
25
+ /**
26
+ * The capabilities and methods this page's companion worker answers, as `{ <id>: [<method>…] }`;
27
+ * `null` outside the app, when the app is older than the handshake, or nothing answered in
28
+ * `timeoutMs`. A list is remembered (and returned at once, whatever `timeoutMs`); a miss is not,
29
+ * because a worker that is still booting drops the first messages.
30
+ */
31
+ export declare function enabledCapabilities(timeoutMs?: number): Promise<Record<string, string[]> | null>;
32
+ /** Whether the companion worker lets this page call `capability.method`, read from
33
+ * enabledCapabilities() — nothing is called. `false` when there is no list. */
34
+ export declare function isEnabled(capability: string, method: string, timeoutMs?: number): Promise<boolean>;
35
+ /** For an app older than the handshake: CALL `capability.method` and report whether it answered
36
+ * (even with an error). It runs the method, so pass only a read-only one. */
37
+ export declare function probe(capability: string, method: string, args?: unknown[], timeoutMs?: number): Promise<boolean>;
23
38
  /**
24
39
  * Typed SDK proxy for every request/response capability in CAPABILITY_REGISTRY.
25
40
  * A namespace is usable only when this screen's companion worker explicitly imported and
@@ -65,8 +65,12 @@ export type DeepPartial<T> = T extends readonly (infer U)[] ? readonly DeepParti
65
65
  * Not overlayable: `contentMaxWidth` (a Projection concern that RFC 0041 size classes own),
66
66
  * `fontFaces` (the served font declaration, derived rather than authored) and `idiom` itself.
67
67
  * Nor a brand colour (`BRAND_COLOR_TOKENS`, #2932): one brand reads as one brand everywhere.
68
+ * Nor the owner's `kit.colorScheme` light/dark pin: every runtime reads it from the base `kit`
69
+ * only, so an overlay pin would compile and do nothing (`himi validate` warns on one too).
68
70
  */
69
- export type IdiomOverlay = DeepPartial<Omit<DesignTokens, "idiom" | "idiomPolicy" | "contentMaxWidth" | "fontFaces">>;
71
+ export type IdiomOverlay = DeepPartial<Omit<DesignTokens, "idiom" | "idiomPolicy" | "contentMaxWidth" | "fontFaces" | "kit"> & {
72
+ kit?: Omit<KitBlock, "colorScheme">;
73
+ }>;
70
74
  /**
71
75
  * One face in a font declaration.
72
76
  *
@@ -122,6 +126,10 @@ export interface KitBlock {
122
126
  variant?: string;
123
127
  density?: string;
124
128
  motion?: string;
129
+ /** The owner's light/dark pin, shipped OTA. "system" (or absent) follows the device; a host
130
+ * override and the OS high-contrast setting still win over it. Read from this top-level
131
+ * block only — an idiom overlay cannot set it. Mirror of iOS/Android `KitBlock.colorScheme`. */
132
+ colorScheme?: "system" | "light" | "dark";
125
133
  }
126
134
  /** RFC 0021 (bottom-nav extension) — kit-driven tab bar styling. All fields
127
135
  * optional; a kit omitting `tabBar` falls back to the flat default bar. */
@@ -87,6 +87,9 @@ export interface IapOrderAdapter {
87
87
  }, bridge: SessionBoundBridge): Promise<OrderAttempt>;
88
88
  /** The vertical's authoritative answer for the order's item and the signed-in member. */
89
89
  readAccess(verticalRef: VerticalRef, bridge: SessionBoundBridge): Promise<AccessRead>;
90
+ /** The member's access to an item before any order exists (bought through Wix, say). Read-only:
91
+ * never opens or prepares an order. An adapter without it shows Get access until a sale says otherwise. */
92
+ currentAccess?(item: IapOrderItem, bridge: SessionBoundBridge): Promise<AccessRead>;
90
93
  }
91
94
  /** Durable, member-partitioned purchase references. Ids only: never a proof or a credential, and
92
95
  * the member id is stored only as a one-way hash in the key. */
@@ -178,6 +181,8 @@ export interface AppleIapCheckout {
178
181
  /** Recovers held purchases and resumes tracking payments already handed over. */
179
182
  start(): Promise<AppleIapCheckoutState>;
180
183
  buy(item: IapOrderItem): Promise<AppleIapCheckoutState>;
184
+ /** Marks the items the signed-in member already has access to, read from each vertical without an order. */
185
+ checkAccess(items: readonly IapOrderItem[]): Promise<AppleIapCheckoutState>;
181
186
  reconcile(): Promise<AppleIapCheckoutState>;
182
187
  retry(): Promise<AppleIapCheckoutState>;
183
188
  tick(): Promise<AppleIapCheckoutState>;
@@ -1,4 +1,6 @@
1
- import type { AppleIapCheckout, AppleIapCheckoutDependencies } from "./apple-iap-contract.js";
1
+ import type { AppleIapCheckout, AppleIapCheckoutDependencies, AppleIapCheckoutState } from "./apple-iap-contract.js";
2
2
  export declare function createAppleIapCheckoutWith(deps: AppleIapCheckoutDependencies & {
3
3
  enabled: boolean;
4
4
  }): AppleIapCheckout;
5
+ /** What a checkout that is not enabled answers: nothing sold, nothing tracked. */
6
+ export declare function notEnabledState(): AppleIapCheckoutState;
@@ -1 +1,5 @@
1
+ import type { AppleIapCheckoutRoutes } from "./commerce-contract.js";
2
+ export declare const HIMALAYA_SERVE_CHECKOUT_ROUTES: AppleIapCheckoutRoutes;
3
+ export declare function appleIapCheckoutRoutes(): AppleIapCheckoutRoutes | null;
4
+ /** The low-level factory's switch: on whenever the production routes exist. */
1
5
  export declare function appleIapCheckoutEnabled(): boolean;
@@ -0,0 +1,83 @@
1
+ import type { CatalogReference, IapCatalogItem, IapCatalogPricing, IapPollDirective, WixIapRoute } from "@wix/himalaya/iap";
2
+ import type { AppleIapCheckoutState, CashierRoute, IapOrderAdapter, IapOrderItem } from "./apple-iap-contract.js";
3
+ /** Where the checkout reaches Wix: mobile-apps-wix-iap's Payments service and cashier pay v2, both
4
+ * as gateway paths the member credential is accepted on. Platform configuration, never a screen's. */
5
+ export interface AppleIapCheckoutRoutes {
6
+ wixIap: WixIapRoute;
7
+ cashier: CashierRoute;
8
+ }
9
+ /** A dependency purchasing needs that this app or host does not have yet. Internal diagnostics:
10
+ * never customer copy.
11
+ * - `routes`: no member-callable wix-iap or cashier route is configured.
12
+ * - `mapping`: no Wix→Apple mapping source is connected.
13
+ * - `binding`: the binary carries no purchases-app binding for this app.
14
+ * - `nativeIdentity`: the host cannot bind a request to the signed-in member.
15
+ * - `managedStore`: managed StoreKit is not enabled on this host (or not iOS).
16
+ * - `storage`: purchase references cannot be stored durably. */
17
+ export type IapPurchaseGap = "routes" | "mapping" | "binding" | "nativeIdentity" | "managedStore" | "storage";
18
+ export type IapPurchaseReadiness = {
19
+ status: "checking";
20
+ } | {
21
+ status: "ready";
22
+ } | {
23
+ status: "unavailable";
24
+ gaps: readonly IapPurchaseGap[];
25
+ };
26
+ export interface IapCommerceOptions {
27
+ /** The verticals this screen sells. A screen that only shows prices passes none. */
28
+ adapters?: readonly IapOrderAdapter[];
29
+ /** After any price, readiness or checkout change; a worker republishes its state here. */
30
+ onChange?(): void;
31
+ }
32
+ export interface IapCommerce {
33
+ /** Routes, display prices, regular-checkout guards and the visible-refresh poll. */
34
+ readonly pricing: IapCatalogPricing;
35
+ /** Prices the items the screen shows, scoped to this app by the host. `scopeComplete` is false
36
+ * when the host's own identity could not be read, so the screen offers Retry itself. */
37
+ loadPrices(items: IapCatalogItem[]): Promise<{
38
+ scopeComplete: boolean;
39
+ }>;
40
+ readiness(): IapPurchaseReadiness;
41
+ /** Whether the latest price load (the screen's or the poll's) had the host's own identity; when
42
+ * false the screen offers Retry itself. */
43
+ scopeComplete(): boolean;
44
+ state(): AppleIapCheckoutState;
45
+ /** The item's App Store action, from its price route (the settled one while a refresh resolves),
46
+ * purchase readiness and the checkout state. */
47
+ purchaseFields(reference: CatalogReference, copy: IapPurchaseCopy): IapPurchaseFields;
48
+ /** Checks readiness, then recovers held purchases and resumes payments already handed over. */
49
+ start(): Promise<AppleIapCheckoutState>;
50
+ buy(item: IapOrderItem): Promise<AppleIapCheckoutState>;
51
+ /** On resume: re-reads Apple's unfinished queue and the payments being tracked. */
52
+ reconcile(): Promise<AppleIapCheckoutState>;
53
+ tick(): Promise<AppleIapCheckoutState>;
54
+ /** The screen's one `_poll` for prices and purchase, or undefined when the cadence it already
55
+ * armed still holds (or there is nothing to poll). Emit it from every publish. */
56
+ pollDirective(action: string): IapPollDirective | undefined;
57
+ /** The polled action's body: due purchase work — a full reconcile when the host had suspended
58
+ * the poll (background, a pooled screen) — and the price refresh at its own cadence. */
59
+ poll(): Promise<void>;
60
+ dispose(): void;
61
+ }
62
+ /** Labels from the screen's copy pack; the shared layer only chooses between them. */
63
+ export interface IapPurchaseCopy {
64
+ buy: string;
65
+ processing: string;
66
+ awaitingApproval: string;
67
+ unavailable: string;
68
+ signInRequired: string;
69
+ retry: string;
70
+ priceChanged: string;
71
+ support: string;
72
+ }
73
+ /** What a screen binds for an item's App Store purchase action. */
74
+ export interface IapPurchaseFields {
75
+ /** The item sells through the App Store: show this action instead of the regular one. */
76
+ appleRoute: boolean;
77
+ /** The vertical confirmed the member's access: open the content instead of selling it. */
78
+ accessReady: boolean;
79
+ buyLabel: string;
80
+ buyDisabled: boolean;
81
+ buyBusy: boolean;
82
+ buyNote: string;
83
+ }
@@ -0,0 +1,36 @@
1
+ import type { MemberIdentitySource, AppBindingSource, Clock, HostIdentitySource, IapAppHost, IapCatalogPricing, SessionProvider, TransactionStore, WixIapClient, WixIapRoute } from "@wix/himalaya/iap";
2
+ import type { IapOrderAdapter, OrderRefStore, WixBridge } from "./apple-iap-contract.js";
3
+ import type { AppleIapCheckoutRoutes, IapCommerce } from "./commerce-contract.js";
4
+ export interface HostIdentity {
5
+ appId: string;
6
+ bundleId: string;
7
+ platform: string;
8
+ }
9
+ export interface CommerceHost {
10
+ /** The running app's identity and platform; null when the host could not say. */
11
+ identity(): Promise<HostIdentity | null>;
12
+ /** The host's preference business, the price scope of an app with no binding. */
13
+ preferenceSite(): string;
14
+ }
15
+ export interface IapCommerceDependencies {
16
+ routes: AppleIapCheckoutRoutes | null;
17
+ pricing: IapCatalogPricing;
18
+ binding: AppBindingSource;
19
+ /** One provider for the wix-iap client and the checkout: every step compares its generations. */
20
+ session: SessionProvider & Partial<HostIdentitySource>;
21
+ /** The member a captured session names (D61: wix-iap records purchases against the member id). */
22
+ identity: MemberIdentitySource;
23
+ host: CommerceHost;
24
+ store: TransactionStore;
25
+ refs: OrderRefStore;
26
+ clock: Clock;
27
+ adapters: readonly IapOrderAdapter[];
28
+ bridge?: WixBridge;
29
+ wixIapClient(config: {
30
+ host: IapAppHost;
31
+ route: WixIapRoute;
32
+ }): WixIapClient;
33
+ jitter?: (baseDelayMs: number) => number;
34
+ onChange?(): void;
35
+ }
36
+ export declare function createIapCommerceWith(deps: IapCommerceDependencies): IapCommerce;
@@ -0,0 +1,8 @@
1
+ import type { IapCommerce, IapCommerceOptions } from "./commerce-contract.js";
2
+ /**
3
+ * Creates this worker's App Store commerce: catalog pricing for the items the screen shows, and the
4
+ * shared Apple-IAP checkout for the verticals it sells. Create it once at module scope, call
5
+ * `start()` when the screen boots, `reconcile()` when it resumes, and `tick()` from a `_poll` at
6
+ * `state().nextWakeAt`. Bind the action with `iapPurchaseFields`.
7
+ */
8
+ export declare function createIapCommerce(options?: IapCommerceOptions): IapCommerce;
@@ -1,4 +1,7 @@
1
+ export { createIapCommerce } from "./commerce.js";
2
+ export { iapPurchaseFields } from "./purchase-fields.js";
1
3
  export { createAppleIapCheckout } from "./apple-iap.js";
2
4
  export { onlineProgramOrders, pricingPlanOrders, storesProductOrders, classifyCart } from "./iap-verticals/index.js";
3
5
  export { createWorkerOrderRefStore } from "./order-refs.js";
4
6
  export type { AccessRead, AppleIapCheckout, AppleIapCheckoutDependencies, AppleIapCheckoutPhase, AppleIapCheckoutState, BridgeOutcome, BridgeRefusal, CashierRoute, IapEligibility, IapOrderAdapter, IapOrderItem, OrderAttempt, OrderFailureCode, OrderPartitionKey, OrderRef, OrderRefPartition, OrderRefStage, OrderRefStore, PaymentAccess, PaymentProgress, SessionBoundBridge, VerticalRef, WixBridge, } from "./apple-iap-contract.js";
7
+ export type { AppleIapCheckoutRoutes, IapCommerce, IapCommerceOptions, IapPurchaseCopy, IapPurchaseFields, IapPurchaseGap, IapPurchaseReadiness, } from "./commerce-contract.js";
@@ -0,0 +1,4 @@
1
+ import type { IapItemView } from "@wix/himalaya/iap";
2
+ import type { AppleIapCheckoutState } from "./apple-iap-contract.js";
3
+ import type { IapPurchaseCopy, IapPurchaseFields, IapPurchaseReadiness } from "./commerce-contract.js";
4
+ export declare function iapPurchaseFields(view: IapItemView, state: AppleIapCheckoutState, readiness: IapPurchaseReadiness, copy: IapPurchaseCopy): IapPurchaseFields;
@@ -106,11 +106,32 @@ export interface StoreProductSearch {
106
106
  query?: string;
107
107
  sort?: 'default' | 'az' | 'za';
108
108
  ids?: string[];
109
+ /**
110
+ * Only products in this category (V3) / collection (V1) — a category screen's
111
+ * "products in X". ANDed with `ids` when both are given.
112
+ *
113
+ * V3 matches `allCategoriesInfo.categories`, so a parent category also lists its
114
+ * subcategories' products, as the site does. Only Search Products can filter by
115
+ * category — Query Products answers `not declared as filterable` — so a
116
+ * `categoryId` always routes the V3 read to `/products/search`. V1 matches
117
+ * `collections.id`.
118
+ */
119
+ categoryId?: string;
109
120
  limit?: number;
110
121
  cursor?: string;
111
122
  /** Extra v3 fieldsets. Additive — widens the default, never replaces it. */
112
123
  fields?: readonly string[];
113
124
  }
125
+ /**
126
+ * Search, sort, and filter products on whichever catalog this site runs — the read
127
+ * behind a shop list, a saved-products list, and a category screen.
128
+ *
129
+ * `categoryId` narrows to one category's products (V3 `allCategoriesInfo`, so a parent
130
+ * category includes its subcategories; V1 `collections.id`), ANDed with `ids`. An
131
+ * empty `ids` array resolves to an empty page WITHOUT a request. Paging is one
132
+ * contract on both catalogs: pass back `pagingMetadata.cursors.next` as `cursor`.
133
+ * A non-catalog failure (401/403, offline) rejects; it is never retried on V1.
134
+ */
114
135
  export declare function searchStoreProducts(options?: StoreProductSearch): Promise<StoreProductsResponse>;
115
136
  /** Read one product from whichever catalog this site runs. `fields` is additive —
116
137
  * it WIDENS the default v3 display fieldset rather than replacing it. */
@@ -31,7 +31,7 @@ var CAPABILITY_REGISTRY = {
31
31
  "haptic": ["play"],
32
32
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
33
33
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
34
- "iap": ["consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
34
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
35
35
  "keyboard": ["dismiss"],
36
36
  "live_activity": ["end", "start", "update"],
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
@@ -31,7 +31,7 @@ var CAPABILITY_REGISTRY = {
31
31
  "haptic": ["play"],
32
32
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
33
33
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
34
- "iap": ["consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
34
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
35
35
  "keyboard": ["dismiss"],
36
36
  "live_activity": ["end", "start", "update"],
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
@@ -31,7 +31,7 @@ var CAPABILITY_REGISTRY = {
31
31
  "haptic": ["play"],
32
32
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
33
33
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
34
- "iap": ["consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
34
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
35
35
  "keyboard": ["dismiss"],
36
36
  "live_activity": ["end", "start", "update"],
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
@@ -31,7 +31,7 @@ var CAPABILITY_REGISTRY = {
31
31
  "haptic": ["play"],
32
32
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
33
33
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
34
- "iap": ["consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
34
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore"],
35
35
  "keyboard": ["dismiss"],
36
36
  "live_activity": ["end", "start", "update"],
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],