order3000 0.1.5 → 0.1.7
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/dist/client.cjs +7 -18
- package/dist/client.d.cts +11 -4
- package/dist/client.d.mts +11 -4
- package/dist/client.mjs +7 -18
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -35,7 +35,7 @@ class TokenManager {
|
|
|
35
35
|
this.refreshPromise = got.post(this.tokenEndpoint, {
|
|
36
36
|
json: { clientId: this.clientId, clientSecret: this.clientSecret },
|
|
37
37
|
responseType: "json",
|
|
38
|
-
timeout: { request:
|
|
38
|
+
timeout: { request: 36e4 },
|
|
39
39
|
retry: { limit: 3 }
|
|
40
40
|
}).then((response) => {
|
|
41
41
|
this.accessToken = response.body.accessToken;
|
|
@@ -77,7 +77,7 @@ class BaseResource {
|
|
|
77
77
|
json: data,
|
|
78
78
|
headers: { Authorization: `Bearer ${token}` },
|
|
79
79
|
responseType: "json",
|
|
80
|
-
timeout: { request:
|
|
80
|
+
timeout: { request: 36e4 },
|
|
81
81
|
retry: { limit: 2 }
|
|
82
82
|
}
|
|
83
83
|
).json();
|
|
@@ -102,30 +102,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
102
102
|
class Order3000Client {
|
|
103
103
|
constructor(config) {
|
|
104
104
|
__publicField(this, "orders");
|
|
105
|
-
__publicField(this, "
|
|
105
|
+
__publicField(this, "apiEndpoint");
|
|
106
106
|
__publicField(this, "tokenManager");
|
|
107
|
-
this.
|
|
107
|
+
this.apiEndpoint = config.apiEndpoint || "https://order3000.com/api";
|
|
108
|
+
const tokenUrl = config.tokenUrl || `${this.apiEndpoint}/auth/token`;
|
|
108
109
|
this.tokenManager = new TokenManager(
|
|
109
110
|
config.clientId,
|
|
110
111
|
config.clientSecret,
|
|
111
|
-
|
|
112
|
+
tokenUrl,
|
|
112
113
|
config.tenantId
|
|
113
114
|
);
|
|
114
|
-
this.orders = new OrdersResource(this.tokenManager, this.
|
|
115
|
+
this.orders = new OrdersResource(this.tokenManager, this.apiEndpoint);
|
|
115
116
|
this.initialize();
|
|
116
117
|
}
|
|
117
|
-
resolveBaseUrl(config) {
|
|
118
|
-
if (config.baseUrl) return config.baseUrl;
|
|
119
|
-
const env = process.env.APP_ENV || "development";
|
|
120
|
-
switch (env) {
|
|
121
|
-
case "production":
|
|
122
|
-
return "https://order3000.com/api";
|
|
123
|
-
case "staging":
|
|
124
|
-
return "https://order3000.kolaveri.co/api";
|
|
125
|
-
default:
|
|
126
|
-
return "http://localhost:3000/api";
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
118
|
async initialize() {
|
|
130
119
|
try {
|
|
131
120
|
await this.tokenManager.initialize();
|
package/dist/client.d.cts
CHANGED
|
@@ -68,15 +68,22 @@ interface Order3000ClientConfig {
|
|
|
68
68
|
clientId: string;
|
|
69
69
|
clientSecret: string;
|
|
70
70
|
tenantId?: string;
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Base URL for API services
|
|
73
|
+
* @default "https://order3000.com/api"
|
|
74
|
+
*/
|
|
75
|
+
apiEndpoint?: string;
|
|
76
|
+
/**
|
|
77
|
+
* OAuth 2.0 token endpoint
|
|
78
|
+
* @default "${apiEndpoint}/auth/token"
|
|
79
|
+
*/
|
|
80
|
+
tokenUrl?: string;
|
|
73
81
|
}
|
|
74
82
|
declare class Order3000Client {
|
|
75
83
|
orders: OrdersResource;
|
|
76
|
-
private readonly
|
|
84
|
+
private readonly apiEndpoint;
|
|
77
85
|
private readonly tokenManager;
|
|
78
86
|
constructor(config: Order3000ClientConfig);
|
|
79
|
-
private resolveBaseUrl;
|
|
80
87
|
private initialize;
|
|
81
88
|
}
|
|
82
89
|
|
package/dist/client.d.mts
CHANGED
|
@@ -68,15 +68,22 @@ interface Order3000ClientConfig {
|
|
|
68
68
|
clientId: string;
|
|
69
69
|
clientSecret: string;
|
|
70
70
|
tenantId?: string;
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Base URL for API services
|
|
73
|
+
* @default "https://order3000.com/api"
|
|
74
|
+
*/
|
|
75
|
+
apiEndpoint?: string;
|
|
76
|
+
/**
|
|
77
|
+
* OAuth 2.0 token endpoint
|
|
78
|
+
* @default "${apiEndpoint}/auth/token"
|
|
79
|
+
*/
|
|
80
|
+
tokenUrl?: string;
|
|
73
81
|
}
|
|
74
82
|
declare class Order3000Client {
|
|
75
83
|
orders: OrdersResource;
|
|
76
|
-
private readonly
|
|
84
|
+
private readonly apiEndpoint;
|
|
77
85
|
private readonly tokenManager;
|
|
78
86
|
constructor(config: Order3000ClientConfig);
|
|
79
|
-
private resolveBaseUrl;
|
|
80
87
|
private initialize;
|
|
81
88
|
}
|
|
82
89
|
|
package/dist/client.mjs
CHANGED
|
@@ -33,7 +33,7 @@ class TokenManager {
|
|
|
33
33
|
this.refreshPromise = got.post(this.tokenEndpoint, {
|
|
34
34
|
json: { clientId: this.clientId, clientSecret: this.clientSecret },
|
|
35
35
|
responseType: "json",
|
|
36
|
-
timeout: { request:
|
|
36
|
+
timeout: { request: 36e4 },
|
|
37
37
|
retry: { limit: 3 }
|
|
38
38
|
}).then((response) => {
|
|
39
39
|
this.accessToken = response.body.accessToken;
|
|
@@ -75,7 +75,7 @@ class BaseResource {
|
|
|
75
75
|
json: data,
|
|
76
76
|
headers: { Authorization: `Bearer ${token}` },
|
|
77
77
|
responseType: "json",
|
|
78
|
-
timeout: { request:
|
|
78
|
+
timeout: { request: 36e4 },
|
|
79
79
|
retry: { limit: 2 }
|
|
80
80
|
}
|
|
81
81
|
).json();
|
|
@@ -100,30 +100,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
100
100
|
class Order3000Client {
|
|
101
101
|
constructor(config) {
|
|
102
102
|
__publicField(this, "orders");
|
|
103
|
-
__publicField(this, "
|
|
103
|
+
__publicField(this, "apiEndpoint");
|
|
104
104
|
__publicField(this, "tokenManager");
|
|
105
|
-
this.
|
|
105
|
+
this.apiEndpoint = config.apiEndpoint || "https://order3000.com/api";
|
|
106
|
+
const tokenUrl = config.tokenUrl || `${this.apiEndpoint}/auth/token`;
|
|
106
107
|
this.tokenManager = new TokenManager(
|
|
107
108
|
config.clientId,
|
|
108
109
|
config.clientSecret,
|
|
109
|
-
|
|
110
|
+
tokenUrl,
|
|
110
111
|
config.tenantId
|
|
111
112
|
);
|
|
112
|
-
this.orders = new OrdersResource(this.tokenManager, this.
|
|
113
|
+
this.orders = new OrdersResource(this.tokenManager, this.apiEndpoint);
|
|
113
114
|
this.initialize();
|
|
114
115
|
}
|
|
115
|
-
resolveBaseUrl(config) {
|
|
116
|
-
if (config.baseUrl) return config.baseUrl;
|
|
117
|
-
const env = process.env.APP_ENV || "development";
|
|
118
|
-
switch (env) {
|
|
119
|
-
case "production":
|
|
120
|
-
return "https://order3000.com/api";
|
|
121
|
-
case "staging":
|
|
122
|
-
return "https://order3000.kolaveri.co/api";
|
|
123
|
-
default:
|
|
124
|
-
return "http://localhost:3000/api";
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
116
|
async initialize() {
|
|
128
117
|
try {
|
|
129
118
|
await this.tokenManager.initialize();
|