@viceme-ai/sdk 0.4.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.
Files changed (55) hide show
  1. package/README.md +105 -16
  2. package/dist/browser-events.d.ts +5 -2
  3. package/dist/browser-events.d.ts.map +1 -1
  4. package/dist/chunks/build-endpoints-NrDmg6jf.js +12 -0
  5. package/dist/chunks/build-endpoints-NrDmg6jf.js.map +1 -0
  6. package/dist/chunks/{client-Cbldd7F2.js → client-w9vih8Ng.js} +267 -238
  7. package/dist/chunks/client-w9vih8Ng.js.map +1 -0
  8. package/dist/chunks/{errors-B-Qv_azy.js → errors-C7DfLKcF.js} +14 -22
  9. package/dist/chunks/errors-C7DfLKcF.js.map +1 -0
  10. package/dist/chunks/validation-patAYhXC.js +43 -0
  11. package/dist/chunks/validation-patAYhXC.js.map +1 -0
  12. package/dist/chunks/version-uPTHb89K.js +6 -0
  13. package/dist/chunks/{version-C8DeBm39.js.map → version-uPTHb89K.js.map} +1 -1
  14. package/dist/core/capabilities.d.ts +2 -0
  15. package/dist/core/capabilities.d.ts.map +1 -1
  16. package/dist/core/client.d.ts.map +1 -1
  17. package/dist/core/config.d.ts +1 -1
  18. package/dist/core/config.d.ts.map +1 -1
  19. package/dist/core/errors.d.ts +1 -1
  20. package/dist/core/errors.d.ts.map +1 -1
  21. package/dist/core/presentation.d.ts.map +1 -1
  22. package/dist/danmaku.js +5 -4
  23. package/dist/danmaku.js.map +1 -1
  24. package/dist/generated/public-contract.d.ts +108 -1
  25. package/dist/generated/public-contract.d.ts.map +1 -1
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +4 -4
  28. package/dist/index.js.map +1 -1
  29. package/dist/manifest.json +49 -37
  30. package/dist/testing.js +14 -14
  31. package/dist/testing.js.map +1 -1
  32. package/dist/tip/headless.d.ts +4 -0
  33. package/dist/tip/headless.d.ts.map +1 -0
  34. package/dist/tip/index.d.ts +47 -2
  35. package/dist/tip/index.d.ts.map +1 -1
  36. package/dist/tip/mount.d.ts.map +1 -1
  37. package/dist/tip/testing.d.ts +9 -0
  38. package/dist/tip/testing.d.ts.map +1 -0
  39. package/dist/tip/testing.js +43 -0
  40. package/dist/tip/testing.js.map +1 -0
  41. package/dist/tip/validation.d.ts +7 -0
  42. package/dist/tip/validation.d.ts.map +1 -0
  43. package/dist/tip.js +419 -84
  44. package/dist/tip.js.map +1 -1
  45. package/dist/version.d.ts +1 -1
  46. package/dist/viceme.min.js +5 -2
  47. package/dist/viceme.min.js.map +1 -1
  48. package/package.json +7 -6
  49. package/dist/bootstrap.min.js +0 -2
  50. package/dist/bootstrap.min.js.map +0 -1
  51. package/dist/chunks/client-Cbldd7F2.js.map +0 -1
  52. package/dist/chunks/errors-B-Qv_azy.js.map +0 -1
  53. package/dist/chunks/version-C8DeBm39.js +0 -6
  54. package/dist/loader/bootstrap.d.ts +0 -1
  55. package/dist/loader/bootstrap.d.ts.map +0 -1
@@ -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/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 valid workKey (\"wrk_…\").');\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',\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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AAAA,MACjB,QAAQA,EAAQ;AAAA,MAChB,QAAQA,EAAQ;AAAA,IAAA;AAAA,IAElB,WAAWA,EAAQ;AAAA,IACnB,WAAWA,EAAQ;AAAA,IACnB,GAAIA,EAAQ,QAAQ,SAAY,EAAE,KAAKA,EAAQ,QAAQ,CAAA;AAAA,EAAC,CACzD;AACH;AAGO,MAAMe,IAA2C;AAAA,EACtD,KAAK;AAAA,EACL,cAAc,CAAC,SAAS;AAAA,EACxB,OAAO;AACT;"}
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,S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EACxB,OAAO;AACT;"}
@@ -0,0 +1,4 @@
1
+ import type { ViceMeClient } from '../core/client.ts';
2
+ import type { TipClient } from './index.ts';
3
+ export declare function createHeadlessTip(client: ViceMeClient): TipClient;
4
+ //# sourceMappingURL=headless.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headless.d.ts","sourceRoot":"","sources":["../../src/tip/headless.ts"],"names":[],"mappings":"AAAA,OAAO,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"}
@@ -1,4 +1,44 @@
1
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
+ }
2
42
  export interface TipMountOptions {
3
43
  target: Element;
4
44
  theme: 'light' | 'dark' | 'auto';
@@ -12,11 +52,16 @@ export interface TipWidgetCloseDetail {
12
52
  workId: string;
13
53
  }
14
54
  export interface TipPaidDetail {
15
- workId: string;
16
- orderNo: string;
17
55
  status: 'PAID';
56
+ work: {
57
+ id: string;
58
+ title: string;
59
+ };
18
60
  amountCents: number;
61
+ currency: 'CNY';
19
62
  }
63
+ /** Create a framework-independent controller for a host-rendered Tip flow. */
64
+ export declare function createTip(client: ViceMeClient): TipClient;
20
65
  /** Explicit ESM/npm entry point; the CDN loader calls the same mount function. */
21
66
  export declare function mountTip(client: ViceMeClient, options: TipMountOptions): Promise<TipMountHandle>;
22
67
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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;AAGtD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAID,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAgChG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tip/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA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AAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC;CACjB;AAID,8EAA8E;AAC9E,wBAAgB,SAAS,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"}
@@ -1 +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;AAM5C,wBAAsB,KAAK,CACzB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAsLhC"}
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"}