order3000 0.13.3 → 0.13.4
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 +1 -22
- package/dist/client.d.cts +9 -12
- package/dist/client.d.mts +9 -12
- package/dist/client.mjs +1 -22
- package/package.json +5 -4
package/dist/client.cjs
CHANGED
|
@@ -26,26 +26,16 @@ class TokenManager {
|
|
|
26
26
|
return this.refreshToken();
|
|
27
27
|
}
|
|
28
28
|
getVenueId() {
|
|
29
|
-
console.log("[SDK VENUE] Getting venue ID...");
|
|
30
|
-
console.log("[SDK VENUE] User venue ID:", this.userVenueId);
|
|
31
|
-
console.log("[SDK VENUE] Default venue ID:", this.defaultVenueId);
|
|
32
29
|
if (this.userVenueId) {
|
|
33
|
-
console.log("[SDK VENUE] Using user venue ID:", this.userVenueId);
|
|
34
30
|
return this.userVenueId;
|
|
35
31
|
}
|
|
36
32
|
if (!this.defaultVenueId) {
|
|
37
|
-
console.error("[SDK VENUE] No venue ID available!");
|
|
38
|
-
console.error("[SDK VENUE] Token exists:", !!this.accessToken);
|
|
39
33
|
throw new Error("No venue ID available. The robot account may not be associated with any venues.");
|
|
40
34
|
}
|
|
41
|
-
console.log("[SDK VENUE] Using default venue ID:", this.defaultVenueId);
|
|
42
35
|
return this.defaultVenueId;
|
|
43
36
|
}
|
|
44
37
|
async refreshToken() {
|
|
45
38
|
if (this.refreshPromise) return this.refreshPromise;
|
|
46
|
-
console.log("[SDK TOKEN] Requesting token from:", this.tokenEndpoint);
|
|
47
|
-
console.log("[SDK TOKEN] Using clientId:", this.clientId);
|
|
48
|
-
console.log("[SDK TOKEN] Secret length:", this.clientSecret?.length);
|
|
49
39
|
this.refreshPromise = fetch(this.tokenEndpoint, {
|
|
50
40
|
method: "POST",
|
|
51
41
|
headers: { "Content-Type": "application/json" },
|
|
@@ -56,20 +46,15 @@ class TokenManager {
|
|
|
56
46
|
signal: AbortSignal.timeout(36e4)
|
|
57
47
|
}).then(async (response) => {
|
|
58
48
|
if (!response.ok) {
|
|
59
|
-
const body = await response.text();
|
|
60
|
-
console.log("[SDK TOKEN] Response status:", response.status);
|
|
61
|
-
console.log("[SDK TOKEN] Response body:", body);
|
|
62
49
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
63
50
|
}
|
|
64
51
|
return response.json();
|
|
65
52
|
}).then((data) => {
|
|
66
|
-
console.log("[SDK TOKEN] Token received successfully");
|
|
67
53
|
this.accessToken = data.accessToken;
|
|
68
54
|
this.tokenExpiresAt = Date.now() + data.expiresIn * 1e3;
|
|
69
55
|
this.setDefaultVenueId();
|
|
70
56
|
return this.accessToken;
|
|
71
57
|
}).catch((error) => {
|
|
72
|
-
console.log("[SDK TOKEN] Token request failed:", error.message);
|
|
73
58
|
throw error;
|
|
74
59
|
}).finally(() => {
|
|
75
60
|
this.refreshPromise = null;
|
|
@@ -79,21 +64,16 @@ class TokenManager {
|
|
|
79
64
|
setDefaultVenueId() {
|
|
80
65
|
if (this.userVenueId || !this.accessToken) return;
|
|
81
66
|
try {
|
|
82
|
-
console.log("[SDK VENUE] Parsing token to extract default venue ID...");
|
|
83
67
|
const [, payload] = this.accessToken.split(".");
|
|
84
68
|
const decoded = JSON.parse(
|
|
85
69
|
Buffer.from(payload, "base64").toString()
|
|
86
70
|
);
|
|
87
|
-
console.log("[SDK VENUE] Token payload venues:", decoded.venues);
|
|
88
71
|
if (!decoded.venues || decoded.venues.length === 0) {
|
|
89
|
-
console.warn("[SDK VENUE] No venues found in token. Robot account may not be associated with any venues.");
|
|
90
72
|
this.defaultVenueId = void 0;
|
|
91
73
|
return;
|
|
92
74
|
}
|
|
93
75
|
this.defaultVenueId = decoded.venues[0];
|
|
94
|
-
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.error("[SDK VENUE] Failed to parse venue ID from token:", error);
|
|
76
|
+
} catch {
|
|
97
77
|
throw new Error("Failed to parse venue ID from token");
|
|
98
78
|
}
|
|
99
79
|
}
|
|
@@ -109,7 +89,6 @@ class BaseResource {
|
|
|
109
89
|
const token = await this.tokenManager.getToken();
|
|
110
90
|
const venueId = this.tokenManager.getVenueId();
|
|
111
91
|
const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
|
|
112
|
-
console.log(`[SDK] Making ${method} request to: ${url}`);
|
|
113
92
|
const response = await fetch(url, {
|
|
114
93
|
method,
|
|
115
94
|
headers: {
|
package/dist/client.d.cts
CHANGED
|
@@ -113,21 +113,19 @@ interface components {
|
|
|
113
113
|
publicId?: string | null;
|
|
114
114
|
quickReferenceNumber?: number | null;
|
|
115
115
|
/** @enum {string} */
|
|
116
|
-
status?: "
|
|
116
|
+
status?: "pending" | "in_progress" | "ready" | "completed" | "cancelled";
|
|
117
117
|
paymentIntentId?: string | null;
|
|
118
118
|
/** @enum {string|null} */
|
|
119
119
|
paymentMethod?: "card" | "cash" | "voucher" | null;
|
|
120
|
+
/** @enum {string} */
|
|
121
|
+
paymentStatus?: "unpaid" | "paid" | "refunded";
|
|
120
122
|
taxAmount: number;
|
|
121
123
|
totalAmount: number;
|
|
122
124
|
/** @enum {string} */
|
|
123
125
|
currency?: "EUR" | "CHF";
|
|
124
126
|
/** @enum {string|null} */
|
|
125
127
|
fulfillmentType?: "pickup" | "delivery" | null;
|
|
126
|
-
|
|
127
|
-
* Format: date-time
|
|
128
|
-
* @description When the order should be fulfilled (ISO 8601 datetime string)
|
|
129
|
-
*/
|
|
130
|
-
fulfillmentAt?: string | null;
|
|
128
|
+
fulfillmentAt: unknown;
|
|
131
129
|
orderedAt?: unknown;
|
|
132
130
|
orderedBy: string;
|
|
133
131
|
updatedAt?: unknown;
|
|
@@ -141,21 +139,19 @@ interface components {
|
|
|
141
139
|
publicId: string | null;
|
|
142
140
|
quickReferenceNumber: number | null;
|
|
143
141
|
/** @enum {string} */
|
|
144
|
-
status: "
|
|
142
|
+
status: "pending" | "in_progress" | "ready" | "completed" | "cancelled";
|
|
145
143
|
paymentIntentId: string | null;
|
|
146
144
|
/** @enum {string|null} */
|
|
147
145
|
paymentMethod: "card" | "cash" | "voucher" | null;
|
|
146
|
+
/** @enum {string} */
|
|
147
|
+
paymentStatus: "unpaid" | "paid" | "refunded";
|
|
148
148
|
taxAmount: number;
|
|
149
149
|
totalAmount: number;
|
|
150
150
|
/** @enum {string} */
|
|
151
151
|
currency: "EUR" | "CHF";
|
|
152
152
|
/** @enum {string|null} */
|
|
153
153
|
fulfillmentType: "pickup" | "delivery" | null;
|
|
154
|
-
|
|
155
|
-
* Format: date-time
|
|
156
|
-
* @description When the order should be fulfilled (ISO 8601 datetime string)
|
|
157
|
-
*/
|
|
158
|
-
fulfillmentAt: string | null;
|
|
154
|
+
fulfillmentAt: unknown;
|
|
159
155
|
orderedAt: unknown;
|
|
160
156
|
orderedBy: string;
|
|
161
157
|
updatedAt: unknown;
|
|
@@ -484,6 +480,7 @@ interface MenuDish {
|
|
|
484
480
|
isVegan: boolean | null;
|
|
485
481
|
isGlutenFree: boolean | null;
|
|
486
482
|
isDairyFree: boolean | null;
|
|
483
|
+
spiciness: number | null;
|
|
487
484
|
assets?: MenuAsset[];
|
|
488
485
|
}
|
|
489
486
|
interface MenuBeverage {
|
package/dist/client.d.mts
CHANGED
|
@@ -113,21 +113,19 @@ interface components {
|
|
|
113
113
|
publicId?: string | null;
|
|
114
114
|
quickReferenceNumber?: number | null;
|
|
115
115
|
/** @enum {string} */
|
|
116
|
-
status?: "
|
|
116
|
+
status?: "pending" | "in_progress" | "ready" | "completed" | "cancelled";
|
|
117
117
|
paymentIntentId?: string | null;
|
|
118
118
|
/** @enum {string|null} */
|
|
119
119
|
paymentMethod?: "card" | "cash" | "voucher" | null;
|
|
120
|
+
/** @enum {string} */
|
|
121
|
+
paymentStatus?: "unpaid" | "paid" | "refunded";
|
|
120
122
|
taxAmount: number;
|
|
121
123
|
totalAmount: number;
|
|
122
124
|
/** @enum {string} */
|
|
123
125
|
currency?: "EUR" | "CHF";
|
|
124
126
|
/** @enum {string|null} */
|
|
125
127
|
fulfillmentType?: "pickup" | "delivery" | null;
|
|
126
|
-
|
|
127
|
-
* Format: date-time
|
|
128
|
-
* @description When the order should be fulfilled (ISO 8601 datetime string)
|
|
129
|
-
*/
|
|
130
|
-
fulfillmentAt?: string | null;
|
|
128
|
+
fulfillmentAt: unknown;
|
|
131
129
|
orderedAt?: unknown;
|
|
132
130
|
orderedBy: string;
|
|
133
131
|
updatedAt?: unknown;
|
|
@@ -141,21 +139,19 @@ interface components {
|
|
|
141
139
|
publicId: string | null;
|
|
142
140
|
quickReferenceNumber: number | null;
|
|
143
141
|
/** @enum {string} */
|
|
144
|
-
status: "
|
|
142
|
+
status: "pending" | "in_progress" | "ready" | "completed" | "cancelled";
|
|
145
143
|
paymentIntentId: string | null;
|
|
146
144
|
/** @enum {string|null} */
|
|
147
145
|
paymentMethod: "card" | "cash" | "voucher" | null;
|
|
146
|
+
/** @enum {string} */
|
|
147
|
+
paymentStatus: "unpaid" | "paid" | "refunded";
|
|
148
148
|
taxAmount: number;
|
|
149
149
|
totalAmount: number;
|
|
150
150
|
/** @enum {string} */
|
|
151
151
|
currency: "EUR" | "CHF";
|
|
152
152
|
/** @enum {string|null} */
|
|
153
153
|
fulfillmentType: "pickup" | "delivery" | null;
|
|
154
|
-
|
|
155
|
-
* Format: date-time
|
|
156
|
-
* @description When the order should be fulfilled (ISO 8601 datetime string)
|
|
157
|
-
*/
|
|
158
|
-
fulfillmentAt: string | null;
|
|
154
|
+
fulfillmentAt: unknown;
|
|
159
155
|
orderedAt: unknown;
|
|
160
156
|
orderedBy: string;
|
|
161
157
|
updatedAt: unknown;
|
|
@@ -484,6 +480,7 @@ interface MenuDish {
|
|
|
484
480
|
isVegan: boolean | null;
|
|
485
481
|
isGlutenFree: boolean | null;
|
|
486
482
|
isDairyFree: boolean | null;
|
|
483
|
+
spiciness: number | null;
|
|
487
484
|
assets?: MenuAsset[];
|
|
488
485
|
}
|
|
489
486
|
interface MenuBeverage {
|
package/dist/client.mjs
CHANGED
|
@@ -24,26 +24,16 @@ class TokenManager {
|
|
|
24
24
|
return this.refreshToken();
|
|
25
25
|
}
|
|
26
26
|
getVenueId() {
|
|
27
|
-
console.log("[SDK VENUE] Getting venue ID...");
|
|
28
|
-
console.log("[SDK VENUE] User venue ID:", this.userVenueId);
|
|
29
|
-
console.log("[SDK VENUE] Default venue ID:", this.defaultVenueId);
|
|
30
27
|
if (this.userVenueId) {
|
|
31
|
-
console.log("[SDK VENUE] Using user venue ID:", this.userVenueId);
|
|
32
28
|
return this.userVenueId;
|
|
33
29
|
}
|
|
34
30
|
if (!this.defaultVenueId) {
|
|
35
|
-
console.error("[SDK VENUE] No venue ID available!");
|
|
36
|
-
console.error("[SDK VENUE] Token exists:", !!this.accessToken);
|
|
37
31
|
throw new Error("No venue ID available. The robot account may not be associated with any venues.");
|
|
38
32
|
}
|
|
39
|
-
console.log("[SDK VENUE] Using default venue ID:", this.defaultVenueId);
|
|
40
33
|
return this.defaultVenueId;
|
|
41
34
|
}
|
|
42
35
|
async refreshToken() {
|
|
43
36
|
if (this.refreshPromise) return this.refreshPromise;
|
|
44
|
-
console.log("[SDK TOKEN] Requesting token from:", this.tokenEndpoint);
|
|
45
|
-
console.log("[SDK TOKEN] Using clientId:", this.clientId);
|
|
46
|
-
console.log("[SDK TOKEN] Secret length:", this.clientSecret?.length);
|
|
47
37
|
this.refreshPromise = fetch(this.tokenEndpoint, {
|
|
48
38
|
method: "POST",
|
|
49
39
|
headers: { "Content-Type": "application/json" },
|
|
@@ -54,20 +44,15 @@ class TokenManager {
|
|
|
54
44
|
signal: AbortSignal.timeout(36e4)
|
|
55
45
|
}).then(async (response) => {
|
|
56
46
|
if (!response.ok) {
|
|
57
|
-
const body = await response.text();
|
|
58
|
-
console.log("[SDK TOKEN] Response status:", response.status);
|
|
59
|
-
console.log("[SDK TOKEN] Response body:", body);
|
|
60
47
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
61
48
|
}
|
|
62
49
|
return response.json();
|
|
63
50
|
}).then((data) => {
|
|
64
|
-
console.log("[SDK TOKEN] Token received successfully");
|
|
65
51
|
this.accessToken = data.accessToken;
|
|
66
52
|
this.tokenExpiresAt = Date.now() + data.expiresIn * 1e3;
|
|
67
53
|
this.setDefaultVenueId();
|
|
68
54
|
return this.accessToken;
|
|
69
55
|
}).catch((error) => {
|
|
70
|
-
console.log("[SDK TOKEN] Token request failed:", error.message);
|
|
71
56
|
throw error;
|
|
72
57
|
}).finally(() => {
|
|
73
58
|
this.refreshPromise = null;
|
|
@@ -77,21 +62,16 @@ class TokenManager {
|
|
|
77
62
|
setDefaultVenueId() {
|
|
78
63
|
if (this.userVenueId || !this.accessToken) return;
|
|
79
64
|
try {
|
|
80
|
-
console.log("[SDK VENUE] Parsing token to extract default venue ID...");
|
|
81
65
|
const [, payload] = this.accessToken.split(".");
|
|
82
66
|
const decoded = JSON.parse(
|
|
83
67
|
Buffer.from(payload, "base64").toString()
|
|
84
68
|
);
|
|
85
|
-
console.log("[SDK VENUE] Token payload venues:", decoded.venues);
|
|
86
69
|
if (!decoded.venues || decoded.venues.length === 0) {
|
|
87
|
-
console.warn("[SDK VENUE] No venues found in token. Robot account may not be associated with any venues.");
|
|
88
70
|
this.defaultVenueId = void 0;
|
|
89
71
|
return;
|
|
90
72
|
}
|
|
91
73
|
this.defaultVenueId = decoded.venues[0];
|
|
92
|
-
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.error("[SDK VENUE] Failed to parse venue ID from token:", error);
|
|
74
|
+
} catch {
|
|
95
75
|
throw new Error("Failed to parse venue ID from token");
|
|
96
76
|
}
|
|
97
77
|
}
|
|
@@ -107,7 +87,6 @@ class BaseResource {
|
|
|
107
87
|
const token = await this.tokenManager.getToken();
|
|
108
88
|
const venueId = this.tokenManager.getVenueId();
|
|
109
89
|
const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
|
|
110
|
-
console.log(`[SDK] Making ${method} request to: ${url}`);
|
|
111
90
|
const response = await fetch(url, {
|
|
112
91
|
method,
|
|
113
92
|
headers: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "order3000",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"description": "order3000 node.js sdk",
|
|
5
5
|
"main": "./dist/client.cjs",
|
|
6
6
|
"module": "./dist/client.mjs",
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^24.10.0",
|
|
29
|
+
"esbuild": "^0.26.0",
|
|
29
30
|
"openapi-typescript": "^7.6.1",
|
|
30
31
|
"pkgroll": "^2.26.3",
|
|
31
32
|
"prettier": "^3.7.4",
|
|
32
33
|
"tsx": "^4.19.2",
|
|
33
34
|
"typescript": "^5.9.3",
|
|
34
|
-
"@kolaveri/eslint-config": "1.4.
|
|
35
|
-
"@kolaveri/
|
|
36
|
-
"@kolaveri/
|
|
35
|
+
"@kolaveri/eslint-config": "1.4.2",
|
|
36
|
+
"@kolaveri/prettier-config": "1.0.6",
|
|
37
|
+
"@kolaveri/tsconfig": "1.0.1"
|
|
37
38
|
},
|
|
38
39
|
"files": [
|
|
39
40
|
"dist"
|