@myparcel-dev/sdk 5.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/LICENSE.txt +21 -0
- package/README.md +15 -0
- package/lib/createMyParcelSdk.d.ts +18 -0
- package/lib/createMyParcelSdk.spec.d.ts +1 -0
- package/lib/createPrivateSdk.d.ts +8 -0
- package/lib/createPrivateSdk.spec.d.ts +1 -0
- package/lib/createPublicSdk.d.ts +8 -0
- package/lib/endpoints/endpoints.spec.d.ts +1 -0
- package/lib/endpoints/index.d.ts +2 -0
- package/lib/endpoints/private/account-messages/AccountMessages.types.d.ts +6 -0
- package/lib/endpoints/private/account-messages/DeleteAccountMessage.d.ts +20 -0
- package/lib/endpoints/private/account-messages/GetAccountMessages.d.ts +20 -0
- package/lib/endpoints/private/account-messages/index.d.ts +3 -0
- package/lib/endpoints/private/accounts/Account.types.d.ts +59 -0
- package/lib/endpoints/private/accounts/GetAccount.d.ts +20 -0
- package/lib/endpoints/private/accounts/GetAccounts.d.ts +14 -0
- package/lib/endpoints/private/accounts/PutAccount.d.ts +19 -0
- package/lib/endpoints/private/accounts/index.d.ts +4 -0
- package/lib/endpoints/private/api-key/ApiKey.types.d.ts +12 -0
- package/lib/endpoints/private/api-key/GetApiKeys.d.ts +17 -0
- package/lib/endpoints/private/api-key/PostApiKeys.d.ts +20 -0
- package/lib/endpoints/private/api-key/index.d.ts +3 -0
- package/lib/endpoints/private/carrier-options/CarrierOption.types.d.ts +47 -0
- package/lib/endpoints/private/carrier-options/DeleteCarrierOptions.d.ts +18 -0
- package/lib/endpoints/private/carrier-options/GetCarrierOptions.d.ts +18 -0
- package/lib/endpoints/private/carrier-options/PostCarrierOptions.d.ts +20 -0
- package/lib/endpoints/private/carrier-options/PutCarrierOptions.d.ts +22 -0
- package/lib/endpoints/private/carrier-options/index.d.ts +5 -0
- package/lib/endpoints/private/index.d.ts +13 -0
- package/lib/endpoints/private/locations/GetLocations.d.ts +15 -0
- package/lib/endpoints/private/locations/Location.types.d.ts +9 -0
- package/lib/endpoints/private/locations/index.d.ts +2 -0
- package/lib/endpoints/private/shipments/GetShipment.d.ts +20 -0
- package/lib/endpoints/private/shipments/GetShipments.d.ts +23 -0
- package/lib/endpoints/private/shipments/PostShipments.d.ts +24 -0
- package/lib/endpoints/private/shipments/Shipment.types.d.ts +175 -0
- package/lib/endpoints/private/shipments/index.d.ts +4 -0
- package/lib/endpoints/private/shops/GetShop.d.ts +20 -0
- package/lib/endpoints/private/shops/PostShop.d.ts +23 -0
- package/lib/endpoints/private/shops/PostShopDuplicate.d.ts +24 -0
- package/lib/endpoints/private/shops/PutShop.d.ts +17 -0
- package/lib/endpoints/private/shops/Shop.types.d.ts +81 -0
- package/lib/endpoints/private/shops/index.d.ts +5 -0
- package/lib/endpoints/private/subscription-capabilities/GetSubscriptionCapabilities.d.ts +18 -0
- package/lib/endpoints/private/subscription-capabilities/SubscriptionCapability.types.d.ts +24 -0
- package/lib/endpoints/private/subscription-capabilities/index.d.ts +2 -0
- package/lib/endpoints/private/subscriptions/DeleteSubscription.d.ts +17 -0
- package/lib/endpoints/private/subscriptions/GetSubscriptions.d.ts +18 -0
- package/lib/endpoints/private/subscriptions/PatchSubscriptions.d.ts +20 -0
- package/lib/endpoints/private/subscriptions/PostSubscriptions.d.ts +20 -0
- package/lib/endpoints/private/subscriptions/Subscriptions.types.d.ts +30 -0
- package/lib/endpoints/private/subscriptions/index.d.ts +5 -0
- package/lib/endpoints/private/system-country-codes/GetSystemCountryCodes.d.ts +15 -0
- package/lib/endpoints/private/system-country-codes/SystemCountryCodes.types.d.ts +11 -0
- package/lib/endpoints/private/system-country-codes/index.d.ts +2 -0
- package/lib/endpoints/private/system-messages/GetSystemMessages.d.ts +17 -0
- package/lib/endpoints/private/system-messages/SystemMessage.types.d.ts +18 -0
- package/lib/endpoints/private/system-messages/index.d.ts +2 -0
- package/lib/endpoints/private/track-traces/GetTrackAndTraceByShipment.d.ts +17 -0
- package/lib/endpoints/private/track-traces/TrackTraces.types.d.ts +51 -0
- package/lib/endpoints/private/track-traces/index.d.ts +2 -0
- package/lib/endpoints/private/webhook-subscriptions/DeleteWebhookSubscriptions.d.ts +17 -0
- package/lib/endpoints/private/webhook-subscriptions/GetWebhookSubscriptions.d.ts +15 -0
- package/lib/endpoints/private/webhook-subscriptions/PostWebhookSubscriptions.d.ts +20 -0
- package/lib/endpoints/private/webhook-subscriptions/Webhook.types.d.ts +13 -0
- package/lib/endpoints/private/webhook-subscriptions/index.d.ts +4 -0
- package/lib/endpoints/public/carriers/Carrier.types.d.ts +11 -0
- package/lib/endpoints/public/carriers/GetCarrier.d.ts +20 -0
- package/lib/endpoints/public/carriers/GetCarriers.d.ts +16 -0
- package/lib/endpoints/public/carriers/index.d.ts +3 -0
- package/lib/endpoints/public/delivery-options/DeliveryOption.types.d.ts +22 -0
- package/lib/endpoints/public/delivery-options/GetDeliveryOptions.d.ts +50 -0
- package/lib/endpoints/public/delivery-options/index.d.ts +2 -0
- package/lib/endpoints/public/index.d.ts +3 -0
- package/lib/endpoints/public/pickup-locations/GetPickupLocations.d.ts +18 -0
- package/lib/endpoints/public/pickup-locations/PickupLocation.types.d.ts +32 -0
- package/lib/endpoints/public/pickup-locations/index.d.ts +2 -0
- package/lib/index.cjs +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +660 -0
- package/lib/index.spec.d.ts +1 -0
- package/lib/model/client/AbstractClient.d.ts +89 -0
- package/lib/model/client/AbstractClient.spec.d.ts +1 -0
- package/lib/model/client/AbstractClient.types.d.ts +55 -0
- package/lib/model/client/FetchClient.d.ts +7 -0
- package/lib/model/client/helper/addParameters.d.ts +4 -0
- package/lib/model/client/helper/addParameters.spec.d.ts +1 -0
- package/lib/model/client/helper/index.d.ts +2 -0
- package/lib/model/client/helper/isJson.d.ts +1 -0
- package/lib/model/client/helper/isJson.spec.d.ts +1 -0
- package/lib/model/client/index.d.ts +4 -0
- package/lib/model/client/middleware/Interceptors.d.ts +8 -0
- package/lib/model/client/middleware/Interceptors.unit.spec.d.ts +1 -0
- package/lib/model/client/middleware/middleware.types.d.ts +1 -0
- package/lib/model/endpoint/AbstractEndpoint.d.ts +57 -0
- package/lib/model/endpoint/AbstractEndpoint.types.d.ts +21 -0
- package/lib/model/endpoint/AbstractPrivateEndpoint.d.ts +14 -0
- package/lib/model/endpoint/AbstractPublicEndpoint.d.ts +6 -0
- package/lib/model/endpoint/index.d.ts +4 -0
- package/lib/model/exception/ApiException.d.ts +6 -0
- package/lib/model/exception/UserException.d.ts +4 -0
- package/lib/model/exception/index.d.ts +2 -0
- package/lib/model/index.d.ts +3 -0
- package/lib/types/common.types.d.ts +31 -0
- package/lib/types/data.types.d.ts +23 -0
- package/lib/types/global.types.d.ts +4 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/request.types.d.ts +18 -0
- package/package.json +79 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Interceptors } from './middleware/Interceptors';
|
|
2
|
+
import { RequestHeader, RequestHeaders, ResponseWrapper } from '../../types/request.types';
|
|
3
|
+
import { WithRequired } from '../../types';
|
|
4
|
+
import { AbstractEndpoint } from '../endpoint/AbstractEndpoint';
|
|
5
|
+
import { ClientConfig, ClientOptions, ClientRequest, EndpointPath, EndpointResponse, EndpointResponseBody, PaginatedEndpointResponse, Options, OptionsWithBody, OptionsWithoutBody } from './AbstractClient.types';
|
|
6
|
+
|
|
7
|
+
export declare const BASE_URL = "https://api.myparcel.nl";
|
|
8
|
+
export declare abstract class AbstractClient {
|
|
9
|
+
/**
|
|
10
|
+
* Interceptors for request and response.
|
|
11
|
+
*
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
interceptors: {
|
|
15
|
+
request: Interceptors<OptionsWithBody<AbstractEndpoint> | OptionsWithoutBody<AbstractEndpoint>>;
|
|
16
|
+
response: Interceptors<ResponseWrapper<EndpointResponseBody<AbstractEndpoint>>>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Executes the request. Should return a promise containing the response json as object.
|
|
20
|
+
*/
|
|
21
|
+
protected abstract request: ClientRequest;
|
|
22
|
+
/**
|
|
23
|
+
* Base URL to make requests to.
|
|
24
|
+
*
|
|
25
|
+
* @protected
|
|
26
|
+
*/
|
|
27
|
+
protected baseUrl: string;
|
|
28
|
+
/**
|
|
29
|
+
* Headers to use with requests.
|
|
30
|
+
*
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
protected headers: RequestHeaders;
|
|
34
|
+
/**
|
|
35
|
+
* @protected
|
|
36
|
+
*/
|
|
37
|
+
protected parameters: Record<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* Additional client specific options.
|
|
40
|
+
*
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
43
|
+
protected options: ClientOptions;
|
|
44
|
+
/**
|
|
45
|
+
* Array of headers that are required. Client will throw an error if any are missing.
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private _requiredHeaders;
|
|
50
|
+
protected constructor(config?: ClientConfig);
|
|
51
|
+
get requiredHeaders(): (RequestHeader | string)[];
|
|
52
|
+
set requiredHeaders(value: (RequestHeader | string)[]);
|
|
53
|
+
/**
|
|
54
|
+
* Prepare and execute the final request and handle the response.
|
|
55
|
+
*/
|
|
56
|
+
doRequest<E extends AbstractEndpoint>(endpoint: E, options: Options<E>): Promise<EndpointResponse<E>>;
|
|
57
|
+
getResponseBody<E extends AbstractEndpoint>(endpoint: E, response: EndpointResponse<E>): EndpointResponse<E> | PaginatedEndpointResponse<E>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets default and custom headers.
|
|
60
|
+
*
|
|
61
|
+
* @protected
|
|
62
|
+
*/
|
|
63
|
+
protected getHeaders(): RequestHeaders;
|
|
64
|
+
/**
|
|
65
|
+
* Uses the base url, endpoint and options to create the final request url.
|
|
66
|
+
*
|
|
67
|
+
* @protected
|
|
68
|
+
*/
|
|
69
|
+
protected createUrl<E extends AbstractEndpoint>(endpoint: E, options: Options<E>): string;
|
|
70
|
+
/**
|
|
71
|
+
* Replace path variables in an url path. Deletes optional parameters if
|
|
72
|
+
* they're not passed.
|
|
73
|
+
*
|
|
74
|
+
* @protected
|
|
75
|
+
*/
|
|
76
|
+
protected substitutePath<E extends AbstractEndpoint>(urlPath: string, pathVariables?: EndpointPath<E>): string;
|
|
77
|
+
/**
|
|
78
|
+
* Validates headers passed in options.
|
|
79
|
+
*
|
|
80
|
+
* @protected
|
|
81
|
+
*/
|
|
82
|
+
protected validateHeaders<E extends AbstractEndpoint>(endpoint: E, options: WithRequired<Options<E>, 'headers'>): void;
|
|
83
|
+
/**
|
|
84
|
+
* Executes transformations on options before request.
|
|
85
|
+
*
|
|
86
|
+
* @protected
|
|
87
|
+
*/
|
|
88
|
+
protected normalizeOptions<E extends AbstractEndpoint>(endpoint: E, options: Options<E>): WithRequired<Options<E>, 'headers'>;
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
6
|
+
interface ClientPlugin {
|
|
7
|
+
getClient?: () => void;
|
|
8
|
+
init?: (client: AbstractClient) => void;
|
|
9
|
+
transformRequest?: () => void;
|
|
10
|
+
transformResponse?: <Endpoint extends AbstractEndpoint>(response: ResponseWrapper<EndpointResponseBody<Endpoint>>) => ResponseWrapper<EndpointResponseBody<Endpoint>>;
|
|
11
|
+
}
|
|
12
|
+
type PluginConstructor = (client: AbstractClient) => ClientPlugin;
|
|
13
|
+
export interface ClientConfig {
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
headers?: RequestHeaders;
|
|
16
|
+
parameters?: Record<string, string>;
|
|
17
|
+
plugins?: PluginConstructor[];
|
|
18
|
+
options?: ClientOptions;
|
|
19
|
+
interceptors?: {
|
|
20
|
+
request: Interceptors<RequestInit>;
|
|
21
|
+
response: Interceptors<Response>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ClientOptions {
|
|
25
|
+
timeout?: number;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export type ClientRequest = <E extends AbstractEndpoint>(endpoint: E, options: OptionsWithoutBody<E> | OptionsWithBody<E>) => Promise<ResponseWrapper<EndpointResponseBody<E>>>;
|
|
29
|
+
export type EndpointParameters<E extends AbstractEndpoint> = E['definition']['parameters'];
|
|
30
|
+
export type EndpointPath<E extends AbstractEndpoint> = E['definition']['path'];
|
|
31
|
+
export type EndpointResponse<E extends AbstractEndpoint> = E['definition']['response'];
|
|
32
|
+
export type PaginatedEndpointResponse<E extends AbstractEndpoint> = E['definition']['response'] & {
|
|
33
|
+
page?: number;
|
|
34
|
+
size?: number;
|
|
35
|
+
results?: number;
|
|
36
|
+
};
|
|
37
|
+
export type EndpointBody<E extends AbstractEndpoint> = E['definition']['body'];
|
|
38
|
+
export type EndpointResponseProperty<E extends AbstractEndpoint> = E['responseProperty'] extends string ? E['responseProperty'] : E['property'] extends string ? E['property'] : never;
|
|
39
|
+
type EndpointResponseBodyWrapper<E extends AbstractEndpoint> = EndpointResponseProperty<E>;
|
|
40
|
+
type Page = 'page' | 'size' | 'results';
|
|
41
|
+
export type EndpointResponseBody<E extends AbstractEndpoint> = {
|
|
42
|
+
[key in EndpointResponseBodyWrapper<E>]: EndpointResponse<E>;
|
|
43
|
+
} & {
|
|
44
|
+
[key in Page]?: number;
|
|
45
|
+
};
|
|
46
|
+
export interface OptionsWithBody<E extends AbstractEndpoint> {
|
|
47
|
+
body?: EndpointBody<E>;
|
|
48
|
+
headers?: RequestHeaders;
|
|
49
|
+
parameters?: EndpointParameters<E>;
|
|
50
|
+
path?: EndpointPath<E>;
|
|
51
|
+
timeout?: number;
|
|
52
|
+
}
|
|
53
|
+
export type OptionsWithoutBody<E extends AbstractEndpoint> = Omit<OptionsWithBody<E>, 'body'>;
|
|
54
|
+
export type Options<E extends AbstractEndpoint> = OptionsWithBody<E> | OptionsWithoutBody<E>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isJson: (data: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Middleware<T> = (value: T) => T | Promise<T>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { HttpMethod } from '../../types/request.types';
|
|
2
|
+
import { EndpointDefinition } from './AbstractEndpoint.types';
|
|
3
|
+
|
|
4
|
+
interface EndpointOptions {
|
|
5
|
+
headers?: AbstractEndpoint['definition']['headers'];
|
|
6
|
+
parameters?: AbstractEndpoint['definition']['parameters'];
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class AbstractEndpoint<D = EndpointDefinition> {
|
|
9
|
+
/**
|
|
10
|
+
* HTTP method.
|
|
11
|
+
*/
|
|
12
|
+
readonly method: HttpMethod;
|
|
13
|
+
/**
|
|
14
|
+
* Name of the endpoint.
|
|
15
|
+
*/
|
|
16
|
+
abstract readonly name: string;
|
|
17
|
+
/**
|
|
18
|
+
* URL path of the API endpoint. Can contain path variables like `:variable`.
|
|
19
|
+
*/
|
|
20
|
+
abstract readonly path: string;
|
|
21
|
+
/**
|
|
22
|
+
* The property in the request body and response body. If the response body
|
|
23
|
+
* property differs, set responseProperty alongside property.
|
|
24
|
+
* If the property is undefined, the endpoint will be called without a namespace.
|
|
25
|
+
*/
|
|
26
|
+
readonly property: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Property used in the response. Falls back to `this.property` if it's not
|
|
29
|
+
* set.
|
|
30
|
+
*/
|
|
31
|
+
readonly responseProperty: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Timeout in milliseconds.
|
|
34
|
+
* This is used to override the default timeout of the client.
|
|
35
|
+
*/
|
|
36
|
+
readonly timeout: number | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Used to expose EndpointDefinition type.
|
|
39
|
+
*/
|
|
40
|
+
readonly definition: D;
|
|
41
|
+
/**
|
|
42
|
+
* Headers to include when calling this endpoint.
|
|
43
|
+
*/
|
|
44
|
+
private readonly headers;
|
|
45
|
+
/**
|
|
46
|
+
* Parameters to include in the endpoint url.
|
|
47
|
+
*/
|
|
48
|
+
private readonly parameters;
|
|
49
|
+
constructor(options?: EndpointOptions);
|
|
50
|
+
getHeaders(): AbstractEndpoint['definition']['headers'];
|
|
51
|
+
getParameters(): AbstractEndpoint['definition']['parameters'];
|
|
52
|
+
getPath(): AbstractEndpoint['path'];
|
|
53
|
+
getProperty(): AbstractEndpoint['property'];
|
|
54
|
+
getResponseProperty(): AbstractEndpoint['responseProperty'];
|
|
55
|
+
getTimeout(): AbstractEndpoint['timeout'];
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OneOrMore } from '@myparcel-dev/ts-utils';
|
|
2
|
+
import { RequestHeaders } from '../../types/request.types';
|
|
3
|
+
import { NoInfer } from '../../types/global.types';
|
|
4
|
+
|
|
5
|
+
type Pagination = {
|
|
6
|
+
page?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
results?: number;
|
|
9
|
+
};
|
|
10
|
+
export type PaginatedResponse<T> = Pagination & Record<string, T>;
|
|
11
|
+
export interface EndpointDefinition {
|
|
12
|
+
name: string;
|
|
13
|
+
body?: NoInfer<unknown>;
|
|
14
|
+
headers?: RequestHeaders;
|
|
15
|
+
parameters?: NoInfer<Record<string, string | number | boolean>>;
|
|
16
|
+
path?: Record<string, string | number>;
|
|
17
|
+
response?: NoInfer<OneOrMore<unknown>> | PaginatedResponse<NoInfer<unknown[]>>;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
export type CreateDefinition<D extends EndpointDefinition> = D;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RequestHeaders } from '../../types/request.types';
|
|
2
|
+
import { EndpointDefinition } from './AbstractEndpoint.types';
|
|
3
|
+
import { AbstractEndpoint } from './AbstractEndpoint';
|
|
4
|
+
|
|
5
|
+
type PrivateEndpointDefinition = {
|
|
6
|
+
headers: RequestHeaders & {
|
|
7
|
+
Authorization: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type Private<D = EndpointDefinition> = D & PrivateEndpointDefinition;
|
|
11
|
+
export declare abstract class AbstractPrivateEndpoint<D = EndpointDefinition> extends AbstractEndpoint<Private<D>> {
|
|
12
|
+
abstract readonly name: AbstractPrivateEndpoint['definition']['name'];
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EndpointDefinition } from './AbstractEndpoint.types';
|
|
2
|
+
import { AbstractEndpoint } from './AbstractEndpoint';
|
|
3
|
+
|
|
4
|
+
export declare abstract class AbstractPublicEndpoint<D = EndpointDefinition> extends AbstractEndpoint<D> {
|
|
5
|
+
abstract readonly name: AbstractPublicEndpoint['definition']['name'];
|
|
6
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface Address {
|
|
2
|
+
area?: string;
|
|
3
|
+
box_number?: string;
|
|
4
|
+
cc: string;
|
|
5
|
+
city: string;
|
|
6
|
+
company?: string;
|
|
7
|
+
eori_number?: string;
|
|
8
|
+
number?: string;
|
|
9
|
+
number_suffix?: string;
|
|
10
|
+
person: string;
|
|
11
|
+
postal_code: string;
|
|
12
|
+
region?: string;
|
|
13
|
+
state?: string;
|
|
14
|
+
street: string;
|
|
15
|
+
street_additional_info?: string;
|
|
16
|
+
vat_number?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface AddressWithContactDetails extends Address {
|
|
19
|
+
email?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RetailLocation {
|
|
23
|
+
cc: string;
|
|
24
|
+
city: string;
|
|
25
|
+
location_code: string;
|
|
26
|
+
location_name: string;
|
|
27
|
+
number: string;
|
|
28
|
+
postal_code: string;
|
|
29
|
+
retail_network_id: string;
|
|
30
|
+
street: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Weekday = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
|
|
2
|
+
export type IntBoolean = 0 | 1;
|
|
3
|
+
export interface Price {
|
|
4
|
+
amount: number;
|
|
5
|
+
currency: 'EUR' | string;
|
|
6
|
+
}
|
|
7
|
+
export interface StartEndDate {
|
|
8
|
+
end: Timestamp;
|
|
9
|
+
start: Timestamp;
|
|
10
|
+
}
|
|
11
|
+
export interface EnumSchema<Type> {
|
|
12
|
+
enum: Type[];
|
|
13
|
+
type: Type extends boolean ? 'boolean' : string;
|
|
14
|
+
}
|
|
15
|
+
export interface Timestamp {
|
|
16
|
+
date: string;
|
|
17
|
+
timezone: string;
|
|
18
|
+
timezone_type: number;
|
|
19
|
+
}
|
|
20
|
+
export type PaginationParameters = {
|
|
21
|
+
page: number;
|
|
22
|
+
size: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type HttpMethodWithBody = 'POST' | 'PATCH' | 'PUT';
|
|
2
|
+
export type HttpMethodWithoutBody = 'GET' | 'OPTIONS' | 'DELETE' | 'HEAD';
|
|
3
|
+
export type HttpMethod = HttpMethodWithBody | HttpMethodWithoutBody;
|
|
4
|
+
export type RequestHeader = 'Content-Type' | 'Authorization' | 'Accept' | 'Accept-Language';
|
|
5
|
+
export type RequestHeaders = Record<RequestHeader | string, string>;
|
|
6
|
+
export interface ResponseWrapper<Data = Record<string, unknown>> {
|
|
7
|
+
data: Data;
|
|
8
|
+
}
|
|
9
|
+
export interface ErrorResponse {
|
|
10
|
+
message: string;
|
|
11
|
+
request_id: string;
|
|
12
|
+
errors: {
|
|
13
|
+
status?: number;
|
|
14
|
+
code: number;
|
|
15
|
+
title?: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}[];
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@myparcel-dev/sdk",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "JavaScript SDK to connect to the MyParcel API via Node.js or browser",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"myparcel",
|
|
7
|
+
"sdk",
|
|
8
|
+
"node",
|
|
9
|
+
"browser"
|
|
10
|
+
],
|
|
11
|
+
"repository": "github:myparcelnl/js-sdk",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Edie Lemoine <edie@myparcel.nl>",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"import": "./lib/index.js",
|
|
19
|
+
"require": "./lib/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"main": "./lib/index.cjs",
|
|
23
|
+
"module": "./lib/index.js",
|
|
24
|
+
"types": "./lib/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"build:dev": "vite build --mode development",
|
|
31
|
+
"test": "vitest",
|
|
32
|
+
"test:coverage": "vitest run --coverage",
|
|
33
|
+
"test:run": "vitest run",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"watch": "yarn build:dev --watch"
|
|
36
|
+
},
|
|
37
|
+
"lint-staged": {
|
|
38
|
+
"*.{ts,js,cjs.mjs}": "eslint --fix",
|
|
39
|
+
"*.{json,yml,md}": "prettier --write",
|
|
40
|
+
"package.json": [
|
|
41
|
+
"sort-package-json",
|
|
42
|
+
"sh -c \"publint\""
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"prettier": "@myparcel-dev/prettier-config",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@myparcel-dev/constants": "^2.7.0",
|
|
48
|
+
"@myparcel-dev/ts-utils": "^1.15.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
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
|
+
"@tsconfig/recommended": "^1.0.2",
|
|
58
|
+
"@types/node": "^20.0.0",
|
|
59
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
60
|
+
"@vitest/ui": "^2.0.0",
|
|
61
|
+
"eslint": "^8.34.0",
|
|
62
|
+
"eslint-plugin-sort-exports": "^0.9.0",
|
|
63
|
+
"husky": "^9.0.0",
|
|
64
|
+
"prettier": "^2.8.4",
|
|
65
|
+
"publint": "^0.2.0",
|
|
66
|
+
"sort-package-json": "^2.4.1",
|
|
67
|
+
"typescript": "^5.2.0",
|
|
68
|
+
"vite": "^5.0.0",
|
|
69
|
+
"vite-plugin-dts": "^3.6.0",
|
|
70
|
+
"vitest": "^2.0.0"
|
|
71
|
+
},
|
|
72
|
+
"volta": {
|
|
73
|
+
"node": "20.10.0",
|
|
74
|
+
"yarn": "4.3.1"
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
}
|
|
79
|
+
}
|