order3000 0.1.8 → 0.1.10

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 CHANGED
@@ -31,31 +31,39 @@ class TokenManager {
31
31
  return this.defaultTenantId;
32
32
  }
33
33
  async refreshToken() {
34
+ console.log("refreshToken 1");
34
35
  if (this.refreshPromise) return this.refreshPromise;
36
+ console.log("refreshToken 2");
35
37
  this.refreshPromise = got.post(this.tokenEndpoint, {
36
38
  json: { clientId: this.clientId, clientSecret: this.clientSecret },
37
39
  responseType: "json",
38
40
  timeout: { request: 36e4 },
39
41
  retry: { limit: 3 }
40
42
  }).then((response) => {
43
+ console.log("refreshToken 3");
41
44
  this.accessToken = response.body.accessToken;
42
45
  this.tokenExpiresAt = Date.now() + response.body.expiresIn * 1e3;
43
46
  this.setDefaultTenantId();
44
47
  return this.accessToken;
45
48
  }).finally(() => {
49
+ console.log("refreshToken 4");
46
50
  this.refreshPromise = null;
47
51
  });
52
+ console.log("refreshToken 5");
48
53
  return this.refreshPromise;
49
54
  }
50
55
  setDefaultTenantId() {
56
+ console.log("refreshToken 6");
51
57
  if (this.userTenantId || !this.accessToken) return;
52
58
  try {
59
+ console.log("refreshToken 7");
53
60
  const [, payload] = this.accessToken.split(".");
54
61
  const decoded = JSON.parse(
55
62
  Buffer.from(payload, "base64").toString()
56
63
  );
57
64
  this.defaultTenantId = decoded.tenants?.[0];
58
65
  } catch (error) {
66
+ console.log("refreshToken 8");
59
67
  throw new Error("Failed to parse tenant ID from token");
60
68
  }
61
69
  }
@@ -112,13 +120,19 @@ class Order3000Client {
112
120
  tokenUrl,
113
121
  config.tenantId
114
122
  );
123
+ console.log("refreshToken 12");
115
124
  this.orders = new OrdersResource(this.tokenManager, this.apiEndpoint);
125
+ console.log("refreshToken 13");
116
126
  this.initialize();
127
+ console.log("refreshToken 14");
117
128
  }
118
129
  async initialize() {
119
130
  try {
131
+ console.log("refreshToken 9");
120
132
  await this.tokenManager.initialize();
133
+ console.log("refreshToken 10");
121
134
  } catch (error) {
135
+ console.log("refreshToken 11");
122
136
  console.error("Failed to initialize client:", error);
123
137
  process.exit(1);
124
138
  }
package/dist/client.d.cts CHANGED
@@ -30,21 +30,43 @@ interface components {
30
30
  * @description Place a new order for a specific tenant
31
31
  */
32
32
  PlaceOrderRequest: {
33
- /** Format: uuid */
34
33
  id?: string;
34
+ tenantId: string;
35
+ basketId: string;
36
+ /** @enum {string} */
37
+ status?: "DRAFT" | "PENDING" | "PAID" | "FULFILLED" | "CANCELLED" | "REFUNDED";
38
+ paymentIntentId?: string | null;
39
+ /** @enum {string|null} */
40
+ paymentMethod?: "CARD" | "CASH" | "VOUCHER" | null;
41
+ taxAmount: string;
42
+ totalAmount: string;
43
+ currency?: string;
35
44
  /** Format: date-time */
36
- createdAt?: string;
45
+ orderedAt?: string;
46
+ orderedBy: string;
37
47
  /** Format: date-time */
38
- updatedAt?: string;
48
+ updatedAt?: string | null;
49
+ updatedBy?: string | null;
39
50
  };
40
51
  /** PlaceOrderResponse */
41
52
  PlaceOrderResponse: {
42
- /** Format: uuid */
43
53
  id: string;
54
+ tenantId: string;
55
+ basketId: string;
56
+ /** @enum {string} */
57
+ status: "DRAFT" | "PENDING" | "PAID" | "FULFILLED" | "CANCELLED" | "REFUNDED";
58
+ paymentIntentId: string | null;
59
+ /** @enum {string|null} */
60
+ paymentMethod: "CARD" | "CASH" | "VOUCHER" | null;
61
+ taxAmount: string;
62
+ totalAmount: string;
63
+ currency: string;
44
64
  /** Format: date-time */
45
- createdAt: string;
65
+ orderedAt: string;
66
+ orderedBy: string;
46
67
  /** Format: date-time */
47
- updatedAt: string;
68
+ updatedAt: string | null;
69
+ updatedBy: string | null;
48
70
  };
49
71
  };
50
72
  responses: never;
package/dist/client.d.mts CHANGED
@@ -30,21 +30,43 @@ interface components {
30
30
  * @description Place a new order for a specific tenant
31
31
  */
32
32
  PlaceOrderRequest: {
33
- /** Format: uuid */
34
33
  id?: string;
34
+ tenantId: string;
35
+ basketId: string;
36
+ /** @enum {string} */
37
+ status?: "DRAFT" | "PENDING" | "PAID" | "FULFILLED" | "CANCELLED" | "REFUNDED";
38
+ paymentIntentId?: string | null;
39
+ /** @enum {string|null} */
40
+ paymentMethod?: "CARD" | "CASH" | "VOUCHER" | null;
41
+ taxAmount: string;
42
+ totalAmount: string;
43
+ currency?: string;
35
44
  /** Format: date-time */
36
- createdAt?: string;
45
+ orderedAt?: string;
46
+ orderedBy: string;
37
47
  /** Format: date-time */
38
- updatedAt?: string;
48
+ updatedAt?: string | null;
49
+ updatedBy?: string | null;
39
50
  };
40
51
  /** PlaceOrderResponse */
41
52
  PlaceOrderResponse: {
42
- /** Format: uuid */
43
53
  id: string;
54
+ tenantId: string;
55
+ basketId: string;
56
+ /** @enum {string} */
57
+ status: "DRAFT" | "PENDING" | "PAID" | "FULFILLED" | "CANCELLED" | "REFUNDED";
58
+ paymentIntentId: string | null;
59
+ /** @enum {string|null} */
60
+ paymentMethod: "CARD" | "CASH" | "VOUCHER" | null;
61
+ taxAmount: string;
62
+ totalAmount: string;
63
+ currency: string;
44
64
  /** Format: date-time */
45
- createdAt: string;
65
+ orderedAt: string;
66
+ orderedBy: string;
46
67
  /** Format: date-time */
47
- updatedAt: string;
68
+ updatedAt: string | null;
69
+ updatedBy: string | null;
48
70
  };
49
71
  };
50
72
  responses: never;
package/dist/client.mjs CHANGED
@@ -29,31 +29,39 @@ class TokenManager {
29
29
  return this.defaultTenantId;
30
30
  }
31
31
  async refreshToken() {
32
+ console.log("refreshToken 1");
32
33
  if (this.refreshPromise) return this.refreshPromise;
34
+ console.log("refreshToken 2");
33
35
  this.refreshPromise = got.post(this.tokenEndpoint, {
34
36
  json: { clientId: this.clientId, clientSecret: this.clientSecret },
35
37
  responseType: "json",
36
38
  timeout: { request: 36e4 },
37
39
  retry: { limit: 3 }
38
40
  }).then((response) => {
41
+ console.log("refreshToken 3");
39
42
  this.accessToken = response.body.accessToken;
40
43
  this.tokenExpiresAt = Date.now() + response.body.expiresIn * 1e3;
41
44
  this.setDefaultTenantId();
42
45
  return this.accessToken;
43
46
  }).finally(() => {
47
+ console.log("refreshToken 4");
44
48
  this.refreshPromise = null;
45
49
  });
50
+ console.log("refreshToken 5");
46
51
  return this.refreshPromise;
47
52
  }
48
53
  setDefaultTenantId() {
54
+ console.log("refreshToken 6");
49
55
  if (this.userTenantId || !this.accessToken) return;
50
56
  try {
57
+ console.log("refreshToken 7");
51
58
  const [, payload] = this.accessToken.split(".");
52
59
  const decoded = JSON.parse(
53
60
  Buffer.from(payload, "base64").toString()
54
61
  );
55
62
  this.defaultTenantId = decoded.tenants?.[0];
56
63
  } catch (error) {
64
+ console.log("refreshToken 8");
57
65
  throw new Error("Failed to parse tenant ID from token");
58
66
  }
59
67
  }
@@ -110,13 +118,19 @@ class Order3000Client {
110
118
  tokenUrl,
111
119
  config.tenantId
112
120
  );
121
+ console.log("refreshToken 12");
113
122
  this.orders = new OrdersResource(this.tokenManager, this.apiEndpoint);
123
+ console.log("refreshToken 13");
114
124
  this.initialize();
125
+ console.log("refreshToken 14");
115
126
  }
116
127
  async initialize() {
117
128
  try {
129
+ console.log("refreshToken 9");
118
130
  await this.tokenManager.initialize();
131
+ console.log("refreshToken 10");
119
132
  } catch (error) {
133
+ console.log("refreshToken 11");
120
134
  console.error("Failed to initialize client:", error);
121
135
  process.exit(1);
122
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "order3000",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "order3000 node.js sdk",
5
5
  "main": "./dist/client.cjs",
6
6
  "module": "./dist/client.mjs",
@@ -16,7 +16,9 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "got": "^14.4.6"
19
+ "got": "^14.4.6",
20
+ "i18next": "^25.0.0",
21
+ "i18next-fs-backend": "^2.6.0"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@types/node": "^22.13.9",