@aippy/runtime 0.4.1 → 0.4.2-beta.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/README.md +35 -6
- package/dist/ai/errors.d.ts +1 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.js +22 -17
- package/dist/ai/viggle/generate.d.ts +67 -0
- package/dist/ai/viggle/models.d.ts +46 -0
- package/dist/ai/viggle/recovery.d.ts +12 -0
- package/dist/{app-version-checker-Bz7FrEZz.js → app-version-checker-YVIFbytA.js} +18 -17
- package/dist/bridge-K3HqQwdj.js +311 -0
- package/dist/container-message-gRiGPin4.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-CJ3YV3nf.js +748 -0
- package/dist/{hooks-D5lkty5r.js → hooks-CMKwSLcQ.js} +1 -1
- package/dist/index/index.js +65 -55
- 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 +99 -0
- package/dist/ministore/order.d.ts +1 -0
- package/dist/ministore/purchase.d.ts +5 -0
- package/dist/ministore/queries.d.ts +14 -0
- package/dist/ministore/recharge.d.ts +12 -0
- package/dist/ministore/transport.d.ts +14 -0
- package/dist/ministore/types.d.ts +177 -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/recharge-o5P-y8eV.js +1036 -0
- package/dist/user/bridge.d.ts +3 -8
- package/dist/user/config.d.ts +2 -0
- package/dist/user/index.js +3 -3
- package/dist/utils/app-version-requirements.json.d.ts +4 -0
- package/dist/utils/index.js +1 -1
- package/package.json +5 -1
- package/dist/bridge-CtB9L5kL.js +0 -259
- package/dist/container-message-C3YXyTZj.js +0 -56
- package/dist/helper-WRpB-6MD.js +0 -241
|
@@ -15,7 +15,7 @@ async function v() {
|
|
|
15
15
|
console.log("🔍 [useUserInfo] fetchUserInfoFromBridge started");
|
|
16
16
|
const n = A();
|
|
17
17
|
try {
|
|
18
|
-
const { getUserInfoAsync: o, getUserInfoFromParent: c, isInIframe: t } = await import("./bridge-
|
|
18
|
+
const { getUserInfoAsync: o, getUserInfoFromParent: c, isInIframe: t } = await import("./bridge-K3HqQwdj.js").then((r) => r.d), { hasNativeBridge: f } = await import("./native-bridge-BnvipFJc.js"), i = f(), l = t();
|
|
19
19
|
console.log("🔍 [useUserInfo] Environment check:", {
|
|
20
20
|
hasNativeBridge: i,
|
|
21
21
|
isInIframe: l,
|
package/dist/index/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { D as r, g as s, m as o } from "../config-B0A7gHQM.js";
|
|
2
|
-
import { _ as i, g as n, r as p } from "../bridge-
|
|
3
|
-
import { A
|
|
4
|
-
import { S as
|
|
5
|
-
import { A as U, C as _, R as
|
|
6
|
-
import { CameraAPI as
|
|
7
|
-
import { P as
|
|
2
|
+
import { _ as i, g as n, r as p } from "../bridge-K3HqQwdj.js";
|
|
3
|
+
import { A, a as f, E as c, b as g, c as l } from "../errors-B3bDbQbD.js";
|
|
4
|
+
import { S as C, V as d, c as E, a as I, g as S, s as x } from "../container-message-gRiGPin4.js";
|
|
5
|
+
import { A as U, C as _, R as M, a as D, p as T } from "../runtime-CmoG3v2m.js";
|
|
6
|
+
import { CameraAPI as v, FileSystemAPI as y, GeolocationAPI as F, SensorsAPI as P, camera as O, fileSystem as V, geolocation as b, isMotionSupported as L, isOrientationSupported as w, requestMotionPermission as H, sensors as N, vibrate as k, watchMotion as B, watchOrientation as q } from "../device/index.js";
|
|
7
|
+
import { P as j, a as z, c as K, b as W, g as X, i as Y, p as J, r as Q, s as Z } from "../app-version-checker-YVIFbytA.js";
|
|
8
8
|
import { a as ee, P as ae, p as re, b as se } from "../pwa-C5nXU0DN.js";
|
|
9
9
|
import { j as te } from "../url-c26cuIpu.js";
|
|
10
10
|
import { a as ne, b as pe } from "../useTweaks-C7BEMpV3.js";
|
|
11
|
-
import { c as
|
|
12
|
-
import { reportScore as
|
|
13
|
-
import { D as xe, d as Re, e as Ue, c as _e, U as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
11
|
+
import { c as Ae, b as fe, i as ce, p as ge, u as le, a as ue } from "../useSound-z_eIn0KH.js";
|
|
12
|
+
import { reportScore as de, sendEvent as Ee, updateScore as Ie } from "../leaderboard/index.js";
|
|
13
|
+
import { D as xe, d as Re, e as Ue, c as _e, U as Me, V as De, a as Te, b as he, o as ve, i as ye, g as Fe, h as Pe, m as Oe, l as Ve, k as be, n as Le, p as we, r as He, f as Ne, j as ke, s as Be, v as qe } from "../helper-CJ3YV3nf.js";
|
|
14
|
+
import { ministore as je } from "../ministore/index.js";
|
|
15
|
+
import { c as Ke, u as We } from "../hooks-CMKwSLcQ.js";
|
|
16
|
+
import { hasNativeBridge as Ye } from "../native-bridge-BnvipFJc.js";
|
|
17
|
+
import { M as Qe } from "../recharge-o5P-y8eV.js";
|
|
16
18
|
export {
|
|
17
19
|
U as AippyRuntime,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
A as AippyRuntimeError,
|
|
21
|
+
v as CameraAPI,
|
|
20
22
|
_ as Cancellable,
|
|
21
23
|
xe as DEFAULT_BASE_URL,
|
|
22
24
|
Re as DEFAULT_CHAT_MODEL,
|
|
@@ -25,73 +27,81 @@ export {
|
|
|
25
27
|
_e as DEFAULT_UI_BASE_URL,
|
|
26
28
|
f as ERROR_CODES,
|
|
27
29
|
c as ERROR_PREFIX,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
y as FileSystemAPI,
|
|
31
|
+
F as GeolocationAPI,
|
|
32
|
+
Qe as MinistoreError,
|
|
30
33
|
ee as PWAUtils,
|
|
31
34
|
ae as PerformanceMonitor,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
j as PlatformDetector,
|
|
36
|
+
M as ReceiveChannel,
|
|
37
|
+
C as SDK_NAME,
|
|
38
|
+
P as SensorsAPI,
|
|
39
|
+
Me as UI_CHAT_ENDPOINT,
|
|
40
|
+
d as VERSION,
|
|
41
|
+
De as ViggleGenerationError,
|
|
38
42
|
i as _resetCachedApiBaseUrl,
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
Te as aippyAIProvider,
|
|
44
|
+
he as aippyChatConfig,
|
|
41
45
|
D as aippyRuntime,
|
|
42
46
|
ne as aippyTweaks,
|
|
43
47
|
pe as aippyTweaksRuntime,
|
|
44
48
|
O as camera,
|
|
45
49
|
z as checkFeatureSupport,
|
|
46
|
-
|
|
50
|
+
Ke as clearUserInfoCache,
|
|
47
51
|
K as compareVersions,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Fe as
|
|
52
|
+
ve as createAIConfig,
|
|
53
|
+
E as createAippyHeaders,
|
|
54
|
+
I as createAippyHeadersAsync,
|
|
55
|
+
g as createCodeError,
|
|
56
|
+
l as createError,
|
|
57
|
+
Ae as createHiddenMediaElement,
|
|
58
|
+
ye as createViggleRequestId,
|
|
59
|
+
V as fileSystem,
|
|
60
|
+
Fe as generateCharacter3D,
|
|
61
|
+
Pe as generateMotion,
|
|
62
|
+
b as geolocation,
|
|
63
|
+
Oe as getAIConfigValue,
|
|
57
64
|
n as getAuthTokenAsync,
|
|
58
65
|
W as getAvailableFeatures,
|
|
59
66
|
s as getConfigFromEnv,
|
|
60
67
|
X as getFeatureVersionRequirements,
|
|
61
68
|
S as getVersionInfo,
|
|
62
|
-
|
|
69
|
+
Ye as hasNativeBridge,
|
|
63
70
|
fe as isIOSDevice,
|
|
64
71
|
Y as isInIframe,
|
|
65
72
|
ce as isMediaStreamAudioSupported,
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
L as isMotionSupported,
|
|
74
|
+
w as isOrientationSupported,
|
|
68
75
|
te as joinUrl,
|
|
69
|
-
|
|
76
|
+
Ve as listViggleModels,
|
|
77
|
+
be as loadAIConfig,
|
|
70
78
|
o as mergeConfig,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
je as ministore,
|
|
80
|
+
Le as normalizeError,
|
|
81
|
+
we as parseAIConfig,
|
|
82
|
+
ge as patchAudioContext,
|
|
74
83
|
re as performanceMonitor,
|
|
75
84
|
J as platform,
|
|
76
|
-
|
|
85
|
+
T as processMotionData,
|
|
77
86
|
se as pwa,
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
de as reportScore,
|
|
88
|
+
H as requestMotionPermission,
|
|
80
89
|
Q as requireFeatureSupport,
|
|
81
90
|
p as resolveApiBaseUrl,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
He as resolveOpenAIConfig,
|
|
92
|
+
Ne as resolveUIConfig,
|
|
93
|
+
ke as resumeViggleGeneration,
|
|
94
|
+
Be as sendAIConfigToContainer,
|
|
95
|
+
Ee as sendEvent,
|
|
86
96
|
x as sendMessageToContainer,
|
|
87
|
-
|
|
97
|
+
N as sensors,
|
|
88
98
|
Z as showAlert,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
Ie as updateScore,
|
|
100
|
+
le as useAudioContext,
|
|
101
|
+
ue as useSound,
|
|
102
|
+
We as useUserInfo,
|
|
103
|
+
qe as validateAIConfig,
|
|
104
|
+
k as vibrate,
|
|
105
|
+
B as watchMotion,
|
|
96
106
|
q as watchOrientation
|
|
97
107
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MinistoreAuthorization, MinistoreAuthorizationInput, MinistoreResult } from './types';
|
|
2
|
+
export declare function usableAuthorization(data: MinistoreAuthorization, input: MinistoreAuthorizationInput): boolean;
|
|
3
|
+
/** Native bridge plus the ministore app version floor. Silent: no upgrade banner. */
|
|
4
|
+
export declare function isAuthorizationSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Native records authorization only. No App login token, project ID or HTTP
|
|
7
|
+
* authorization writer is exposed to H5. Every bridge attempt gets its own ID.
|
|
8
|
+
*/
|
|
9
|
+
export declare function confirmInApp(input: MinistoreAuthorizationInput, signal?: AbortSignal): Promise<MinistoreResult<MinistoreAuthorization>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MinistoreAuthorization, MinistoreAuthorizationInput, MinistoreRequestOptions, MinistoreResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Ask the App to record authorization through wallet.authorize, then verify mall.
|
|
4
|
+
* Confirmation never purchases or consumes an entitlement.
|
|
5
|
+
*/
|
|
6
|
+
export declare function requestAuthorization(input: MinistoreAuthorizationInput, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreAuthorization>>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MinistoreConsumeInput, MinistoreRequestOptions, MinistoreResult, MinistoreSettlement } from './types';
|
|
2
|
+
/** Consume the requested inventory/items; mall validates any automatic deficit purchase. */
|
|
3
|
+
export declare function consume(input: MinistoreConsumeInput, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreSettlement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MinistoreErrorDetails, MinistoreErrorKind, MinistoreReason } from './types';
|
|
2
|
+
export declare class MinistoreError extends Error {
|
|
3
|
+
readonly kind: MinistoreErrorKind;
|
|
4
|
+
readonly httpStatus?: number;
|
|
5
|
+
readonly code?: number | string;
|
|
6
|
+
readonly type?: string;
|
|
7
|
+
readonly reason?: MinistoreReason;
|
|
8
|
+
readonly appMessage?: string;
|
|
9
|
+
readonly traceId?: string;
|
|
10
|
+
readonly retryAfterMs?: number;
|
|
11
|
+
readonly bizOrderNo?: string;
|
|
12
|
+
readonly settlementUnknown: boolean;
|
|
13
|
+
readonly authorizationUnknown: boolean;
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
constructor(kind: MinistoreErrorKind, message: string, details?: MinistoreErrorDetails);
|
|
16
|
+
}
|
|
17
|
+
export declare function invalidInput(message: string): never;
|
|
18
|
+
export declare function invalidResponse(): never;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { requestAuthorization } from './authorization';
|
|
2
|
+
import { consume } from './consume';
|
|
3
|
+
import { isPurchaseSupported, purchase } from './purchase';
|
|
4
|
+
import { updateItem } from './update-item';
|
|
5
|
+
import { getAuthorization, getGemBalance, listBenefits, listCatalog, listRecords } from './queries';
|
|
6
|
+
export { MinistoreError } from './errors';
|
|
7
|
+
export type { BenefitHolding, BenefitItem, BenefitRecord, BenefitState, CatalogDisplay, CatalogItem, MinistoreAuthMode, MinistoreAuthorization, MinistoreAuthorizationInput, MinistoreAuthorizationQuery, MinistoreBenefits, MinistoreCatalog, MinistoreConsumeInput, MinistoreErrorDetails, MinistoreErrorKind, MinistorePurchaseInput, MinistoreReason, MinistoreRecordsPage, MinistoreRecordsQuery, MinistoreRequestOptions, MinistoreResult, MinistoreSettlement, MinistoreUpdateItem, MinistoreUpdateItemInput, } from './types';
|
|
8
|
+
export declare const ministore: {
|
|
9
|
+
getGemBalance: typeof getGemBalance;
|
|
10
|
+
getAuthorization: typeof getAuthorization;
|
|
11
|
+
requestAuthorization: typeof requestAuthorization;
|
|
12
|
+
listCatalog: typeof listCatalog;
|
|
13
|
+
listBenefits: typeof listBenefits;
|
|
14
|
+
isPurchaseSupported: typeof isPurchaseSupported;
|
|
15
|
+
purchase: typeof purchase;
|
|
16
|
+
consume: typeof consume;
|
|
17
|
+
updateItem: typeof updateItem;
|
|
18
|
+
listRecords: typeof listRecords;
|
|
19
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { i as y, a as I, b as B, s as m, r as f, w as h, c as l, d, e as u, f as b, g, p as v, h as z, u as O, j as w, o as N, k as P, l as K, m as S, n as T, q as A, t as V, v as H } from "../recharge-o5P-y8eV.js";
|
|
2
|
+
import { M as E } from "../recharge-o5P-y8eV.js";
|
|
3
|
+
function p(e) {
|
|
4
|
+
if (e !== void 0)
|
|
5
|
+
return y(e, "bizOrderNo", 64), e;
|
|
6
|
+
if (typeof globalThis.crypto?.randomUUID == "function")
|
|
7
|
+
return globalThis.crypto.randomUUID();
|
|
8
|
+
I("This environment cannot create a secure bizOrderNo");
|
|
9
|
+
}
|
|
10
|
+
async function R(e, n = {}) {
|
|
11
|
+
B(e);
|
|
12
|
+
const t = p(e.bizOrderNo), s = m({
|
|
13
|
+
benefitKey: e.benefitKey,
|
|
14
|
+
bizOrderNo: t,
|
|
15
|
+
autoPurchase: e.autoPurchase === !0,
|
|
16
|
+
...e.quantity === void 0 ? {} : { quantity: e.quantity },
|
|
17
|
+
...e.itemIds === void 0 ? {} : { itemIds: e.itemIds },
|
|
18
|
+
...e.itemValues === void 0 ? {} : { itemValues: e.itemValues }
|
|
19
|
+
}), a = f(n);
|
|
20
|
+
return h(
|
|
21
|
+
() => l(
|
|
22
|
+
"benefits/consume",
|
|
23
|
+
a.options,
|
|
24
|
+
{ method: "POST", bizOrderNo: t, body: s },
|
|
25
|
+
(c) => d(c, (i) => ({
|
|
26
|
+
benefit: g(i.benefit),
|
|
27
|
+
charged: u(i.charged),
|
|
28
|
+
idempotentHit: b(i.idempotentHit),
|
|
29
|
+
bizOrderNo: t,
|
|
30
|
+
..."walletBalance" in i ? { walletBalance: u(i.walletBalance, !0) } : {}
|
|
31
|
+
}))
|
|
32
|
+
),
|
|
33
|
+
a,
|
|
34
|
+
t,
|
|
35
|
+
s.autoPurchase && s.itemIds === void 0
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function U() {
|
|
39
|
+
return z();
|
|
40
|
+
}
|
|
41
|
+
async function M(e, n = {}) {
|
|
42
|
+
v(e);
|
|
43
|
+
const t = e.itemValues, s = e.quantity ?? t?.length ?? 1, a = p(e.bizOrderNo), o = m({
|
|
44
|
+
benefitKey: e.benefitKey,
|
|
45
|
+
quantity: s,
|
|
46
|
+
bizOrderNo: a,
|
|
47
|
+
...t === void 0 ? {} : { itemValues: t }
|
|
48
|
+
}), c = f(n);
|
|
49
|
+
return h(() => l(
|
|
50
|
+
"benefits/purchase",
|
|
51
|
+
c.options,
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
bizOrderNo: a,
|
|
55
|
+
body: o
|
|
56
|
+
},
|
|
57
|
+
(q) => d(q, (r) => ({
|
|
58
|
+
benefit: g(r.benefit),
|
|
59
|
+
charged: u(r.charged),
|
|
60
|
+
idempotentHit: b(r.idempotentHit),
|
|
61
|
+
bizOrderNo: a,
|
|
62
|
+
..."walletBalance" in r ? { walletBalance: u(r.walletBalance, !0) } : {}
|
|
63
|
+
}))
|
|
64
|
+
), c, a);
|
|
65
|
+
}
|
|
66
|
+
async function x(e, n = {}) {
|
|
67
|
+
return O(e), l(
|
|
68
|
+
"benefits/items/update",
|
|
69
|
+
n,
|
|
70
|
+
{
|
|
71
|
+
method: "POST",
|
|
72
|
+
body: {
|
|
73
|
+
benefitKey: e.benefitKey,
|
|
74
|
+
itemId: e.itemId,
|
|
75
|
+
value: e.value
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
(t) => d(t, (s) => {
|
|
79
|
+
const a = w(s.reason), o = N(s.item);
|
|
80
|
+
return o ? { item: o } : (a === "" && P(), {});
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const j = {
|
|
85
|
+
getGemBalance: H,
|
|
86
|
+
getAuthorization: V,
|
|
87
|
+
requestAuthorization: A,
|
|
88
|
+
listCatalog: T,
|
|
89
|
+
listBenefits: S,
|
|
90
|
+
isPurchaseSupported: U,
|
|
91
|
+
purchase: M,
|
|
92
|
+
consume: R,
|
|
93
|
+
updateItem: x,
|
|
94
|
+
listRecords: K
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
E as MinistoreError,
|
|
98
|
+
j as ministore
|
|
99
|
+
};
|
|
@@ -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 ministore app version floor; not backend 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,14 @@
|
|
|
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
|
+
/** Filter successful project orders; full history requires a compatible mall service. */
|
|
14
|
+
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,177 @@
|
|
|
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
|
+
/** Full filters and zero-GEM history require a compatible aisdk/mall deployment. */
|
|
115
|
+
export interface MinistoreRecordsQuery {
|
|
116
|
+
cursor?: string;
|
|
117
|
+
limit?: number;
|
|
118
|
+
/** Exact product key, merged with benefitKeys. */
|
|
119
|
+
benefitKey?: string;
|
|
120
|
+
/** Merged with benefitKey; at most 50 distinct keys after normalization. */
|
|
121
|
+
benefitKeys?: string[];
|
|
122
|
+
ops?: ('PURCHASE' | 'CONSUME')[];
|
|
123
|
+
/** Leave charge unrestricted, including zero-GEM consumption. */
|
|
124
|
+
charge?: 'CHARGED' | 'UNCHARGED';
|
|
125
|
+
}
|
|
126
|
+
export interface MinistoreConsumeInput {
|
|
127
|
+
benefitKey: string;
|
|
128
|
+
/** SDK-generated when omitted; retain one order per action for retries. */
|
|
129
|
+
bizOrderNo?: string;
|
|
130
|
+
/** Buy the inventory deficit if needed; ignored for explicit itemIds. */
|
|
131
|
+
autoPurchase?: boolean;
|
|
132
|
+
/** Consume this many inventory units; defaults to one. */
|
|
133
|
+
quantity?: number;
|
|
134
|
+
/** For item benefits, consume these exact item IDs instead of FIFO selection. */
|
|
135
|
+
itemIds?: string[];
|
|
136
|
+
/** For item benefits: replace each consumed item's value, or initialize
|
|
137
|
+
* automatically purchased deficit items. Mall validates the exact deficit. */
|
|
138
|
+
itemValues?: unknown[];
|
|
139
|
+
}
|
|
140
|
+
export interface MinistoreSettlement {
|
|
141
|
+
benefit: BenefitState;
|
|
142
|
+
charged: number;
|
|
143
|
+
walletBalance?: number;
|
|
144
|
+
idempotentHit: boolean;
|
|
145
|
+
bizOrderNo: string;
|
|
146
|
+
}
|
|
147
|
+
export interface MinistorePurchaseInput {
|
|
148
|
+
benefitKey: string;
|
|
149
|
+
quantity?: number;
|
|
150
|
+
/** For item benefits, the value of each purchased item. */
|
|
151
|
+
itemValues?: unknown[];
|
|
152
|
+
/** SDK-generated when omitted; retain one order per action for retries. */
|
|
153
|
+
bizOrderNo?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface MinistoreUpdateItemInput {
|
|
156
|
+
benefitKey: string;
|
|
157
|
+
itemId: string;
|
|
158
|
+
value: unknown;
|
|
159
|
+
}
|
|
160
|
+
export interface MinistoreUpdateItem {
|
|
161
|
+
item?: BenefitItem;
|
|
162
|
+
}
|
|
163
|
+
export type MinistoreErrorKind = 'validation' | 'auth' | 'http' | 'network' | 'protocol' | 'unsupported' | 'abort' | 'authorization' | 'recharge';
|
|
164
|
+
export interface MinistoreErrorDetails {
|
|
165
|
+
httpStatus?: number;
|
|
166
|
+
code?: number | string;
|
|
167
|
+
type?: string;
|
|
168
|
+
/** Native business refusal reason, distinct from transport type/code. */
|
|
169
|
+
reason?: MinistoreReason;
|
|
170
|
+
appMessage?: string;
|
|
171
|
+
traceId?: string;
|
|
172
|
+
retryAfterMs?: number;
|
|
173
|
+
bizOrderNo?: string;
|
|
174
|
+
settlementUnknown?: boolean;
|
|
175
|
+
authorizationUnknown?: boolean;
|
|
176
|
+
cause?: unknown;
|
|
177
|
+
}
|
|
@@ -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;
|