@deliverart/sdk-js-point-of-sale 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/.changeset/config.json +11 -0
- package/.github/workflows/workflow.yml +47 -0
- package/.prettierrc +7 -0
- package/README.md +3 -0
- package/dist/index.cjs +304 -0
- package/dist/index.d.cts +4020 -0
- package/dist/index.d.ts +4020 -0
- package/dist/index.js +251 -0
- package/eslint.config.js +41 -0
- package/package.json +46 -0
- package/src/index.ts +3 -0
- package/src/models.ts +110 -0
- package/src/requests/CreatePointOfSale.ts +36 -0
- package/src/requests/DeletePointOfSale.ts +27 -0
- package/src/requests/GetPointOfSaleDetails.ts +30 -0
- package/src/requests/GetPointOfSales.ts +61 -0
- package/src/requests/UpdatePointOfSale.ts +35 -0
- package/src/requests/index.ts +5 -0
- package/src/types.ts +13 -0
- package/tsconfig.json +15 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// src/models.ts
|
|
2
|
+
import { addressSchema, datetimeSchema, dayOfWeekSchema } from "@deliverart/sdk-js-global-types";
|
|
3
|
+
import { z as z2 } from "zod";
|
|
4
|
+
|
|
5
|
+
// src/types.ts
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
var pointOfSaleOpeningStatuses = ["OPEN", "CLOSED"];
|
|
8
|
+
var pointOfSaleOpeningStatusSchema = z.enum(pointOfSaleOpeningStatuses);
|
|
9
|
+
var pointOfSaleCapabilities = ["DELIVERY_OPTIMIZATION"];
|
|
10
|
+
var pointOfSaleCapabilitySchema = z.enum(pointOfSaleCapabilities);
|
|
11
|
+
var pointOfSaleUserRoles = ["ROLE_ADMIN", "ROLE_READER"];
|
|
12
|
+
var pointOfSaleUserRoleSchema = z.enum(pointOfSaleUserRoles);
|
|
13
|
+
|
|
14
|
+
// src/models.ts
|
|
15
|
+
var timeSettingSchema = z2.object({
|
|
16
|
+
dayOfWeek: dayOfWeekSchema,
|
|
17
|
+
times: z2.object({
|
|
18
|
+
startTime: z2.string().regex(/^\d{2}:\d{2}$/),
|
|
19
|
+
endTime: z2.string().regex(/^\d{2}:\d{2}$/)
|
|
20
|
+
}).array()
|
|
21
|
+
});
|
|
22
|
+
var deliveryTimeSettingSchema = z2.object({
|
|
23
|
+
dayOfWeek: dayOfWeekSchema,
|
|
24
|
+
times: z2.object({
|
|
25
|
+
startTime: z2.string().regex(/^\d{2}:\d{2}$/),
|
|
26
|
+
endTime: z2.string().regex(/^\d{2}:\d{2}$/),
|
|
27
|
+
availableCouriers: z2.number().nonnegative()
|
|
28
|
+
}).array()
|
|
29
|
+
});
|
|
30
|
+
var pointOfSaleSchema = z2.object({
|
|
31
|
+
id: z2.string(),
|
|
32
|
+
name: z2.string(),
|
|
33
|
+
address: addressSchema,
|
|
34
|
+
timezone: z2.string(),
|
|
35
|
+
location: z2.object({
|
|
36
|
+
latitude: z2.number(),
|
|
37
|
+
longitude: z2.number()
|
|
38
|
+
}),
|
|
39
|
+
capabilities: pointOfSaleCapabilitySchema.array(),
|
|
40
|
+
openingStatus: pointOfSaleOpeningStatusSchema,
|
|
41
|
+
createdAt: datetimeSchema,
|
|
42
|
+
updatedAt: datetimeSchema
|
|
43
|
+
});
|
|
44
|
+
var userPointOfSaleSchema = z2.object({
|
|
45
|
+
pointOfSale: pointOfSaleSchema,
|
|
46
|
+
role: pointOfSaleUserRoleSchema
|
|
47
|
+
});
|
|
48
|
+
var pointOfSaleIntervalValues = [5, 10, 15, 20, 30, 60];
|
|
49
|
+
var pointOfSaleAutoAcceptOrderValues = [0, 5, 10, 15];
|
|
50
|
+
var pointOfSaleDetailsSchema = pointOfSaleSchema.extend({
|
|
51
|
+
company: z2.string().regex(
|
|
52
|
+
/^\/companies\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
|
|
53
|
+
),
|
|
54
|
+
settings: z2.object({
|
|
55
|
+
menuLocales: z2.any().array(),
|
|
56
|
+
deliveryTimesInterval: z2.number().positive().refine((value) => pointOfSaleIntervalValues.includes(value)),
|
|
57
|
+
takeAwayTimesInterval: z2.number().positive().refine((value) => pointOfSaleIntervalValues.includes(value)),
|
|
58
|
+
numberMinutesToPrecessFirstOrder: z2.number().positive(),
|
|
59
|
+
numberMinutesTimeChangeTolerance: z2.number().positive(),
|
|
60
|
+
maxCountableItemsPerBundle: z2.number().positive(),
|
|
61
|
+
maxOrdersPerBundle: z2.number().positive(),
|
|
62
|
+
preventOrderTakingIfTheMaxCountableItemsExceeded: z2.boolean(),
|
|
63
|
+
numberMinutesBeforeAutoAcceptOrder: z2.number().nonnegative().refine((value) => pointOfSaleAutoAcceptOrderValues.includes(value))
|
|
64
|
+
}),
|
|
65
|
+
openingTimeSettings: timeSettingSchema.array(),
|
|
66
|
+
deliveryTimeSettings: deliveryTimeSettingSchema.array(),
|
|
67
|
+
takeAwayTimeSettings: timeSettingSchema.array(),
|
|
68
|
+
numberOfCouriers: z2.number().nonnegative()
|
|
69
|
+
});
|
|
70
|
+
var writablePointOfSaleSchema = pointOfSaleDetailsSchema.pick({
|
|
71
|
+
name: true,
|
|
72
|
+
address: true,
|
|
73
|
+
timezone: true,
|
|
74
|
+
settings: true,
|
|
75
|
+
openingTimeSettings: true,
|
|
76
|
+
deliveryTimeSettings: true,
|
|
77
|
+
takeAwayTimeSettings: true,
|
|
78
|
+
capabilities: true,
|
|
79
|
+
openingStatus: true
|
|
80
|
+
});
|
|
81
|
+
var writableCreatePointOfSaleSchema = z2.object({
|
|
82
|
+
...writablePointOfSaleSchema.shape,
|
|
83
|
+
...pointOfSaleDetailsSchema.pick({
|
|
84
|
+
company: true
|
|
85
|
+
}).shape
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/requests/CreatePointOfSale.ts
|
|
89
|
+
import { AbstractApiRequest } from "@deliverart/sdk-js-core";
|
|
90
|
+
var createPointOfSaleInputSchema = writableCreatePointOfSaleSchema.required();
|
|
91
|
+
var createPointOfSaleResponseSchema = pointOfSaleDetailsSchema;
|
|
92
|
+
var CreatePointOfSale = class extends AbstractApiRequest {
|
|
93
|
+
method = "POST";
|
|
94
|
+
contentType = "application/json";
|
|
95
|
+
accept = "application/json";
|
|
96
|
+
inputSchema = createPointOfSaleInputSchema;
|
|
97
|
+
outputSchema = createPointOfSaleResponseSchema;
|
|
98
|
+
querySchema = void 0;
|
|
99
|
+
headersSchema = void 0;
|
|
100
|
+
constructor(input) {
|
|
101
|
+
super(input);
|
|
102
|
+
}
|
|
103
|
+
getPath() {
|
|
104
|
+
return "/point_of_sales";
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/requests/DeletePointOfSale.ts
|
|
109
|
+
import { AbstractApiRequest as AbstractApiRequest2 } from "@deliverart/sdk-js-core";
|
|
110
|
+
import { z as z3 } from "zod";
|
|
111
|
+
var deletePointOfSaleInputSchema = z3.undefined();
|
|
112
|
+
var deletePointOfSaleResponseSchema = z3.undefined();
|
|
113
|
+
var DeletePointOfSale = class extends AbstractApiRequest2 {
|
|
114
|
+
method = "DELETE";
|
|
115
|
+
contentType = "application/json";
|
|
116
|
+
accept = "application/json";
|
|
117
|
+
inputSchema = deletePointOfSaleInputSchema;
|
|
118
|
+
outputSchema = deletePointOfSaleResponseSchema;
|
|
119
|
+
querySchema = void 0;
|
|
120
|
+
headersSchema = void 0;
|
|
121
|
+
pointOfSaleId;
|
|
122
|
+
constructor(pointOfSaleId) {
|
|
123
|
+
super();
|
|
124
|
+
this.pointOfSaleId = pointOfSaleId;
|
|
125
|
+
}
|
|
126
|
+
getPath() {
|
|
127
|
+
return `/point_of_sales/${this.pointOfSaleId}`;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/requests/GetPointOfSaleDetails.ts
|
|
132
|
+
import { AbstractApiRequest as AbstractApiRequest3 } from "@deliverart/sdk-js-core";
|
|
133
|
+
import { z as z4 } from "zod";
|
|
134
|
+
var getPointOfSaleDetailsInputSchema = z4.undefined();
|
|
135
|
+
var getPointOfSaleDetailsResponseSchema = pointOfSaleDetailsSchema;
|
|
136
|
+
var GetPointOfSaleDetails = class extends AbstractApiRequest3 {
|
|
137
|
+
method = "GET";
|
|
138
|
+
contentType = "application/json";
|
|
139
|
+
accept = "application/json";
|
|
140
|
+
inputSchema = getPointOfSaleDetailsInputSchema;
|
|
141
|
+
outputSchema = getPointOfSaleDetailsResponseSchema;
|
|
142
|
+
querySchema = void 0;
|
|
143
|
+
headersSchema = void 0;
|
|
144
|
+
pointOfSaleId;
|
|
145
|
+
constructor(pointOfSaleId) {
|
|
146
|
+
super();
|
|
147
|
+
this.pointOfSaleId = pointOfSaleId;
|
|
148
|
+
}
|
|
149
|
+
getPath() {
|
|
150
|
+
return `/point_of_sales/${this.pointOfSaleId}`;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/requests/GetPointOfSales.ts
|
|
155
|
+
import { AbstractApiRequest as AbstractApiRequest4 } from "@deliverart/sdk-js-core";
|
|
156
|
+
import {
|
|
157
|
+
createPaginatedSchema,
|
|
158
|
+
responseToPagination,
|
|
159
|
+
sortDirSchema
|
|
160
|
+
} from "@deliverart/sdk-js-global-types";
|
|
161
|
+
import { z as z5 } from "zod";
|
|
162
|
+
var getCompaniesQuerySchema = z5.object({
|
|
163
|
+
name: z5.string().optional(),
|
|
164
|
+
openingStatus: pointOfSaleOpeningStatusSchema.optional(),
|
|
165
|
+
"integrationActivationRequests.connectionId": z5.string().optional(),
|
|
166
|
+
"address.city": z5.string().optional(),
|
|
167
|
+
"address.postalCode": z5.string().optional(),
|
|
168
|
+
"order[name]": sortDirSchema.optional(),
|
|
169
|
+
"order[createdAt]": sortDirSchema.optional(),
|
|
170
|
+
"order[updatedAt]": sortDirSchema.optional(),
|
|
171
|
+
page: z5.coerce.number().optional()
|
|
172
|
+
});
|
|
173
|
+
var getCompaniesResponseSchema = createPaginatedSchema(pointOfSaleSchema);
|
|
174
|
+
var getCompaniesInputSchema = z5.undefined();
|
|
175
|
+
var GetPointOfSales = class extends AbstractApiRequest4 {
|
|
176
|
+
method = "GET";
|
|
177
|
+
contentType = "application/json";
|
|
178
|
+
accept = "application/json";
|
|
179
|
+
inputSchema = getCompaniesInputSchema;
|
|
180
|
+
outputSchema = getCompaniesResponseSchema;
|
|
181
|
+
querySchema = getCompaniesQuerySchema;
|
|
182
|
+
headersSchema = void 0;
|
|
183
|
+
constructor(options) {
|
|
184
|
+
super(void 0, options);
|
|
185
|
+
}
|
|
186
|
+
getPath() {
|
|
187
|
+
return "/point_of_sales";
|
|
188
|
+
}
|
|
189
|
+
parseResponse(data, rawResponse) {
|
|
190
|
+
const pointOfSales = z5.array(pointOfSaleSchema).parse(data);
|
|
191
|
+
return this.validateOutput({
|
|
192
|
+
data: pointOfSales,
|
|
193
|
+
pagination: responseToPagination(rawResponse)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/requests/UpdatePointOfSale.ts
|
|
199
|
+
import { AbstractApiRequest as AbstractApiRequest5 } from "@deliverart/sdk-js-core";
|
|
200
|
+
var updatePointOfSaleInputSchema = writablePointOfSaleSchema.partial();
|
|
201
|
+
var updatePointOfSaleResponseSchema = pointOfSaleDetailsSchema;
|
|
202
|
+
var UpdatePointOfSale = class extends AbstractApiRequest5 {
|
|
203
|
+
method = "PATCH";
|
|
204
|
+
contentType = "application/merge-patch+json";
|
|
205
|
+
accept = "application/json";
|
|
206
|
+
inputSchema = updatePointOfSaleInputSchema;
|
|
207
|
+
outputSchema = updatePointOfSaleResponseSchema;
|
|
208
|
+
querySchema = void 0;
|
|
209
|
+
headersSchema = void 0;
|
|
210
|
+
pointOfSaleId;
|
|
211
|
+
constructor(pointOfSaleId, input) {
|
|
212
|
+
super(input);
|
|
213
|
+
this.pointOfSaleId = pointOfSaleId;
|
|
214
|
+
}
|
|
215
|
+
getPath() {
|
|
216
|
+
return `/point_of_sales/${this.pointOfSaleId}`;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
export {
|
|
220
|
+
CreatePointOfSale,
|
|
221
|
+
DeletePointOfSale,
|
|
222
|
+
GetPointOfSaleDetails,
|
|
223
|
+
GetPointOfSales,
|
|
224
|
+
UpdatePointOfSale,
|
|
225
|
+
createPointOfSaleInputSchema,
|
|
226
|
+
createPointOfSaleResponseSchema,
|
|
227
|
+
deletePointOfSaleInputSchema,
|
|
228
|
+
deletePointOfSaleResponseSchema,
|
|
229
|
+
deliveryTimeSettingSchema,
|
|
230
|
+
getCompaniesInputSchema,
|
|
231
|
+
getCompaniesQuerySchema,
|
|
232
|
+
getCompaniesResponseSchema,
|
|
233
|
+
getPointOfSaleDetailsInputSchema,
|
|
234
|
+
getPointOfSaleDetailsResponseSchema,
|
|
235
|
+
pointOfSaleAutoAcceptOrderValues,
|
|
236
|
+
pointOfSaleCapabilities,
|
|
237
|
+
pointOfSaleCapabilitySchema,
|
|
238
|
+
pointOfSaleDetailsSchema,
|
|
239
|
+
pointOfSaleIntervalValues,
|
|
240
|
+
pointOfSaleOpeningStatusSchema,
|
|
241
|
+
pointOfSaleOpeningStatuses,
|
|
242
|
+
pointOfSaleSchema,
|
|
243
|
+
pointOfSaleUserRoleSchema,
|
|
244
|
+
pointOfSaleUserRoles,
|
|
245
|
+
timeSettingSchema,
|
|
246
|
+
updatePointOfSaleInputSchema,
|
|
247
|
+
updatePointOfSaleResponseSchema,
|
|
248
|
+
userPointOfSaleSchema,
|
|
249
|
+
writableCreatePointOfSaleSchema,
|
|
250
|
+
writablePointOfSaleSchema
|
|
251
|
+
};
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// eslint.config.js per @typescript-eslint v8
|
|
3
|
+
import js from '@eslint/js'
|
|
4
|
+
import prettier from 'eslint-config-prettier'
|
|
5
|
+
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
|
|
6
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
7
|
+
import tsParser from '@typescript-eslint/parser'
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
js.configs.recommended,
|
|
11
|
+
{
|
|
12
|
+
files: ['**/*.ts'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parser: tsParser,
|
|
15
|
+
globals: {
|
|
16
|
+
process: 'readonly',
|
|
17
|
+
fetch: 'readonly',
|
|
18
|
+
Request: 'readonly',
|
|
19
|
+
Response: 'readonly',
|
|
20
|
+
Headers: 'readonly',
|
|
21
|
+
},
|
|
22
|
+
parserOptions: {
|
|
23
|
+
project: ['./tsconfig.json'],
|
|
24
|
+
tsconfigRootDir: process.cwd(),
|
|
25
|
+
sourceType: 'module',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
plugins: {
|
|
29
|
+
'@typescript-eslint': tsPlugin,
|
|
30
|
+
'simple-import-sort': simpleImportSortPlugin,
|
|
31
|
+
},
|
|
32
|
+
rules: {
|
|
33
|
+
'simple-import-sort/imports': 'error',
|
|
34
|
+
'simple-import-sort/exports': 'error',
|
|
35
|
+
'@typescript-eslint/no-unused-vars': 'warn',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
prettier,
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
export const ignores = ['dist', 'node_modules']
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deliverart/sdk-js-point-of-sale",
|
|
3
|
+
"description": "Deliverart JavaScript SDK for Point of Sale Management",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"zod": "3.25.67",
|
|
16
|
+
"axios": "1.9.0",
|
|
17
|
+
"@deliverart/sdk-js-core": "0.1.3",
|
|
18
|
+
"@deliverart/sdk-js-global-types": "0.0.12"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@changesets/cli": "^2.29.4",
|
|
22
|
+
"@eslint/js": "9.28.0",
|
|
23
|
+
"@types/node": "22.15.30",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "8.33.1",
|
|
25
|
+
"@typescript-eslint/parser": "8.33.1",
|
|
26
|
+
"eslint": "9.28.0",
|
|
27
|
+
"eslint-config-prettier": "10.1.5",
|
|
28
|
+
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
29
|
+
"prettier": "3.5.3",
|
|
30
|
+
"tsup": "8.5.0",
|
|
31
|
+
"typescript": "5.8.3"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
38
|
+
"dev": "tsup src/index.ts --dts --watch",
|
|
39
|
+
"lint": "eslint .",
|
|
40
|
+
"lint:fix": "eslint . --fix",
|
|
41
|
+
"prettier": "prettier --check .",
|
|
42
|
+
"prettier:fix": "prettier --write .",
|
|
43
|
+
"version": "@changesets/cli version",
|
|
44
|
+
"release": "@changesets/cli publish"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/index.ts
ADDED
package/src/models.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { addressSchema, datetimeSchema, dayOfWeekSchema } from '@deliverart/sdk-js-global-types'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
pointOfSaleCapabilitySchema,
|
|
6
|
+
pointOfSaleOpeningStatusSchema,
|
|
7
|
+
pointOfSaleUserRoleSchema,
|
|
8
|
+
} from './types'
|
|
9
|
+
|
|
10
|
+
export const timeSettingSchema = z.object({
|
|
11
|
+
dayOfWeek: dayOfWeekSchema,
|
|
12
|
+
times: z
|
|
13
|
+
.object({
|
|
14
|
+
startTime: z.string().regex(/^\d{2}:\d{2}$/),
|
|
15
|
+
endTime: z.string().regex(/^\d{2}:\d{2}$/),
|
|
16
|
+
})
|
|
17
|
+
.array(),
|
|
18
|
+
})
|
|
19
|
+
export type TimeSetting = z.infer<typeof timeSettingSchema>
|
|
20
|
+
|
|
21
|
+
export const deliveryTimeSettingSchema = z.object({
|
|
22
|
+
dayOfWeek: dayOfWeekSchema,
|
|
23
|
+
times: z
|
|
24
|
+
.object({
|
|
25
|
+
startTime: z.string().regex(/^\d{2}:\d{2}$/),
|
|
26
|
+
endTime: z.string().regex(/^\d{2}:\d{2}$/),
|
|
27
|
+
availableCouriers: z.number().nonnegative(),
|
|
28
|
+
})
|
|
29
|
+
.array(),
|
|
30
|
+
})
|
|
31
|
+
export type DeliveryTimeSetting = z.infer<typeof deliveryTimeSettingSchema>
|
|
32
|
+
|
|
33
|
+
export const pointOfSaleSchema = z.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
name: z.string(),
|
|
36
|
+
address: addressSchema,
|
|
37
|
+
timezone: z.string(),
|
|
38
|
+
location: z.object({
|
|
39
|
+
latitude: z.number(),
|
|
40
|
+
longitude: z.number(),
|
|
41
|
+
}),
|
|
42
|
+
capabilities: pointOfSaleCapabilitySchema.array(),
|
|
43
|
+
openingStatus: pointOfSaleOpeningStatusSchema,
|
|
44
|
+
createdAt: datetimeSchema,
|
|
45
|
+
updatedAt: datetimeSchema,
|
|
46
|
+
})
|
|
47
|
+
export type PointOfSale = z.infer<typeof pointOfSaleSchema>
|
|
48
|
+
|
|
49
|
+
export const userPointOfSaleSchema = z.object({
|
|
50
|
+
pointOfSale: pointOfSaleSchema,
|
|
51
|
+
role: pointOfSaleUserRoleSchema,
|
|
52
|
+
})
|
|
53
|
+
export type UserPointOfSale = z.infer<typeof userPointOfSaleSchema>
|
|
54
|
+
|
|
55
|
+
export const pointOfSaleIntervalValues = [5, 10, 15, 20, 30, 60]
|
|
56
|
+
export const pointOfSaleAutoAcceptOrderValues = [0, 5, 10, 15]
|
|
57
|
+
|
|
58
|
+
export const pointOfSaleDetailsSchema = pointOfSaleSchema.extend({
|
|
59
|
+
company: z
|
|
60
|
+
.string()
|
|
61
|
+
.regex(
|
|
62
|
+
/^\/companies\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
63
|
+
),
|
|
64
|
+
settings: z.object({
|
|
65
|
+
menuLocales: z.any().array(),
|
|
66
|
+
deliveryTimesInterval: z
|
|
67
|
+
.number()
|
|
68
|
+
.positive()
|
|
69
|
+
.refine(value => pointOfSaleIntervalValues.includes(value)),
|
|
70
|
+
takeAwayTimesInterval: z
|
|
71
|
+
.number()
|
|
72
|
+
.positive()
|
|
73
|
+
.refine(value => pointOfSaleIntervalValues.includes(value)),
|
|
74
|
+
numberMinutesToPrecessFirstOrder: z.number().positive(),
|
|
75
|
+
numberMinutesTimeChangeTolerance: z.number().positive(),
|
|
76
|
+
maxCountableItemsPerBundle: z.number().positive(),
|
|
77
|
+
maxOrdersPerBundle: z.number().positive(),
|
|
78
|
+
preventOrderTakingIfTheMaxCountableItemsExceeded: z.boolean(),
|
|
79
|
+
numberMinutesBeforeAutoAcceptOrder: z
|
|
80
|
+
.number()
|
|
81
|
+
.nonnegative()
|
|
82
|
+
.refine(value => pointOfSaleAutoAcceptOrderValues.includes(value)),
|
|
83
|
+
}),
|
|
84
|
+
openingTimeSettings: timeSettingSchema.array(),
|
|
85
|
+
deliveryTimeSettings: deliveryTimeSettingSchema.array(),
|
|
86
|
+
takeAwayTimeSettings: timeSettingSchema.array(),
|
|
87
|
+
numberOfCouriers: z.number().nonnegative(),
|
|
88
|
+
})
|
|
89
|
+
export type PointOfSaleDetails = z.infer<typeof pointOfSaleDetailsSchema>
|
|
90
|
+
|
|
91
|
+
export const writablePointOfSaleSchema = pointOfSaleDetailsSchema.pick({
|
|
92
|
+
name: true,
|
|
93
|
+
address: true,
|
|
94
|
+
timezone: true,
|
|
95
|
+
settings: true,
|
|
96
|
+
openingTimeSettings: true,
|
|
97
|
+
deliveryTimeSettings: true,
|
|
98
|
+
takeAwayTimeSettings: true,
|
|
99
|
+
capabilities: true,
|
|
100
|
+
openingStatus: true,
|
|
101
|
+
})
|
|
102
|
+
export type WritablePointOfSale = z.infer<typeof writablePointOfSaleSchema>
|
|
103
|
+
|
|
104
|
+
export const writableCreatePointOfSaleSchema = z.object({
|
|
105
|
+
...writablePointOfSaleSchema.shape,
|
|
106
|
+
...pointOfSaleDetailsSchema.pick({
|
|
107
|
+
company: true,
|
|
108
|
+
}).shape,
|
|
109
|
+
})
|
|
110
|
+
export type WritableCreatePointOfSale = z.infer<typeof writableCreatePointOfSaleSchema>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
PointOfSaleDetails,
|
|
6
|
+
pointOfSaleDetailsSchema,
|
|
7
|
+
writableCreatePointOfSaleSchema,
|
|
8
|
+
} from '../models'
|
|
9
|
+
|
|
10
|
+
export const createPointOfSaleInputSchema = writableCreatePointOfSaleSchema.required()
|
|
11
|
+
export type CreatePointOfSaleInput = z.infer<typeof createPointOfSaleInputSchema>
|
|
12
|
+
|
|
13
|
+
export const createPointOfSaleResponseSchema = pointOfSaleDetailsSchema
|
|
14
|
+
export type CreatePointOfSaleResponse = PointOfSaleDetails
|
|
15
|
+
|
|
16
|
+
export class CreatePointOfSale extends AbstractApiRequest<
|
|
17
|
+
CreatePointOfSaleInput,
|
|
18
|
+
CreatePointOfSaleResponse
|
|
19
|
+
> {
|
|
20
|
+
readonly method = 'POST'
|
|
21
|
+
readonly contentType = 'application/json'
|
|
22
|
+
readonly accept = 'application/json'
|
|
23
|
+
|
|
24
|
+
readonly inputSchema = createPointOfSaleInputSchema
|
|
25
|
+
readonly outputSchema = createPointOfSaleResponseSchema
|
|
26
|
+
readonly querySchema = undefined
|
|
27
|
+
readonly headersSchema = undefined
|
|
28
|
+
|
|
29
|
+
constructor(input: CreatePointOfSaleInput) {
|
|
30
|
+
super(input)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getPath(): string {
|
|
34
|
+
return '/point_of_sales'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export const deletePointOfSaleInputSchema = z.undefined()
|
|
5
|
+
export const deletePointOfSaleResponseSchema = z.undefined()
|
|
6
|
+
|
|
7
|
+
export class DeletePointOfSale extends AbstractApiRequest<void, void> {
|
|
8
|
+
readonly method = 'DELETE'
|
|
9
|
+
readonly contentType = 'application/json'
|
|
10
|
+
readonly accept = 'application/json'
|
|
11
|
+
|
|
12
|
+
readonly inputSchema = deletePointOfSaleInputSchema
|
|
13
|
+
readonly outputSchema = deletePointOfSaleResponseSchema
|
|
14
|
+
readonly querySchema = undefined
|
|
15
|
+
readonly headersSchema = undefined
|
|
16
|
+
|
|
17
|
+
private readonly pointOfSaleId: string
|
|
18
|
+
|
|
19
|
+
constructor(pointOfSaleId: string) {
|
|
20
|
+
super()
|
|
21
|
+
this.pointOfSaleId = pointOfSaleId
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getPath(): string {
|
|
25
|
+
return `/point_of_sales/${this.pointOfSaleId}`
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { PointOfSaleDetails, pointOfSaleDetailsSchema } from '../models'
|
|
5
|
+
|
|
6
|
+
export const getPointOfSaleDetailsInputSchema = z.undefined()
|
|
7
|
+
|
|
8
|
+
export const getPointOfSaleDetailsResponseSchema = pointOfSaleDetailsSchema
|
|
9
|
+
export type GetPointOfSaleDetailsResponse = PointOfSaleDetails
|
|
10
|
+
|
|
11
|
+
export class GetPointOfSaleDetails extends AbstractApiRequest<void, GetPointOfSaleDetailsResponse> {
|
|
12
|
+
readonly method = 'GET'
|
|
13
|
+
readonly contentType = 'application/json'
|
|
14
|
+
readonly accept = 'application/json'
|
|
15
|
+
readonly inputSchema = getPointOfSaleDetailsInputSchema
|
|
16
|
+
readonly outputSchema = getPointOfSaleDetailsResponseSchema
|
|
17
|
+
readonly querySchema = undefined
|
|
18
|
+
readonly headersSchema = undefined
|
|
19
|
+
|
|
20
|
+
private readonly pointOfSaleId: string
|
|
21
|
+
|
|
22
|
+
constructor(pointOfSaleId: string) {
|
|
23
|
+
super()
|
|
24
|
+
this.pointOfSaleId = pointOfSaleId
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getPath(): string {
|
|
28
|
+
return `/point_of_sales/${this.pointOfSaleId}`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import {
|
|
3
|
+
createPaginatedSchema,
|
|
4
|
+
Paginated,
|
|
5
|
+
responseToPagination,
|
|
6
|
+
sortDirSchema,
|
|
7
|
+
} from '@deliverart/sdk-js-global-types'
|
|
8
|
+
import { AxiosResponse } from 'axios'
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
|
|
11
|
+
import { PointOfSale, pointOfSaleSchema } from '../models'
|
|
12
|
+
import { pointOfSaleOpeningStatusSchema } from '../types'
|
|
13
|
+
|
|
14
|
+
export const getCompaniesQuerySchema = z.object({
|
|
15
|
+
name: z.string().optional(),
|
|
16
|
+
openingStatus: pointOfSaleOpeningStatusSchema.optional(),
|
|
17
|
+
'integrationActivationRequests.connectionId': z.string().optional(),
|
|
18
|
+
'address.city': z.string().optional(),
|
|
19
|
+
'address.postalCode': z.string().optional(),
|
|
20
|
+
'order[name]': sortDirSchema.optional(),
|
|
21
|
+
'order[createdAt]': sortDirSchema.optional(),
|
|
22
|
+
'order[updatedAt]': sortDirSchema.optional(),
|
|
23
|
+
page: z.coerce.number().optional(),
|
|
24
|
+
})
|
|
25
|
+
export type GetCompaniesQueryParams = z.infer<typeof getCompaniesQuerySchema>
|
|
26
|
+
|
|
27
|
+
export const getCompaniesResponseSchema = createPaginatedSchema(pointOfSaleSchema)
|
|
28
|
+
export type GetCompaniesResponse = z.infer<typeof getCompaniesResponseSchema>
|
|
29
|
+
|
|
30
|
+
export const getCompaniesInputSchema = z.undefined()
|
|
31
|
+
|
|
32
|
+
export class GetPointOfSales extends AbstractApiRequest<
|
|
33
|
+
void,
|
|
34
|
+
GetCompaniesResponse,
|
|
35
|
+
GetCompaniesQueryParams
|
|
36
|
+
> {
|
|
37
|
+
readonly method = 'GET'
|
|
38
|
+
readonly contentType = 'application/json'
|
|
39
|
+
readonly accept = 'application/json'
|
|
40
|
+
|
|
41
|
+
readonly inputSchema = getCompaniesInputSchema
|
|
42
|
+
readonly outputSchema = getCompaniesResponseSchema
|
|
43
|
+
readonly querySchema = getCompaniesQuerySchema
|
|
44
|
+
readonly headersSchema = undefined
|
|
45
|
+
|
|
46
|
+
constructor(options?: { query?: GetCompaniesQueryParams }) {
|
|
47
|
+
super(undefined, options)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getPath(): string {
|
|
51
|
+
return '/point_of_sales'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<PointOfSale> {
|
|
55
|
+
const pointOfSales = z.array(pointOfSaleSchema).parse(data)
|
|
56
|
+
return this.validateOutput({
|
|
57
|
+
data: pointOfSales,
|
|
58
|
+
pagination: responseToPagination(rawResponse),
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { PointOfSaleDetails, pointOfSaleDetailsSchema, writablePointOfSaleSchema } from '../models'
|
|
5
|
+
|
|
6
|
+
export const updatePointOfSaleInputSchema = writablePointOfSaleSchema.partial()
|
|
7
|
+
export type UpdatePointOfSaleInput = z.infer<typeof updatePointOfSaleInputSchema>
|
|
8
|
+
|
|
9
|
+
export const updatePointOfSaleResponseSchema = pointOfSaleDetailsSchema
|
|
10
|
+
export type UpdatePointOfSaleResponse = PointOfSaleDetails
|
|
11
|
+
|
|
12
|
+
export class UpdatePointOfSale extends AbstractApiRequest<
|
|
13
|
+
UpdatePointOfSaleInput,
|
|
14
|
+
UpdatePointOfSaleResponse
|
|
15
|
+
> {
|
|
16
|
+
readonly method = 'PATCH'
|
|
17
|
+
readonly contentType = 'application/merge-patch+json'
|
|
18
|
+
readonly accept = 'application/json'
|
|
19
|
+
|
|
20
|
+
readonly inputSchema = updatePointOfSaleInputSchema
|
|
21
|
+
readonly outputSchema = updatePointOfSaleResponseSchema
|
|
22
|
+
readonly querySchema = undefined
|
|
23
|
+
readonly headersSchema = undefined
|
|
24
|
+
|
|
25
|
+
private readonly pointOfSaleId: string
|
|
26
|
+
|
|
27
|
+
constructor(pointOfSaleId: string, input: UpdatePointOfSaleInput) {
|
|
28
|
+
super(input)
|
|
29
|
+
this.pointOfSaleId = pointOfSaleId
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getPath(): string {
|
|
33
|
+
return `/point_of_sales/${this.pointOfSaleId}`
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const pointOfSaleOpeningStatuses = ['OPEN', 'CLOSED'] as const
|
|
4
|
+
export const pointOfSaleOpeningStatusSchema = z.enum(pointOfSaleOpeningStatuses)
|
|
5
|
+
export type PointOfSaleOpeningStatus = z.infer<typeof pointOfSaleOpeningStatusSchema>
|
|
6
|
+
|
|
7
|
+
export const pointOfSaleCapabilities = ['DELIVERY_OPTIMIZATION'] as const
|
|
8
|
+
export const pointOfSaleCapabilitySchema = z.enum(pointOfSaleCapabilities)
|
|
9
|
+
export type PointOfSaleCapability = z.infer<typeof pointOfSaleCapabilitySchema>
|
|
10
|
+
|
|
11
|
+
export const pointOfSaleUserRoles = ['ROLE_ADMIN', 'ROLE_READER'] as const
|
|
12
|
+
export const pointOfSaleUserRoleSchema = z.enum(pointOfSaleUserRoles)
|
|
13
|
+
export type PointOfSaleUserRole = z.infer<typeof pointOfSaleUserRoleSchema>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"outDir": "dist",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"]
|
|
15
|
+
}
|