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.
- package/README.md +0 -0
- package/dist/react/client/AutumnContext.d.mts +9 -0
- package/dist/react/client/AutumnContext.d.ts +9 -0
- package/dist/react/client/AutumnContext.js +18 -0
- package/dist/react/client/AutumnContext.mjs +18 -0
- package/dist/react/client/AutumnProvider.d.mts +12 -0
- package/dist/react/client/AutumnProvider.d.ts +12 -0
- package/dist/react/client/AutumnProvider.js +22 -0
- package/dist/react/client/AutumnProvider.mjs +22 -0
- package/dist/react/client/cusTypes-BT7wlTNj.d.mts +67 -0
- package/dist/react/client/cusTypes-BT7wlTNj.d.ts +67 -0
- package/dist/react/client/error-TNbN4XE4.d.mts +6 -0
- package/dist/react/client/error-TNbN4XE4.d.ts +6 -0
- package/dist/react/client/hooks/useAutumn.d.mts +65 -0
- package/dist/react/client/hooks/useAutumn.d.ts +65 -0
- package/dist/react/client/hooks/useAutumn.js +74 -0
- package/dist/react/client/hooks/useAutumn.mjs +74 -0
- package/dist/react/client/hooks/useCustomer.d.mts +14 -0
- package/dist/react/client/hooks/useCustomer.d.ts +14 -0
- package/dist/react/client/hooks/useCustomer.js +44 -0
- package/dist/react/client/hooks/useCustomer.mjs +44 -0
- package/dist/react/index.d.mts +157 -0
- package/dist/react/index.d.ts +157 -0
- package/dist/react/index.js +28 -0
- package/dist/react/index.mjs +4 -0
- package/dist/react/server/cusActions.d.mts +140 -0
- package/dist/react/server/cusActions.d.ts +140 -0
- package/dist/react/server/cusActions.js +26 -0
- package/dist/react/server/cusActions.mjs +26 -0
- package/dist/react/server/genActions.d.mts +42 -0
- package/dist/react/server/genActions.d.ts +42 -0
- package/dist/react/server/genActions.js +41 -0
- package/dist/react/server/genActions.mjs +41 -0
- package/dist/react/server/genTypes-RkqyS6Mn.d.mts +152 -0
- package/dist/react/server/genTypes-RkqyS6Mn.d.ts +152 -0
- package/dist/sdk/cusTypes-B9fUPd5R.d.ts +68 -0
- package/dist/sdk/cusTypes-DEdFHlrl.d.mts +68 -0
- package/dist/sdk/customers.d.mts +2 -0
- package/dist/sdk/customers.d.ts +2 -0
- package/dist/sdk/general.d.mts +60 -0
- package/dist/sdk/general.d.ts +60 -0
- package/dist/sdk/index.d.mts +97 -0
- package/dist/sdk/index.d.ts +97 -0
- package/dist/sdk/index.js +245 -0
- package/dist/sdk/index.mjs +237 -0
- package/dist/sdk/prodEnums-BnhKkH4e.d.mts +26 -0
- package/dist/sdk/prodEnums-BnhKkH4e.d.ts +26 -0
- package/dist/sdk/products.d.mts +45 -0
- package/dist/sdk/products.d.ts +45 -0
- package/package.json +46 -0
- package/tsconfig.json +25 -0
- package/tsup.config.ts +78 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/sdk/customers/cusUtils.ts
|
|
6
|
+
var validateCreateCustomer = (params) => {
|
|
7
|
+
if (!params.email && !params.id) {
|
|
8
|
+
throw {
|
|
9
|
+
message: "Email or id is required",
|
|
10
|
+
code: "invalid_params"
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/sdk/customers/cusMethods.ts
|
|
16
|
+
var customerMethods = (instance) => {
|
|
17
|
+
return {
|
|
18
|
+
get: (id) => getCustomer({ instance, id }),
|
|
19
|
+
create: (params) => createCustomer({ instance, params }),
|
|
20
|
+
update: (id, params) => updateCustomer({ instance, id, params }),
|
|
21
|
+
billingPortal: (id, params) => billingPortal({ instance, id, params })
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var getCustomer = async ({
|
|
25
|
+
instance,
|
|
26
|
+
id
|
|
27
|
+
}) => {
|
|
28
|
+
if (!id) {
|
|
29
|
+
throw {
|
|
30
|
+
message: "Customer ID is required",
|
|
31
|
+
code: "CUSTOMER_ID_REQUIRED"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return instance.get(`/customers/${id}`);
|
|
35
|
+
};
|
|
36
|
+
var createCustomer = async ({
|
|
37
|
+
instance,
|
|
38
|
+
params
|
|
39
|
+
}) => {
|
|
40
|
+
validateCreateCustomer(params || {});
|
|
41
|
+
return instance.post("/customers", params);
|
|
42
|
+
};
|
|
43
|
+
var updateCustomer = async ({
|
|
44
|
+
instance,
|
|
45
|
+
id,
|
|
46
|
+
params
|
|
47
|
+
}) => {
|
|
48
|
+
return instance.post(`/customers/${id}`, params);
|
|
49
|
+
};
|
|
50
|
+
var billingPortal = async ({
|
|
51
|
+
instance,
|
|
52
|
+
id,
|
|
53
|
+
params
|
|
54
|
+
}) => {
|
|
55
|
+
const queryParams = params?.return_url ? `?return_url=${encodeURIComponent(params.return_url)}` : "";
|
|
56
|
+
return instance.get(`/customers/${id}/billing_portal${queryParams}`);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/sdk/general/genMethods.ts
|
|
60
|
+
var handleAttach = async ({
|
|
61
|
+
instance,
|
|
62
|
+
params
|
|
63
|
+
}) => {
|
|
64
|
+
return instance.post("/attach", params);
|
|
65
|
+
};
|
|
66
|
+
var handleEntitled = async ({
|
|
67
|
+
instance,
|
|
68
|
+
params
|
|
69
|
+
}) => {
|
|
70
|
+
return instance.post("/entitled", params);
|
|
71
|
+
};
|
|
72
|
+
var handleEvent = async ({
|
|
73
|
+
instance,
|
|
74
|
+
params
|
|
75
|
+
}) => {
|
|
76
|
+
return instance.post("/events", params);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/sdk/products/prodMethods.ts
|
|
80
|
+
var productMethods = (instance) => {
|
|
81
|
+
return {
|
|
82
|
+
get: (id) => getProduct({ instance, id }),
|
|
83
|
+
create: (params) => createProduct({ instance, params })
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
var getProduct = async ({
|
|
87
|
+
instance,
|
|
88
|
+
id
|
|
89
|
+
}) => {
|
|
90
|
+
return instance.get(`/products/${id}`);
|
|
91
|
+
};
|
|
92
|
+
var createProduct = async ({
|
|
93
|
+
instance,
|
|
94
|
+
params
|
|
95
|
+
}) => {
|
|
96
|
+
return instance.post("/products", params);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/sdk/client.ts
|
|
100
|
+
var Autumn = class {
|
|
101
|
+
constructor(options = {}) {
|
|
102
|
+
__publicField(this, "secretKey");
|
|
103
|
+
__publicField(this, "publishableKey");
|
|
104
|
+
__publicField(this, "level");
|
|
105
|
+
__publicField(this, "headers");
|
|
106
|
+
__publicField(this, "url");
|
|
107
|
+
__publicField(this, "customers", customerMethods(this));
|
|
108
|
+
__publicField(this, "products", productMethods(this));
|
|
109
|
+
try {
|
|
110
|
+
this.secretKey = options.secretKey || process.env.AUTUMN_SECRET_KEY;
|
|
111
|
+
this.publishableKey = options.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
}
|
|
114
|
+
if (!this.secretKey && !this.publishableKey) {
|
|
115
|
+
throw new Error("Autumn secret key or publishable key is required");
|
|
116
|
+
}
|
|
117
|
+
this.headers = {
|
|
118
|
+
Authorization: `Bearer ${this.secretKey || this.publishableKey}`,
|
|
119
|
+
"Content-Type": "application/json"
|
|
120
|
+
};
|
|
121
|
+
this.url = options.url || "https://api.useautumn.com/v1";
|
|
122
|
+
this.level = this.secretKey ? "secret" : "publishable";
|
|
123
|
+
}
|
|
124
|
+
getLevel() {
|
|
125
|
+
return this.level;
|
|
126
|
+
}
|
|
127
|
+
async handleResponse(response) {
|
|
128
|
+
if (response.status < 200 || response.status >= 300) {
|
|
129
|
+
let error;
|
|
130
|
+
try {
|
|
131
|
+
error = await response.json();
|
|
132
|
+
} catch (error2) {
|
|
133
|
+
return {
|
|
134
|
+
data: null,
|
|
135
|
+
error: {
|
|
136
|
+
message: "Something went wrong",
|
|
137
|
+
code: "internal_error"
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
data: null,
|
|
143
|
+
error: {
|
|
144
|
+
message: error.message,
|
|
145
|
+
code: error.code
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
return {
|
|
151
|
+
data: await response.json(),
|
|
152
|
+
error: null
|
|
153
|
+
};
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
data: null,
|
|
157
|
+
error: {
|
|
158
|
+
message: "Failed to parse Autumn API response",
|
|
159
|
+
code: "internal_error"
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async get(path) {
|
|
165
|
+
const response = await fetch(`${this.url}${path}`, {
|
|
166
|
+
headers: this.headers
|
|
167
|
+
});
|
|
168
|
+
return this.handleResponse(response);
|
|
169
|
+
}
|
|
170
|
+
async post(path, body) {
|
|
171
|
+
const response = await fetch(`${this.url}${path}`, {
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: this.headers,
|
|
174
|
+
body: JSON.stringify(body)
|
|
175
|
+
});
|
|
176
|
+
return this.handleResponse(response);
|
|
177
|
+
}
|
|
178
|
+
async attach(params) {
|
|
179
|
+
return handleAttach({
|
|
180
|
+
instance: this,
|
|
181
|
+
params
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async entitled(params) {
|
|
185
|
+
return handleEntitled({
|
|
186
|
+
instance: this,
|
|
187
|
+
params
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async event(params) {
|
|
191
|
+
return handleEvent({
|
|
192
|
+
instance: this,
|
|
193
|
+
params
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/sdk/general/genEnums.ts
|
|
199
|
+
var AppEnv = /* @__PURE__ */ ((AppEnv2) => {
|
|
200
|
+
AppEnv2["Sandbox"] = "sandbox";
|
|
201
|
+
AppEnv2["Live"] = "live";
|
|
202
|
+
return AppEnv2;
|
|
203
|
+
})(AppEnv || {});
|
|
204
|
+
|
|
205
|
+
// src/sdk/customers/cusEnums.ts
|
|
206
|
+
var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
|
|
207
|
+
ProductStatus2["Active"] = "active";
|
|
208
|
+
ProductStatus2["Expired"] = "expired";
|
|
209
|
+
ProductStatus2["Trialing"] = "trialing";
|
|
210
|
+
ProductStatus2["Scheduled"] = "scheduled";
|
|
211
|
+
return ProductStatus2;
|
|
212
|
+
})(ProductStatus || {});
|
|
213
|
+
|
|
214
|
+
// src/sdk/products/prodEnums.ts
|
|
215
|
+
var Infinite = "inf";
|
|
216
|
+
var FreeTrialDuration = /* @__PURE__ */ ((FreeTrialDuration2) => {
|
|
217
|
+
FreeTrialDuration2["Day"] = "day";
|
|
218
|
+
return FreeTrialDuration2;
|
|
219
|
+
})(FreeTrialDuration || {});
|
|
220
|
+
var UsageModel = /* @__PURE__ */ ((UsageModel2) => {
|
|
221
|
+
UsageModel2["Prepaid"] = "prepaid";
|
|
222
|
+
UsageModel2["PayPerUse"] = "pay_per_use";
|
|
223
|
+
return UsageModel2;
|
|
224
|
+
})(UsageModel || {});
|
|
225
|
+
var ProductItemInterval = /* @__PURE__ */ ((ProductItemInterval2) => {
|
|
226
|
+
ProductItemInterval2["Minute"] = "minute";
|
|
227
|
+
ProductItemInterval2["Hour"] = "hour";
|
|
228
|
+
ProductItemInterval2["Day"] = "day";
|
|
229
|
+
ProductItemInterval2["Week"] = "week";
|
|
230
|
+
ProductItemInterval2["Month"] = "month";
|
|
231
|
+
ProductItemInterval2["Quarter"] = "quarter";
|
|
232
|
+
ProductItemInterval2["SemiAnnual"] = "semi_annual";
|
|
233
|
+
ProductItemInterval2["Year"] = "year";
|
|
234
|
+
return ProductItemInterval2;
|
|
235
|
+
})(ProductItemInterval || {});
|
|
236
|
+
|
|
237
|
+
export { AppEnv, Autumn, FreeTrialDuration, Infinite, ProductItemInterval, ProductStatus, UsageModel };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare enum AppEnv {
|
|
2
|
+
Sandbox = "sandbox",
|
|
3
|
+
Live = "live"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare const Infinite = "inf";
|
|
7
|
+
declare enum FreeTrialDuration {
|
|
8
|
+
Day = "day"
|
|
9
|
+
}
|
|
10
|
+
declare enum UsageModel {
|
|
11
|
+
Prepaid = "prepaid",
|
|
12
|
+
PayPerUse = "pay_per_use"
|
|
13
|
+
}
|
|
14
|
+
declare enum ProductItemInterval {
|
|
15
|
+
Minute = "minute",
|
|
16
|
+
Hour = "hour",
|
|
17
|
+
Day = "day",
|
|
18
|
+
Week = "week",
|
|
19
|
+
Month = "month",
|
|
20
|
+
Quarter = "quarter",
|
|
21
|
+
SemiAnnual = "semi_annual",
|
|
22
|
+
Year = "year"
|
|
23
|
+
}
|
|
24
|
+
type ProductItemIntervalType = "minute" | "hour" | "day" | "week" | "month" | "quarter" | "semi_annual" | "year";
|
|
25
|
+
|
|
26
|
+
export { AppEnv as A, FreeTrialDuration as F, Infinite as I, ProductItemInterval as P, UsageModel as U, type ProductItemIntervalType as a };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare enum AppEnv {
|
|
2
|
+
Sandbox = "sandbox",
|
|
3
|
+
Live = "live"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare const Infinite = "inf";
|
|
7
|
+
declare enum FreeTrialDuration {
|
|
8
|
+
Day = "day"
|
|
9
|
+
}
|
|
10
|
+
declare enum UsageModel {
|
|
11
|
+
Prepaid = "prepaid",
|
|
12
|
+
PayPerUse = "pay_per_use"
|
|
13
|
+
}
|
|
14
|
+
declare enum ProductItemInterval {
|
|
15
|
+
Minute = "minute",
|
|
16
|
+
Hour = "hour",
|
|
17
|
+
Day = "day",
|
|
18
|
+
Week = "week",
|
|
19
|
+
Month = "month",
|
|
20
|
+
Quarter = "quarter",
|
|
21
|
+
SemiAnnual = "semi_annual",
|
|
22
|
+
Year = "year"
|
|
23
|
+
}
|
|
24
|
+
type ProductItemIntervalType = "minute" | "hour" | "day" | "week" | "month" | "quarter" | "semi_annual" | "year";
|
|
25
|
+
|
|
26
|
+
export { AppEnv as A, FreeTrialDuration as F, Infinite as I, ProductItemInterval as P, UsageModel as U, type ProductItemIntervalType as a };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { I as Infinite, a as ProductItemIntervalType, U as UsageModel, F as FreeTrialDuration, A as AppEnv } from './prodEnums-BnhKkH4e.mjs';
|
|
2
|
+
|
|
3
|
+
interface PriceTier {
|
|
4
|
+
to: number;
|
|
5
|
+
amount: number | "inf";
|
|
6
|
+
}
|
|
7
|
+
interface ProductItem {
|
|
8
|
+
feature_id?: string;
|
|
9
|
+
included_usage?: number | typeof Infinite;
|
|
10
|
+
interval?: ProductItemIntervalType;
|
|
11
|
+
usage_model?: UsageModel;
|
|
12
|
+
price?: number;
|
|
13
|
+
billing_units?: number;
|
|
14
|
+
entity_feature_id?: string;
|
|
15
|
+
reset_usage_on_billing?: boolean;
|
|
16
|
+
reset_usage_when_enabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface FreeTrial {
|
|
19
|
+
duration: FreeTrialDuration;
|
|
20
|
+
length: number;
|
|
21
|
+
unique_fingerprint: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface Product {
|
|
24
|
+
autumn_id: string;
|
|
25
|
+
created_at: number;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
env: AppEnv;
|
|
29
|
+
is_add_on: boolean;
|
|
30
|
+
is_default: boolean;
|
|
31
|
+
group: string;
|
|
32
|
+
version: number;
|
|
33
|
+
items: ProductItem[];
|
|
34
|
+
free_trial: FreeTrial | null;
|
|
35
|
+
}
|
|
36
|
+
interface CreateProductParams {
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
is_add_on?: boolean;
|
|
40
|
+
is_default?: boolean;
|
|
41
|
+
items?: ProductItem[];
|
|
42
|
+
free_trial?: FreeTrial;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { CreateProductParams, FreeTrial, PriceTier, Product, ProductItem };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { I as Infinite, a as ProductItemIntervalType, U as UsageModel, F as FreeTrialDuration, A as AppEnv } from './prodEnums-BnhKkH4e.js';
|
|
2
|
+
|
|
3
|
+
interface PriceTier {
|
|
4
|
+
to: number;
|
|
5
|
+
amount: number | "inf";
|
|
6
|
+
}
|
|
7
|
+
interface ProductItem {
|
|
8
|
+
feature_id?: string;
|
|
9
|
+
included_usage?: number | typeof Infinite;
|
|
10
|
+
interval?: ProductItemIntervalType;
|
|
11
|
+
usage_model?: UsageModel;
|
|
12
|
+
price?: number;
|
|
13
|
+
billing_units?: number;
|
|
14
|
+
entity_feature_id?: string;
|
|
15
|
+
reset_usage_on_billing?: boolean;
|
|
16
|
+
reset_usage_when_enabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface FreeTrial {
|
|
19
|
+
duration: FreeTrialDuration;
|
|
20
|
+
length: number;
|
|
21
|
+
unique_fingerprint: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface Product {
|
|
24
|
+
autumn_id: string;
|
|
25
|
+
created_at: number;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
env: AppEnv;
|
|
29
|
+
is_add_on: boolean;
|
|
30
|
+
is_default: boolean;
|
|
31
|
+
group: string;
|
|
32
|
+
version: number;
|
|
33
|
+
items: ProductItem[];
|
|
34
|
+
free_trial: FreeTrial | null;
|
|
35
|
+
}
|
|
36
|
+
interface CreateProductParams {
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
is_add_on?: boolean;
|
|
40
|
+
is_default?: boolean;
|
|
41
|
+
items?: ProductItem[];
|
|
42
|
+
free_trial?: FreeTrial;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { CreateProductParams, FreeTrial, PriceTier, Product, ProductItem };
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "autumn-js",
|
|
3
|
+
"description": "Autumn JS Package",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/sdk/index.d.ts",
|
|
11
|
+
"require": "./dist/sdk/index.js",
|
|
12
|
+
"import": "./dist/sdk/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/react/index.d.ts",
|
|
16
|
+
"require": "./dist/react/index.js",
|
|
17
|
+
"import": "./dist/react/index.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"dev": "tsup --watch"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"pricing",
|
|
27
|
+
"autumn",
|
|
28
|
+
"js-sdk"
|
|
29
|
+
],
|
|
30
|
+
"author": "John Yeo",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.14.1",
|
|
34
|
+
"@types/react": "^18.2.0",
|
|
35
|
+
"@types/react-dom": "^18.2.0",
|
|
36
|
+
"tsup": "^8.4.0",
|
|
37
|
+
"typescript": "^5.8.3"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": "^18.2.0",
|
|
41
|
+
"react-dom": "^18.2.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"esbuild-fix-imports-plugin": "^1.0.19"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"strictNullChecks": true,
|
|
7
|
+
"target": "ES2022",
|
|
8
|
+
"moduleResolution": "Node10",
|
|
9
|
+
"module": "CommonJS",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"baseUrl": ".",
|
|
18
|
+
"paths": {
|
|
19
|
+
// "@sdk/*": ["src/sdk/*"],
|
|
20
|
+
// "@react/*": ["src/react/*"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"],
|
|
24
|
+
"exclude": ["node_modules"]
|
|
25
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
{
|
|
5
|
+
format: ["cjs", "esm"],
|
|
6
|
+
entry: ["./src/sdk/index.ts"],
|
|
7
|
+
skipNodeModulesBundle: true,
|
|
8
|
+
// dts: true,
|
|
9
|
+
shims: true,
|
|
10
|
+
clean: false,
|
|
11
|
+
outDir: "./dist/sdk",
|
|
12
|
+
|
|
13
|
+
treeshake: true,
|
|
14
|
+
target: "es2020",
|
|
15
|
+
|
|
16
|
+
dts: {
|
|
17
|
+
entry: {
|
|
18
|
+
general: "src/sdk/general/genTypes.ts",
|
|
19
|
+
customers: "src/sdk/customers/cusTypes.ts",
|
|
20
|
+
products: "src/sdk/products/prodTypes.ts",
|
|
21
|
+
index: "src/sdk/index.ts", // Main types will go to index.d.ts
|
|
22
|
+
},
|
|
23
|
+
// This ensures .d.ts files are generated separately
|
|
24
|
+
resolve: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
entry: ["src/react/index.ts"],
|
|
30
|
+
format: ["cjs", "esm"],
|
|
31
|
+
dts: {
|
|
32
|
+
entry: "src/react/index.ts",
|
|
33
|
+
},
|
|
34
|
+
clean: false, // Don't clean on subsequent builds
|
|
35
|
+
outDir: "./dist/react",
|
|
36
|
+
external: ["react", "react/jsx-runtime", "react-dom"],
|
|
37
|
+
bundle: false,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// React client components
|
|
41
|
+
{
|
|
42
|
+
entry: ["src/react/client/**/*.ts", "src/react/client/**/*.tsx"],
|
|
43
|
+
format: ["cjs", "esm"],
|
|
44
|
+
dts: true,
|
|
45
|
+
clean: true,
|
|
46
|
+
outDir: "./dist/react/client",
|
|
47
|
+
external: ["react", "react/jsx-runtime", "react-dom"],
|
|
48
|
+
bundle: false,
|
|
49
|
+
esbuildOptions(options) {
|
|
50
|
+
options.banner = {
|
|
51
|
+
js: '"use client";',
|
|
52
|
+
};
|
|
53
|
+
options.platform = "neutral";
|
|
54
|
+
options.format = "esm";
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// React server components
|
|
59
|
+
{
|
|
60
|
+
entry: ["src/react/server/*.ts"],
|
|
61
|
+
format: ["cjs", "esm"],
|
|
62
|
+
dts: true,
|
|
63
|
+
clean: true,
|
|
64
|
+
outDir: "./dist/react/server",
|
|
65
|
+
external: ["react", "react/jsx-runtime", "react-dom"],
|
|
66
|
+
bundle: false,
|
|
67
|
+
banner: {
|
|
68
|
+
js: '"use server";',
|
|
69
|
+
},
|
|
70
|
+
esbuildOptions(options) {
|
|
71
|
+
options.banner = {
|
|
72
|
+
js: '"use server";',
|
|
73
|
+
};
|
|
74
|
+
options.platform = "node";
|
|
75
|
+
options.format = "esm";
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
]);
|