@viceme-ai/sdk 0.3.0 → 0.6.1
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 +158 -44
- package/dist/browser-events.d.ts +52 -0
- package/dist/browser-events.d.ts.map +1 -0
- package/dist/capability-mount.d.ts +15 -0
- package/dist/capability-mount.d.ts.map +1 -0
- package/dist/chunks/build-endpoints-NrDmg6jf.js +12 -0
- package/dist/chunks/build-endpoints-NrDmg6jf.js.map +1 -0
- package/dist/chunks/{client-DKsaEtwq.js → client-w9vih8Ng.js} +386 -349
- package/dist/chunks/client-w9vih8Ng.js.map +1 -0
- package/dist/chunks/{version-C3KVoLNb.js → errors-C7DfLKcF.js} +14 -25
- package/dist/chunks/errors-C7DfLKcF.js.map +1 -0
- package/dist/chunks/validation-patAYhXC.js +43 -0
- package/dist/chunks/validation-patAYhXC.js.map +1 -0
- package/dist/chunks/version-uPTHb89K.js +6 -0
- package/dist/chunks/version-uPTHb89K.js.map +1 -0
- package/dist/core/build-endpoints.d.ts +2 -0
- package/dist/core/build-endpoints.d.ts.map +1 -1
- package/dist/core/capabilities.d.ts +4 -2
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/client.d.ts +4 -2
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/lifecycle.d.ts +2 -4
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/presentation.d.ts +7 -2
- package/dist/core/presentation.d.ts.map +1 -1
- package/dist/danmaku/index.d.ts +1 -0
- package/dist/danmaku/index.d.ts.map +1 -1
- package/dist/danmaku/mount.d.ts +1 -1
- package/dist/danmaku/mount.d.ts.map +1 -1
- package/dist/danmaku.js +128 -121
- package/dist/danmaku.js.map +1 -1
- package/dist/generated/public-contract.d.ts +124 -373
- package/dist/generated/public-contract.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -21
- package/dist/index.js.map +1 -1
- package/dist/loader/attributes.d.ts +3 -2
- package/dist/loader/attributes.d.ts.map +1 -1
- package/dist/loader/auto-loader.d.ts +1 -1
- package/dist/loader/auto-loader.d.ts.map +1 -1
- package/dist/loader/events.d.ts +1 -44
- package/dist/loader/events.d.ts.map +1 -1
- package/dist/loader/registry.d.ts +2 -1
- package/dist/loader/registry.d.ts.map +1 -1
- package/dist/manifest.json +60 -35
- package/dist/session/session.d.ts +7 -6
- package/dist/session/session.d.ts.map +1 -1
- package/dist/testing/test-adapter.d.ts +1 -1
- package/dist/testing/test-adapter.d.ts.map +1 -1
- package/dist/testing.js +18 -17
- package/dist/testing.js.map +1 -1
- package/dist/tip/headless.d.ts +4 -0
- package/dist/tip/headless.d.ts.map +1 -0
- package/dist/tip/index.d.ts +67 -0
- package/dist/tip/index.d.ts.map +1 -0
- package/dist/tip/mount.d.ts +5 -0
- package/dist/tip/mount.d.ts.map +1 -0
- package/dist/tip/testing.d.ts +9 -0
- package/dist/tip/testing.d.ts.map +1 -0
- package/dist/tip/testing.js +43 -0
- package/dist/tip/testing.js.map +1 -0
- package/dist/tip/validation.d.ts +7 -0
- package/dist/tip/validation.d.ts.map +1 -0
- package/dist/tip.js +472 -0
- package/dist/tip.js.map +1 -0
- package/dist/transport/transport.d.ts +3 -1
- package/dist/transport/transport.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/viceme.min.js +5 -22
- package/dist/viceme.min.js.map +1 -1
- package/package.json +12 -7
- package/dist/bootstrap.min.js +0 -2
- package/dist/bootstrap.min.js.map +0 -1
- package/dist/chunks/client-DKsaEtwq.js.map +0 -1
- package/dist/chunks/version-C3KVoLNb.js.map +0 -1
- package/dist/loader/bootstrap.d.ts +0 -1
- package/dist/loader/bootstrap.d.ts.map +0 -1
- package/dist/loader/mount-handle.d.ts +0 -25
- package/dist/loader/mount-handle.d.ts.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
1
|
+
import { a as i } from "./chunks/errors-C7DfLKcF.js";
|
|
2
|
+
import { i as l, a as u, V as k } from "./chunks/client-w9vih8Ng.js";
|
|
3
3
|
function g(e) {
|
|
4
|
-
const
|
|
4
|
+
const s = [], o = [...e.sessionFailures ?? []], a = e.latencyMs ?? 0;
|
|
5
5
|
return {
|
|
6
|
-
requests:
|
|
6
|
+
requests: s,
|
|
7
7
|
async request(t) {
|
|
8
8
|
if (t.signal?.aborted)
|
|
9
9
|
throw new DOMException("Aborted", "AbortError");
|
|
10
|
-
if (
|
|
11
|
-
const c = t.signal,
|
|
10
|
+
if (s.push(t), await new Promise((r, n) => {
|
|
11
|
+
const c = t.signal, w = setTimeout(() => r(), a);
|
|
12
12
|
c?.addEventListener(
|
|
13
13
|
"abort",
|
|
14
14
|
() => {
|
|
15
|
-
clearTimeout(
|
|
15
|
+
clearTimeout(w), n(new DOMException("Aborted", "AbortError"));
|
|
16
16
|
},
|
|
17
17
|
{ once: !0 }
|
|
18
18
|
);
|
|
19
|
-
}), t.path === "/v1/public/
|
|
19
|
+
}), t.path === "/v1/public/work-sdk/sessions" && t.method === "POST") {
|
|
20
20
|
const r = o.shift();
|
|
21
21
|
if (r) {
|
|
22
22
|
if (r instanceof Error) throw r;
|
|
@@ -30,11 +30,12 @@ function g(e) {
|
|
|
30
30
|
return {
|
|
31
31
|
status: 201,
|
|
32
32
|
body: {
|
|
33
|
-
|
|
33
|
+
workKey: e.work.key,
|
|
34
|
+
capabilities: [...e.work.capabilities],
|
|
34
35
|
...e.work.token !== void 0 ? { token: e.work.token } : {},
|
|
35
|
-
...e.work.expiresAt !== void 0 ? { expiresAt: e.work.expiresAt } : {}
|
|
36
|
+
...e.work.expiresAt !== void 0 ? { expiresAt: new Date(e.work.expiresAt).toISOString() } : {}
|
|
36
37
|
},
|
|
37
|
-
requestId: `test-${
|
|
38
|
+
requestId: `test-${s.length}`
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
return {
|
|
@@ -45,13 +46,13 @@ function g(e) {
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
function m(e) {
|
|
48
|
-
if (!
|
|
49
|
-
throw
|
|
49
|
+
if (!l(e.workKey))
|
|
50
|
+
throw i('Test client requires a "wrk_test_" or "wrk_live_" workKey.');
|
|
50
51
|
if (!u(e.region))
|
|
51
|
-
throw
|
|
52
|
+
throw i('Test client requires region "cn" or "global".');
|
|
52
53
|
if (typeof e.transport?.request != "function")
|
|
53
|
-
throw
|
|
54
|
-
return new
|
|
54
|
+
throw i("Test client requires a transport with a request() method.");
|
|
55
|
+
return new k({
|
|
55
56
|
config: {
|
|
56
57
|
workKey: e.workKey,
|
|
57
58
|
region: e.region,
|
|
@@ -63,7 +64,7 @@ function m(e) {
|
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
const y = {
|
|
66
|
-
key: "
|
|
67
|
+
key: "wrk_test_demo",
|
|
67
68
|
capabilities: ["fixture"],
|
|
68
69
|
token: "test-session-token"
|
|
69
70
|
};
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sources":["../src/testing/test-adapter.ts"],"sourcesContent":["/**\n * `@viceme-ai/sdk/testing` — explicit test adapter.\n *\n * Deterministic fixture helpers for SDK consumers and capability authors.\n * This code must never be imported from production core, loader, or capability\n * bundles; it is excluded from them at build time and only exported via the\n * `./testing` subpath.\n *\n * The test client runs the exact same config, lifecycle, error, and contract\n * validation as production `createViceMe()` — it is not a bypass mock.\n */\n\nimport { configInvalid } from '../core/errors.ts';\nimport { isValidWorkKey, isValidRegion } from '../core/config.ts';\nimport { ViceMeClientImpl } from '../core/client.ts';\nimport type { ViceMeClient } from '../core/client.ts';\nimport type { ViceMeRegion } from '../core/config.ts';\nimport type { AccessPresenter } from '../core/presentation.ts';\nimport type { Transport, TransportRequest, TransportResponse } from '../transport/transport.ts';\n\nexport interface MemoryTransportWorkFixture {\n key: string;\n capabilities: string[];\n token?: string;\n expiresAt?: number;\n}\n\nexport interface MemoryTransportOptions {\n /** Work descriptor served for `POST /v1/public/
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../src/testing/test-adapter.ts"],"sourcesContent":["/**\n * `@viceme-ai/sdk/testing` — explicit test adapter.\n *\n * Deterministic fixture helpers for SDK consumers and capability authors.\n * This code must never be imported from production core, loader, or capability\n * bundles; it is excluded from them at build time and only exported via the\n * `./testing` subpath.\n *\n * The test client runs the exact same config, lifecycle, error, and contract\n * validation as production `createViceMe()` — it is not a bypass mock.\n */\n\nimport { configInvalid } from '../core/errors.ts';\nimport { isValidWorkKey, isValidRegion } from '../core/config.ts';\nimport { ViceMeClientImpl } from '../core/client.ts';\nimport type { ViceMeClient } from '../core/client.ts';\nimport type { ViceMeRegion } from '../core/config.ts';\nimport type { AccessPresenter } from '../core/presentation.ts';\nimport type { Transport, TransportRequest, TransportResponse } from '../transport/transport.ts';\n\nexport interface MemoryTransportWorkFixture {\n key: string;\n capabilities: string[];\n token?: string;\n expiresAt?: number;\n}\n\nexport interface MemoryTransportOptions {\n /** Work descriptor served for `POST /v1/public/work-sdk/sessions`. */\n work: MemoryTransportWorkFixture;\n /** Artificial response latency in milliseconds (default 0). */\n latencyMs?: number;\n /**\n * Queue of failures thrown before the fixture response is served; each\n * entry is consumed by one session request. Use for retry/timeout tests.\n */\n sessionFailures?: Array<Error | { status: number; code: string; message?: string }>;\n}\n\nexport interface MemoryTransport extends Transport {\n /** Every request seen so far, for assertions. */\n readonly requests: TransportRequest[];\n}\n\nexport function createMemoryTransport(options: MemoryTransportOptions): MemoryTransport {\n const requests: TransportRequest[] = [];\n const failures = [...(options.sessionFailures ?? [])];\n const latencyMs = options.latencyMs ?? 0;\n\n return {\n requests,\n async request(request: TransportRequest): Promise<TransportResponse> {\n // A pre-aborted signal never counts as an issued request.\n if (request.signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n requests.push(request);\n await new Promise<void>((resolve, reject) => {\n const signal = request.signal;\n const timer = setTimeout(() => resolve(), latencyMs);\n signal?.addEventListener(\n 'abort',\n () => {\n clearTimeout(timer);\n reject(new DOMException('Aborted', 'AbortError'));\n },\n { once: true },\n );\n });\n if (request.path === '/v1/public/work-sdk/sessions' && request.method === 'POST') {\n const failure = failures.shift();\n if (failure) {\n if (failure instanceof Error) throw failure;\n return {\n status: failure.status,\n body: {\n error: { code: failure.code, message: failure.message ?? 'Simulated failure.' },\n },\n };\n }\n return {\n status: 201,\n body: {\n workKey: options.work.key,\n capabilities: [...options.work.capabilities],\n ...(options.work.token !== undefined ? { token: options.work.token } : {}),\n ...(options.work.expiresAt !== undefined\n ? { expiresAt: new Date(options.work.expiresAt).toISOString() }\n : {}),\n },\n requestId: `test-${requests.length}`,\n };\n }\n return {\n status: 404,\n body: { error: { code: 'CONFIG_INVALID', message: `No fixture for ${request.path}.` } },\n };\n },\n };\n}\n\nexport interface CreateTestViceMeOptions {\n workKey: string;\n region: ViceMeRegion;\n /** Mock transport serving the fixture contract. */\n transport: Transport;\n signal?: AbortSignal;\n presenter?: AccessPresenter;\n /** Stable virtual clock for deterministic time-based assertions. */\n now?: () => number;\n}\n\n/**\n * Create a client backed by an injected transport. Runs identical validation\n * and lifecycle logic to `createViceMe()`.\n */\nexport function createTestViceMe(options: CreateTestViceMeOptions): ViceMeClient {\n if (!isValidWorkKey(options.workKey)) {\n throw configInvalid('Test client requires a \"wrk_test_\" or \"wrk_live_\" workKey.');\n }\n if (!isValidRegion(options.region)) {\n throw configInvalid('Test client requires region \"cn\" or \"global\".');\n }\n if (typeof options.transport?.request !== 'function') {\n throw configInvalid('Test client requires a transport with a request() method.');\n }\n return new ViceMeClientImpl({\n config: {\n workKey: options.workKey,\n region: options.region,\n signal: options.signal,\n },\n transport: options.transport,\n presenter: options.presenter,\n ...(options.now !== undefined ? { now: options.now } : {}),\n });\n}\n\n/** Standard fixture work used across repo tests and examples. */\nexport const FIXTURE_WORK: MemoryTransportWorkFixture = {\n key: 'wrk_test_demo',\n capabilities: ['fixture'],\n token: 'test-session-token',\n};\n"],"names":["createMemoryTransport","options","requests","failures","latencyMs","request","resolve","reject","signal","timer","failure","createTestViceMe","isValidWorkKey","configInvalid","isValidRegion","ViceMeClientImpl","FIXTURE_WORK"],"mappings":";;AA4CO,SAASA,EAAsBC,GAAkD;AACtF,QAAMC,IAA+B,CAAA,GAC/BC,IAAW,CAAC,GAAIF,EAAQ,mBAAmB,CAAA,CAAG,GAC9CG,IAAYH,EAAQ,aAAa;AAEvC,SAAO;AAAA,IACL,UAAAC;AAAA,IACA,MAAM,QAAQG,GAAuD;AAEnE,UAAIA,EAAQ,QAAQ;AAClB,cAAM,IAAI,aAAa,WAAW,YAAY;AAehD,UAbAH,EAAS,KAAKG,CAAO,GACrB,MAAM,IAAI,QAAc,CAACC,GAASC,MAAW;AAC3C,cAAMC,IAASH,EAAQ,QACjBI,IAAQ,WAAW,MAAMH,EAAA,GAAWF,CAAS;AACnD,QAAAI,GAAQ;AAAA,UACN;AAAA,UACA,MAAM;AACJ,yBAAaC,CAAK,GAClBF,EAAO,IAAI,aAAa,WAAW,YAAY,CAAC;AAAA,UAClD;AAAA,UACA,EAAE,MAAM,GAAA;AAAA,QAAK;AAAA,MAEjB,CAAC,GACGF,EAAQ,SAAS,kCAAkCA,EAAQ,WAAW,QAAQ;AAChF,cAAMK,IAAUP,EAAS,MAAA;AACzB,YAAIO,GAAS;AACX,cAAIA,aAAmB,MAAO,OAAMA;AACpC,iBAAO;AAAA,YACL,QAAQA,EAAQ;AAAA,YAChB,MAAM;AAAA,cACJ,OAAO,EAAE,MAAMA,EAAQ,MAAM,SAASA,EAAQ,WAAW,qBAAA;AAAA,YAAqB;AAAA,UAChF;AAAA,QAEJ;AACA,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,MAAM;AAAA,YACJ,SAAST,EAAQ,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,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAA4C,MAAM,YAAY,CAAC;AA8TtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CA6OjE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ViceMeClient } from '../core/client.ts';
|
|
2
|
+
export type TipProvider = 'WECHAT_PAY' | 'ALIPAY';
|
|
3
|
+
export interface TipConfig {
|
|
4
|
+
work: {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
workKey: string;
|
|
9
|
+
environment: 'SANDBOX' | 'PRODUCTION';
|
|
10
|
+
currency: 'CNY';
|
|
11
|
+
amount: {
|
|
12
|
+
minCents: 100;
|
|
13
|
+
maxCents: 20_000;
|
|
14
|
+
stepCents: 1;
|
|
15
|
+
};
|
|
16
|
+
providers: TipProvider[];
|
|
17
|
+
}
|
|
18
|
+
export interface TipOpenOptions {
|
|
19
|
+
amountCents: number;
|
|
20
|
+
provider?: TipProvider;
|
|
21
|
+
locale?: 'zh-CN' | 'en-US';
|
|
22
|
+
appearance?: 'light' | 'dark' | 'auto';
|
|
23
|
+
}
|
|
24
|
+
export type TipOpenResult = {
|
|
25
|
+
status: 'PAID';
|
|
26
|
+
work: {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
};
|
|
30
|
+
amountCents: number;
|
|
31
|
+
currency: 'CNY';
|
|
32
|
+
} | {
|
|
33
|
+
status: 'CANCELLED';
|
|
34
|
+
} | {
|
|
35
|
+
status: 'UNKNOWN';
|
|
36
|
+
};
|
|
37
|
+
export interface TipClient {
|
|
38
|
+
getConfig(): Promise<TipConfig>;
|
|
39
|
+
open(options: TipOpenOptions): Promise<TipOpenResult>;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
42
|
+
export interface TipMountOptions {
|
|
43
|
+
target: Element;
|
|
44
|
+
theme: 'light' | 'dark' | 'auto';
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}
|
|
47
|
+
export interface TipMountHandle {
|
|
48
|
+
readonly capability: 'tip';
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
51
|
+
export interface TipWidgetCloseDetail {
|
|
52
|
+
workId: string;
|
|
53
|
+
}
|
|
54
|
+
export interface TipPaidDetail {
|
|
55
|
+
status: 'PAID';
|
|
56
|
+
work: {
|
|
57
|
+
id: string;
|
|
58
|
+
title: string;
|
|
59
|
+
};
|
|
60
|
+
amountCents: number;
|
|
61
|
+
currency: 'CNY';
|
|
62
|
+
}
|
|
63
|
+
/** Create a framework-independent controller for a host-rendered Tip flow. */
|
|
64
|
+
export declare function createTip(client: ViceMeClient): TipClient;
|
|
65
|
+
/** Explicit ESM/npm entry point; the CDN loader calls the same mount function. */
|
|
66
|
+
export declare function mountTip(client: ViceMeClient, options: TipMountOptions): Promise<TipMountHandle>;
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tip/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,SAAS,GAAG,YAAY,CAAC;IACtC,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,EAAE;QACN,QAAQ,EAAE,GAAG,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,CAAC,CAAC;KACd,CAAC;IACF,SAAS,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,MAAM,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AS,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAEzD;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAgChG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ViceMeClient } from '../core/client.ts';
|
|
2
|
+
import type { CapabilityMountHandle, CapabilityMountOptions } from '../capability-mount.ts';
|
|
3
|
+
export declare const FRAME_READY_TIMEOUT_MS = 8000;
|
|
4
|
+
export declare function mount(client: ViceMeClient, options: CapabilityMountOptions): Promise<CapabilityMountHandle>;
|
|
5
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tip/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAS5F,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAY5C,wBAAsB,KAAK,CACzB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAwMhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TipClient, TipConfig } from './index.ts';
|
|
2
|
+
export type TipTestOutcome = 'PAID' | 'CANCELLED' | 'UNKNOWN' | Error;
|
|
3
|
+
export interface TipTestOptions {
|
|
4
|
+
config: TipConfig | Error;
|
|
5
|
+
outcome: TipTestOutcome;
|
|
6
|
+
}
|
|
7
|
+
/** Deterministic TipClient fake for component tests and Storybook stories. */
|
|
8
|
+
export declare function createTestTip(options: TipTestOptions): TipClient;
|
|
9
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/tip/testing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAiC,MAAM,YAAY,CAAC;AAGtF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAwChE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { c as i } from "../chunks/errors-C7DfLKcF.js";
|
|
2
|
+
import { p as m, t as a } from "../chunks/validation-patAYhXC.js";
|
|
3
|
+
function d(r) {
|
|
4
|
+
const e = r.config instanceof Error ? r.config : s(r.config), t = r.outcome;
|
|
5
|
+
let n = !1;
|
|
6
|
+
return {
|
|
7
|
+
getConfig() {
|
|
8
|
+
return n ? Promise.reject(i()) : e instanceof Error ? Promise.reject(e) : Promise.resolve(s(e));
|
|
9
|
+
},
|
|
10
|
+
open(c) {
|
|
11
|
+
if (n) return Promise.reject(i());
|
|
12
|
+
let o;
|
|
13
|
+
try {
|
|
14
|
+
o = m(c);
|
|
15
|
+
} catch (u) {
|
|
16
|
+
return Promise.reject(u);
|
|
17
|
+
}
|
|
18
|
+
return e instanceof Error ? Promise.reject(e) : o.provider !== void 0 && !e.providers.includes(o.provider) ? Promise.reject(a()) : t instanceof Error ? Promise.reject(t) : t === "PAID" ? Promise.resolve({
|
|
19
|
+
status: "PAID",
|
|
20
|
+
work: { ...e.work },
|
|
21
|
+
amountCents: o.amountCents,
|
|
22
|
+
currency: "CNY"
|
|
23
|
+
}) : Promise.resolve({ status: t });
|
|
24
|
+
},
|
|
25
|
+
destroy() {
|
|
26
|
+
n = !0;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function s(r) {
|
|
31
|
+
return {
|
|
32
|
+
work: { ...r.work },
|
|
33
|
+
workKey: r.workKey,
|
|
34
|
+
environment: r.environment,
|
|
35
|
+
currency: r.currency,
|
|
36
|
+
amount: { ...r.amount },
|
|
37
|
+
providers: [...r.providers]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
d as createTestTip
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../../src/tip/testing.ts"],"sourcesContent":["import { clientDestroyed } from '../core/errors.ts';\nimport type { TipClient, TipConfig, TipOpenOptions, TipOpenResult } from './index.ts';\nimport { parseTipOpenOptions, tipOptionInvalid } from './validation.ts';\n\nexport type TipTestOutcome = 'PAID' | 'CANCELLED' | 'UNKNOWN' | Error;\n\nexport interface TipTestOptions {\n config: TipConfig | Error;\n outcome: TipTestOutcome;\n}\n\n/** Deterministic TipClient fake for component tests and Storybook stories. */\nexport function createTestTip(options: TipTestOptions): TipClient {\n const config = options.config instanceof Error ? options.config : copyConfig(options.config);\n const outcome = options.outcome;\n let destroyed = false;\n\n return {\n getConfig(): Promise<TipConfig> {\n if (destroyed) return Promise.reject(clientDestroyed());\n if (config instanceof Error) return Promise.reject(config);\n return Promise.resolve(copyConfig(config));\n },\n\n open(openOptions: TipOpenOptions): Promise<TipOpenResult> {\n if (destroyed) return Promise.reject(clientDestroyed());\n let validated: TipOpenOptions;\n try {\n validated = parseTipOpenOptions(openOptions);\n } catch (error) {\n return Promise.reject(error);\n }\n if (config instanceof Error) return Promise.reject(config);\n if (validated.provider !== undefined && !config.providers.includes(validated.provider)) {\n return Promise.reject(tipOptionInvalid());\n }\n if (outcome instanceof Error) return Promise.reject(outcome);\n if (outcome === 'PAID') {\n return Promise.resolve({\n status: 'PAID',\n work: { ...config.work },\n amountCents: validated.amountCents,\n currency: 'CNY',\n });\n }\n return Promise.resolve({ status: outcome });\n },\n\n destroy(): void {\n destroyed = true;\n },\n };\n}\n\nfunction copyConfig(config: TipConfig): TipConfig {\n return {\n work: { ...config.work },\n workKey: config.workKey,\n environment: config.environment,\n currency: config.currency,\n amount: { ...config.amount },\n providers: [...config.providers],\n };\n}\n"],"names":["createTestTip","options","config","copyConfig","outcome","destroyed","clientDestroyed","openOptions","validated","parseTipOpenOptions","error","tipOptionInvalid"],"mappings":";;AAYO,SAASA,EAAcC,GAAoC;AAChE,QAAMC,IAASD,EAAQ,kBAAkB,QAAQA,EAAQ,SAASE,EAAWF,EAAQ,MAAM,GACrFG,IAAUH,EAAQ;AACxB,MAAII,IAAY;AAEhB,SAAO;AAAA,IACL,YAAgC;AAC9B,aAAIA,IAAkB,QAAQ,OAAOC,GAAiB,IAClDJ,aAAkB,QAAc,QAAQ,OAAOA,CAAM,IAClD,QAAQ,QAAQC,EAAWD,CAAM,CAAC;AAAA,IAC3C;AAAA,IAEA,KAAKK,GAAqD;AACxD,UAAIF,EAAW,QAAO,QAAQ,OAAOC,GAAiB;AACtD,UAAIE;AACJ,UAAI;AACF,QAAAA,IAAYC,EAAoBF,CAAW;AAAA,MAC7C,SAASG,GAAO;AACd,eAAO,QAAQ,OAAOA,CAAK;AAAA,MAC7B;AACA,aAAIR,aAAkB,QAAc,QAAQ,OAAOA,CAAM,IACrDM,EAAU,aAAa,UAAa,CAACN,EAAO,UAAU,SAASM,EAAU,QAAQ,IAC5E,QAAQ,OAAOG,GAAkB,IAEtCP,aAAmB,QAAc,QAAQ,OAAOA,CAAO,IACvDA,MAAY,SACP,QAAQ,QAAQ;AAAA,QACrB,QAAQ;AAAA,QACR,MAAM,EAAE,GAAGF,EAAO,KAAA;AAAA,QAClB,aAAaM,EAAU;AAAA,QACvB,UAAU;AAAA,MAAA,CACX,IAEI,QAAQ,QAAQ,EAAE,QAAQJ,GAAS;AAAA,IAC5C;AAAA,IAEA,UAAgB;AACd,MAAAC,IAAY;AAAA,IACd;AAAA,EAAA;AAEJ;AAEA,SAASF,EAAWD,GAA8B;AAChD,SAAO;AAAA,IACL,MAAM,EAAE,GAAGA,EAAO,KAAA;AAAA,IAClB,SAASA,EAAO;AAAA,IAChB,aAAaA,EAAO;AAAA,IACpB,UAAUA,EAAO;AAAA,IACjB,QAAQ,EAAE,GAAGA,EAAO,OAAA;AAAA,IACpB,WAAW,CAAC,GAAGA,EAAO,SAAS;AAAA,EAAA;AAEnC;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ViceMeError } from '../core/errors.ts';
|
|
2
|
+
import type { TipOpenOptions, TipProvider } from './index.ts';
|
|
3
|
+
export declare function isTipProvider(value: unknown): value is TipProvider;
|
|
4
|
+
export declare function isValidTipWorkTitle(value: unknown): value is string;
|
|
5
|
+
export declare function tipOptionInvalid(): ViceMeError;
|
|
6
|
+
export declare function parseTipOpenOptions(input: unknown): TipOpenOptions;
|
|
7
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/tip/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAU9D,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAInE;AAED,wBAAgB,gBAAgB,IAAI,WAAW,CAO9C;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAkClE"}
|