doboxa-js 1.0.0 → 1.0.2
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/chunk-36DDSV5T.mjs +3077 -0
- package/dist/chunk-36DDSV5T.mjs.map +1 -0
- package/dist/chunk-CGJD4ZO5.mjs +107 -0
- package/dist/chunk-CGJD4ZO5.mjs.map +1 -0
- package/dist/client.js +2046 -0
- package/dist/client.js.map +1 -0
- package/dist/client.mjs +8 -0
- package/dist/client.mjs.map +1 -0
- package/dist/errors.js +91 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +15 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.js +3724 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +719 -0
- package/dist/index.mjs.map +1 -0
- package/dist/models.js +1 -0
- package/dist/models.js.map +1 -0
- package/dist/models.mjs +1 -0
- package/dist/models.mjs.map +1 -0
- package/package.json +18 -11
- package/api-doc.yaml +0 -2013
- package/openapi-generator-config.yaml +0 -15
- package/openapitools.json +0 -7
- package/src/client.ts +0 -99
- package/src/errors.ts +0 -90
- package/src/http/client.ts +0 -156
- package/src/index.ts +0 -31
- package/src/models.ts +0 -0
- package/src/resources/authentication.ts +0 -73
- package/src/resources/clients.ts +0 -32
- package/src/resources/discountCodes.ts +0 -32
- package/src/resources/invoices.ts +0 -46
- package/src/resources/orderComments.ts +0 -38
- package/src/resources/orderStatusChanges.ts +0 -38
- package/src/resources/orders.ts +0 -123
- package/src/resources/trackingNumbers.ts +0 -38
- package/src/resources/users.ts +0 -28
- package/src/types/index.ts +0 -59
- package/src/utils/config.ts +0 -10
- package/src/utils/tokenManager.ts +0 -68
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -27
package/src/resources/orders.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { HTTPClient } from '../http/client';
|
|
2
|
-
import { Configuration } from '../types/generated/src/runtime';
|
|
3
|
-
import { OrderApi } from '../types/generated/src/apis/OrderApi';
|
|
4
|
-
import { OrderCancellationApi } from '../types/generated/src/apis/OrderCancellationApi';
|
|
5
|
-
import type {
|
|
6
|
-
Order,
|
|
7
|
-
OrderStatus,
|
|
8
|
-
PostOrderStatus,
|
|
9
|
-
CreateOrderComment,
|
|
10
|
-
PostOrderCommentResponse,
|
|
11
|
-
PostOrderResponse,
|
|
12
|
-
PostOrderStatusResponse,
|
|
13
|
-
PageOfInvoices,
|
|
14
|
-
PageOfOrderComments,
|
|
15
|
-
PageOfTrackingNumbers,
|
|
16
|
-
OrderCancellation,
|
|
17
|
-
OrderCancellationResponse,
|
|
18
|
-
} from '../types/generated/src/models';
|
|
19
|
-
|
|
20
|
-
export interface OrderCreateParams extends Omit<
|
|
21
|
-
Order,
|
|
22
|
-
'billing_address' | 'order_source' | 'discount_code' | 'partner_code' |
|
|
23
|
-
'order_original_data' | 'payment_method' | 'payment_transaction_id' |
|
|
24
|
-
'ag_invoice_requested' | 'suggested_delivery_method'
|
|
25
|
-
> {}
|
|
26
|
-
|
|
27
|
-
export interface OrderStatusUpdateParams extends PostOrderStatus {}
|
|
28
|
-
|
|
29
|
-
export interface OrderCommentCreateParams extends CreateOrderComment {}
|
|
30
|
-
|
|
31
|
-
export interface OrderCancelParams {
|
|
32
|
-
order_id: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Orders resource
|
|
37
|
-
*/
|
|
38
|
-
export class OrdersResource {
|
|
39
|
-
private orderApi: OrderApi;
|
|
40
|
-
private cancellationApi: OrderCancellationApi;
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
private httpClient: HTTPClient,
|
|
44
|
-
config: Configuration
|
|
45
|
-
) {
|
|
46
|
-
this.orderApi = new OrderApi(config);
|
|
47
|
-
this.cancellationApi = new OrderCancellationApi(config);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create an order
|
|
52
|
-
*/
|
|
53
|
-
async create(params: OrderCreateParams): Promise<PostOrderResponse> {
|
|
54
|
-
return this.orderApi.postAppEcommerceApiV2PostorderInvoke(params);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get current order status
|
|
59
|
-
*/
|
|
60
|
-
async getStatus(orderId: string): Promise<OrderStatus> {
|
|
61
|
-
return this.orderApi.getAppEcommerceApiV2GetorderstatusInvoke(orderId);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Update order status
|
|
66
|
-
*/
|
|
67
|
-
async updateStatus(
|
|
68
|
-
orderId: string,
|
|
69
|
-
params: OrderStatusUpdateParams
|
|
70
|
-
): Promise<PostOrderStatusResponse> {
|
|
71
|
-
return this.orderApi.postAppEcommerceApiV2PostorderstatuschangeInvoke(
|
|
72
|
-
orderId,
|
|
73
|
-
params
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get order comments
|
|
79
|
-
*/
|
|
80
|
-
async getComments(orderId: string): Promise<PageOfOrderComments> {
|
|
81
|
-
return this.orderApi.getAppEcommerceApiV2GetordercommentsInvoke(orderId);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Create an order comment
|
|
86
|
-
*/
|
|
87
|
-
async createComment(
|
|
88
|
-
orderId: string,
|
|
89
|
-
params: OrderCommentCreateParams
|
|
90
|
-
): Promise<PostOrderCommentResponse> {
|
|
91
|
-
return this.orderApi.postAppEcommerceApiV2PostordercommentInvoke(
|
|
92
|
-
orderId,
|
|
93
|
-
params
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get order invoices
|
|
99
|
-
*/
|
|
100
|
-
async getInvoices(orderId: string): Promise<PageOfInvoices> {
|
|
101
|
-
return this.orderApi.getAppEcommerceApiV2GetorderinvoicesInvoke(orderId);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get order tracking numbers
|
|
106
|
-
*/
|
|
107
|
-
async getTrackingNumbers(orderId: string): Promise<PageOfTrackingNumbers> {
|
|
108
|
-
return this.orderApi.getAppEcommerceApiV2GetordertrackingnumbersInvoke(orderId);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Cancel an order
|
|
113
|
-
*/
|
|
114
|
-
async cancel(params: OrderCancelParams): Promise<OrderCancellationResponse> {
|
|
115
|
-
const cancellation: OrderCancellation = {
|
|
116
|
-
order_id: params.order_id,
|
|
117
|
-
};
|
|
118
|
-
return this.cancellationApi.postAppEcommerceApiV2PostordercancellationInvoke(
|
|
119
|
-
cancellation
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { HTTPClient } from '../http/client';
|
|
2
|
-
import { Configuration } from '../types/generated/src/runtime';
|
|
3
|
-
import { TrackingNumberApi } from '../types/generated/src/apis/TrackingNumberApi';
|
|
4
|
-
import type {
|
|
5
|
-
PageOfTrackingNumbers,
|
|
6
|
-
} from '../types/generated/src/models';
|
|
7
|
-
|
|
8
|
-
export interface TrackingNumberListParams {
|
|
9
|
-
page?: number;
|
|
10
|
-
from?: string; // ISO date-time
|
|
11
|
-
to?: string; // ISO date-time
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Tracking Numbers resource
|
|
16
|
-
*/
|
|
17
|
-
export class TrackingNumbersResource {
|
|
18
|
-
private trackingNumberApi: TrackingNumberApi;
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
private httpClient: HTTPClient,
|
|
22
|
-
config: Configuration
|
|
23
|
-
) {
|
|
24
|
-
this.trackingNumberApi = new TrackingNumberApi(config);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* List tracking numbers
|
|
29
|
-
*/
|
|
30
|
-
async list(params?: TrackingNumberListParams): Promise<PageOfTrackingNumbers> {
|
|
31
|
-
return this.trackingNumberApi.getAppEcommerceApiV2GettrackingnumbersInvoke(
|
|
32
|
-
params?.page,
|
|
33
|
-
params?.from ? new Date(params.from) : undefined,
|
|
34
|
-
params?.to ? new Date(params.to) : undefined
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
package/src/resources/users.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { HTTPClient } from '../http/client';
|
|
2
|
-
import { Configuration } from '../types/generated/src/runtime';
|
|
3
|
-
import { UserApi } from '../types/generated/src/apis/UserApi';
|
|
4
|
-
import type {
|
|
5
|
-
Me,
|
|
6
|
-
} from '../types/generated/src/models';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Users resource
|
|
10
|
-
*/
|
|
11
|
-
export class UsersResource {
|
|
12
|
-
private userApi: UserApi;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
private httpClient: HTTPClient,
|
|
16
|
-
config: Configuration
|
|
17
|
-
) {
|
|
18
|
-
this.userApi = new UserApi(config);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get current user (validate access token)
|
|
23
|
-
*/
|
|
24
|
-
async me(): Promise<Me> {
|
|
25
|
-
return this.userApi.getAppEcommerceApiV2GetmeInvoke();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
package/src/types/index.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Re-export all generated types
|
|
2
|
-
export * from '../types/generated/src/models';
|
|
3
|
-
|
|
4
|
-
// Re-export convenience types from resources
|
|
5
|
-
export type {
|
|
6
|
-
LoginParams,
|
|
7
|
-
RefreshTokenParams,
|
|
8
|
-
} from '../resources/authentication';
|
|
9
|
-
|
|
10
|
-
export type {
|
|
11
|
-
OrderCreateParams,
|
|
12
|
-
OrderStatusUpdateParams,
|
|
13
|
-
OrderCommentCreateParams,
|
|
14
|
-
OrderCancelParams,
|
|
15
|
-
} from '../resources/orders';
|
|
16
|
-
|
|
17
|
-
export type {
|
|
18
|
-
InvoiceListParams,
|
|
19
|
-
} from '../resources/invoices';
|
|
20
|
-
|
|
21
|
-
export type {
|
|
22
|
-
ClientListParams,
|
|
23
|
-
} from '../resources/clients';
|
|
24
|
-
|
|
25
|
-
export type {
|
|
26
|
-
DiscountCodeListParams,
|
|
27
|
-
} from '../resources/discountCodes';
|
|
28
|
-
|
|
29
|
-
export type {
|
|
30
|
-
TrackingNumberListParams,
|
|
31
|
-
} from '../resources/trackingNumbers';
|
|
32
|
-
|
|
33
|
-
export type {
|
|
34
|
-
OrderCommentListParams,
|
|
35
|
-
} from '../resources/orderComments';
|
|
36
|
-
|
|
37
|
-
export type {
|
|
38
|
-
OrderStatusChangeListParams,
|
|
39
|
-
} from '../resources/orderStatusChanges';
|
|
40
|
-
|
|
41
|
-
// Re-export configuration types
|
|
42
|
-
export type { DoboxaConfig } from '../client';
|
|
43
|
-
|
|
44
|
-
// Convenience type aliases for common enums
|
|
45
|
-
export type OrderStatusEnum =
|
|
46
|
-
| 'new'
|
|
47
|
-
| 'wait_for_payment'
|
|
48
|
-
| 'paid'
|
|
49
|
-
| 'in_progress'
|
|
50
|
-
| 'ready_to_be_sent'
|
|
51
|
-
| 'sent'
|
|
52
|
-
| 'cancelled'
|
|
53
|
-
| 'hold'
|
|
54
|
-
| 'refund';
|
|
55
|
-
|
|
56
|
-
export type InvoiceStateEnum = 'PAID' | 'UNPAID';
|
|
57
|
-
|
|
58
|
-
export type AuthorTypeEnum = 'client' | 'support';
|
|
59
|
-
|
package/src/utils/config.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token manager for handling access tokens and refresh tokens
|
|
3
|
-
*/
|
|
4
|
-
export class TokenManager {
|
|
5
|
-
private accessToken: string | null = null;
|
|
6
|
-
private refreshToken: string | null = null;
|
|
7
|
-
private tokenExpiry: number | null = null;
|
|
8
|
-
private refreshPromise: Promise<string> | null = null;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Set tokens and calculate expiry
|
|
12
|
-
*/
|
|
13
|
-
setTokens(accessToken: string, refreshToken: string, expiresIn: number = 3600): void {
|
|
14
|
-
this.accessToken = accessToken;
|
|
15
|
-
this.refreshToken = refreshToken;
|
|
16
|
-
// Set expiry to 5 seconds before actual expiry for safety
|
|
17
|
-
this.tokenExpiry = Date.now() + (expiresIn - 5) * 1000;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get current access token
|
|
22
|
-
*/
|
|
23
|
-
getAccessToken(): string | null {
|
|
24
|
-
return this.accessToken;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get refresh token
|
|
29
|
-
*/
|
|
30
|
-
getRefreshToken(): string | null {
|
|
31
|
-
return this.refreshToken;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Check if token is expired or will expire soon
|
|
36
|
-
*/
|
|
37
|
-
isTokenExpired(): boolean {
|
|
38
|
-
if (!this.tokenExpiry || !this.accessToken) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return Date.now() >= this.tokenExpiry;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Clear all tokens
|
|
46
|
-
*/
|
|
47
|
-
clearTokens(): void {
|
|
48
|
-
this.accessToken = null;
|
|
49
|
-
this.refreshToken = null;
|
|
50
|
-
this.tokenExpiry = null;
|
|
51
|
-
this.refreshPromise = null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Set refresh promise to prevent concurrent refresh requests
|
|
56
|
-
*/
|
|
57
|
-
setRefreshPromise(promise: Promise<string> | null): void {
|
|
58
|
-
this.refreshPromise = promise;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get current refresh promise
|
|
63
|
-
*/
|
|
64
|
-
getRefreshPromise(): Promise<string> | null {
|
|
65
|
-
return this.refreshPromise;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup';
|
|
2
|
-
|
|
3
|
-
import { name, version } from './package.json';
|
|
4
|
-
|
|
5
|
-
export default defineConfig(overrideOptions => {
|
|
6
|
-
const isWatch = !!overrideOptions.watch;
|
|
7
|
-
const shouldPublish = !!overrideOptions.env?.publish;
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
entry: {
|
|
11
|
-
index: 'src/index.ts',
|
|
12
|
-
},
|
|
13
|
-
dts: true,
|
|
14
|
-
onSuccess: shouldPublish ? `git tag v${version} && pnpm publish` : undefined,
|
|
15
|
-
format: ['cjs', 'esm'],
|
|
16
|
-
bundle: true,
|
|
17
|
-
clean: true,
|
|
18
|
-
minify: false,
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
define: {
|
|
21
|
-
PACKAGE_NAME: `"${name}"`,
|
|
22
|
-
PACKAGE_VERSION: `"${version}"`,
|
|
23
|
-
JS_PACKAGE_VERSION: `"${version}"`,
|
|
24
|
-
__DEV__: `${isWatch}`,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
});
|