@deliverart/sdk-js-user 0.3.1 → 1.1.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/package.json +10 -25
- package/.changeset/config.json +0 -11
- package/.github/workflows/workflow.yml +0 -47
- package/.prettierrc +0 -7
- package/CHANGELOG.md +0 -79
- package/README.md +0 -3
- package/dist/index.cjs +0 -303
- package/dist/index.d.cts +0 -782
- package/dist/index.d.ts +0 -782
- package/dist/index.js +0 -253
- package/eslint.config.js +0 -41
- package/src/index.ts +0 -3
- package/src/models.ts +0 -42
- package/src/requests/CreateUser.ts +0 -32
- package/src/requests/DeleteUser.ts +0 -30
- package/src/requests/GetMe.ts +0 -28
- package/src/requests/GetUserDetails.ts +0 -34
- package/src/requests/GetUsers.ts +0 -47
- package/src/requests/UpdateUser.ts +0 -35
- package/src/requests/index.ts +0 -6
- package/src/types.ts +0 -55
- package/tsconfig.json +0 -15
package/dist/index.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
// src/models.ts
|
|
2
|
-
import { datetimeSchema } from "@deliverart/sdk-js-global-types";
|
|
3
|
-
import { z as z2 } from "zod";
|
|
4
|
-
|
|
5
|
-
// src/types.ts
|
|
6
|
-
import { iriSchema } from "@deliverart/sdk-js-global-types";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
var securityRoles = [
|
|
9
|
-
// Role used for describe single operations
|
|
10
|
-
"ROLE_CUSTOMER_ACCESS",
|
|
11
|
-
"ROLE_BUNDLE_ACCESS",
|
|
12
|
-
"ROLE_DELIVERY_ACCESS",
|
|
13
|
-
"ROLE_POINT_OF_SALE_ACCESS",
|
|
14
|
-
"ROLE_MENU_ACCESS",
|
|
15
|
-
"ROLE_INTEGRATION_ACCESS",
|
|
16
|
-
"ROLE_ORDER_ACCESS",
|
|
17
|
-
"ROLE_LEAD_ACCESS",
|
|
18
|
-
"ROLE_COMPANY_ACCESS",
|
|
19
|
-
"ROLE_USER_ACCESS",
|
|
20
|
-
"ROLE_SUBSCRIPTION_ACCESS",
|
|
21
|
-
"ROLE_PAYMENT_ACCESS",
|
|
22
|
-
"ROLE_PAYMENT_CONFIG_ACCESS",
|
|
23
|
-
// Role ADMIN for single operations
|
|
24
|
-
"ROLE_CUSTOMER_ADMIN",
|
|
25
|
-
"ROLE_BUNDLE_ADMIN",
|
|
26
|
-
"ROLE_DELIVERY_ADMIN",
|
|
27
|
-
"ROLE_POINT_OF_SALE_ADMIN",
|
|
28
|
-
"ROLE_MENU_ADMIN",
|
|
29
|
-
"ROLE_INTEGRATION_ADMIN",
|
|
30
|
-
"ROLE_ORDER_ADMIN",
|
|
31
|
-
"ROLE_LEAD_ADMIN",
|
|
32
|
-
"ROLE_COMPANY_ADMIN",
|
|
33
|
-
"ROLE_USER_ADMIN",
|
|
34
|
-
"ROLE_SUBSCRIPTION_ADMIN",
|
|
35
|
-
"ROLE_PAYMENT_ADMIN",
|
|
36
|
-
"ROLE_PAYMENT_CONFIG_ADMIN",
|
|
37
|
-
// Role for the users
|
|
38
|
-
"ROLE_COURIER",
|
|
39
|
-
"ROLE_CUSTOMER",
|
|
40
|
-
"ROLE_MANAGER",
|
|
41
|
-
"ROLE_SUPER_ADMIN",
|
|
42
|
-
"ROLE_KITCHEN",
|
|
43
|
-
// Default user role
|
|
44
|
-
"ROLE_USER"
|
|
45
|
-
];
|
|
46
|
-
var securityRoleSchema = z.enum(securityRoles);
|
|
47
|
-
var userSteps = [
|
|
48
|
-
"registration",
|
|
49
|
-
"verify_email",
|
|
50
|
-
"create_company",
|
|
51
|
-
"create_point_of_sale"
|
|
52
|
-
];
|
|
53
|
-
var userStepSchema = z.enum(userSteps);
|
|
54
|
-
var userIriSchema = iriSchema("/users/:id");
|
|
55
|
-
|
|
56
|
-
// src/models.ts
|
|
57
|
-
var userSchema = z2.object({
|
|
58
|
-
id: z2.string(),
|
|
59
|
-
firstName: z2.string(),
|
|
60
|
-
lastName: z2.string(),
|
|
61
|
-
email: z2.string().email(),
|
|
62
|
-
roles: securityRoleSchema.array(),
|
|
63
|
-
completedSteps: userStepSchema.array(),
|
|
64
|
-
emailVerified: z2.boolean(),
|
|
65
|
-
suspended: z2.boolean(),
|
|
66
|
-
createdAt: datetimeSchema,
|
|
67
|
-
updatedAt: datetimeSchema
|
|
68
|
-
});
|
|
69
|
-
var writableUserSchema = userSchema.pick({
|
|
70
|
-
firstName: true,
|
|
71
|
-
lastName: true,
|
|
72
|
-
roles: true,
|
|
73
|
-
email: true
|
|
74
|
-
}).extend({
|
|
75
|
-
plainPassword: z2.string().optional()
|
|
76
|
-
}).partial();
|
|
77
|
-
var usersQuerySchema = z2.object({
|
|
78
|
-
email: z2.string().optional(),
|
|
79
|
-
firstName: z2.string().optional(),
|
|
80
|
-
lastName: z2.string().optional(),
|
|
81
|
-
suspended: z2.string().optional(),
|
|
82
|
-
"order[createdAt]": z2.enum(["asc", "desc"]).optional(),
|
|
83
|
-
page: z2.coerce.number().optional(),
|
|
84
|
-
"roles[]": z2.array(z2.enum(securityRoles)).optional()
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// src/requests/CreateUser.ts
|
|
88
|
-
import { AbstractApiRequest } from "@deliverart/sdk-js-core";
|
|
89
|
-
var createUserInputSchema = writableUserSchema.required();
|
|
90
|
-
var createUserResponseSchema = userSchema;
|
|
91
|
-
var CreateUser = class extends AbstractApiRequest {
|
|
92
|
-
method = "POST";
|
|
93
|
-
contentType = "application/json";
|
|
94
|
-
accept = "application/json";
|
|
95
|
-
inputSchema = createUserInputSchema;
|
|
96
|
-
outputSchema = createUserResponseSchema;
|
|
97
|
-
querySchema = void 0;
|
|
98
|
-
headersSchema = void 0;
|
|
99
|
-
constructor(input) {
|
|
100
|
-
super(input);
|
|
101
|
-
}
|
|
102
|
-
getPath() {
|
|
103
|
-
return "/users";
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// src/requests/DeleteUser.ts
|
|
108
|
-
import { AbstractApiRequest as AbstractApiRequest2 } from "@deliverart/sdk-js-core";
|
|
109
|
-
import { z as z3 } from "zod";
|
|
110
|
-
var deleteUserInputSchema = z3.undefined();
|
|
111
|
-
var deleteUserResponseSchema = z3.undefined();
|
|
112
|
-
var DeleteUser = class extends AbstractApiRequest2 {
|
|
113
|
-
method = "DELETE";
|
|
114
|
-
contentType = "application/json";
|
|
115
|
-
accept = "application/json";
|
|
116
|
-
inputSchema = deleteUserInputSchema;
|
|
117
|
-
outputSchema = deleteUserResponseSchema;
|
|
118
|
-
querySchema = void 0;
|
|
119
|
-
headersSchema = void 0;
|
|
120
|
-
userId;
|
|
121
|
-
constructor(userId) {
|
|
122
|
-
super(void 0);
|
|
123
|
-
this.userId = userId;
|
|
124
|
-
}
|
|
125
|
-
getPath() {
|
|
126
|
-
return `/users/${this.userId}`;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// src/requests/GetMe.ts
|
|
131
|
-
import { AbstractApiRequest as AbstractApiRequest3 } from "@deliverart/sdk-js-core";
|
|
132
|
-
import { z as z4 } from "zod";
|
|
133
|
-
var getMeInputSchema = z4.undefined();
|
|
134
|
-
var getMeResponseSchema = userSchema;
|
|
135
|
-
var GetMe = class extends AbstractApiRequest3 {
|
|
136
|
-
method = "GET";
|
|
137
|
-
contentType = "application/json";
|
|
138
|
-
accept = "application/json";
|
|
139
|
-
inputSchema = getMeInputSchema;
|
|
140
|
-
outputSchema = getMeResponseSchema;
|
|
141
|
-
querySchema = void 0;
|
|
142
|
-
headersSchema = void 0;
|
|
143
|
-
constructor() {
|
|
144
|
-
super(void 0);
|
|
145
|
-
}
|
|
146
|
-
getPath() {
|
|
147
|
-
return "/me";
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// src/requests/GetUserDetails.ts
|
|
152
|
-
import { AbstractApiRequest as AbstractApiRequest4 } from "@deliverart/sdk-js-core";
|
|
153
|
-
import { z as z5 } from "zod";
|
|
154
|
-
var getUserDetailsInputSchema = z5.undefined();
|
|
155
|
-
var getUserDetailsResponseSchema = userSchema;
|
|
156
|
-
var GetUserDetails = class extends AbstractApiRequest4 {
|
|
157
|
-
method = "GET";
|
|
158
|
-
contentType = "application/json";
|
|
159
|
-
accept = "application/json";
|
|
160
|
-
inputSchema = getUserDetailsInputSchema;
|
|
161
|
-
outputSchema = getUserDetailsResponseSchema;
|
|
162
|
-
querySchema = void 0;
|
|
163
|
-
headersSchema = void 0;
|
|
164
|
-
userId;
|
|
165
|
-
constructor(userId) {
|
|
166
|
-
super(void 0);
|
|
167
|
-
this.userId = userId;
|
|
168
|
-
}
|
|
169
|
-
getPath() {
|
|
170
|
-
return `/users/${this.userId}`;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// src/requests/GetUsers.ts
|
|
175
|
-
import { AbstractApiRequest as AbstractApiRequest5 } from "@deliverart/sdk-js-core";
|
|
176
|
-
import {
|
|
177
|
-
createPaginatedSchema,
|
|
178
|
-
responseToPagination
|
|
179
|
-
} from "@deliverart/sdk-js-global-types";
|
|
180
|
-
import { z as z6 } from "zod";
|
|
181
|
-
var getUsersQuerySchema = usersQuerySchema;
|
|
182
|
-
var getUsersInputSchema = z6.undefined();
|
|
183
|
-
var getUsersResponseSchema = createPaginatedSchema(userSchema);
|
|
184
|
-
var GetUsers = class extends AbstractApiRequest5 {
|
|
185
|
-
method = "GET";
|
|
186
|
-
contentType = "application/json";
|
|
187
|
-
accept = "application/json";
|
|
188
|
-
inputSchema = getUsersInputSchema;
|
|
189
|
-
outputSchema = getUsersResponseSchema;
|
|
190
|
-
querySchema = getUsersQuerySchema;
|
|
191
|
-
headersSchema = void 0;
|
|
192
|
-
constructor(options) {
|
|
193
|
-
super(void 0, options);
|
|
194
|
-
}
|
|
195
|
-
getPath() {
|
|
196
|
-
return "/users";
|
|
197
|
-
}
|
|
198
|
-
parseResponse(data, rawResponse) {
|
|
199
|
-
const users = z6.array(userSchema).parse(data);
|
|
200
|
-
return this.validateOutput({ data: users, pagination: responseToPagination(rawResponse) });
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// src/requests/UpdateUser.ts
|
|
205
|
-
import { AbstractApiRequest as AbstractApiRequest6 } from "@deliverart/sdk-js-core";
|
|
206
|
-
var updateUserInputSchema = writableUserSchema;
|
|
207
|
-
var updateUserResponseSchema = userSchema;
|
|
208
|
-
var UpdateUser = class extends AbstractApiRequest6 {
|
|
209
|
-
method = "PATCH";
|
|
210
|
-
contentType = "application/merge-patch+json";
|
|
211
|
-
accept = "application/json";
|
|
212
|
-
inputSchema = updateUserInputSchema;
|
|
213
|
-
outputSchema = updateUserResponseSchema;
|
|
214
|
-
querySchema = void 0;
|
|
215
|
-
headersSchema = void 0;
|
|
216
|
-
userId;
|
|
217
|
-
constructor(userId, input) {
|
|
218
|
-
super(input);
|
|
219
|
-
this.userId = userId;
|
|
220
|
-
}
|
|
221
|
-
getPath() {
|
|
222
|
-
return `/users/${this.userId}`;
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
export {
|
|
226
|
-
CreateUser,
|
|
227
|
-
DeleteUser,
|
|
228
|
-
GetMe,
|
|
229
|
-
GetUserDetails,
|
|
230
|
-
GetUsers,
|
|
231
|
-
UpdateUser,
|
|
232
|
-
createUserInputSchema,
|
|
233
|
-
createUserResponseSchema,
|
|
234
|
-
deleteUserInputSchema,
|
|
235
|
-
deleteUserResponseSchema,
|
|
236
|
-
getMeInputSchema,
|
|
237
|
-
getMeResponseSchema,
|
|
238
|
-
getUserDetailsInputSchema,
|
|
239
|
-
getUserDetailsResponseSchema,
|
|
240
|
-
getUsersInputSchema,
|
|
241
|
-
getUsersQuerySchema,
|
|
242
|
-
getUsersResponseSchema,
|
|
243
|
-
securityRoleSchema,
|
|
244
|
-
securityRoles,
|
|
245
|
-
updateUserInputSchema,
|
|
246
|
-
updateUserResponseSchema,
|
|
247
|
-
userIriSchema,
|
|
248
|
-
userSchema,
|
|
249
|
-
userStepSchema,
|
|
250
|
-
userSteps,
|
|
251
|
-
usersQuerySchema,
|
|
252
|
-
writableUserSchema
|
|
253
|
-
};
|
package/eslint.config.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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/src/index.ts
DELETED
package/src/models.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { datetimeSchema } from '@deliverart/sdk-js-global-types'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
import { securityRoles, securityRoleSchema, userStepSchema } from './types'
|
|
5
|
-
|
|
6
|
-
export const userSchema = z.object({
|
|
7
|
-
id: z.string(),
|
|
8
|
-
firstName: z.string(),
|
|
9
|
-
lastName: z.string(),
|
|
10
|
-
email: z.string().email(),
|
|
11
|
-
roles: securityRoleSchema.array(),
|
|
12
|
-
completedSteps: userStepSchema.array(),
|
|
13
|
-
emailVerified: z.boolean(),
|
|
14
|
-
suspended: z.boolean(),
|
|
15
|
-
createdAt: datetimeSchema,
|
|
16
|
-
updatedAt: datetimeSchema,
|
|
17
|
-
})
|
|
18
|
-
export type User = z.infer<typeof userSchema>
|
|
19
|
-
|
|
20
|
-
export const writableUserSchema = userSchema
|
|
21
|
-
.pick({
|
|
22
|
-
firstName: true,
|
|
23
|
-
lastName: true,
|
|
24
|
-
roles: true,
|
|
25
|
-
email: true,
|
|
26
|
-
})
|
|
27
|
-
.extend({
|
|
28
|
-
plainPassword: z.string().optional(),
|
|
29
|
-
})
|
|
30
|
-
.partial()
|
|
31
|
-
export type WritableUser = z.infer<typeof writableUserSchema>
|
|
32
|
-
|
|
33
|
-
export const usersQuerySchema = z.object({
|
|
34
|
-
email: z.string().optional(),
|
|
35
|
-
firstName: z.string().optional(),
|
|
36
|
-
lastName: z.string().optional(),
|
|
37
|
-
suspended: z.string().optional(),
|
|
38
|
-
'order[createdAt]': z.enum(['asc', 'desc']).optional(),
|
|
39
|
-
page: z.coerce.number().optional(),
|
|
40
|
-
'roles[]': z.array(z.enum(securityRoles)).optional(),
|
|
41
|
-
})
|
|
42
|
-
export type UsersQueryParams = z.infer<typeof usersQuerySchema>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
import { userSchema, writableUserSchema } from '../models'
|
|
5
|
-
|
|
6
|
-
export const createUserInputSchema = writableUserSchema.required()
|
|
7
|
-
export type CreateUserInput = z.input<typeof createUserInputSchema>
|
|
8
|
-
|
|
9
|
-
export const createUserResponseSchema = userSchema
|
|
10
|
-
export type CreateUserResponse = z.output<typeof createUserResponseSchema>
|
|
11
|
-
|
|
12
|
-
export class CreateUser extends AbstractApiRequest<
|
|
13
|
-
typeof createUserInputSchema,
|
|
14
|
-
typeof createUserResponseSchema
|
|
15
|
-
> {
|
|
16
|
-
readonly method = 'POST'
|
|
17
|
-
readonly contentType = 'application/json'
|
|
18
|
-
readonly accept = 'application/json'
|
|
19
|
-
|
|
20
|
-
readonly inputSchema = createUserInputSchema
|
|
21
|
-
readonly outputSchema = createUserResponseSchema
|
|
22
|
-
readonly querySchema = undefined
|
|
23
|
-
readonly headersSchema = undefined
|
|
24
|
-
|
|
25
|
-
constructor(input: z.input<typeof createUserInputSchema>) {
|
|
26
|
-
super(input)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getPath(): string {
|
|
30
|
-
return '/users'
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
export const deleteUserInputSchema = z.undefined()
|
|
5
|
-
export const deleteUserResponseSchema = z.undefined()
|
|
6
|
-
|
|
7
|
-
export class DeleteUser extends AbstractApiRequest<
|
|
8
|
-
typeof deleteUserInputSchema,
|
|
9
|
-
typeof deleteUserResponseSchema
|
|
10
|
-
> {
|
|
11
|
-
readonly method = 'DELETE'
|
|
12
|
-
readonly contentType = 'application/json'
|
|
13
|
-
readonly accept = 'application/json'
|
|
14
|
-
|
|
15
|
-
readonly inputSchema = deleteUserInputSchema
|
|
16
|
-
readonly outputSchema = deleteUserResponseSchema
|
|
17
|
-
readonly querySchema = undefined
|
|
18
|
-
readonly headersSchema = undefined
|
|
19
|
-
|
|
20
|
-
private readonly userId: string
|
|
21
|
-
|
|
22
|
-
constructor(userId: string) {
|
|
23
|
-
super(undefined)
|
|
24
|
-
this.userId = userId
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getPath(): string {
|
|
28
|
-
return `/users/${this.userId}`
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/requests/GetMe.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
import { userSchema } from '../models'
|
|
5
|
-
|
|
6
|
-
export const getMeInputSchema = z.undefined()
|
|
7
|
-
export type GetMeInput = z.input<typeof getMeInputSchema>
|
|
8
|
-
|
|
9
|
-
export const getMeResponseSchema = userSchema
|
|
10
|
-
export type GetMeResponse = z.output<typeof getMeResponseSchema>
|
|
11
|
-
|
|
12
|
-
export class GetMe extends AbstractApiRequest<typeof getMeInputSchema, typeof getMeResponseSchema> {
|
|
13
|
-
readonly method = 'GET'
|
|
14
|
-
readonly contentType = 'application/json'
|
|
15
|
-
readonly accept = 'application/json'
|
|
16
|
-
readonly inputSchema = getMeInputSchema
|
|
17
|
-
readonly outputSchema = getMeResponseSchema
|
|
18
|
-
readonly querySchema = undefined
|
|
19
|
-
readonly headersSchema = undefined
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
super(undefined)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getPath(): string {
|
|
26
|
-
return '/me'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
import { userSchema } from '../models'
|
|
5
|
-
|
|
6
|
-
export const getUserDetailsInputSchema = z.undefined()
|
|
7
|
-
export type GetUserDetailsInput = z.input<typeof getUserDetailsInputSchema>
|
|
8
|
-
|
|
9
|
-
export const getUserDetailsResponseSchema = userSchema
|
|
10
|
-
export type GetUserDetailsResponse = z.infer<typeof getUserDetailsResponseSchema>
|
|
11
|
-
|
|
12
|
-
export class GetUserDetails extends AbstractApiRequest<
|
|
13
|
-
typeof getUserDetailsInputSchema,
|
|
14
|
-
typeof getUserDetailsResponseSchema
|
|
15
|
-
> {
|
|
16
|
-
readonly method = 'GET'
|
|
17
|
-
readonly contentType = 'application/json'
|
|
18
|
-
readonly accept = 'application/json'
|
|
19
|
-
readonly inputSchema = getUserDetailsInputSchema
|
|
20
|
-
readonly outputSchema = getUserDetailsResponseSchema
|
|
21
|
-
readonly querySchema = undefined
|
|
22
|
-
readonly headersSchema = undefined
|
|
23
|
-
|
|
24
|
-
private readonly userId: string
|
|
25
|
-
|
|
26
|
-
constructor(userId: string) {
|
|
27
|
-
super(undefined)
|
|
28
|
-
this.userId = userId
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getPath(): string {
|
|
32
|
-
return `/users/${this.userId}`
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/requests/GetUsers.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
-
import {
|
|
3
|
-
createPaginatedSchema,
|
|
4
|
-
Paginated,
|
|
5
|
-
responseToPagination,
|
|
6
|
-
} from '@deliverart/sdk-js-global-types'
|
|
7
|
-
import { AxiosResponse } from 'axios'
|
|
8
|
-
import { z } from 'zod'
|
|
9
|
-
|
|
10
|
-
import { User, userSchema, usersQuerySchema } from '../models'
|
|
11
|
-
|
|
12
|
-
export const getUsersQuerySchema = usersQuerySchema
|
|
13
|
-
export type GetUsersQueryParams = z.infer<typeof getUsersQuerySchema>
|
|
14
|
-
|
|
15
|
-
export const getUsersInputSchema = z.undefined()
|
|
16
|
-
export type GetUsersInput = z.input<typeof getUsersInputSchema>
|
|
17
|
-
|
|
18
|
-
export const getUsersResponseSchema = createPaginatedSchema(userSchema)
|
|
19
|
-
export type GetUsersResponse = z.infer<typeof getUsersResponseSchema>
|
|
20
|
-
|
|
21
|
-
export class GetUsers extends AbstractApiRequest<
|
|
22
|
-
typeof getUsersInputSchema,
|
|
23
|
-
typeof getUsersResponseSchema,
|
|
24
|
-
GetUsersQueryParams
|
|
25
|
-
> {
|
|
26
|
-
readonly method = 'GET'
|
|
27
|
-
readonly contentType = 'application/json'
|
|
28
|
-
readonly accept = 'application/json'
|
|
29
|
-
|
|
30
|
-
readonly inputSchema = getUsersInputSchema
|
|
31
|
-
readonly outputSchema = getUsersResponseSchema
|
|
32
|
-
readonly querySchema = getUsersQuerySchema
|
|
33
|
-
readonly headersSchema = undefined
|
|
34
|
-
|
|
35
|
-
constructor(options?: { query?: GetUsersQueryParams }) {
|
|
36
|
-
super(undefined, options)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getPath(): string {
|
|
40
|
-
return '/users'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<User> {
|
|
44
|
-
const users = z.array(userSchema).parse(data)
|
|
45
|
-
return this.validateOutput({ data: users, pagination: responseToPagination(rawResponse) })
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
import { userSchema, writableUserSchema } from '../models'
|
|
5
|
-
|
|
6
|
-
export const updateUserInputSchema = writableUserSchema
|
|
7
|
-
export type UpdateUserInput = z.input<typeof updateUserInputSchema>
|
|
8
|
-
|
|
9
|
-
export const updateUserResponseSchema = userSchema
|
|
10
|
-
export type UpdateUserResponse = z.infer<typeof updateUserResponseSchema>
|
|
11
|
-
|
|
12
|
-
export class UpdateUser extends AbstractApiRequest<
|
|
13
|
-
typeof updateUserInputSchema,
|
|
14
|
-
typeof updateUserResponseSchema
|
|
15
|
-
> {
|
|
16
|
-
readonly method = 'PATCH'
|
|
17
|
-
readonly contentType = 'application/merge-patch+json'
|
|
18
|
-
readonly accept = 'application/json'
|
|
19
|
-
|
|
20
|
-
readonly inputSchema = updateUserInputSchema
|
|
21
|
-
readonly outputSchema = updateUserResponseSchema
|
|
22
|
-
readonly querySchema = undefined
|
|
23
|
-
readonly headersSchema = undefined
|
|
24
|
-
|
|
25
|
-
private readonly userId: string
|
|
26
|
-
|
|
27
|
-
constructor(userId: string, input: z.input<typeof updateUserInputSchema>) {
|
|
28
|
-
super(input)
|
|
29
|
-
this.userId = userId
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getPath(): string {
|
|
33
|
-
return `/users/${this.userId}`
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/requests/index.ts
DELETED
package/src/types.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { iriSchema } from '@deliverart/sdk-js-global-types'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
export const securityRoles = [
|
|
5
|
-
// Role used for describe single operations
|
|
6
|
-
'ROLE_CUSTOMER_ACCESS',
|
|
7
|
-
'ROLE_BUNDLE_ACCESS',
|
|
8
|
-
'ROLE_DELIVERY_ACCESS',
|
|
9
|
-
'ROLE_POINT_OF_SALE_ACCESS',
|
|
10
|
-
'ROLE_MENU_ACCESS',
|
|
11
|
-
'ROLE_INTEGRATION_ACCESS',
|
|
12
|
-
'ROLE_ORDER_ACCESS',
|
|
13
|
-
'ROLE_LEAD_ACCESS',
|
|
14
|
-
'ROLE_COMPANY_ACCESS',
|
|
15
|
-
'ROLE_USER_ACCESS',
|
|
16
|
-
'ROLE_SUBSCRIPTION_ACCESS',
|
|
17
|
-
'ROLE_PAYMENT_ACCESS',
|
|
18
|
-
'ROLE_PAYMENT_CONFIG_ACCESS',
|
|
19
|
-
// Role ADMIN for single operations
|
|
20
|
-
'ROLE_CUSTOMER_ADMIN',
|
|
21
|
-
'ROLE_BUNDLE_ADMIN',
|
|
22
|
-
'ROLE_DELIVERY_ADMIN',
|
|
23
|
-
'ROLE_POINT_OF_SALE_ADMIN',
|
|
24
|
-
'ROLE_MENU_ADMIN',
|
|
25
|
-
'ROLE_INTEGRATION_ADMIN',
|
|
26
|
-
'ROLE_ORDER_ADMIN',
|
|
27
|
-
'ROLE_LEAD_ADMIN',
|
|
28
|
-
'ROLE_COMPANY_ADMIN',
|
|
29
|
-
'ROLE_USER_ADMIN',
|
|
30
|
-
'ROLE_SUBSCRIPTION_ADMIN',
|
|
31
|
-
'ROLE_PAYMENT_ADMIN',
|
|
32
|
-
'ROLE_PAYMENT_CONFIG_ADMIN',
|
|
33
|
-
// Role for the users
|
|
34
|
-
'ROLE_COURIER',
|
|
35
|
-
'ROLE_CUSTOMER',
|
|
36
|
-
'ROLE_MANAGER',
|
|
37
|
-
'ROLE_SUPER_ADMIN',
|
|
38
|
-
'ROLE_KITCHEN',
|
|
39
|
-
// Default user role
|
|
40
|
-
'ROLE_USER',
|
|
41
|
-
] as const
|
|
42
|
-
export const securityRoleSchema = z.enum(securityRoles)
|
|
43
|
-
export type SecurityRole = z.infer<typeof securityRoleSchema>
|
|
44
|
-
|
|
45
|
-
export const userSteps = [
|
|
46
|
-
'registration',
|
|
47
|
-
'verify_email',
|
|
48
|
-
'create_company',
|
|
49
|
-
'create_point_of_sale',
|
|
50
|
-
] as const
|
|
51
|
-
export const userStepSchema = z.enum(userSteps)
|
|
52
|
-
export type UserStep = z.infer<typeof userStepSchema>
|
|
53
|
-
|
|
54
|
-
export const userIriSchema = iriSchema('/users/:id')
|
|
55
|
-
export type UserIri = z.infer<typeof userIriSchema>
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|