@dodopayments/better-auth 1.3.6 → 1.4.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.
@@ -0,0 +1,177 @@
1
+ import * as better_call from 'better-call';
2
+ import { DodoPayments } from 'dodopayments';
3
+ import { Event } from 'dodopayments/resources/usage-events.mjs';
4
+ import { z } from 'zod/v3';
5
+
6
+ declare const usage: () => (dodopayments: DodoPayments) => {
7
+ dodoUsageIngest: {
8
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
9
+ body: {
10
+ event_id: string;
11
+ event_name: string;
12
+ metadata?: Record<string, string | number | boolean> | null | undefined;
13
+ timestamp?: Date | undefined;
14
+ };
15
+ } & {
16
+ method?: "POST" | undefined;
17
+ } & {
18
+ query?: Record<string, any> | undefined;
19
+ } & {
20
+ params?: Record<string, any>;
21
+ } & {
22
+ request?: Request;
23
+ } & {
24
+ headers?: HeadersInit;
25
+ } & {
26
+ asResponse?: boolean;
27
+ returnHeaders?: boolean;
28
+ use?: better_call.Middleware[];
29
+ path?: string;
30
+ } & {
31
+ asResponse?: AsResponse | undefined;
32
+ returnHeaders?: ReturnHeaders | undefined;
33
+ }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
34
+ headers: Headers;
35
+ response: {
36
+ ingested_count: number;
37
+ };
38
+ } : {
39
+ ingested_count: number;
40
+ }>;
41
+ options: {
42
+ method: "POST";
43
+ body: z.ZodObject<{
44
+ event_id: z.ZodString;
45
+ event_name: z.ZodString;
46
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
47
+ timestamp: z.ZodOptional<z.ZodEffects<z.ZodDate, string, Date>>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ event_id: string;
50
+ event_name: string;
51
+ metadata?: Record<string, string | number | boolean> | null | undefined;
52
+ timestamp?: string | undefined;
53
+ }, {
54
+ event_id: string;
55
+ event_name: string;
56
+ metadata?: Record<string, string | number | boolean> | null | undefined;
57
+ timestamp?: Date | undefined;
58
+ }>;
59
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
60
+ session: {
61
+ session: Record<string, any> & {
62
+ id: string;
63
+ userId: string;
64
+ expiresAt: Date;
65
+ createdAt: Date;
66
+ updatedAt: Date;
67
+ token: string;
68
+ ipAddress?: string | null | undefined;
69
+ userAgent?: string | null | undefined;
70
+ };
71
+ user: Record<string, any> & {
72
+ id: string;
73
+ email: string;
74
+ emailVerified: boolean;
75
+ name: string;
76
+ createdAt: Date;
77
+ updatedAt: Date;
78
+ image?: string | null | undefined;
79
+ };
80
+ };
81
+ }>)[];
82
+ } & {
83
+ use: any[];
84
+ };
85
+ path: "/dodopayments/usage/ingest";
86
+ };
87
+ dodoUsageMetersList: {
88
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
89
+ body?: undefined;
90
+ } & {
91
+ method?: "GET" | undefined;
92
+ } & {
93
+ query?: {
94
+ event_name?: string | undefined;
95
+ page_number?: number | undefined;
96
+ page_size?: number | undefined;
97
+ meter_id?: string | undefined;
98
+ start?: string | undefined;
99
+ end?: string | undefined;
100
+ } | undefined;
101
+ } & {
102
+ params?: Record<string, any>;
103
+ } & {
104
+ request?: Request;
105
+ } & {
106
+ headers?: HeadersInit;
107
+ } & {
108
+ asResponse?: boolean;
109
+ returnHeaders?: boolean;
110
+ use?: better_call.Middleware[];
111
+ path?: string;
112
+ } & {
113
+ asResponse?: AsResponse | undefined;
114
+ returnHeaders?: ReturnHeaders | undefined;
115
+ }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
116
+ headers: Headers;
117
+ response: {
118
+ items: Event[];
119
+ };
120
+ } : {
121
+ items: Event[];
122
+ }>;
123
+ options: {
124
+ method: "GET";
125
+ query: z.ZodOptional<z.ZodObject<{
126
+ page_number: z.ZodOptional<z.ZodNumber>;
127
+ page_size: z.ZodOptional<z.ZodNumber>;
128
+ event_name: z.ZodOptional<z.ZodString>;
129
+ meter_id: z.ZodOptional<z.ZodString>;
130
+ start: z.ZodOptional<z.ZodString>;
131
+ end: z.ZodOptional<z.ZodString>;
132
+ }, "strip", z.ZodTypeAny, {
133
+ event_name?: string | undefined;
134
+ page_number?: number | undefined;
135
+ page_size?: number | undefined;
136
+ meter_id?: string | undefined;
137
+ start?: string | undefined;
138
+ end?: string | undefined;
139
+ }, {
140
+ event_name?: string | undefined;
141
+ page_number?: number | undefined;
142
+ page_size?: number | undefined;
143
+ meter_id?: string | undefined;
144
+ start?: string | undefined;
145
+ end?: string | undefined;
146
+ }>>;
147
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
148
+ session: {
149
+ session: Record<string, any> & {
150
+ id: string;
151
+ userId: string;
152
+ expiresAt: Date;
153
+ createdAt: Date;
154
+ updatedAt: Date;
155
+ token: string;
156
+ ipAddress?: string | null | undefined;
157
+ userAgent?: string | null | undefined;
158
+ };
159
+ user: Record<string, any> & {
160
+ id: string;
161
+ email: string;
162
+ emailVerified: boolean;
163
+ name: string;
164
+ createdAt: Date;
165
+ updatedAt: Date;
166
+ image?: string | null | undefined;
167
+ };
168
+ };
169
+ }>)[];
170
+ } & {
171
+ use: any[];
172
+ };
173
+ path: "/dodopayments/usage/meters/list";
174
+ };
175
+ };
176
+
177
+ export { usage };
@@ -0,0 +1,177 @@
1
+ import * as better_call from 'better-call';
2
+ import { DodoPayments } from 'dodopayments';
3
+ import { Event } from 'dodopayments/resources/usage-events.mjs';
4
+ import { z } from 'zod/v3';
5
+
6
+ declare const usage: () => (dodopayments: DodoPayments) => {
7
+ dodoUsageIngest: {
8
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
9
+ body: {
10
+ event_id: string;
11
+ event_name: string;
12
+ metadata?: Record<string, string | number | boolean> | null | undefined;
13
+ timestamp?: Date | undefined;
14
+ };
15
+ } & {
16
+ method?: "POST" | undefined;
17
+ } & {
18
+ query?: Record<string, any> | undefined;
19
+ } & {
20
+ params?: Record<string, any>;
21
+ } & {
22
+ request?: Request;
23
+ } & {
24
+ headers?: HeadersInit;
25
+ } & {
26
+ asResponse?: boolean;
27
+ returnHeaders?: boolean;
28
+ use?: better_call.Middleware[];
29
+ path?: string;
30
+ } & {
31
+ asResponse?: AsResponse | undefined;
32
+ returnHeaders?: ReturnHeaders | undefined;
33
+ }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
34
+ headers: Headers;
35
+ response: {
36
+ ingested_count: number;
37
+ };
38
+ } : {
39
+ ingested_count: number;
40
+ }>;
41
+ options: {
42
+ method: "POST";
43
+ body: z.ZodObject<{
44
+ event_id: z.ZodString;
45
+ event_name: z.ZodString;
46
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
47
+ timestamp: z.ZodOptional<z.ZodEffects<z.ZodDate, string, Date>>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ event_id: string;
50
+ event_name: string;
51
+ metadata?: Record<string, string | number | boolean> | null | undefined;
52
+ timestamp?: string | undefined;
53
+ }, {
54
+ event_id: string;
55
+ event_name: string;
56
+ metadata?: Record<string, string | number | boolean> | null | undefined;
57
+ timestamp?: Date | undefined;
58
+ }>;
59
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
60
+ session: {
61
+ session: Record<string, any> & {
62
+ id: string;
63
+ userId: string;
64
+ expiresAt: Date;
65
+ createdAt: Date;
66
+ updatedAt: Date;
67
+ token: string;
68
+ ipAddress?: string | null | undefined;
69
+ userAgent?: string | null | undefined;
70
+ };
71
+ user: Record<string, any> & {
72
+ id: string;
73
+ email: string;
74
+ emailVerified: boolean;
75
+ name: string;
76
+ createdAt: Date;
77
+ updatedAt: Date;
78
+ image?: string | null | undefined;
79
+ };
80
+ };
81
+ }>)[];
82
+ } & {
83
+ use: any[];
84
+ };
85
+ path: "/dodopayments/usage/ingest";
86
+ };
87
+ dodoUsageMetersList: {
88
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
89
+ body?: undefined;
90
+ } & {
91
+ method?: "GET" | undefined;
92
+ } & {
93
+ query?: {
94
+ event_name?: string | undefined;
95
+ page_number?: number | undefined;
96
+ page_size?: number | undefined;
97
+ meter_id?: string | undefined;
98
+ start?: string | undefined;
99
+ end?: string | undefined;
100
+ } | undefined;
101
+ } & {
102
+ params?: Record<string, any>;
103
+ } & {
104
+ request?: Request;
105
+ } & {
106
+ headers?: HeadersInit;
107
+ } & {
108
+ asResponse?: boolean;
109
+ returnHeaders?: boolean;
110
+ use?: better_call.Middleware[];
111
+ path?: string;
112
+ } & {
113
+ asResponse?: AsResponse | undefined;
114
+ returnHeaders?: ReturnHeaders | undefined;
115
+ }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
116
+ headers: Headers;
117
+ response: {
118
+ items: Event[];
119
+ };
120
+ } : {
121
+ items: Event[];
122
+ }>;
123
+ options: {
124
+ method: "GET";
125
+ query: z.ZodOptional<z.ZodObject<{
126
+ page_number: z.ZodOptional<z.ZodNumber>;
127
+ page_size: z.ZodOptional<z.ZodNumber>;
128
+ event_name: z.ZodOptional<z.ZodString>;
129
+ meter_id: z.ZodOptional<z.ZodString>;
130
+ start: z.ZodOptional<z.ZodString>;
131
+ end: z.ZodOptional<z.ZodString>;
132
+ }, "strip", z.ZodTypeAny, {
133
+ event_name?: string | undefined;
134
+ page_number?: number | undefined;
135
+ page_size?: number | undefined;
136
+ meter_id?: string | undefined;
137
+ start?: string | undefined;
138
+ end?: string | undefined;
139
+ }, {
140
+ event_name?: string | undefined;
141
+ page_number?: number | undefined;
142
+ page_size?: number | undefined;
143
+ meter_id?: string | undefined;
144
+ start?: string | undefined;
145
+ end?: string | undefined;
146
+ }>>;
147
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
148
+ session: {
149
+ session: Record<string, any> & {
150
+ id: string;
151
+ userId: string;
152
+ expiresAt: Date;
153
+ createdAt: Date;
154
+ updatedAt: Date;
155
+ token: string;
156
+ ipAddress?: string | null | undefined;
157
+ userAgent?: string | null | undefined;
158
+ };
159
+ user: Record<string, any> & {
160
+ id: string;
161
+ email: string;
162
+ emailVerified: boolean;
163
+ name: string;
164
+ createdAt: Date;
165
+ updatedAt: Date;
166
+ image?: string | null | undefined;
167
+ };
168
+ };
169
+ }>)[];
170
+ } & {
171
+ use: any[];
172
+ };
173
+ path: "/dodopayments/usage/meters/list";
174
+ };
175
+ };
176
+
177
+ export { usage };
@@ -0,0 +1,7 @@
1
+ import {
2
+ usage
3
+ } from "../chunk-47N33D2M.js";
4
+ export {
5
+ usage
6
+ };
7
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,8 @@
1
1
  import 'better-call';
2
2
  import 'dodopayments';
3
3
  import '@dodopayments/core/webhook';
4
- export { w as webhooks } from '../types-D8DKNcM-.cjs';
4
+ export { w as webhooks } from '../types-BxuQGgnN.cjs';
5
5
  import 'better-auth';
6
6
  import 'zod/v3';
7
+ import './usage.cjs';
8
+ import 'dodopayments/resources/usage-events.mjs';
@@ -1,6 +1,8 @@
1
1
  import 'better-call';
2
2
  import 'dodopayments';
3
3
  import '@dodopayments/core/webhook';
4
- export { w as webhooks } from '../types-D8DKNcM-.js';
4
+ export { w as webhooks } from '../types-D2QzXmgc.js';
5
5
  import 'better-auth';
6
6
  import 'zod/v3';
7
+ import './usage.js';
8
+ import 'dodopayments/resources/usage-events.mjs';
@@ -3,6 +3,7 @@ import { UnionToIntersection } from 'better-auth';
3
3
  import * as better_call from 'better-call';
4
4
  import { z } from 'zod/v3';
5
5
  import { WebhookHandlerConfig } from '@dodopayments/core/webhook';
6
+ import { usage } from './plugins/usage.cjs';
6
7
 
7
8
  interface CheckoutOptions {
8
9
  /**
@@ -913,7 +914,7 @@ type Product = {
913
914
  */
914
915
  slug: string;
915
916
  };
916
- type DodoPaymentsPlugin = ReturnType<typeof checkout> | ReturnType<typeof portal> | ReturnType<typeof webhooks>;
917
+ type DodoPaymentsPlugin = ReturnType<typeof checkout> | ReturnType<typeof portal> | ReturnType<typeof webhooks> | ReturnType<typeof usage>;
917
918
  type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];
918
919
  type DodoPaymentsEndpoints = UnionToIntersection<ReturnType<DodoPaymentsPlugin>>;
919
920
  interface DodoPaymentsOptions {
@@ -3,6 +3,7 @@ import { UnionToIntersection } from 'better-auth';
3
3
  import * as better_call from 'better-call';
4
4
  import { z } from 'zod/v3';
5
5
  import { WebhookHandlerConfig } from '@dodopayments/core/webhook';
6
+ import { usage } from './plugins/usage.js';
6
7
 
7
8
  interface CheckoutOptions {
8
9
  /**
@@ -913,7 +914,7 @@ type Product = {
913
914
  */
914
915
  slug: string;
915
916
  };
916
- type DodoPaymentsPlugin = ReturnType<typeof checkout> | ReturnType<typeof portal> | ReturnType<typeof webhooks>;
917
+ type DodoPaymentsPlugin = ReturnType<typeof checkout> | ReturnType<typeof portal> | ReturnType<typeof webhooks> | ReturnType<typeof usage>;
917
918
  type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];
918
919
  type DodoPaymentsEndpoints = UnionToIntersection<ReturnType<DodoPaymentsPlugin>>;
919
920
  interface DodoPaymentsOptions {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DodoPayments } from \"dodopayments\";\n\nimport type { UnionToIntersection } from \"better-auth\";\nimport type { checkout } from \"./plugins/checkout\";\nimport type { portal } from \"./plugins/portal\";\nimport type { webhooks } from \"./plugins/webhooks\";\n\nexport type Product = {\n /**\n * Product Id from DodoPayments Product\n */\n productId: string;\n /**\n * Easily identifiable slug for the product\n */\n slug: string;\n};\n\nexport type DodoPaymentsPlugin =\n | ReturnType<typeof checkout>\n | ReturnType<typeof portal>\n | ReturnType<typeof webhooks>;\n\nexport type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];\n\nexport type DodoPaymentsEndpoints = UnionToIntersection<\n ReturnType<DodoPaymentsPlugin>\n>;\n\nexport interface DodoPaymentsOptions {\n /**\n * DodoPayments Client\n */\n client: DodoPayments;\n /**\n * Enable customer creation when a user signs up\n */\n createCustomerOnSignUp?: boolean;\n /**\n * Use DodoPayments plugins\n */\n use: DodoPaymentsPlugins;\n}\n\ntype PaymentsList = Awaited<ReturnType<DodoPayments[\"payments\"][\"list\"]>>;\ntype SubscriptionsList = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"list\"]>\n>;\nexport type PaymentItems = { items: PaymentsList[\"items\"] };\nexport type SubscriptionItems = { items: SubscriptionsList[\"items\"] };\nexport type CustomerPortalResponse = { url: string; redirect: boolean };\nexport type CreateCheckoutResponse = { url: string; redirect: boolean };\nexport type WebhookResponse = { received: boolean };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DodoPayments } from \"dodopayments\";\n\nimport type { UnionToIntersection } from \"better-auth\";\nimport type { checkout } from \"./plugins/checkout\";\nimport type { portal } from \"./plugins/portal\";\nimport type { webhooks } from \"./plugins/webhooks\";\nimport { usage } from \"./plugins/usage\";\n\nexport type Product = {\n /**\n * Product Id from DodoPayments Product\n */\n productId: string;\n /**\n * Easily identifiable slug for the product\n */\n slug: string;\n};\n\nexport type DodoPaymentsPlugin =\n | ReturnType<typeof checkout>\n | ReturnType<typeof portal>\n | ReturnType<typeof webhooks>\n | ReturnType<typeof usage>;\n\nexport type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];\n\nexport type DodoPaymentsEndpoints = UnionToIntersection<\n ReturnType<DodoPaymentsPlugin>\n>;\n\nexport interface DodoPaymentsOptions {\n /**\n * DodoPayments Client\n */\n client: DodoPayments;\n /**\n * Enable customer creation when a user signs up\n */\n createCustomerOnSignUp?: boolean;\n /**\n * Use DodoPayments plugins\n */\n use: DodoPaymentsPlugins;\n}\n\ntype PaymentsList = Awaited<ReturnType<DodoPayments[\"payments\"][\"list\"]>>;\ntype SubscriptionsList = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"list\"]>\n>;\nexport type PaymentItems = { items: PaymentsList[\"items\"] };\nexport type SubscriptionItems = { items: SubscriptionsList[\"items\"] };\nexport type CustomerPortalResponse = { url: string; redirect: boolean };\nexport type CreateCheckoutResponse = { url: string; redirect: boolean };\nexport type WebhookResponse = { received: boolean };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/dist/types.d.cts CHANGED
@@ -1,6 +1,8 @@
1
1
  import 'dodopayments';
2
2
  import 'better-auth';
3
- export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-D8DKNcM-.cjs';
3
+ export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-BxuQGgnN.cjs';
4
+ import './plugins/usage.cjs';
4
5
  import 'better-call';
5
6
  import 'zod/v3';
6
7
  import '@dodopayments/core/webhook';
8
+ import 'dodopayments/resources/usage-events.mjs';
package/dist/types.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import 'dodopayments';
2
2
  import 'better-auth';
3
- export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-D8DKNcM-.js';
3
+ export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-D2QzXmgc.js';
4
+ import './plugins/usage.js';
4
5
  import 'better-call';
5
6
  import 'zod/v3';
6
7
  import '@dodopayments/core/webhook';
8
+ import 'dodopayments/resources/usage-events.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodopayments/better-auth",
3
- "version": "1.3.6",
3
+ "version": "1.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },