palbase 0.71.0 → 0.73.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/ai/index.js +2 -2
- package/dist/ai-sdk/index.js +2 -2
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +8 -8
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{NNFT2MAJ.js → 25HECIZY.js} +1 -1
- package/dist/chunks/{WYZDZ7QZ.js → 3DUDNEMM.js} +2 -2
- package/dist/chunks/4XSSQAES.js +95 -0
- package/dist/chunks/{C7I5HJWB.js → 5OOA4R4H.js} +1 -1
- package/dist/chunks/{6I2XBWUM.js → 757A6AR6.js} +2 -2
- package/dist/chunks/76W5ZO2L.js +2 -0
- package/dist/chunks/{KWAJFRHM.js → CY6KUFZW.js} +2 -2
- package/dist/chunks/DIQMCEMJ.js +19 -0
- package/dist/chunks/{NWKQOVQV.js → EKOEK6LR.js} +2 -2
- package/dist/chunks/{P2PPTVZS.js → IICQMY2Z.js} +2 -2
- package/dist/chunks/{5EP5JREH.js → J7Z2PYL4.js} +1 -1
- package/dist/chunks/{6G26LJYB.js → J7ZNBBRN.js} +1 -1
- package/dist/chunks/{AVLXOKYL.js → JG4V6LNY.js} +2 -2
- package/dist/chunks/{STC7LMPR.js → LCDNCPQW.js} +1 -1
- package/dist/chunks/{FHSOCZK5.js → MVKZWEHL.js} +2 -2
- package/dist/chunks/{WDNAIUED.js → P36C47FS.js} +1 -1
- package/dist/chunks/{WMXNVSHQ.js → P4NZ4NZD.js} +2 -2
- package/dist/chunks/{F5D2WPY6.js → PAQCJT7M.js} +2 -2
- package/dist/chunks/{P2ZR3LIZ.js → PEQZDT6P.js} +2 -2
- package/dist/chunks/SMECWMF7.js +2 -0
- package/dist/chunks/SRN7N2WX.js +13 -0
- package/dist/chunks/UFP6GLLW.js +23 -0
- package/dist/chunks/{4RTYKYU6.js → VEL7X2G3.js} +2 -2
- package/dist/chunks/{6DOVOQD7.js → YMIK6HLK.js} +2 -2
- package/dist/cli.js +347 -347
- package/dist/cloud/index.js +2 -2
- package/dist/refuse/ai-sdk.js +1 -1
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/cloud.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/message.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/payments-ui.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/push-sw.js +1 -1
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +2 -2
- package/types/backend/src/index.d.ts +1 -1
- package/types/backend/src/services.d.ts +78 -0
- package/types/cloud/src/generated/project.d.ts +4 -2
- package/types/internal/src/modules/analytics.d.ts +58 -4
- package/types/internal/src/modules/campaigns.d.ts +616 -0
- package/types/internal/src/modules/commerce.d.ts +4244 -0
- package/types/internal/src/modules/events.d.ts +5 -3
- package/types/internal/src/modules/index.d.ts +2 -0
- package/types/internal/src/modules/journeys.d.ts +145 -0
- package/types/internal/src/modules/notify.d.ts +7 -6
- package/types/internal/src/modules/payments.d.ts +851 -2
- package/types/server/src/campaigns.d.ts +31 -0
- package/types/server/src/commerce.d.ts +78 -0
- package/types/server/src/index.d.ts +3 -1
- package/types/server/src/payments.d.ts +6 -0
- package/types/server/src/server.d.ts +6 -0
- package/types/web/src/campaigns.d.ts +59 -0
- package/types/web/src/client.d.ts +6 -0
- package/types/web/src/commerce.d.ts +130 -0
- package/types/web/src/inapp.d.ts +4 -0
- package/types/web/src/index.d.ts +2 -0
- package/types/web/src/screen/render.d.ts +6 -1
- package/types/web/src/screen/resolve.d.ts +10 -0
- package/dist/chunks/AYPODLGK.js +0 -23
- package/dist/chunks/E3JCXDTW.js +0 -2
- package/dist/chunks/LCZZSEYY.js +0 -2
- package/dist/chunks/PZEHNKUJ.js +0 -95
- package/dist/chunks/S6FTHDCG.js +0 -13
- package/dist/chunks/WL7Z55QJ.js +0 -13
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { campaigns as campaignsModule, journeys as journeysModule, PalbaseEvent } from '../../internal/src/modules/index.js';
|
|
2
|
+
export type Broadcast = campaignsModule.Broadcast;
|
|
3
|
+
export type BroadcastWrite = campaignsModule.BroadcastWrite;
|
|
4
|
+
export type BroadcastVariant = campaignsModule.BroadcastVariant;
|
|
5
|
+
export type BroadcastStats = campaignsModule.BroadcastStats;
|
|
6
|
+
export type BroadcastArmStats = campaignsModule.BroadcastArmStats;
|
|
7
|
+
export type BroadcastConversionWrite = campaignsModule.BroadcastConversionWrite;
|
|
8
|
+
export type BroadcastConversionResult = campaignsModule.BroadcastConversionResult;
|
|
9
|
+
export type CampaignIncentive = campaignsModule.Incentive;
|
|
10
|
+
export type OnSiteCampaign = campaignsModule.OnSiteCampaign;
|
|
11
|
+
export type OnSiteCampaignWrite = campaignsModule.OnSiteCampaignWrite;
|
|
12
|
+
export type OnSiteSettings = campaignsModule.OnSiteSettings;
|
|
13
|
+
export type OnSiteStats = campaignsModule.OnSiteStats;
|
|
14
|
+
export type TrackingLink = campaignsModule.TrackingLink;
|
|
15
|
+
export type TrackingLinkWrite = campaignsModule.TrackingLinkWrite;
|
|
16
|
+
export type TrackingLinkStats = campaignsModule.TrackingLinkStats;
|
|
17
|
+
export type LinkAttributeWrite = campaignsModule.LinkAttributeWrite;
|
|
18
|
+
export type LinkAttributeResult = campaignsModule.LinkAttributeResult;
|
|
19
|
+
export type SellerBlueprint = journeysModule.Blueprint;
|
|
20
|
+
export type StoreBlueprintActivate = journeysModule.StoreBlueprintActivate;
|
|
21
|
+
export type StoreBlueprintJourney = journeysModule.StoreBlueprintJourney;
|
|
22
|
+
export type CampaignsWebhookEvent = Extract<PalbaseEvent, {
|
|
23
|
+
type: `campaigns.${string}`;
|
|
24
|
+
}>;
|
|
25
|
+
export type JourneysWebhookEvent = Extract<PalbaseEvent, {
|
|
26
|
+
type: `journey.${string}`;
|
|
27
|
+
}>;
|
|
28
|
+
/** Type guard narrowing a verified Palbase webhook event to campaigns.* events. */
|
|
29
|
+
export declare function isCampaignsEvent(event: PalbaseEvent): event is CampaignsWebhookEvent;
|
|
30
|
+
/** Type guard narrowing a verified Palbase webhook event to journey.* events. */
|
|
31
|
+
export declare function isJourneysEvent(event: PalbaseEvent): event is JourneysWebhookEvent;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { commerce as commerceModule, PalbaseEvent } from '../../internal/src/modules/index.js';
|
|
2
|
+
export type CommerceSettings = commerceModule.CommerceSettings;
|
|
3
|
+
export type Region = commerceModule.Region;
|
|
4
|
+
export type Channel = commerceModule.Channel;
|
|
5
|
+
export type Store = commerceModule.Store;
|
|
6
|
+
export type StoreMetrics = commerceModule.StoreMetrics;
|
|
7
|
+
export type Product = commerceModule.Product;
|
|
8
|
+
export type ProductDetail = commerceModule.ProductDetail;
|
|
9
|
+
export type Variant = commerceModule.Variant;
|
|
10
|
+
export type Listing = commerceModule.Listing;
|
|
11
|
+
export type Price = commerceModule.Price;
|
|
12
|
+
export type StockLocation = commerceModule.StockLocation;
|
|
13
|
+
export type InventoryLevel = commerceModule.InventoryLevel;
|
|
14
|
+
export type Cart = commerceModule.Cart;
|
|
15
|
+
export type CheckoutResponse = commerceModule.CheckoutResponse;
|
|
16
|
+
export type Order = commerceModule.Order;
|
|
17
|
+
export type OrderDetail = commerceModule.OrderDetail;
|
|
18
|
+
export type StoreOrder = commerceModule.StoreOrder;
|
|
19
|
+
export type ReturnRecord = commerceModule.ReturnRecord;
|
|
20
|
+
export type Invoice = commerceModule.Invoice;
|
|
21
|
+
export type Settlement = commerceModule.Settlement;
|
|
22
|
+
export type HookView = commerceModule.HookView;
|
|
23
|
+
export type HookCreated = commerceModule.HookCreated;
|
|
24
|
+
export type PromotionRule = commerceModule.PromotionRule;
|
|
25
|
+
export type PromotionCode = commerceModule.PromotionCode;
|
|
26
|
+
export type PromotionEvalResult = commerceModule.PromotionEvalResult;
|
|
27
|
+
export type PromotionRedemption = commerceModule.PromotionRedemption;
|
|
28
|
+
export type CommerceHookPoint = 'shipping.calculate' | 'tax.calculate' | 'checkout.validate' | 'buybox.rank';
|
|
29
|
+
export type CommerceWebhookEvent = Extract<PalbaseEvent, {
|
|
30
|
+
type: `commerce.${string}`;
|
|
31
|
+
}>;
|
|
32
|
+
export type PromotionsWebhookEvent = Extract<PalbaseEvent, {
|
|
33
|
+
type: `promotions.${string}`;
|
|
34
|
+
}>;
|
|
35
|
+
/** Type guard narrowing a verified Palbase webhook event to commerce.* events. */
|
|
36
|
+
export declare function isCommerceEvent(event: PalbaseEvent): event is CommerceWebhookEvent;
|
|
37
|
+
/** Type guard narrowing a verified Palbase webhook event to promotions.* events. */
|
|
38
|
+
export declare function isPromotionsEvent(event: PalbaseEvent): event is PromotionsWebhookEvent;
|
|
39
|
+
export interface CommerceHookVerifyOptions {
|
|
40
|
+
/** Hook signing secret (whsec_…), returned once by POST /commerce/hooks. */
|
|
41
|
+
secret: string;
|
|
42
|
+
/** Standard Webhooks `webhook-id` header. */
|
|
43
|
+
webhookId: string | null | undefined;
|
|
44
|
+
/** Standard Webhooks `webhook-timestamp` header (unix seconds). */
|
|
45
|
+
webhookTimestamp: string | null | undefined;
|
|
46
|
+
/** Standard Webhooks `webhook-signature` header (`v1,<base64>`). */
|
|
47
|
+
webhookSignature: string | null | undefined;
|
|
48
|
+
/** Raw request body bytes/string before JSON parsing. */
|
|
49
|
+
body: string | Uint8Array | ArrayBuffer;
|
|
50
|
+
/** Replay tolerance in seconds (default 300). */
|
|
51
|
+
toleranceSeconds?: number;
|
|
52
|
+
/** Clock function in epoch ms (default Date.now). */
|
|
53
|
+
now?: () => number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Verifies a Standard Webhooks HMAC-SHA256 signature sent by Palbase's blocking
|
|
57
|
+
* commerce extension hooks (`webhook-id`, `webhook-timestamp`, `webhook-signature`).
|
|
58
|
+
*/
|
|
59
|
+
export declare function verifyCommerceHookSignature(opts: CommerceHookVerifyOptions): Promise<void>;
|
|
60
|
+
export interface CommerceHookContext<TReq = Record<string, unknown>> {
|
|
61
|
+
hookPoint: string;
|
|
62
|
+
webhookId: string;
|
|
63
|
+
payload: TReq;
|
|
64
|
+
request: Request;
|
|
65
|
+
}
|
|
66
|
+
export interface CommerceHookHandlerOptions<TReq = Record<string, unknown>, TRes = Record<string, unknown>> {
|
|
67
|
+
secret: string;
|
|
68
|
+
toleranceSeconds?: number;
|
|
69
|
+
now?: () => number;
|
|
70
|
+
handle: (ctx: CommerceHookContext<TReq>) => Promise<TRes> | TRes;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Builds a Web-standard `(request: Request) => Promise<Response>` handler for a
|
|
74
|
+
* Palbase blocking commerce extension hook (`shipping.calculate`, `tax.calculate`,
|
|
75
|
+
* `checkout.validate`, `buybox.rank`). Verifies Standard Webhooks signatures before
|
|
76
|
+
* invoking `handle` and responds with JSON.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createCommerceHookHandler<TReq = Record<string, unknown>, TRes = Record<string, unknown>>(opts: CommerceHookHandlerOptions<TReq, TRes>): (request: Request) => Promise<Response>;
|
|
@@ -4,7 +4,9 @@ export { Transit, TransitRefusal, TransitRequest, type TransitKeySet } from './t
|
|
|
4
4
|
export { EVENT_TYPES, signatureHeader, verifySignature, verifyWebhook, verifyWebhookRequest, WebhookSignatureError, type EventType, type PalbaseEvent, type PlatformEvent, type PlatformEvents, type SignatureOptions, type VerifyOptions, type WebhookEvent, type WebhookRefusal, } from './webhooks.js';
|
|
5
5
|
export { AuthUnavailable, requestAddress, sessionStanding, TokenError, TokenVerifier, type ProofContext, type RequestLike, type SessionStanding, type TokenRefusal, type TokenUser, type VerifierOptions, } from './auth/jwt.js';
|
|
6
6
|
export { isEntitled, ReservationSettled, withReservation, type CustomerInfo, type Reservation, type SpendReceipt } from './iap.js';
|
|
7
|
-
export { isPaymentsEvent, isRetryableDecline, settleWalletHold, WalletHoldSettled, withWalletHold, type DeclineCode, type PaymentChannel, type PaymentIntent, type PaymentSubscription, type PaymentsWebhookEvent, type SavedPaymentMethod, type WalletBalance, type WalletHold, type WalletHoldReservation, type WalletHoldSettlement, } from './payments.js';
|
|
7
|
+
export { isPaymentsEvent, isRetryableDecline, settleWalletHold, WalletHoldSettled, withWalletHold, type DeclineCode, type PaymentChannel, type PaymentIntent, type PaymentSplit, type PaymentSubscription, type PaymentsWebhookEvent, type SavedPaymentMethod, type SellerAccount, type SellerBalance, type SplitInput, type SplitRefundInput, type SubMerchant, type WalletBalance, type WalletHold, type WalletHoldReservation, type WalletHoldSettlement, } from './payments.js';
|
|
8
|
+
export { createCommerceHookHandler, isCommerceEvent, isPromotionsEvent, verifyCommerceHookSignature, type Cart, type Channel, type CheckoutResponse, type CommerceHookContext, type CommerceHookHandlerOptions, type CommerceHookPoint, type CommerceHookVerifyOptions, type CommerceSettings, type CommerceWebhookEvent, type HookCreated, type HookView, type InventoryLevel, type Invoice, type Listing, type Order, type OrderDetail, type Price, type Product, type ProductDetail, type PromotionCode, type PromotionEvalResult, type PromotionRedemption, type PromotionRule, type PromotionsWebhookEvent, type Region, type ReturnRecord, type Settlement, type StockLocation, type Store, type StoreMetrics, type StoreOrder, type Variant, } from './commerce.js';
|
|
9
|
+
export { isCampaignsEvent, isJourneysEvent, type Broadcast, type BroadcastArmStats, type BroadcastConversionResult, type BroadcastConversionWrite, type BroadcastStats, type BroadcastVariant, type BroadcastWrite, type CampaignIncentive, type CampaignsWebhookEvent, type JourneysWebhookEvent, type LinkAttributeResult, type LinkAttributeWrite, type OnSiteCampaign, type OnSiteCampaignWrite, type OnSiteSettings, type OnSiteStats, type SellerBlueprint, type StoreBlueprintActivate, type StoreBlueprintJourney, type TrackingLink, type TrackingLinkStats, type TrackingLinkWrite, } from './campaigns.js';
|
|
8
10
|
export { pages } from './pages.js';
|
|
9
11
|
export { PalbaseError } from '../../internal/src/transport.js';
|
|
10
12
|
export type { RetryPolicy } from '../../internal/src/retry.js';
|
|
@@ -6,6 +6,12 @@ export type PaymentChannel = payments.ChannelView;
|
|
|
6
6
|
export type WalletBalance = payments.WalletBalance;
|
|
7
7
|
export type SavedPaymentMethod = payments.SavedMethodView;
|
|
8
8
|
export type PaymentSubscription = payments.SubscriptionView;
|
|
9
|
+
export type SubMerchant = payments.SubMerchantView;
|
|
10
|
+
export type PaymentSplit = payments.PaymentSplitView;
|
|
11
|
+
export type SplitInput = payments.SplitInput;
|
|
12
|
+
export type SplitRefundInput = payments.SplitRefundRequest;
|
|
13
|
+
export type SellerBalance = payments.SellerBalance;
|
|
14
|
+
export type SellerAccount = payments.SellerAccountResponse;
|
|
9
15
|
/** Canonical provider-agnostic decline codes emitted across Stripe, iyzico, Masterpass, and wallet payments. */
|
|
10
16
|
export type DeclineCode = 'insufficient_funds' | 'expired_card' | 'invalid_cvc' | 'three_ds_failed' | 'fraud_suspected' | 'issuer_declined' | 'do_not_honor' | 'limit_exceeded' | 'card_not_supported' | 'authentication_required' | 'provider_unavailable' | 'invalid_request' | 'unknown_decline';
|
|
11
17
|
/** Reports whether a canonical decline code can safely be retried with another attempt or user verification. */
|
|
@@ -55,6 +55,12 @@ export interface PalbaseServer {
|
|
|
55
55
|
notify: ReturnType<typeof modules.notify.client>;
|
|
56
56
|
/** Provider-agnostic payments, saved methods, subscriptions, closed-loop double-entry wallets, spend QR tokens, and zero-drift audit. */
|
|
57
57
|
payments: ReturnType<typeof modules.payments.client>;
|
|
58
|
+
/** Multi-channel broadcasts, on-site/in-app campaigns, and allowlisted tracking links. */
|
|
59
|
+
campaigns: ReturnType<typeof modules.campaigns.client>;
|
|
60
|
+
/** Unified commerce, multi-seller marketplace, Buy Box, split OMS/RMA, and standalone promotions engine. */
|
|
61
|
+
commerce: ReturnType<typeof modules.commerce.client>;
|
|
62
|
+
/** Lifecycle automation journeys and sandboxed seller blueprints. */
|
|
63
|
+
journeys: ReturnType<typeof modules.journeys.client>;
|
|
58
64
|
realtime: ReturnType<typeof modules.realtime.client>;
|
|
59
65
|
secrets: ReturnType<typeof modules.secrets.client>;
|
|
60
66
|
storage: ReturnType<typeof modules.storage.client>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { campaigns as campaignsModule } from '../../internal/src/modules/index.js';
|
|
2
|
+
import type { Transport } from '../../internal/src/transport.js';
|
|
3
|
+
import { type Installation } from './installation.js';
|
|
4
|
+
import type { Cart, CartAuthOptions, Commerce } from './commerce.js';
|
|
5
|
+
type CM = typeof campaignsModule;
|
|
6
|
+
export type OnSiteMessage = campaignsModule.OnSiteMessage;
|
|
7
|
+
export type OnSiteMessageList = campaignsModule.OnSiteMessageList;
|
|
8
|
+
export type OnSiteImpression = campaignsModule.OnSiteImpression;
|
|
9
|
+
export type OnSiteImpressionWrite = campaignsModule.OnSiteImpressionWrite;
|
|
10
|
+
export type OnSiteEventWrite = campaignsModule.OnSiteEventWrite;
|
|
11
|
+
export interface CampaignAttribution {
|
|
12
|
+
clickToken?: string;
|
|
13
|
+
promoCode?: string;
|
|
14
|
+
utmSource?: string;
|
|
15
|
+
utmMedium?: string;
|
|
16
|
+
utmCampaign?: string;
|
|
17
|
+
utmContent?: string;
|
|
18
|
+
utmTerm?: string;
|
|
19
|
+
capturedAt: number;
|
|
20
|
+
}
|
|
21
|
+
type Globals = {
|
|
22
|
+
location?: {
|
|
23
|
+
href?: string;
|
|
24
|
+
search?: string;
|
|
25
|
+
};
|
|
26
|
+
localStorage?: Storage;
|
|
27
|
+
};
|
|
28
|
+
export declare class Campaigns {
|
|
29
|
+
readonly api: ReturnType<CM['client']>;
|
|
30
|
+
private commerce;
|
|
31
|
+
private installation;
|
|
32
|
+
private storageKey;
|
|
33
|
+
private g;
|
|
34
|
+
private now;
|
|
35
|
+
private memoryAttribution;
|
|
36
|
+
constructor(transport: Transport, installation: Installation, commerce: Commerce, origin: string, g?: Globals, now?: () => number);
|
|
37
|
+
/** Fetches eligible on-site / in-app campaigns for the current user or browser installation. */
|
|
38
|
+
listOnSiteMessages(signal?: AbortSignal): Promise<OnSiteMessageList>;
|
|
39
|
+
/** Records an on-site campaign impression and returns any generated incentive variables. */
|
|
40
|
+
recordImpression(body: {
|
|
41
|
+
campaign_id: string;
|
|
42
|
+
session_id: string;
|
|
43
|
+
installation_id?: string;
|
|
44
|
+
}, signal?: AbortSignal): Promise<OnSiteImpression>;
|
|
45
|
+
/** Records a clicked, dismissed, or converted interaction on an on-site impression. */
|
|
46
|
+
recordEvent(impressionId: string, body: OnSiteEventWrite, signal?: AbortSignal): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Reads `pb_click`, `pb_promo`, and `utm_*` query parameters from `urlOrSearch` (or `window.location.search`),
|
|
49
|
+
* persists them for attribution across page navigation, and returns the captured record (or null when absent).
|
|
50
|
+
*/
|
|
51
|
+
captureAttribution(urlOrSearch?: string): CampaignAttribution | null;
|
|
52
|
+
/** Returns the currently active captured tracking-link attribution (or null if absent or expired). */
|
|
53
|
+
getAttribution(maxAgeMs?: number): CampaignAttribution | null;
|
|
54
|
+
/** Clears persisted tracking-link attribution. */
|
|
55
|
+
clearAttribution(): void;
|
|
56
|
+
/** Applies the captured `pb_promo` code (if any) directly to a commerce cart. */
|
|
57
|
+
applyAttributedPromo(cartId: string, opts?: CartAuthOptions): Promise<Cart | null>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -9,6 +9,8 @@ import { Installation } from './installation.js';
|
|
|
9
9
|
import { Notify } from './notify.js';
|
|
10
10
|
import { Iap } from './iap.js';
|
|
11
11
|
import { Payments } from './payments.js';
|
|
12
|
+
import { Commerce } from './commerce.js';
|
|
13
|
+
import { Campaigns } from './campaigns.js';
|
|
12
14
|
import { type ChatToolCall, type SessionSummaryEvent } from './chat.js';
|
|
13
15
|
import { Flags } from './flags.js';
|
|
14
16
|
import { Messaging, type MessagingOptions } from './messaging.js';
|
|
@@ -99,6 +101,10 @@ export interface PalbaseClient {
|
|
|
99
101
|
iap: Iap;
|
|
100
102
|
/** Core payments client: capabilities, installments, PaymentIntents, saved cards, closed-loop wallets, QR spend tokens, subscriptions, and portal. */
|
|
101
103
|
payments: Payments;
|
|
104
|
+
/** Unified storefront catalog, guest/customer carts, single-TX checkout, customer orders/downloads, and user-pinned Seller Portal. */
|
|
105
|
+
commerce: Commerce;
|
|
106
|
+
/** On-site / in-app campaigns and cookieless tracking-link attribution (`pb_click`, `pb_promo`, UTM). */
|
|
107
|
+
campaigns: Campaigns;
|
|
102
108
|
/** The project's notifications as this app takes them: this browser's pushes (Web Push). */
|
|
103
109
|
notify: Notify;
|
|
104
110
|
/** The project's feature flags and remote configuration, resolved for this app and its reader, kept current as they change. */
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { commerce as commerceModule } from '../../internal/src/modules/index.js';
|
|
2
|
+
import type { Transport } from '../../internal/src/transport.js';
|
|
3
|
+
import { type SessionManager } from './session.js';
|
|
4
|
+
type C = typeof commerceModule;
|
|
5
|
+
export type Cart = commerceModule.Cart;
|
|
6
|
+
export type CheckoutResponse = commerceModule.CheckoutResponse;
|
|
7
|
+
export type Order = commerceModule.Order;
|
|
8
|
+
export type OrderDetail = commerceModule.OrderDetail;
|
|
9
|
+
export type OrderDownloads = commerceModule.OrderDownloads;
|
|
10
|
+
export type OrderList = commerceModule.OrderList;
|
|
11
|
+
export type Product = commerceModule.Product;
|
|
12
|
+
export type ProductDetail = commerceModule.ProductDetail;
|
|
13
|
+
export type ProductList = commerceModule.ProductList;
|
|
14
|
+
export type ReturnList = commerceModule.ReturnList;
|
|
15
|
+
export type ReturnRecord = commerceModule.ReturnRecord;
|
|
16
|
+
export type Store = commerceModule.Store;
|
|
17
|
+
export type StoreList = commerceModule.StoreList;
|
|
18
|
+
export type StoreMetrics = commerceModule.StoreMetrics;
|
|
19
|
+
export type StoreOrder = commerceModule.StoreOrder;
|
|
20
|
+
export type StoreOrderDetail = commerceModule.StoreOrderDetail;
|
|
21
|
+
export type StoreOrderList = commerceModule.StoreOrderList;
|
|
22
|
+
export interface CartAuthOptions {
|
|
23
|
+
guestToken?: string;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Seller-scoped marketplace portal client bound to the user session that opened it.
|
|
28
|
+
* If the signed-in user signs out or switches accounts mid-flight, requests fail
|
|
29
|
+
* fast with `SessionChangedError` instead of crossing user boundaries.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SellerPortal {
|
|
32
|
+
readonly storeId: string;
|
|
33
|
+
readonly api: ReturnType<C['client']>;
|
|
34
|
+
constructor(storeId: string, transport: Transport);
|
|
35
|
+
listProducts(query?: {
|
|
36
|
+
q?: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
cursor?: string;
|
|
39
|
+
}, signal?: AbortSignal): Promise<ProductList>;
|
|
40
|
+
createQuickProduct(body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.QuickProductResponse>;
|
|
41
|
+
listListings(signal?: AbortSignal): Promise<commerceModule.ListingList>;
|
|
42
|
+
createListing(body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.Listing>;
|
|
43
|
+
updateListing(listingId: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.Listing>;
|
|
44
|
+
upsertPrice(listingId: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.Price>;
|
|
45
|
+
listInventory(signal?: AbortSignal): Promise<commerceModule.InventoryLevelList>;
|
|
46
|
+
adjustInventory(body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.InventoryLevel>;
|
|
47
|
+
bulkSyncInventory(body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.ActionResult>;
|
|
48
|
+
listOrders(query?: {
|
|
49
|
+
status?: string;
|
|
50
|
+
limit?: number;
|
|
51
|
+
cursor?: string;
|
|
52
|
+
}, signal?: AbortSignal): Promise<StoreOrderList>;
|
|
53
|
+
getOrder(storeOrderId: string, signal?: AbortSignal): Promise<StoreOrderDetail>;
|
|
54
|
+
createFulfillment(storeOrderId: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.ActionResult>;
|
|
55
|
+
updateFulfillment(fulfillmentId: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.ActionResult>;
|
|
56
|
+
cancelOrder(storeOrderId: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.ActionResult>;
|
|
57
|
+
listReturns(signal?: AbortSignal): Promise<ReturnList>;
|
|
58
|
+
approveReturn(returnId: string, body?: Record<string, unknown>, signal?: AbortSignal): Promise<ReturnRecord>;
|
|
59
|
+
completeReturn(returnId: string, body?: Record<string, unknown>, signal?: AbortSignal): Promise<ReturnRecord>;
|
|
60
|
+
listSettlements(signal?: AbortSignal): Promise<commerceModule.SettlementList>;
|
|
61
|
+
metrics(signal?: AbortSignal): Promise<StoreMetrics>;
|
|
62
|
+
onboardPayouts(body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.SubMerchantAccount>;
|
|
63
|
+
onboardingLink(body: Record<string, unknown>, signal?: AbortSignal): Promise<commerceModule.OnboardingLink>;
|
|
64
|
+
}
|
|
65
|
+
export declare class Commerce {
|
|
66
|
+
readonly api: ReturnType<C['client']>;
|
|
67
|
+
private transport;
|
|
68
|
+
private userTransport;
|
|
69
|
+
private session;
|
|
70
|
+
private guestTokens;
|
|
71
|
+
constructor(transport: Transport, userTransport: (user: string) => Transport, session: SessionManager);
|
|
72
|
+
private cartClient;
|
|
73
|
+
/** Storefront product discovery with search, category, brand, store, and collection filters. */
|
|
74
|
+
listProducts(query?: {
|
|
75
|
+
q?: string;
|
|
76
|
+
category_id?: string;
|
|
77
|
+
brand_id?: string;
|
|
78
|
+
store_id?: string;
|
|
79
|
+
collection_id?: string;
|
|
80
|
+
channel?: string;
|
|
81
|
+
limit?: number;
|
|
82
|
+
cursor?: string;
|
|
83
|
+
}, signal?: AbortSignal): Promise<ProductList>;
|
|
84
|
+
getProduct(idOrHandle: string, signal?: AbortSignal): Promise<ProductDetail>;
|
|
85
|
+
listCategories(signal?: AbortSignal): Promise<commerceModule.CategoryList>;
|
|
86
|
+
listBrands(signal?: AbortSignal): Promise<commerceModule.BrandList>;
|
|
87
|
+
listCollections(signal?: AbortSignal): Promise<commerceModule.CollectionList>;
|
|
88
|
+
listStores(query?: {
|
|
89
|
+
limit?: number;
|
|
90
|
+
cursor?: string;
|
|
91
|
+
}, signal?: AbortSignal): Promise<StoreList>;
|
|
92
|
+
getStore(idOrSlug: string, signal?: AbortSignal): Promise<Store>;
|
|
93
|
+
listRegions(signal?: AbortSignal): Promise<commerceModule.RegionList>;
|
|
94
|
+
listChannels(signal?: AbortSignal): Promise<commerceModule.ChannelList>;
|
|
95
|
+
/** Creates a guest or customer cart and remembers any returned `guest_token` for subsequent cart operations. */
|
|
96
|
+
createCart(body?: Record<string, unknown>, signal?: AbortSignal): Promise<Cart>;
|
|
97
|
+
getCart(cartId: string, opts?: CartAuthOptions): Promise<Cart>;
|
|
98
|
+
updateCart(cartId: string, body: Record<string, unknown>, opts?: CartAuthOptions): Promise<Cart>;
|
|
99
|
+
addItem(cartId: string, body: {
|
|
100
|
+
listing_id: string;
|
|
101
|
+
quantity: number;
|
|
102
|
+
metadata?: Record<string, unknown>;
|
|
103
|
+
}, opts?: CartAuthOptions): Promise<Cart>;
|
|
104
|
+
updateItem(cartId: string, lineId: string, body: {
|
|
105
|
+
quantity?: number;
|
|
106
|
+
selected?: boolean;
|
|
107
|
+
}, opts?: CartAuthOptions): Promise<Cart>;
|
|
108
|
+
removeItem(cartId: string, lineId: string, opts?: CartAuthOptions): Promise<Cart>;
|
|
109
|
+
selectShipping(cartId: string, body: Record<string, unknown>, opts?: CartAuthOptions): Promise<Cart>;
|
|
110
|
+
applyPromoCode(cartId: string, code: string, opts?: CartAuthOptions): Promise<Cart>;
|
|
111
|
+
removePromoCode(cartId: string, code: string, opts?: CartAuthOptions): Promise<Cart>;
|
|
112
|
+
mergeCart(cartId: string, opts?: CartAuthOptions): Promise<Cart>;
|
|
113
|
+
checkout(cartId: string, body?: Record<string, unknown>, opts?: CartAuthOptions): Promise<CheckoutResponse>;
|
|
114
|
+
getGuestOrder(orderNumber: string, guestAccessToken: string, signal?: AbortSignal): Promise<OrderDetail>;
|
|
115
|
+
myOrders(query?: {
|
|
116
|
+
status?: string;
|
|
117
|
+
limit?: number;
|
|
118
|
+
cursor?: string;
|
|
119
|
+
}, signal?: AbortSignal): Promise<OrderList>;
|
|
120
|
+
myOrder(orderId: string, signal?: AbortSignal): Promise<OrderDetail>;
|
|
121
|
+
myOrderDownloads(orderId: string, signal?: AbortSignal): Promise<OrderDownloads>;
|
|
122
|
+
requestReturn(storeOrderId: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<ReturnRecord>;
|
|
123
|
+
myReturns(signal?: AbortSignal): Promise<ReturnList>;
|
|
124
|
+
/**
|
|
125
|
+
* Opens a Seller Portal handle pinned to the currently signed-in user via `userTransport`.
|
|
126
|
+
* Throws `SessionChangedError` if no user is signed in or if the user changes mid-session.
|
|
127
|
+
*/
|
|
128
|
+
seller(storeId: string): SellerPortal;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
package/types/web/src/inapp.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ export interface InAppOptions {
|
|
|
31
31
|
onOffer?(offer: string): void | Promise<void>;
|
|
32
32
|
/** An offer the SDK could not take (no one signed in, a guest, the offer no longer theirs, the network). Without one it is thrown, and the message stays. */
|
|
33
33
|
onOfferError?(error: unknown, offer: string): void;
|
|
34
|
+
/** Applies a commerce promotion code triggered by an `apply_promo` action button. */
|
|
35
|
+
onApplyPromo?(code: string): void | Promise<void>;
|
|
36
|
+
/** Handles a `copy_code` action button (defaults to navigator.clipboard.writeText). */
|
|
37
|
+
onCopyCode?(code: string): void | Promise<void>;
|
|
34
38
|
/** The push ask's button: the browser's prompt and this browser subscribed (pb.notify.push.subscribe), unless the app does it. */
|
|
35
39
|
onRequestPush?(): void | Promise<void>;
|
|
36
40
|
/** Told as a campaign shows, and as it closes. */
|
package/types/web/src/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export { connectVoice, type StartedVoice, type VoiceConnection, type VoiceOption
|
|
|
11
11
|
export { ClientTemplates, type TemplateAttachment, type TemplateRunOptions, type TemplateRunResult, type TemplateRunUsage, type TemplateStreamChunk, type TemplateVoiceOptions, type TemplateVoiceResult, type WebAI, } from './templates.js';
|
|
12
12
|
export { Iap, redemptionToken, type CheckoutSource, type CustomerInfo, type CustomerInfoListener, type GrantInfo, type MergeGrant, type OfferView, type Offerings, type Redeemed, type RedemptionLink, type RefundDataConsent, } from './iap.js';
|
|
13
13
|
export { Payments, TERMINAL_INTENT_STATUSES, declineMessage, isTerminalIntentStatus, mountEmbedFrame, parseCallbackMessage, type Address, type Buyer, type CancelSubscriptionResponse, type Capabilities, type CapabilitiesResponse, type ConfirmIntentOptions, type InstallmentConfig, type InstallmentOption, type InstallmentTable, type IntentView, type MasterpassAction, type NextAction, type OtpPromptContext, type PaymentCallbackMessage, type PaymentRealtimeEvent, type PaymentRealtimeListener, type PresentIntentOptions, type PresentableIntent, type ProviderOptions, type SavedMethodView, type SpendToken, type SubmitOtpOptions, type SubscriptionListResponse, type SubscriptionSummary, type TopUpWalletOptions, type WaitForIntentOptions, type WalletBalance, type WalletBalancesListener, } from './payments.js';
|
|
14
|
+
export { Commerce, SellerPortal, type Cart, type CartAuthOptions, type CheckoutResponse, type Order, type OrderDetail, type OrderDownloads, type OrderList, type Product, type ProductDetail, type ProductList, type ReturnList, type ReturnRecord, type Store, type StoreList, type StoreMetrics, type StoreOrder, type StoreOrderDetail, type StoreOrderList, } from './commerce.js';
|
|
15
|
+
export { Campaigns, type CampaignAttribution, type OnSiteEventWrite, type OnSiteImpression, type OnSiteImpressionWrite, type OnSiteMessage, type OnSiteMessageList, } from './campaigns.js';
|
|
14
16
|
export { Notify, WebPush, type PushPermission, type PushSubscribeOptions } from './notify.js';
|
|
15
17
|
export { Flags, type FlagSource, type FlagsListener } from './flags.js';
|
|
16
18
|
export { ConversationList, ConversationView, DeletedGroupList, indexedDBKeyValue, Messaging, ScheduledList, ThreadView, type Conversation, type ConversationMatch, type ConversationViewState, type ConversationListState, type DeletedGroup, type DeletedGroupListState, type Entry, type Hit, type Member, type Message, type MessagingOptions, type MyProfile, type Observed, type OpenedFile, type OutboxItem, type OutgoingFile, type Profile, type ScheduledMessage, type SearchHit, type SearchMatch, type SearchOptions, type SearchResults, type SendOptions, type ThreadState, type ThreadViewState, } from './messaging.js';
|
|
@@ -114,7 +114,7 @@ export interface MessageInput {
|
|
|
114
114
|
export type MessageState = Omit<PaywallState, 'selected'>;
|
|
115
115
|
/** A button's action as the person took it, with where the button is: what a campaign counts as a click. */
|
|
116
116
|
export interface MessageActionTaken {
|
|
117
|
-
type: 'close' | 'open_url' | 'deep_link' | 'request_push' | 'show_paywall' | 'custom' | 'sheet' | 'offer';
|
|
117
|
+
type: 'close' | 'open_url' | 'deep_link' | 'request_push' | 'show_paywall' | 'custom' | 'sheet' | 'offer' | 'apply_promo' | 'copy_code';
|
|
118
118
|
url?: string;
|
|
119
119
|
link?: string;
|
|
120
120
|
placement?: string;
|
|
@@ -122,6 +122,7 @@ export interface MessageActionTaken {
|
|
|
122
122
|
value?: string;
|
|
123
123
|
sheet?: string;
|
|
124
124
|
offer?: string;
|
|
125
|
+
code?: string;
|
|
125
126
|
/** Whether the message closes as it is taken. */
|
|
126
127
|
dismiss: boolean;
|
|
127
128
|
/** The button's path in the definition (`root.children[2]`), and its id when it has one. */
|
|
@@ -143,6 +144,10 @@ export interface MessageHandlers {
|
|
|
143
144
|
onShowPaywall?(placement: string): void | Promise<void>;
|
|
144
145
|
/** One of the catalog's offers, by key: bought with, or its grant claimed. Without this its button is not drawn; the button waits while a promise it returns runs. */
|
|
145
146
|
onOffer?(offer: string): void | Promise<void>;
|
|
147
|
+
/** Applies a commerce promotion code (apply_promo). Without this its button is not drawn. */
|
|
148
|
+
onApplyPromo?(code: string): void | Promise<void>;
|
|
149
|
+
/** Copies a promo or coupon code (copy_code). Without this, copies via navigator.clipboard.writeText. */
|
|
150
|
+
onCopyCode?(code: string): void | Promise<void>;
|
|
146
151
|
/** The app's own code, by name; without this its button is not drawn. */
|
|
147
152
|
onCustom?(name: string, value?: string): void;
|
|
148
153
|
/** The message's own words, which the definition does not hold: the app's, in its language. */
|
|
@@ -158,6 +158,16 @@ export type ResolvedPresentation = {
|
|
|
158
158
|
position: 'top' | 'bottom';
|
|
159
159
|
dismissible: boolean;
|
|
160
160
|
auto_dismiss_seconds?: number;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'slide_in';
|
|
163
|
+
position: 'top' | 'bottom';
|
|
164
|
+
dismissible: boolean;
|
|
165
|
+
auto_dismiss_seconds?: number;
|
|
166
|
+
} | {
|
|
167
|
+
type: 'toast';
|
|
168
|
+
position: 'top' | 'bottom';
|
|
169
|
+
dismissible: boolean;
|
|
170
|
+
auto_dismiss_seconds?: number;
|
|
161
171
|
} | {
|
|
162
172
|
type: 'card';
|
|
163
173
|
};
|