@aippy/runtime 0.4.2-dev.2 → 0.4.2-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/ai/errors.d.ts +1 -1
- package/dist/ai/index.d.ts +0 -1
- package/dist/ai/index.js +18 -21
- package/dist/bridge-D_-7nPNC.js +311 -0
- package/dist/container-message-DmIChz4h.js +56 -0
- package/dist/core/env.d.ts +2 -0
- package/dist/core/index.js +2 -2
- package/dist/core/parent-message.d.ts +5 -0
- package/dist/core/wallet-recharge.d.ts +16 -0
- package/dist/helper-BWszI06u.js +346 -0
- package/dist/{hooks-D5lkty5r.js → hooks-Ct9qEjM6.js} +1 -1
- package/dist/index/index.js +43 -42
- package/dist/index.d.ts +1 -0
- package/dist/ministore/app-authorization.d.ts +9 -0
- package/dist/ministore/authorization.d.ts +6 -0
- package/dist/ministore/consume.d.ts +3 -0
- package/dist/ministore/errors.d.ts +18 -0
- package/dist/ministore/index.d.ts +19 -0
- package/dist/ministore/index.js +915 -0
- package/dist/ministore/order.d.ts +1 -0
- package/dist/ministore/purchase.d.ts +5 -0
- package/dist/ministore/queries.d.ts +13 -0
- package/dist/ministore/recharge.d.ts +12 -0
- package/dist/ministore/transport.d.ts +14 -0
- package/dist/ministore/types.d.ts +166 -0
- package/dist/ministore/update-item.d.ts +3 -0
- package/dist/ministore/validation.d.ts +19 -0
- package/dist/ministore.d.ts +2 -0
- package/dist/user/bridge.d.ts +3 -8
- package/dist/user/config.d.ts +2 -0
- package/dist/user/index.js +2 -2
- package/dist/wallet-recharge-BqOljLWn.js +140 -0
- package/package.json +5 -1
- package/dist/ai/credits.d.ts +0 -12
- package/dist/bridge-CtB9L5kL.js +0 -259
- package/dist/container-message-ChLaG4Ke.js +0 -56
- package/dist/helper-CCuf-R6I.js +0 -405
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createBizOrderNo(value?: string): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MinistorePurchaseInput, MinistoreRequestOptions, MinistoreResult, MinistoreSettlement } from './types';
|
|
2
|
+
/** Native bridge and shared auth version floor; not wallet capability or API readiness. */
|
|
3
|
+
export declare function isPurchaseSupported(): boolean;
|
|
4
|
+
/** Settle an explicit purchase; mall enforces its server-recorded authorization. */
|
|
5
|
+
export declare function purchase(input: MinistorePurchaseInput, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreSettlement>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MinistoreAuthorization, MinistoreAuthorizationQuery, MinistoreBenefits, MinistoreCatalog, MinistoreRecordsPage, MinistoreRecordsQuery, MinistoreRequestOptions, MinistoreResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Read the user's GEM balance from the mall wallet.
|
|
4
|
+
* The mall wallet endpoint returns { balance: number, assetType: 'GEM' }.
|
|
5
|
+
* No account is a real zero; wallet failures are never replaced with a fake zero.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getGemBalance(options?: MinistoreRequestOptions): Promise<number>;
|
|
8
|
+
/** Read mall authorization state; this endpoint never writes authorization. */
|
|
9
|
+
export declare function getAuthorization(query: MinistoreAuthorizationQuery, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreAuthorization>>;
|
|
10
|
+
export declare function listCatalog(options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreCatalog>>;
|
|
11
|
+
/** Includes previously used benefits even when their current quantity is zero. */
|
|
12
|
+
export declare function listBenefits(options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreBenefits>>;
|
|
13
|
+
export declare function listRecords(query?: MinistoreRecordsQuery, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreRecordsPage>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MinistoreRequestOptions, MinistoreResult } from './types';
|
|
2
|
+
interface Scope {
|
|
3
|
+
options: MinistoreRequestOptions;
|
|
4
|
+
check: () => void;
|
|
5
|
+
prepareContinuation: () => void;
|
|
6
|
+
available: () => boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Bind continuation to the fresh credential identity of the original request. */
|
|
9
|
+
export declare function rechargeScope(options: MinistoreRequestOptions): Scope;
|
|
10
|
+
/** One recharge and one original-order continuation, never an authorization or retry loop. */
|
|
11
|
+
export declare function withRecharge<T>(request: () => Promise<MinistoreResult<T>>, scope: Scope, bizOrderNo: string, enabled?: boolean): Promise<MinistoreResult<T>>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MinistoreRequestOptions } from './types';
|
|
2
|
+
/** Internal per-operation guard; never a public option or a credential cache. */
|
|
3
|
+
export declare const REQUEST_SCOPE_CHECK: unique symbol;
|
|
4
|
+
interface RequestInit {
|
|
5
|
+
method: 'GET' | 'POST';
|
|
6
|
+
body?: unknown;
|
|
7
|
+
bizOrderNo?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Validate before requesting credentials or opening native authorization UI. */
|
|
10
|
+
export declare function ministoreApiBaseUrl(baseUrl?: string): string;
|
|
11
|
+
/** Keep the same finite JSON contents across a recharge continuation. */
|
|
12
|
+
export declare function snapshotRequestBody<T>(body: T): T;
|
|
13
|
+
export declare function requestMinistore<T>(path: string, options: MinistoreRequestOptions, init: RequestInit, parse: (body: unknown) => T): Promise<T>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export interface MinistoreRequestOptions {
|
|
2
|
+
/** Official HTTPS Aippy API origin with /aisdk/v1/; arbitrary proxies are rejected. */
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
/** Explicit App-Language. Omit to use the backend's default language. */
|
|
5
|
+
language?: string;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
export type MinistoreReason = 'project_unresolved' | 'unknown_action' | 'inactive' | 'limit_reached' | 'limit_exceeded' | 'user_purchase_limit' | 'total_purchase_limit' | 'purchase_interval' | 'purchase_window_limit' | 'authorization_required' | 'not_consumable' | 'out_of_stock' | 'insufficient_balance' | 'payment_rejected' | 'idempotency_conflict' | (string & {});
|
|
9
|
+
export type MinistoreResult<T> = {
|
|
10
|
+
ok: true;
|
|
11
|
+
data: T;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
reason: MinistoreReason;
|
|
15
|
+
data: T;
|
|
16
|
+
};
|
|
17
|
+
export interface CatalogDisplay {
|
|
18
|
+
title: string;
|
|
19
|
+
subtitle: string;
|
|
20
|
+
iconUrl: string;
|
|
21
|
+
}
|
|
22
|
+
export type MinistoreAuthMode = 'none' | 'once' | 'every' | (string & {});
|
|
23
|
+
export interface BenefitHolding {
|
|
24
|
+
orderId: string;
|
|
25
|
+
bizOrderNo: string;
|
|
26
|
+
value: unknown;
|
|
27
|
+
quantity: number;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
source: 'PURCHASE' | 'FREE' | (string & {});
|
|
30
|
+
}
|
|
31
|
+
export interface BenefitItem {
|
|
32
|
+
itemId: string;
|
|
33
|
+
value: unknown;
|
|
34
|
+
orderId: string;
|
|
35
|
+
bizOrderNo: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
export interface BenefitState {
|
|
40
|
+
benefitKey: string;
|
|
41
|
+
kind: 'fixed' | 'inventory' | 'item' | (string & {});
|
|
42
|
+
/** Entitlement snapshot; its shape is defined by the project. */
|
|
43
|
+
value: unknown;
|
|
44
|
+
quantity: number;
|
|
45
|
+
used: number;
|
|
46
|
+
display: CatalogDisplay;
|
|
47
|
+
holdings: BenefitHolding[];
|
|
48
|
+
items: BenefitItem[];
|
|
49
|
+
}
|
|
50
|
+
export interface CatalogItem extends Omit<BenefitState, 'holdings' | 'items'> {
|
|
51
|
+
price: number;
|
|
52
|
+
freeQuota: number;
|
|
53
|
+
/** Zero means no configured inventory limit. Fixed benefits follow server rules. */
|
|
54
|
+
maxQuantity: number;
|
|
55
|
+
consumable: boolean;
|
|
56
|
+
maxUserPurchase: number;
|
|
57
|
+
userPurchased: number;
|
|
58
|
+
maxTotalPurchase: number;
|
|
59
|
+
totalSold: number;
|
|
60
|
+
authMode: MinistoreAuthMode;
|
|
61
|
+
authRequired: boolean;
|
|
62
|
+
authorized: boolean;
|
|
63
|
+
authorizedAt: string;
|
|
64
|
+
}
|
|
65
|
+
export interface BenefitRecord {
|
|
66
|
+
id: string;
|
|
67
|
+
op: 'PURCHASE' | 'CONSUME' | (string & {});
|
|
68
|
+
benefitKey: string;
|
|
69
|
+
quantity: number;
|
|
70
|
+
charged: number;
|
|
71
|
+
projectName: string;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
bizOrderNo: string;
|
|
74
|
+
value: unknown;
|
|
75
|
+
}
|
|
76
|
+
export interface MinistoreAuthorizationQuery {
|
|
77
|
+
benefitKey: string;
|
|
78
|
+
/** Required by mall for every-order authorization; optional for once. */
|
|
79
|
+
bizOrderNo?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface MinistoreAuthorization {
|
|
82
|
+
benefitKey: string;
|
|
83
|
+
authMode: MinistoreAuthMode;
|
|
84
|
+
authorized: boolean;
|
|
85
|
+
authorizedAt: string;
|
|
86
|
+
bizOrderNo: string;
|
|
87
|
+
quantity: number;
|
|
88
|
+
amount: number;
|
|
89
|
+
expireAt: string;
|
|
90
|
+
used: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** Native confirmation input. App login credentials and project IDs stay native. */
|
|
93
|
+
export interface MinistoreAuthorizationInput {
|
|
94
|
+
operation: 'purchase' | 'consume';
|
|
95
|
+
benefitKey: string;
|
|
96
|
+
quantity: number;
|
|
97
|
+
/** Stable business order, distinct from the SDK-generated bridge requestId. */
|
|
98
|
+
bizOrderNo: string;
|
|
99
|
+
title: string;
|
|
100
|
+
buttonText: string;
|
|
101
|
+
content?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface MinistoreCatalog {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
items: CatalogItem[];
|
|
106
|
+
}
|
|
107
|
+
export interface MinistoreBenefits {
|
|
108
|
+
benefits: BenefitState[];
|
|
109
|
+
}
|
|
110
|
+
export interface MinistoreRecordsPage {
|
|
111
|
+
records: BenefitRecord[];
|
|
112
|
+
nextCursor: string;
|
|
113
|
+
}
|
|
114
|
+
export interface MinistoreRecordsQuery {
|
|
115
|
+
cursor?: string;
|
|
116
|
+
limit?: number;
|
|
117
|
+
}
|
|
118
|
+
export interface MinistoreConsumeInput {
|
|
119
|
+
benefitKey: string;
|
|
120
|
+
/** SDK-generated when omitted; retain one order per action for retries. */
|
|
121
|
+
bizOrderNo?: string;
|
|
122
|
+
/** Buy the inventory deficit if needed; ignored for explicit itemIds. */
|
|
123
|
+
autoPurchase?: boolean;
|
|
124
|
+
/** Consume this many inventory units; defaults to one. */
|
|
125
|
+
quantity?: number;
|
|
126
|
+
/** For item benefits, consume these exact item IDs instead of FIFO selection. */
|
|
127
|
+
itemIds?: string[];
|
|
128
|
+
}
|
|
129
|
+
export interface MinistoreSettlement {
|
|
130
|
+
benefit: BenefitState;
|
|
131
|
+
charged: number;
|
|
132
|
+
walletBalance?: number;
|
|
133
|
+
idempotentHit: boolean;
|
|
134
|
+
bizOrderNo: string;
|
|
135
|
+
}
|
|
136
|
+
export interface MinistorePurchaseInput {
|
|
137
|
+
benefitKey: string;
|
|
138
|
+
quantity?: number;
|
|
139
|
+
/** For item benefits, the value of each purchased item. */
|
|
140
|
+
itemValues?: unknown[];
|
|
141
|
+
/** SDK-generated when omitted; retain one order per action for retries. */
|
|
142
|
+
bizOrderNo?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface MinistoreUpdateItemInput {
|
|
145
|
+
benefitKey: string;
|
|
146
|
+
itemId: string;
|
|
147
|
+
value: unknown;
|
|
148
|
+
}
|
|
149
|
+
export interface MinistoreUpdateItem {
|
|
150
|
+
item?: BenefitItem;
|
|
151
|
+
}
|
|
152
|
+
export type MinistoreErrorKind = 'validation' | 'auth' | 'http' | 'network' | 'protocol' | 'unsupported' | 'abort' | 'authorization' | 'recharge';
|
|
153
|
+
export interface MinistoreErrorDetails {
|
|
154
|
+
httpStatus?: number;
|
|
155
|
+
code?: number | string;
|
|
156
|
+
type?: string;
|
|
157
|
+
/** Native business refusal reason, distinct from transport type/code. */
|
|
158
|
+
reason?: MinistoreReason;
|
|
159
|
+
appMessage?: string;
|
|
160
|
+
traceId?: string;
|
|
161
|
+
retryAfterMs?: number;
|
|
162
|
+
bizOrderNo?: string;
|
|
163
|
+
settlementUnknown?: boolean;
|
|
164
|
+
authorizationUnknown?: boolean;
|
|
165
|
+
cause?: unknown;
|
|
166
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MinistoreRequestOptions, MinistoreResult, MinistoreUpdateItem, MinistoreUpdateItemInput } from './types';
|
|
2
|
+
/** Update one still-owned item; mall returns a business refusal in the envelope. */
|
|
3
|
+
export declare function updateItem(input: MinistoreUpdateItemInput, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreUpdateItem>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BenefitItem, BenefitState, MinistoreAuthorization, MinistoreConsumeInput, MinistorePurchaseInput, MinistoreResult, MinistoreUpdateItemInput } from './types';
|
|
2
|
+
export declare function object(value: unknown): Record<string, unknown>;
|
|
3
|
+
export declare function string(value: unknown): string;
|
|
4
|
+
export declare function integer(value: unknown, signed?: boolean): number;
|
|
5
|
+
export declare function boolean(value: unknown): boolean;
|
|
6
|
+
export declare function array<T>(value: unknown, parse: (value: unknown) => T): T[];
|
|
7
|
+
export declare function benefitSummary(value: unknown): Omit<BenefitState, 'holdings' | 'items'>;
|
|
8
|
+
export declare function benefitItem(value: unknown): BenefitItem;
|
|
9
|
+
export declare function optionalBenefitItem(value: unknown): BenefitItem | undefined;
|
|
10
|
+
export declare function benefit(value: unknown): BenefitState;
|
|
11
|
+
export declare function result<T>(value: unknown, parse: (body: Record<string, unknown>) => T): MinistoreResult<T>;
|
|
12
|
+
export declare function authorization(body: Record<string, unknown>): MinistoreAuthorization;
|
|
13
|
+
export declare function action(input: MinistoreConsumeInput): void;
|
|
14
|
+
export declare function purchaseAction(input: MinistorePurchaseInput): void;
|
|
15
|
+
export declare function updateItemAction(input: MinistoreUpdateItemInput): void;
|
|
16
|
+
export declare function identity(value: unknown, name: string, maxLength?: number): asserts value is string;
|
|
17
|
+
export declare function quantity(value: unknown): number;
|
|
18
|
+
export declare function isCursor(value: string): boolean;
|
|
19
|
+
export declare function isItemId(value: string): boolean;
|
package/dist/user/bridge.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User SDK Bridge
|
|
3
|
-
*/
|
|
4
1
|
export { isInIframe } from '../utils/platform';
|
|
5
2
|
export interface IOSUserCredentials {
|
|
6
3
|
uid: string;
|
|
@@ -17,13 +14,11 @@ export interface IOSUserInfo {
|
|
|
17
14
|
avatar?: string;
|
|
18
15
|
[key: string]: unknown;
|
|
19
16
|
}
|
|
20
|
-
/** Get auth token
|
|
17
|
+
/** Get a fresh auth token; native/iframe failures retain sign-in/upgrade UX. */
|
|
21
18
|
export declare function getAuthTokenAsync(): Promise<string>;
|
|
22
|
-
/** Get user info async, auto-detects environment */
|
|
23
19
|
export declare function getUserInfoAsync(forceRefresh?: boolean): Promise<IOSUserInfo | null>;
|
|
24
|
-
/** Get user info from parent window (iframe only, no cache) */
|
|
25
20
|
export declare function getUserInfoFromParent(timeoutMs?: number): Promise<IOSUserInfo | null>;
|
|
26
|
-
/** Called by iOS/Android: window.processUserCredentials(data) */
|
|
21
|
+
/** Called by iOS/Android: window.processUserCredentials(data). */
|
|
27
22
|
export declare function processUserCredentials(data: unknown): void;
|
|
28
|
-
/** Called by iOS/Android: window.processUserInfo(data) */
|
|
23
|
+
/** Called by iOS/Android: window.processUserInfo(data). */
|
|
29
24
|
export declare function processUserInfo(data: unknown): void;
|
package/dist/user/config.d.ts
CHANGED
|
@@ -9,4 +9,6 @@ interface UserSdkConfig {
|
|
|
9
9
|
export declare function initUserSdk(partial: Partial<UserSdkConfig>): void;
|
|
10
10
|
export declare function setAuthToken(token: string): void;
|
|
11
11
|
export declare function setCurrentUserId(userId: string | null): void;
|
|
12
|
+
/** Internal identity check; API requests still acquire fresh credentials. */
|
|
13
|
+
export declare function getCurrentUserId(): string | null;
|
|
12
14
|
export {};
|
package/dist/user/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as o, u as s } from "../hooks-
|
|
2
|
-
import { g as f } from "../bridge-
|
|
1
|
+
import { c as o, u as s } from "../hooks-Ct9qEjM6.js";
|
|
2
|
+
import { g as f } from "../bridge-D_-7nPNC.js";
|
|
3
3
|
import { i as t } from "../app-version-checker-Bz7FrEZz.js";
|
|
4
4
|
export {
|
|
5
5
|
o as clearUserInfoCache,
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { a as v } from "./bridge-D_-7nPNC.js";
|
|
2
|
+
const l = "wallet.showRecharge", R = 3e5;
|
|
3
|
+
class s extends Error {
|
|
4
|
+
constructor(t, r) {
|
|
5
|
+
super(r), this.type = t, this.name = "WalletRechargeError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
const c = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
function h() {
|
|
10
|
+
if (typeof window > "u" || typeof document < "u" && document.visibilityState === "hidden")
|
|
11
|
+
return;
|
|
12
|
+
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
13
|
+
if (typeof e?.postMessage == "function")
|
|
14
|
+
return { host: window, listener: e };
|
|
15
|
+
}
|
|
16
|
+
function y(e) {
|
|
17
|
+
e.host.processRechargeResult === e.dispatch && (e.hadPrevious ? e.host.processRechargeResult = e.previous : delete e.host.processRechargeResult), c.delete(e.host);
|
|
18
|
+
}
|
|
19
|
+
function p(e) {
|
|
20
|
+
const t = {
|
|
21
|
+
host: e,
|
|
22
|
+
previous: e.processRechargeResult,
|
|
23
|
+
hadPrevious: Object.prototype.hasOwnProperty.call(
|
|
24
|
+
e,
|
|
25
|
+
"processRechargeResult"
|
|
26
|
+
),
|
|
27
|
+
dispatch: (r) => {
|
|
28
|
+
const a = r && typeof r == "object" && !Array.isArray(r) ? r : void 0;
|
|
29
|
+
if (a?.status === "success" ? t.succeeded = !0 : a?.status === "closed" && typeof a.purchased == "boolean" ? (y(t), t.succeeded && !a.purchased ? t.waiter?.reject(
|
|
30
|
+
new s("protocol", "Inconsistent recharge closure")
|
|
31
|
+
) : t.waiter?.resolve(a.purchased)) : (t.quarantined = !0, t.waiter?.reject(
|
|
32
|
+
new s("protocol", "Invalid recharge result")
|
|
33
|
+
)), typeof t.previous == "function")
|
|
34
|
+
try {
|
|
35
|
+
t.previous.call(e, r);
|
|
36
|
+
} catch {
|
|
37
|
+
console.warn("Native recharge observer failed");
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
succeeded: !1,
|
|
41
|
+
quarantined: !1
|
|
42
|
+
};
|
|
43
|
+
return e.processRechargeResult = t.dispatch, c.set(e, t), t;
|
|
44
|
+
}
|
|
45
|
+
function m() {
|
|
46
|
+
let e;
|
|
47
|
+
try {
|
|
48
|
+
if (typeof document < "u" && document.visibilityState === "hidden")
|
|
49
|
+
return;
|
|
50
|
+
const t = h();
|
|
51
|
+
if (t) {
|
|
52
|
+
if (c.has(t.host)) return;
|
|
53
|
+
e = p(t.host), t.listener.postMessage({ command: l });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const r = v();
|
|
57
|
+
if (!r) return;
|
|
58
|
+
window.parent.postMessage({ type: l }, r);
|
|
59
|
+
} catch {
|
|
60
|
+
e && (e.quarantined = !0), console.warn("Failed to request native recharge");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function E(e) {
|
|
64
|
+
return new Promise((t, r) => {
|
|
65
|
+
if (e?.aborted) {
|
|
66
|
+
r(new s("cancelled", "Recharge wait cancelled"));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const a = h();
|
|
70
|
+
if (!a) {
|
|
71
|
+
r(
|
|
72
|
+
new s("unavailable", "Native recharge is unavailable")
|
|
73
|
+
);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let n = c.get(a.host);
|
|
77
|
+
if (n?.waiter || n?.quarantined) {
|
|
78
|
+
r(
|
|
79
|
+
new s(
|
|
80
|
+
"busy",
|
|
81
|
+
"Another recharge continuation is active"
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (n && a.host.processRechargeResult !== n.dispatch) {
|
|
87
|
+
n.quarantined = !0, r(
|
|
88
|
+
new s(
|
|
89
|
+
"protocol",
|
|
90
|
+
"Native recharge callback was replaced"
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const f = !n;
|
|
96
|
+
try {
|
|
97
|
+
n ?? (n = p(a.host));
|
|
98
|
+
} catch {
|
|
99
|
+
r(
|
|
100
|
+
new s(
|
|
101
|
+
"unavailable",
|
|
102
|
+
"Native recharge callback is unavailable"
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
let d = !1;
|
|
108
|
+
const o = (i, g = !1) => {
|
|
109
|
+
i && (n.quarantined = !0), !d && (d = !0, clearTimeout(w), e?.removeEventListener("abort", u), i ? r(i) : t(g));
|
|
110
|
+
}, u = () => o(new s("cancelled", "Recharge wait cancelled")), w = setTimeout(
|
|
111
|
+
() => o(
|
|
112
|
+
new s(
|
|
113
|
+
"timeout",
|
|
114
|
+
"Recharge closure was not received"
|
|
115
|
+
)
|
|
116
|
+
),
|
|
117
|
+
R
|
|
118
|
+
);
|
|
119
|
+
if (n.waiter = {
|
|
120
|
+
resolve: (i) => o(void 0, i),
|
|
121
|
+
reject: (i) => o(i)
|
|
122
|
+
}, e?.addEventListener("abort", u, { once: !0 }), e?.aborted) {
|
|
123
|
+
u();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (f)
|
|
127
|
+
try {
|
|
128
|
+
a.listener.postMessage({ command: l });
|
|
129
|
+
} catch {
|
|
130
|
+
o(
|
|
131
|
+
new s("bridge", "Native recharge request failed")
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
s as W,
|
|
138
|
+
m as s,
|
|
139
|
+
E as w
|
|
140
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aippy/runtime",
|
|
3
|
-
"version": "0.4.2-dev.
|
|
3
|
+
"version": "0.4.2-dev.4",
|
|
4
4
|
"description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"import": "./dist/ai/index.js",
|
|
41
41
|
"types": "./dist/ai.d.ts"
|
|
42
42
|
},
|
|
43
|
+
"./ministore": {
|
|
44
|
+
"types": "./dist/ministore/index.d.ts",
|
|
45
|
+
"import": "./dist/ministore/index.js"
|
|
46
|
+
},
|
|
43
47
|
"./user": {
|
|
44
48
|
"import": "./dist/user/index.js",
|
|
45
49
|
"types": "./dist/user/index.d.ts"
|
package/dist/ai/credits.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AippyOpenAIConfig } from './shared';
|
|
2
|
-
export interface CreditsRequestOptions extends AippyOpenAIConfig {
|
|
3
|
-
signal?: AbortSignal;
|
|
4
|
-
}
|
|
5
|
-
export interface DeductCreditsOptions extends CreditsRequestOptions {
|
|
6
|
-
/** One UUID per business action. Retries must reuse both the UUID and amount. */
|
|
7
|
-
eventId: string;
|
|
8
|
-
}
|
|
9
|
-
/** Return the authenticated user's VIP plus regular credit balance. */
|
|
10
|
-
export declare function getCredits(options?: CreditsRequestOptions): Promise<number>;
|
|
11
|
-
/** Deduct a positive integer amount. The server checks the balance atomically. */
|
|
12
|
-
export declare function deductCredits(amount: number, options: DeductCreditsOptions): Promise<void>;
|