@shopickup/adapters-mpl 0.0.1
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 +43 -0
- package/dist/capabilities/auth.d.ts +39 -0
- package/dist/capabilities/auth.d.ts.map +1 -0
- package/dist/capabilities/auth.js +130 -0
- package/dist/capabilities/close.d.ts +8 -0
- package/dist/capabilities/close.d.ts.map +1 -0
- package/dist/capabilities/close.js +70 -0
- package/dist/capabilities/get-shipment-details.d.ts +63 -0
- package/dist/capabilities/get-shipment-details.d.ts.map +1 -0
- package/dist/capabilities/get-shipment-details.js +97 -0
- package/dist/capabilities/index.d.ts +10 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +9 -0
- package/dist/capabilities/label.d.ts +33 -0
- package/dist/capabilities/label.d.ts.map +1 -0
- package/dist/capabilities/label.js +328 -0
- package/dist/capabilities/parcels.d.ts +33 -0
- package/dist/capabilities/parcels.d.ts.map +1 -0
- package/dist/capabilities/parcels.js +284 -0
- package/dist/capabilities/pickup-points.d.ts +41 -0
- package/dist/capabilities/pickup-points.d.ts.map +1 -0
- package/dist/capabilities/pickup-points.js +294 -0
- package/dist/capabilities/track.d.ts +72 -0
- package/dist/capabilities/track.d.ts.map +1 -0
- package/dist/capabilities/track.js +331 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +142 -0
- package/dist/mappers/label.d.ts +67 -0
- package/dist/mappers/label.d.ts.map +1 -0
- package/dist/mappers/label.js +83 -0
- package/dist/mappers/shipment.d.ts +110 -0
- package/dist/mappers/shipment.d.ts.map +1 -0
- package/dist/mappers/shipment.js +258 -0
- package/dist/mappers/tracking.d.ts +60 -0
- package/dist/mappers/tracking.d.ts.map +1 -0
- package/dist/mappers/tracking.js +187 -0
- package/dist/utils/httpUtils.d.ts +36 -0
- package/dist/utils/httpUtils.d.ts.map +1 -0
- package/dist/utils/httpUtils.js +76 -0
- package/dist/utils/oauthFallback.d.ts +47 -0
- package/dist/utils/oauthFallback.d.ts.map +1 -0
- package/dist/utils/oauthFallback.js +250 -0
- package/dist/utils/resolveBaseUrl.d.ts +75 -0
- package/dist/utils/resolveBaseUrl.d.ts.map +1 -0
- package/dist/utils/resolveBaseUrl.js +65 -0
- package/dist/validation.d.ts +1890 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +726 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveBaseUrl.d.ts","sourceRoot":"","sources":["../../src/utils/resolveBaseUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,IACnE,OAAO;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,MAAM,CAGjD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,IACtE,OAAO;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,MAAM,CAGjD;AAGD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,IACvF,OAAO;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,MAAM,CAGjD;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory that creates a resolver function bound to production and test base URLs.
|
|
3
|
+
*
|
|
4
|
+
* This removes duplication of base URL strings across capability files while keeping
|
|
5
|
+
* per-call decision logic explicit and testable.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const resolveBaseUrl = createResolveBaseUrl(prodUrl, testUrl);
|
|
9
|
+
* const url = resolveBaseUrl(req.options); // returns test or prod based on useTestApi flag
|
|
10
|
+
*
|
|
11
|
+
* @param prodBaseUrl Production API base URL
|
|
12
|
+
* @param testBaseUrl Test/sandbox API base URL
|
|
13
|
+
* @returns A pure resolver function that accepts request options and returns the appropriate URL
|
|
14
|
+
*/
|
|
15
|
+
export function createResolveBaseUrl(prodBaseUrl, testBaseUrl) {
|
|
16
|
+
return (opts) => {
|
|
17
|
+
return opts?.useTestApi ? testBaseUrl : prodBaseUrl;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Factory that creates a resolver function for OAuth2 token endpoints.
|
|
22
|
+
*
|
|
23
|
+
* MPL OAuth2 endpoints are separate from the main API:
|
|
24
|
+
* - Production: https://core.api.posta.hu/oauth2/token
|
|
25
|
+
* - Test/Sandbox: https://sandbox.api.posta.hu/oauth2/token
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* const resolveOAuthUrl = createResolveOAuthUrl(
|
|
29
|
+
* 'https://core.api.posta.hu/oauth2/token',
|
|
30
|
+
* 'https://sandbox.api.posta.hu/oauth2/token'
|
|
31
|
+
* );
|
|
32
|
+
* const url = resolveOAuthUrl(req.options); // returns test or prod endpoint
|
|
33
|
+
*
|
|
34
|
+
* @param prodOAuthUrl Production OAuth2 token endpoint
|
|
35
|
+
* @param testOAuthUrl Test/sandbox OAuth2 token endpoint
|
|
36
|
+
* @returns A pure resolver function that accepts request options and returns the appropriate OAuth URL
|
|
37
|
+
*/
|
|
38
|
+
export function createResolveOAuthUrl(prodOAuthUrl, testOAuthUrl) {
|
|
39
|
+
return (opts) => {
|
|
40
|
+
return opts?.useTestApi ? testOAuthUrl : prodOAuthUrl;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Factory that creates a resolver function for tracking endpoints.
|
|
45
|
+
*
|
|
46
|
+
* MPL tracking endpoints are separate from the main API:
|
|
47
|
+
* - Production: https://core.api.posta.hu/nyomkovetes
|
|
48
|
+
* - Test/Sandbox: https://sandbox.api.posta.hu/nyomkovetes
|
|
49
|
+
*
|
|
50
|
+
* Usage:
|
|
51
|
+
* const resolveTrackingUrl = createResolveTrackingUrl(
|
|
52
|
+
* 'https://core.api.posta.hu/nyomkovetes',
|
|
53
|
+
* 'https://sandbox.api.posta.hu/nyomkovetes'
|
|
54
|
+
* );
|
|
55
|
+
* const url = resolveTrackingUrl(req.options); // returns test or prod endpoint
|
|
56
|
+
*
|
|
57
|
+
* @param prodTrackingBaseUrl Production tracking API base URL
|
|
58
|
+
* @param testTrackingBaseUrl Test/sandbox tracking API base URL
|
|
59
|
+
* @returns A pure resolver function that accepts request options and returns the appropriate tracking URL
|
|
60
|
+
*/
|
|
61
|
+
export function createResolveTrackingUrl(prodTrackingBaseUrl, testTrackingBaseUrl) {
|
|
62
|
+
return (opts) => {
|
|
63
|
+
return opts?.useTestApi ? testTrackingBaseUrl : prodTrackingBaseUrl;
|
|
64
|
+
};
|
|
65
|
+
}
|