@myparcel-dev/sdk 4.1.1 → 5.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.
Files changed (65) hide show
  1. package/README.md +2 -2
  2. package/lib/createMyParcelSdk.d.ts +8 -4
  3. package/lib/createPrivateSdk.d.ts +5 -4
  4. package/lib/createPublicSdk.d.ts +5 -4
  5. package/lib/endpoints/private/account-messages/DeleteAccountMessage.d.ts +3 -2
  6. package/lib/endpoints/private/account-messages/GetAccountMessages.d.ts +3 -2
  7. package/lib/endpoints/private/accounts/Account.types.d.ts +5 -4
  8. package/lib/endpoints/private/accounts/GetAccount.d.ts +3 -2
  9. package/lib/endpoints/private/accounts/GetAccounts.d.ts +3 -2
  10. package/lib/endpoints/private/accounts/PutAccount.d.ts +4 -3
  11. package/lib/endpoints/private/api-key/GetApiKeys.d.ts +3 -2
  12. package/lib/endpoints/private/api-key/PostApiKeys.d.ts +4 -3
  13. package/lib/endpoints/private/carrier-options/CarrierOption.types.d.ts +3 -2
  14. package/lib/endpoints/private/carrier-options/DeleteCarrierOptions.d.ts +3 -2
  15. package/lib/endpoints/private/carrier-options/GetCarrierOptions.d.ts +3 -2
  16. package/lib/endpoints/private/carrier-options/PostCarrierOptions.d.ts +4 -3
  17. package/lib/endpoints/private/carrier-options/PutCarrierOptions.d.ts +4 -3
  18. package/lib/endpoints/private/locations/GetLocations.d.ts +3 -2
  19. package/lib/endpoints/private/shipments/GetShipment.d.ts +3 -2
  20. package/lib/endpoints/private/shipments/GetShipments.d.ts +4 -3
  21. package/lib/endpoints/private/shipments/PostShipments.d.ts +4 -3
  22. package/lib/endpoints/private/shipments/Shipment.types.d.ts +4 -4
  23. package/lib/endpoints/private/shops/GetShop.d.ts +3 -2
  24. package/lib/endpoints/private/shops/PostShop.d.ts +4 -3
  25. package/lib/endpoints/private/shops/PostShopDuplicate.d.ts +4 -3
  26. package/lib/endpoints/private/shops/PutShop.d.ts +4 -3
  27. package/lib/endpoints/private/shops/Shop.types.d.ts +2 -1
  28. package/lib/endpoints/private/shops/index.d.ts +1 -1
  29. package/lib/endpoints/private/subscription-capabilities/GetSubscriptionCapabilities.d.ts +4 -3
  30. package/lib/endpoints/private/subscription-capabilities/SubscriptionCapability.types.d.ts +3 -2
  31. package/lib/endpoints/private/subscriptions/DeleteSubscription.d.ts +3 -2
  32. package/lib/endpoints/private/subscriptions/GetSubscriptions.d.ts +3 -2
  33. package/lib/endpoints/private/subscriptions/PatchSubscriptions.d.ts +4 -3
  34. package/lib/endpoints/private/subscriptions/PostSubscriptions.d.ts +4 -3
  35. package/lib/endpoints/private/system-country-codes/GetSystemCountryCodes.d.ts +3 -2
  36. package/lib/endpoints/private/system-country-codes/SystemCountryCodes.types.d.ts +2 -1
  37. package/lib/endpoints/private/system-messages/GetSystemMessages.d.ts +3 -2
  38. package/lib/endpoints/private/track-traces/GetTrackAndTraceByShipment.d.ts +3 -2
  39. package/lib/endpoints/private/track-traces/TrackTraces.types.d.ts +5 -4
  40. package/lib/endpoints/private/webhook-subscriptions/DeleteWebhookSubscriptions.d.ts +3 -2
  41. package/lib/endpoints/private/webhook-subscriptions/GetWebhookSubscriptions.d.ts +3 -2
  42. package/lib/endpoints/private/webhook-subscriptions/PostWebhookSubscriptions.d.ts +4 -3
  43. package/lib/endpoints/public/carriers/Carrier.types.d.ts +2 -1
  44. package/lib/endpoints/public/carriers/GetCarrier.d.ts +4 -3
  45. package/lib/endpoints/public/carriers/GetCarriers.d.ts +3 -2
  46. package/lib/endpoints/public/delivery-options/DeliveryOption.types.d.ts +4 -4
  47. package/lib/endpoints/public/delivery-options/GetDeliveryOptions.d.ts +6 -5
  48. package/lib/endpoints/public/pickup-locations/GetPickupLocations.d.ts +4 -3
  49. package/lib/endpoints/public/pickup-locations/PickupLocation.types.d.ts +3 -2
  50. package/lib/index.cjs +1 -1
  51. package/lib/index.js +154 -118
  52. package/lib/model/client/AbstractClient.d.ts +15 -4
  53. package/lib/model/client/AbstractClient.types.d.ts +9 -3
  54. package/lib/model/client/FetchClient.d.ts +2 -1
  55. package/lib/model/client/helper/addParameters.d.ts +4 -3
  56. package/lib/model/client/middleware/Interceptors.d.ts +8 -0
  57. package/lib/model/client/middleware/Interceptors.unit.spec.d.ts +1 -0
  58. package/lib/model/client/middleware/middleware.types.d.ts +1 -0
  59. package/lib/model/endpoint/AbstractEndpoint.d.ts +3 -2
  60. package/lib/model/endpoint/AbstractEndpoint.types.d.ts +4 -3
  61. package/lib/model/endpoint/AbstractPrivateEndpoint.d.ts +3 -2
  62. package/lib/model/endpoint/AbstractPublicEndpoint.d.ts +2 -1
  63. package/lib/model/exception/ApiException.d.ts +2 -1
  64. package/package.json +15 -16
  65. package/lib/endpoints/private/shipments/PatchShipment.d.ts +0 -21
@@ -1,6 +1,8 @@
1
- import { type RequestHeaders, type ResponseWrapper } from '../../types/request.types';
2
- import { type AbstractEndpoint } from '../endpoint/AbstractEndpoint';
3
- import { type AbstractClient } from './AbstractClient';
1
+ import { Interceptors } from './middleware/Interceptors';
2
+ import { RequestHeaders, ResponseWrapper } from '../../types/request.types';
3
+ import { AbstractEndpoint } from '../endpoint/AbstractEndpoint';
4
+ import { AbstractClient } from './AbstractClient';
5
+
4
6
  interface ClientPlugin {
5
7
  getClient?: () => void;
6
8
  init?: (client: AbstractClient) => void;
@@ -14,6 +16,10 @@ export interface ClientConfig {
14
16
  parameters?: Record<string, string>;
15
17
  plugins?: PluginConstructor[];
16
18
  options?: ClientOptions;
19
+ interceptors?: {
20
+ request: Interceptors<RequestInit>;
21
+ response: Interceptors<Response>;
22
+ };
17
23
  }
18
24
  export interface ClientOptions {
19
25
  timeout?: number;
@@ -1,5 +1,6 @@
1
- import { type ClientConfig, type ClientRequest } from './AbstractClient.types';
1
+ import { ClientConfig, ClientRequest } from './AbstractClient.types';
2
2
  import { AbstractClient } from './AbstractClient';
3
+
3
4
  export declare class FetchClient extends AbstractClient {
4
5
  constructor(config?: ClientConfig);
5
6
  protected request: ClientRequest;
@@ -1,3 +1,4 @@
1
- import { type AbstractEndpoint } from '../../endpoint/AbstractEndpoint';
2
- import { type EndpointParameters } from '../AbstractClient.types';
3
- export declare const addParameters: <E extends AbstractEndpoint<import("../..").EndpointDefinition>>(path: string, parameters?: EndpointParameters<E> | undefined) => string;
1
+ import { AbstractEndpoint } from '../../endpoint/AbstractEndpoint';
2
+ import { EndpointParameters } from '../AbstractClient.types';
3
+
4
+ export declare const addParameters: <E extends AbstractEndpoint>(path: string, parameters?: EndpointParameters<E>) => string;
@@ -0,0 +1,8 @@
1
+ import { Middleware } from './middleware.types';
2
+
3
+ export declare class Interceptors<T> {
4
+ fns: Middleware<T>[];
5
+ constructor();
6
+ delete(fn: Middleware<T>): void;
7
+ use(fn: Middleware<T>): void;
8
+ }
@@ -0,0 +1 @@
1
+ export type Middleware<T> = (value: T) => T | Promise<T>;
@@ -1,5 +1,6 @@
1
- import { type HttpMethod } from '../../types/request.types';
2
- import { type EndpointDefinition } from './AbstractEndpoint.types';
1
+ import { HttpMethod } from '../../types/request.types';
2
+ import { EndpointDefinition } from './AbstractEndpoint.types';
3
+
3
4
  interface EndpointOptions {
4
5
  headers?: AbstractEndpoint['definition']['headers'];
5
6
  parameters?: AbstractEndpoint['definition']['parameters'];
@@ -1,6 +1,7 @@
1
- import { type RequestHeaders } from '../../types/request.types';
2
- import { type NoInfer } from '../../types/global.types';
3
- import { type OneOrMore } from '@myparcel-dev/ts-utils';
1
+ import { OneOrMore } from '@myparcel-dev/ts-utils';
2
+ import { RequestHeaders } from '../../types/request.types';
3
+ import { NoInfer } from '../../types/global.types';
4
+
4
5
  type Pagination = {
5
6
  page?: number;
6
7
  size?: number;
@@ -1,6 +1,7 @@
1
- import { type RequestHeaders } from '../../types/request.types';
2
- import { type EndpointDefinition } from './AbstractEndpoint.types';
1
+ import { RequestHeaders } from '../../types/request.types';
2
+ import { EndpointDefinition } from './AbstractEndpoint.types';
3
3
  import { AbstractEndpoint } from './AbstractEndpoint';
4
+
4
5
  type PrivateEndpointDefinition = {
5
6
  headers: RequestHeaders & {
6
7
  Authorization: string;
@@ -1,5 +1,6 @@
1
- import { type EndpointDefinition } from './AbstractEndpoint.types';
1
+ import { EndpointDefinition } from './AbstractEndpoint.types';
2
2
  import { AbstractEndpoint } from './AbstractEndpoint';
3
+
3
4
  export declare abstract class AbstractPublicEndpoint<D = EndpointDefinition> extends AbstractEndpoint<D> {
4
5
  abstract readonly name: AbstractPublicEndpoint['definition']['name'];
5
6
  }
@@ -1,4 +1,5 @@
1
- import { type ErrorResponse } from '../../types/request.types';
1
+ import { ErrorResponse } from '../../types/request.types';
2
+
2
3
  export declare class ApiException extends Error {
3
4
  data: ErrorResponse;
4
5
  constructor(error: ErrorResponse);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myparcel-dev/sdk",
3
- "version": "4.1.1",
3
+ "version": "5.0.1",
4
4
  "description": "JavaScript SDK to connect to the MyParcel API via Node.js or browser",
5
5
  "keywords": [
6
6
  "myparcel",
@@ -42,22 +42,22 @@
42
42
  "sh -c \"publint\""
43
43
  ]
44
44
  },
45
- "prettier": "@myparcel/prettier-config",
45
+ "prettier": "@myparcel-dev/prettier-config",
46
46
  "dependencies": {
47
- "@myparcel-dev/constants": "^2.0.0",
48
- "@myparcel-dev/ts-utils": "^1.6.0"
47
+ "@myparcel-dev/constants": "^2.7.0",
48
+ "@myparcel-dev/ts-utils": "^1.15.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@myparcel-eslint/eslint-config-esnext": "^1.2.0",
52
- "@myparcel-eslint/eslint-config-import": "^1.2.1",
53
- "@myparcel-eslint/eslint-config-node": "^1.2.0",
54
- "@myparcel-eslint/eslint-config-prettier": "^1.2.0",
55
- "@myparcel-eslint/eslint-config-prettier-typescript": "^1.2.0",
56
- "@myparcel/semantic-release-config": "^5.0.0",
51
+ "@myparcel-dev/eslint-config-esnext": "^1.4.0",
52
+ "@myparcel-dev/eslint-config-import": "^1.3.0",
53
+ "@myparcel-dev/eslint-config-node": "^1.4.0",
54
+ "@myparcel-dev/eslint-config-prettier": "^1.4.0",
55
+ "@myparcel-dev/eslint-config-prettier-typescript": "^1.4.0",
56
+ "@myparcel-dev/semantic-release-config": "^6.0.0",
57
57
  "@tsconfig/recommended": "^1.0.2",
58
58
  "@types/node": "^20.0.0",
59
- "@vitest/coverage-v8": "^1.0.0",
60
- "@vitest/ui": "^1.0.0",
59
+ "@vitest/coverage-v8": "^2.0.0",
60
+ "@vitest/ui": "^2.0.0",
61
61
  "eslint": "^8.34.0",
62
62
  "eslint-plugin-sort-exports": "^0.9.0",
63
63
  "husky": "^9.0.0",
@@ -67,12 +67,11 @@
67
67
  "typescript": "^5.2.0",
68
68
  "vite": "^5.0.0",
69
69
  "vite-plugin-dts": "^3.6.0",
70
- "vitest": "^1.0.0",
71
- "vitest-fetch-mock": "^0.2.1"
70
+ "vitest": "^2.0.0"
72
71
  },
73
- "packageManager": "yarn@4.0.1",
74
72
  "volta": {
75
- "node": "20.10.0"
73
+ "node": "20.10.0",
74
+ "yarn": "4.3.1"
76
75
  },
77
76
  "publishConfig": {
78
77
  "access": "public"
@@ -1,21 +0,0 @@
1
- import { type HttpMethod, type RequestHeaders } from '../../../types/request.types';
2
- import { AbstractPrivateEndpoint } from '../../../model/endpoint/AbstractPrivateEndpoint';
3
- import { type CreateDefinition } from '../../../model/endpoint/AbstractEndpoint.types';
4
- import { type ShipmentPatchData } from './Shipment.types';
5
- type PatchShipmentsDefinition = CreateDefinition<{
6
- name: typeof PatchShipments.name;
7
- body: ShipmentPatchData[];
8
- }>;
9
- /**
10
- * Patch an existing shipment.
11
- *
12
- * @see https://developer.myparcel.nl/api-reference/06.shipments.html
13
- */
14
- export declare class PatchShipments extends AbstractPrivateEndpoint<PatchShipmentsDefinition> {
15
- readonly method: HttpMethod;
16
- readonly name = "patchShipments";
17
- readonly path = "shipments";
18
- readonly property = "shipments";
19
- getHeaders(): RequestHeaders;
20
- }
21
- export {};