@jazzdev/dpd-local-sdk 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -5
- package/dist/index.mjs +14 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -420,7 +420,7 @@ declare function generateConsignmentRef(orderId: string): string;
|
|
|
420
420
|
declare function createCompleteShipment(orderId: string, params: Omit<CreateShipmentParams, 'orderId'>, config: DPDModuleConfig, dbAdapter: DatabaseAdapter, storageAdapter: StorageAdapter): Promise<CreateShipmentResult & {
|
|
421
421
|
labelUrl?: string;
|
|
422
422
|
}>;
|
|
423
|
-
declare function generateAndUploadLabel(shipmentId: string | number,
|
|
423
|
+
declare function generateAndUploadLabel(shipmentId: string | number, labelFormat: 'zpl' | 'clp' | 'epl' | 'html', credentials: DPDCredentials, storageAdapter: StorageAdapter): Promise<GenerateLabelResult>;
|
|
424
424
|
declare function validateDeliveryAddress(params: ValidateAddressParams, credentials: DPDCredentials): Promise<ValidateAddressResult>;
|
|
425
425
|
declare function saveAddress(userId: string, address: Omit<SavedAddress, 'id' | 'userId' | 'createdAt' | 'updatedAt'>, credentials: DPDCredentials, dbAdapter: DatabaseAdapter): Promise<string>;
|
|
426
426
|
declare function getSavedAddresses(userId: string, dbAdapter: DatabaseAdapter): Promise<SavedAddress[]>;
|
|
@@ -428,7 +428,7 @@ declare function getSavedAddress(addressId: string, dbAdapter: DatabaseAdapter):
|
|
|
428
428
|
declare function updateSavedAddress(addressId: string, data: Partial<SavedAddress>, dbAdapter: DatabaseAdapter): Promise<void>;
|
|
429
429
|
declare function deleteSavedAddress(addressId: string, dbAdapter: DatabaseAdapter): Promise<void>;
|
|
430
430
|
declare function getLabelUrl(consignmentNumber: string, storageAdapter: StorageAdapter): Promise<string | null>;
|
|
431
|
-
declare function regenerateLabel(shipmentId: string | number,
|
|
431
|
+
declare function regenerateLabel(shipmentId: string | number, labelFormat: 'zpl' | 'clp' | 'epl' | 'html', credentials: DPDCredentials, storageAdapter: StorageAdapter): Promise<GenerateLabelResult>;
|
|
432
432
|
declare function testDPDConnection(credentials: DPDCredentials): Promise<{
|
|
433
433
|
success: boolean;
|
|
434
434
|
message: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -420,7 +420,7 @@ declare function generateConsignmentRef(orderId: string): string;
|
|
|
420
420
|
declare function createCompleteShipment(orderId: string, params: Omit<CreateShipmentParams, 'orderId'>, config: DPDModuleConfig, dbAdapter: DatabaseAdapter, storageAdapter: StorageAdapter): Promise<CreateShipmentResult & {
|
|
421
421
|
labelUrl?: string;
|
|
422
422
|
}>;
|
|
423
|
-
declare function generateAndUploadLabel(shipmentId: string | number,
|
|
423
|
+
declare function generateAndUploadLabel(shipmentId: string | number, labelFormat: 'zpl' | 'clp' | 'epl' | 'html', credentials: DPDCredentials, storageAdapter: StorageAdapter): Promise<GenerateLabelResult>;
|
|
424
424
|
declare function validateDeliveryAddress(params: ValidateAddressParams, credentials: DPDCredentials): Promise<ValidateAddressResult>;
|
|
425
425
|
declare function saveAddress(userId: string, address: Omit<SavedAddress, 'id' | 'userId' | 'createdAt' | 'updatedAt'>, credentials: DPDCredentials, dbAdapter: DatabaseAdapter): Promise<string>;
|
|
426
426
|
declare function getSavedAddresses(userId: string, dbAdapter: DatabaseAdapter): Promise<SavedAddress[]>;
|
|
@@ -428,7 +428,7 @@ declare function getSavedAddress(addressId: string, dbAdapter: DatabaseAdapter):
|
|
|
428
428
|
declare function updateSavedAddress(addressId: string, data: Partial<SavedAddress>, dbAdapter: DatabaseAdapter): Promise<void>;
|
|
429
429
|
declare function deleteSavedAddress(addressId: string, dbAdapter: DatabaseAdapter): Promise<void>;
|
|
430
430
|
declare function getLabelUrl(consignmentNumber: string, storageAdapter: StorageAdapter): Promise<string | null>;
|
|
431
|
-
declare function regenerateLabel(shipmentId: string | number,
|
|
431
|
+
declare function regenerateLabel(shipmentId: string | number, labelFormat: 'zpl' | 'clp' | 'epl' | 'html', credentials: DPDCredentials, storageAdapter: StorageAdapter): Promise<GenerateLabelResult>;
|
|
432
432
|
declare function testDPDConnection(credentials: DPDCredentials): Promise<{
|
|
433
433
|
success: boolean;
|
|
434
434
|
message: string;
|
package/dist/index.js
CHANGED
|
@@ -324,6 +324,10 @@ async function authenticatedRequest(credentials, options) {
|
|
|
324
324
|
const isLabelRequest = acceptHeader === "text/vnd.zebra-zpl" || acceptHeader === "text/vnd.citizen-clp" || acceptHeader === "text/vnd.eltron-epl" || acceptHeader === "text/html";
|
|
325
325
|
let data = null;
|
|
326
326
|
if (isLabelRequest) {
|
|
327
|
+
console.log("\u{1F3F7}\uFE0F [SDK auth] Label request detected");
|
|
328
|
+
console.log(` HTTP Status: ${response.status} ${response.statusText}`);
|
|
329
|
+
console.log(` Response length: ${raw.length} chars`);
|
|
330
|
+
console.log(` Response preview (first 300 chars): ${raw.substring(0, 300)}`);
|
|
327
331
|
if (!response.ok) {
|
|
328
332
|
throw new Error(
|
|
329
333
|
`Label request failed: ${response.status} ${response.statusText}`
|
|
@@ -331,7 +335,13 @@ async function authenticatedRequest(credentials, options) {
|
|
|
331
335
|
}
|
|
332
336
|
try {
|
|
333
337
|
const parsed = JSON.parse(raw);
|
|
338
|
+
console.log("\u{1F50D} [SDK auth] Label request - parsed JSON response:", parsed);
|
|
334
339
|
if (parsed?.error || parsed?.data === null) {
|
|
340
|
+
console.log("\u26A0\uFE0F [SDK auth] Detected error response:", {
|
|
341
|
+
hasError: !!parsed?.error,
|
|
342
|
+
dataIsNull: parsed?.data === null,
|
|
343
|
+
errorObj: parsed?.error
|
|
344
|
+
});
|
|
335
345
|
const errorObj = parsed?.error;
|
|
336
346
|
let errorMessage = "Label generation failed";
|
|
337
347
|
let errorCode = "UNKNOWN";
|
|
@@ -349,6 +359,7 @@ async function authenticatedRequest(credentials, options) {
|
|
|
349
359
|
}
|
|
350
360
|
}
|
|
351
361
|
}
|
|
362
|
+
console.error(`\u274C [SDK auth] Throwing error - Code: ${errorCode}, Message: ${errorMessage}`);
|
|
352
363
|
throw new Error(`DPD API Error ${errorCode}: ${errorMessage}`);
|
|
353
364
|
}
|
|
354
365
|
if (parsed?.data) {
|
|
@@ -749,7 +760,6 @@ async function createCompleteShipment(orderId, params, config2, dbAdapter, stora
|
|
|
749
760
|
}
|
|
750
761
|
const labelResult = await generateAndUploadLabel(
|
|
751
762
|
shipmentResult.shipmentId,
|
|
752
|
-
shipmentResult.consignmentNumber,
|
|
753
763
|
"zpl",
|
|
754
764
|
config2.credentials,
|
|
755
765
|
storageAdapter
|
|
@@ -836,7 +846,7 @@ async function createCompleteShipment(orderId, params, config2, dbAdapter, stora
|
|
|
836
846
|
};
|
|
837
847
|
}
|
|
838
848
|
}
|
|
839
|
-
async function generateAndUploadLabel(shipmentId,
|
|
849
|
+
async function generateAndUploadLabel(shipmentId, labelFormat, credentials, storageAdapter) {
|
|
840
850
|
try {
|
|
841
851
|
const labelResult = await generateLabel(credentials, {
|
|
842
852
|
shipmentId,
|
|
@@ -847,7 +857,7 @@ async function generateAndUploadLabel(shipmentId, consignmentNumber, labelFormat
|
|
|
847
857
|
}
|
|
848
858
|
const timestamp = Date.now();
|
|
849
859
|
const extension = labelFormat === "html" ? "html" : "txt";
|
|
850
|
-
const fileName = `${
|
|
860
|
+
const fileName = `${shipmentId}-${timestamp}.${extension}`;
|
|
851
861
|
const labelUrl = await storageAdapter.uploadLabel(
|
|
852
862
|
labelResult.labelData,
|
|
853
863
|
fileName
|
|
@@ -904,10 +914,9 @@ async function getLabelUrl(consignmentNumber, storageAdapter) {
|
|
|
904
914
|
return null;
|
|
905
915
|
}
|
|
906
916
|
}
|
|
907
|
-
async function regenerateLabel(shipmentId,
|
|
917
|
+
async function regenerateLabel(shipmentId, labelFormat, credentials, storageAdapter) {
|
|
908
918
|
return await generateAndUploadLabel(
|
|
909
919
|
shipmentId,
|
|
910
|
-
consignmentNumber,
|
|
911
920
|
labelFormat,
|
|
912
921
|
credentials,
|
|
913
922
|
storageAdapter
|
package/dist/index.mjs
CHANGED
|
@@ -236,6 +236,10 @@ async function authenticatedRequest(credentials, options) {
|
|
|
236
236
|
const isLabelRequest = acceptHeader === "text/vnd.zebra-zpl" || acceptHeader === "text/vnd.citizen-clp" || acceptHeader === "text/vnd.eltron-epl" || acceptHeader === "text/html";
|
|
237
237
|
let data = null;
|
|
238
238
|
if (isLabelRequest) {
|
|
239
|
+
console.log("\u{1F3F7}\uFE0F [SDK auth] Label request detected");
|
|
240
|
+
console.log(` HTTP Status: ${response.status} ${response.statusText}`);
|
|
241
|
+
console.log(` Response length: ${raw.length} chars`);
|
|
242
|
+
console.log(` Response preview (first 300 chars): ${raw.substring(0, 300)}`);
|
|
239
243
|
if (!response.ok) {
|
|
240
244
|
throw new Error(
|
|
241
245
|
`Label request failed: ${response.status} ${response.statusText}`
|
|
@@ -243,7 +247,13 @@ async function authenticatedRequest(credentials, options) {
|
|
|
243
247
|
}
|
|
244
248
|
try {
|
|
245
249
|
const parsed = JSON.parse(raw);
|
|
250
|
+
console.log("\u{1F50D} [SDK auth] Label request - parsed JSON response:", parsed);
|
|
246
251
|
if (parsed?.error || parsed?.data === null) {
|
|
252
|
+
console.log("\u26A0\uFE0F [SDK auth] Detected error response:", {
|
|
253
|
+
hasError: !!parsed?.error,
|
|
254
|
+
dataIsNull: parsed?.data === null,
|
|
255
|
+
errorObj: parsed?.error
|
|
256
|
+
});
|
|
247
257
|
const errorObj = parsed?.error;
|
|
248
258
|
let errorMessage = "Label generation failed";
|
|
249
259
|
let errorCode = "UNKNOWN";
|
|
@@ -261,6 +271,7 @@ async function authenticatedRequest(credentials, options) {
|
|
|
261
271
|
}
|
|
262
272
|
}
|
|
263
273
|
}
|
|
274
|
+
console.error(`\u274C [SDK auth] Throwing error - Code: ${errorCode}, Message: ${errorMessage}`);
|
|
264
275
|
throw new Error(`DPD API Error ${errorCode}: ${errorMessage}`);
|
|
265
276
|
}
|
|
266
277
|
if (parsed?.data) {
|
|
@@ -661,7 +672,6 @@ async function createCompleteShipment(orderId, params, config2, dbAdapter, stora
|
|
|
661
672
|
}
|
|
662
673
|
const labelResult = await generateAndUploadLabel(
|
|
663
674
|
shipmentResult.shipmentId,
|
|
664
|
-
shipmentResult.consignmentNumber,
|
|
665
675
|
"zpl",
|
|
666
676
|
config2.credentials,
|
|
667
677
|
storageAdapter
|
|
@@ -748,7 +758,7 @@ async function createCompleteShipment(orderId, params, config2, dbAdapter, stora
|
|
|
748
758
|
};
|
|
749
759
|
}
|
|
750
760
|
}
|
|
751
|
-
async function generateAndUploadLabel(shipmentId,
|
|
761
|
+
async function generateAndUploadLabel(shipmentId, labelFormat, credentials, storageAdapter) {
|
|
752
762
|
try {
|
|
753
763
|
const labelResult = await generateLabel(credentials, {
|
|
754
764
|
shipmentId,
|
|
@@ -759,7 +769,7 @@ async function generateAndUploadLabel(shipmentId, consignmentNumber, labelFormat
|
|
|
759
769
|
}
|
|
760
770
|
const timestamp = Date.now();
|
|
761
771
|
const extension = labelFormat === "html" ? "html" : "txt";
|
|
762
|
-
const fileName = `${
|
|
772
|
+
const fileName = `${shipmentId}-${timestamp}.${extension}`;
|
|
763
773
|
const labelUrl = await storageAdapter.uploadLabel(
|
|
764
774
|
labelResult.labelData,
|
|
765
775
|
fileName
|
|
@@ -816,10 +826,9 @@ async function getLabelUrl(consignmentNumber, storageAdapter) {
|
|
|
816
826
|
return null;
|
|
817
827
|
}
|
|
818
828
|
}
|
|
819
|
-
async function regenerateLabel(shipmentId,
|
|
829
|
+
async function regenerateLabel(shipmentId, labelFormat, credentials, storageAdapter) {
|
|
820
830
|
return await generateAndUploadLabel(
|
|
821
831
|
shipmentId,
|
|
822
|
-
consignmentNumber,
|
|
823
832
|
labelFormat,
|
|
824
833
|
credentials,
|
|
825
834
|
storageAdapter
|
package/package.json
CHANGED