payweave 0.0.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +272 -0
  3. package/dist/_tsup-dts-rollup.d.ts +19470 -0
  4. package/dist/chunk-4R5OGOCC.js +94 -0
  5. package/dist/chunk-4R5OGOCC.js.map +1 -0
  6. package/dist/chunk-535Q3GUN.js +175 -0
  7. package/dist/chunk-535Q3GUN.js.map +1 -0
  8. package/dist/chunk-67NRYGRC.js +192 -0
  9. package/dist/chunk-67NRYGRC.js.map +1 -0
  10. package/dist/chunk-CGQ73I4I.js +568 -0
  11. package/dist/chunk-CGQ73I4I.js.map +1 -0
  12. package/dist/chunk-CJEYDHY6.js +18 -0
  13. package/dist/chunk-CJEYDHY6.js.map +1 -0
  14. package/dist/chunk-CR63JAAS.js +3 -0
  15. package/dist/chunk-CR63JAAS.js.map +1 -0
  16. package/dist/chunk-E633MKVX.js +1507 -0
  17. package/dist/chunk-E633MKVX.js.map +1 -0
  18. package/dist/chunk-FBPOCXRZ.js +1135 -0
  19. package/dist/chunk-FBPOCXRZ.js.map +1 -0
  20. package/dist/chunk-HTRGMZFH.js +267 -0
  21. package/dist/chunk-HTRGMZFH.js.map +1 -0
  22. package/dist/chunk-IUVGM3K7.js +765 -0
  23. package/dist/chunk-IUVGM3K7.js.map +1 -0
  24. package/dist/chunk-JD4OZHRI.js +326 -0
  25. package/dist/chunk-JD4OZHRI.js.map +1 -0
  26. package/dist/chunk-NV3MZF7L.js +139 -0
  27. package/dist/chunk-NV3MZF7L.js.map +1 -0
  28. package/dist/chunk-NXQBP35U.js +13 -0
  29. package/dist/chunk-NXQBP35U.js.map +1 -0
  30. package/dist/chunk-QJHXDZYC.js +412 -0
  31. package/dist/chunk-QJHXDZYC.js.map +1 -0
  32. package/dist/chunk-TWZK62TZ.js +83 -0
  33. package/dist/chunk-TWZK62TZ.js.map +1 -0
  34. package/dist/cli/index.js +35381 -0
  35. package/dist/core/index.d.ts +85 -0
  36. package/dist/core/index.js +6 -0
  37. package/dist/core/index.js.map +1 -0
  38. package/dist/db/drizzle/index.d.ts +6 -0
  39. package/dist/db/drizzle/index.js +1532 -0
  40. package/dist/db/drizzle/index.js.map +1 -0
  41. package/dist/db/index.d.ts +43 -0
  42. package/dist/db/index.js +3 -0
  43. package/dist/db/index.js.map +1 -0
  44. package/dist/db/mongodb/index.d.ts +3 -0
  45. package/dist/db/mongodb/index.js +934 -0
  46. package/dist/db/mongodb/index.js.map +1 -0
  47. package/dist/db/mysql/index.d.ts +1 -0
  48. package/dist/db/mysql/index.js +12 -0
  49. package/dist/db/mysql/index.js.map +1 -0
  50. package/dist/db/postgres/index.d.ts +5 -0
  51. package/dist/db/postgres/index.js +791 -0
  52. package/dist/db/postgres/index.js.map +1 -0
  53. package/dist/db/prisma/index.d.ts +1 -0
  54. package/dist/db/prisma/index.js +12 -0
  55. package/dist/db/prisma/index.js.map +1 -0
  56. package/dist/db/sqlite/index.d.ts +5 -0
  57. package/dist/db/sqlite/index.js +750 -0
  58. package/dist/db/sqlite/index.js.map +1 -0
  59. package/dist/express/index.d.ts +1 -0
  60. package/dist/express/index.js +3 -0
  61. package/dist/express/index.js.map +1 -0
  62. package/dist/fastify/index.d.ts +1 -0
  63. package/dist/fastify/index.js +3 -0
  64. package/dist/fastify/index.js.map +1 -0
  65. package/dist/flutterwave/index.d.ts +27 -0
  66. package/dist/flutterwave/index.js +9 -0
  67. package/dist/flutterwave/index.js.map +1 -0
  68. package/dist/index.d.ts +85 -0
  69. package/dist/index.js +3677 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/next/index.d.ts +1 -0
  72. package/dist/next/index.js +3 -0
  73. package/dist/next/index.js.map +1 -0
  74. package/dist/paystack/index.d.ts +33 -0
  75. package/dist/paystack/index.js +9 -0
  76. package/dist/paystack/index.js.map +1 -0
  77. package/dist/products/index.d.ts +22 -0
  78. package/dist/products/index.js +7 -0
  79. package/dist/products/index.js.map +1 -0
  80. package/dist/testing/index.d.ts +11 -0
  81. package/dist/testing/index.js +69 -0
  82. package/dist/testing/index.js.map +1 -0
  83. package/dist/unified/index.d.ts +41 -0
  84. package/dist/unified/index.js +6 -0
  85. package/dist/unified/index.js.map +1 -0
  86. package/dist/webhooks/index.d.ts +8 -0
  87. package/dist/webhooks/index.js +8 -0
  88. package/dist/webhooks/index.js.map +1 -0
  89. package/package.json +164 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,33 @@
1
+ export { PaystackClient_alias_2 as PaystackClient } from '../_tsup-dts-rollup.js';
2
+ export { Transactions_alias_2 as Transactions } from '../_tsup-dts-rollup.js';
3
+ export { Refunds_alias_2 as Refunds } from '../_tsup-dts-rollup.js';
4
+ export { Customers } from '../_tsup-dts-rollup.js';
5
+ export { Misc } from '../_tsup-dts-rollup.js';
6
+ export { TransferRecipients } from '../_tsup-dts-rollup.js';
7
+ export { Transfers_alias_2 as Transfers } from '../_tsup-dts-rollup.js';
8
+ export { Plans } from '../_tsup-dts-rollup.js';
9
+ export { Subscriptions } from '../_tsup-dts-rollup.js';
10
+ export { InitializeReq } from '../_tsup-dts-rollup.js';
11
+ export { ChargeAuthorizationReq } from '../_tsup-dts-rollup.js';
12
+ export { PartialDebitReq } from '../_tsup-dts-rollup.js';
13
+ export { TransactionListQuery_alias_1 as TransactionListQuery } from '../_tsup-dts-rollup.js';
14
+ export { TotalsQuery } from '../_tsup-dts-rollup.js';
15
+ export { CreateRefundReq_alias_2 as CreateRefundReq } from '../_tsup-dts-rollup.js';
16
+ export { ListRefundsQuery_alias_2 as ListRefundsQuery } from '../_tsup-dts-rollup.js';
17
+ export { CreateCustomerReq } from '../_tsup-dts-rollup.js';
18
+ export { UpdateCustomerReq } from '../_tsup-dts-rollup.js';
19
+ export { ListCustomersQuery } from '../_tsup-dts-rollup.js';
20
+ export { ValidateCustomerReq } from '../_tsup-dts-rollup.js';
21
+ export { SetRiskActionReq } from '../_tsup-dts-rollup.js';
22
+ export { ListBanksQuery } from '../_tsup-dts-rollup.js';
23
+ export { ResolveAccountQuery } from '../_tsup-dts-rollup.js';
24
+ export { ListStatesQuery } from '../_tsup-dts-rollup.js';
25
+ export { CreateRecipientReq } from '../_tsup-dts-rollup.js';
26
+ export { ListRecipientsQuery } from '../_tsup-dts-rollup.js';
27
+ export { InitiateTransferReq } from '../_tsup-dts-rollup.js';
28
+ export { ListTransfersQuery_alias_2 as ListTransfersQuery } from '../_tsup-dts-rollup.js';
29
+ export { CreatePlanReq } from '../_tsup-dts-rollup.js';
30
+ export { ListPlansQuery } from '../_tsup-dts-rollup.js';
31
+ export { CreateSubscriptionReq } from '../_tsup-dts-rollup.js';
32
+ export { ListSubscriptionsQuery } from '../_tsup-dts-rollup.js';
33
+ export { ToggleSubscriptionReq } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,9 @@
1
+ export { Customers, Misc, PaystackClient, Plans, Refunds, Subscriptions, Transactions, TransferRecipients, Transfers } from '../chunk-E633MKVX.js';
2
+ import '../chunk-IUVGM3K7.js';
3
+ import '../chunk-535Q3GUN.js';
4
+ import '../chunk-TWZK62TZ.js';
5
+ import '../chunk-NXQBP35U.js';
6
+ import '../chunk-67NRYGRC.js';
7
+ import '../chunk-HTRGMZFH.js';
8
+ //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,22 @@
1
+ export { advance } from '../_tsup-dts-rollup.js';
2
+ export { currentPeriod } from '../_tsup-dts-rollup.js';
3
+ export { DAY_MS_alias_1 as DAY_MS } from '../_tsup-dts-rollup.js';
4
+ export { WEEK_MS_alias_1 as WEEK_MS } from '../_tsup-dts-rollup.js';
5
+ export { BillingPeriod } from '../_tsup-dts-rollup.js';
6
+ export { ResetInterval } from '../_tsup-dts-rollup.js';
7
+ export { feature_alias_2 as feature } from '../_tsup-dts-rollup.js';
8
+ export { BooleanFeatureInclusion_alias_2 as BooleanFeatureInclusion } from '../_tsup-dts-rollup.js';
9
+ export { FeatureDef_alias_2 as FeatureDef } from '../_tsup-dts-rollup.js';
10
+ export { FeatureDefInput_alias_2 as FeatureDefInput } from '../_tsup-dts-rollup.js';
11
+ export { FeatureFn_alias_2 as FeatureFn } from '../_tsup-dts-rollup.js';
12
+ export { FeatureInclusion_alias_2 as FeatureInclusion } from '../_tsup-dts-rollup.js';
13
+ export { FeatureType_alias_2 as FeatureType } from '../_tsup-dts-rollup.js';
14
+ export { MeteredFeatureArg_alias_2 as MeteredFeatureArg } from '../_tsup-dts-rollup.js';
15
+ export { MeteredFeatureInclusion_alias_2 as MeteredFeatureInclusion } from '../_tsup-dts-rollup.js';
16
+ export { plan_alias_2 as plan } from '../_tsup-dts-rollup.js';
17
+ export { resolvePlanPricing } from '../_tsup-dts-rollup.js';
18
+ export { Plan_alias_1 as Plan } from '../_tsup-dts-rollup.js';
19
+ export { PlanDefInput_alias_1 as PlanDefInput } from '../_tsup-dts-rollup.js';
20
+ export { PlanPrice_alias_1 as PlanPrice } from '../_tsup-dts-rollup.js';
21
+ export { PlanPriceInput_alias_1 as PlanPriceInput } from '../_tsup-dts-rollup.js';
22
+ export { ResolvedPlanPrice_alias_1 as ResolvedPlanPrice } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,7 @@
1
+ import '../chunk-CR63JAAS.js';
2
+ export { feature, plan, resolvePlanPricing } from '../chunk-535Q3GUN.js';
3
+ import '../chunk-TWZK62TZ.js';
4
+ export { DAY_MS, WEEK_MS, advance, currentPeriod } from '../chunk-4R5OGOCC.js';
5
+ import '../chunk-HTRGMZFH.js';
6
+ //# sourceMappingURL=index.js.map
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,11 @@
1
+ export { signWebhook } from '../_tsup-dts-rollup.js';
2
+ export { SignWebhookProvider } from '../_tsup-dts-rollup.js';
3
+ export { SignWebhookOptions } from '../_tsup-dts-rollup.js';
4
+ export { SignedWebhook } from '../_tsup-dts-rollup.js';
5
+ export { loadFixture_alias_1 as loadFixture } from '../_tsup-dts-rollup.js';
6
+ export { loadFixtureAs_alias_1 as loadFixtureAs } from '../_tsup-dts-rollup.js';
7
+ export { LoadFixtureOptions_alias_1 as LoadFixtureOptions } from '../_tsup-dts-rollup.js';
8
+ export { createMswServer } from '../_tsup-dts-rollup.js';
9
+ export { createHandlers } from '../_tsup-dts-rollup.js';
10
+ export { MockRoute } from '../_tsup-dts-rollup.js';
11
+ export { MockMethod } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,69 @@
1
+ import { createHmac } from 'crypto';
2
+ import { readFileSync } from 'fs';
3
+ import { resolve } from 'path';
4
+
5
+ // src/testing/sign-webhook.ts
6
+ var HEADER_NAMES = {
7
+ paystack: "x-paystack-signature",
8
+ flutterwave: "verif-hash",
9
+ "flutterwave-v4": "flutterwave-signature",
10
+ stripe: "stripe-signature"
11
+ };
12
+ function toBody(payload) {
13
+ return typeof payload === "string" ? payload : JSON.stringify(payload);
14
+ }
15
+ function signWebhook(provider, payload, secret, options) {
16
+ const body = toBody(payload);
17
+ const headerName = HEADER_NAMES[provider];
18
+ let header;
19
+ switch (provider) {
20
+ case "paystack":
21
+ header = createHmac("sha512", secret).update(body).digest("hex");
22
+ break;
23
+ case "flutterwave":
24
+ header = secret;
25
+ break;
26
+ case "flutterwave-v4":
27
+ header = createHmac("sha256", secret).update(body).digest("base64");
28
+ break;
29
+ case "stripe": {
30
+ const timestamp = options?.timestamp ?? Math.floor(Date.now() / 1e3);
31
+ const signature = createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex");
32
+ header = `t=${timestamp},v1=${signature}`;
33
+ break;
34
+ }
35
+ }
36
+ return { headerName, header, body, headers: { [headerName]: header } };
37
+ }
38
+ function loadFixture(provider, resource, name, options = {}) {
39
+ const root = options.root ?? resolve(process.cwd(), "test", "fixtures");
40
+ const path = resolve(root, provider, resource, `${name}.json`);
41
+ return JSON.parse(readFileSync(path, "utf8"));
42
+ }
43
+ function loadFixtureAs(provider, resource, name, options = {}) {
44
+ return loadFixture(provider, resource, name, options);
45
+ }
46
+
47
+ // src/testing/msw.ts
48
+ async function loadMsw() {
49
+ return import('msw');
50
+ }
51
+ async function createHandlers(routes) {
52
+ const { http, HttpResponse } = await loadMsw();
53
+ return routes.map((route) => {
54
+ const resolver = () => HttpResponse.json(route.json ?? null, {
55
+ status: route.status ?? 200,
56
+ ...route.headers ? { headers: route.headers } : {}
57
+ });
58
+ return http[route.method](route.url, resolver);
59
+ });
60
+ }
61
+ async function createMswServer(routes = []) {
62
+ const { setupServer } = await import('msw/node');
63
+ const handlers = await createHandlers(routes);
64
+ return setupServer(...handlers);
65
+ }
66
+
67
+ export { createHandlers, createMswServer, loadFixture, loadFixtureAs, signWebhook };
68
+ //# sourceMappingURL=index.js.map
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/testing/sign-webhook.ts","../../src/testing/fixtures.ts","../../src/testing/msw.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["/**\n * `signWebhook` (PW-008, TDD §10) — produce valid header+body pairs matching\n * each provider's verify scheme, for consumer tests and our own. Consumers must\n * verify against the SAME `body` string returned here (verification runs on\n * exact bytes — never re-serialize).\n */\nimport { createHmac } from \"node:crypto\";\n\n/** Webhook schemes we can sign for. `flutterwave` = v3; `flutterwave-v4` = v4. */\nexport type SignWebhookProvider = \"paystack\" | \"flutterwave\" | \"flutterwave-v4\" | \"stripe\";\n\n/** Options for {@link signWebhook}. */\nexport interface SignWebhookOptions {\n /**\n * Unix-SECONDS timestamp for schemes that sign one (`stripe`'s `t=`).\n * Default: now. Ignored by schemes without a timestamp.\n */\n timestamp?: number;\n}\n\n/** A signed webhook: the exact body bytes plus the header to send with them. */\nexport interface SignedWebhook {\n /** Canonical header name for the scheme. */\n headerName: string;\n /** Header value (signature or secret hash). */\n header: string;\n /** Exact request body — pass THIS string to the verify function. */\n body: string;\n /** Convenience map: `{ [headerName]: header }`. */\n headers: Record<string, string>;\n}\n\nconst HEADER_NAMES: Record<SignWebhookProvider, string> = {\n paystack: \"x-paystack-signature\",\n flutterwave: \"verif-hash\",\n \"flutterwave-v4\": \"flutterwave-signature\",\n stripe: \"stripe-signature\",\n};\n\nfunction toBody(payload: unknown): string {\n return typeof payload === \"string\" ? payload : JSON.stringify(payload);\n}\n\n/**\n * Sign `payload` for `provider`, returning the header + the exact body to send.\n *\n * - `paystack`: HMAC-SHA512 hex, keyed with the secret key.\n * - `flutterwave` (v3): the secret hash itself (plain equality, no HMAC).\n * - `flutterwave-v4`: HMAC-SHA256 base64, keyed with the dashboard secret hash.\n * - `stripe`: `t=<unix seconds>,v1=<HMAC-SHA256 hex over `${t}.${body}`>`,\n * keyed with the endpoint signing secret (`whsec_*`); `options.timestamp`\n * overrides `t` for tolerance tests.\n *\n * @example\n * const { header, body, headerName } = signWebhook(\"paystack\", event, secret);\n * verifyPaystack(body, header, secret); // true\n */\nexport function signWebhook(\n provider: SignWebhookProvider,\n payload: unknown,\n secret: string,\n options?: SignWebhookOptions,\n): SignedWebhook {\n const body = toBody(payload);\n const headerName = HEADER_NAMES[provider];\n let header: string;\n switch (provider) {\n case \"paystack\":\n header = createHmac(\"sha512\", secret).update(body).digest(\"hex\");\n break;\n case \"flutterwave\":\n header = secret;\n break;\n case \"flutterwave-v4\":\n header = createHmac(\"sha256\", secret).update(body).digest(\"base64\");\n break;\n case \"stripe\": {\n const timestamp = options?.timestamp ?? Math.floor(Date.now() / 1000);\n const signature = createHmac(\"sha256\", secret)\n .update(`${timestamp}.${body}`)\n .digest(\"hex\");\n header = `t=${timestamp},v1=${signature}`;\n break;\n }\n }\n return { headerName, header, body, headers: { [headerName]: header } };\n}\n","/**\n * Fixture loader. Reads sanitized JSON fixtures from\n * `test/fixtures/<provider>/<resource>/<name>.json`. Fixtures must never carry\n * live secrets (CI regex gate enforces). Used by resource unit tests and by\n * consumers writing tests against the SDK.\n */\nimport { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/** Options for {@link loadFixture}. */\nexport interface LoadFixtureOptions {\n /** Fixtures root. Defaults to `<cwd>/test/fixtures`. */\n root?: string;\n}\n\n/**\n * Load and JSON-parse a fixture.\n *\n * @param provider - e.g. `\"paystack\"` / `\"flutterwave\"`.\n * @param resource - e.g. `\"transactions\"`.\n * @param name - Fixture file basename without extension, e.g. `\"initialize.success\"`.\n * @returns The parsed JSON (typed as `unknown` — narrow at the call site).\n */\nexport function loadFixture(\n provider: string,\n resource: string,\n name: string,\n options: LoadFixtureOptions = {},\n): unknown {\n const root = options.root ?? resolve(process.cwd(), \"test\", \"fixtures\");\n const path = resolve(root, provider, resource, `${name}.json`);\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\n/**\n * Typed variant of {@link loadFixture} — asserts the caller-supplied shape.\n * (No runtime validation; use a schema at the boundary for that.)\n */\nexport function loadFixtureAs<T>(\n provider: string,\n resource: string,\n name: string,\n options: LoadFixtureOptions = {},\n): T {\n return loadFixture(provider, resource, name, options) as T;\n}\n","/**\n * MSW network-edge mocking helpers (PW-008, TDD §13). Resource tests mock at\n * the network layer (never stub `HttpClient`/`fetch`). `msw` is an OPTIONAL peer\n * dependency, so it is loaded via dynamic `import()` — importing `payweave/testing`\n * for `signWebhook`/`loadFixture` alone never requires msw to be installed.\n */\nimport type { RequestHandler } from \"msw\";\nimport type { SetupServer } from \"msw/node\";\n\n/** HTTP methods a {@link MockRoute} can match. */\nexport type MockMethod = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\" | \"all\";\n\n/** Declarative mock route → compiled into an msw handler. */\nexport interface MockRoute {\n method: MockMethod;\n /** Absolute URL or path pattern (msw path syntax, e.g. `*\\/transaction/*`). */\n url: string;\n /** Response status (default 200). */\n status?: number;\n /** JSON body to respond with. */\n json?: unknown;\n /** Response headers. */\n headers?: Record<string, string>;\n}\n\nasync function loadMsw(): Promise<typeof import(\"msw\")> {\n return import(\"msw\");\n}\n\n/**\n * Compile declarative {@link MockRoute}s into msw request handlers. Async\n * because it lazily loads `msw`.\n */\nexport async function createHandlers(routes: MockRoute[]): Promise<RequestHandler[]> {\n const { http, HttpResponse } = await loadMsw();\n return routes.map((route) => {\n const resolver = (): Response =>\n HttpResponse.json((route.json ?? null) as Record<string, unknown> | null, {\n status: route.status ?? 200,\n ...(route.headers ? { headers: route.headers } : {}),\n });\n return http[route.method](route.url, resolver);\n });\n}\n\n/**\n * Create (but do not start) an msw `setupServer` seeded with the given routes.\n * Callers own the lifecycle: `server.listen()` / `server.resetHandlers()` /\n * `server.close()`. Async because it lazily loads `msw/node`.\n *\n * @example\n * const server = await createMswServer([\n * { method: \"post\", url: \"*\\/transaction/initialize\", json: fixture },\n * ]);\n * server.listen();\n */\nexport async function createMswServer(routes: MockRoute[] = []): Promise<SetupServer> {\n const { setupServer } = await import(\"msw/node\");\n const handlers = await createHandlers(routes);\n return setupServer(...handlers);\n}\n"]}
@@ -0,0 +1,41 @@
1
+ export { toUnifiedEventType } from '../_tsup-dts-rollup.js';
2
+ export { toUnifiedStatus } from '../_tsup-dts-rollup.js';
3
+ export { PAYSTACK_EVENT_MAP } from '../_tsup-dts-rollup.js';
4
+ export { FLUTTERWAVE_EVENT_MAP } from '../_tsup-dts-rollup.js';
5
+ export { FLUTTERWAVE_STATUS_SPLIT_MAP } from '../_tsup-dts-rollup.js';
6
+ export { STRIPE_EVENT_MAP } from '../_tsup-dts-rollup.js';
7
+ export { STRIPE_EVENT_STATUS_SPLIT_MAP } from '../_tsup-dts-rollup.js';
8
+ export { PAYSTACK_STATUS_MAP } from '../_tsup-dts-rollup.js';
9
+ export { FLUTTERWAVE_V3_STATUS_MAP } from '../_tsup-dts-rollup.js';
10
+ export { FLUTTERWAVE_V4_STATUS_MAP } from '../_tsup-dts-rollup.js';
11
+ export { STRIPE_STATUS_MAP } from '../_tsup-dts-rollup.js';
12
+ export { UNIFIED_CAPABILITY_MATRIX } from '../_tsup-dts-rollup.js';
13
+ export { isUnifiedOpSupported } from '../_tsup-dts-rollup.js';
14
+ export { assertUnifiedCapability } from '../_tsup-dts-rollup.js';
15
+ export { UnifiedEventType } from '../_tsup-dts-rollup.js';
16
+ export { UnifiedStatus } from '../_tsup-dts-rollup.js';
17
+ export { MappingProvider } from '../_tsup-dts-rollup.js';
18
+ export { MappingVersion } from '../_tsup-dts-rollup.js';
19
+ export { StripeEventStatusSplit } from '../_tsup-dts-rollup.js';
20
+ export { UnifiedOpName_alias_1 as UnifiedOpName } from '../_tsup-dts-rollup.js';
21
+ export { UnifiedOpCapability_alias_1 as UnifiedOpCapability } from '../_tsup-dts-rollup.js';
22
+ export { createPaystackUnified } from '../_tsup-dts-rollup.js';
23
+ export { createFlutterwaveUnified_alias_1 as createFlutterwaveUnified } from '../_tsup-dts-rollup.js';
24
+ export { generateReference } from '../_tsup-dts-rollup.js';
25
+ export { UnifiedNamespace_alias_1 as UnifiedNamespace } from '../_tsup-dts-rollup.js';
26
+ export { UnifiedAmount_alias_1 as UnifiedAmount } from '../_tsup-dts-rollup.js';
27
+ export { UnifiedCustomerInput_alias_1 as UnifiedCustomerInput } from '../_tsup-dts-rollup.js';
28
+ export { UnifiedCustomer_alias_1 as UnifiedCustomer } from '../_tsup-dts-rollup.js';
29
+ export { CheckoutCreateInput_alias_1 as CheckoutCreateInput } from '../_tsup-dts-rollup.js';
30
+ export { CheckoutCreateResult_alias_1 as CheckoutCreateResult } from '../_tsup-dts-rollup.js';
31
+ export { VerifyInput_alias_1 as VerifyInput } from '../_tsup-dts-rollup.js';
32
+ export { VerifyResult_alias_1 as VerifyResult } from '../_tsup-dts-rollup.js';
33
+ export { RefundCreateInput_alias_1 as RefundCreateInput } from '../_tsup-dts-rollup.js';
34
+ export { RefundCreateResult_alias_1 as RefundCreateResult } from '../_tsup-dts-rollup.js';
35
+ export { TransferRecipient_alias_1 as TransferRecipient } from '../_tsup-dts-rollup.js';
36
+ export { TransferCreateInput_alias_1 as TransferCreateInput } from '../_tsup-dts-rollup.js';
37
+ export { TransferCreateResult_alias_1 as TransferCreateResult } from '../_tsup-dts-rollup.js';
38
+ export { BanksListInput_alias_1 as BanksListInput } from '../_tsup-dts-rollup.js';
39
+ export { UnifiedBank_alias_1 as UnifiedBank } from '../_tsup-dts-rollup.js';
40
+ export { ResolveAccountInput_alias_1 as ResolveAccountInput } from '../_tsup-dts-rollup.js';
41
+ export { ResolvedAccountResult_alias_1 as ResolvedAccountResult } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,6 @@
1
+ export { createFlutterwaveUnified, createPaystackUnified, generateReference } from '../chunk-JD4OZHRI.js';
2
+ import '../chunk-TWZK62TZ.js';
3
+ export { FLUTTERWAVE_EVENT_MAP, FLUTTERWAVE_STATUS_SPLIT_MAP, FLUTTERWAVE_V3_STATUS_MAP, FLUTTERWAVE_V4_STATUS_MAP, PAYSTACK_EVENT_MAP, PAYSTACK_STATUS_MAP, STRIPE_EVENT_MAP, STRIPE_EVENT_STATUS_SPLIT_MAP, STRIPE_STATUS_MAP, UNIFIED_CAPABILITY_MATRIX, assertUnifiedCapability, isUnifiedOpSupported, toUnifiedEventType, toUnifiedStatus } from '../chunk-67NRYGRC.js';
4
+ import '../chunk-HTRGMZFH.js';
5
+ //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,8 @@
1
+ export { constructEvent } from '../_tsup-dts-rollup.js';
2
+ export { verifyPaystack } from '../_tsup-dts-rollup.js';
3
+ export { verifyFlutterwaveV3_alias_1 as verifyFlutterwaveV3 } from '../_tsup-dts-rollup.js';
4
+ export { verifyFlutterwaveV4_alias_1 as verifyFlutterwaveV4 } from '../_tsup-dts-rollup.js';
5
+ export { verifyStripe } from '../_tsup-dts-rollup.js';
6
+ export { WebhookProvider } from '../_tsup-dts-rollup.js';
7
+ export { WebhookEvent_alias_1 as WebhookEvent } from '../_tsup-dts-rollup.js';
8
+ export { ConstructEventParams } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,8 @@
1
+ export { constructEvent, verifyStripe } from '../chunk-CGQ73I4I.js';
2
+ import '../chunk-4R5OGOCC.js';
3
+ export { verifyPaystack } from '../chunk-NXQBP35U.js';
4
+ export { verifyFlutterwaveV3, verifyFlutterwaveV4 } from '../chunk-CJEYDHY6.js';
5
+ import '../chunk-67NRYGRC.js';
6
+ import '../chunk-HTRGMZFH.js';
7
+ //# sourceMappingURL=index.js.map
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json ADDED
@@ -0,0 +1,164 @@
1
+ {
2
+ "name": "payweave",
3
+ "version": "0.0.0",
4
+ "description": "One SDK, every provider, woven together — unified TypeScript SDK for Paystack and Flutterwave.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=20.19"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "bin": {
15
+ "payweave": "./dist/cli/index.js"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./core": {
23
+ "types": "./dist/core/index.d.ts",
24
+ "import": "./dist/core/index.js"
25
+ },
26
+ "./paystack": {
27
+ "types": "./dist/paystack/index.d.ts",
28
+ "import": "./dist/paystack/index.js"
29
+ },
30
+ "./flutterwave": {
31
+ "types": "./dist/flutterwave/index.d.ts",
32
+ "import": "./dist/flutterwave/index.js"
33
+ },
34
+ "./unified": {
35
+ "types": "./dist/unified/index.d.ts",
36
+ "import": "./dist/unified/index.js"
37
+ },
38
+ "./webhooks": {
39
+ "types": "./dist/webhooks/index.d.ts",
40
+ "import": "./dist/webhooks/index.js"
41
+ },
42
+ "./testing": {
43
+ "types": "./dist/testing/index.d.ts",
44
+ "import": "./dist/testing/index.js"
45
+ },
46
+ "./express": {
47
+ "types": "./dist/express/index.d.ts",
48
+ "import": "./dist/express/index.js"
49
+ },
50
+ "./next": {
51
+ "types": "./dist/next/index.d.ts",
52
+ "import": "./dist/next/index.js"
53
+ },
54
+ "./fastify": {
55
+ "types": "./dist/fastify/index.d.ts",
56
+ "import": "./dist/fastify/index.js"
57
+ },
58
+ "./products": {
59
+ "types": "./dist/products/index.d.ts",
60
+ "import": "./dist/products/index.js"
61
+ },
62
+ "./db": {
63
+ "types": "./dist/db/index.d.ts",
64
+ "import": "./dist/db/index.js"
65
+ },
66
+ "./db/prisma": {
67
+ "types": "./dist/db/prisma/index.d.ts",
68
+ "import": "./dist/db/prisma/index.js"
69
+ },
70
+ "./db/drizzle": {
71
+ "types": "./dist/db/drizzle/index.d.ts",
72
+ "import": "./dist/db/drizzle/index.js"
73
+ },
74
+ "./db/postgres": {
75
+ "types": "./dist/db/postgres/index.d.ts",
76
+ "import": "./dist/db/postgres/index.js"
77
+ },
78
+ "./db/mysql": {
79
+ "types": "./dist/db/mysql/index.d.ts",
80
+ "import": "./dist/db/mysql/index.js"
81
+ },
82
+ "./db/sqlite": {
83
+ "types": "./dist/db/sqlite/index.d.ts",
84
+ "import": "./dist/db/sqlite/index.js"
85
+ },
86
+ "./db/mongodb": {
87
+ "types": "./dist/db/mongodb/index.d.ts",
88
+ "import": "./dist/db/mongodb/index.js"
89
+ },
90
+ "./package.json": "./package.json"
91
+ },
92
+ "scripts": {
93
+ "build": "tsup && tsup --config tsup.cli.config.ts",
94
+ "dev": "tsup --watch",
95
+ "typecheck": "tsc --noEmit",
96
+ "test": "vitest run --coverage",
97
+ "test:types": "vitest run --typecheck",
98
+ "test:e2e": "vitest run --config e2e/vitest.config.ts",
99
+ "lint": "eslint .",
100
+ "format": "prettier --write .",
101
+ "check-exports": "node scripts/check-exports.mjs",
102
+ "check-imports": "node scripts/check-imports.mjs",
103
+ "check-bundle-isolation": "node scripts/check-bundle-isolation.mjs",
104
+ "check-cli-deps": "node scripts/check-cli-deps.mjs",
105
+ "test:cli-tarball": "node scripts/test-cli-tarball.mjs",
106
+ "check:attw": "attw --pack --profile esm-only",
107
+ "release": "changeset publish"
108
+ },
109
+ "dependencies": {
110
+ "zod": "^4.4.3"
111
+ },
112
+ "peerDependencies": {
113
+ "@libsql/client": "^0.17.4",
114
+ "better-sqlite3": "^12.11.1",
115
+ "drizzle-orm": ">=0.44.0 <1.0.0",
116
+ "mongodb": ">=6.0.0 <8.0.0",
117
+ "msw": "^2",
118
+ "pg": "^8.11.0"
119
+ },
120
+ "peerDependenciesMeta": {
121
+ "@libsql/client": {
122
+ "optional": true
123
+ },
124
+ "better-sqlite3": {
125
+ "optional": true
126
+ },
127
+ "drizzle-orm": {
128
+ "optional": true
129
+ },
130
+ "mongodb": {
131
+ "optional": true
132
+ },
133
+ "msw": {
134
+ "optional": true
135
+ },
136
+ "pg": {
137
+ "optional": true
138
+ }
139
+ },
140
+ "devDependencies": {
141
+ "@arethetypeswrong/cli": "^0.18.5",
142
+ "@clack/prompts": "^1.7.0",
143
+ "@libsql/client": "^0.17.4",
144
+ "@microsoft/api-extractor": "^7.52.0",
145
+ "@payweave/eslint-config": "workspace:*",
146
+ "@payweave/typescript-config": "workspace:*",
147
+ "@types/better-sqlite3": "^7.6.13",
148
+ "@types/pg": "^8.15.6",
149
+ "@vitest/coverage-v8": "^4.0.0",
150
+ "better-sqlite3": "^12.11.1",
151
+ "drizzle-kit": "0.31.10",
152
+ "drizzle-orm": "0.45.2",
153
+ "eslint": "^10.7.0",
154
+ "expect-type": "^1.2.0",
155
+ "jiti": "^2.7.0",
156
+ "mongodb": "^7.5.0",
157
+ "mri": "^1.2.0",
158
+ "msw": "^2.7.0",
159
+ "pg": "^8.22.0",
160
+ "tsup": "^8.5.0",
161
+ "typescript": "^6.0.3",
162
+ "vitest": "^4.0.0"
163
+ }
164
+ }