@wix/himalaya-cli 0.1142.0 → 0.1144.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 (47) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/delivery-contract.d.ts +104 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/delivery.d.ts +33 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/index.d.ts +5 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +509 -3
  5. package/dist/cli.mjs +31387 -30592
  6. package/dist/preview-assets.generated.bin +0 -0
  7. package/guides/getting-started.md +29 -11
  8. package/guides/himi-skill.md +29 -11
  9. package/guides/sdk-reference.json +132 -0
  10. package/guides/templates.md +33 -0
  11. package/guides/trim-a-template.md +13 -0
  12. package/package.json +2 -2
  13. package/templates/beauty-salon/dev/index.ts +2 -0
  14. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +2 -2
  15. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +7 -1
  16. package/templates/branded-lite/dev/index.ts +3 -1
  17. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +2 -2
  18. package/templates/branded-lite/tier5-src/himi-events-rsvp/index.ts +2 -2
  19. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +7 -1
  20. package/templates/community-club/dev/index.ts +2 -1
  21. package/templates/community-club/tier5-src/himi-events-rsvp/index.ts +2 -2
  22. package/templates/community-club/tier5-src/himi-store-account/index.ts +7 -1
  23. package/templates/events-meetups/dev/index.ts +2 -1
  24. package/templates/events-meetups/tier5-src/himi-events-rsvp/index.ts +2 -2
  25. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +7 -1
  26. package/templates/gym-fitness/dev/index.ts +3 -1
  27. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +2 -2
  28. package/templates/gym-fitness/tier5-src/himi-events-rsvp/index.ts +2 -2
  29. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +7 -1
  30. package/templates/nonprofit-cause/dev/index.ts +2 -1
  31. package/templates/nonprofit-cause/tier5-src/himi-events-rsvp/index.ts +2 -2
  32. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +7 -1
  33. package/templates/podcast-creator/dev/index.ts +2 -1
  34. package/templates/podcast-creator/tier5-src/himi-events-rsvp/index.ts +2 -2
  35. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +7 -1
  36. package/templates/portfolio-creative/dev/index.ts +2 -1
  37. package/templates/portfolio-creative/tier5-src/himi-events-rsvp/index.ts +2 -2
  38. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +7 -1
  39. package/templates/restaurant/dev/index.ts +2 -1
  40. package/templates/restaurant/tier5-src/himi-events-rsvp/index.ts +2 -2
  41. package/templates/restaurant/tier5-src/himi-store-account/index.ts +7 -1
  42. package/templates/retail-store/dev/index.ts +1 -0
  43. package/templates/retail-store/tier5-src/himi-store-account/index.ts +7 -1
  44. package/templates/yoga-studio/dev/index.ts +3 -1
  45. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +2 -2
  46. package/templates/yoga-studio/tier5-src/himi-events-rsvp/index.ts +2 -2
  47. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +7 -1
@@ -0,0 +1,104 @@
1
+ import type { AppleTransaction, FinishTransactionResult, TransactionErrorCode, UnfinishedTransactionsResult, VerificationPurchaseResult } from "./index.js";
2
+ /** Trusted host session snapshot. Not a credential: the backend adapter resolves real
3
+ * credentials from its own authenticated transport, bound to this `generation`. */
4
+ export interface SessionSnapshot {
5
+ /** Changes on every sign-in, sign-out, member or site change. */
6
+ generation: number;
7
+ kind: "member" | "visitor" | "owner" | "signedOut";
8
+ }
9
+ /** Supplied by the host, never by worker UI state. */
10
+ export interface SessionProvider {
11
+ current(): SessionSnapshot;
12
+ /** Called after `current()` changes; returns an unsubscribe function. */
13
+ subscribe(listener: () => void): () => void;
14
+ }
15
+ /** A catalog item resolved by the backend for the captured member. */
16
+ export interface PurchaseContext {
17
+ productId: string;
18
+ /** Canonical UUID the backend associates with this site/member. */
19
+ appAccountToken: string;
20
+ /** Opaque site/member scope the acknowledgement must echo. */
21
+ scopeKey: string;
22
+ }
23
+ /** The current member's association, used to recover purchases without a catalog item. */
24
+ export interface MemberContext {
25
+ appAccountToken: string;
26
+ scopeKey: string;
27
+ }
28
+ export type ContextResult<T> = {
29
+ status: "ok";
30
+ context: T;
31
+ } | {
32
+ status: "authRequired" | "rejected";
33
+ } | {
34
+ status: "retryable";
35
+ retryAfterMs?: number;
36
+ };
37
+ /** Bound to one transaction and scope. Means verification AND durable access persistence
38
+ * completed; an HTTP 2xx, a receipt or a job id is not an acknowledgement. */
39
+ export interface ProcessingAcknowledgement {
40
+ transactionId: string;
41
+ productId: string;
42
+ environment: AppleTransaction["environment"];
43
+ scopeKey: string;
44
+ }
45
+ export type SubmitProofResult = {
46
+ status: "processed" | "alreadyProcessed";
47
+ acknowledgement: ProcessingAcknowledgement;
48
+ } | {
49
+ status: "retryable";
50
+ retryAfterMs?: number;
51
+ } | {
52
+ status: "authRequired" | "ownershipConflict" | "rejected";
53
+ };
54
+ /** PROPOSED backend agreement. Every call carries the session captured when the work
55
+ * started, never whichever session is current when the request is sent. Responses are
56
+ * decoded strictly; anything unrecognised is treated as invalid, never as success. */
57
+ export interface DeliveryBackend {
58
+ getPurchaseContext(session: SessionSnapshot, catalogRef: string): Promise<ContextResult<PurchaseContext>>;
59
+ getMemberContext(session: SessionSnapshot): Promise<ContextResult<MemberContext>>;
60
+ /** Must be idempotent per store/environment/transaction id; delivery is at-least-once. */
61
+ submitProof(session: SessionSnapshot, transaction: AppleTransaction): Promise<SubmitProofResult>;
62
+ }
63
+ /** The three managed verbs; `appleManagedStore` in index.ts is the production binding. */
64
+ export interface TransactionStore {
65
+ purchaseForVerification(input: {
66
+ productId: string;
67
+ appAccountToken: string;
68
+ }): Promise<VerificationPurchaseResult>;
69
+ getUnfinishedTransactions(): Promise<UnfinishedTransactionsResult>;
70
+ finishTransaction(input: {
71
+ transactionId: string;
72
+ }): Promise<FinishTransactionResult>;
73
+ }
74
+ export interface Clock {
75
+ /** Epoch milliseconds. */
76
+ now(): number;
77
+ }
78
+ export type DeliveryPhase = "idle" | "purchasing" | "awaitingApproval" | "cancelled" | "signInRequired" | "unavailable";
79
+ /** `sessionChanged`: a purchase was requested under an earlier session and was not carried out. */
80
+ export type DeliveryErrorCode = TransactionErrorCode | "contextUnavailable" | "contextRejected" | "proofRejected" | "sessionChanged";
81
+ export type AccessStatus = "pending" | "confirming" | "waitingToRetry" | "signInRequired" | "ownershipConflict" | "rejected" | "confirmed";
82
+ export type CompletionStatus = "pending" | "finished" | "notFound" | "retryRequired";
83
+ /** Safe to render and persist: no proof, account token, transaction or member id. */
84
+ export interface DeliveryItemState {
85
+ productId: string;
86
+ environment: AppleTransaction["environment"];
87
+ /** Present in the last native unfinished enumeration; null before one succeeded. */
88
+ held: boolean | null;
89
+ /** `confirmed` only from a matching acknowledgement for the current session. */
90
+ access: AccessStatus;
91
+ completion: CompletionStatus;
92
+ attempts: number;
93
+ nextAttemptAt: number | null;
94
+ errorCode: DeliveryErrorCode | null;
95
+ }
96
+ export interface DeliveryState {
97
+ phase: DeliveryPhase;
98
+ errorCode: DeliveryErrorCode | null;
99
+ items: DeliveryItemState[];
100
+ /** From the last successful enumeration; null when unknown or it failed. */
101
+ unfinishedCount: number | null;
102
+ /** Earliest `nextAttemptAt`; hosts schedule `tick()` for it (e.g. a worker `_poll`). */
103
+ nextWakeAt: number | null;
104
+ }
@@ -0,0 +1,33 @@
1
+ import type { Clock, DeliveryBackend, DeliveryState, SessionProvider, TransactionStore } from "./delivery-contract.js";
2
+ export interface PurchaseCoordinatorDependencies {
3
+ store: TransactionStore;
4
+ backend: DeliveryBackend;
5
+ session: SessionProvider;
6
+ clock: Clock;
7
+ /** Extra milliseconds added to a backoff step; inject for deterministic tests. */
8
+ jitter?: (baseDelayMs: number) => number;
9
+ /** Receives a fresh safe snapshot after every change. */
10
+ onState?: (state: DeliveryState) => void;
11
+ }
12
+ export interface PurchaseCoordinator {
13
+ /** Reconciles unfinished purchases now and again after every later session change. */
14
+ start(): Promise<DeliveryState>;
15
+ /** Buys a catalog item; the backend resolves its product id and account token.
16
+ * The same member's purchase of the same item already in progress is shared, not repeated. */
17
+ purchase(catalogRef: string): Promise<DeliveryState>;
18
+ /** Re-enumerates unfinished purchases and delivers eligible ones (e.g. on resume). */
19
+ reconcile(): Promise<DeliveryState>;
20
+ /** Unblocks every waiting or blocked item with a fresh attempt budget, then reconciles. */
21
+ retry(): Promise<DeliveryState>;
22
+ /** Runs whatever retries are due at `clock.now()`. */
23
+ tick(): Promise<DeliveryState>;
24
+ getState(): DeliveryState;
25
+ /** Drops the session subscription and suppresses every later callback. */
26
+ dispose(): void;
27
+ }
28
+ /** Automatic attempts per item per reconciliation run; the item is never discarded after. */
29
+ export declare const MAX_AUTOMATIC_ATTEMPTS = 5;
30
+ export declare const MAX_RETRY_DELAY_MS = 60000;
31
+ /** Creates a coordinator owned by the host/service lifecycle, not by a screen or render.
32
+ * Closures, not classes: Tier-5 bundles must also evaluate on Hermes, which has no `class`. */
33
+ export declare function createPurchaseCoordinator(deps: PurchaseCoordinatorDependencies): PurchaseCoordinator;
@@ -1,3 +1,6 @@
1
+ import type { TransactionStore } from "./delivery-contract.js";
2
+ export * from "./delivery-contract.js";
3
+ export * from "./delivery.js";
1
4
  /** The three store product categories. */
2
5
  export type ProductType = "subscription" | "nonConsumable" | "consumable";
3
6
  export interface Product {
@@ -132,3 +135,5 @@ export declare function getUnfinishedTransactions(): Promise<UnfinishedTransacti
132
135
  export declare function finishTransaction(input: {
133
136
  transactionId: string;
134
137
  }): Promise<FinishTransactionResult>;
138
+ /** The managed native verbs as the delivery coordinator's store. */
139
+ export declare const appleManagedStore: TransactionStore;