linxcommerce-webapi-sdk 1.0.0
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 +116 -0
- package/dist/index.d.ts +2908 -0
- package/dist/index.js +4634 -0
- package/dist/index.mjs +4586 -0
- package/package.json +44 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4634 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
AddressService: () => AddressService,
|
|
34
|
+
BasketService: () => BasketService,
|
|
35
|
+
CheckoutService: () => CheckoutService,
|
|
36
|
+
CustomersService: () => CustomersService,
|
|
37
|
+
DeliveryService: () => DeliveryService,
|
|
38
|
+
Environment: () => Environment,
|
|
39
|
+
LinxcommerceWebapiSdk: () => LinxcommerceWebapiSdk,
|
|
40
|
+
OndeEncontrarJsonService: () => OndeEncontrarJsonService,
|
|
41
|
+
OrdersService: () => OrdersService,
|
|
42
|
+
ProductsService: () => ProductsService,
|
|
43
|
+
WidgetService: () => WidgetService,
|
|
44
|
+
WsService: () => WsService
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(src_exports);
|
|
47
|
+
|
|
48
|
+
// src/services/customers/customers-service.ts
|
|
49
|
+
var import_zod15 = require("zod");
|
|
50
|
+
|
|
51
|
+
// src/http/handlers/handler-chain.ts
|
|
52
|
+
var RequestHandlerChain = class {
|
|
53
|
+
constructor() {
|
|
54
|
+
/** Array of handlers in the chain */
|
|
55
|
+
this.handlers = [];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Adds a handler to the end of the chain.
|
|
59
|
+
* Links the new handler to the previous one in the chain.
|
|
60
|
+
* @param handler - The request handler to add
|
|
61
|
+
*/
|
|
62
|
+
addHandler(handler) {
|
|
63
|
+
if (this.handlers.length > 0) {
|
|
64
|
+
const previousHandler = this.handlers[this.handlers.length - 1];
|
|
65
|
+
previousHandler.next = handler;
|
|
66
|
+
}
|
|
67
|
+
this.handlers.push(handler);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Executes the handler chain for a standard request.
|
|
71
|
+
* @template T - The expected response data type
|
|
72
|
+
* @param request - The HTTP request to process
|
|
73
|
+
* @returns A promise that resolves to the HTTP response
|
|
74
|
+
* @throws Error if no handlers are added to the chain
|
|
75
|
+
*/
|
|
76
|
+
async callChain(request) {
|
|
77
|
+
if (!this.handlers.length) {
|
|
78
|
+
throw new Error("No handlers added to the chain");
|
|
79
|
+
}
|
|
80
|
+
return this.handlers[0].handle(request);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Executes the handler chain for a streaming request.
|
|
84
|
+
* @template T - The expected response data type for each chunk
|
|
85
|
+
* @param request - The HTTP request to process
|
|
86
|
+
* @returns An async generator that yields HTTP responses
|
|
87
|
+
* @throws Error if no handlers are added to the chain
|
|
88
|
+
*/
|
|
89
|
+
async *streamChain(request) {
|
|
90
|
+
if (!this.handlers.length) {
|
|
91
|
+
throw new Error("No handlers added to the chain");
|
|
92
|
+
}
|
|
93
|
+
yield* this.handlers[0].stream(request);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/http/error.ts
|
|
98
|
+
var HttpError = class extends Error {
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new HTTP error.
|
|
101
|
+
* @param metadata - HTTP response metadata
|
|
102
|
+
* @param raw - Raw response object (optional)
|
|
103
|
+
* @param error - Custom error message (optional, defaults to status text)
|
|
104
|
+
*/
|
|
105
|
+
constructor(metadata, raw, error) {
|
|
106
|
+
super(error);
|
|
107
|
+
this.error = metadata.statusText;
|
|
108
|
+
this.metadata = metadata;
|
|
109
|
+
this.raw = raw;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/http/hooks/custom-hook.ts
|
|
114
|
+
var CustomHook = class {
|
|
115
|
+
/**
|
|
116
|
+
* Called before an HTTP request is sent.
|
|
117
|
+
* Default implementation returns the request unchanged.
|
|
118
|
+
* @param request - The HTTP request to be sent
|
|
119
|
+
* @param params - Additional custom parameters
|
|
120
|
+
* @returns A promise that resolves to the unmodified request
|
|
121
|
+
*/
|
|
122
|
+
async beforeRequest(request, params) {
|
|
123
|
+
return request;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Called after a successful HTTP response is received.
|
|
127
|
+
* Default implementation returns the response unchanged.
|
|
128
|
+
* @param request - The original HTTP request
|
|
129
|
+
* @param response - The HTTP response received
|
|
130
|
+
* @param params - Additional custom parameters
|
|
131
|
+
* @returns A promise that resolves to the unmodified response
|
|
132
|
+
*/
|
|
133
|
+
async afterResponse(request, response, params) {
|
|
134
|
+
return response;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Called when an HTTP request results in an error.
|
|
138
|
+
* Default implementation wraps the error response in an HttpError object.
|
|
139
|
+
* @param request - The original HTTP request
|
|
140
|
+
* @param response - The error response received
|
|
141
|
+
* @param params - Additional custom parameters
|
|
142
|
+
* @returns A promise that resolves to an HttpError object
|
|
143
|
+
*/
|
|
144
|
+
async onError(request, response, params) {
|
|
145
|
+
return new HttpError(response.metadata, response.raw);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/http/serialization/base-serializer.ts
|
|
150
|
+
var Serializer = class {
|
|
151
|
+
/**
|
|
152
|
+
* Serializes a parameter value based on its type and serialization style.
|
|
153
|
+
* @param param - The request parameter to serialize
|
|
154
|
+
* @returns The serialized string representation
|
|
155
|
+
*/
|
|
156
|
+
serializeValue(param) {
|
|
157
|
+
if (Array.isArray(param.value)) {
|
|
158
|
+
return this.serializeArray(param.value, param);
|
|
159
|
+
}
|
|
160
|
+
if (this.isNonNullObject(param.value)) {
|
|
161
|
+
return this.serializeObject(param.value, param);
|
|
162
|
+
}
|
|
163
|
+
return this.serializePrimitive(param);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Serializes a primitive value (string, number, boolean).
|
|
167
|
+
* @param param - The request parameter containing the primitive value
|
|
168
|
+
* @returns The serialized primitive string
|
|
169
|
+
*/
|
|
170
|
+
serializePrimitive(param) {
|
|
171
|
+
if (param.style === "label" /* LABEL */) {
|
|
172
|
+
return `.${param.value}`;
|
|
173
|
+
} else if (param.style === "matrix" /* MATRIX */) {
|
|
174
|
+
return `;${param.key}=${param.value}`;
|
|
175
|
+
} else if (param.style === "form" /* FORM */) {
|
|
176
|
+
return `${encodeURIComponent(param.key || "")}=${encodeURIComponent(`${param.value}`)}`;
|
|
177
|
+
}
|
|
178
|
+
return `${param.value}`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Serializes an array value according to the specified style.
|
|
182
|
+
* @param value - The array to serialize
|
|
183
|
+
* @param param - The request parameter configuration
|
|
184
|
+
* @returns The serialized array string
|
|
185
|
+
*/
|
|
186
|
+
serializeArray(value, param) {
|
|
187
|
+
if (param.explode) {
|
|
188
|
+
this.serializeArrayExploded(value, param);
|
|
189
|
+
return this.serializeArrayExploded(value, param);
|
|
190
|
+
}
|
|
191
|
+
if (param.style === "simple" /* SIMPLE */) {
|
|
192
|
+
return `${value.join(",")}`;
|
|
193
|
+
} else if (param.style === "label" /* LABEL */) {
|
|
194
|
+
return `.${value.join(",")}`;
|
|
195
|
+
} else if (param.style === "matrix" /* MATRIX */) {
|
|
196
|
+
return `;${param.key}=${value.join(",")}`;
|
|
197
|
+
} else if (param.style === "form" /* FORM */) {
|
|
198
|
+
return `${encodeURIComponent(param.key || "")}=${encodeURIComponent(value.join(","))}`;
|
|
199
|
+
} else if (param.style === "space_delimited" /* SPACE_DELIMITED */) {
|
|
200
|
+
return `${param.key}=${value.join(" ")}`;
|
|
201
|
+
} else if (param.style === "pipe_delimited" /* PIPE_DELIMITED */) {
|
|
202
|
+
return `${param.key}=${value.join("|")}`;
|
|
203
|
+
}
|
|
204
|
+
return `${value.join(",")}`;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Serializes an array in exploded format where each value is a separate parameter.
|
|
208
|
+
* @param value - The array to serialize
|
|
209
|
+
* @param param - The request parameter configuration
|
|
210
|
+
* @returns The serialized exploded array string
|
|
211
|
+
*/
|
|
212
|
+
serializeArrayExploded(value, param) {
|
|
213
|
+
if (param.style === "simple" /* SIMPLE */) {
|
|
214
|
+
return value.map((val) => `${val}`).join(",");
|
|
215
|
+
} else if (param.style === "label" /* LABEL */) {
|
|
216
|
+
return value.map((val) => `.${val}`).join("");
|
|
217
|
+
} else if (param.style === "matrix" /* MATRIX */) {
|
|
218
|
+
return value.map((val) => `;${param.key}=${val}`).join("");
|
|
219
|
+
} else if (param.style === "form" /* FORM */ || param.style === "space_delimited" /* SPACE_DELIMITED */ || param.style === "pipe_delimited" /* PIPE_DELIMITED */) {
|
|
220
|
+
return value.map((val) => `${encodeURIComponent(param.key || "")}=${encodeURIComponent(`${val}`)}`).join("&");
|
|
221
|
+
}
|
|
222
|
+
return `${value.join(",")}`;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Serializes an object value according to the specified style.
|
|
226
|
+
* @param obj - The object to serialize
|
|
227
|
+
* @param param - The request parameter configuration
|
|
228
|
+
* @returns The serialized object string
|
|
229
|
+
*/
|
|
230
|
+
serializeObject(obj, param) {
|
|
231
|
+
if (param.explode) {
|
|
232
|
+
if (param.style === "simple" /* SIMPLE */) {
|
|
233
|
+
return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join(",");
|
|
234
|
+
} else if (param.style === "label" /* LABEL */) {
|
|
235
|
+
return Object.entries(obj).map(([key, val]) => `.${key}=${val}`).join("");
|
|
236
|
+
} else if (param.style === "matrix" /* MATRIX */) {
|
|
237
|
+
return Object.entries(obj).map(([key, val]) => `;${key}=${val}`).join("");
|
|
238
|
+
} else if (param.style === "form" /* FORM */) {
|
|
239
|
+
return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join("&");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (param.style === "simple" /* SIMPLE */) {
|
|
243
|
+
return Object.entries(obj).map(([key, val]) => `${key},${val}`).join(",");
|
|
244
|
+
} else if (param.style === "label" /* LABEL */) {
|
|
245
|
+
return `.${Object.entries(obj).map(([key, val]) => `${key},${val}`).join(",")}`;
|
|
246
|
+
} else if (param.style === "matrix" /* MATRIX */) {
|
|
247
|
+
return `;${param.key}=${Object.entries(obj).map(([key, val]) => `${key},${val}`).join(",")}`;
|
|
248
|
+
} else if (param.style === "form" /* FORM */) {
|
|
249
|
+
return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join("&");
|
|
250
|
+
} else if (param.style === "deep_object" /* DEEP_OBJECT */) {
|
|
251
|
+
return Object.entries(obj).map(([key, val]) => {
|
|
252
|
+
return `${param.key}[${key}]=${val}`;
|
|
253
|
+
}).join("&");
|
|
254
|
+
}
|
|
255
|
+
return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join("&");
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Type guard to check if a value is a non-null object.
|
|
259
|
+
* @param value - The value to check
|
|
260
|
+
* @returns True if the value is an object and not null
|
|
261
|
+
*/
|
|
262
|
+
isNonNullObject(value) {
|
|
263
|
+
return typeof value === "object" && value !== null;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/http/transport/transport-hook-adapter.ts
|
|
268
|
+
var TransportHookAdapter = class {
|
|
269
|
+
constructor() {
|
|
270
|
+
this.hook = new CustomHook();
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Invokes the custom hook before sending the request.
|
|
274
|
+
* Converts the Request to HttpRequest format, calls the hook, then converts back.
|
|
275
|
+
*
|
|
276
|
+
* @param request - The internal Request object
|
|
277
|
+
* @param params - Additional parameters to pass to the hook
|
|
278
|
+
* @returns The modified Request after hook processing
|
|
279
|
+
*/
|
|
280
|
+
async beforeRequest(request, params) {
|
|
281
|
+
const hookRequest = this.requestToHookRequest(request);
|
|
282
|
+
const newRequest = await this.hook.beforeRequest(hookRequest, params);
|
|
283
|
+
const newTransportRequest = request.copy({
|
|
284
|
+
baseUrl: newRequest.baseUrl,
|
|
285
|
+
method: newRequest.method,
|
|
286
|
+
path: newRequest.path,
|
|
287
|
+
body: newRequest.body,
|
|
288
|
+
queryParams: this.hookParamsToTransportParams(
|
|
289
|
+
newRequest.queryParams,
|
|
290
|
+
request.queryParams,
|
|
291
|
+
true
|
|
292
|
+
),
|
|
293
|
+
headers: this.hookParamsToTransportParams(newRequest.headers, request.headers, false),
|
|
294
|
+
pathParams: this.hookParamsToTransportParams(newRequest.pathParams, request.headers, false)
|
|
295
|
+
});
|
|
296
|
+
return newTransportRequest;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Invokes the custom hook after receiving a response.
|
|
300
|
+
* Converts the Request to HttpRequest format and calls the hook with the response.
|
|
301
|
+
*
|
|
302
|
+
* @param request - The internal Request object
|
|
303
|
+
* @param response - The HTTP response received
|
|
304
|
+
* @param params - Additional parameters to pass to the hook
|
|
305
|
+
* @returns The potentially modified response after hook processing
|
|
306
|
+
*/
|
|
307
|
+
async afterResponse(request, response, params) {
|
|
308
|
+
const hookRequest = this.requestToHookRequest(request);
|
|
309
|
+
return this.hook.afterResponse(hookRequest, response, params);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Invokes the custom hook when an error occurs.
|
|
313
|
+
* Converts the Request to HttpRequest format and calls the error hook.
|
|
314
|
+
*
|
|
315
|
+
* @param request - The internal Request object
|
|
316
|
+
* @param response - The HTTP response that triggered the error
|
|
317
|
+
* @param params - Additional parameters to pass to the hook
|
|
318
|
+
* @returns The HttpError from the hook
|
|
319
|
+
*/
|
|
320
|
+
async onError(request, response, params) {
|
|
321
|
+
const hookRequest = this.requestToHookRequest(request);
|
|
322
|
+
return this.hook.onError(hookRequest, response, params);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Converts the internal Request representation to the hook's HttpRequest format.
|
|
326
|
+
* Extracts parameter values from RequestParameter wrappers.
|
|
327
|
+
*
|
|
328
|
+
* @param request - The internal Request object
|
|
329
|
+
* @returns An HttpRequest object for hook processing
|
|
330
|
+
*/
|
|
331
|
+
requestToHookRequest(request) {
|
|
332
|
+
const hookHeaders = /* @__PURE__ */ new Map();
|
|
333
|
+
request.headers.forEach((header, key) => {
|
|
334
|
+
hookHeaders.set(key, header.value);
|
|
335
|
+
});
|
|
336
|
+
const hookQueryParams = /* @__PURE__ */ new Map();
|
|
337
|
+
request.queryParams.forEach((queryParam, key) => {
|
|
338
|
+
hookQueryParams.set(key, queryParam.value);
|
|
339
|
+
});
|
|
340
|
+
const hookPathParams = /* @__PURE__ */ new Map();
|
|
341
|
+
request.pathParams.forEach((pathParam, key) => {
|
|
342
|
+
hookPathParams.set(key, pathParam.value);
|
|
343
|
+
});
|
|
344
|
+
const hookRequest = {
|
|
345
|
+
baseUrl: request.baseUrl,
|
|
346
|
+
method: request.method,
|
|
347
|
+
path: request.path,
|
|
348
|
+
headers: hookHeaders,
|
|
349
|
+
body: request.body,
|
|
350
|
+
queryParams: hookQueryParams,
|
|
351
|
+
pathParams: hookPathParams
|
|
352
|
+
};
|
|
353
|
+
return hookRequest;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Converts hook parameter maps back to RequestParameter format.
|
|
357
|
+
* Preserves serialization metadata from the original parameters.
|
|
358
|
+
*
|
|
359
|
+
* @template T - The parameter value type
|
|
360
|
+
* @param hookParams - The parameter map from hook processing
|
|
361
|
+
* @param originalTransportParams - The original RequestParameter map for metadata
|
|
362
|
+
* @param encode - Whether to encode the parameters
|
|
363
|
+
* @returns A map of RequestParameter objects for transport
|
|
364
|
+
*/
|
|
365
|
+
hookParamsToTransportParams(hookParams, originalTransportParams, encode) {
|
|
366
|
+
const transportParams = /* @__PURE__ */ new Map();
|
|
367
|
+
hookParams.forEach((hookParamValue, hookParamKey) => {
|
|
368
|
+
var _a, _b, _c, _d, _e;
|
|
369
|
+
const requestParam = originalTransportParams.get(hookParamKey);
|
|
370
|
+
transportParams.set(hookParamKey, {
|
|
371
|
+
key: hookParamKey,
|
|
372
|
+
value: hookParamValue,
|
|
373
|
+
encode: (_a = requestParam == null ? void 0 : requestParam.encode) != null ? _a : false,
|
|
374
|
+
style: (requestParam == null ? void 0 : requestParam.style) || "none" /* NONE */,
|
|
375
|
+
explode: (_b = requestParam == null ? void 0 : requestParam.explode) != null ? _b : false,
|
|
376
|
+
isLimit: (_c = requestParam == null ? void 0 : requestParam.isLimit) != null ? _c : false,
|
|
377
|
+
isOffset: (_d = requestParam == null ? void 0 : requestParam.isOffset) != null ? _d : false,
|
|
378
|
+
isCursor: (_e = requestParam == null ? void 0 : requestParam.isCursor) != null ? _e : false
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
return transportParams;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/http/utils/content-type.ts
|
|
386
|
+
function getContentTypeDefinition(contentType) {
|
|
387
|
+
const ct = contentType.toLowerCase();
|
|
388
|
+
if (ct.startsWith("application/") && ct.includes("xml")) {
|
|
389
|
+
return "xml" /* Xml */;
|
|
390
|
+
}
|
|
391
|
+
if (ct === "application/x-www-form-urlencoded") {
|
|
392
|
+
return "form" /* FormUrlEncoded */;
|
|
393
|
+
}
|
|
394
|
+
if (ct === "text/event-stream") {
|
|
395
|
+
return "eventStream" /* EventStream */;
|
|
396
|
+
}
|
|
397
|
+
if (ct === "application/json" || ct === "text/json" || ct.includes("+json")) {
|
|
398
|
+
return "json" /* Json */;
|
|
399
|
+
}
|
|
400
|
+
if (ct === "application/javascript") {
|
|
401
|
+
return "text" /* Text */;
|
|
402
|
+
}
|
|
403
|
+
if (ct.startsWith("text/")) {
|
|
404
|
+
return "text" /* Text */;
|
|
405
|
+
}
|
|
406
|
+
if (ct === "image/svg+xml") {
|
|
407
|
+
return "text" /* Text */;
|
|
408
|
+
}
|
|
409
|
+
if (ct.startsWith("image/")) {
|
|
410
|
+
return "image" /* Image */;
|
|
411
|
+
}
|
|
412
|
+
if (ct === "application/octet-stream" || ct === "application/pdf") {
|
|
413
|
+
return "binary" /* Binary */;
|
|
414
|
+
}
|
|
415
|
+
if (ct === "*/*") {
|
|
416
|
+
return "binary" /* Binary */;
|
|
417
|
+
}
|
|
418
|
+
return "binary" /* Binary */;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// src/http/handlers/hook-handler.ts
|
|
422
|
+
var HookHandler = class {
|
|
423
|
+
constructor(hook) {
|
|
424
|
+
this.hook = hook;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Handles a standard HTTP request with hook invocation.
|
|
428
|
+
* Calls beforeRequest hook, processes the request, and calls afterResponse or onError hooks.
|
|
429
|
+
* @template T - The expected response data type
|
|
430
|
+
* @param request - The HTTP request to process
|
|
431
|
+
* @returns A promise that resolves to the HTTP response
|
|
432
|
+
* @throws Error if no next handler is set, or if error handling fails
|
|
433
|
+
*/
|
|
434
|
+
async handle(request) {
|
|
435
|
+
var _a;
|
|
436
|
+
if (!this.next) {
|
|
437
|
+
throw new Error("No next handler set in hook handler.");
|
|
438
|
+
}
|
|
439
|
+
const hook = new TransportHookAdapter();
|
|
440
|
+
const hookParams = this.getHookParams(request);
|
|
441
|
+
const nextRequest = await hook.beforeRequest(request, hookParams);
|
|
442
|
+
const response = await this.next.handle(nextRequest);
|
|
443
|
+
if (response.metadata.status < 400) {
|
|
444
|
+
return await hook.afterResponse(nextRequest, response, hookParams);
|
|
445
|
+
}
|
|
446
|
+
const arrayBuffer = response.raw;
|
|
447
|
+
const rawContentType = ((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.toLocaleLowerCase()) || "";
|
|
448
|
+
const contentType = getContentTypeDefinition(rawContentType);
|
|
449
|
+
const statusCode = response.metadata.status;
|
|
450
|
+
const error = request.errors.find((error2) => {
|
|
451
|
+
return error2.contentType === contentType && error2.status === statusCode;
|
|
452
|
+
});
|
|
453
|
+
if (error) {
|
|
454
|
+
const decodedBody2 = new TextDecoder().decode(arrayBuffer);
|
|
455
|
+
const json = JSON.parse(decodedBody2);
|
|
456
|
+
const customError = new error.error((json == null ? void 0 : json.message) || "", json);
|
|
457
|
+
customError.metadata = response.metadata;
|
|
458
|
+
customError.throw();
|
|
459
|
+
}
|
|
460
|
+
const decodedBody = new TextDecoder().decode(arrayBuffer);
|
|
461
|
+
throw new HttpError(
|
|
462
|
+
response.metadata,
|
|
463
|
+
arrayBuffer,
|
|
464
|
+
`Unexpected response body for error status.
|
|
465
|
+
StatusCode: ${response.metadata.status}
|
|
466
|
+
Body: ${decodedBody}`
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Handles a streaming HTTP request with hook invocation.
|
|
471
|
+
* Calls beforeRequest hook and afterResponse/onError hooks for each chunk.
|
|
472
|
+
* @template T - The expected response data type for each chunk
|
|
473
|
+
* @param request - The HTTP request to process
|
|
474
|
+
* @returns An async generator that yields HTTP responses
|
|
475
|
+
* @throws Error if no next handler is set, or if error handling fails
|
|
476
|
+
*/
|
|
477
|
+
async *stream(request) {
|
|
478
|
+
if (!this.next) {
|
|
479
|
+
throw new Error("No next handler set in hook handler.");
|
|
480
|
+
}
|
|
481
|
+
const hook = new TransportHookAdapter();
|
|
482
|
+
const hookParams = this.getHookParams(request);
|
|
483
|
+
const nextRequest = await hook.beforeRequest(request, hookParams);
|
|
484
|
+
const stream = this.next.stream(nextRequest);
|
|
485
|
+
for await (const response of stream) {
|
|
486
|
+
if (response.metadata.status < 400) {
|
|
487
|
+
yield await hook.afterResponse(nextRequest, response, hookParams);
|
|
488
|
+
} else {
|
|
489
|
+
throw await hook.onError(nextRequest, response, hookParams);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Extracts hook parameters from the request configuration.
|
|
495
|
+
* @template T - The response data type
|
|
496
|
+
* @param request - The HTTP request
|
|
497
|
+
* @returns A map of hook parameter names to values
|
|
498
|
+
*/
|
|
499
|
+
getHookParams(_request) {
|
|
500
|
+
const hookParams = /* @__PURE__ */ new Map();
|
|
501
|
+
return hookParams;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
// src/http/handlers/response-validation-handler.ts
|
|
506
|
+
var import_zod = require("zod");
|
|
507
|
+
|
|
508
|
+
// src/http/utils/response-matcher.ts
|
|
509
|
+
var ResponseMatcher = class {
|
|
510
|
+
/**
|
|
511
|
+
* Creates a new response matcher.
|
|
512
|
+
* @param responses - Array of possible response definitions for an endpoint
|
|
513
|
+
*/
|
|
514
|
+
constructor(responses) {
|
|
515
|
+
this.responses = responses;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Finds the matching response definition for an HTTP response.
|
|
519
|
+
* Matches based on status code and content type from the response headers.
|
|
520
|
+
* @param response - The HTTP response to match
|
|
521
|
+
* @returns The matching response definition, or undefined if no match found
|
|
522
|
+
*/
|
|
523
|
+
getResponseDefinition(response) {
|
|
524
|
+
var _a;
|
|
525
|
+
const rawContentType = ((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.toLocaleLowerCase()) || "";
|
|
526
|
+
const contentType = getContentTypeDefinition(rawContentType);
|
|
527
|
+
const statusCode = response.metadata.status;
|
|
528
|
+
if (!this.responses.length) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (this.responses.length === 1) {
|
|
532
|
+
return this.responses[0];
|
|
533
|
+
}
|
|
534
|
+
return this.responses.find((response2) => {
|
|
535
|
+
return response2.contentType === contentType && response2.status === statusCode;
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// src/http/handlers/response-validation-handler.ts
|
|
541
|
+
var ResponseValidationHandler = class {
|
|
542
|
+
/**
|
|
543
|
+
* Handles a standard HTTP request and validates its response.
|
|
544
|
+
* @template T - The expected response data type
|
|
545
|
+
* @param request - The HTTP request to process
|
|
546
|
+
* @returns A promise that resolves to the validated HTTP response
|
|
547
|
+
*/
|
|
548
|
+
async handle(request) {
|
|
549
|
+
const response = await this.next.handle(request);
|
|
550
|
+
return this.decodeBody(request, response);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Handles a streaming HTTP request and validates response chunks.
|
|
554
|
+
* @template T - The expected response data type for each chunk
|
|
555
|
+
* @param request - The HTTP request to process
|
|
556
|
+
* @returns An async generator that yields validated HTTP responses
|
|
557
|
+
* @throws Error if response headers are enabled (streaming not supported with headers)
|
|
558
|
+
*/
|
|
559
|
+
async *stream(request) {
|
|
560
|
+
const stream = this.next.stream(request);
|
|
561
|
+
for await (const response of stream) {
|
|
562
|
+
const responseChunks = this.splitByDataChunks(response);
|
|
563
|
+
for (const chunk of responseChunks) {
|
|
564
|
+
yield this.decodeBody(request, chunk);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
splitByDataChunks(response) {
|
|
569
|
+
var _a;
|
|
570
|
+
if (!((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.includes("text/event-stream"))) {
|
|
571
|
+
return [response];
|
|
572
|
+
}
|
|
573
|
+
const text = new TextDecoder().decode(response.raw);
|
|
574
|
+
const encoder = new TextEncoder();
|
|
575
|
+
return text.split("\n").filter((line) => line.startsWith("data: ")).map((part) => ({
|
|
576
|
+
...response,
|
|
577
|
+
raw: encoder.encode(part).buffer
|
|
578
|
+
}));
|
|
579
|
+
}
|
|
580
|
+
decodeBody(request, response) {
|
|
581
|
+
var _a;
|
|
582
|
+
const responseMatcher = new ResponseMatcher(request.responses);
|
|
583
|
+
const responseDefinition = responseMatcher.getResponseDefinition(response);
|
|
584
|
+
if (!responseDefinition || !this.hasContent(responseDefinition, response)) {
|
|
585
|
+
return response;
|
|
586
|
+
}
|
|
587
|
+
const contentType = responseDefinition.contentType;
|
|
588
|
+
const contentTypeHandlers = {
|
|
589
|
+
["binary" /* Binary */]: this.decodeFile,
|
|
590
|
+
["image" /* Image */]: this.decodeFile,
|
|
591
|
+
["multipartFormData" /* MultipartFormData */]: this.decodeMultipartFormData,
|
|
592
|
+
["text" /* Text */]: this.decodeText,
|
|
593
|
+
["xml" /* Xml */]: this.decodeText,
|
|
594
|
+
["form" /* FormUrlEncoded */]: this.decodeFormUrlEncoded,
|
|
595
|
+
["eventStream" /* EventStream */]: this.decodeEventStream
|
|
596
|
+
};
|
|
597
|
+
if (contentTypeHandlers[contentType]) {
|
|
598
|
+
return contentTypeHandlers[contentType].call(this, request, responseDefinition, response);
|
|
599
|
+
}
|
|
600
|
+
if ((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.includes("text/event-stream")) {
|
|
601
|
+
return this.decodeEventStream(request, responseDefinition, response);
|
|
602
|
+
}
|
|
603
|
+
return this.decodeJson(request, responseDefinition, response);
|
|
604
|
+
}
|
|
605
|
+
decodeFile(request, responseDefinition, response) {
|
|
606
|
+
return {
|
|
607
|
+
...response,
|
|
608
|
+
data: this.validate(request, responseDefinition, response.raw)
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
decodeMultipartFormData(request, responseDefinition, response) {
|
|
612
|
+
const formData = this.fromFormData(response.raw);
|
|
613
|
+
return {
|
|
614
|
+
...response,
|
|
615
|
+
data: this.validate(request, responseDefinition, formData)
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
decodeText(request, responseDefinition, response) {
|
|
619
|
+
const decodedBody = new TextDecoder().decode(response.raw);
|
|
620
|
+
return {
|
|
621
|
+
...response,
|
|
622
|
+
data: this.validate(request, responseDefinition, decodedBody)
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
decodeFormUrlEncoded(request, responseDefinition, response) {
|
|
626
|
+
const decodedBody = new TextDecoder().decode(response.raw);
|
|
627
|
+
const urlEncoded = this.fromUrlEncoded(decodedBody);
|
|
628
|
+
return {
|
|
629
|
+
...response,
|
|
630
|
+
data: this.validate(request, responseDefinition, urlEncoded)
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
decodeEventStream(request, responseDefinition, response) {
|
|
634
|
+
let decodedBody = new TextDecoder().decode(response.raw);
|
|
635
|
+
if (decodedBody.startsWith("data: ")) {
|
|
636
|
+
decodedBody = decodedBody.substring(6);
|
|
637
|
+
}
|
|
638
|
+
const json = JSON.parse(decodedBody);
|
|
639
|
+
return {
|
|
640
|
+
...response,
|
|
641
|
+
data: this.validate(request, responseDefinition, json)
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
decodeJson(request, responseDefinition, response) {
|
|
645
|
+
const decodedBody = new TextDecoder().decode(response.raw);
|
|
646
|
+
const json = JSON.parse(decodedBody);
|
|
647
|
+
return {
|
|
648
|
+
...response,
|
|
649
|
+
data: this.validate(request, responseDefinition, json)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Validates response data against the expected schema if validation is enabled.
|
|
654
|
+
* @template T - The expected data type
|
|
655
|
+
* @param request - The HTTP request containing validation settings
|
|
656
|
+
* @param response - The response definition with schema
|
|
657
|
+
* @param data - The data to validate
|
|
658
|
+
* @returns The validated data (parsed if validation enabled, raw otherwise)
|
|
659
|
+
*/
|
|
660
|
+
validate(request, response, data) {
|
|
661
|
+
var _a, _b;
|
|
662
|
+
if ((_b = (_a = request.config.validation) == null ? void 0 : _a.responseValidation) != null ? _b : true) {
|
|
663
|
+
return response.schema.parse(data);
|
|
664
|
+
}
|
|
665
|
+
return data;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Checks if a response should contain data based on its schema and status.
|
|
669
|
+
* @template T - The response data type
|
|
670
|
+
* @param responseDefinition - The response definition
|
|
671
|
+
* @param response - The HTTP response
|
|
672
|
+
* @returns True if the response should have content, false otherwise
|
|
673
|
+
*/
|
|
674
|
+
hasContent(responseDefinition, response) {
|
|
675
|
+
return !!responseDefinition.schema && !(responseDefinition.schema instanceof import_zod.ZodUndefined) && response.metadata.status !== 204;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Parses URL-encoded data into an object.
|
|
679
|
+
* @param urlEncodedData - The URL-encoded string
|
|
680
|
+
* @returns An object with decoded key-value pairs
|
|
681
|
+
*/
|
|
682
|
+
fromUrlEncoded(urlEncodedData) {
|
|
683
|
+
const pairs = urlEncodedData.split("&");
|
|
684
|
+
const result = {};
|
|
685
|
+
pairs.forEach((pair) => {
|
|
686
|
+
const [key, value] = pair.split("=");
|
|
687
|
+
if (key && value !== void 0) {
|
|
688
|
+
result[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
return result;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Parses multipart form data into an object.
|
|
695
|
+
* @param arrayBuffer - The raw form data as ArrayBuffer
|
|
696
|
+
* @returns An object with form field names and values
|
|
697
|
+
*/
|
|
698
|
+
fromFormData(arrayBuffer) {
|
|
699
|
+
const decoder = new TextDecoder();
|
|
700
|
+
const text = decoder.decode(arrayBuffer);
|
|
701
|
+
const boundary = text.split("\r\n")[0];
|
|
702
|
+
const parts = text.split(boundary).slice(1, -1);
|
|
703
|
+
const formDataObj = {};
|
|
704
|
+
parts.forEach((part) => {
|
|
705
|
+
const [header, value] = part.split("\r\n\r\n");
|
|
706
|
+
const nameMatch = header.match(/name="([^"]+)"/);
|
|
707
|
+
if (nameMatch) {
|
|
708
|
+
const name = nameMatch[1].trim();
|
|
709
|
+
formDataObj[name] = (value == null ? void 0 : value.trim()) || "";
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
return formDataObj;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// src/http/handlers/request-validation-handler.ts
|
|
717
|
+
var import_zod2 = require("zod");
|
|
718
|
+
|
|
719
|
+
// src/http/errors/validation-error.ts
|
|
720
|
+
var ValidationError = class extends Error {
|
|
721
|
+
/**
|
|
722
|
+
* Creates a new validation error from a Zod error.
|
|
723
|
+
* @param zodError - The Zod validation error containing issue details
|
|
724
|
+
* @param object - The object that failed validation
|
|
725
|
+
*/
|
|
726
|
+
constructor(zodError, object) {
|
|
727
|
+
let actual;
|
|
728
|
+
try {
|
|
729
|
+
actual = JSON.stringify(object, void 0, 2);
|
|
730
|
+
} catch (err) {
|
|
731
|
+
actual = object;
|
|
732
|
+
}
|
|
733
|
+
const error = [
|
|
734
|
+
`ValidationError:`,
|
|
735
|
+
...zodError.issues.map(
|
|
736
|
+
(issue) => ` Property: ${issue.path.join(".")}. Message: ${issue.message}`
|
|
737
|
+
),
|
|
738
|
+
" Validated:",
|
|
739
|
+
...actual.split("\n").map((line) => ` ${line}`)
|
|
740
|
+
].join("\n");
|
|
741
|
+
super(error);
|
|
742
|
+
this.error = error;
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
// src/http/handlers/request-validation-handler.ts
|
|
747
|
+
var RequestValidationHandler = class {
|
|
748
|
+
/**
|
|
749
|
+
* Handles a standard HTTP request with validation.
|
|
750
|
+
* @template T - The expected response data type
|
|
751
|
+
* @param request - The HTTP request to validate
|
|
752
|
+
* @returns A promise that resolves to the HTTP response
|
|
753
|
+
* @throws Error if no next handler is set
|
|
754
|
+
*/
|
|
755
|
+
async handle(request) {
|
|
756
|
+
if (!this.next) {
|
|
757
|
+
throw new Error("No next handler set in ContentTypeHandler.");
|
|
758
|
+
}
|
|
759
|
+
this.validateRequest(request);
|
|
760
|
+
return this.next.handle(request);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Handles a streaming HTTP request with validation.
|
|
764
|
+
* @template T - The expected response data type for each chunk
|
|
765
|
+
* @param request - The HTTP request to validate
|
|
766
|
+
* @returns An async generator that yields HTTP responses
|
|
767
|
+
* @throws Error if no next handler is set
|
|
768
|
+
*/
|
|
769
|
+
async *stream(request) {
|
|
770
|
+
if (!this.next) {
|
|
771
|
+
throw new Error("No next handler set in ContentTypeHandler.");
|
|
772
|
+
}
|
|
773
|
+
this.validateRequest(request);
|
|
774
|
+
yield* this.next.stream(request);
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Validates and serializes the request body based on its content type.
|
|
778
|
+
* @param request - The HTTP request to validate
|
|
779
|
+
* @throws ValidationError if Zod schema validation fails
|
|
780
|
+
*/
|
|
781
|
+
validateRequest(request) {
|
|
782
|
+
var _a, _b;
|
|
783
|
+
if (request.requestContentType === "json" /* Json */) {
|
|
784
|
+
try {
|
|
785
|
+
const parsedBody = (_a = request.requestSchema) == null ? void 0 : _a.parse(request.body);
|
|
786
|
+
request.body = JSON.stringify(parsedBody);
|
|
787
|
+
} catch (error) {
|
|
788
|
+
if (error instanceof import_zod2.ZodError) {
|
|
789
|
+
throw new ValidationError(error, request.body);
|
|
790
|
+
}
|
|
791
|
+
throw error;
|
|
792
|
+
}
|
|
793
|
+
} else if (request.requestContentType === "xml" /* Xml */ || request.requestContentType === "text" /* Text */ || request.requestContentType === "image" /* Image */ || request.requestContentType === "binary" /* Binary */) {
|
|
794
|
+
request.body = request.body;
|
|
795
|
+
} else if (request.requestContentType === "form" /* FormUrlEncoded */) {
|
|
796
|
+
request.body = this.toFormUrlEncoded(request);
|
|
797
|
+
} else if (request.requestContentType === "multipartFormData" /* MultipartFormData */) {
|
|
798
|
+
request.body = this.toFormData(request.body, request.filename, request.filenames);
|
|
799
|
+
} else {
|
|
800
|
+
request.body = JSON.stringify((_b = request.requestSchema) == null ? void 0 : _b.parse(request.body));
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Converts request body to URL-encoded form data format.
|
|
805
|
+
* @param request - The HTTP request with body to convert
|
|
806
|
+
* @returns URL-encoded string representation of the body
|
|
807
|
+
*/
|
|
808
|
+
toFormUrlEncoded(request) {
|
|
809
|
+
var _a;
|
|
810
|
+
if (request.body === void 0) {
|
|
811
|
+
return "";
|
|
812
|
+
}
|
|
813
|
+
if (typeof request.body === "string") {
|
|
814
|
+
return request.body;
|
|
815
|
+
}
|
|
816
|
+
if (request.body instanceof URLSearchParams) {
|
|
817
|
+
return request.body.toString();
|
|
818
|
+
}
|
|
819
|
+
const validatedBody = (_a = request.requestSchema) == null ? void 0 : _a.parse(request.body);
|
|
820
|
+
if (validatedBody instanceof FormData) {
|
|
821
|
+
const params = new URLSearchParams();
|
|
822
|
+
validatedBody.forEach((value, key) => {
|
|
823
|
+
if (value != null) {
|
|
824
|
+
params.append(key, value.toString());
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
return params.toString();
|
|
828
|
+
}
|
|
829
|
+
if (typeof validatedBody === "object" && !Array.isArray(validatedBody)) {
|
|
830
|
+
const params = new URLSearchParams();
|
|
831
|
+
for (const [key, value] of Object.entries(validatedBody)) {
|
|
832
|
+
if (value != null) {
|
|
833
|
+
params.append(key, `${value}`);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return params.toString();
|
|
837
|
+
}
|
|
838
|
+
return "";
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Converts request body to multipart form data format.
|
|
842
|
+
* Handles files (ArrayBuffer), arrays, and regular values.
|
|
843
|
+
* @param body - The request body object
|
|
844
|
+
* @param filename - Optional filename for single file uploads
|
|
845
|
+
* @param filenames - Optional filenames array for array of file uploads
|
|
846
|
+
* @returns FormData object with serialized body
|
|
847
|
+
*/
|
|
848
|
+
toFormData(body, filename, filenames) {
|
|
849
|
+
const formData = new FormData();
|
|
850
|
+
Object.keys(body).forEach((key) => {
|
|
851
|
+
const value = body[key];
|
|
852
|
+
if (Array.isArray(value)) {
|
|
853
|
+
value.forEach((v, i) => {
|
|
854
|
+
if (v instanceof ArrayBuffer) {
|
|
855
|
+
const fileFilename = filenames && filenames[i] ? filenames[i] : `${key}[${i}]`;
|
|
856
|
+
formData.append(`${key}[${i}]`, new Blob([v]), fileFilename);
|
|
857
|
+
} else {
|
|
858
|
+
formData.append(`${key}[${i}]`, v);
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
} else if (value instanceof ArrayBuffer) {
|
|
862
|
+
const fileFilename = filename || key;
|
|
863
|
+
formData.append(key, new Blob([value]), fileFilename);
|
|
864
|
+
} else {
|
|
865
|
+
formData.append(key, value);
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
return formData;
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
// src/http/utils/line-decoder.ts
|
|
873
|
+
var LineDecoder = class {
|
|
874
|
+
constructor() {
|
|
875
|
+
this.lineBuffer = "";
|
|
876
|
+
this.decoder = new TextDecoder();
|
|
877
|
+
this.encoder = new TextEncoder();
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Splits the given chunk into lines.
|
|
881
|
+
* Stores incomplete lines in a buffer and returns them when the next chunk arrives.
|
|
882
|
+
*
|
|
883
|
+
* @param chunk - The data chunk to split into lines
|
|
884
|
+
* @returns An array of complete lines as Uint8Array
|
|
885
|
+
*/
|
|
886
|
+
splitLines(chunk) {
|
|
887
|
+
this.lineBuffer += this.decoder.decode(chunk);
|
|
888
|
+
let lineEndIndex;
|
|
889
|
+
const lines = [];
|
|
890
|
+
while ((lineEndIndex = this.lineBuffer.indexOf("\n")) >= 0) {
|
|
891
|
+
const line = this.lineBuffer.slice(0, lineEndIndex + 1);
|
|
892
|
+
this.lineBuffer = this.lineBuffer.slice(lineEndIndex + 1);
|
|
893
|
+
if (line.length > 1) {
|
|
894
|
+
lines.push(this.encoder.encode(line));
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return lines;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Returns the remaining lines in the buffer.
|
|
901
|
+
* Call this after the stream ends to get any incomplete final line.
|
|
902
|
+
*
|
|
903
|
+
* @returns An array containing the buffered line, or empty if buffer is empty
|
|
904
|
+
*/
|
|
905
|
+
flush() {
|
|
906
|
+
if (this.lineBuffer.length === 0) {
|
|
907
|
+
return [];
|
|
908
|
+
}
|
|
909
|
+
const lines = [this.encoder.encode(this.lineBuffer)];
|
|
910
|
+
this.lineBuffer = "";
|
|
911
|
+
return lines;
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
// src/http/transport/request-fetch-adapter.ts
|
|
916
|
+
var RequestFetchAdapter = class {
|
|
917
|
+
constructor(request) {
|
|
918
|
+
this.request = request;
|
|
919
|
+
this.requestInit = {};
|
|
920
|
+
this.setMethod(request.method);
|
|
921
|
+
this.setHeaders(request.getHeaders());
|
|
922
|
+
this.setCookies(request.getCookies());
|
|
923
|
+
this.setBody(request.body);
|
|
924
|
+
this.setTimeout(request.config.timeoutMs);
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Executes the HTTP request and returns the response.
|
|
928
|
+
* Fetches the full response body as an ArrayBuffer.
|
|
929
|
+
*
|
|
930
|
+
* @returns A promise resolving to the HTTP response with metadata and body
|
|
931
|
+
*/
|
|
932
|
+
async send() {
|
|
933
|
+
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
934
|
+
const metadata = {
|
|
935
|
+
status: response.status,
|
|
936
|
+
statusText: response.statusText || "",
|
|
937
|
+
headers: this.getHeaders(response)
|
|
938
|
+
};
|
|
939
|
+
return {
|
|
940
|
+
metadata,
|
|
941
|
+
raw: await response.clone().arrayBuffer()
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Executes the HTTP request as a stream, yielding chunks as they arrive.
|
|
946
|
+
* Uses the Fetch API's ReadableStream and LineDecoder to split into lines.
|
|
947
|
+
*
|
|
948
|
+
* @returns An async generator yielding HTTP response chunks
|
|
949
|
+
* @throws Error if responseHeaders is enabled (streaming not supported with responseHeaders)
|
|
950
|
+
*/
|
|
951
|
+
async *stream() {
|
|
952
|
+
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
953
|
+
const metadata = {
|
|
954
|
+
status: response.status,
|
|
955
|
+
statusText: response.statusText || "",
|
|
956
|
+
headers: this.getHeaders(response)
|
|
957
|
+
};
|
|
958
|
+
if (response.status >= 400) {
|
|
959
|
+
throw new HttpError(metadata, await response.clone().arrayBuffer());
|
|
960
|
+
}
|
|
961
|
+
if (!response.body) {
|
|
962
|
+
return yield {
|
|
963
|
+
metadata,
|
|
964
|
+
raw: await response.clone().arrayBuffer()
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
const reader = response.body.getReader();
|
|
968
|
+
const lineDecoder = new LineDecoder();
|
|
969
|
+
while (true) {
|
|
970
|
+
const { done, value } = await reader.read();
|
|
971
|
+
if (done) {
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
for (const line of lineDecoder.splitLines(value)) {
|
|
975
|
+
yield {
|
|
976
|
+
metadata,
|
|
977
|
+
raw: this.toArrayBuffer(line)
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
for (const line of lineDecoder.flush()) {
|
|
982
|
+
yield {
|
|
983
|
+
metadata,
|
|
984
|
+
raw: this.toArrayBuffer(line)
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
setMethod(method) {
|
|
989
|
+
if (!method) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
this.requestInit = {
|
|
993
|
+
...this.requestInit,
|
|
994
|
+
method
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
setBody(body) {
|
|
998
|
+
if (!body) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
this.requestInit = {
|
|
1002
|
+
...this.requestInit,
|
|
1003
|
+
body
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
setHeaders(headers) {
|
|
1007
|
+
if (!headers) {
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
this.requestInit = {
|
|
1011
|
+
...this.requestInit,
|
|
1012
|
+
headers
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
setCookies(cookies) {
|
|
1016
|
+
if (!cookies || Object.keys(cookies).length === 0) {
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
const cookieString = Object.entries(cookies).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
1020
|
+
this.requestInit = {
|
|
1021
|
+
...this.requestInit,
|
|
1022
|
+
headers: {
|
|
1023
|
+
...this.requestInit.headers,
|
|
1024
|
+
Cookie: cookieString
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
setTimeout(timeoutMs) {
|
|
1029
|
+
if (!timeoutMs) {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
this.requestInit = {
|
|
1033
|
+
...this.requestInit,
|
|
1034
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
getHeaders(response) {
|
|
1038
|
+
const headers = {};
|
|
1039
|
+
response.headers.forEach((value, key) => {
|
|
1040
|
+
headers[key] = value;
|
|
1041
|
+
});
|
|
1042
|
+
return headers;
|
|
1043
|
+
}
|
|
1044
|
+
toArrayBuffer(uint8Array) {
|
|
1045
|
+
return uint8Array.buffer.slice(
|
|
1046
|
+
uint8Array.byteOffset,
|
|
1047
|
+
uint8Array.byteOffset + uint8Array.byteLength
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// src/http/handlers/terminating-handler.ts
|
|
1053
|
+
var TerminatingHandler = class {
|
|
1054
|
+
/**
|
|
1055
|
+
* Executes the actual HTTP request using the configured client adapter.
|
|
1056
|
+
* @template T - The expected response data type
|
|
1057
|
+
* @param request - The HTTP request to execute
|
|
1058
|
+
* @returns A promise that resolves to the HTTP response
|
|
1059
|
+
*/
|
|
1060
|
+
async handle(request) {
|
|
1061
|
+
return new RequestFetchAdapter(request).send();
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Executes a streaming HTTP request using the configured client adapter.
|
|
1065
|
+
* @template T - The expected response data type for each chunk
|
|
1066
|
+
* @param request - The HTTP request to execute
|
|
1067
|
+
* @returns An async generator that yields HTTP responses
|
|
1068
|
+
*/
|
|
1069
|
+
async *stream(request) {
|
|
1070
|
+
yield* new RequestFetchAdapter(request).stream();
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
// src/http/handlers/retry-handler.ts
|
|
1075
|
+
var RetryHandler = class {
|
|
1076
|
+
/**
|
|
1077
|
+
* Handles a standard HTTP request with retry logic.
|
|
1078
|
+
* Retries failed requests based on the configured retry settings.
|
|
1079
|
+
* Implements exponential backoff with optional jitter between retry attempts.
|
|
1080
|
+
* @template T - The expected response data type
|
|
1081
|
+
* @param request - The HTTP request to process
|
|
1082
|
+
* @returns A promise that resolves to the HTTP response
|
|
1083
|
+
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1084
|
+
*/
|
|
1085
|
+
async handle(request) {
|
|
1086
|
+
var _a, _b;
|
|
1087
|
+
if (!this.next) {
|
|
1088
|
+
throw new Error("No next handler set in retry handler.");
|
|
1089
|
+
}
|
|
1090
|
+
const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
|
|
1091
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
1092
|
+
try {
|
|
1093
|
+
return await this.next.handle(request);
|
|
1094
|
+
} catch (error) {
|
|
1095
|
+
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1096
|
+
throw error;
|
|
1097
|
+
}
|
|
1098
|
+
const delayMs = this.calculateDelay(attempt, request);
|
|
1099
|
+
await this.delay(delayMs);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
throw new Error("Error retrying request.");
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Handles a streaming HTTP request with retry logic.
|
|
1106
|
+
* @template T - The expected response data type for each chunk
|
|
1107
|
+
* @param request - The HTTP request to process
|
|
1108
|
+
* @returns An async generator that yields HTTP responses
|
|
1109
|
+
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1110
|
+
*/
|
|
1111
|
+
async *stream(request) {
|
|
1112
|
+
var _a, _b;
|
|
1113
|
+
if (!this.next) {
|
|
1114
|
+
throw new Error("No next handler set in retry handler.");
|
|
1115
|
+
}
|
|
1116
|
+
const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
|
|
1117
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
1118
|
+
try {
|
|
1119
|
+
yield* this.next.stream(request);
|
|
1120
|
+
return;
|
|
1121
|
+
} catch (error) {
|
|
1122
|
+
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1123
|
+
throw error;
|
|
1124
|
+
}
|
|
1125
|
+
const delayMs = this.calculateDelay(attempt, request);
|
|
1126
|
+
await this.delay(delayMs);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
throw new Error("Error retrying request.");
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Determines if an error should trigger a retry.
|
|
1133
|
+
* Checks both HTTP status codes and HTTP methods against the configured retry settings.
|
|
1134
|
+
* By default, retries all 5xx server errors and specific 4xx client errors (408 Timeout, 429 Rate Limit).
|
|
1135
|
+
* @param error - The error to check
|
|
1136
|
+
* @param request - The HTTP request being retried
|
|
1137
|
+
* @returns True if the request should be retried, false otherwise
|
|
1138
|
+
*/
|
|
1139
|
+
shouldRetry(error, request) {
|
|
1140
|
+
var _a, _b, _c;
|
|
1141
|
+
if (!(error instanceof HttpError)) {
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1144
|
+
const httpMethodsToRetry = (_b = (_a = request.config.retry) == null ? void 0 : _a.httpMethodsToRetry) != null ? _b : [
|
|
1145
|
+
"GET",
|
|
1146
|
+
"POST",
|
|
1147
|
+
"PUT",
|
|
1148
|
+
"DELETE",
|
|
1149
|
+
"PATCH",
|
|
1150
|
+
"HEAD",
|
|
1151
|
+
"OPTIONS"
|
|
1152
|
+
];
|
|
1153
|
+
const shouldRetryStatus = ((_c = request.config.retry) == null ? void 0 : _c.statusCodesToRetry) ? request.config.retry.statusCodesToRetry.includes(error.metadata.status) : error.metadata.status >= 500 || [408, 429].includes(error.metadata.status);
|
|
1154
|
+
const shouldRetryMethod = httpMethodsToRetry.includes(request.method);
|
|
1155
|
+
return shouldRetryStatus && shouldRetryMethod;
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Calculates the delay before the next retry attempt using exponential backoff.
|
|
1159
|
+
* Optionally adds jitter to prevent thundering herd problems.
|
|
1160
|
+
* @param attempt - The current retry attempt number (1-indexed)
|
|
1161
|
+
* @param request - The HTTP request being retried
|
|
1162
|
+
* @returns The delay in milliseconds, capped at the configured maximum delay
|
|
1163
|
+
*/
|
|
1164
|
+
calculateDelay(attempt, request) {
|
|
1165
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1166
|
+
const baseDelay = (_b = (_a = request.config.retry) == null ? void 0 : _a.delayMs) != null ? _b : 150;
|
|
1167
|
+
const backoffFactor = (_d = (_c = request.config.retry) == null ? void 0 : _c.backoffFactor) != null ? _d : 2;
|
|
1168
|
+
const maxDelay = (_f = (_e = request.config.retry) == null ? void 0 : _e.maxDelayMs) != null ? _f : 5e3;
|
|
1169
|
+
const jitter = (_h = (_g = request.config.retry) == null ? void 0 : _g.jitterMs) != null ? _h : 50;
|
|
1170
|
+
let delay = baseDelay * Math.pow(backoffFactor, attempt - 1);
|
|
1171
|
+
delay = Math.min(delay, maxDelay);
|
|
1172
|
+
if (jitter > 0) {
|
|
1173
|
+
delay += Math.random() * jitter;
|
|
1174
|
+
}
|
|
1175
|
+
return Math.floor(delay);
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Delays execution for a specified duration before retrying.
|
|
1179
|
+
* @param delayMs - The delay in milliseconds
|
|
1180
|
+
* @returns A promise that resolves after the delay
|
|
1181
|
+
*/
|
|
1182
|
+
delay(delayMs) {
|
|
1183
|
+
if (delayMs <= 0) {
|
|
1184
|
+
return Promise.resolve();
|
|
1185
|
+
}
|
|
1186
|
+
return new Promise((resolve, reject) => {
|
|
1187
|
+
setTimeout(() => resolve(), delayMs);
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// src/http/transport/types.ts
|
|
1193
|
+
function isRequestCursorPagination(pagination) {
|
|
1194
|
+
return !!pagination && "cursorPath" in pagination;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// src/http/client.ts
|
|
1198
|
+
var HttpClient = class {
|
|
1199
|
+
/**
|
|
1200
|
+
* Creates a new HTTP client with configured request handlers.
|
|
1201
|
+
* @param config - SDK configuration including base URL and authentication
|
|
1202
|
+
* @param hook - Optional custom hook for request/response interception
|
|
1203
|
+
*/
|
|
1204
|
+
constructor(config, hook = new CustomHook()) {
|
|
1205
|
+
this.config = config;
|
|
1206
|
+
/** Chain of request handlers that process requests in sequence */
|
|
1207
|
+
this.requestHandlerChain = new RequestHandlerChain();
|
|
1208
|
+
this.requestHandlerChain.addHandler(new ResponseValidationHandler());
|
|
1209
|
+
this.requestHandlerChain.addHandler(new RequestValidationHandler());
|
|
1210
|
+
this.requestHandlerChain.addHandler(new RetryHandler());
|
|
1211
|
+
this.requestHandlerChain.addHandler(new HookHandler(hook));
|
|
1212
|
+
this.requestHandlerChain.addHandler(new TerminatingHandler());
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Executes a standard HTTP request.
|
|
1216
|
+
* @template T - The expected response data type
|
|
1217
|
+
* @param request - The HTTP request to execute
|
|
1218
|
+
* @returns A promise that resolves to the HTTP response
|
|
1219
|
+
*/
|
|
1220
|
+
call(request) {
|
|
1221
|
+
return this.requestHandlerChain.callChain(request);
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Executes a standard HTTP request and returns only the data directly.
|
|
1225
|
+
* @template T - The expected response data type
|
|
1226
|
+
* @param request - The HTTP request to execute
|
|
1227
|
+
* @returns A promise that resolves to the response data
|
|
1228
|
+
*/
|
|
1229
|
+
callDirect(request) {
|
|
1230
|
+
return this.call(request).then((response) => response.data);
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Executes a streaming HTTP request that yields responses incrementally.
|
|
1234
|
+
* @template T - The expected response data type for each chunk
|
|
1235
|
+
* @param request - The HTTP request to execute
|
|
1236
|
+
* @returns An async generator that yields HTTP responses
|
|
1237
|
+
*/
|
|
1238
|
+
async *stream(request) {
|
|
1239
|
+
yield* this.requestHandlerChain.streamChain(request);
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Executes a paginated HTTP request and extracts the page data from the response.
|
|
1243
|
+
* @template FullResponse - The complete response type from the API
|
|
1244
|
+
* @template Page - The type of a single page of data
|
|
1245
|
+
* @param request - The paginated HTTP request to execute
|
|
1246
|
+
* @returns A promise that resolves to the paginated HTTP response
|
|
1247
|
+
* @throws Error if the response contains no data to paginate through
|
|
1248
|
+
*/
|
|
1249
|
+
async callPaginated(request) {
|
|
1250
|
+
const response = await this.call(request);
|
|
1251
|
+
if (!response.data) {
|
|
1252
|
+
throw new Error("no response data to paginate through");
|
|
1253
|
+
}
|
|
1254
|
+
const page = this.getPage(request, response.data);
|
|
1255
|
+
return {
|
|
1256
|
+
...response,
|
|
1257
|
+
data: page
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Executes a cursor-paginated HTTP request and extracts both page data and the next cursor.
|
|
1262
|
+
* @template FullResponse - The complete response type from the API
|
|
1263
|
+
* @template Page - The type of a single page of data
|
|
1264
|
+
* @param request - The cursor-paginated HTTP request to execute
|
|
1265
|
+
* @returns A promise that resolves to the cursor-paginated HTTP response with next cursor
|
|
1266
|
+
* @throws Error if the response contains no data to paginate through
|
|
1267
|
+
*/
|
|
1268
|
+
async callCursorPaginated(request) {
|
|
1269
|
+
const response = await this.call(request);
|
|
1270
|
+
if (!response.data) {
|
|
1271
|
+
throw new Error("no response data to paginate through");
|
|
1272
|
+
}
|
|
1273
|
+
const page = this.getPage(request, response.data);
|
|
1274
|
+
const nextCursor = this.getNextCursor(request, response.data);
|
|
1275
|
+
return {
|
|
1276
|
+
...response,
|
|
1277
|
+
data: page,
|
|
1278
|
+
nextCursor
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Updates the base URL for all subsequent requests.
|
|
1283
|
+
* @param url - The new base URL to use
|
|
1284
|
+
*/
|
|
1285
|
+
setBaseUrl(url) {
|
|
1286
|
+
this.config.baseUrl = url;
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Updates the SDK configuration.
|
|
1290
|
+
* @param config - The new SDK configuration
|
|
1291
|
+
*/
|
|
1292
|
+
setConfig(config) {
|
|
1293
|
+
this.config = config;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Extracts page data from a full API response using the configured pagination path.
|
|
1297
|
+
* @template FullResponse - The complete response type from the API
|
|
1298
|
+
* @template Page - The type of a single page of data
|
|
1299
|
+
* @param request - The request containing pagination configuration
|
|
1300
|
+
* @param data - The full response data to extract the page from
|
|
1301
|
+
* @returns The extracted and parsed page data
|
|
1302
|
+
* @throws Error if pagination is not configured or page extraction fails
|
|
1303
|
+
*/
|
|
1304
|
+
getPage(request, data) {
|
|
1305
|
+
var _a;
|
|
1306
|
+
if (!request.pagination) {
|
|
1307
|
+
throw new Error("getPage called for request without pagination property");
|
|
1308
|
+
}
|
|
1309
|
+
let curr = data;
|
|
1310
|
+
for (const segment of request.pagination.pagePath || []) {
|
|
1311
|
+
curr = curr[segment];
|
|
1312
|
+
}
|
|
1313
|
+
const page = (_a = request.pagination.pageSchema) == null ? void 0 : _a.parse(curr);
|
|
1314
|
+
if (!page) {
|
|
1315
|
+
throw new Error(
|
|
1316
|
+
`error getting page data. Curr: ${JSON.stringify(curr)}. PagePath: ${request.pagination.pagePath}. Data: ${JSON.stringify(data)}`
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
return page;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Extracts the next cursor from a full API response for cursor-based pagination.
|
|
1323
|
+
* @template FullResponse - The complete response type from the API
|
|
1324
|
+
* @template Page - The type of a single page of data
|
|
1325
|
+
* @param request - The request containing cursor pagination configuration
|
|
1326
|
+
* @param data - The full response data to extract the cursor from
|
|
1327
|
+
* @returns The next cursor string, null if no more pages, or undefined if not cursor pagination
|
|
1328
|
+
*/
|
|
1329
|
+
getNextCursor(request, data) {
|
|
1330
|
+
var _a, _b;
|
|
1331
|
+
if (!isRequestCursorPagination(request.pagination)) {
|
|
1332
|
+
return void 0;
|
|
1333
|
+
}
|
|
1334
|
+
let curr = data;
|
|
1335
|
+
for (const segment of request.pagination.cursorPath) {
|
|
1336
|
+
if (curr === null || curr === void 0) {
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
curr = curr[segment];
|
|
1340
|
+
}
|
|
1341
|
+
return (_b = (_a = request.pagination.cursorSchema) == null ? void 0 : _a.parse(curr)) != null ? _b : null;
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
// src/services/base-service.ts
|
|
1346
|
+
var BaseService = class {
|
|
1347
|
+
constructor(config) {
|
|
1348
|
+
this.config = config;
|
|
1349
|
+
this.client = new HttpClient(this.config);
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Sets service-level configuration that applies to all methods in this service.
|
|
1353
|
+
* @param config - Partial configuration to override SDK-level defaults
|
|
1354
|
+
* @returns This service instance for method chaining
|
|
1355
|
+
*/
|
|
1356
|
+
setConfig(config) {
|
|
1357
|
+
this.serviceConfig = config;
|
|
1358
|
+
return this;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Resolves configuration from the hierarchy: requestConfig > methodConfig > serviceConfig > sdkConfig
|
|
1362
|
+
* Merges all config levels into a single resolved config object.
|
|
1363
|
+
* @param methodConfig - Method-level configuration override
|
|
1364
|
+
* @param requestConfig - Request-level configuration override
|
|
1365
|
+
* @returns Merged configuration with all overrides applied
|
|
1366
|
+
*/
|
|
1367
|
+
getResolvedConfig(methodConfig, requestConfig) {
|
|
1368
|
+
return {
|
|
1369
|
+
...this.config,
|
|
1370
|
+
...this.serviceConfig,
|
|
1371
|
+
...methodConfig,
|
|
1372
|
+
...requestConfig
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
set baseUrl(baseUrl) {
|
|
1376
|
+
this.config.baseUrl = baseUrl;
|
|
1377
|
+
}
|
|
1378
|
+
set environment(environment) {
|
|
1379
|
+
this.config.environment = environment;
|
|
1380
|
+
}
|
|
1381
|
+
set timeoutMs(timeoutMs) {
|
|
1382
|
+
this.config.timeoutMs = timeoutMs;
|
|
1383
|
+
}
|
|
1384
|
+
set username(username) {
|
|
1385
|
+
this.config.username = username;
|
|
1386
|
+
}
|
|
1387
|
+
set password(password) {
|
|
1388
|
+
this.config.password = password;
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
// src/http/transport/request-builder.ts
|
|
1393
|
+
var import_zod3 = __toESM(require("zod"));
|
|
1394
|
+
|
|
1395
|
+
// src/http/serialization/path-serializer.ts
|
|
1396
|
+
var PathSerializer = class extends Serializer {
|
|
1397
|
+
/**
|
|
1398
|
+
* Serializes path parameters into a URL path by replacing template placeholders.
|
|
1399
|
+
* @param pathPattern - The URL path pattern with {placeholders}
|
|
1400
|
+
* @param pathArguments - Map of parameter names to their values
|
|
1401
|
+
* @returns The path with placeholders replaced by serialized values
|
|
1402
|
+
* @example
|
|
1403
|
+
* serialize("/users/{id}", Map([["id", {key: "id", value: 123}]])) returns "/users/123"
|
|
1404
|
+
*/
|
|
1405
|
+
serialize(pathPattern, pathArguments) {
|
|
1406
|
+
let serializedPath = pathPattern;
|
|
1407
|
+
pathArguments.forEach((param) => {
|
|
1408
|
+
serializedPath = serializedPath.replace(`{${param.key}}`, `${this.serializeValue(param)}`);
|
|
1409
|
+
});
|
|
1410
|
+
return serializedPath;
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
// src/http/serialization/query-serializer.ts
|
|
1415
|
+
var QuerySerializer = class extends Serializer {
|
|
1416
|
+
/**
|
|
1417
|
+
* Serializes query parameters into a URL query string.
|
|
1418
|
+
* @param queryParams - Map of query parameter names to their values
|
|
1419
|
+
* @returns A query string starting with "?" if parameters exist, empty string otherwise
|
|
1420
|
+
* @example
|
|
1421
|
+
* serialize(Map([["name", {...}], ["age", {...}]])) returns "?name=John&age=30"
|
|
1422
|
+
*/
|
|
1423
|
+
serialize(queryParams) {
|
|
1424
|
+
if (!queryParams || !queryParams.size) {
|
|
1425
|
+
return "";
|
|
1426
|
+
}
|
|
1427
|
+
const query = [];
|
|
1428
|
+
queryParams.forEach((param) => {
|
|
1429
|
+
if (param.value === void 0) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
return query.push(`${this.serializeValue(param)}`);
|
|
1433
|
+
});
|
|
1434
|
+
return query.length ? `?${query.join("&")}` : "";
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
// src/http/serialization/header-serializer.ts
|
|
1439
|
+
var HeaderSerializer = class extends Serializer {
|
|
1440
|
+
/**
|
|
1441
|
+
* Serializes header parameters into a headers object.
|
|
1442
|
+
* @param headerParams - Map of header names to their parameter values
|
|
1443
|
+
* @returns A HeadersInit object with serialized header values, or undefined if no headers
|
|
1444
|
+
*/
|
|
1445
|
+
serialize(headerParams) {
|
|
1446
|
+
if (!headerParams || !headerParams.size) {
|
|
1447
|
+
return void 0;
|
|
1448
|
+
}
|
|
1449
|
+
const headers = {};
|
|
1450
|
+
headerParams.forEach((param) => {
|
|
1451
|
+
if (!param.key) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
headers[param.key] = this.serializeValue(param);
|
|
1455
|
+
});
|
|
1456
|
+
return headers;
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
// src/http/serialization/cookie-serializer.ts
|
|
1461
|
+
var CookieSerializer = class {
|
|
1462
|
+
/**
|
|
1463
|
+
* Serializes cookie parameters into a cookie object.
|
|
1464
|
+
* @param cookieParams - Map of cookie names to their parameter values
|
|
1465
|
+
* @returns A record of cookie names to serialized values, or undefined if no cookies
|
|
1466
|
+
*/
|
|
1467
|
+
serialize(cookieParams) {
|
|
1468
|
+
if (!cookieParams || !cookieParams.size) {
|
|
1469
|
+
return void 0;
|
|
1470
|
+
}
|
|
1471
|
+
const cookies = {};
|
|
1472
|
+
cookieParams.forEach((param) => {
|
|
1473
|
+
if (!param.key || param.value === void 0) {
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
cookies[param.key] = this.serializeCookieValue(param);
|
|
1477
|
+
});
|
|
1478
|
+
return cookies;
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Serializes a single cookie value based on its type.
|
|
1482
|
+
* @param param - The cookie parameter to serialize
|
|
1483
|
+
* @returns The serialized cookie value string
|
|
1484
|
+
*/
|
|
1485
|
+
serializeCookieValue(param) {
|
|
1486
|
+
if (Array.isArray(param.value)) {
|
|
1487
|
+
return this.serializeArray(param.value, param);
|
|
1488
|
+
}
|
|
1489
|
+
if (this.isNonNullObject(param.value)) {
|
|
1490
|
+
return this.serializeObject(param.value, param);
|
|
1491
|
+
}
|
|
1492
|
+
return this.serializePrimitive(param.value);
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Serializes a primitive cookie value.
|
|
1496
|
+
* @param value - The primitive value to serialize
|
|
1497
|
+
* @returns The string representation of the value
|
|
1498
|
+
*/
|
|
1499
|
+
serializePrimitive(value) {
|
|
1500
|
+
return `${value}`;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Serializes an array cookie value.
|
|
1504
|
+
* @param value - The array to serialize
|
|
1505
|
+
* @param param - The cookie parameter configuration
|
|
1506
|
+
* @returns The serialized array string
|
|
1507
|
+
*/
|
|
1508
|
+
serializeArray(value, param) {
|
|
1509
|
+
if (param.explode) {
|
|
1510
|
+
if (value.length === 0)
|
|
1511
|
+
return "";
|
|
1512
|
+
const first = value[0];
|
|
1513
|
+
const rest = value.slice(1).map((v) => `${param.key}=${v}`).join("; ");
|
|
1514
|
+
return rest ? `${first}; ${rest}` : `${first}`;
|
|
1515
|
+
}
|
|
1516
|
+
return value.join(",");
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Serializes an object cookie value as JSON.
|
|
1520
|
+
* @param obj - The object to serialize
|
|
1521
|
+
* @param param - The cookie parameter configuration
|
|
1522
|
+
* @returns The JSON string representation of the object
|
|
1523
|
+
*/
|
|
1524
|
+
serializeObject(obj, param) {
|
|
1525
|
+
return JSON.stringify(obj);
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Type guard to check if a value is a non-null object.
|
|
1529
|
+
* @param value - The value to check
|
|
1530
|
+
* @returns True if the value is an object and not null
|
|
1531
|
+
*/
|
|
1532
|
+
isNonNullObject(value) {
|
|
1533
|
+
return typeof value === "object" && value !== null;
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
// src/http/transport/request.ts
|
|
1538
|
+
var Request = class {
|
|
1539
|
+
constructor(params) {
|
|
1540
|
+
this.baseUrl = "";
|
|
1541
|
+
this.headers = /* @__PURE__ */ new Map();
|
|
1542
|
+
this.queryParams = /* @__PURE__ */ new Map();
|
|
1543
|
+
this.pathParams = /* @__PURE__ */ new Map();
|
|
1544
|
+
this.cookies = /* @__PURE__ */ new Map();
|
|
1545
|
+
this.baseUrl = params.baseUrl;
|
|
1546
|
+
this.method = params.method;
|
|
1547
|
+
this.pathPattern = params.path;
|
|
1548
|
+
this.body = params.body;
|
|
1549
|
+
this.path = this.constructPath();
|
|
1550
|
+
this.config = params.config;
|
|
1551
|
+
this.pathParams = params.pathParams;
|
|
1552
|
+
this.headers = params.headers;
|
|
1553
|
+
this.queryParams = params.queryParams;
|
|
1554
|
+
this.cookies = params.cookies;
|
|
1555
|
+
this.responses = params.responses;
|
|
1556
|
+
this.errors = params.errors;
|
|
1557
|
+
this.requestSchema = params.requestSchema;
|
|
1558
|
+
this.requestContentType = params.requestContentType;
|
|
1559
|
+
this.pagination = params.pagination;
|
|
1560
|
+
this.filename = params.filename;
|
|
1561
|
+
this.filenames = params.filenames;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Adds a header parameter to the request with OpenAPI serialization rules.
|
|
1565
|
+
*
|
|
1566
|
+
* @param key - The header name
|
|
1567
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1568
|
+
*/
|
|
1569
|
+
addHeaderParam(key, param) {
|
|
1570
|
+
if (param.value === void 0) {
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
if (param.explode === void 0) {
|
|
1574
|
+
param.explode = false;
|
|
1575
|
+
}
|
|
1576
|
+
if (param.style === void 0) {
|
|
1577
|
+
param.style = "simple" /* SIMPLE */;
|
|
1578
|
+
}
|
|
1579
|
+
if (param.encode === void 0) {
|
|
1580
|
+
param.encode = false;
|
|
1581
|
+
}
|
|
1582
|
+
this.headers.set(key, param);
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* Adds a query parameter to the request with OpenAPI serialization rules.
|
|
1586
|
+
*
|
|
1587
|
+
* @param key - The query parameter name
|
|
1588
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1589
|
+
*/
|
|
1590
|
+
addQueryParam(key, param) {
|
|
1591
|
+
if (param.value === void 0) {
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
if (param.explode === void 0) {
|
|
1595
|
+
param.explode = true;
|
|
1596
|
+
}
|
|
1597
|
+
if (param.style === void 0) {
|
|
1598
|
+
param.style = "form" /* FORM */;
|
|
1599
|
+
}
|
|
1600
|
+
if (param.encode === void 0) {
|
|
1601
|
+
param.encode = true;
|
|
1602
|
+
}
|
|
1603
|
+
this.queryParams.set(key, param);
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Adds a path parameter to the request with OpenAPI serialization rules.
|
|
1607
|
+
*
|
|
1608
|
+
* @param key - The path parameter name (matches template variable in path pattern)
|
|
1609
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1610
|
+
*/
|
|
1611
|
+
addPathParam(key, param) {
|
|
1612
|
+
if (param.value === void 0) {
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
if (param.explode === void 0) {
|
|
1616
|
+
param.explode = false;
|
|
1617
|
+
}
|
|
1618
|
+
if (param.style === void 0) {
|
|
1619
|
+
param.style = "simple" /* SIMPLE */;
|
|
1620
|
+
}
|
|
1621
|
+
if (param.encode === void 0) {
|
|
1622
|
+
param.encode = true;
|
|
1623
|
+
}
|
|
1624
|
+
this.pathParams.set(key, param);
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Sets the request body if the value is defined.
|
|
1628
|
+
*
|
|
1629
|
+
* @param body - The request body to send
|
|
1630
|
+
*/
|
|
1631
|
+
addBody(body) {
|
|
1632
|
+
if (body === void 0) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
this.body = body;
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Updates this request from a modified hook request.
|
|
1639
|
+
* Used after hooks modify the request to sync changes back to the internal Request object.
|
|
1640
|
+
*
|
|
1641
|
+
* @param hookRequest - The modified request from hook processing
|
|
1642
|
+
*/
|
|
1643
|
+
updateFromHookRequest(hookRequest) {
|
|
1644
|
+
this.baseUrl = hookRequest.baseUrl;
|
|
1645
|
+
this.method = hookRequest.method;
|
|
1646
|
+
this.path = hookRequest.path;
|
|
1647
|
+
this.body = hookRequest.body;
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Constructs the complete URL by combining base URL, path with substituted parameters,
|
|
1651
|
+
* and serialized query string.
|
|
1652
|
+
*
|
|
1653
|
+
* @returns The fully constructed URL ready for HTTP execution
|
|
1654
|
+
*/
|
|
1655
|
+
constructFullUrl() {
|
|
1656
|
+
const queryString = new QuerySerializer().serialize(this.queryParams);
|
|
1657
|
+
const path = this.constructPath();
|
|
1658
|
+
let baseUrl = this.baseUrl;
|
|
1659
|
+
return `${baseUrl}${path}${queryString}`;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Creates a copy of this request with optional parameter overrides.
|
|
1663
|
+
* Useful for pagination where you need to modify parameters while keeping the rest intact.
|
|
1664
|
+
*
|
|
1665
|
+
* @param overrides - Optional parameters to override in the copied request
|
|
1666
|
+
* @returns A new Request instance with the specified overrides
|
|
1667
|
+
*/
|
|
1668
|
+
copy(overrides) {
|
|
1669
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1670
|
+
const createRequestParams = {
|
|
1671
|
+
baseUrl: (_a = overrides == null ? void 0 : overrides.baseUrl) != null ? _a : this.baseUrl,
|
|
1672
|
+
errors: (_b = overrides == null ? void 0 : overrides.errors) != null ? _b : this.errors,
|
|
1673
|
+
method: (_c = overrides == null ? void 0 : overrides.method) != null ? _c : this.method,
|
|
1674
|
+
path: (_d = overrides == null ? void 0 : overrides.path) != null ? _d : this.path,
|
|
1675
|
+
body: (_e = overrides == null ? void 0 : overrides.body) != null ? _e : this.body,
|
|
1676
|
+
config: (_f = overrides == null ? void 0 : overrides.config) != null ? _f : this.config,
|
|
1677
|
+
pathParams: (_g = overrides == null ? void 0 : overrides.pathParams) != null ? _g : this.pathParams,
|
|
1678
|
+
queryParams: (_h = overrides == null ? void 0 : overrides.queryParams) != null ? _h : this.queryParams,
|
|
1679
|
+
headers: (_i = overrides == null ? void 0 : overrides.headers) != null ? _i : this.headers,
|
|
1680
|
+
cookies: (_j = overrides == null ? void 0 : overrides.cookies) != null ? _j : this.cookies,
|
|
1681
|
+
responses: (_k = overrides == null ? void 0 : overrides.responses) != null ? _k : this.responses,
|
|
1682
|
+
requestSchema: (_l = overrides == null ? void 0 : overrides.requestSchema) != null ? _l : this.requestSchema,
|
|
1683
|
+
requestContentType: (_m = overrides == null ? void 0 : overrides.requestContentType) != null ? _m : this.requestContentType,
|
|
1684
|
+
filename: (_n = overrides == null ? void 0 : overrides.filename) != null ? _n : this.filename,
|
|
1685
|
+
filenames: (_o = overrides == null ? void 0 : overrides.filenames) != null ? _o : this.filenames
|
|
1686
|
+
};
|
|
1687
|
+
return new Request({
|
|
1688
|
+
...createRequestParams,
|
|
1689
|
+
...overrides
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Serializes headers to a format suitable for HTTP execution.
|
|
1694
|
+
*
|
|
1695
|
+
* @returns Serialized headers as HeadersInit, or undefined if no headers
|
|
1696
|
+
*/
|
|
1697
|
+
getHeaders() {
|
|
1698
|
+
if (!this.headers || !this.headers.size) {
|
|
1699
|
+
return void 0;
|
|
1700
|
+
}
|
|
1701
|
+
return new HeaderSerializer().serialize(this.headers);
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Serializes cookies to a format suitable for HTTP execution.
|
|
1705
|
+
*
|
|
1706
|
+
* @returns Serialized cookies as a record, or undefined if no cookies
|
|
1707
|
+
*/
|
|
1708
|
+
getCookies() {
|
|
1709
|
+
if (!this.cookies || !this.cookies.size) {
|
|
1710
|
+
return void 0;
|
|
1711
|
+
}
|
|
1712
|
+
return new CookieSerializer().serialize(this.cookies);
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Advances pagination parameters to fetch the next page.
|
|
1716
|
+
* Handles both cursor-based and limit-offset pagination strategies.
|
|
1717
|
+
*
|
|
1718
|
+
* @param cursor - The cursor value for cursor-based pagination (optional for limit-offset)
|
|
1719
|
+
*/
|
|
1720
|
+
nextPage(cursor) {
|
|
1721
|
+
if (!this.pagination) {
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
if (isRequestCursorPagination(this.pagination)) {
|
|
1725
|
+
const cursorParam = this.getCursorParam();
|
|
1726
|
+
if (cursorParam && cursor !== void 0) {
|
|
1727
|
+
cursorParam.value = cursor;
|
|
1728
|
+
}
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
const offsetParam = this.getOffsetParam();
|
|
1732
|
+
if (offsetParam) {
|
|
1733
|
+
if (this.pagination.pageSize === void 0) {
|
|
1734
|
+
throw new Error("pageSize is required for limit-offset pagination");
|
|
1735
|
+
}
|
|
1736
|
+
offsetParam.value = Number(offsetParam.value) + this.pagination.pageSize;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
constructPath() {
|
|
1740
|
+
return new PathSerializer().serialize(this.pathPattern, this.pathParams);
|
|
1741
|
+
}
|
|
1742
|
+
getOffsetParam() {
|
|
1743
|
+
const offsetParam = this.getAllParams().find((param) => param.isOffset);
|
|
1744
|
+
return offsetParam;
|
|
1745
|
+
}
|
|
1746
|
+
getCursorParam() {
|
|
1747
|
+
const cursorParam = this.getAllParams().find((param) => param.isCursor);
|
|
1748
|
+
return cursorParam;
|
|
1749
|
+
}
|
|
1750
|
+
getAllParams() {
|
|
1751
|
+
const allParams = [];
|
|
1752
|
+
this.headers.forEach((val, _) => {
|
|
1753
|
+
allParams.push(val);
|
|
1754
|
+
});
|
|
1755
|
+
this.queryParams.forEach((val, _) => {
|
|
1756
|
+
allParams.push(val);
|
|
1757
|
+
});
|
|
1758
|
+
this.pathParams.forEach((val, _) => {
|
|
1759
|
+
allParams.push(val);
|
|
1760
|
+
});
|
|
1761
|
+
this.cookies.forEach((val, _) => {
|
|
1762
|
+
allParams.push(val);
|
|
1763
|
+
});
|
|
1764
|
+
return allParams;
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1768
|
+
// src/http/environment.ts
|
|
1769
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
1770
|
+
Environment2["DEFAULT"] = "https://{{apiLinxcommerce}}";
|
|
1771
|
+
Environment2["APILINXCOMMERCE"] = "https://{{apiLinxcommerce}}";
|
|
1772
|
+
Environment2["STOREURL"] = "https://{{storeUrl}}";
|
|
1773
|
+
Environment2["URLSTORE"] = "https://{{urlStore}}";
|
|
1774
|
+
Environment2["URLSTORESHOPPING"] = "https://{{urlStore}}Shopping";
|
|
1775
|
+
Environment2["URLLINX"] = "https://{{urlLinx}}";
|
|
1776
|
+
Environment2["VIACEP"] = "https://viacep.com.br";
|
|
1777
|
+
return Environment2;
|
|
1778
|
+
})(Environment || {});
|
|
1779
|
+
|
|
1780
|
+
// src/http/transport/request-builder.ts
|
|
1781
|
+
var RequestBuilder = class {
|
|
1782
|
+
/**
|
|
1783
|
+
* Creates a new request builder with default configuration.
|
|
1784
|
+
* Initializes retry settings, validation options, and empty parameter collections.
|
|
1785
|
+
*/
|
|
1786
|
+
constructor() {
|
|
1787
|
+
this.params = {
|
|
1788
|
+
baseUrl: "https://{{apiLinxcommerce}}" /* DEFAULT */,
|
|
1789
|
+
method: "GET",
|
|
1790
|
+
path: "",
|
|
1791
|
+
config: {
|
|
1792
|
+
retry: {
|
|
1793
|
+
attempts: 3,
|
|
1794
|
+
delayMs: 150,
|
|
1795
|
+
maxDelayMs: 5e3,
|
|
1796
|
+
backoffFactor: 2,
|
|
1797
|
+
jitterMs: 50,
|
|
1798
|
+
httpMethodsToRetry: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]
|
|
1799
|
+
},
|
|
1800
|
+
validation: { responseValidation: true }
|
|
1801
|
+
},
|
|
1802
|
+
responses: [],
|
|
1803
|
+
errors: [],
|
|
1804
|
+
requestSchema: import_zod3.default.any(),
|
|
1805
|
+
requestContentType: "json" /* Json */,
|
|
1806
|
+
pathParams: /* @__PURE__ */ new Map(),
|
|
1807
|
+
queryParams: /* @__PURE__ */ new Map(),
|
|
1808
|
+
headers: /* @__PURE__ */ new Map(),
|
|
1809
|
+
cookies: /* @__PURE__ */ new Map()
|
|
1810
|
+
};
|
|
1811
|
+
this.addHeaderParam({
|
|
1812
|
+
key: "User-Agent",
|
|
1813
|
+
value: "postman-codegen/2.25.51 linxcommerce-webapi-sdk/1.0.0 (typescript)"
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
setConfig(config) {
|
|
1817
|
+
var _a, _b;
|
|
1818
|
+
let mergedRetry = (_a = config.retry) != null ? _a : this.params.config.retry;
|
|
1819
|
+
if (config.retry !== void 0 && this.params.config.retry !== void 0) {
|
|
1820
|
+
mergedRetry = { ...this.params.config.retry, ...config.retry };
|
|
1821
|
+
}
|
|
1822
|
+
let mergedValidation = (_b = config.validation) != null ? _b : this.params.config.validation;
|
|
1823
|
+
if (config.validation !== void 0 && this.params.config.validation !== void 0) {
|
|
1824
|
+
mergedValidation = { ...this.params.config.validation, ...config.validation };
|
|
1825
|
+
}
|
|
1826
|
+
this.params.config = {
|
|
1827
|
+
...this.params.config,
|
|
1828
|
+
...config,
|
|
1829
|
+
...mergedRetry !== void 0 && { retry: mergedRetry },
|
|
1830
|
+
...mergedValidation !== void 0 && { validation: mergedValidation }
|
|
1831
|
+
};
|
|
1832
|
+
return this;
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Sets the base URL for the request using hierarchical configuration resolution.
|
|
1836
|
+
*
|
|
1837
|
+
* Resolution logic:
|
|
1838
|
+
* 1. First tries to resolve 'baseUrl' (string) from the resolved config
|
|
1839
|
+
* 2. If no 'baseUrl' found, falls back to 'environment' (enum) from the resolved config
|
|
1840
|
+
* 3. 'baseUrl' always takes precedence over 'environment'
|
|
1841
|
+
*
|
|
1842
|
+
* @param config - Resolved configuration from all hierarchy levels
|
|
1843
|
+
* @returns This builder instance for method chaining
|
|
1844
|
+
*/
|
|
1845
|
+
setBaseUrl(config) {
|
|
1846
|
+
if (!config) {
|
|
1847
|
+
return this;
|
|
1848
|
+
}
|
|
1849
|
+
if ("baseUrl" in config && typeof config.baseUrl === "string" && config.baseUrl) {
|
|
1850
|
+
this.params.baseUrl = config.baseUrl;
|
|
1851
|
+
return this;
|
|
1852
|
+
}
|
|
1853
|
+
if ("environment" in config && config.environment) {
|
|
1854
|
+
this.params.baseUrl = config.environment;
|
|
1855
|
+
}
|
|
1856
|
+
return this;
|
|
1857
|
+
}
|
|
1858
|
+
setMethod(method) {
|
|
1859
|
+
this.params.method = method;
|
|
1860
|
+
return this;
|
|
1861
|
+
}
|
|
1862
|
+
setPath(path) {
|
|
1863
|
+
this.params.path = path;
|
|
1864
|
+
return this;
|
|
1865
|
+
}
|
|
1866
|
+
setRequestContentType(contentType) {
|
|
1867
|
+
this.params.requestContentType = contentType;
|
|
1868
|
+
return this;
|
|
1869
|
+
}
|
|
1870
|
+
setRequestSchema(requestSchema) {
|
|
1871
|
+
this.params.requestSchema = requestSchema;
|
|
1872
|
+
return this;
|
|
1873
|
+
}
|
|
1874
|
+
setFilename(filename) {
|
|
1875
|
+
if (filename !== void 0) {
|
|
1876
|
+
this.params.filename = filename;
|
|
1877
|
+
}
|
|
1878
|
+
return this;
|
|
1879
|
+
}
|
|
1880
|
+
setFilenames(filenames) {
|
|
1881
|
+
if (filenames !== void 0) {
|
|
1882
|
+
this.params.filenames = filenames;
|
|
1883
|
+
}
|
|
1884
|
+
return this;
|
|
1885
|
+
}
|
|
1886
|
+
setPagination(pagination) {
|
|
1887
|
+
this.params.pagination = pagination;
|
|
1888
|
+
return this;
|
|
1889
|
+
}
|
|
1890
|
+
setCursorPagination(pagination) {
|
|
1891
|
+
this.params.pagination = pagination;
|
|
1892
|
+
return this;
|
|
1893
|
+
}
|
|
1894
|
+
addAccessTokenAuth(accessToken, prefix) {
|
|
1895
|
+
if (accessToken === void 0) {
|
|
1896
|
+
return this;
|
|
1897
|
+
}
|
|
1898
|
+
this.params.headers.set("Authorization", {
|
|
1899
|
+
key: "Authorization",
|
|
1900
|
+
value: `${prefix != null ? prefix : "BEARER"} ${accessToken}`,
|
|
1901
|
+
explode: false,
|
|
1902
|
+
style: "simple" /* SIMPLE */,
|
|
1903
|
+
encode: true,
|
|
1904
|
+
isLimit: false,
|
|
1905
|
+
isOffset: false,
|
|
1906
|
+
isCursor: false
|
|
1907
|
+
});
|
|
1908
|
+
return this;
|
|
1909
|
+
}
|
|
1910
|
+
addBasicAuth(username, password) {
|
|
1911
|
+
if (username === void 0 || password === void 0) {
|
|
1912
|
+
return this;
|
|
1913
|
+
}
|
|
1914
|
+
this.params.headers.set("Authorization", {
|
|
1915
|
+
key: "Authorization",
|
|
1916
|
+
value: `Basic ${this.toBase64(`${username}:${password}`)}`,
|
|
1917
|
+
explode: false,
|
|
1918
|
+
style: "simple" /* SIMPLE */,
|
|
1919
|
+
encode: true,
|
|
1920
|
+
isLimit: false,
|
|
1921
|
+
isOffset: false,
|
|
1922
|
+
isCursor: false
|
|
1923
|
+
});
|
|
1924
|
+
return this;
|
|
1925
|
+
}
|
|
1926
|
+
addApiKeyAuth(apiKey, keyName) {
|
|
1927
|
+
if (apiKey === void 0) {
|
|
1928
|
+
return this;
|
|
1929
|
+
}
|
|
1930
|
+
this.params.headers.set(keyName != null ? keyName : "X-API-KEY", {
|
|
1931
|
+
key: keyName != null ? keyName : "X-API-KEY",
|
|
1932
|
+
value: apiKey,
|
|
1933
|
+
explode: false,
|
|
1934
|
+
style: "simple" /* SIMPLE */,
|
|
1935
|
+
encode: true,
|
|
1936
|
+
isLimit: false,
|
|
1937
|
+
isOffset: false,
|
|
1938
|
+
isCursor: false
|
|
1939
|
+
});
|
|
1940
|
+
return this;
|
|
1941
|
+
}
|
|
1942
|
+
addResponse(response) {
|
|
1943
|
+
this.params.responses.push(response);
|
|
1944
|
+
return this;
|
|
1945
|
+
}
|
|
1946
|
+
addError(error) {
|
|
1947
|
+
this.params.errors.push(error);
|
|
1948
|
+
return this;
|
|
1949
|
+
}
|
|
1950
|
+
addBody(body) {
|
|
1951
|
+
if (body !== void 0) {
|
|
1952
|
+
this.params.body = body;
|
|
1953
|
+
}
|
|
1954
|
+
return this;
|
|
1955
|
+
}
|
|
1956
|
+
addPathParam(param) {
|
|
1957
|
+
var _a, _b, _c;
|
|
1958
|
+
if (param.value === void 0 || param.key === void 0) {
|
|
1959
|
+
return this;
|
|
1960
|
+
}
|
|
1961
|
+
this.params.pathParams.set(param.key, {
|
|
1962
|
+
key: param.key,
|
|
1963
|
+
value: param.value,
|
|
1964
|
+
explode: (_a = param.explode) != null ? _a : true,
|
|
1965
|
+
style: (_b = param.style) != null ? _b : "simple" /* SIMPLE */,
|
|
1966
|
+
encode: (_c = param.encode) != null ? _c : true,
|
|
1967
|
+
isLimit: !!param.isLimit,
|
|
1968
|
+
isOffset: !!param.isOffset,
|
|
1969
|
+
isCursor: !!param.isCursor
|
|
1970
|
+
});
|
|
1971
|
+
return this;
|
|
1972
|
+
}
|
|
1973
|
+
addQueryParam(param) {
|
|
1974
|
+
var _a, _b, _c;
|
|
1975
|
+
if (param.key === void 0) {
|
|
1976
|
+
return this;
|
|
1977
|
+
}
|
|
1978
|
+
this.params.queryParams.set(param.key, {
|
|
1979
|
+
key: param.key,
|
|
1980
|
+
value: param.value,
|
|
1981
|
+
explode: (_a = param.explode) != null ? _a : true,
|
|
1982
|
+
style: (_b = param.style) != null ? _b : "form" /* FORM */,
|
|
1983
|
+
encode: (_c = param.encode) != null ? _c : true,
|
|
1984
|
+
isLimit: !!param.isLimit,
|
|
1985
|
+
isOffset: !!param.isOffset,
|
|
1986
|
+
isCursor: !!param.isCursor
|
|
1987
|
+
});
|
|
1988
|
+
return this;
|
|
1989
|
+
}
|
|
1990
|
+
addHeaderParam(param) {
|
|
1991
|
+
var _a, _b, _c;
|
|
1992
|
+
if (param.value === void 0 || param.key === void 0) {
|
|
1993
|
+
return this;
|
|
1994
|
+
}
|
|
1995
|
+
this.params.headers.set(param.key, {
|
|
1996
|
+
key: param.key,
|
|
1997
|
+
value: param.value,
|
|
1998
|
+
explode: (_a = param.explode) != null ? _a : true,
|
|
1999
|
+
style: (_b = param.style) != null ? _b : "simple" /* SIMPLE */,
|
|
2000
|
+
encode: (_c = param.encode) != null ? _c : false,
|
|
2001
|
+
isLimit: !!param.isLimit,
|
|
2002
|
+
isOffset: !!param.isOffset,
|
|
2003
|
+
isCursor: !!param.isCursor
|
|
2004
|
+
});
|
|
2005
|
+
return this;
|
|
2006
|
+
}
|
|
2007
|
+
addCookieParam(param) {
|
|
2008
|
+
var _a, _b, _c;
|
|
2009
|
+
if (param.value === void 0 || param.key === void 0) {
|
|
2010
|
+
return this;
|
|
2011
|
+
}
|
|
2012
|
+
this.params.cookies.set(param.key, {
|
|
2013
|
+
key: param.key,
|
|
2014
|
+
value: param.value,
|
|
2015
|
+
explode: (_a = param.explode) != null ? _a : true,
|
|
2016
|
+
style: (_b = param.style) != null ? _b : "form" /* FORM */,
|
|
2017
|
+
encode: (_c = param.encode) != null ? _c : false,
|
|
2018
|
+
isLimit: !!param.isLimit,
|
|
2019
|
+
isOffset: !!param.isOffset,
|
|
2020
|
+
isCursor: !!param.isCursor
|
|
2021
|
+
});
|
|
2022
|
+
return this;
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Builds and returns the configured Request object.
|
|
2026
|
+
* Call this method after configuring all request parameters.
|
|
2027
|
+
* @returns A new Request instance with all configured parameters
|
|
2028
|
+
*/
|
|
2029
|
+
build() {
|
|
2030
|
+
return new Request(this.params);
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Converts a string to Base64 encoding.
|
|
2034
|
+
* Works in both Node.js and browser environments.
|
|
2035
|
+
* @param str - The string to encode
|
|
2036
|
+
* @returns The Base64-encoded string
|
|
2037
|
+
*/
|
|
2038
|
+
toBase64(str) {
|
|
2039
|
+
if (typeof window === "undefined") {
|
|
2040
|
+
return Buffer.from(str, "utf-8").toString("base64");
|
|
2041
|
+
} else {
|
|
2042
|
+
return btoa(unescape(encodeURIComponent(str)));
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
|
|
2047
|
+
// src/services/customers/models/create-consumer-request.ts
|
|
2048
|
+
var import_zod6 = require("zod");
|
|
2049
|
+
|
|
2050
|
+
// src/services/customers/models/create-consumer-request-customer.ts
|
|
2051
|
+
var import_zod5 = require("zod");
|
|
2052
|
+
|
|
2053
|
+
// src/services/customers/models/customer-contact-1.ts
|
|
2054
|
+
var import_zod4 = require("zod");
|
|
2055
|
+
var customerContact1 = import_zod4.z.lazy(() => {
|
|
2056
|
+
return import_zod4.z.object({
|
|
2057
|
+
phone: import_zod4.z.string().optional().nullable(),
|
|
2058
|
+
cellPhone: import_zod4.z.string().optional().nullable()
|
|
2059
|
+
});
|
|
2060
|
+
});
|
|
2061
|
+
var customerContact1Response = import_zod4.z.lazy(() => {
|
|
2062
|
+
return import_zod4.z.object({
|
|
2063
|
+
Phone: import_zod4.z.string().optional().nullable(),
|
|
2064
|
+
CellPhone: import_zod4.z.string().optional().nullable()
|
|
2065
|
+
}).transform((data) => ({
|
|
2066
|
+
phone: data["Phone"],
|
|
2067
|
+
cellPhone: data["CellPhone"]
|
|
2068
|
+
}));
|
|
2069
|
+
});
|
|
2070
|
+
var customerContact1Request = import_zod4.z.lazy(() => {
|
|
2071
|
+
return import_zod4.z.object({
|
|
2072
|
+
phone: import_zod4.z.string().optional().nullable(),
|
|
2073
|
+
cellPhone: import_zod4.z.string().optional().nullable()
|
|
2074
|
+
}).transform((data) => ({
|
|
2075
|
+
Phone: data["phone"],
|
|
2076
|
+
CellPhone: data["cellPhone"]
|
|
2077
|
+
}));
|
|
2078
|
+
});
|
|
2079
|
+
|
|
2080
|
+
// src/services/customers/models/create-consumer-request-customer.ts
|
|
2081
|
+
var createConsumerRequestCustomer = import_zod5.z.lazy(() => {
|
|
2082
|
+
return import_zod5.z.object({
|
|
2083
|
+
customerType: import_zod5.z.string().optional().nullable(),
|
|
2084
|
+
email: import_zod5.z.string().optional().nullable(),
|
|
2085
|
+
password: import_zod5.z.string().optional().nullable(),
|
|
2086
|
+
passwordCheck: import_zod5.z.string().optional().nullable(),
|
|
2087
|
+
name: import_zod5.z.string().optional().nullable(),
|
|
2088
|
+
surname: import_zod5.z.string().optional().nullable(),
|
|
2089
|
+
birthDate: import_zod5.z.string().optional().nullable(),
|
|
2090
|
+
gender: import_zod5.z.string().optional().nullable(),
|
|
2091
|
+
cpf: import_zod5.z.string().optional().nullable(),
|
|
2092
|
+
contact: customerContact1.optional().nullable()
|
|
2093
|
+
});
|
|
2094
|
+
});
|
|
2095
|
+
var createConsumerRequestCustomerResponse = import_zod5.z.lazy(() => {
|
|
2096
|
+
return import_zod5.z.object({
|
|
2097
|
+
CustomerType: import_zod5.z.string().optional().nullable(),
|
|
2098
|
+
Email: import_zod5.z.string().optional().nullable(),
|
|
2099
|
+
Password: import_zod5.z.string().optional().nullable(),
|
|
2100
|
+
Password_Check: import_zod5.z.string().optional().nullable(),
|
|
2101
|
+
Name: import_zod5.z.string().optional().nullable(),
|
|
2102
|
+
Surname: import_zod5.z.string().optional().nullable(),
|
|
2103
|
+
BirthDate: import_zod5.z.string().optional().nullable(),
|
|
2104
|
+
Gender: import_zod5.z.string().optional().nullable(),
|
|
2105
|
+
Cpf: import_zod5.z.string().optional().nullable(),
|
|
2106
|
+
Contact: customerContact1Response.optional().nullable()
|
|
2107
|
+
}).transform((data) => ({
|
|
2108
|
+
customerType: data["CustomerType"],
|
|
2109
|
+
email: data["Email"],
|
|
2110
|
+
password: data["Password"],
|
|
2111
|
+
passwordCheck: data["Password_Check"],
|
|
2112
|
+
name: data["Name"],
|
|
2113
|
+
surname: data["Surname"],
|
|
2114
|
+
birthDate: data["BirthDate"],
|
|
2115
|
+
gender: data["Gender"],
|
|
2116
|
+
cpf: data["Cpf"],
|
|
2117
|
+
contact: data["Contact"]
|
|
2118
|
+
}));
|
|
2119
|
+
});
|
|
2120
|
+
var createConsumerRequestCustomerRequest = import_zod5.z.lazy(() => {
|
|
2121
|
+
return import_zod5.z.object({
|
|
2122
|
+
customerType: import_zod5.z.string().optional().nullable(),
|
|
2123
|
+
email: import_zod5.z.string().optional().nullable(),
|
|
2124
|
+
password: import_zod5.z.string().optional().nullable(),
|
|
2125
|
+
passwordCheck: import_zod5.z.string().optional().nullable(),
|
|
2126
|
+
name: import_zod5.z.string().optional().nullable(),
|
|
2127
|
+
surname: import_zod5.z.string().optional().nullable(),
|
|
2128
|
+
birthDate: import_zod5.z.string().optional().nullable(),
|
|
2129
|
+
gender: import_zod5.z.string().optional().nullable(),
|
|
2130
|
+
cpf: import_zod5.z.string().optional().nullable(),
|
|
2131
|
+
contact: customerContact1Request.optional().nullable()
|
|
2132
|
+
}).transform((data) => ({
|
|
2133
|
+
CustomerType: data["customerType"],
|
|
2134
|
+
Email: data["email"],
|
|
2135
|
+
Password: data["password"],
|
|
2136
|
+
Password_Check: data["passwordCheck"],
|
|
2137
|
+
Name: data["name"],
|
|
2138
|
+
Surname: data["surname"],
|
|
2139
|
+
BirthDate: data["birthDate"],
|
|
2140
|
+
Gender: data["gender"],
|
|
2141
|
+
Cpf: data["cpf"],
|
|
2142
|
+
Contact: data["contact"]
|
|
2143
|
+
}));
|
|
2144
|
+
});
|
|
2145
|
+
|
|
2146
|
+
// src/services/customers/models/create-consumer-request.ts
|
|
2147
|
+
var createConsumerRequest = import_zod6.z.lazy(() => {
|
|
2148
|
+
return import_zod6.z.object({
|
|
2149
|
+
customer: createConsumerRequestCustomer.optional().nullable(),
|
|
2150
|
+
basketId: import_zod6.z.number().optional().nullable()
|
|
2151
|
+
});
|
|
2152
|
+
});
|
|
2153
|
+
var createConsumerRequestResponse = import_zod6.z.lazy(() => {
|
|
2154
|
+
return import_zod6.z.object({
|
|
2155
|
+
Customer: createConsumerRequestCustomerResponse.optional().nullable(),
|
|
2156
|
+
BasketID: import_zod6.z.number().optional().nullable()
|
|
2157
|
+
}).transform((data) => ({
|
|
2158
|
+
customer: data["Customer"],
|
|
2159
|
+
basketId: data["BasketID"]
|
|
2160
|
+
}));
|
|
2161
|
+
});
|
|
2162
|
+
var createConsumerRequestRequest = import_zod6.z.lazy(() => {
|
|
2163
|
+
return import_zod6.z.object({
|
|
2164
|
+
customer: createConsumerRequestCustomerRequest.optional().nullable(),
|
|
2165
|
+
basketId: import_zod6.z.number().optional().nullable()
|
|
2166
|
+
}).transform((data) => ({
|
|
2167
|
+
Customer: data["customer"],
|
|
2168
|
+
BasketID: data["basketId"]
|
|
2169
|
+
}));
|
|
2170
|
+
});
|
|
2171
|
+
|
|
2172
|
+
// src/services/customers/models/create-business-account-request.ts
|
|
2173
|
+
var import_zod12 = require("zod");
|
|
2174
|
+
|
|
2175
|
+
// src/services/customers/models/create-business-account-request-customer.ts
|
|
2176
|
+
var import_zod8 = require("zod");
|
|
2177
|
+
|
|
2178
|
+
// src/services/customers/models/customer-contact-2.ts
|
|
2179
|
+
var import_zod7 = require("zod");
|
|
2180
|
+
var customerContact2 = import_zod7.z.lazy(() => {
|
|
2181
|
+
return import_zod7.z.object({
|
|
2182
|
+
phone: import_zod7.z.string().optional().nullable(),
|
|
2183
|
+
phone2: import_zod7.z.string().optional().nullable(),
|
|
2184
|
+
cellPhone: import_zod7.z.string().optional().nullable(),
|
|
2185
|
+
fax: import_zod7.z.string().optional().nullable()
|
|
2186
|
+
});
|
|
2187
|
+
});
|
|
2188
|
+
var customerContact2Response = import_zod7.z.lazy(() => {
|
|
2189
|
+
return import_zod7.z.object({
|
|
2190
|
+
Phone: import_zod7.z.string().optional().nullable(),
|
|
2191
|
+
Phone2: import_zod7.z.string().optional().nullable(),
|
|
2192
|
+
CellPhone: import_zod7.z.string().optional().nullable(),
|
|
2193
|
+
Fax: import_zod7.z.string().optional().nullable()
|
|
2194
|
+
}).transform((data) => ({
|
|
2195
|
+
phone: data["Phone"],
|
|
2196
|
+
phone2: data["Phone2"],
|
|
2197
|
+
cellPhone: data["CellPhone"],
|
|
2198
|
+
fax: data["Fax"]
|
|
2199
|
+
}));
|
|
2200
|
+
});
|
|
2201
|
+
var customerContact2Request = import_zod7.z.lazy(() => {
|
|
2202
|
+
return import_zod7.z.object({
|
|
2203
|
+
phone: import_zod7.z.string().optional().nullable(),
|
|
2204
|
+
phone2: import_zod7.z.string().optional().nullable(),
|
|
2205
|
+
cellPhone: import_zod7.z.string().optional().nullable(),
|
|
2206
|
+
fax: import_zod7.z.string().optional().nullable()
|
|
2207
|
+
}).transform((data) => ({
|
|
2208
|
+
Phone: data["phone"],
|
|
2209
|
+
Phone2: data["phone2"],
|
|
2210
|
+
CellPhone: data["cellPhone"],
|
|
2211
|
+
Fax: data["fax"]
|
|
2212
|
+
}));
|
|
2213
|
+
});
|
|
2214
|
+
|
|
2215
|
+
// src/services/customers/models/create-business-account-request-customer.ts
|
|
2216
|
+
var createBusinessAccountRequestCustomer = import_zod8.z.lazy(() => {
|
|
2217
|
+
return import_zod8.z.object({
|
|
2218
|
+
customerType: import_zod8.z.string().optional().nullable(),
|
|
2219
|
+
sourceEnvironment: import_zod8.z.string().optional().nullable(),
|
|
2220
|
+
email: import_zod8.z.string().optional().nullable(),
|
|
2221
|
+
password: import_zod8.z.string().optional().nullable(),
|
|
2222
|
+
passwordCheck: import_zod8.z.string().optional().nullable(),
|
|
2223
|
+
passwordCurrent: import_zod8.z.string().optional().nullable(),
|
|
2224
|
+
currentPassword: import_zod8.z.string().optional().nullable(),
|
|
2225
|
+
generatePassword: import_zod8.z.boolean().optional().nullable(),
|
|
2226
|
+
generateAndDefinePassword: import_zod8.z.boolean().optional().nullable(),
|
|
2227
|
+
recoveryPasswordActionUrl: import_zod8.z.string().optional().nullable(),
|
|
2228
|
+
name: import_zod8.z.string().optional().nullable(),
|
|
2229
|
+
surname: import_zod8.z.string().optional().nullable(),
|
|
2230
|
+
birthDate: import_zod8.z.string().optional().nullable(),
|
|
2231
|
+
gender: import_zod8.z.string().optional().nullable(),
|
|
2232
|
+
cpf: import_zod8.z.string().optional().nullable(),
|
|
2233
|
+
rg: import_zod8.z.string().optional().nullable(),
|
|
2234
|
+
tradingName: import_zod8.z.string().optional().nullable(),
|
|
2235
|
+
cnpj: import_zod8.z.string().optional().nullable(),
|
|
2236
|
+
contact: customerContact2.optional().nullable(),
|
|
2237
|
+
extendedProperties: import_zod8.z.array(import_zod8.z.string()).optional().nullable(),
|
|
2238
|
+
currentUserIPs: import_zod8.z.string().optional().nullable(),
|
|
2239
|
+
provider: import_zod8.z.string().optional().nullable(),
|
|
2240
|
+
isCustomerRelation: import_zod8.z.boolean().optional().nullable(),
|
|
2241
|
+
reCaptchaToken: import_zod8.z.string().optional().nullable(),
|
|
2242
|
+
isFromGuestSession: import_zod8.z.boolean().optional().nullable(),
|
|
2243
|
+
prefixFormat: import_zod8.z.string().optional().nullable()
|
|
2244
|
+
});
|
|
2245
|
+
});
|
|
2246
|
+
var createBusinessAccountRequestCustomerResponse = import_zod8.z.lazy(() => {
|
|
2247
|
+
return import_zod8.z.object({
|
|
2248
|
+
CustomerType: import_zod8.z.string().optional().nullable(),
|
|
2249
|
+
SourceEnvironment: import_zod8.z.string().optional().nullable(),
|
|
2250
|
+
Email: import_zod8.z.string().optional().nullable(),
|
|
2251
|
+
Password: import_zod8.z.string().optional().nullable(),
|
|
2252
|
+
Password_Check: import_zod8.z.string().optional().nullable(),
|
|
2253
|
+
Password_Current: import_zod8.z.string().optional().nullable(),
|
|
2254
|
+
CurrentPassword: import_zod8.z.string().optional().nullable(),
|
|
2255
|
+
GeneratePassword: import_zod8.z.boolean().optional().nullable(),
|
|
2256
|
+
GenerateAndDefinePassword: import_zod8.z.boolean().optional().nullable(),
|
|
2257
|
+
RecoveryPasswordActionUrl: import_zod8.z.string().optional().nullable(),
|
|
2258
|
+
Name: import_zod8.z.string().optional().nullable(),
|
|
2259
|
+
Surname: import_zod8.z.string().optional().nullable(),
|
|
2260
|
+
BirthDate: import_zod8.z.string().optional().nullable(),
|
|
2261
|
+
Gender: import_zod8.z.string().optional().nullable(),
|
|
2262
|
+
Cpf: import_zod8.z.string().optional().nullable(),
|
|
2263
|
+
RG: import_zod8.z.string().optional().nullable(),
|
|
2264
|
+
TradingName: import_zod8.z.string().optional().nullable(),
|
|
2265
|
+
Cnpj: import_zod8.z.string().optional().nullable(),
|
|
2266
|
+
Contact: customerContact2Response.optional().nullable(),
|
|
2267
|
+
ExtendedProperties: import_zod8.z.array(import_zod8.z.string()).optional().nullable(),
|
|
2268
|
+
CurrentUserIPs: import_zod8.z.string().optional().nullable(),
|
|
2269
|
+
Provider: import_zod8.z.string().optional().nullable(),
|
|
2270
|
+
IsCustomerRelation: import_zod8.z.boolean().optional().nullable(),
|
|
2271
|
+
ReCaptchaToken: import_zod8.z.string().optional().nullable(),
|
|
2272
|
+
IsFromGuestSession: import_zod8.z.boolean().optional().nullable(),
|
|
2273
|
+
PrefixFormat: import_zod8.z.string().optional().nullable()
|
|
2274
|
+
}).transform((data) => ({
|
|
2275
|
+
customerType: data["CustomerType"],
|
|
2276
|
+
sourceEnvironment: data["SourceEnvironment"],
|
|
2277
|
+
email: data["Email"],
|
|
2278
|
+
password: data["Password"],
|
|
2279
|
+
passwordCheck: data["Password_Check"],
|
|
2280
|
+
passwordCurrent: data["Password_Current"],
|
|
2281
|
+
currentPassword: data["CurrentPassword"],
|
|
2282
|
+
generatePassword: data["GeneratePassword"],
|
|
2283
|
+
generateAndDefinePassword: data["GenerateAndDefinePassword"],
|
|
2284
|
+
recoveryPasswordActionUrl: data["RecoveryPasswordActionUrl"],
|
|
2285
|
+
name: data["Name"],
|
|
2286
|
+
surname: data["Surname"],
|
|
2287
|
+
birthDate: data["BirthDate"],
|
|
2288
|
+
gender: data["Gender"],
|
|
2289
|
+
cpf: data["Cpf"],
|
|
2290
|
+
rg: data["RG"],
|
|
2291
|
+
tradingName: data["TradingName"],
|
|
2292
|
+
cnpj: data["Cnpj"],
|
|
2293
|
+
contact: data["Contact"],
|
|
2294
|
+
extendedProperties: data["ExtendedProperties"],
|
|
2295
|
+
currentUserIPs: data["CurrentUserIPs"],
|
|
2296
|
+
provider: data["Provider"],
|
|
2297
|
+
isCustomerRelation: data["IsCustomerRelation"],
|
|
2298
|
+
reCaptchaToken: data["ReCaptchaToken"],
|
|
2299
|
+
isFromGuestSession: data["IsFromGuestSession"],
|
|
2300
|
+
prefixFormat: data["PrefixFormat"]
|
|
2301
|
+
}));
|
|
2302
|
+
});
|
|
2303
|
+
var createBusinessAccountRequestCustomerRequest = import_zod8.z.lazy(() => {
|
|
2304
|
+
return import_zod8.z.object({
|
|
2305
|
+
customerType: import_zod8.z.string().optional().nullable(),
|
|
2306
|
+
sourceEnvironment: import_zod8.z.string().optional().nullable(),
|
|
2307
|
+
email: import_zod8.z.string().optional().nullable(),
|
|
2308
|
+
password: import_zod8.z.string().optional().nullable(),
|
|
2309
|
+
passwordCheck: import_zod8.z.string().optional().nullable(),
|
|
2310
|
+
passwordCurrent: import_zod8.z.string().optional().nullable(),
|
|
2311
|
+
currentPassword: import_zod8.z.string().optional().nullable(),
|
|
2312
|
+
generatePassword: import_zod8.z.boolean().optional().nullable(),
|
|
2313
|
+
generateAndDefinePassword: import_zod8.z.boolean().optional().nullable(),
|
|
2314
|
+
recoveryPasswordActionUrl: import_zod8.z.string().optional().nullable(),
|
|
2315
|
+
name: import_zod8.z.string().optional().nullable(),
|
|
2316
|
+
surname: import_zod8.z.string().optional().nullable(),
|
|
2317
|
+
birthDate: import_zod8.z.string().optional().nullable(),
|
|
2318
|
+
gender: import_zod8.z.string().optional().nullable(),
|
|
2319
|
+
cpf: import_zod8.z.string().optional().nullable(),
|
|
2320
|
+
rg: import_zod8.z.string().optional().nullable(),
|
|
2321
|
+
tradingName: import_zod8.z.string().optional().nullable(),
|
|
2322
|
+
cnpj: import_zod8.z.string().optional().nullable(),
|
|
2323
|
+
contact: customerContact2Request.optional().nullable(),
|
|
2324
|
+
extendedProperties: import_zod8.z.array(import_zod8.z.string()).optional().nullable(),
|
|
2325
|
+
currentUserIPs: import_zod8.z.string().optional().nullable(),
|
|
2326
|
+
provider: import_zod8.z.string().optional().nullable(),
|
|
2327
|
+
isCustomerRelation: import_zod8.z.boolean().optional().nullable(),
|
|
2328
|
+
reCaptchaToken: import_zod8.z.string().optional().nullable(),
|
|
2329
|
+
isFromGuestSession: import_zod8.z.boolean().optional().nullable(),
|
|
2330
|
+
prefixFormat: import_zod8.z.string().optional().nullable()
|
|
2331
|
+
}).transform((data) => ({
|
|
2332
|
+
CustomerType: data["customerType"],
|
|
2333
|
+
SourceEnvironment: data["sourceEnvironment"],
|
|
2334
|
+
Email: data["email"],
|
|
2335
|
+
Password: data["password"],
|
|
2336
|
+
Password_Check: data["passwordCheck"],
|
|
2337
|
+
Password_Current: data["passwordCurrent"],
|
|
2338
|
+
CurrentPassword: data["currentPassword"],
|
|
2339
|
+
GeneratePassword: data["generatePassword"],
|
|
2340
|
+
GenerateAndDefinePassword: data["generateAndDefinePassword"],
|
|
2341
|
+
RecoveryPasswordActionUrl: data["recoveryPasswordActionUrl"],
|
|
2342
|
+
Name: data["name"],
|
|
2343
|
+
Surname: data["surname"],
|
|
2344
|
+
BirthDate: data["birthDate"],
|
|
2345
|
+
Gender: data["gender"],
|
|
2346
|
+
Cpf: data["cpf"],
|
|
2347
|
+
RG: data["rg"],
|
|
2348
|
+
TradingName: data["tradingName"],
|
|
2349
|
+
Cnpj: data["cnpj"],
|
|
2350
|
+
Contact: data["contact"],
|
|
2351
|
+
ExtendedProperties: data["extendedProperties"],
|
|
2352
|
+
CurrentUserIPs: data["currentUserIPs"],
|
|
2353
|
+
Provider: data["provider"],
|
|
2354
|
+
IsCustomerRelation: data["isCustomerRelation"],
|
|
2355
|
+
ReCaptchaToken: data["reCaptchaToken"],
|
|
2356
|
+
IsFromGuestSession: data["isFromGuestSession"],
|
|
2357
|
+
PrefixFormat: data["prefixFormat"]
|
|
2358
|
+
}));
|
|
2359
|
+
});
|
|
2360
|
+
|
|
2361
|
+
// src/services/customers/models/addresses.ts
|
|
2362
|
+
var import_zod11 = require("zod");
|
|
2363
|
+
|
|
2364
|
+
// src/services/customers/models/extended-properties.ts
|
|
2365
|
+
var import_zod10 = require("zod");
|
|
2366
|
+
|
|
2367
|
+
// src/services/customers/models/html-attributes.ts
|
|
2368
|
+
var import_zod9 = require("zod");
|
|
2369
|
+
var htmlAttributes = import_zod9.z.lazy(() => {
|
|
2370
|
+
return import_zod9.z.object({
|
|
2371
|
+
additionalProp1: import_zod9.z.string().optional().nullable(),
|
|
2372
|
+
additionalProp2: import_zod9.z.string().optional().nullable(),
|
|
2373
|
+
additionalProp3: import_zod9.z.string().optional().nullable()
|
|
2374
|
+
});
|
|
2375
|
+
});
|
|
2376
|
+
var htmlAttributesResponse = import_zod9.z.lazy(() => {
|
|
2377
|
+
return import_zod9.z.object({
|
|
2378
|
+
additionalProp1: import_zod9.z.string().optional().nullable(),
|
|
2379
|
+
additionalProp2: import_zod9.z.string().optional().nullable(),
|
|
2380
|
+
additionalProp3: import_zod9.z.string().optional().nullable()
|
|
2381
|
+
}).transform((data) => ({
|
|
2382
|
+
additionalProp1: data["additionalProp1"],
|
|
2383
|
+
additionalProp2: data["additionalProp2"],
|
|
2384
|
+
additionalProp3: data["additionalProp3"]
|
|
2385
|
+
}));
|
|
2386
|
+
});
|
|
2387
|
+
var htmlAttributesRequest = import_zod9.z.lazy(() => {
|
|
2388
|
+
return import_zod9.z.object({
|
|
2389
|
+
additionalProp1: import_zod9.z.string().optional().nullable(),
|
|
2390
|
+
additionalProp2: import_zod9.z.string().optional().nullable(),
|
|
2391
|
+
additionalProp3: import_zod9.z.string().optional().nullable()
|
|
2392
|
+
}).transform((data) => ({
|
|
2393
|
+
additionalProp1: data["additionalProp1"],
|
|
2394
|
+
additionalProp2: data["additionalProp2"],
|
|
2395
|
+
additionalProp3: data["additionalProp3"]
|
|
2396
|
+
}));
|
|
2397
|
+
});
|
|
2398
|
+
|
|
2399
|
+
// src/services/customers/models/extended-properties.ts
|
|
2400
|
+
var extendedProperties = import_zod10.z.lazy(() => {
|
|
2401
|
+
return import_zod10.z.object({
|
|
2402
|
+
prefix: import_zod10.z.string().optional().nullable(),
|
|
2403
|
+
htmlAttributes: htmlAttributes.optional().nullable(),
|
|
2404
|
+
inputType: import_zod10.z.string().optional().nullable(),
|
|
2405
|
+
name: import_zod10.z.string().optional().nullable(),
|
|
2406
|
+
fieldName: import_zod10.z.string().optional().nullable(),
|
|
2407
|
+
bindType: import_zod10.z.string().optional().nullable(),
|
|
2408
|
+
entityMetadataId: import_zod10.z.number().optional().nullable(),
|
|
2409
|
+
value: import_zod10.z.string().optional().nullable(),
|
|
2410
|
+
values: import_zod10.z.array(import_zod10.z.string()).optional().nullable(),
|
|
2411
|
+
isNew: import_zod10.z.boolean().optional().nullable(),
|
|
2412
|
+
isRequired: import_zod10.z.boolean().optional().nullable(),
|
|
2413
|
+
displayName: import_zod10.z.string().optional().nullable(),
|
|
2414
|
+
optionName: import_zod10.z.string().optional().nullable()
|
|
2415
|
+
});
|
|
2416
|
+
});
|
|
2417
|
+
var extendedPropertiesResponse = import_zod10.z.lazy(() => {
|
|
2418
|
+
return import_zod10.z.object({
|
|
2419
|
+
Prefix: import_zod10.z.string().optional().nullable(),
|
|
2420
|
+
HtmlAttributes: htmlAttributesResponse.optional().nullable(),
|
|
2421
|
+
InputType: import_zod10.z.string().optional().nullable(),
|
|
2422
|
+
Name: import_zod10.z.string().optional().nullable(),
|
|
2423
|
+
FieldName: import_zod10.z.string().optional().nullable(),
|
|
2424
|
+
BindType: import_zod10.z.string().optional().nullable(),
|
|
2425
|
+
EntityMetadataID: import_zod10.z.number().optional().nullable(),
|
|
2426
|
+
Value: import_zod10.z.string().optional().nullable(),
|
|
2427
|
+
Values: import_zod10.z.array(import_zod10.z.string()).optional().nullable(),
|
|
2428
|
+
IsNew: import_zod10.z.boolean().optional().nullable(),
|
|
2429
|
+
IsRequired: import_zod10.z.boolean().optional().nullable(),
|
|
2430
|
+
DisplayName: import_zod10.z.string().optional().nullable(),
|
|
2431
|
+
OptionName: import_zod10.z.string().optional().nullable()
|
|
2432
|
+
}).transform((data) => ({
|
|
2433
|
+
prefix: data["Prefix"],
|
|
2434
|
+
htmlAttributes: data["HtmlAttributes"],
|
|
2435
|
+
inputType: data["InputType"],
|
|
2436
|
+
name: data["Name"],
|
|
2437
|
+
fieldName: data["FieldName"],
|
|
2438
|
+
bindType: data["BindType"],
|
|
2439
|
+
entityMetadataId: data["EntityMetadataID"],
|
|
2440
|
+
value: data["Value"],
|
|
2441
|
+
values: data["Values"],
|
|
2442
|
+
isNew: data["IsNew"],
|
|
2443
|
+
isRequired: data["IsRequired"],
|
|
2444
|
+
displayName: data["DisplayName"],
|
|
2445
|
+
optionName: data["OptionName"]
|
|
2446
|
+
}));
|
|
2447
|
+
});
|
|
2448
|
+
var extendedPropertiesRequest = import_zod10.z.lazy(() => {
|
|
2449
|
+
return import_zod10.z.object({
|
|
2450
|
+
prefix: import_zod10.z.string().optional().nullable(),
|
|
2451
|
+
htmlAttributes: htmlAttributesRequest.optional().nullable(),
|
|
2452
|
+
inputType: import_zod10.z.string().optional().nullable(),
|
|
2453
|
+
name: import_zod10.z.string().optional().nullable(),
|
|
2454
|
+
fieldName: import_zod10.z.string().optional().nullable(),
|
|
2455
|
+
bindType: import_zod10.z.string().optional().nullable(),
|
|
2456
|
+
entityMetadataId: import_zod10.z.number().optional().nullable(),
|
|
2457
|
+
value: import_zod10.z.string().optional().nullable(),
|
|
2458
|
+
values: import_zod10.z.array(import_zod10.z.string()).optional().nullable(),
|
|
2459
|
+
isNew: import_zod10.z.boolean().optional().nullable(),
|
|
2460
|
+
isRequired: import_zod10.z.boolean().optional().nullable(),
|
|
2461
|
+
displayName: import_zod10.z.string().optional().nullable(),
|
|
2462
|
+
optionName: import_zod10.z.string().optional().nullable()
|
|
2463
|
+
}).transform((data) => ({
|
|
2464
|
+
Prefix: data["prefix"],
|
|
2465
|
+
HtmlAttributes: data["htmlAttributes"],
|
|
2466
|
+
InputType: data["inputType"],
|
|
2467
|
+
Name: data["name"],
|
|
2468
|
+
FieldName: data["fieldName"],
|
|
2469
|
+
BindType: data["bindType"],
|
|
2470
|
+
EntityMetadataID: data["entityMetadataId"],
|
|
2471
|
+
Value: data["value"],
|
|
2472
|
+
Values: data["values"],
|
|
2473
|
+
IsNew: data["isNew"],
|
|
2474
|
+
IsRequired: data["isRequired"],
|
|
2475
|
+
DisplayName: data["displayName"],
|
|
2476
|
+
OptionName: data["optionName"]
|
|
2477
|
+
}));
|
|
2478
|
+
});
|
|
2479
|
+
|
|
2480
|
+
// src/services/customers/models/addresses.ts
|
|
2481
|
+
var addresses = import_zod11.z.lazy(() => {
|
|
2482
|
+
return import_zod11.z.object({
|
|
2483
|
+
id: import_zod11.z.number().optional().nullable(),
|
|
2484
|
+
name: import_zod11.z.string().optional().nullable(),
|
|
2485
|
+
contactName: import_zod11.z.string().optional().nullable(),
|
|
2486
|
+
addressLine: import_zod11.z.string().optional().nullable(),
|
|
2487
|
+
city: import_zod11.z.string().optional().nullable(),
|
|
2488
|
+
neighbourhood: import_zod11.z.string().optional().nullable(),
|
|
2489
|
+
number: import_zod11.z.string().optional().nullable(),
|
|
2490
|
+
state: import_zod11.z.string().optional().nullable(),
|
|
2491
|
+
postalCode: import_zod11.z.string().optional().nullable(),
|
|
2492
|
+
addressNotes: import_zod11.z.string().optional().nullable(),
|
|
2493
|
+
landmark: import_zod11.z.string().optional().nullable(),
|
|
2494
|
+
isMainAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2495
|
+
setAsShippingAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2496
|
+
setAsBillingAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2497
|
+
latitude: import_zod11.z.string().optional().nullable(),
|
|
2498
|
+
longitude: import_zod11.z.string().optional().nullable(),
|
|
2499
|
+
extendedProperties: import_zod11.z.array(extendedProperties).optional().nullable(),
|
|
2500
|
+
currentUserIPs: import_zod11.z.string().optional().nullable(),
|
|
2501
|
+
prefixFormat: import_zod11.z.string().optional().nullable()
|
|
2502
|
+
});
|
|
2503
|
+
});
|
|
2504
|
+
var addressesResponse = import_zod11.z.lazy(() => {
|
|
2505
|
+
return import_zod11.z.object({
|
|
2506
|
+
ID: import_zod11.z.number().optional().nullable(),
|
|
2507
|
+
Name: import_zod11.z.string().optional().nullable(),
|
|
2508
|
+
ContactName: import_zod11.z.string().optional().nullable(),
|
|
2509
|
+
AddressLine: import_zod11.z.string().optional().nullable(),
|
|
2510
|
+
City: import_zod11.z.string().optional().nullable(),
|
|
2511
|
+
Neighbourhood: import_zod11.z.string().optional().nullable(),
|
|
2512
|
+
Number: import_zod11.z.string().optional().nullable(),
|
|
2513
|
+
State: import_zod11.z.string().optional().nullable(),
|
|
2514
|
+
PostalCode: import_zod11.z.string().optional().nullable(),
|
|
2515
|
+
AddressNotes: import_zod11.z.string().optional().nullable(),
|
|
2516
|
+
Landmark: import_zod11.z.string().optional().nullable(),
|
|
2517
|
+
IsMainAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2518
|
+
SetAsShippingAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2519
|
+
SetAsBillingAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2520
|
+
Latitude: import_zod11.z.string().optional().nullable(),
|
|
2521
|
+
Longitude: import_zod11.z.string().optional().nullable(),
|
|
2522
|
+
ExtendedProperties: import_zod11.z.array(extendedPropertiesResponse).optional().nullable(),
|
|
2523
|
+
CurrentUserIPs: import_zod11.z.string().optional().nullable(),
|
|
2524
|
+
PrefixFormat: import_zod11.z.string().optional().nullable()
|
|
2525
|
+
}).transform((data) => ({
|
|
2526
|
+
id: data["ID"],
|
|
2527
|
+
name: data["Name"],
|
|
2528
|
+
contactName: data["ContactName"],
|
|
2529
|
+
addressLine: data["AddressLine"],
|
|
2530
|
+
city: data["City"],
|
|
2531
|
+
neighbourhood: data["Neighbourhood"],
|
|
2532
|
+
number: data["Number"],
|
|
2533
|
+
state: data["State"],
|
|
2534
|
+
postalCode: data["PostalCode"],
|
|
2535
|
+
addressNotes: data["AddressNotes"],
|
|
2536
|
+
landmark: data["Landmark"],
|
|
2537
|
+
isMainAddress: data["IsMainAddress"],
|
|
2538
|
+
setAsShippingAddress: data["SetAsShippingAddress"],
|
|
2539
|
+
setAsBillingAddress: data["SetAsBillingAddress"],
|
|
2540
|
+
latitude: data["Latitude"],
|
|
2541
|
+
longitude: data["Longitude"],
|
|
2542
|
+
extendedProperties: data["ExtendedProperties"],
|
|
2543
|
+
currentUserIPs: data["CurrentUserIPs"],
|
|
2544
|
+
prefixFormat: data["PrefixFormat"]
|
|
2545
|
+
}));
|
|
2546
|
+
});
|
|
2547
|
+
var addressesRequest = import_zod11.z.lazy(() => {
|
|
2548
|
+
return import_zod11.z.object({
|
|
2549
|
+
id: import_zod11.z.number().optional().nullable(),
|
|
2550
|
+
name: import_zod11.z.string().optional().nullable(),
|
|
2551
|
+
contactName: import_zod11.z.string().optional().nullable(),
|
|
2552
|
+
addressLine: import_zod11.z.string().optional().nullable(),
|
|
2553
|
+
city: import_zod11.z.string().optional().nullable(),
|
|
2554
|
+
neighbourhood: import_zod11.z.string().optional().nullable(),
|
|
2555
|
+
number: import_zod11.z.string().optional().nullable(),
|
|
2556
|
+
state: import_zod11.z.string().optional().nullable(),
|
|
2557
|
+
postalCode: import_zod11.z.string().optional().nullable(),
|
|
2558
|
+
addressNotes: import_zod11.z.string().optional().nullable(),
|
|
2559
|
+
landmark: import_zod11.z.string().optional().nullable(),
|
|
2560
|
+
isMainAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2561
|
+
setAsShippingAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2562
|
+
setAsBillingAddress: import_zod11.z.boolean().optional().nullable(),
|
|
2563
|
+
latitude: import_zod11.z.string().optional().nullable(),
|
|
2564
|
+
longitude: import_zod11.z.string().optional().nullable(),
|
|
2565
|
+
extendedProperties: import_zod11.z.array(extendedPropertiesRequest).optional().nullable(),
|
|
2566
|
+
currentUserIPs: import_zod11.z.string().optional().nullable(),
|
|
2567
|
+
prefixFormat: import_zod11.z.string().optional().nullable()
|
|
2568
|
+
}).transform((data) => ({
|
|
2569
|
+
ID: data["id"],
|
|
2570
|
+
Name: data["name"],
|
|
2571
|
+
ContactName: data["contactName"],
|
|
2572
|
+
AddressLine: data["addressLine"],
|
|
2573
|
+
City: data["city"],
|
|
2574
|
+
Neighbourhood: data["neighbourhood"],
|
|
2575
|
+
Number: data["number"],
|
|
2576
|
+
State: data["state"],
|
|
2577
|
+
PostalCode: data["postalCode"],
|
|
2578
|
+
AddressNotes: data["addressNotes"],
|
|
2579
|
+
Landmark: data["landmark"],
|
|
2580
|
+
IsMainAddress: data["isMainAddress"],
|
|
2581
|
+
SetAsShippingAddress: data["setAsShippingAddress"],
|
|
2582
|
+
SetAsBillingAddress: data["setAsBillingAddress"],
|
|
2583
|
+
Latitude: data["latitude"],
|
|
2584
|
+
Longitude: data["longitude"],
|
|
2585
|
+
ExtendedProperties: data["extendedProperties"],
|
|
2586
|
+
CurrentUserIPs: data["currentUserIPs"],
|
|
2587
|
+
PrefixFormat: data["prefixFormat"]
|
|
2588
|
+
}));
|
|
2589
|
+
});
|
|
2590
|
+
|
|
2591
|
+
// src/services/customers/models/create-business-account-request.ts
|
|
2592
|
+
var createBusinessAccountRequest = import_zod12.z.lazy(() => {
|
|
2593
|
+
return import_zod12.z.object({
|
|
2594
|
+
customer: createBusinessAccountRequestCustomer.optional().nullable(),
|
|
2595
|
+
addresses: import_zod12.z.array(addresses).optional().nullable(),
|
|
2596
|
+
shopperTicketId: import_zod12.z.string().optional().nullable(),
|
|
2597
|
+
basketId: import_zod12.z.number().optional().nullable(),
|
|
2598
|
+
customerId: import_zod12.z.number().optional().nullable(),
|
|
2599
|
+
sessionId: import_zod12.z.string().optional().nullable()
|
|
2600
|
+
});
|
|
2601
|
+
});
|
|
2602
|
+
var createBusinessAccountRequestResponse = import_zod12.z.lazy(() => {
|
|
2603
|
+
return import_zod12.z.object({
|
|
2604
|
+
Customer: createBusinessAccountRequestCustomerResponse.optional().nullable(),
|
|
2605
|
+
Addresses: import_zod12.z.array(addressesResponse).optional().nullable(),
|
|
2606
|
+
ShopperTicketID: import_zod12.z.string().optional().nullable(),
|
|
2607
|
+
BasketID: import_zod12.z.number().optional().nullable(),
|
|
2608
|
+
CustomerID: import_zod12.z.number().optional().nullable(),
|
|
2609
|
+
SessionID: import_zod12.z.string().optional().nullable()
|
|
2610
|
+
}).transform((data) => ({
|
|
2611
|
+
customer: data["Customer"],
|
|
2612
|
+
addresses: data["Addresses"],
|
|
2613
|
+
shopperTicketId: data["ShopperTicketID"],
|
|
2614
|
+
basketId: data["BasketID"],
|
|
2615
|
+
customerId: data["CustomerID"],
|
|
2616
|
+
sessionId: data["SessionID"]
|
|
2617
|
+
}));
|
|
2618
|
+
});
|
|
2619
|
+
var createBusinessAccountRequestRequest = import_zod12.z.lazy(() => {
|
|
2620
|
+
return import_zod12.z.object({
|
|
2621
|
+
customer: createBusinessAccountRequestCustomerRequest.optional().nullable(),
|
|
2622
|
+
addresses: import_zod12.z.array(addressesRequest).optional().nullable(),
|
|
2623
|
+
shopperTicketId: import_zod12.z.string().optional().nullable(),
|
|
2624
|
+
basketId: import_zod12.z.number().optional().nullable(),
|
|
2625
|
+
customerId: import_zod12.z.number().optional().nullable(),
|
|
2626
|
+
sessionId: import_zod12.z.string().optional().nullable()
|
|
2627
|
+
}).transform((data) => ({
|
|
2628
|
+
Customer: data["customer"],
|
|
2629
|
+
Addresses: data["addresses"],
|
|
2630
|
+
ShopperTicketID: data["shopperTicketId"],
|
|
2631
|
+
BasketID: data["basketId"],
|
|
2632
|
+
CustomerID: data["customerId"],
|
|
2633
|
+
SessionID: data["sessionId"]
|
|
2634
|
+
}));
|
|
2635
|
+
});
|
|
2636
|
+
|
|
2637
|
+
// src/services/customers/models/login-request.ts
|
|
2638
|
+
var import_zod13 = require("zod");
|
|
2639
|
+
var loginRequest = import_zod13.z.lazy(() => {
|
|
2640
|
+
return import_zod13.z.object({
|
|
2641
|
+
key: import_zod13.z.string().optional().nullable(),
|
|
2642
|
+
password: import_zod13.z.string().optional().nullable()
|
|
2643
|
+
});
|
|
2644
|
+
});
|
|
2645
|
+
var loginRequestResponse = import_zod13.z.lazy(() => {
|
|
2646
|
+
return import_zod13.z.object({
|
|
2647
|
+
Key: import_zod13.z.string().optional().nullable(),
|
|
2648
|
+
Password: import_zod13.z.string().optional().nullable()
|
|
2649
|
+
}).transform((data) => ({
|
|
2650
|
+
key: data["Key"],
|
|
2651
|
+
password: data["Password"]
|
|
2652
|
+
}));
|
|
2653
|
+
});
|
|
2654
|
+
var loginRequestRequest = import_zod13.z.lazy(() => {
|
|
2655
|
+
return import_zod13.z.object({
|
|
2656
|
+
key: import_zod13.z.string().optional().nullable(),
|
|
2657
|
+
password: import_zod13.z.string().optional().nullable()
|
|
2658
|
+
}).transform((data) => ({
|
|
2659
|
+
Key: data["key"],
|
|
2660
|
+
Password: data["password"]
|
|
2661
|
+
}));
|
|
2662
|
+
});
|
|
2663
|
+
|
|
2664
|
+
// src/services/customers/models/recover-password-request.ts
|
|
2665
|
+
var import_zod14 = require("zod");
|
|
2666
|
+
var recoverPasswordRequest = import_zod14.z.lazy(() => {
|
|
2667
|
+
return import_zod14.z.object({
|
|
2668
|
+
key: import_zod14.z.string().optional().nullable()
|
|
2669
|
+
});
|
|
2670
|
+
});
|
|
2671
|
+
var recoverPasswordRequestResponse = import_zod14.z.lazy(() => {
|
|
2672
|
+
return import_zod14.z.object({
|
|
2673
|
+
Key: import_zod14.z.string().optional().nullable()
|
|
2674
|
+
}).transform((data) => ({
|
|
2675
|
+
key: data["Key"]
|
|
2676
|
+
}));
|
|
2677
|
+
});
|
|
2678
|
+
var recoverPasswordRequestRequest = import_zod14.z.lazy(() => {
|
|
2679
|
+
return import_zod14.z.object({
|
|
2680
|
+
key: import_zod14.z.string().optional().nullable()
|
|
2681
|
+
}).transform((data) => ({
|
|
2682
|
+
Key: data["key"]
|
|
2683
|
+
}));
|
|
2684
|
+
});
|
|
2685
|
+
|
|
2686
|
+
// src/services/customers/customers-service.ts
|
|
2687
|
+
var CustomersService = class extends BaseService {
|
|
2688
|
+
constructor() {
|
|
2689
|
+
super(...arguments);
|
|
2690
|
+
this.createConsumerConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2691
|
+
this.createBusinessAccountConfig = {
|
|
2692
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
2693
|
+
};
|
|
2694
|
+
this.loginConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2695
|
+
this.refreshLoginConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2696
|
+
this.keepSessionActiveConfig = {
|
|
2697
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
2698
|
+
};
|
|
2699
|
+
this.consumerDetailConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2700
|
+
this.updateConsumerConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2701
|
+
this.recoverPasswordConfig = {
|
|
2702
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
2703
|
+
};
|
|
2704
|
+
this.logoutConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2705
|
+
this.sendPinConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
2706
|
+
this.sendConfirmationEmailConfig = {
|
|
2707
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
2708
|
+
};
|
|
2709
|
+
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Sets method-level configuration for createConsumer.
|
|
2712
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2713
|
+
* @returns This service instance for method chaining
|
|
2714
|
+
*/
|
|
2715
|
+
setCreateConsumerConfig(config) {
|
|
2716
|
+
this.createConsumerConfig = config;
|
|
2717
|
+
return this;
|
|
2718
|
+
}
|
|
2719
|
+
/**
|
|
2720
|
+
* Sets method-level configuration for createBusinessAccount.
|
|
2721
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2722
|
+
* @returns This service instance for method chaining
|
|
2723
|
+
*/
|
|
2724
|
+
setCreateBusinessAccountConfig(config) {
|
|
2725
|
+
this.createBusinessAccountConfig = config;
|
|
2726
|
+
return this;
|
|
2727
|
+
}
|
|
2728
|
+
/**
|
|
2729
|
+
* Sets method-level configuration for login.
|
|
2730
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2731
|
+
* @returns This service instance for method chaining
|
|
2732
|
+
*/
|
|
2733
|
+
setLoginConfig(config) {
|
|
2734
|
+
this.loginConfig = config;
|
|
2735
|
+
return this;
|
|
2736
|
+
}
|
|
2737
|
+
/**
|
|
2738
|
+
* Sets method-level configuration for refreshLogin.
|
|
2739
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2740
|
+
* @returns This service instance for method chaining
|
|
2741
|
+
*/
|
|
2742
|
+
setRefreshLoginConfig(config) {
|
|
2743
|
+
this.refreshLoginConfig = config;
|
|
2744
|
+
return this;
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Sets method-level configuration for keepSessionActive.
|
|
2748
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2749
|
+
* @returns This service instance for method chaining
|
|
2750
|
+
*/
|
|
2751
|
+
setKeepSessionActiveConfig(config) {
|
|
2752
|
+
this.keepSessionActiveConfig = config;
|
|
2753
|
+
return this;
|
|
2754
|
+
}
|
|
2755
|
+
/**
|
|
2756
|
+
* Sets method-level configuration for consumerDetail.
|
|
2757
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2758
|
+
* @returns This service instance for method chaining
|
|
2759
|
+
*/
|
|
2760
|
+
setConsumerDetailConfig(config) {
|
|
2761
|
+
this.consumerDetailConfig = config;
|
|
2762
|
+
return this;
|
|
2763
|
+
}
|
|
2764
|
+
/**
|
|
2765
|
+
* Sets method-level configuration for updateConsumer.
|
|
2766
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2767
|
+
* @returns This service instance for method chaining
|
|
2768
|
+
*/
|
|
2769
|
+
setUpdateConsumerConfig(config) {
|
|
2770
|
+
this.updateConsumerConfig = config;
|
|
2771
|
+
return this;
|
|
2772
|
+
}
|
|
2773
|
+
/**
|
|
2774
|
+
* Sets method-level configuration for recoverPassword.
|
|
2775
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2776
|
+
* @returns This service instance for method chaining
|
|
2777
|
+
*/
|
|
2778
|
+
setRecoverPasswordConfig(config) {
|
|
2779
|
+
this.recoverPasswordConfig = config;
|
|
2780
|
+
return this;
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Sets method-level configuration for logout.
|
|
2784
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2785
|
+
* @returns This service instance for method chaining
|
|
2786
|
+
*/
|
|
2787
|
+
setLogoutConfig(config) {
|
|
2788
|
+
this.logoutConfig = config;
|
|
2789
|
+
return this;
|
|
2790
|
+
}
|
|
2791
|
+
/**
|
|
2792
|
+
* Sets method-level configuration for sendPin.
|
|
2793
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2794
|
+
* @returns This service instance for method chaining
|
|
2795
|
+
*/
|
|
2796
|
+
setSendPinConfig(config) {
|
|
2797
|
+
this.sendPinConfig = config;
|
|
2798
|
+
return this;
|
|
2799
|
+
}
|
|
2800
|
+
/**
|
|
2801
|
+
* Sets method-level configuration for sendConfirmationEmail.
|
|
2802
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2803
|
+
* @returns This service instance for method chaining
|
|
2804
|
+
*/
|
|
2805
|
+
setSendConfirmationEmailConfig(config) {
|
|
2806
|
+
this.sendConfirmationEmailConfig = config;
|
|
2807
|
+
return this;
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
*
|
|
2811
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2812
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2813
|
+
*/
|
|
2814
|
+
async createConsumer(body, requestConfig) {
|
|
2815
|
+
const resolvedConfig = this.getResolvedConfig(this.createConsumerConfig, requestConfig);
|
|
2816
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/Register").setRequestSchema(createConsumerRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2817
|
+
schema: import_zod15.z.any(),
|
|
2818
|
+
contentType: "json" /* Json */,
|
|
2819
|
+
status: 200
|
|
2820
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2821
|
+
return this.client.callDirect(request);
|
|
2822
|
+
}
|
|
2823
|
+
/**
|
|
2824
|
+
*
|
|
2825
|
+
* @param {string} params.accept -
|
|
2826
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2827
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2828
|
+
*/
|
|
2829
|
+
async createBusinessAccount(body, params, requestConfig) {
|
|
2830
|
+
const resolvedConfig = this.getResolvedConfig(this.createBusinessAccountConfig, requestConfig);
|
|
2831
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/Register").setRequestSchema(createBusinessAccountRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2832
|
+
schema: import_zod15.z.any(),
|
|
2833
|
+
contentType: "json" /* Json */,
|
|
2834
|
+
status: 200
|
|
2835
|
+
}).addHeaderParam({
|
|
2836
|
+
key: "Accept",
|
|
2837
|
+
value: params == null ? void 0 : params.accept
|
|
2838
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2839
|
+
return this.client.callDirect(request);
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
*
|
|
2843
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2844
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2845
|
+
*/
|
|
2846
|
+
async login(body, requestConfig) {
|
|
2847
|
+
const resolvedConfig = this.getResolvedConfig(this.loginConfig, requestConfig);
|
|
2848
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/Login").setRequestSchema(loginRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2849
|
+
schema: import_zod15.z.any(),
|
|
2850
|
+
contentType: "json" /* Json */,
|
|
2851
|
+
status: 200
|
|
2852
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2853
|
+
return this.client.callDirect(request);
|
|
2854
|
+
}
|
|
2855
|
+
/**
|
|
2856
|
+
*
|
|
2857
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2858
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2859
|
+
*/
|
|
2860
|
+
async refreshLogin(body, requestConfig) {
|
|
2861
|
+
const resolvedConfig = this.getResolvedConfig(this.refreshLoginConfig, requestConfig);
|
|
2862
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/RefreshLogin").setRequestSchema(import_zod15.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2863
|
+
schema: import_zod15.z.any(),
|
|
2864
|
+
contentType: "json" /* Json */,
|
|
2865
|
+
status: 200
|
|
2866
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2867
|
+
return this.client.callDirect(request);
|
|
2868
|
+
}
|
|
2869
|
+
/**
|
|
2870
|
+
*
|
|
2871
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2872
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2873
|
+
*/
|
|
2874
|
+
async keepSessionActive(body, requestConfig) {
|
|
2875
|
+
const resolvedConfig = this.getResolvedConfig(this.keepSessionActiveConfig, requestConfig);
|
|
2876
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/KeepAlive").setRequestSchema(import_zod15.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2877
|
+
schema: import_zod15.z.any(),
|
|
2878
|
+
contentType: "json" /* Json */,
|
|
2879
|
+
status: 200
|
|
2880
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2881
|
+
return this.client.callDirect(request);
|
|
2882
|
+
}
|
|
2883
|
+
/**
|
|
2884
|
+
*
|
|
2885
|
+
* @param {string} [params.customerId] -
|
|
2886
|
+
* @param {string} [params.sessionId] -
|
|
2887
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2888
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2889
|
+
*/
|
|
2890
|
+
async consumerDetail(params, requestConfig) {
|
|
2891
|
+
const resolvedConfig = this.getResolvedConfig(this.consumerDetailConfig, requestConfig);
|
|
2892
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/Profile/Customer/GetCustomer").setRequestSchema(import_zod15.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2893
|
+
schema: import_zod15.z.any(),
|
|
2894
|
+
contentType: "json" /* Json */,
|
|
2895
|
+
status: 200
|
|
2896
|
+
}).addQueryParam({
|
|
2897
|
+
key: "customerID",
|
|
2898
|
+
value: params == null ? void 0 : params.customerId
|
|
2899
|
+
}).addQueryParam({
|
|
2900
|
+
key: "sessionID",
|
|
2901
|
+
value: params == null ? void 0 : params.sessionId
|
|
2902
|
+
}).build();
|
|
2903
|
+
return this.client.callDirect(request);
|
|
2904
|
+
}
|
|
2905
|
+
/**
|
|
2906
|
+
*
|
|
2907
|
+
* @param {string} params.accept -
|
|
2908
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2909
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2910
|
+
*/
|
|
2911
|
+
async updateConsumer(body, params, requestConfig) {
|
|
2912
|
+
const resolvedConfig = this.getResolvedConfig(this.updateConsumerConfig, requestConfig);
|
|
2913
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/Update").setRequestSchema(import_zod15.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2914
|
+
schema: import_zod15.z.any(),
|
|
2915
|
+
contentType: "json" /* Json */,
|
|
2916
|
+
status: 200
|
|
2917
|
+
}).addHeaderParam({
|
|
2918
|
+
key: "Accept",
|
|
2919
|
+
value: params == null ? void 0 : params.accept
|
|
2920
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2921
|
+
return this.client.callDirect(request);
|
|
2922
|
+
}
|
|
2923
|
+
/**
|
|
2924
|
+
*
|
|
2925
|
+
* @param {string} params.accept -
|
|
2926
|
+
* @param {string} params.cacheControl -
|
|
2927
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2928
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2929
|
+
*/
|
|
2930
|
+
async recoverPassword(body, params, requestConfig) {
|
|
2931
|
+
const resolvedConfig = this.getResolvedConfig(this.recoverPasswordConfig, requestConfig);
|
|
2932
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Customer/RecoverPassword").setRequestSchema(recoverPasswordRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
2933
|
+
schema: import_zod15.z.any(),
|
|
2934
|
+
contentType: "json" /* Json */,
|
|
2935
|
+
status: 200
|
|
2936
|
+
}).addHeaderParam({
|
|
2937
|
+
key: "Accept",
|
|
2938
|
+
value: params == null ? void 0 : params.accept
|
|
2939
|
+
}).addHeaderParam({
|
|
2940
|
+
key: "Cache-Control",
|
|
2941
|
+
value: params == null ? void 0 : params.cacheControl
|
|
2942
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2943
|
+
return this.client.callDirect(request);
|
|
2944
|
+
}
|
|
2945
|
+
/**
|
|
2946
|
+
*
|
|
2947
|
+
* @param {string} params.authorization -
|
|
2948
|
+
* @param {string} params.accept -
|
|
2949
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2950
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2951
|
+
*/
|
|
2952
|
+
async logout(body, params, requestConfig) {
|
|
2953
|
+
const resolvedConfig = this.getResolvedConfig(this.logoutConfig, requestConfig);
|
|
2954
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/Logout").setRequestSchema(import_zod15.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
2955
|
+
schema: import_zod15.z.any(),
|
|
2956
|
+
contentType: "json" /* Json */,
|
|
2957
|
+
status: 200
|
|
2958
|
+
}).addHeaderParam({
|
|
2959
|
+
key: "Authorization",
|
|
2960
|
+
value: params == null ? void 0 : params.authorization
|
|
2961
|
+
}).addHeaderParam({
|
|
2962
|
+
key: "Accept",
|
|
2963
|
+
value: params == null ? void 0 : params.accept
|
|
2964
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2965
|
+
return this.client.callDirect(request);
|
|
2966
|
+
}
|
|
2967
|
+
/**
|
|
2968
|
+
*
|
|
2969
|
+
* @param {string} params.authorization -
|
|
2970
|
+
* @param {string} params.accept -
|
|
2971
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2972
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2973
|
+
*/
|
|
2974
|
+
async sendPin(body, params, requestConfig) {
|
|
2975
|
+
const resolvedConfig = this.getResolvedConfig(this.sendPinConfig, requestConfig);
|
|
2976
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/Account/RequestNewPin").setRequestSchema(import_zod15.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
2977
|
+
schema: import_zod15.z.any(),
|
|
2978
|
+
contentType: "json" /* Json */,
|
|
2979
|
+
status: 200
|
|
2980
|
+
}).addHeaderParam({
|
|
2981
|
+
key: "Authorization",
|
|
2982
|
+
value: params == null ? void 0 : params.authorization
|
|
2983
|
+
}).addHeaderParam({
|
|
2984
|
+
key: "Accept",
|
|
2985
|
+
value: params == null ? void 0 : params.accept
|
|
2986
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
2987
|
+
return this.client.callDirect(request);
|
|
2988
|
+
}
|
|
2989
|
+
/**
|
|
2990
|
+
*
|
|
2991
|
+
* @param {string} params.authorization -
|
|
2992
|
+
* @param {string} params.accept -
|
|
2993
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2994
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
2995
|
+
*/
|
|
2996
|
+
async sendConfirmationEmail(body, params, requestConfig) {
|
|
2997
|
+
const resolvedConfig = this.getResolvedConfig(this.sendConfirmationEmailConfig, requestConfig);
|
|
2998
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/Profile/Account/ResendEmailConfirmationMessage").setRequestSchema(import_zod15.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
2999
|
+
schema: import_zod15.z.any(),
|
|
3000
|
+
contentType: "json" /* Json */,
|
|
3001
|
+
status: 200
|
|
3002
|
+
}).addHeaderParam({
|
|
3003
|
+
key: "Authorization",
|
|
3004
|
+
value: params == null ? void 0 : params.authorization
|
|
3005
|
+
}).addHeaderParam({
|
|
3006
|
+
key: "Accept",
|
|
3007
|
+
value: params == null ? void 0 : params.accept
|
|
3008
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3009
|
+
return this.client.callDirect(request);
|
|
3010
|
+
}
|
|
3011
|
+
};
|
|
3012
|
+
|
|
3013
|
+
// src/services/products/products-service.ts
|
|
3014
|
+
var import_zod18 = require("zod");
|
|
3015
|
+
|
|
3016
|
+
// src/services/products/models/products-datasource-request.ts
|
|
3017
|
+
var import_zod16 = require("zod");
|
|
3018
|
+
var productsDatasourceRequest = import_zod16.z.lazy(() => {
|
|
3019
|
+
return import_zod16.z.object({
|
|
3020
|
+
pageNumber: import_zod16.z.number().optional().nullable(),
|
|
3021
|
+
pageIndex: import_zod16.z.number().optional().nullable(),
|
|
3022
|
+
pageSize: import_zod16.z.number().optional().nullable()
|
|
3023
|
+
});
|
|
3024
|
+
});
|
|
3025
|
+
var productsDatasourceRequestResponse = import_zod16.z.lazy(() => {
|
|
3026
|
+
return import_zod16.z.object({
|
|
3027
|
+
PageNumber: import_zod16.z.number().optional().nullable(),
|
|
3028
|
+
PageIndex: import_zod16.z.number().optional().nullable(),
|
|
3029
|
+
PageSize: import_zod16.z.number().optional().nullable()
|
|
3030
|
+
}).transform((data) => ({
|
|
3031
|
+
pageNumber: data["PageNumber"],
|
|
3032
|
+
pageIndex: data["PageIndex"],
|
|
3033
|
+
pageSize: data["PageSize"]
|
|
3034
|
+
}));
|
|
3035
|
+
});
|
|
3036
|
+
var productsDatasourceRequestRequest = import_zod16.z.lazy(() => {
|
|
3037
|
+
return import_zod16.z.object({
|
|
3038
|
+
pageNumber: import_zod16.z.number().optional().nullable(),
|
|
3039
|
+
pageIndex: import_zod16.z.number().optional().nullable(),
|
|
3040
|
+
pageSize: import_zod16.z.number().optional().nullable()
|
|
3041
|
+
}).transform((data) => ({
|
|
3042
|
+
PageNumber: data["pageNumber"],
|
|
3043
|
+
PageIndex: data["pageIndex"],
|
|
3044
|
+
PageSize: data["pageSize"]
|
|
3045
|
+
}));
|
|
3046
|
+
});
|
|
3047
|
+
|
|
3048
|
+
// src/services/products/models/brands-request.ts
|
|
3049
|
+
var import_zod17 = require("zod");
|
|
3050
|
+
var brandsRequest = import_zod17.z.lazy(() => {
|
|
3051
|
+
return import_zod17.z.object({
|
|
3052
|
+
id: import_zod17.z.number().optional().nullable()
|
|
3053
|
+
});
|
|
3054
|
+
});
|
|
3055
|
+
var brandsRequestResponse = import_zod17.z.lazy(() => {
|
|
3056
|
+
return import_zod17.z.object({
|
|
3057
|
+
id: import_zod17.z.number().optional().nullable()
|
|
3058
|
+
}).transform((data) => ({
|
|
3059
|
+
id: data["id"]
|
|
3060
|
+
}));
|
|
3061
|
+
});
|
|
3062
|
+
var brandsRequestRequest = import_zod17.z.lazy(() => {
|
|
3063
|
+
return import_zod17.z.object({
|
|
3064
|
+
id: import_zod17.z.number().optional().nullable()
|
|
3065
|
+
}).transform((data) => ({
|
|
3066
|
+
id: data["id"]
|
|
3067
|
+
}));
|
|
3068
|
+
});
|
|
3069
|
+
|
|
3070
|
+
// src/services/products/products-service.ts
|
|
3071
|
+
var ProductsService = class extends BaseService {
|
|
3072
|
+
constructor() {
|
|
3073
|
+
super(...arguments);
|
|
3074
|
+
this.productSearchConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3075
|
+
this.productDetailsConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3076
|
+
this.productsDatasourceConfig = {
|
|
3077
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3078
|
+
};
|
|
3079
|
+
this.searchCategoriesConfig = {
|
|
3080
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3081
|
+
};
|
|
3082
|
+
this.brandsConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3083
|
+
this.listCategoriesConfig = { environment: "https://{{storeUrl}}" /* STOREURL */ };
|
|
3084
|
+
}
|
|
3085
|
+
/**
|
|
3086
|
+
* Sets method-level configuration for productSearch.
|
|
3087
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3088
|
+
* @returns This service instance for method chaining
|
|
3089
|
+
*/
|
|
3090
|
+
setProductSearchConfig(config) {
|
|
3091
|
+
this.productSearchConfig = config;
|
|
3092
|
+
return this;
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* Sets method-level configuration for productDetails.
|
|
3096
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3097
|
+
* @returns This service instance for method chaining
|
|
3098
|
+
*/
|
|
3099
|
+
setProductDetailsConfig(config) {
|
|
3100
|
+
this.productDetailsConfig = config;
|
|
3101
|
+
return this;
|
|
3102
|
+
}
|
|
3103
|
+
/**
|
|
3104
|
+
* Sets method-level configuration for productsDatasource.
|
|
3105
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3106
|
+
* @returns This service instance for method chaining
|
|
3107
|
+
*/
|
|
3108
|
+
setProductsDatasourceConfig(config) {
|
|
3109
|
+
this.productsDatasourceConfig = config;
|
|
3110
|
+
return this;
|
|
3111
|
+
}
|
|
3112
|
+
/**
|
|
3113
|
+
* Sets method-level configuration for searchCategories.
|
|
3114
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3115
|
+
* @returns This service instance for method chaining
|
|
3116
|
+
*/
|
|
3117
|
+
setSearchCategoriesConfig(config) {
|
|
3118
|
+
this.searchCategoriesConfig = config;
|
|
3119
|
+
return this;
|
|
3120
|
+
}
|
|
3121
|
+
/**
|
|
3122
|
+
* Sets method-level configuration for brands.
|
|
3123
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3124
|
+
* @returns This service instance for method chaining
|
|
3125
|
+
*/
|
|
3126
|
+
setBrandsConfig(config) {
|
|
3127
|
+
this.brandsConfig = config;
|
|
3128
|
+
return this;
|
|
3129
|
+
}
|
|
3130
|
+
/**
|
|
3131
|
+
* Sets method-level configuration for listCategories.
|
|
3132
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3133
|
+
* @returns This service instance for method chaining
|
|
3134
|
+
*/
|
|
3135
|
+
setListCategoriesConfig(config) {
|
|
3136
|
+
this.listCategoriesConfig = config;
|
|
3137
|
+
return this;
|
|
3138
|
+
}
|
|
3139
|
+
/**
|
|
3140
|
+
*
|
|
3141
|
+
* @param {string} [params.id] -
|
|
3142
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3143
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3144
|
+
*/
|
|
3145
|
+
async productSearch(params, requestConfig) {
|
|
3146
|
+
const resolvedConfig = this.getResolvedConfig(this.productSearchConfig, requestConfig);
|
|
3147
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Catalog/Products/Search").setRequestSchema(import_zod18.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3148
|
+
schema: import_zod18.z.any(),
|
|
3149
|
+
contentType: "json" /* Json */,
|
|
3150
|
+
status: 200
|
|
3151
|
+
}).addQueryParam({
|
|
3152
|
+
key: "id",
|
|
3153
|
+
value: params == null ? void 0 : params.id
|
|
3154
|
+
}).build();
|
|
3155
|
+
return this.client.callDirect(request);
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
*
|
|
3159
|
+
* @param {string} [params.id] -
|
|
3160
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3161
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3162
|
+
*/
|
|
3163
|
+
async productDetails(params, requestConfig) {
|
|
3164
|
+
const resolvedConfig = this.getResolvedConfig(this.productDetailsConfig, requestConfig);
|
|
3165
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/Catalog/Products/Get").setRequestSchema(import_zod18.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3166
|
+
schema: import_zod18.z.any(),
|
|
3167
|
+
contentType: "json" /* Json */,
|
|
3168
|
+
status: 200
|
|
3169
|
+
}).addQueryParam({
|
|
3170
|
+
key: "id",
|
|
3171
|
+
value: params == null ? void 0 : params.id
|
|
3172
|
+
}).build();
|
|
3173
|
+
return this.client.callDirect(request);
|
|
3174
|
+
}
|
|
3175
|
+
/**
|
|
3176
|
+
*
|
|
3177
|
+
* @param {string} params.authorization -
|
|
3178
|
+
* @param {string} params.accept -
|
|
3179
|
+
* @param {string} params.userAgent -
|
|
3180
|
+
* @param {string} [params.pageIndex] -
|
|
3181
|
+
* @param {string} [params.pageSize] -
|
|
3182
|
+
* @param {string} [params.id] -
|
|
3183
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3184
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3185
|
+
*/
|
|
3186
|
+
async productsDatasource(body, params, requestConfig) {
|
|
3187
|
+
const resolvedConfig = this.getResolvedConfig(this.productsDatasourceConfig, requestConfig);
|
|
3188
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Catalog/Products/Datasource").setRequestSchema(productsDatasourceRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3189
|
+
schema: import_zod18.z.any(),
|
|
3190
|
+
contentType: "json" /* Json */,
|
|
3191
|
+
status: 200
|
|
3192
|
+
}).addQueryParam({
|
|
3193
|
+
key: "PageIndex",
|
|
3194
|
+
value: params == null ? void 0 : params.pageIndex
|
|
3195
|
+
}).addQueryParam({
|
|
3196
|
+
key: "PageSize",
|
|
3197
|
+
value: params == null ? void 0 : params.pageSize
|
|
3198
|
+
}).addQueryParam({
|
|
3199
|
+
key: "Id",
|
|
3200
|
+
value: params == null ? void 0 : params.id
|
|
3201
|
+
}).addHeaderParam({
|
|
3202
|
+
key: "Authorization",
|
|
3203
|
+
value: params == null ? void 0 : params.authorization
|
|
3204
|
+
}).addHeaderParam({
|
|
3205
|
+
key: "Accept",
|
|
3206
|
+
value: params == null ? void 0 : params.accept
|
|
3207
|
+
}).addHeaderParam({
|
|
3208
|
+
key: "User-Agent",
|
|
3209
|
+
value: params == null ? void 0 : params.userAgent
|
|
3210
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3211
|
+
return this.client.callDirect(request);
|
|
3212
|
+
}
|
|
3213
|
+
/**
|
|
3214
|
+
*
|
|
3215
|
+
* @param {string} params.accept -
|
|
3216
|
+
* @param {string} params.userAgent -
|
|
3217
|
+
* @param {string} [params.id] -
|
|
3218
|
+
* @param {string} [params.catalogId] -
|
|
3219
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3220
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3221
|
+
*/
|
|
3222
|
+
async searchCategories(params, requestConfig) {
|
|
3223
|
+
const resolvedConfig = this.getResolvedConfig(this.searchCategoriesConfig, requestConfig);
|
|
3224
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Catalog/Products/Category").setRequestSchema(import_zod18.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3225
|
+
schema: import_zod18.z.any(),
|
|
3226
|
+
contentType: "json" /* Json */,
|
|
3227
|
+
status: 200
|
|
3228
|
+
}).addQueryParam({
|
|
3229
|
+
key: "id",
|
|
3230
|
+
value: params == null ? void 0 : params.id
|
|
3231
|
+
}).addQueryParam({
|
|
3232
|
+
key: "catalogID",
|
|
3233
|
+
value: params == null ? void 0 : params.catalogId
|
|
3234
|
+
}).addHeaderParam({
|
|
3235
|
+
key: "Accept",
|
|
3236
|
+
value: params == null ? void 0 : params.accept
|
|
3237
|
+
}).addHeaderParam({
|
|
3238
|
+
key: "User-Agent",
|
|
3239
|
+
value: params == null ? void 0 : params.userAgent
|
|
3240
|
+
}).build();
|
|
3241
|
+
return this.client.callDirect(request);
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
*
|
|
3245
|
+
* @param {string} params.accept -
|
|
3246
|
+
* @param {string} params.userAgent -
|
|
3247
|
+
* @param {string} [params.id] -
|
|
3248
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3249
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3250
|
+
*/
|
|
3251
|
+
async brands(body, params, requestConfig) {
|
|
3252
|
+
const resolvedConfig = this.getResolvedConfig(this.brandsConfig, requestConfig);
|
|
3253
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Catalog/Products/Brand").setRequestSchema(brandsRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3254
|
+
schema: import_zod18.z.any(),
|
|
3255
|
+
contentType: "json" /* Json */,
|
|
3256
|
+
status: 200
|
|
3257
|
+
}).addQueryParam({
|
|
3258
|
+
key: "id",
|
|
3259
|
+
value: params == null ? void 0 : params.id
|
|
3260
|
+
}).addHeaderParam({
|
|
3261
|
+
key: "Accept",
|
|
3262
|
+
value: params == null ? void 0 : params.accept
|
|
3263
|
+
}).addHeaderParam({
|
|
3264
|
+
key: "User-Agent",
|
|
3265
|
+
value: params == null ? void 0 : params.userAgent
|
|
3266
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3267
|
+
return this.client.callDirect(request);
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
*
|
|
3271
|
+
* @param {string} params.userAgent -
|
|
3272
|
+
* @param {string} params.vary -
|
|
3273
|
+
* @param {string} params.accept -
|
|
3274
|
+
* @param {string} [params.template] -
|
|
3275
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3276
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3277
|
+
*/
|
|
3278
|
+
async listCategories(params, requestConfig) {
|
|
3279
|
+
const resolvedConfig = this.getResolvedConfig(this.listCategoriesConfig, requestConfig);
|
|
3280
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/widget/browsing_categorymenu").setRequestSchema(import_zod18.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3281
|
+
schema: import_zod18.z.any(),
|
|
3282
|
+
contentType: "json" /* Json */,
|
|
3283
|
+
status: 200
|
|
3284
|
+
}).addQueryParam({
|
|
3285
|
+
key: "template",
|
|
3286
|
+
value: params == null ? void 0 : params.template
|
|
3287
|
+
}).addHeaderParam({
|
|
3288
|
+
key: "User-Agent",
|
|
3289
|
+
value: params == null ? void 0 : params.userAgent
|
|
3290
|
+
}).addHeaderParam({
|
|
3291
|
+
key: "Vary",
|
|
3292
|
+
value: params == null ? void 0 : params.vary
|
|
3293
|
+
}).addHeaderParam({
|
|
3294
|
+
key: "Accept",
|
|
3295
|
+
value: params == null ? void 0 : params.accept
|
|
3296
|
+
}).build();
|
|
3297
|
+
return this.client.callDirect(request);
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3300
|
+
|
|
3301
|
+
// src/services/address/address-service.ts
|
|
3302
|
+
var import_zod19 = require("zod");
|
|
3303
|
+
var AddressService = class extends BaseService {
|
|
3304
|
+
constructor() {
|
|
3305
|
+
super(...arguments);
|
|
3306
|
+
this.addressListConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3307
|
+
this.registerAddressConfig = {
|
|
3308
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3309
|
+
};
|
|
3310
|
+
this.removeAddressConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3311
|
+
this.getAShippingQuote_Config = {
|
|
3312
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3313
|
+
};
|
|
3314
|
+
}
|
|
3315
|
+
/**
|
|
3316
|
+
* Sets method-level configuration for addressList.
|
|
3317
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3318
|
+
* @returns This service instance for method chaining
|
|
3319
|
+
*/
|
|
3320
|
+
setAddressListConfig(config) {
|
|
3321
|
+
this.addressListConfig = config;
|
|
3322
|
+
return this;
|
|
3323
|
+
}
|
|
3324
|
+
/**
|
|
3325
|
+
* Sets method-level configuration for registerAddress.
|
|
3326
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3327
|
+
* @returns This service instance for method chaining
|
|
3328
|
+
*/
|
|
3329
|
+
setRegisterAddressConfig(config) {
|
|
3330
|
+
this.registerAddressConfig = config;
|
|
3331
|
+
return this;
|
|
3332
|
+
}
|
|
3333
|
+
/**
|
|
3334
|
+
* Sets method-level configuration for removeAddress.
|
|
3335
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3336
|
+
* @returns This service instance for method chaining
|
|
3337
|
+
*/
|
|
3338
|
+
setRemoveAddressConfig(config) {
|
|
3339
|
+
this.removeAddressConfig = config;
|
|
3340
|
+
return this;
|
|
3341
|
+
}
|
|
3342
|
+
/**
|
|
3343
|
+
* Sets method-level configuration for getAShippingQuote_.
|
|
3344
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3345
|
+
* @returns This service instance for method chaining
|
|
3346
|
+
*/
|
|
3347
|
+
setGetAShippingQuote_Config(config) {
|
|
3348
|
+
this.getAShippingQuote_Config = config;
|
|
3349
|
+
return this;
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
*
|
|
3353
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3354
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3355
|
+
*/
|
|
3356
|
+
async addressList(body, requestConfig) {
|
|
3357
|
+
const resolvedConfig = this.getResolvedConfig(this.addressListConfig, requestConfig);
|
|
3358
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/AccountAddress/List").setRequestSchema(import_zod19.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3359
|
+
schema: import_zod19.z.any(),
|
|
3360
|
+
contentType: "json" /* Json */,
|
|
3361
|
+
status: 200
|
|
3362
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3363
|
+
return this.client.callDirect(request);
|
|
3364
|
+
}
|
|
3365
|
+
/**
|
|
3366
|
+
*
|
|
3367
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3368
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3369
|
+
*/
|
|
3370
|
+
async registerAddress(body, requestConfig) {
|
|
3371
|
+
const resolvedConfig = this.getResolvedConfig(this.registerAddressConfig, requestConfig);
|
|
3372
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/AccountAddress/Save").setRequestSchema(import_zod19.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3373
|
+
schema: import_zod19.z.any(),
|
|
3374
|
+
contentType: "json" /* Json */,
|
|
3375
|
+
status: 200
|
|
3376
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3377
|
+
return this.client.callDirect(request);
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
*
|
|
3381
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3382
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3383
|
+
*/
|
|
3384
|
+
async removeAddress(body, requestConfig) {
|
|
3385
|
+
const resolvedConfig = this.getResolvedConfig(this.removeAddressConfig, requestConfig);
|
|
3386
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/AccountAddress/Delete").setRequestSchema(import_zod19.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3387
|
+
schema: import_zod19.z.any(),
|
|
3388
|
+
contentType: "json" /* Json */,
|
|
3389
|
+
status: 200
|
|
3390
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3391
|
+
return this.client.callDirect(request);
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
*
|
|
3395
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3396
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3397
|
+
*/
|
|
3398
|
+
async getAShippingQuote_(body, requestConfig) {
|
|
3399
|
+
const resolvedConfig = this.getResolvedConfig(this.getAShippingQuote_Config, requestConfig);
|
|
3400
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Delivery/Get").setRequestSchema(import_zod19.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3401
|
+
schema: import_zod19.z.any(),
|
|
3402
|
+
contentType: "json" /* Json */,
|
|
3403
|
+
status: 200
|
|
3404
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3405
|
+
return this.client.callDirect(request);
|
|
3406
|
+
}
|
|
3407
|
+
};
|
|
3408
|
+
|
|
3409
|
+
// src/services/delivery/delivery-service.ts
|
|
3410
|
+
var import_zod20 = require("zod");
|
|
3411
|
+
var DeliveryService = class extends BaseService {
|
|
3412
|
+
constructor() {
|
|
3413
|
+
super(...arguments);
|
|
3414
|
+
this.defineDeliveryOptionConfig = {
|
|
3415
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3416
|
+
};
|
|
3417
|
+
this.loadPointsOfSaleConfig = {
|
|
3418
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3419
|
+
};
|
|
3420
|
+
this.carregarSellersConfig = { environment: "https://{{urlStore}}" /* URLSTORE */ };
|
|
3421
|
+
this.quoteViaTemplateConfig = { environment: "https://{{storeUrl}}" /* STOREURL */ };
|
|
3422
|
+
this.returnLocationIdConfig = { environment: "https://{{urlStore}}" /* URLSTORE */ };
|
|
3423
|
+
}
|
|
3424
|
+
/**
|
|
3425
|
+
* Sets method-level configuration for defineDeliveryOption.
|
|
3426
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3427
|
+
* @returns This service instance for method chaining
|
|
3428
|
+
*/
|
|
3429
|
+
setDefineDeliveryOptionConfig(config) {
|
|
3430
|
+
this.defineDeliveryOptionConfig = config;
|
|
3431
|
+
return this;
|
|
3432
|
+
}
|
|
3433
|
+
/**
|
|
3434
|
+
* Sets method-level configuration for loadPointsOfSale.
|
|
3435
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3436
|
+
* @returns This service instance for method chaining
|
|
3437
|
+
*/
|
|
3438
|
+
setLoadPointsOfSaleConfig(config) {
|
|
3439
|
+
this.loadPointsOfSaleConfig = config;
|
|
3440
|
+
return this;
|
|
3441
|
+
}
|
|
3442
|
+
/**
|
|
3443
|
+
* Sets method-level configuration for carregarSellers.
|
|
3444
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3445
|
+
* @returns This service instance for method chaining
|
|
3446
|
+
*/
|
|
3447
|
+
setCarregarSellersConfig(config) {
|
|
3448
|
+
this.carregarSellersConfig = config;
|
|
3449
|
+
return this;
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Sets method-level configuration for quoteViaTemplate.
|
|
3453
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3454
|
+
* @returns This service instance for method chaining
|
|
3455
|
+
*/
|
|
3456
|
+
setQuoteViaTemplateConfig(config) {
|
|
3457
|
+
this.quoteViaTemplateConfig = config;
|
|
3458
|
+
return this;
|
|
3459
|
+
}
|
|
3460
|
+
/**
|
|
3461
|
+
* Sets method-level configuration for returnLocationId.
|
|
3462
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3463
|
+
* @returns This service instance for method chaining
|
|
3464
|
+
*/
|
|
3465
|
+
setReturnLocationIdConfig(config) {
|
|
3466
|
+
this.returnLocationIdConfig = config;
|
|
3467
|
+
return this;
|
|
3468
|
+
}
|
|
3469
|
+
/**
|
|
3470
|
+
*
|
|
3471
|
+
* @param {string} params.accept -
|
|
3472
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3473
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3474
|
+
*/
|
|
3475
|
+
async defineDeliveryOption(body, params, requestConfig) {
|
|
3476
|
+
const resolvedConfig = this.getResolvedConfig(this.defineDeliveryOptionConfig, requestConfig);
|
|
3477
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/SetDeliveryOption").setRequestSchema(import_zod20.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3478
|
+
schema: import_zod20.z.any(),
|
|
3479
|
+
contentType: "json" /* Json */,
|
|
3480
|
+
status: 200
|
|
3481
|
+
}).addHeaderParam({
|
|
3482
|
+
key: "Accept",
|
|
3483
|
+
value: params == null ? void 0 : params.accept
|
|
3484
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3485
|
+
return this.client.callDirect(request);
|
|
3486
|
+
}
|
|
3487
|
+
/**
|
|
3488
|
+
*
|
|
3489
|
+
* @param {string} params.authorization -
|
|
3490
|
+
* @param {string} params.accept -
|
|
3491
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3492
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3493
|
+
*/
|
|
3494
|
+
async loadPointsOfSale(body, params, requestConfig) {
|
|
3495
|
+
const resolvedConfig = this.getResolvedConfig(this.loadPointsOfSaleConfig, requestConfig);
|
|
3496
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/Shopping/Seller/GetAvailablePointOfSales").setRequestSchema(import_zod20.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3497
|
+
schema: import_zod20.z.any(),
|
|
3498
|
+
contentType: "json" /* Json */,
|
|
3499
|
+
status: 200
|
|
3500
|
+
}).addHeaderParam({
|
|
3501
|
+
key: "Authorization",
|
|
3502
|
+
value: params == null ? void 0 : params.authorization
|
|
3503
|
+
}).addHeaderParam({
|
|
3504
|
+
key: "Accept",
|
|
3505
|
+
value: params == null ? void 0 : params.accept
|
|
3506
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3507
|
+
return this.client.callDirect(request);
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
*
|
|
3511
|
+
* @param {string} params.accept -
|
|
3512
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3513
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3514
|
+
*/
|
|
3515
|
+
async carregarSellers(body, params, requestConfig) {
|
|
3516
|
+
const resolvedConfig = this.getResolvedConfig(this.carregarSellersConfig, requestConfig);
|
|
3517
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/Shopping/Seller/GetAll").setRequestSchema(import_zod20.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3518
|
+
schema: import_zod20.z.any(),
|
|
3519
|
+
contentType: "json" /* Json */,
|
|
3520
|
+
status: 200
|
|
3521
|
+
}).addHeaderParam({
|
|
3522
|
+
key: "Accept",
|
|
3523
|
+
value: params == null ? void 0 : params.accept
|
|
3524
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3525
|
+
return this.client.callDirect(request);
|
|
3526
|
+
}
|
|
3527
|
+
/**
|
|
3528
|
+
*
|
|
3529
|
+
* @param {string} params.userAgent -
|
|
3530
|
+
* @param {string} params.accept -
|
|
3531
|
+
* @param {string} [params.productId] -
|
|
3532
|
+
* @param {string} [params.skuId] -
|
|
3533
|
+
* @param {string} [params.postalCode] -
|
|
3534
|
+
* @param {string} [params.template] -
|
|
3535
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3536
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3537
|
+
*/
|
|
3538
|
+
async quoteViaTemplate(params, requestConfig) {
|
|
3539
|
+
const resolvedConfig = this.getResolvedConfig(this.quoteViaTemplateConfig, requestConfig);
|
|
3540
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/widget/product_deliveryfee").setRequestSchema(import_zod20.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3541
|
+
schema: import_zod20.z.any(),
|
|
3542
|
+
contentType: "json" /* Json */,
|
|
3543
|
+
status: 200
|
|
3544
|
+
}).addQueryParam({
|
|
3545
|
+
key: "ProductID",
|
|
3546
|
+
value: params == null ? void 0 : params.productId
|
|
3547
|
+
}).addQueryParam({
|
|
3548
|
+
key: "SkuID",
|
|
3549
|
+
value: params == null ? void 0 : params.skuId
|
|
3550
|
+
}).addQueryParam({
|
|
3551
|
+
key: "PostalCode",
|
|
3552
|
+
value: params == null ? void 0 : params.postalCode
|
|
3553
|
+
}).addQueryParam({
|
|
3554
|
+
key: "Template",
|
|
3555
|
+
value: params == null ? void 0 : params.template
|
|
3556
|
+
}).addHeaderParam({
|
|
3557
|
+
key: "User-Agent",
|
|
3558
|
+
value: params == null ? void 0 : params.userAgent
|
|
3559
|
+
}).addHeaderParam({
|
|
3560
|
+
key: "Accept",
|
|
3561
|
+
value: params == null ? void 0 : params.accept
|
|
3562
|
+
}).build();
|
|
3563
|
+
return this.client.callDirect(request);
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
*
|
|
3567
|
+
* @param {string} params.userAgent -
|
|
3568
|
+
* @param {string} params.accept -
|
|
3569
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3570
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3571
|
+
*/
|
|
3572
|
+
async returnLocationId(params, requestConfig) {
|
|
3573
|
+
const resolvedConfig = this.getResolvedConfig(this.returnLocationIdConfig, requestConfig);
|
|
3574
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/onde-encontrar.json").setRequestSchema(import_zod20.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3575
|
+
schema: import_zod20.z.any(),
|
|
3576
|
+
contentType: "json" /* Json */,
|
|
3577
|
+
status: 200
|
|
3578
|
+
}).addHeaderParam({
|
|
3579
|
+
key: "User-Agent",
|
|
3580
|
+
value: params == null ? void 0 : params.userAgent
|
|
3581
|
+
}).addHeaderParam({
|
|
3582
|
+
key: "Accept",
|
|
3583
|
+
value: params == null ? void 0 : params.accept
|
|
3584
|
+
}).build();
|
|
3585
|
+
return this.client.callDirect(request);
|
|
3586
|
+
}
|
|
3587
|
+
};
|
|
3588
|
+
|
|
3589
|
+
// src/services/basket/basket-service.ts
|
|
3590
|
+
var import_zod21 = require("zod");
|
|
3591
|
+
var BasketService = class extends BaseService {
|
|
3592
|
+
constructor() {
|
|
3593
|
+
super(...arguments);
|
|
3594
|
+
this.recoverBasketConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3595
|
+
this.addProductToBasketConfig = {
|
|
3596
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3597
|
+
};
|
|
3598
|
+
this.addMetadataToBasketItemConfig = {
|
|
3599
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3600
|
+
};
|
|
3601
|
+
this.addCouponConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3602
|
+
this.removeCouponConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3603
|
+
this.addKitBasketConfig = { environment: "https://{{urlStore}}Shopping" /* URLSTORESHOPPING */ };
|
|
3604
|
+
this.adicionarServiOAdicionalConfig = {
|
|
3605
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3606
|
+
};
|
|
3607
|
+
this.removerItemDoCarrinhoConfig = {
|
|
3608
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3609
|
+
};
|
|
3610
|
+
this.removerTodosItemsDoCarrinhoConfig = {
|
|
3611
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3612
|
+
};
|
|
3613
|
+
this.defineCepDeEntregaConfig = {
|
|
3614
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3617
|
+
/**
|
|
3618
|
+
* Sets method-level configuration for recoverBasket.
|
|
3619
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3620
|
+
* @returns This service instance for method chaining
|
|
3621
|
+
*/
|
|
3622
|
+
setRecoverBasketConfig(config) {
|
|
3623
|
+
this.recoverBasketConfig = config;
|
|
3624
|
+
return this;
|
|
3625
|
+
}
|
|
3626
|
+
/**
|
|
3627
|
+
* Sets method-level configuration for addProductToBasket.
|
|
3628
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3629
|
+
* @returns This service instance for method chaining
|
|
3630
|
+
*/
|
|
3631
|
+
setAddProductToBasketConfig(config) {
|
|
3632
|
+
this.addProductToBasketConfig = config;
|
|
3633
|
+
return this;
|
|
3634
|
+
}
|
|
3635
|
+
/**
|
|
3636
|
+
* Sets method-level configuration for addMetadataToBasketItem.
|
|
3637
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3638
|
+
* @returns This service instance for method chaining
|
|
3639
|
+
*/
|
|
3640
|
+
setAddMetadataToBasketItemConfig(config) {
|
|
3641
|
+
this.addMetadataToBasketItemConfig = config;
|
|
3642
|
+
return this;
|
|
3643
|
+
}
|
|
3644
|
+
/**
|
|
3645
|
+
* Sets method-level configuration for addCoupon.
|
|
3646
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3647
|
+
* @returns This service instance for method chaining
|
|
3648
|
+
*/
|
|
3649
|
+
setAddCouponConfig(config) {
|
|
3650
|
+
this.addCouponConfig = config;
|
|
3651
|
+
return this;
|
|
3652
|
+
}
|
|
3653
|
+
/**
|
|
3654
|
+
* Sets method-level configuration for removeCoupon.
|
|
3655
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3656
|
+
* @returns This service instance for method chaining
|
|
3657
|
+
*/
|
|
3658
|
+
setRemoveCouponConfig(config) {
|
|
3659
|
+
this.removeCouponConfig = config;
|
|
3660
|
+
return this;
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* Sets method-level configuration for addKitBasket.
|
|
3664
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3665
|
+
* @returns This service instance for method chaining
|
|
3666
|
+
*/
|
|
3667
|
+
setAddKitBasketConfig(config) {
|
|
3668
|
+
this.addKitBasketConfig = config;
|
|
3669
|
+
return this;
|
|
3670
|
+
}
|
|
3671
|
+
/**
|
|
3672
|
+
* Sets method-level configuration for adicionarServiOAdicional.
|
|
3673
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3674
|
+
* @returns This service instance for method chaining
|
|
3675
|
+
*/
|
|
3676
|
+
setAdicionarServiOAdicionalConfig(config) {
|
|
3677
|
+
this.adicionarServiOAdicionalConfig = config;
|
|
3678
|
+
return this;
|
|
3679
|
+
}
|
|
3680
|
+
/**
|
|
3681
|
+
* Sets method-level configuration for removerItemDoCarrinho.
|
|
3682
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3683
|
+
* @returns This service instance for method chaining
|
|
3684
|
+
*/
|
|
3685
|
+
setRemoverItemDoCarrinhoConfig(config) {
|
|
3686
|
+
this.removerItemDoCarrinhoConfig = config;
|
|
3687
|
+
return this;
|
|
3688
|
+
}
|
|
3689
|
+
/**
|
|
3690
|
+
* Sets method-level configuration for removerTodosItemsDoCarrinho.
|
|
3691
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3692
|
+
* @returns This service instance for method chaining
|
|
3693
|
+
*/
|
|
3694
|
+
setRemoverTodosItemsDoCarrinhoConfig(config) {
|
|
3695
|
+
this.removerTodosItemsDoCarrinhoConfig = config;
|
|
3696
|
+
return this;
|
|
3697
|
+
}
|
|
3698
|
+
/**
|
|
3699
|
+
* Sets method-level configuration for defineCepDeEntrega.
|
|
3700
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3701
|
+
* @returns This service instance for method chaining
|
|
3702
|
+
*/
|
|
3703
|
+
setDefineCepDeEntregaConfig(config) {
|
|
3704
|
+
this.defineCepDeEntregaConfig = config;
|
|
3705
|
+
return this;
|
|
3706
|
+
}
|
|
3707
|
+
/**
|
|
3708
|
+
*
|
|
3709
|
+
* @param {string} params.authorization -
|
|
3710
|
+
* @param {string} params.accept -
|
|
3711
|
+
* @param {string} params.cacheControl -
|
|
3712
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3713
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3714
|
+
*/
|
|
3715
|
+
async recoverBasket(body, params, requestConfig) {
|
|
3716
|
+
const resolvedConfig = this.getResolvedConfig(this.recoverBasketConfig, requestConfig);
|
|
3717
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/Get").setRequestSchema(import_zod21.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3718
|
+
schema: import_zod21.z.any(),
|
|
3719
|
+
contentType: "json" /* Json */,
|
|
3720
|
+
status: 200
|
|
3721
|
+
}).addHeaderParam({
|
|
3722
|
+
key: "Authorization",
|
|
3723
|
+
value: params == null ? void 0 : params.authorization
|
|
3724
|
+
}).addHeaderParam({
|
|
3725
|
+
key: "Accept",
|
|
3726
|
+
value: params == null ? void 0 : params.accept
|
|
3727
|
+
}).addHeaderParam({
|
|
3728
|
+
key: "Cache-Control",
|
|
3729
|
+
value: params == null ? void 0 : params.cacheControl
|
|
3730
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3731
|
+
return this.client.callDirect(request);
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
*
|
|
3735
|
+
* @param {string} params.accept -
|
|
3736
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3737
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3738
|
+
*/
|
|
3739
|
+
async addProductToBasket(body, params, requestConfig) {
|
|
3740
|
+
const resolvedConfig = this.getResolvedConfig(this.addProductToBasketConfig, requestConfig);
|
|
3741
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/AddProduct").setRequestSchema(import_zod21.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3742
|
+
schema: import_zod21.z.any(),
|
|
3743
|
+
contentType: "json" /* Json */,
|
|
3744
|
+
status: 200
|
|
3745
|
+
}).addHeaderParam({
|
|
3746
|
+
key: "Accept",
|
|
3747
|
+
value: params == null ? void 0 : params.accept
|
|
3748
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3749
|
+
return this.client.callDirect(request);
|
|
3750
|
+
}
|
|
3751
|
+
/**
|
|
3752
|
+
*
|
|
3753
|
+
* @param {string} params.authorization -
|
|
3754
|
+
* @param {string} params.accept -
|
|
3755
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3756
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3757
|
+
*/
|
|
3758
|
+
async addMetadataToBasketItem(body, params, requestConfig) {
|
|
3759
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
3760
|
+
this.addMetadataToBasketItemConfig,
|
|
3761
|
+
requestConfig
|
|
3762
|
+
);
|
|
3763
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/AddCustomMetadata").setRequestSchema(import_zod21.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3764
|
+
schema: import_zod21.z.any(),
|
|
3765
|
+
contentType: "json" /* Json */,
|
|
3766
|
+
status: 200
|
|
3767
|
+
}).addHeaderParam({
|
|
3768
|
+
key: "Authorization",
|
|
3769
|
+
value: params == null ? void 0 : params.authorization
|
|
3770
|
+
}).addHeaderParam({
|
|
3771
|
+
key: "Accept",
|
|
3772
|
+
value: params == null ? void 0 : params.accept
|
|
3773
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3774
|
+
return this.client.callDirect(request);
|
|
3775
|
+
}
|
|
3776
|
+
/**
|
|
3777
|
+
*
|
|
3778
|
+
* @param {string} params.accept -
|
|
3779
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3780
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3781
|
+
*/
|
|
3782
|
+
async addCoupon(body, params, requestConfig) {
|
|
3783
|
+
const resolvedConfig = this.getResolvedConfig(this.addCouponConfig, requestConfig);
|
|
3784
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/AddCoupon").setRequestSchema(import_zod21.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3785
|
+
schema: import_zod21.z.any(),
|
|
3786
|
+
contentType: "json" /* Json */,
|
|
3787
|
+
status: 200
|
|
3788
|
+
}).addHeaderParam({
|
|
3789
|
+
key: "Accept",
|
|
3790
|
+
value: params == null ? void 0 : params.accept
|
|
3791
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3792
|
+
return this.client.callDirect(request);
|
|
3793
|
+
}
|
|
3794
|
+
/**
|
|
3795
|
+
*
|
|
3796
|
+
* @param {string} params.accept -
|
|
3797
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3798
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3799
|
+
*/
|
|
3800
|
+
async removeCoupon(body, params, requestConfig) {
|
|
3801
|
+
const resolvedConfig = this.getResolvedConfig(this.removeCouponConfig, requestConfig);
|
|
3802
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/RemoveCoupon").setRequestSchema(import_zod21.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3803
|
+
schema: import_zod21.z.any(),
|
|
3804
|
+
contentType: "json" /* Json */,
|
|
3805
|
+
status: 200
|
|
3806
|
+
}).addHeaderParam({
|
|
3807
|
+
key: "Accept",
|
|
3808
|
+
value: params == null ? void 0 : params.accept
|
|
3809
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3810
|
+
return this.client.callDirect(request);
|
|
3811
|
+
}
|
|
3812
|
+
/**
|
|
3813
|
+
*
|
|
3814
|
+
* @param {string} params.accept -
|
|
3815
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3816
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3817
|
+
*/
|
|
3818
|
+
async addKitBasket(body, params, requestConfig) {
|
|
3819
|
+
const resolvedConfig = this.getResolvedConfig(this.addKitBasketConfig, requestConfig);
|
|
3820
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Basket/AddProduct").setRequestSchema(import_zod21.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3821
|
+
schema: import_zod21.z.any(),
|
|
3822
|
+
contentType: "json" /* Json */,
|
|
3823
|
+
status: 200
|
|
3824
|
+
}).addHeaderParam({
|
|
3825
|
+
key: "Accept",
|
|
3826
|
+
value: params == null ? void 0 : params.accept
|
|
3827
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3828
|
+
return this.client.callDirect(request);
|
|
3829
|
+
}
|
|
3830
|
+
/**
|
|
3831
|
+
*
|
|
3832
|
+
* @param {string} params.accept -
|
|
3833
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3834
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3835
|
+
*/
|
|
3836
|
+
async adicionarServiOAdicional(body, params, requestConfig) {
|
|
3837
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
3838
|
+
this.adicionarServiOAdicionalConfig,
|
|
3839
|
+
requestConfig
|
|
3840
|
+
);
|
|
3841
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/AddProduct").setRequestSchema(import_zod21.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3842
|
+
schema: import_zod21.z.any(),
|
|
3843
|
+
contentType: "json" /* Json */,
|
|
3844
|
+
status: 200
|
|
3845
|
+
}).addHeaderParam({
|
|
3846
|
+
key: "Accept",
|
|
3847
|
+
value: params == null ? void 0 : params.accept
|
|
3848
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3849
|
+
return this.client.callDirect(request);
|
|
3850
|
+
}
|
|
3851
|
+
/**
|
|
3852
|
+
*
|
|
3853
|
+
* @param {string} params.accept -
|
|
3854
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3855
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3856
|
+
*/
|
|
3857
|
+
async removerItemDoCarrinho(body, params, requestConfig) {
|
|
3858
|
+
const resolvedConfig = this.getResolvedConfig(this.removerItemDoCarrinhoConfig, requestConfig);
|
|
3859
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/RemoveBasketItem").setRequestSchema(import_zod21.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
3860
|
+
schema: import_zod21.z.any(),
|
|
3861
|
+
contentType: "json" /* Json */,
|
|
3862
|
+
status: 200
|
|
3863
|
+
}).addHeaderParam({
|
|
3864
|
+
key: "Accept",
|
|
3865
|
+
value: params == null ? void 0 : params.accept
|
|
3866
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3867
|
+
return this.client.callDirect(request);
|
|
3868
|
+
}
|
|
3869
|
+
/**
|
|
3870
|
+
* StartFragment
|
|
3871
|
+
Simula a API do parceiro que retorna informações sobre promoções
|
|
3872
|
+
|
|
3873
|
+
EndFragment
|
|
3874
|
+
* @param {string} params.authorization -
|
|
3875
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3876
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3877
|
+
*/
|
|
3878
|
+
async removerTodosItemsDoCarrinho(body, params, requestConfig) {
|
|
3879
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
3880
|
+
this.removerTodosItemsDoCarrinhoConfig,
|
|
3881
|
+
requestConfig
|
|
3882
|
+
);
|
|
3883
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/RemoveAll").setRequestSchema(import_zod21.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3884
|
+
schema: import_zod21.z.any(),
|
|
3885
|
+
contentType: "json" /* Json */,
|
|
3886
|
+
status: 200
|
|
3887
|
+
}).addHeaderParam({
|
|
3888
|
+
key: "Authorization",
|
|
3889
|
+
value: params == null ? void 0 : params.authorization
|
|
3890
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3891
|
+
return this.client.callDirect(request);
|
|
3892
|
+
}
|
|
3893
|
+
/**
|
|
3894
|
+
*
|
|
3895
|
+
* @param {string} params.accept -
|
|
3896
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3897
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
3898
|
+
*/
|
|
3899
|
+
async defineCepDeEntrega(body, params, requestConfig) {
|
|
3900
|
+
const resolvedConfig = this.getResolvedConfig(this.defineCepDeEntregaConfig, requestConfig);
|
|
3901
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Basket/SetPostalCode").setRequestSchema(import_zod21.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
3902
|
+
schema: import_zod21.z.any(),
|
|
3903
|
+
contentType: "json" /* Json */,
|
|
3904
|
+
status: 200
|
|
3905
|
+
}).addHeaderParam({
|
|
3906
|
+
key: "Accept",
|
|
3907
|
+
value: params == null ? void 0 : params.accept
|
|
3908
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3909
|
+
return this.client.callDirect(request);
|
|
3910
|
+
}
|
|
3911
|
+
};
|
|
3912
|
+
|
|
3913
|
+
// src/services/checkout/checkout-service.ts
|
|
3914
|
+
var import_zod23 = require("zod");
|
|
3915
|
+
|
|
3916
|
+
// src/services/checkout/models/retorna-op-o-de-entrega-para-oms-request.ts
|
|
3917
|
+
var import_zod22 = require("zod");
|
|
3918
|
+
var retornaOpODeEntregaParaOmsRequest = import_zod22.z.lazy(() => {
|
|
3919
|
+
return import_zod22.z.object({
|
|
3920
|
+
groupKey: import_zod22.z.string().optional().nullable(),
|
|
3921
|
+
basketId: import_zod22.z.string().optional().nullable(),
|
|
3922
|
+
customerId: import_zod22.z.string().optional().nullable(),
|
|
3923
|
+
sessionId: import_zod22.z.string().optional().nullable(),
|
|
3924
|
+
shopperTicketId: import_zod22.z.string().optional().nullable(),
|
|
3925
|
+
basketAuthorityToken: import_zod22.z.string().optional().nullable()
|
|
3926
|
+
});
|
|
3927
|
+
});
|
|
3928
|
+
var retornaOpODeEntregaParaOmsRequestResponse = import_zod22.z.lazy(() => {
|
|
3929
|
+
return import_zod22.z.object({
|
|
3930
|
+
GroupKey: import_zod22.z.string().optional().nullable(),
|
|
3931
|
+
BasketID: import_zod22.z.string().optional().nullable(),
|
|
3932
|
+
CustomerID: import_zod22.z.string().optional().nullable(),
|
|
3933
|
+
SessionID: import_zod22.z.string().optional().nullable(),
|
|
3934
|
+
ShopperTicketID: import_zod22.z.string().optional().nullable(),
|
|
3935
|
+
BasketAuthorityToken: import_zod22.z.string().optional().nullable()
|
|
3936
|
+
}).transform((data) => ({
|
|
3937
|
+
groupKey: data["GroupKey"],
|
|
3938
|
+
basketId: data["BasketID"],
|
|
3939
|
+
customerId: data["CustomerID"],
|
|
3940
|
+
sessionId: data["SessionID"],
|
|
3941
|
+
shopperTicketId: data["ShopperTicketID"],
|
|
3942
|
+
basketAuthorityToken: data["BasketAuthorityToken"]
|
|
3943
|
+
}));
|
|
3944
|
+
});
|
|
3945
|
+
var retornaOpODeEntregaParaOmsRequestRequest = import_zod22.z.lazy(() => {
|
|
3946
|
+
return import_zod22.z.object({
|
|
3947
|
+
groupKey: import_zod22.z.string().optional().nullable(),
|
|
3948
|
+
basketId: import_zod22.z.string().optional().nullable(),
|
|
3949
|
+
customerId: import_zod22.z.string().optional().nullable(),
|
|
3950
|
+
sessionId: import_zod22.z.string().optional().nullable(),
|
|
3951
|
+
shopperTicketId: import_zod22.z.string().optional().nullable(),
|
|
3952
|
+
basketAuthorityToken: import_zod22.z.string().optional().nullable()
|
|
3953
|
+
}).transform((data) => ({
|
|
3954
|
+
GroupKey: data["groupKey"],
|
|
3955
|
+
BasketID: data["basketId"],
|
|
3956
|
+
CustomerID: data["customerId"],
|
|
3957
|
+
SessionID: data["sessionId"],
|
|
3958
|
+
ShopperTicketID: data["shopperTicketId"],
|
|
3959
|
+
BasketAuthorityToken: data["basketAuthorityToken"]
|
|
3960
|
+
}));
|
|
3961
|
+
});
|
|
3962
|
+
|
|
3963
|
+
// src/services/checkout/checkout-service.ts
|
|
3964
|
+
var CheckoutService = class extends BaseService {
|
|
3965
|
+
constructor() {
|
|
3966
|
+
super(...arguments);
|
|
3967
|
+
this.recuperaCheckoutConfig = {
|
|
3968
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3969
|
+
};
|
|
3970
|
+
this.selecionaEndereODeEntregaConfig = {
|
|
3971
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3972
|
+
};
|
|
3973
|
+
this.setPostalCodeConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
3974
|
+
this.setaMTodoDeEntregaLocationIdConfig = {
|
|
3975
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3976
|
+
};
|
|
3977
|
+
this.setaMTodoDeEntregaConfig = {
|
|
3978
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3979
|
+
};
|
|
3980
|
+
this.retornaOpODeEntregaParaOmsConfig = {
|
|
3981
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3982
|
+
};
|
|
3983
|
+
this.gruposDePagamentoConfig = {
|
|
3984
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3985
|
+
};
|
|
3986
|
+
this.adicioneCupomNoCheckoutConfig = {
|
|
3987
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3988
|
+
};
|
|
3989
|
+
this.removeCupomNoCheckoutConfig = {
|
|
3990
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3991
|
+
};
|
|
3992
|
+
this.realizaPedidoDeVendaPixConfig = {
|
|
3993
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3994
|
+
};
|
|
3995
|
+
this.realizaPedidoDeVendaCardConfig = {
|
|
3996
|
+
environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
/**
|
|
4000
|
+
* Sets method-level configuration for recuperaCheckout.
|
|
4001
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4002
|
+
* @returns This service instance for method chaining
|
|
4003
|
+
*/
|
|
4004
|
+
setRecuperaCheckoutConfig(config) {
|
|
4005
|
+
this.recuperaCheckoutConfig = config;
|
|
4006
|
+
return this;
|
|
4007
|
+
}
|
|
4008
|
+
/**
|
|
4009
|
+
* Sets method-level configuration for selecionaEndereODeEntrega.
|
|
4010
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4011
|
+
* @returns This service instance for method chaining
|
|
4012
|
+
*/
|
|
4013
|
+
setSelecionaEndereODeEntregaConfig(config) {
|
|
4014
|
+
this.selecionaEndereODeEntregaConfig = config;
|
|
4015
|
+
return this;
|
|
4016
|
+
}
|
|
4017
|
+
/**
|
|
4018
|
+
* Sets method-level configuration for setPostalCode.
|
|
4019
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4020
|
+
* @returns This service instance for method chaining
|
|
4021
|
+
*/
|
|
4022
|
+
setSetPostalCodeConfig(config) {
|
|
4023
|
+
this.setPostalCodeConfig = config;
|
|
4024
|
+
return this;
|
|
4025
|
+
}
|
|
4026
|
+
/**
|
|
4027
|
+
* Sets method-level configuration for setaMTodoDeEntregaLocationId.
|
|
4028
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4029
|
+
* @returns This service instance for method chaining
|
|
4030
|
+
*/
|
|
4031
|
+
setSetaMTodoDeEntregaLocationIdConfig(config) {
|
|
4032
|
+
this.setaMTodoDeEntregaLocationIdConfig = config;
|
|
4033
|
+
return this;
|
|
4034
|
+
}
|
|
4035
|
+
/**
|
|
4036
|
+
* Sets method-level configuration for setaMTodoDeEntrega.
|
|
4037
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4038
|
+
* @returns This service instance for method chaining
|
|
4039
|
+
*/
|
|
4040
|
+
setSetaMTodoDeEntregaConfig(config) {
|
|
4041
|
+
this.setaMTodoDeEntregaConfig = config;
|
|
4042
|
+
return this;
|
|
4043
|
+
}
|
|
4044
|
+
/**
|
|
4045
|
+
* Sets method-level configuration for retornaOpODeEntregaParaOms.
|
|
4046
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4047
|
+
* @returns This service instance for method chaining
|
|
4048
|
+
*/
|
|
4049
|
+
setRetornaOpODeEntregaParaOmsConfig(config) {
|
|
4050
|
+
this.retornaOpODeEntregaParaOmsConfig = config;
|
|
4051
|
+
return this;
|
|
4052
|
+
}
|
|
4053
|
+
/**
|
|
4054
|
+
* Sets method-level configuration for gruposDePagamento.
|
|
4055
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4056
|
+
* @returns This service instance for method chaining
|
|
4057
|
+
*/
|
|
4058
|
+
setGruposDePagamentoConfig(config) {
|
|
4059
|
+
this.gruposDePagamentoConfig = config;
|
|
4060
|
+
return this;
|
|
4061
|
+
}
|
|
4062
|
+
/**
|
|
4063
|
+
* Sets method-level configuration for adicioneCupomNoCheckout.
|
|
4064
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4065
|
+
* @returns This service instance for method chaining
|
|
4066
|
+
*/
|
|
4067
|
+
setAdicioneCupomNoCheckoutConfig(config) {
|
|
4068
|
+
this.adicioneCupomNoCheckoutConfig = config;
|
|
4069
|
+
return this;
|
|
4070
|
+
}
|
|
4071
|
+
/**
|
|
4072
|
+
* Sets method-level configuration for removeCupomNoCheckout.
|
|
4073
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4074
|
+
* @returns This service instance for method chaining
|
|
4075
|
+
*/
|
|
4076
|
+
setRemoveCupomNoCheckoutConfig(config) {
|
|
4077
|
+
this.removeCupomNoCheckoutConfig = config;
|
|
4078
|
+
return this;
|
|
4079
|
+
}
|
|
4080
|
+
/**
|
|
4081
|
+
* Sets method-level configuration for realizaPedidoDeVendaPix.
|
|
4082
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4083
|
+
* @returns This service instance for method chaining
|
|
4084
|
+
*/
|
|
4085
|
+
setRealizaPedidoDeVendaPixConfig(config) {
|
|
4086
|
+
this.realizaPedidoDeVendaPixConfig = config;
|
|
4087
|
+
return this;
|
|
4088
|
+
}
|
|
4089
|
+
/**
|
|
4090
|
+
* Sets method-level configuration for realizaPedidoDeVendaCard.
|
|
4091
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4092
|
+
* @returns This service instance for method chaining
|
|
4093
|
+
*/
|
|
4094
|
+
setRealizaPedidoDeVendaCardConfig(config) {
|
|
4095
|
+
this.realizaPedidoDeVendaCardConfig = config;
|
|
4096
|
+
return this;
|
|
4097
|
+
}
|
|
4098
|
+
/**
|
|
4099
|
+
*
|
|
4100
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4101
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4102
|
+
*/
|
|
4103
|
+
async recuperaCheckout(body, requestConfig) {
|
|
4104
|
+
const resolvedConfig = this.getResolvedConfig(this.recuperaCheckoutConfig, requestConfig);
|
|
4105
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/Get").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4106
|
+
schema: import_zod23.z.any(),
|
|
4107
|
+
contentType: "json" /* Json */,
|
|
4108
|
+
status: 200
|
|
4109
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4110
|
+
return this.client.callDirect(request);
|
|
4111
|
+
}
|
|
4112
|
+
/**
|
|
4113
|
+
*
|
|
4114
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4115
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4116
|
+
*/
|
|
4117
|
+
async selecionaEndereODeEntrega(body, requestConfig) {
|
|
4118
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4119
|
+
this.selecionaEndereODeEntregaConfig,
|
|
4120
|
+
requestConfig
|
|
4121
|
+
);
|
|
4122
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/SetAddress").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4123
|
+
schema: import_zod23.z.any(),
|
|
4124
|
+
contentType: "json" /* Json */,
|
|
4125
|
+
status: 200
|
|
4126
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4127
|
+
return this.client.callDirect(request);
|
|
4128
|
+
}
|
|
4129
|
+
/**
|
|
4130
|
+
*
|
|
4131
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4132
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4133
|
+
*/
|
|
4134
|
+
async setPostalCode(body, requestConfig) {
|
|
4135
|
+
const resolvedConfig = this.getResolvedConfig(this.setPostalCodeConfig, requestConfig);
|
|
4136
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/SetAddress").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4137
|
+
schema: import_zod23.z.any(),
|
|
4138
|
+
contentType: "json" /* Json */,
|
|
4139
|
+
status: 200
|
|
4140
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4141
|
+
return this.client.callDirect(request);
|
|
4142
|
+
}
|
|
4143
|
+
/**
|
|
4144
|
+
*
|
|
4145
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4146
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4147
|
+
*/
|
|
4148
|
+
async setaMTodoDeEntregaLocationId(body, requestConfig) {
|
|
4149
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4150
|
+
this.setaMTodoDeEntregaLocationIdConfig,
|
|
4151
|
+
requestConfig
|
|
4152
|
+
);
|
|
4153
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/SetDeliveryOption").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4154
|
+
schema: import_zod23.z.any(),
|
|
4155
|
+
contentType: "json" /* Json */,
|
|
4156
|
+
status: 200
|
|
4157
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4158
|
+
return this.client.callDirect(request);
|
|
4159
|
+
}
|
|
4160
|
+
/**
|
|
4161
|
+
*
|
|
4162
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4163
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4164
|
+
*/
|
|
4165
|
+
async setaMTodoDeEntrega(body, requestConfig) {
|
|
4166
|
+
const resolvedConfig = this.getResolvedConfig(this.setaMTodoDeEntregaConfig, requestConfig);
|
|
4167
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/SetDeliveryOption").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4168
|
+
schema: import_zod23.z.any(),
|
|
4169
|
+
contentType: "json" /* Json */,
|
|
4170
|
+
status: 200
|
|
4171
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4172
|
+
return this.client.callDirect(request);
|
|
4173
|
+
}
|
|
4174
|
+
/**
|
|
4175
|
+
*
|
|
4176
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4177
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4178
|
+
*/
|
|
4179
|
+
async retornaOpODeEntregaParaOms(body, requestConfig) {
|
|
4180
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4181
|
+
this.retornaOpODeEntregaParaOmsConfig,
|
|
4182
|
+
requestConfig
|
|
4183
|
+
);
|
|
4184
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/GetOMSLocations").setRequestSchema(retornaOpODeEntregaParaOmsRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4185
|
+
schema: import_zod23.z.any(),
|
|
4186
|
+
contentType: "json" /* Json */,
|
|
4187
|
+
status: 200
|
|
4188
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4189
|
+
return this.client.callDirect(request);
|
|
4190
|
+
}
|
|
4191
|
+
/**
|
|
4192
|
+
*
|
|
4193
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4194
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4195
|
+
*/
|
|
4196
|
+
async gruposDePagamento(body, requestConfig) {
|
|
4197
|
+
const resolvedConfig = this.getResolvedConfig(this.gruposDePagamentoConfig, requestConfig);
|
|
4198
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/PaymentGroups").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4199
|
+
schema: import_zod23.z.any(),
|
|
4200
|
+
contentType: "json" /* Json */,
|
|
4201
|
+
status: 200
|
|
4202
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4203
|
+
return this.client.callDirect(request);
|
|
4204
|
+
}
|
|
4205
|
+
/**
|
|
4206
|
+
*
|
|
4207
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4208
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4209
|
+
*/
|
|
4210
|
+
async adicioneCupomNoCheckout(body, requestConfig) {
|
|
4211
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4212
|
+
this.adicioneCupomNoCheckoutConfig,
|
|
4213
|
+
requestConfig
|
|
4214
|
+
);
|
|
4215
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/AddCoupon").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4216
|
+
schema: import_zod23.z.any(),
|
|
4217
|
+
contentType: "json" /* Json */,
|
|
4218
|
+
status: 200
|
|
4219
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4220
|
+
return this.client.callDirect(request);
|
|
4221
|
+
}
|
|
4222
|
+
/**
|
|
4223
|
+
*
|
|
4224
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4225
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4226
|
+
*/
|
|
4227
|
+
async removeCupomNoCheckout(body, requestConfig) {
|
|
4228
|
+
const resolvedConfig = this.getResolvedConfig(this.removeCupomNoCheckoutConfig, requestConfig);
|
|
4229
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/RemoveCoupon").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4230
|
+
schema: import_zod23.z.any(),
|
|
4231
|
+
contentType: "json" /* Json */,
|
|
4232
|
+
status: 200
|
|
4233
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4234
|
+
return this.client.callDirect(request);
|
|
4235
|
+
}
|
|
4236
|
+
/**
|
|
4237
|
+
*
|
|
4238
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4239
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4240
|
+
*/
|
|
4241
|
+
async realizaPedidoDeVendaPix(body, requestConfig) {
|
|
4242
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4243
|
+
this.realizaPedidoDeVendaPixConfig,
|
|
4244
|
+
requestConfig
|
|
4245
|
+
);
|
|
4246
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/PlaceOrder").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4247
|
+
schema: import_zod23.z.any(),
|
|
4248
|
+
contentType: "json" /* Json */,
|
|
4249
|
+
status: 200
|
|
4250
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4251
|
+
return this.client.callDirect(request);
|
|
4252
|
+
}
|
|
4253
|
+
/**
|
|
4254
|
+
*
|
|
4255
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4256
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4257
|
+
*/
|
|
4258
|
+
async realizaPedidoDeVendaCard(body, requestConfig) {
|
|
4259
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4260
|
+
this.realizaPedidoDeVendaCardConfig,
|
|
4261
|
+
requestConfig
|
|
4262
|
+
);
|
|
4263
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Shopping/Checkout/PlaceOrder").setRequestSchema(import_zod23.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4264
|
+
schema: import_zod23.z.any(),
|
|
4265
|
+
contentType: "json" /* Json */,
|
|
4266
|
+
status: 200
|
|
4267
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4268
|
+
return this.client.callDirect(request);
|
|
4269
|
+
}
|
|
4270
|
+
};
|
|
4271
|
+
|
|
4272
|
+
// src/services/orders/orders-service.ts
|
|
4273
|
+
var import_zod26 = require("zod");
|
|
4274
|
+
|
|
4275
|
+
// src/services/orders/models/details-order-request.ts
|
|
4276
|
+
var import_zod24 = require("zod");
|
|
4277
|
+
var detailsOrderRequest = import_zod24.z.lazy(() => {
|
|
4278
|
+
return import_zod24.z.object({
|
|
4279
|
+
sessionId: import_zod24.z.string().optional().nullable(),
|
|
4280
|
+
orderNumber: import_zod24.z.string().optional().nullable(),
|
|
4281
|
+
customerId: import_zod24.z.number().optional().nullable()
|
|
4282
|
+
});
|
|
4283
|
+
});
|
|
4284
|
+
var detailsOrderRequestResponse = import_zod24.z.lazy(() => {
|
|
4285
|
+
return import_zod24.z.object({
|
|
4286
|
+
SessionID: import_zod24.z.string().optional().nullable(),
|
|
4287
|
+
OrderNumber: import_zod24.z.string().optional().nullable(),
|
|
4288
|
+
CustomerID: import_zod24.z.number().optional().nullable()
|
|
4289
|
+
}).transform((data) => ({
|
|
4290
|
+
sessionId: data["SessionID"],
|
|
4291
|
+
orderNumber: data["OrderNumber"],
|
|
4292
|
+
customerId: data["CustomerID"]
|
|
4293
|
+
}));
|
|
4294
|
+
});
|
|
4295
|
+
var detailsOrderRequestRequest = import_zod24.z.lazy(() => {
|
|
4296
|
+
return import_zod24.z.object({
|
|
4297
|
+
sessionId: import_zod24.z.string().optional().nullable(),
|
|
4298
|
+
orderNumber: import_zod24.z.string().optional().nullable(),
|
|
4299
|
+
customerId: import_zod24.z.number().optional().nullable()
|
|
4300
|
+
}).transform((data) => ({
|
|
4301
|
+
SessionID: data["sessionId"],
|
|
4302
|
+
OrderNumber: data["orderNumber"],
|
|
4303
|
+
CustomerID: data["customerId"]
|
|
4304
|
+
}));
|
|
4305
|
+
});
|
|
4306
|
+
|
|
4307
|
+
// src/services/orders/models/account-order-request.ts
|
|
4308
|
+
var import_zod25 = require("zod");
|
|
4309
|
+
var accountOrderRequest = import_zod25.z.lazy(() => {
|
|
4310
|
+
return import_zod25.z.object({
|
|
4311
|
+
sessionId: import_zod25.z.string().optional().nullable(),
|
|
4312
|
+
pageSize: import_zod25.z.number().optional().nullable(),
|
|
4313
|
+
pageIndex: import_zod25.z.number().optional().nullable(),
|
|
4314
|
+
customerId: import_zod25.z.number().optional().nullable()
|
|
4315
|
+
});
|
|
4316
|
+
});
|
|
4317
|
+
var accountOrderRequestResponse = import_zod25.z.lazy(() => {
|
|
4318
|
+
return import_zod25.z.object({
|
|
4319
|
+
SessionID: import_zod25.z.string().optional().nullable(),
|
|
4320
|
+
PageSize: import_zod25.z.number().optional().nullable(),
|
|
4321
|
+
PageIndex: import_zod25.z.number().optional().nullable(),
|
|
4322
|
+
CustomerID: import_zod25.z.number().optional().nullable()
|
|
4323
|
+
}).transform((data) => ({
|
|
4324
|
+
sessionId: data["SessionID"],
|
|
4325
|
+
pageSize: data["PageSize"],
|
|
4326
|
+
pageIndex: data["PageIndex"],
|
|
4327
|
+
customerId: data["CustomerID"]
|
|
4328
|
+
}));
|
|
4329
|
+
});
|
|
4330
|
+
var accountOrderRequestRequest = import_zod25.z.lazy(() => {
|
|
4331
|
+
return import_zod25.z.object({
|
|
4332
|
+
sessionId: import_zod25.z.string().optional().nullable(),
|
|
4333
|
+
pageSize: import_zod25.z.number().optional().nullable(),
|
|
4334
|
+
pageIndex: import_zod25.z.number().optional().nullable(),
|
|
4335
|
+
customerId: import_zod25.z.number().optional().nullable()
|
|
4336
|
+
}).transform((data) => ({
|
|
4337
|
+
SessionID: data["sessionId"],
|
|
4338
|
+
PageSize: data["pageSize"],
|
|
4339
|
+
PageIndex: data["pageIndex"],
|
|
4340
|
+
CustomerID: data["customerId"]
|
|
4341
|
+
}));
|
|
4342
|
+
});
|
|
4343
|
+
|
|
4344
|
+
// src/services/orders/orders-service.ts
|
|
4345
|
+
var OrdersService = class extends BaseService {
|
|
4346
|
+
constructor() {
|
|
4347
|
+
super(...arguments);
|
|
4348
|
+
this.orderListConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
4349
|
+
this.detailsOrderConfig = { environment: "https://{{apiLinxcommerce}}" /* APILINXCOMMERCE */ };
|
|
4350
|
+
this.accountOrderConfig = { environment: "https://{{urlLinx}}" /* URLLINX */ };
|
|
4351
|
+
}
|
|
4352
|
+
/**
|
|
4353
|
+
* Sets method-level configuration for orderList.
|
|
4354
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4355
|
+
* @returns This service instance for method chaining
|
|
4356
|
+
*/
|
|
4357
|
+
setOrderListConfig(config) {
|
|
4358
|
+
this.orderListConfig = config;
|
|
4359
|
+
return this;
|
|
4360
|
+
}
|
|
4361
|
+
/**
|
|
4362
|
+
* Sets method-level configuration for detailsOrder.
|
|
4363
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4364
|
+
* @returns This service instance for method chaining
|
|
4365
|
+
*/
|
|
4366
|
+
setDetailsOrderConfig(config) {
|
|
4367
|
+
this.detailsOrderConfig = config;
|
|
4368
|
+
return this;
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* Sets method-level configuration for accountOrder.
|
|
4372
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4373
|
+
* @returns This service instance for method chaining
|
|
4374
|
+
*/
|
|
4375
|
+
setAccountOrderConfig(config) {
|
|
4376
|
+
this.accountOrderConfig = config;
|
|
4377
|
+
return this;
|
|
4378
|
+
}
|
|
4379
|
+
/**
|
|
4380
|
+
*
|
|
4381
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4382
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4383
|
+
*/
|
|
4384
|
+
async orderList(body, requestConfig) {
|
|
4385
|
+
const resolvedConfig = this.getResolvedConfig(this.orderListConfig, requestConfig);
|
|
4386
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/AccountOrder/List").setRequestSchema(import_zod26.z.any()).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4387
|
+
schema: import_zod26.z.any(),
|
|
4388
|
+
contentType: "json" /* Json */,
|
|
4389
|
+
status: 200
|
|
4390
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4391
|
+
return this.client.callDirect(request);
|
|
4392
|
+
}
|
|
4393
|
+
/**
|
|
4394
|
+
*
|
|
4395
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4396
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4397
|
+
*/
|
|
4398
|
+
async detailsOrder(body, requestConfig) {
|
|
4399
|
+
const resolvedConfig = this.getResolvedConfig(this.detailsOrderConfig, requestConfig);
|
|
4400
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/AccountOrder/Get").setRequestSchema(detailsOrderRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4401
|
+
schema: import_zod26.z.any(),
|
|
4402
|
+
contentType: "json" /* Json */,
|
|
4403
|
+
status: 200
|
|
4404
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4405
|
+
return this.client.callDirect(request);
|
|
4406
|
+
}
|
|
4407
|
+
/**
|
|
4408
|
+
*
|
|
4409
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4410
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4411
|
+
*/
|
|
4412
|
+
async accountOrder(body, requestConfig) {
|
|
4413
|
+
const resolvedConfig = this.getResolvedConfig(this.accountOrderConfig, requestConfig);
|
|
4414
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/Profile/AccountOrder/List").setRequestSchema(accountOrderRequestRequest).addBasicAuth(resolvedConfig == null ? void 0 : resolvedConfig.username, resolvedConfig == null ? void 0 : resolvedConfig.password).setRequestContentType("json" /* Json */).addResponse({
|
|
4415
|
+
schema: import_zod26.z.any(),
|
|
4416
|
+
contentType: "json" /* Json */,
|
|
4417
|
+
status: 200
|
|
4418
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
4419
|
+
return this.client.callDirect(request);
|
|
4420
|
+
}
|
|
4421
|
+
};
|
|
4422
|
+
|
|
4423
|
+
// src/services/ws/ws-service.ts
|
|
4424
|
+
var import_zod27 = require("zod");
|
|
4425
|
+
var WsService = class extends BaseService {
|
|
4426
|
+
constructor() {
|
|
4427
|
+
super(...arguments);
|
|
4428
|
+
this.viaccepConfig = { environment: "https://viacep.com.br" /* VIACEP */ };
|
|
4429
|
+
}
|
|
4430
|
+
/**
|
|
4431
|
+
* Sets method-level configuration for viaccep.
|
|
4432
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4433
|
+
* @returns This service instance for method chaining
|
|
4434
|
+
*/
|
|
4435
|
+
setViaccepConfig(config) {
|
|
4436
|
+
this.viaccepConfig = config;
|
|
4437
|
+
return this;
|
|
4438
|
+
}
|
|
4439
|
+
/**
|
|
4440
|
+
*
|
|
4441
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4442
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4443
|
+
*/
|
|
4444
|
+
async viaccep(requestConfig) {
|
|
4445
|
+
const resolvedConfig = this.getResolvedConfig(this.viaccepConfig, requestConfig);
|
|
4446
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/ws/PR/Cascavel/Domingos+Jose/json/").setRequestSchema(import_zod27.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
4447
|
+
schema: import_zod27.z.any(),
|
|
4448
|
+
contentType: "json" /* Json */,
|
|
4449
|
+
status: 200
|
|
4450
|
+
}).build();
|
|
4451
|
+
return this.client.callDirect(request);
|
|
4452
|
+
}
|
|
4453
|
+
};
|
|
4454
|
+
|
|
4455
|
+
// src/services/widget/widget-service.ts
|
|
4456
|
+
var import_zod28 = require("zod");
|
|
4457
|
+
var WidgetService = class extends BaseService {
|
|
4458
|
+
constructor() {
|
|
4459
|
+
super(...arguments);
|
|
4460
|
+
this.getBannerConfig = { environment: "https://{{storeUrl}}" /* STOREURL */ };
|
|
4461
|
+
}
|
|
4462
|
+
/**
|
|
4463
|
+
* Sets method-level configuration for getBanner.
|
|
4464
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4465
|
+
* @returns This service instance for method chaining
|
|
4466
|
+
*/
|
|
4467
|
+
setGetBannerConfig(config) {
|
|
4468
|
+
this.getBannerConfig = config;
|
|
4469
|
+
return this;
|
|
4470
|
+
}
|
|
4471
|
+
/**
|
|
4472
|
+
*
|
|
4473
|
+
* @param {string} params.userAgent -
|
|
4474
|
+
* @param {string} params.accept -
|
|
4475
|
+
* @param {string} [params.positionId] -
|
|
4476
|
+
* @param {string} [params.template] -
|
|
4477
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4478
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4479
|
+
*/
|
|
4480
|
+
async getBanner(params, requestConfig) {
|
|
4481
|
+
const resolvedConfig = this.getResolvedConfig(this.getBannerConfig, requestConfig);
|
|
4482
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/widget/marketing_banner").setRequestSchema(import_zod28.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
4483
|
+
schema: import_zod28.z.any(),
|
|
4484
|
+
contentType: "json" /* Json */,
|
|
4485
|
+
status: 200
|
|
4486
|
+
}).addQueryParam({
|
|
4487
|
+
key: "PositionId",
|
|
4488
|
+
value: params == null ? void 0 : params.positionId
|
|
4489
|
+
}).addQueryParam({
|
|
4490
|
+
key: "template",
|
|
4491
|
+
value: params == null ? void 0 : params.template
|
|
4492
|
+
}).addHeaderParam({
|
|
4493
|
+
key: "User-Agent",
|
|
4494
|
+
value: params == null ? void 0 : params.userAgent
|
|
4495
|
+
}).addHeaderParam({
|
|
4496
|
+
key: "Accept",
|
|
4497
|
+
value: params == null ? void 0 : params.accept
|
|
4498
|
+
}).build();
|
|
4499
|
+
return this.client.callDirect(request);
|
|
4500
|
+
}
|
|
4501
|
+
};
|
|
4502
|
+
|
|
4503
|
+
// src/services/onde-encontrar-json/onde-encontrar-json-service.ts
|
|
4504
|
+
var import_zod29 = require("zod");
|
|
4505
|
+
var OndeEncontrarJsonService = class extends BaseService {
|
|
4506
|
+
constructor() {
|
|
4507
|
+
super(...arguments);
|
|
4508
|
+
this.ondeEncontrarNossasLojasConfig = {
|
|
4509
|
+
environment: "https://{{storeUrl}}" /* STOREURL */
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
/**
|
|
4513
|
+
* Sets method-level configuration for ondeEncontrarNossasLojas.
|
|
4514
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4515
|
+
* @returns This service instance for method chaining
|
|
4516
|
+
*/
|
|
4517
|
+
setOndeEncontrarNossasLojasConfig(config) {
|
|
4518
|
+
this.ondeEncontrarNossasLojasConfig = config;
|
|
4519
|
+
return this;
|
|
4520
|
+
}
|
|
4521
|
+
/**
|
|
4522
|
+
*
|
|
4523
|
+
* @param {string} params.userAgent -
|
|
4524
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
4525
|
+
* @returns {Promise<HttpResponse<any>>} - OK
|
|
4526
|
+
*/
|
|
4527
|
+
async ondeEncontrarNossasLojas(params, requestConfig) {
|
|
4528
|
+
const resolvedConfig = this.getResolvedConfig(
|
|
4529
|
+
this.ondeEncontrarNossasLojasConfig,
|
|
4530
|
+
requestConfig
|
|
4531
|
+
);
|
|
4532
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/onde-encontrar.json").setRequestSchema(import_zod29.z.any()).setRequestContentType("json" /* Json */).addResponse({
|
|
4533
|
+
schema: import_zod29.z.any(),
|
|
4534
|
+
contentType: "json" /* Json */,
|
|
4535
|
+
status: 200
|
|
4536
|
+
}).addHeaderParam({
|
|
4537
|
+
key: "User-Agent",
|
|
4538
|
+
value: params == null ? void 0 : params.userAgent
|
|
4539
|
+
}).build();
|
|
4540
|
+
return this.client.callDirect(request);
|
|
4541
|
+
}
|
|
4542
|
+
};
|
|
4543
|
+
|
|
4544
|
+
// src/index.ts
|
|
4545
|
+
var LinxcommerceWebapiSdk = class {
|
|
4546
|
+
constructor(config) {
|
|
4547
|
+
this.config = config;
|
|
4548
|
+
this.customers = new CustomersService(this.config);
|
|
4549
|
+
this.products = new ProductsService(this.config);
|
|
4550
|
+
this.address = new AddressService(this.config);
|
|
4551
|
+
this.delivery = new DeliveryService(this.config);
|
|
4552
|
+
this.basket = new BasketService(this.config);
|
|
4553
|
+
this.checkout = new CheckoutService(this.config);
|
|
4554
|
+
this.orders = new OrdersService(this.config);
|
|
4555
|
+
this.ws = new WsService(this.config);
|
|
4556
|
+
this.widget = new WidgetService(this.config);
|
|
4557
|
+
this.ondeEncontrarJson = new OndeEncontrarJsonService(this.config);
|
|
4558
|
+
}
|
|
4559
|
+
set baseUrl(baseUrl) {
|
|
4560
|
+
this.customers.baseUrl = baseUrl;
|
|
4561
|
+
this.products.baseUrl = baseUrl;
|
|
4562
|
+
this.address.baseUrl = baseUrl;
|
|
4563
|
+
this.delivery.baseUrl = baseUrl;
|
|
4564
|
+
this.basket.baseUrl = baseUrl;
|
|
4565
|
+
this.checkout.baseUrl = baseUrl;
|
|
4566
|
+
this.orders.baseUrl = baseUrl;
|
|
4567
|
+
this.ws.baseUrl = baseUrl;
|
|
4568
|
+
this.widget.baseUrl = baseUrl;
|
|
4569
|
+
this.ondeEncontrarJson.baseUrl = baseUrl;
|
|
4570
|
+
}
|
|
4571
|
+
set environment(environment) {
|
|
4572
|
+
this.customers.baseUrl = environment;
|
|
4573
|
+
this.products.baseUrl = environment;
|
|
4574
|
+
this.address.baseUrl = environment;
|
|
4575
|
+
this.delivery.baseUrl = environment;
|
|
4576
|
+
this.basket.baseUrl = environment;
|
|
4577
|
+
this.checkout.baseUrl = environment;
|
|
4578
|
+
this.orders.baseUrl = environment;
|
|
4579
|
+
this.ws.baseUrl = environment;
|
|
4580
|
+
this.widget.baseUrl = environment;
|
|
4581
|
+
this.ondeEncontrarJson.baseUrl = environment;
|
|
4582
|
+
}
|
|
4583
|
+
set timeoutMs(timeoutMs) {
|
|
4584
|
+
this.customers.timeoutMs = timeoutMs;
|
|
4585
|
+
this.products.timeoutMs = timeoutMs;
|
|
4586
|
+
this.address.timeoutMs = timeoutMs;
|
|
4587
|
+
this.delivery.timeoutMs = timeoutMs;
|
|
4588
|
+
this.basket.timeoutMs = timeoutMs;
|
|
4589
|
+
this.checkout.timeoutMs = timeoutMs;
|
|
4590
|
+
this.orders.timeoutMs = timeoutMs;
|
|
4591
|
+
this.ws.timeoutMs = timeoutMs;
|
|
4592
|
+
this.widget.timeoutMs = timeoutMs;
|
|
4593
|
+
this.ondeEncontrarJson.timeoutMs = timeoutMs;
|
|
4594
|
+
}
|
|
4595
|
+
set username(username) {
|
|
4596
|
+
this.customers.username = username;
|
|
4597
|
+
this.products.username = username;
|
|
4598
|
+
this.address.username = username;
|
|
4599
|
+
this.delivery.username = username;
|
|
4600
|
+
this.basket.username = username;
|
|
4601
|
+
this.checkout.username = username;
|
|
4602
|
+
this.orders.username = username;
|
|
4603
|
+
this.ws.username = username;
|
|
4604
|
+
this.widget.username = username;
|
|
4605
|
+
this.ondeEncontrarJson.username = username;
|
|
4606
|
+
}
|
|
4607
|
+
set password(password) {
|
|
4608
|
+
this.customers.password = password;
|
|
4609
|
+
this.products.password = password;
|
|
4610
|
+
this.address.password = password;
|
|
4611
|
+
this.delivery.password = password;
|
|
4612
|
+
this.basket.password = password;
|
|
4613
|
+
this.checkout.password = password;
|
|
4614
|
+
this.orders.password = password;
|
|
4615
|
+
this.ws.password = password;
|
|
4616
|
+
this.widget.password = password;
|
|
4617
|
+
this.ondeEncontrarJson.password = password;
|
|
4618
|
+
}
|
|
4619
|
+
};
|
|
4620
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
4621
|
+
0 && (module.exports = {
|
|
4622
|
+
AddressService,
|
|
4623
|
+
BasketService,
|
|
4624
|
+
CheckoutService,
|
|
4625
|
+
CustomersService,
|
|
4626
|
+
DeliveryService,
|
|
4627
|
+
Environment,
|
|
4628
|
+
LinxcommerceWebapiSdk,
|
|
4629
|
+
OndeEncontrarJsonService,
|
|
4630
|
+
OrdersService,
|
|
4631
|
+
ProductsService,
|
|
4632
|
+
WidgetService,
|
|
4633
|
+
WsService
|
|
4634
|
+
});
|