@deliverart/sdk-js-integration 0.0.2 → 0.0.4

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/index.js CHANGED
@@ -87,7 +87,9 @@ var integrationCassaInCloudWebHookEventEventSchema = z.enum(
87
87
  integrationCassaInCloudWebHookEventEvents
88
88
  );
89
89
  function createIntegrationPathSchemas(service) {
90
- const regex = new RegExp(`^/integrations/${service}/[a-z_]+/[0-9a-fA-F-]{36}$`);
90
+ const regex = new RegExp(
91
+ `^/integrations/${service}/[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}$`
92
+ );
91
93
  const pathSchema = z.string().refine((val) => regex.test(val), {
92
94
  message: `Invalid integration ${service} path format`
93
95
  });
@@ -96,15 +98,36 @@ function createIntegrationPathSchemas(service) {
96
98
  });
97
99
  return { pathSchema, nullablePathSchema };
98
100
  }
101
+ function createIntegrationMenuVersionPathSchemas(service) {
102
+ const regex = new RegExp(
103
+ `^/integrations/${service}/[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}/menu_versions/[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}$`
104
+ );
105
+ const pathSchema = z.string().refine((val) => regex.test(val), {
106
+ message: `Invalid integration ${service} menu version path format`
107
+ });
108
+ const nullablePathSchema = z.string().nullable().refine((val) => val == null || regex.test(val), {
109
+ message: `Invalid integration ${service} menu version path format`
110
+ });
111
+ return { pathSchema, nullablePathSchema };
112
+ }
99
113
  var integrationPathSchemas = Object.fromEntries(
100
114
  integrationServices.map((service) => [service, createIntegrationPathSchemas(service)])
101
115
  );
116
+ var integrationMenuVersionPathSchemas = Object.fromEntries(
117
+ integrationServices.map((service) => [service, createIntegrationMenuVersionPathSchemas(service)])
118
+ );
102
119
  var integrationDeliverooPathSchema = integrationPathSchemas.deliveroo.pathSchema;
103
120
  var integrationDeliverooNullablePathSchema = integrationPathSchemas.deliveroo.nullablePathSchema;
121
+ var integrationDeliverooMenuVersionPathSchema = integrationMenuVersionPathSchemas.deliveroo.pathSchema;
122
+ var integrationDeliverooMenuVersionNullablePathSchema = integrationMenuVersionPathSchemas.deliveroo.nullablePathSchema;
104
123
  var integrationGlovoPathSchema = integrationPathSchemas.glovo.pathSchema;
105
124
  var integrationGlovoNullablePathSchema = integrationPathSchemas.glovo.nullablePathSchema;
125
+ var integrationGlovoMenuVersionPathSchema = integrationMenuVersionPathSchemas.glovo.pathSchema;
126
+ var integrationGlovoMenuVersionNullablePathSchema = integrationMenuVersionPathSchemas.glovo.nullablePathSchema;
106
127
  var integrationJustEatPathSchema = integrationPathSchemas.justeat.pathSchema;
107
128
  var integrationJustEatNullablePathSchema = integrationPathSchemas.justeat.nullablePathSchema;
129
+ var integrationJustEatMenuVersionPathSchema = integrationMenuVersionPathSchemas.justeat.pathSchema;
130
+ var integrationJustEatMenuVersionNullablePathSchema = integrationMenuVersionPathSchemas.justeat.nullablePathSchema;
108
131
  var integrationCassaInCloudPathSchema = integrationPathSchemas.cassa_in_cloud.pathSchema;
109
132
  var integrationCassaInCloudNullablePathSchema = integrationPathSchemas.cassa_in_cloud.nullablePathSchema;
110
133
  var integrationPathSchema = z.string().refine(
@@ -811,9 +834,13 @@ var integrationDeliveryProviderCommonSchema = z23.object({
811
834
  importTaggedItems: z23.boolean(),
812
835
  tagsForImport: z23.array(z23.string()).optional(),
813
836
  isValidMenu: z23.boolean(),
814
- latestMenuSyncAt: datetimeSchema3,
815
- latestMenuCheckAt: datetimeSchema3,
816
- currentMenuVersion: menuVersionSchema.nullable(),
837
+ latestMenuSyncAt: datetimeSchema3.nullable(),
838
+ latestMenuCheckAt: datetimeSchema3.nullable(),
839
+ currentMenuVersion: z23.union([
840
+ integrationDeliverooMenuVersionNullablePathSchema,
841
+ integrationGlovoMenuVersionNullablePathSchema,
842
+ integrationJustEatMenuVersionNullablePathSchema
843
+ ]),
817
844
  salesMode: salesModeNullablePathSchema
818
845
  });
819
846
  var integrationClientLogRequestSchema = z23.object({
@@ -1174,7 +1201,7 @@ var integrationJustEatSchema = integrationBaseSchema.omit({ service: true }).ext
1174
1201
  syncType: integrationJustEatSyncTypeSchema,
1175
1202
  defaultLanguage: z27.string(),
1176
1203
  restaurantId: z27.string(),
1177
- latestOpeningTimesSyncAt: datetimeSchema7,
1204
+ latestOpeningTimesSyncAt: datetimeSchema7.nullable(),
1178
1205
  service: integrationServiceSchema.extract(["justeat"]),
1179
1206
  autoAcceptOrders: z27.boolean(),
1180
1207
  nextSyncMenuScheduledAt: datetimeSchema7.nullable()
@@ -3321,6 +3348,8 @@ export {
3321
3348
  integrationClientLogRequestMethods,
3322
3349
  integrationClientLogRequestSchema,
3323
3350
  integrationDeliverooDataSchema,
3351
+ integrationDeliverooMenuVersionNullablePathSchema,
3352
+ integrationDeliverooMenuVersionPathSchema,
3324
3353
  integrationDeliverooNullablePathSchema,
3325
3354
  integrationDeliverooPathSchema,
3326
3355
  integrationDeliverooSiteStatusSchema,
@@ -3338,6 +3367,8 @@ export {
3338
3367
  integrationGlovoDataSchema,
3339
3368
  integrationGlovoMenuUpdateStatusSchema,
3340
3369
  integrationGlovoMenuUpdateStatuses,
3370
+ integrationGlovoMenuVersionNullablePathSchema,
3371
+ integrationGlovoMenuVersionPathSchema,
3341
3372
  integrationGlovoNullablePathSchema,
3342
3373
  integrationGlovoPathSchema,
3343
3374
  integrationGlovoStoreStatusSchema,
@@ -3347,6 +3378,8 @@ export {
3347
3378
  integrationGlovoWebhookEventTypeSchema,
3348
3379
  integrationGlovoWebhookEventTypes,
3349
3380
  integrationJustEatDataSchema,
3381
+ integrationJustEatMenuVersionNullablePathSchema,
3382
+ integrationJustEatMenuVersionPathSchema,
3350
3383
  integrationJustEatNullablePathSchema,
3351
3384
  integrationJustEatPathSchema,
3352
3385
  integrationJustEatRestaurantStatusSchema,
@@ -3357,6 +3390,7 @@ export {
3357
3390
  integrationJustEatSyncOpeningHoursResponseSchema,
3358
3391
  integrationJustEatSyncTypeSchema,
3359
3392
  integrationJustEatSyncTypes,
3393
+ integrationMenuVersionPathSchemas,
3360
3394
  integrationNullablePathSchema,
3361
3395
  integrationPathSchema,
3362
3396
  integrationPathSchemas,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-integration",
3
3
  "description": "Deliverart JavaScript SDK for Integration Management",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/src/schemas.ts CHANGED
@@ -6,6 +6,9 @@ import { z } from 'zod'
6
6
  import { integrationCancellationRequestNullablePathSchema } from './cancellation-request-types'
7
7
  import {
8
8
  integrationClientLogRequestMethodSchema,
9
+ integrationDeliverooMenuVersionNullablePathSchema,
10
+ integrationGlovoMenuVersionNullablePathSchema,
11
+ integrationJustEatMenuVersionNullablePathSchema,
9
12
  integrationPathSchema,
10
13
  integrationProviderSchema,
11
14
  integrationServiceSchema,
@@ -53,9 +56,13 @@ export const integrationDeliveryProviderCommonSchema = z.object({
53
56
  importTaggedItems: z.boolean(),
54
57
  tagsForImport: z.array(z.string()).optional(),
55
58
  isValidMenu: z.boolean(),
56
- latestMenuSyncAt: datetimeSchema,
57
- latestMenuCheckAt: datetimeSchema,
58
- currentMenuVersion: menuVersionSchema.nullable(),
59
+ latestMenuSyncAt: datetimeSchema.nullable(),
60
+ latestMenuCheckAt: datetimeSchema.nullable(),
61
+ currentMenuVersion: z.union([
62
+ integrationDeliverooMenuVersionNullablePathSchema,
63
+ integrationGlovoMenuVersionNullablePathSchema,
64
+ integrationJustEatMenuVersionNullablePathSchema,
65
+ ]),
59
66
  salesMode: salesModeNullablePathSchema,
60
67
  })
61
68
 
@@ -24,7 +24,7 @@ export const integrationJustEatSchema = integrationBaseSchema
24
24
  syncType: integrationJustEatSyncTypeSchema,
25
25
  defaultLanguage: z.string(),
26
26
  restaurantId: z.string(),
27
- latestOpeningTimesSyncAt: datetimeSchema,
27
+ latestOpeningTimesSyncAt: datetimeSchema.nullable(),
28
28
  service: integrationServiceSchema.extract(['justeat']),
29
29
  autoAcceptOrders: z.boolean(),
30
30
  nextSyncMenuScheduledAt: datetimeSchema.nullable(),
package/src/types.ts CHANGED
@@ -132,7 +132,9 @@ export type IntegrationCassaInCloudWebHookEventEvent = z.infer<
132
132
  >
133
133
 
134
134
  function createIntegrationPathSchemas(service: IntegrationService) {
135
- const regex = new RegExp(`^/integrations/${service}/[a-z_]+/[0-9a-fA-F-]{36}$`)
135
+ const regex = new RegExp(
136
+ `^/integrations/${service}/[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}$`,
137
+ )
136
138
 
137
139
  const pathSchema = z.string().refine(val => regex.test(val), {
138
140
  message: `Invalid integration ${service} path format`,
@@ -148,10 +150,33 @@ function createIntegrationPathSchemas(service: IntegrationService) {
148
150
  return { pathSchema, nullablePathSchema }
149
151
  }
150
152
 
153
+ function createIntegrationMenuVersionPathSchemas(service: IntegrationService) {
154
+ const regex = new RegExp(
155
+ `^/integrations/${service}/[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}/menu_versions/[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}$`,
156
+ )
157
+
158
+ const pathSchema = z.string().refine(val => regex.test(val), {
159
+ message: `Invalid integration ${service} menu version path format`,
160
+ })
161
+
162
+ const nullablePathSchema = z
163
+ .string()
164
+ .nullable()
165
+ .refine(val => val == null || regex.test(val), {
166
+ message: `Invalid integration ${service} menu version path format`,
167
+ })
168
+
169
+ return { pathSchema, nullablePathSchema }
170
+ }
171
+
151
172
  export const integrationPathSchemas = Object.fromEntries(
152
173
  integrationServices.map(service => [service, createIntegrationPathSchemas(service)]),
153
174
  ) as Record<IntegrationService, ReturnType<typeof createIntegrationPathSchemas>>
154
175
 
176
+ export const integrationMenuVersionPathSchemas = Object.fromEntries(
177
+ integrationServices.map(service => [service, createIntegrationMenuVersionPathSchemas(service)]),
178
+ ) as Record<IntegrationService, ReturnType<typeof createIntegrationMenuVersionPathSchemas>>
179
+
155
180
  export const integrationDeliverooPathSchema = integrationPathSchemas.deliveroo.pathSchema
156
181
  export const integrationDeliverooNullablePathSchema =
157
182
  integrationPathSchemas.deliveroo.nullablePathSchema
@@ -160,17 +185,48 @@ export type IntegrationDeliverooNullablePath = z.infer<
160
185
  typeof integrationDeliverooNullablePathSchema
161
186
  >
162
187
 
188
+ export const integrationDeliverooMenuVersionPathSchema =
189
+ integrationMenuVersionPathSchemas.deliveroo.pathSchema
190
+ export const integrationDeliverooMenuVersionNullablePathSchema =
191
+ integrationMenuVersionPathSchemas.deliveroo.nullablePathSchema
192
+ export type IntegrationDeliverooMenuVersionPath = z.infer<
193
+ typeof integrationDeliverooMenuVersionPathSchema
194
+ >
195
+ export type IntegrationDeliverooMenuVersionNullablePath = z.infer<
196
+ typeof integrationDeliverooMenuVersionNullablePathSchema
197
+ >
198
+
163
199
  export const integrationGlovoPathSchema = integrationPathSchemas.glovo.pathSchema
164
200
  export const integrationGlovoNullablePathSchema = integrationPathSchemas.glovo.nullablePathSchema
165
201
  export type IntegrationGlovoPath = z.infer<typeof integrationGlovoPathSchema>
166
202
  export type IntegrationGlovoNullablePath = z.infer<typeof integrationGlovoNullablePathSchema>
167
203
 
204
+ export const integrationGlovoMenuVersionPathSchema =
205
+ integrationMenuVersionPathSchemas.glovo.pathSchema
206
+ export const integrationGlovoMenuVersionNullablePathSchema =
207
+ integrationMenuVersionPathSchemas.glovo.nullablePathSchema
208
+ export type IntegrationGlovoMenuVersionPath = z.infer<typeof integrationGlovoMenuVersionPathSchema>
209
+ export type IntegrationGlovoMenuVersionNullablePath = z.infer<
210
+ typeof integrationGlovoMenuVersionNullablePathSchema
211
+ >
212
+
168
213
  export const integrationJustEatPathSchema = integrationPathSchemas.justeat.pathSchema
169
214
  export const integrationJustEatNullablePathSchema =
170
215
  integrationPathSchemas.justeat.nullablePathSchema
171
216
  export type IntegrationJustEatPath = z.infer<typeof integrationJustEatPathSchema>
172
217
  export type IntegrationJustEatNullablePath = z.infer<typeof integrationJustEatNullablePathSchema>
173
218
 
219
+ export const integrationJustEatMenuVersionPathSchema =
220
+ integrationMenuVersionPathSchemas.justeat.pathSchema
221
+ export const integrationJustEatMenuVersionNullablePathSchema =
222
+ integrationMenuVersionPathSchemas.justeat.nullablePathSchema
223
+ export type IntegrationJustEatMenuVersionPath = z.infer<
224
+ typeof integrationJustEatMenuVersionPathSchema
225
+ >
226
+ export type IntegrationJustEatMenuVersionNullablePath = z.infer<
227
+ typeof integrationJustEatMenuVersionNullablePathSchema
228
+ >
229
+
174
230
  export const integrationCassaInCloudPathSchema = integrationPathSchemas.cassa_in_cloud.pathSchema
175
231
  export const integrationCassaInCloudNullablePathSchema =
176
232
  integrationPathSchemas.cassa_in_cloud.nullablePathSchema