autumn-js 0.0.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 (52) hide show
  1. package/README.md +0 -0
  2. package/dist/react/client/AutumnContext.d.mts +9 -0
  3. package/dist/react/client/AutumnContext.d.ts +9 -0
  4. package/dist/react/client/AutumnContext.js +18 -0
  5. package/dist/react/client/AutumnContext.mjs +18 -0
  6. package/dist/react/client/AutumnProvider.d.mts +12 -0
  7. package/dist/react/client/AutumnProvider.d.ts +12 -0
  8. package/dist/react/client/AutumnProvider.js +22 -0
  9. package/dist/react/client/AutumnProvider.mjs +22 -0
  10. package/dist/react/client/cusTypes-BT7wlTNj.d.mts +67 -0
  11. package/dist/react/client/cusTypes-BT7wlTNj.d.ts +67 -0
  12. package/dist/react/client/error-TNbN4XE4.d.mts +6 -0
  13. package/dist/react/client/error-TNbN4XE4.d.ts +6 -0
  14. package/dist/react/client/hooks/useAutumn.d.mts +65 -0
  15. package/dist/react/client/hooks/useAutumn.d.ts +65 -0
  16. package/dist/react/client/hooks/useAutumn.js +74 -0
  17. package/dist/react/client/hooks/useAutumn.mjs +74 -0
  18. package/dist/react/client/hooks/useCustomer.d.mts +14 -0
  19. package/dist/react/client/hooks/useCustomer.d.ts +14 -0
  20. package/dist/react/client/hooks/useCustomer.js +44 -0
  21. package/dist/react/client/hooks/useCustomer.mjs +44 -0
  22. package/dist/react/index.d.mts +157 -0
  23. package/dist/react/index.d.ts +157 -0
  24. package/dist/react/index.js +28 -0
  25. package/dist/react/index.mjs +4 -0
  26. package/dist/react/server/cusActions.d.mts +140 -0
  27. package/dist/react/server/cusActions.d.ts +140 -0
  28. package/dist/react/server/cusActions.js +26 -0
  29. package/dist/react/server/cusActions.mjs +26 -0
  30. package/dist/react/server/genActions.d.mts +42 -0
  31. package/dist/react/server/genActions.d.ts +42 -0
  32. package/dist/react/server/genActions.js +41 -0
  33. package/dist/react/server/genActions.mjs +41 -0
  34. package/dist/react/server/genTypes-RkqyS6Mn.d.mts +152 -0
  35. package/dist/react/server/genTypes-RkqyS6Mn.d.ts +152 -0
  36. package/dist/sdk/cusTypes-B9fUPd5R.d.ts +68 -0
  37. package/dist/sdk/cusTypes-DEdFHlrl.d.mts +68 -0
  38. package/dist/sdk/customers.d.mts +2 -0
  39. package/dist/sdk/customers.d.ts +2 -0
  40. package/dist/sdk/general.d.mts +60 -0
  41. package/dist/sdk/general.d.ts +60 -0
  42. package/dist/sdk/index.d.mts +97 -0
  43. package/dist/sdk/index.d.ts +97 -0
  44. package/dist/sdk/index.js +245 -0
  45. package/dist/sdk/index.mjs +237 -0
  46. package/dist/sdk/prodEnums-BnhKkH4e.d.mts +26 -0
  47. package/dist/sdk/prodEnums-BnhKkH4e.d.ts +26 -0
  48. package/dist/sdk/products.d.mts +45 -0
  49. package/dist/sdk/products.d.ts +45 -0
  50. package/package.json +46 -0
  51. package/tsconfig.json +25 -0
  52. package/tsup.config.ts +78 -0
@@ -0,0 +1,157 @@
1
+ import * as react from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ declare enum AppEnv {
5
+ Sandbox = "sandbox",
6
+ Live = "live"
7
+ }
8
+
9
+ declare enum ProductItemInterval {
10
+ Minute = "minute",
11
+ Hour = "hour",
12
+ Day = "day",
13
+ Week = "week",
14
+ Month = "month",
15
+ Quarter = "quarter",
16
+ SemiAnnual = "semi_annual",
17
+ Year = "year"
18
+ }
19
+
20
+ declare enum ProductStatus {
21
+ Active = "active",
22
+ Expired = "expired",
23
+ Trialing = "trialing",
24
+ Scheduled = "scheduled"
25
+ }
26
+
27
+ interface CustomerFeature {
28
+ feature_id: string;
29
+ unlimited?: boolean;
30
+ interval?: ProductItemInterval | null;
31
+ balance?: number;
32
+ usage?: number;
33
+ included_usage?: number;
34
+ next_reset_at?: number;
35
+ }
36
+ interface CustomerProduct {
37
+ id: string;
38
+ name: string | null;
39
+ group: string | null;
40
+ status: ProductStatus;
41
+ started_at: number;
42
+ canceled_at: number | null;
43
+ subscription_ids?: string[] | null;
44
+ current_period_start?: number | null;
45
+ current_period_end?: number | null;
46
+ }
47
+ interface Customer {
48
+ autumn_id: string;
49
+ created_at: number;
50
+ env: AppEnv;
51
+ id: string | null;
52
+ name: string | null;
53
+ email: string | null;
54
+ fingerprint: string | null;
55
+ stripe_id: string | null;
56
+ products: CustomerProduct[];
57
+ add_ons: CustomerProduct[];
58
+ features: CustomerFeature[];
59
+ }
60
+ interface CustomerData {
61
+ name?: string;
62
+ email?: string;
63
+ fingerprint?: string;
64
+ }
65
+ interface BillingPortalResponse {
66
+ customer_id: string;
67
+ url: string;
68
+ }
69
+
70
+ interface AttachResult {
71
+ checkout_url?: string;
72
+ customer_id: string;
73
+ product_ids: string[];
74
+ code: string;
75
+ message: string;
76
+ }
77
+ interface EventResult {
78
+ id: string;
79
+ code: string;
80
+ customer_id: string;
81
+ feature_id?: string;
82
+ event_name?: string;
83
+ }
84
+ interface EntitledBalance {
85
+ feature_id: string;
86
+ unlimited: boolean;
87
+ usage_allowed: boolean;
88
+ required_quantity: number | null;
89
+ balance: number | null;
90
+ }
91
+ interface EntitledResult {
92
+ customer_id: string;
93
+ feature_id: string;
94
+ code: string;
95
+ allowed: boolean;
96
+ balances: EntitledBalance[];
97
+ }
98
+
99
+ interface AutumnError {
100
+ message: string;
101
+ code: string;
102
+ }
103
+
104
+ interface UseAutumnOptions {
105
+ autoCreate?: boolean;
106
+ }
107
+ declare const useAutumn: (options?: UseAutumnOptions) => {
108
+ customer: Customer | null;
109
+ loading: boolean;
110
+ error: AutumnError | null;
111
+ attach: ({ productId }: {
112
+ productId: string;
113
+ }) => Promise<AttachResult | undefined>;
114
+ sendEvent: ({ featureId, value, }: {
115
+ featureId: string;
116
+ value: number;
117
+ }) => Promise<{
118
+ data: null;
119
+ error: AutumnError;
120
+ } | {
121
+ data: EventResult;
122
+ error: null;
123
+ }>;
124
+ entitled: ({ featureId }: {
125
+ featureId: string;
126
+ }) => Promise<{
127
+ data: null;
128
+ error: AutumnError;
129
+ } | {
130
+ data: EntitledResult;
131
+ error: null;
132
+ }>;
133
+ openBillingPortal: () => Promise<BillingPortalResponse | null>;
134
+ };
135
+
136
+ interface UseCustomerProps {
137
+ autoCreate?: boolean;
138
+ customerData?: CustomerData;
139
+ }
140
+ declare const useCustomer: ({ autoCreate }: UseCustomerProps) => {
141
+ customer: Customer | null;
142
+ error: AutumnError | null;
143
+ isLoading: boolean;
144
+ };
145
+
146
+ interface AutumnContextParams {
147
+ customerId: string;
148
+ customerData?: CustomerData;
149
+ }
150
+ declare const AutumnProvider: ({ children, customerId, customerData, }: AutumnContextParams & {
151
+ children?: React.ReactNode;
152
+ }) => react_jsx_runtime.JSX.Element;
153
+
154
+ declare const AutumnContext: react.Context<AutumnContextParams>;
155
+ declare const useAutumnContext: () => AutumnContextParams;
156
+
157
+ export { AutumnContext, type AutumnContextParams, AutumnProvider, type UseAutumnOptions, type UseCustomerProps, useAutumn, useAutumnContext, useCustomer };
@@ -0,0 +1,157 @@
1
+ import * as react from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ declare enum AppEnv {
5
+ Sandbox = "sandbox",
6
+ Live = "live"
7
+ }
8
+
9
+ declare enum ProductItemInterval {
10
+ Minute = "minute",
11
+ Hour = "hour",
12
+ Day = "day",
13
+ Week = "week",
14
+ Month = "month",
15
+ Quarter = "quarter",
16
+ SemiAnnual = "semi_annual",
17
+ Year = "year"
18
+ }
19
+
20
+ declare enum ProductStatus {
21
+ Active = "active",
22
+ Expired = "expired",
23
+ Trialing = "trialing",
24
+ Scheduled = "scheduled"
25
+ }
26
+
27
+ interface CustomerFeature {
28
+ feature_id: string;
29
+ unlimited?: boolean;
30
+ interval?: ProductItemInterval | null;
31
+ balance?: number;
32
+ usage?: number;
33
+ included_usage?: number;
34
+ next_reset_at?: number;
35
+ }
36
+ interface CustomerProduct {
37
+ id: string;
38
+ name: string | null;
39
+ group: string | null;
40
+ status: ProductStatus;
41
+ started_at: number;
42
+ canceled_at: number | null;
43
+ subscription_ids?: string[] | null;
44
+ current_period_start?: number | null;
45
+ current_period_end?: number | null;
46
+ }
47
+ interface Customer {
48
+ autumn_id: string;
49
+ created_at: number;
50
+ env: AppEnv;
51
+ id: string | null;
52
+ name: string | null;
53
+ email: string | null;
54
+ fingerprint: string | null;
55
+ stripe_id: string | null;
56
+ products: CustomerProduct[];
57
+ add_ons: CustomerProduct[];
58
+ features: CustomerFeature[];
59
+ }
60
+ interface CustomerData {
61
+ name?: string;
62
+ email?: string;
63
+ fingerprint?: string;
64
+ }
65
+ interface BillingPortalResponse {
66
+ customer_id: string;
67
+ url: string;
68
+ }
69
+
70
+ interface AttachResult {
71
+ checkout_url?: string;
72
+ customer_id: string;
73
+ product_ids: string[];
74
+ code: string;
75
+ message: string;
76
+ }
77
+ interface EventResult {
78
+ id: string;
79
+ code: string;
80
+ customer_id: string;
81
+ feature_id?: string;
82
+ event_name?: string;
83
+ }
84
+ interface EntitledBalance {
85
+ feature_id: string;
86
+ unlimited: boolean;
87
+ usage_allowed: boolean;
88
+ required_quantity: number | null;
89
+ balance: number | null;
90
+ }
91
+ interface EntitledResult {
92
+ customer_id: string;
93
+ feature_id: string;
94
+ code: string;
95
+ allowed: boolean;
96
+ balances: EntitledBalance[];
97
+ }
98
+
99
+ interface AutumnError {
100
+ message: string;
101
+ code: string;
102
+ }
103
+
104
+ interface UseAutumnOptions {
105
+ autoCreate?: boolean;
106
+ }
107
+ declare const useAutumn: (options?: UseAutumnOptions) => {
108
+ customer: Customer | null;
109
+ loading: boolean;
110
+ error: AutumnError | null;
111
+ attach: ({ productId }: {
112
+ productId: string;
113
+ }) => Promise<AttachResult | undefined>;
114
+ sendEvent: ({ featureId, value, }: {
115
+ featureId: string;
116
+ value: number;
117
+ }) => Promise<{
118
+ data: null;
119
+ error: AutumnError;
120
+ } | {
121
+ data: EventResult;
122
+ error: null;
123
+ }>;
124
+ entitled: ({ featureId }: {
125
+ featureId: string;
126
+ }) => Promise<{
127
+ data: null;
128
+ error: AutumnError;
129
+ } | {
130
+ data: EntitledResult;
131
+ error: null;
132
+ }>;
133
+ openBillingPortal: () => Promise<BillingPortalResponse | null>;
134
+ };
135
+
136
+ interface UseCustomerProps {
137
+ autoCreate?: boolean;
138
+ customerData?: CustomerData;
139
+ }
140
+ declare const useCustomer: ({ autoCreate }: UseCustomerProps) => {
141
+ customer: Customer | null;
142
+ error: AutumnError | null;
143
+ isLoading: boolean;
144
+ };
145
+
146
+ interface AutumnContextParams {
147
+ customerId: string;
148
+ customerData?: CustomerData;
149
+ }
150
+ declare const AutumnProvider: ({ children, customerId, customerData, }: AutumnContextParams & {
151
+ children?: React.ReactNode;
152
+ }) => react_jsx_runtime.JSX.Element;
153
+
154
+ declare const AutumnContext: react.Context<AutumnContextParams>;
155
+ declare const useAutumnContext: () => AutumnContextParams;
156
+
157
+ export { AutumnContext, type AutumnContextParams, AutumnProvider, type UseAutumnOptions, type UseCustomerProps, useAutumn, useAutumnContext, useCustomer };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./client/hooks/useAutumn"), module.exports);
19
+ __reExport(index_exports, require("./client/hooks/useCustomer"), module.exports);
20
+ __reExport(index_exports, require("./client/AutumnContext"), module.exports);
21
+ __reExport(index_exports, require("./client/AutumnProvider"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./client/hooks/useAutumn"),
25
+ ...require("./client/hooks/useCustomer"),
26
+ ...require("./client/AutumnContext"),
27
+ ...require("./client/AutumnProvider")
28
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./client/hooks/useAutumn";
2
+ export * from "./client/hooks/useCustomer";
3
+ export * from "./client/AutumnContext";
4
+ export * from "./client/AutumnProvider";
@@ -0,0 +1,140 @@
1
+ import { C as Customer, A as AutumnError, a as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, b as BillingPortalResponse, c as AttachParams, d as AttachResult, E as EntitledParams, e as EntitledResult, f as EventParams, g as EventResult, h as AppEnv, I as Infinite, P as ProductItemIntervalType, i as UsageModel, F as FreeTrialDuration, j as CustomerData } from './genTypes-RkqyS6Mn.mjs';
2
+
3
+ declare class Autumn {
4
+ private readonly secretKey;
5
+ private readonly publishableKey;
6
+ private level;
7
+ private headers;
8
+ private url;
9
+ constructor(options?: {
10
+ secretKey?: string;
11
+ publishableKey?: string;
12
+ url?: string;
13
+ });
14
+ getLevel(): "secret" | "publishable";
15
+ private handleResponse;
16
+ get(path: string): Promise<{
17
+ data: null;
18
+ error: {
19
+ message: any;
20
+ code: any;
21
+ };
22
+ } | {
23
+ data: any;
24
+ error: null;
25
+ }>;
26
+ post(path: string, body: any): Promise<{
27
+ data: null;
28
+ error: {
29
+ message: any;
30
+ code: any;
31
+ };
32
+ } | {
33
+ data: any;
34
+ error: null;
35
+ }>;
36
+ customers: {
37
+ get: (id: string) => Promise<{
38
+ data: Customer | null;
39
+ error: AutumnError | null;
40
+ }>;
41
+ create: (params?: CreateCustomerParams) => Promise<{
42
+ data: Customer | null;
43
+ error: AutumnError | null;
44
+ }>;
45
+ update: (id: string, params: UpdateCustomerParams) => Promise<{
46
+ data: Customer | null;
47
+ error: AutumnError | null;
48
+ }>;
49
+ billingPortal: (id: string, params?: BillingPortalParams) => Promise<{
50
+ data: BillingPortalResponse | null;
51
+ error: AutumnError | null;
52
+ }>;
53
+ };
54
+ products: {
55
+ get: (id: string) => Promise<{
56
+ data: Product | null;
57
+ error: AutumnError | null;
58
+ }>;
59
+ create: (params?: CreateProductParams) => Promise<{
60
+ data: Product | null;
61
+ error: AutumnError | null;
62
+ }>;
63
+ };
64
+ attach(params: AttachParams): Promise<{
65
+ data: null;
66
+ error: AutumnError;
67
+ } | {
68
+ data: AttachResult;
69
+ error: null;
70
+ }>;
71
+ entitled(params: EntitledParams): Promise<{
72
+ data: null;
73
+ error: AutumnError;
74
+ } | {
75
+ data: EntitledResult;
76
+ error: null;
77
+ }>;
78
+ event(params: EventParams): Promise<{
79
+ data: null;
80
+ error: AutumnError;
81
+ } | {
82
+ data: EventResult;
83
+ error: null;
84
+ }>;
85
+ }
86
+
87
+ interface ProductItem {
88
+ feature_id?: string;
89
+ included_usage?: number | typeof Infinite;
90
+ interval?: ProductItemIntervalType;
91
+ usage_model?: UsageModel;
92
+ price?: number;
93
+ billing_units?: number;
94
+ entity_feature_id?: string;
95
+ reset_usage_on_billing?: boolean;
96
+ reset_usage_when_enabled?: boolean;
97
+ }
98
+ interface FreeTrial {
99
+ duration: FreeTrialDuration;
100
+ length: number;
101
+ unique_fingerprint: boolean;
102
+ }
103
+ interface Product {
104
+ autumn_id: string;
105
+ created_at: number;
106
+ id: string;
107
+ name: string;
108
+ env: AppEnv;
109
+ is_add_on: boolean;
110
+ is_default: boolean;
111
+ group: string;
112
+ version: number;
113
+ items: ProductItem[];
114
+ free_trial: FreeTrial | null;
115
+ }
116
+ interface CreateProductParams {
117
+ id: string;
118
+ name?: string;
119
+ is_add_on?: boolean;
120
+ is_default?: boolean;
121
+ items?: ProductItem[];
122
+ free_trial?: FreeTrial;
123
+ }
124
+
125
+ declare const createAutumnClient: () => Autumn;
126
+ declare const getOrCreateCustomer: ({ customerId, customerData, }: {
127
+ customerId: string;
128
+ customerData?: CustomerData;
129
+ }) => Promise<{
130
+ data: Customer | null;
131
+ error: AutumnError | null;
132
+ }>;
133
+ declare const getCustomer: ({ customerId }: {
134
+ customerId: string;
135
+ }) => Promise<{
136
+ data: Customer | null;
137
+ error: AutumnError | null;
138
+ }>;
139
+
140
+ export { createAutumnClient, getCustomer, getOrCreateCustomer };
@@ -0,0 +1,140 @@
1
+ import { C as Customer, A as AutumnError, a as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, b as BillingPortalResponse, c as AttachParams, d as AttachResult, E as EntitledParams, e as EntitledResult, f as EventParams, g as EventResult, h as AppEnv, I as Infinite, P as ProductItemIntervalType, i as UsageModel, F as FreeTrialDuration, j as CustomerData } from './genTypes-RkqyS6Mn.js';
2
+
3
+ declare class Autumn {
4
+ private readonly secretKey;
5
+ private readonly publishableKey;
6
+ private level;
7
+ private headers;
8
+ private url;
9
+ constructor(options?: {
10
+ secretKey?: string;
11
+ publishableKey?: string;
12
+ url?: string;
13
+ });
14
+ getLevel(): "secret" | "publishable";
15
+ private handleResponse;
16
+ get(path: string): Promise<{
17
+ data: null;
18
+ error: {
19
+ message: any;
20
+ code: any;
21
+ };
22
+ } | {
23
+ data: any;
24
+ error: null;
25
+ }>;
26
+ post(path: string, body: any): Promise<{
27
+ data: null;
28
+ error: {
29
+ message: any;
30
+ code: any;
31
+ };
32
+ } | {
33
+ data: any;
34
+ error: null;
35
+ }>;
36
+ customers: {
37
+ get: (id: string) => Promise<{
38
+ data: Customer | null;
39
+ error: AutumnError | null;
40
+ }>;
41
+ create: (params?: CreateCustomerParams) => Promise<{
42
+ data: Customer | null;
43
+ error: AutumnError | null;
44
+ }>;
45
+ update: (id: string, params: UpdateCustomerParams) => Promise<{
46
+ data: Customer | null;
47
+ error: AutumnError | null;
48
+ }>;
49
+ billingPortal: (id: string, params?: BillingPortalParams) => Promise<{
50
+ data: BillingPortalResponse | null;
51
+ error: AutumnError | null;
52
+ }>;
53
+ };
54
+ products: {
55
+ get: (id: string) => Promise<{
56
+ data: Product | null;
57
+ error: AutumnError | null;
58
+ }>;
59
+ create: (params?: CreateProductParams) => Promise<{
60
+ data: Product | null;
61
+ error: AutumnError | null;
62
+ }>;
63
+ };
64
+ attach(params: AttachParams): Promise<{
65
+ data: null;
66
+ error: AutumnError;
67
+ } | {
68
+ data: AttachResult;
69
+ error: null;
70
+ }>;
71
+ entitled(params: EntitledParams): Promise<{
72
+ data: null;
73
+ error: AutumnError;
74
+ } | {
75
+ data: EntitledResult;
76
+ error: null;
77
+ }>;
78
+ event(params: EventParams): Promise<{
79
+ data: null;
80
+ error: AutumnError;
81
+ } | {
82
+ data: EventResult;
83
+ error: null;
84
+ }>;
85
+ }
86
+
87
+ interface ProductItem {
88
+ feature_id?: string;
89
+ included_usage?: number | typeof Infinite;
90
+ interval?: ProductItemIntervalType;
91
+ usage_model?: UsageModel;
92
+ price?: number;
93
+ billing_units?: number;
94
+ entity_feature_id?: string;
95
+ reset_usage_on_billing?: boolean;
96
+ reset_usage_when_enabled?: boolean;
97
+ }
98
+ interface FreeTrial {
99
+ duration: FreeTrialDuration;
100
+ length: number;
101
+ unique_fingerprint: boolean;
102
+ }
103
+ interface Product {
104
+ autumn_id: string;
105
+ created_at: number;
106
+ id: string;
107
+ name: string;
108
+ env: AppEnv;
109
+ is_add_on: boolean;
110
+ is_default: boolean;
111
+ group: string;
112
+ version: number;
113
+ items: ProductItem[];
114
+ free_trial: FreeTrial | null;
115
+ }
116
+ interface CreateProductParams {
117
+ id: string;
118
+ name?: string;
119
+ is_add_on?: boolean;
120
+ is_default?: boolean;
121
+ items?: ProductItem[];
122
+ free_trial?: FreeTrial;
123
+ }
124
+
125
+ declare const createAutumnClient: () => Autumn;
126
+ declare const getOrCreateCustomer: ({ customerId, customerData, }: {
127
+ customerId: string;
128
+ customerData?: CustomerData;
129
+ }) => Promise<{
130
+ data: Customer | null;
131
+ error: AutumnError | null;
132
+ }>;
133
+ declare const getCustomer: ({ customerId }: {
134
+ customerId: string;
135
+ }) => Promise<{
136
+ data: Customer | null;
137
+ error: AutumnError | null;
138
+ }>;
139
+
140
+ export { createAutumnClient, getCustomer, getOrCreateCustomer };
@@ -0,0 +1,26 @@
1
+ "use server";
2
+ import { Autumn } from "../../sdk";
3
+ const createAutumnClient = () => {
4
+ return new Autumn();
5
+ };
6
+ const getOrCreateCustomer = async ({
7
+ customerId,
8
+ customerData
9
+ }) => {
10
+ const autumn = createAutumnClient();
11
+ const result = await autumn.customers.create({
12
+ id: customerId,
13
+ ...customerData
14
+ });
15
+ return result;
16
+ };
17
+ const getCustomer = async ({ customerId }) => {
18
+ const autumn = createAutumnClient();
19
+ const result = await autumn.customers.get(customerId);
20
+ return result;
21
+ };
22
+ export {
23
+ createAutumnClient,
24
+ getCustomer,
25
+ getOrCreateCustomer
26
+ };
@@ -0,0 +1,26 @@
1
+ "use server";
2
+ import { Autumn } from "../../sdk";
3
+ const createAutumnClient = () => {
4
+ return new Autumn();
5
+ };
6
+ const getOrCreateCustomer = async ({
7
+ customerId,
8
+ customerData
9
+ }) => {
10
+ const autumn = createAutumnClient();
11
+ const result = await autumn.customers.create({
12
+ id: customerId,
13
+ ...customerData
14
+ });
15
+ return result;
16
+ };
17
+ const getCustomer = async ({ customerId }) => {
18
+ const autumn = createAutumnClient();
19
+ const result = await autumn.customers.get(customerId);
20
+ return result;
21
+ };
22
+ export {
23
+ createAutumnClient,
24
+ getCustomer,
25
+ getOrCreateCustomer
26
+ };