@flipdish/events 1.25350.0 → 1.25352.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.
@@ -0,0 +1,10 @@
1
+ import currencyCodes from 'currency-codes';
2
+ import { z } from 'zod';
3
+ // Currency Code Schema to validate ISO 4217 currency codes
4
+ export const CurrencyCodeSchema = z
5
+ .string()
6
+ .trim()
7
+ .toUpperCase()
8
+ .pipe(z.string().refine((code) => Boolean(currencyCodes.code(code)), {
9
+ message: 'Invalid ISO 4217 currency code',
10
+ }));
@@ -0,0 +1,15 @@
1
+ import currencyCodes from 'currency-codes';
2
+ import { z } from 'zod';
3
+
4
+ // Currency Code Schema to validate ISO 4217 currency codes
5
+ export const CurrencyCodeSchema = z
6
+ .string()
7
+ .trim()
8
+ .toUpperCase()
9
+ .pipe(
10
+ z.string().refine((code) => Boolean(currencyCodes.code(code)), {
11
+ message: 'Invalid ISO 4217 currency code',
12
+ })
13
+ );
14
+
15
+ export type Currency = z.infer<typeof CurrencyCodeSchema>;
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { CurrencyCodeSchema } from './currency.js';
2
3
  import { OnlineOrderingCommonPropertiesSchema, OnlineOrderingMenusSource, } from './online.ordering.common.js';
3
4
  // Event types defined locally to avoid circular imports
4
5
  export const PreProcessEventTypes = {
@@ -220,6 +221,7 @@ export const OnlineOrderingMenuPreprocessSuccessV1PublicMenuSchema = z.object({
220
221
  legacyId: z.number(),
221
222
  name: z.string().nullable(),
222
223
  type: z.string(),
224
+ currency: CurrencyCodeSchema,
223
225
  categories: z.array(MenuCategoriesSchema).nullable(),
224
226
  categoryGroups: z.array(MenuCategoryGroupSchema).nullable(),
225
227
  taxType: TaxTypeSchema,
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { CurrencyCodeSchema } from './currency.js';
2
3
  import {
3
4
  OnlineOrderingCommonPropertiesSchema,
4
5
  OnlineOrderingMenusSource,
@@ -287,6 +288,7 @@ export const OnlineOrderingMenuPreprocessSuccessV1PublicMenuSchema = z.object({
287
288
  legacyId: z.number(),
288
289
  name: z.string().nullable(),
289
290
  type: z.string(),
291
+ currency: CurrencyCodeSchema,
290
292
  categories: z.array(MenuCategoriesSchema).nullable(),
291
293
  categoryGroups: z.array(MenuCategoryGroupSchema).nullable(),
292
294
  taxType: TaxTypeSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/events",
3
- "version": "1.25350.0",
3
+ "version": "1.25352.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --max-old-space-size=4096 --max-semi-space-size=512 ./node_modules/.bin/jest --config=jest.config.ts --verbose",
@@ -27,6 +27,7 @@
27
27
  "@jest/types": "^29.6.3",
28
28
  "@types/node": "^22.13.9",
29
29
  "aws-sdk": "^2.1692.0",
30
+ "currency-codes": "^2.2.0",
30
31
  "dotenv": "^16.3.1",
31
32
  "zod": "^3.24.2"
32
33
  },
@@ -1,17 +1,17 @@
1
1
  import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
2
2
  import { z } from 'zod';
3
- import { eventType as SALE_DELIVERY_STATUS_UPDATED_V1, SaleDeliveryStatusUpdatedV1Schema, } from './sales.delivery.status.updated.v1.js';
4
- import { eventType as SALE_STATUS_UPDATED_V1, SaleStatusUpdatedV1Schema, } from './sales.status.updated.v1.js';
3
+ import { eventType as SALES_DELIVERY_STATUS_UPDATED_V1, SalesDeliveryStatusUpdatedV1Schema, } from './sales.delivery.status.updated.v1.js';
4
+ import { eventType as SALES_POS_STATUS_UPDATED_V1, SalesPosStatusUpdatedV1Schema, } from './sales.pos.status.updated.v1.js';
5
5
  // This must be called before defining any schemas
6
6
  extendZodWithOpenApi(z);
7
- export { SaleStatusUpdatedV1Schema };
8
- export { SaleDeliveryStatusUpdatedV1Schema };
7
+ export { SalesPosStatusUpdatedV1Schema };
8
+ export { SalesDeliveryStatusUpdatedV1Schema };
9
9
  // Export event types
10
10
  export const eventTypes = {
11
- SALE_STATUS_UPDATED_V1,
12
- SALE_DELIVERY_STATUS_UPDATED_V1,
11
+ SALES_POS_STATUS_UPDATED_V1,
12
+ SALES_DELIVERY_STATUS_UPDATED_V1,
13
13
  };
14
14
  export const eventSchemaMap = Object.fromEntries([
15
- [SALE_STATUS_UPDATED_V1, SaleStatusUpdatedV1Schema],
16
- [SALE_DELIVERY_STATUS_UPDATED_V1, SaleDeliveryStatusUpdatedV1Schema],
15
+ [SALES_POS_STATUS_UPDATED_V1, SalesPosStatusUpdatedV1Schema],
16
+ [SALES_DELIVERY_STATUS_UPDATED_V1, SalesDeliveryStatusUpdatedV1Schema],
17
17
  ]);
@@ -1,31 +1,31 @@
1
1
  import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
2
2
  import { z } from 'zod';
3
3
  import {
4
- eventType as SALE_DELIVERY_STATUS_UPDATED_V1,
5
- SaleDeliveryStatusUpdatedV1Schema,
4
+ eventType as SALES_DELIVERY_STATUS_UPDATED_V1,
5
+ SalesDeliveryStatusUpdatedV1Schema,
6
6
  } from './sales.delivery.status.updated.v1.js';
7
7
  import {
8
- eventType as SALE_STATUS_UPDATED_V1,
9
- SaleStatusUpdatedV1Schema,
10
- } from './sales.status.updated.v1.js';
8
+ eventType as SALES_POS_STATUS_UPDATED_V1,
9
+ SalesPosStatusUpdatedV1Schema,
10
+ } from './sales.pos.status.updated.v1.js';
11
11
 
12
12
  // This must be called before defining any schemas
13
13
  extendZodWithOpenApi(z);
14
14
 
15
- export { SaleStatusUpdatedV1Schema };
16
- export { SaleDeliveryStatusUpdatedV1Schema };
15
+ export { SalesPosStatusUpdatedV1Schema };
16
+ export { SalesDeliveryStatusUpdatedV1Schema };
17
17
 
18
18
  // Re-export specific types from each module with renamed exports to avoid conflicts.
19
- export type { SaleStatusUpdatedV1 } from './sales.status.updated.v1.js';
20
- export type { SaleDeliveryStatusUpdatedV1 } from './sales.delivery.status.updated.v1.js';
19
+ export type { SalesPosStatusUpdatedV1 } from './sales.pos.status.updated.v1.js';
20
+ export type { SalesDeliveryStatusUpdatedV1 } from './sales.delivery.status.updated.v1.js';
21
21
 
22
22
  // Export event types
23
23
  export const eventTypes = {
24
- SALE_STATUS_UPDATED_V1,
25
- SALE_DELIVERY_STATUS_UPDATED_V1,
24
+ SALES_POS_STATUS_UPDATED_V1,
25
+ SALES_DELIVERY_STATUS_UPDATED_V1,
26
26
  };
27
27
 
28
28
  export const eventSchemaMap = Object.fromEntries([
29
- [SALE_STATUS_UPDATED_V1, SaleStatusUpdatedV1Schema],
30
- [SALE_DELIVERY_STATUS_UPDATED_V1, SaleDeliveryStatusUpdatedV1Schema],
29
+ [SALES_POS_STATUS_UPDATED_V1, SalesPosStatusUpdatedV1Schema],
30
+ [SALES_DELIVERY_STATUS_UPDATED_V1, SalesDeliveryStatusUpdatedV1Schema],
31
31
  ]);
@@ -1,52 +1,72 @@
1
1
  import { z } from 'zod';
2
2
  import { metadataSchema } from '../../metadata.js';
3
+ import { SalesChannelTypes } from '../../rms/constants.js';
3
4
  import { DeliveryStatus } from './constants.js';
4
5
  export const eventType = 'sales.delivery.status.updated.v1';
5
- const SaleDeliveryStatusUpdatedV1CommonPropertiesSchema = z.object({
6
+ const SalesDeliveryStatusUpdatedV1CommonPropertiesSchema = z.object({
6
7
  orgId: z.string(),
7
8
  brandId: z.string(),
8
9
  propertyId: z.string(),
9
10
  salesChannelId: z.string(),
11
+ salesChannelType: z.nativeEnum(SalesChannelTypes),
10
12
  saleId: z.string(),
11
13
  externalId: z.string().optional(),
12
14
  });
13
- const SaleDeliveryStatusUpdatedV1PropertiesSchema = z
15
+ const SalesDeliveryStatusUpdatedV1PropertiesSchema = z
14
16
  .discriminatedUnion('status', [
15
- SaleDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
17
+ SalesDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
16
18
  status: z.literal(DeliveryStatus.SALE_DISPATCHED),
17
19
  dispatchTime: z.string().datetime(),
18
20
  }),
19
- SaleDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
21
+ SalesDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
20
22
  status: z.literal(DeliveryStatus.SALE_ON_THE_WAY),
21
23
  dispatchTime: z.string().datetime(),
22
24
  }),
23
- SaleDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
25
+ SalesDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
24
26
  status: z.literal(DeliveryStatus.SALE_DELIVERED),
25
27
  deliveryTime: z.string().datetime(),
26
28
  }),
27
29
  ])
28
30
  .openapi({
29
- description: 'Emitted when a sale delivery status is updated',
31
+ description: 'Emitted when a sales delivery status is updated',
30
32
  example: {
31
33
  orgId: 'org123',
32
34
  brandId: 'br123',
33
35
  propertyId: 'p123',
34
36
  salesChannelId: 'sc123',
37
+ salesChannelType: SalesChannelTypes.UberEats,
35
38
  saleId: 'sale-123',
36
39
  externalId: 'sale-external-123',
37
40
  status: DeliveryStatus.SALE_DISPATCHED,
38
41
  dispatchTime: '2025-01-01T00:00:00Z',
39
42
  },
40
43
  });
41
- const SALE_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
44
+ const SALES_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
42
45
  source: 'rms',
43
46
  'detail-type': eventType,
44
47
  detail: {
45
- properties: SaleDeliveryStatusUpdatedV1PropertiesSchema,
46
- metadata: metadataSchema,
48
+ properties: {
49
+ orgId: 'org123',
50
+ brandId: 'br123',
51
+ propertyId: 'p123',
52
+ salesChannelId: 'sc123',
53
+ salesChannelType: SalesChannelTypes.UberEats,
54
+ saleId: 'sale-123',
55
+ externalId: 'sale-external-123',
56
+ status: DeliveryStatus.SALE_DISPATCHED,
57
+ dispatchTime: '2025-01-01T00:00:00Z',
58
+ },
59
+ metadata: {
60
+ actorUserId: 123,
61
+ actor: {
62
+ id: 'user-123',
63
+ email: 'user@example.com',
64
+ name: 'John Doe',
65
+ },
66
+ },
47
67
  },
48
68
  };
49
- export const SaleDeliveryStatusUpdatedV1Schema = z
69
+ export const SalesDeliveryStatusUpdatedV1Schema = z
50
70
  .object({
51
71
  source: z.string().openapi({
52
72
  description: 'Source of the event',
@@ -54,11 +74,12 @@ export const SaleDeliveryStatusUpdatedV1Schema = z
54
74
  }),
55
75
  'detail-type': z.literal(eventType),
56
76
  detail: z.object({
57
- properties: SaleDeliveryStatusUpdatedV1PropertiesSchema,
77
+ properties: SalesDeliveryStatusUpdatedV1PropertiesSchema,
58
78
  metadata: metadataSchema,
59
79
  }),
60
80
  })
61
81
  .openapi({
62
- description: 'Emitted when a sale delivery status is updated',
63
- 'x-example': SALE_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
82
+ description: 'Emitted when a sales delivery status is updated',
83
+ 'x-webhook-group': 'Sales Delivery Status Updated',
84
+ 'x-example': SALES_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
64
85
  });
@@ -1,40 +1,43 @@
1
1
  import { z } from 'zod';
2
2
  import { metadataSchema } from '../../metadata.js';
3
+ import { SalesChannelTypes } from '../../rms/constants.js';
3
4
  import { DeliveryStatus } from './constants.js';
4
5
 
5
6
  export const eventType = 'sales.delivery.status.updated.v1';
6
7
 
7
- const SaleDeliveryStatusUpdatedV1CommonPropertiesSchema = z.object({
8
+ const SalesDeliveryStatusUpdatedV1CommonPropertiesSchema = z.object({
8
9
  orgId: z.string(),
9
10
  brandId: z.string(),
10
11
  propertyId: z.string(),
11
12
  salesChannelId: z.string(),
13
+ salesChannelType: z.nativeEnum(SalesChannelTypes),
12
14
  saleId: z.string(),
13
15
  externalId: z.string().optional(),
14
16
  });
15
17
 
16
- const SaleDeliveryStatusUpdatedV1PropertiesSchema = z
18
+ const SalesDeliveryStatusUpdatedV1PropertiesSchema = z
17
19
  .discriminatedUnion('status', [
18
- SaleDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
20
+ SalesDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
19
21
  status: z.literal(DeliveryStatus.SALE_DISPATCHED),
20
22
  dispatchTime: z.string().datetime(),
21
23
  }),
22
- SaleDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
24
+ SalesDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
23
25
  status: z.literal(DeliveryStatus.SALE_ON_THE_WAY),
24
26
  dispatchTime: z.string().datetime(),
25
27
  }),
26
- SaleDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
28
+ SalesDeliveryStatusUpdatedV1CommonPropertiesSchema.extend({
27
29
  status: z.literal(DeliveryStatus.SALE_DELIVERED),
28
30
  deliveryTime: z.string().datetime(),
29
31
  }),
30
32
  ])
31
33
  .openapi({
32
- description: 'Emitted when a sale delivery status is updated',
34
+ description: 'Emitted when a sales delivery status is updated',
33
35
  example: {
34
36
  orgId: 'org123',
35
37
  brandId: 'br123',
36
38
  propertyId: 'p123',
37
39
  salesChannelId: 'sc123',
40
+ salesChannelType: SalesChannelTypes.UberEats,
38
41
  saleId: 'sale-123',
39
42
  externalId: 'sale-external-123',
40
43
  status: DeliveryStatus.SALE_DISPATCHED,
@@ -42,16 +45,32 @@ const SaleDeliveryStatusUpdatedV1PropertiesSchema = z
42
45
  },
43
46
  });
44
47
 
45
- const SALE_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
48
+ const SALES_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
46
49
  source: 'rms',
47
50
  'detail-type': eventType,
48
51
  detail: {
49
- properties: SaleDeliveryStatusUpdatedV1PropertiesSchema,
50
- metadata: metadataSchema,
52
+ properties: {
53
+ orgId: 'org123',
54
+ brandId: 'br123',
55
+ propertyId: 'p123',
56
+ salesChannelId: 'sc123',
57
+ salesChannelType: SalesChannelTypes.UberEats,
58
+ saleId: 'sale-123',
59
+ externalId: 'sale-external-123',
60
+ status: DeliveryStatus.SALE_DISPATCHED,
61
+ dispatchTime: '2025-01-01T00:00:00Z',
62
+ },
63
+ metadata: {
64
+ actorUserId: 123,
65
+ actor: {
66
+ id: 'user-123',
67
+ email: 'user@example.com',
68
+ name: 'John Doe',
69
+ },
70
+ },
51
71
  },
52
72
  };
53
-
54
- export const SaleDeliveryStatusUpdatedV1Schema = z
73
+ export const SalesDeliveryStatusUpdatedV1Schema = z
55
74
  .object({
56
75
  source: z.string().openapi({
57
76
  description: 'Source of the event',
@@ -59,13 +78,14 @@ export const SaleDeliveryStatusUpdatedV1Schema = z
59
78
  }),
60
79
  'detail-type': z.literal(eventType),
61
80
  detail: z.object({
62
- properties: SaleDeliveryStatusUpdatedV1PropertiesSchema,
81
+ properties: SalesDeliveryStatusUpdatedV1PropertiesSchema,
63
82
  metadata: metadataSchema,
64
83
  }),
65
84
  })
66
85
  .openapi({
67
- description: 'Emitted when a sale delivery status is updated',
68
- 'x-example': SALE_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
86
+ description: 'Emitted when a sales delivery status is updated',
87
+ 'x-webhook-group': 'Sales Delivery Status Updated',
88
+ 'x-example': SALES_DELIVERY_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
69
89
  });
70
90
 
71
- export type SaleDeliveryStatusUpdatedV1 = z.infer<typeof SaleDeliveryStatusUpdatedV1Schema>;
91
+ export type SalesDeliveryStatusUpdatedV1 = z.infer<typeof SalesDeliveryStatusUpdatedV1Schema>;
@@ -1,47 +1,50 @@
1
1
  import { z } from 'zod';
2
2
  import { metadataSchema } from '../../metadata.js';
3
+ import { SalesChannelTypes } from '../../rms/constants.js';
3
4
  import { SaleStatus } from './constants.js';
4
- export const eventType = 'sales.status.updated.v1';
5
- const SaleStatusUpdatedV1CommonPropertiesSchema = z.object({
5
+ export const eventType = 'sales.pos.status.updated.v1';
6
+ const SalesPosStatusUpdatedV1CommonPropertiesSchema = z.object({
6
7
  orgId: z.string(),
7
8
  brandId: z.string(),
8
9
  propertyId: z.string(),
9
10
  salesChannelId: z.string(),
11
+ salesChannelType: z.nativeEnum(SalesChannelTypes),
10
12
  saleId: z.string(),
11
13
  externalId: z.string().optional(),
12
14
  });
13
- const SaleStatusUpdatedV1PropertiesSchema = z
15
+ const SalesPosStatusUpdatedV1PropertiesSchema = z
14
16
  .discriminatedUnion('status', [
15
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
17
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
16
18
  status: z.literal(SaleStatus.SALE_PREPARED_BY_KITCHEN),
17
19
  }),
18
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
20
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
19
21
  status: z.literal(SaleStatus.SALE_PICKUP_TIME_CHANGED),
20
22
  pickupTime: z.string().datetime(),
21
23
  }),
22
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
24
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
23
25
  status: z.literal(SaleStatus.SALE_DELIVERY_TIME_CHANGED),
24
26
  deliveryTime: z.string().datetime(),
25
27
  }),
26
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
28
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
27
29
  status: z.literal(SaleStatus.SALE_CANCELLED),
28
30
  cancellationReason: z.string(),
29
31
  cancelledBy: z.string(),
30
32
  }),
31
33
  ])
32
34
  .openapi({
33
- description: 'Emitted when a sale status is updated',
35
+ description: 'Emitted when a sales POS status is updated',
34
36
  example: {
35
37
  orgId: 'org123',
36
38
  brandId: 'br123',
37
39
  propertyId: 'p123',
38
40
  salesChannelId: 'sc123',
41
+ salesChannelType: SalesChannelTypes.UberEats,
39
42
  saleId: 'sale-123',
40
43
  externalId: 'sale-external-123',
41
44
  status: SaleStatus.SALE_PREPARED_BY_KITCHEN,
42
45
  },
43
46
  });
44
- const SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
47
+ const SALES_POS_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
45
48
  source: 'rms',
46
49
  'detail-type': eventType,
47
50
  detail: {
@@ -50,6 +53,7 @@ const SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
50
53
  brandId: 'br123',
51
54
  propertyId: 'p123',
52
55
  salesChannelId: 'sc123',
56
+ salesChannelType: SalesChannelTypes.UberEats,
53
57
  saleId: 'sale-123',
54
58
  externalId: 'sale-external-123',
55
59
  status: SaleStatus.SALE_PREPARED_BY_KITCHEN,
@@ -64,7 +68,7 @@ const SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
64
68
  },
65
69
  },
66
70
  };
67
- export const SaleStatusUpdatedV1Schema = z
71
+ export const SalesPosStatusUpdatedV1Schema = z
68
72
  .object({
69
73
  source: z.string().openapi({
70
74
  description: 'Source of the event',
@@ -72,12 +76,12 @@ export const SaleStatusUpdatedV1Schema = z
72
76
  }),
73
77
  'detail-type': z.literal(eventType),
74
78
  detail: z.object({
75
- properties: SaleStatusUpdatedV1PropertiesSchema,
79
+ properties: SalesPosStatusUpdatedV1PropertiesSchema,
76
80
  metadata: metadataSchema,
77
81
  }),
78
82
  })
79
83
  .openapi({
80
- description: 'Emitted when a sale status is updated',
84
+ description: 'Emitted when a sales POS status is updated',
81
85
  'x-webhook-group': 'Sale Status Updated',
82
- 'x-example': SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
86
+ 'x-example': SALES_POS_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
83
87
  });
@@ -1,51 +1,54 @@
1
1
  import { z } from 'zod';
2
2
  import { metadataSchema } from '../../metadata.js';
3
+ import { SalesChannelTypes } from '../../rms/constants.js';
3
4
  import { SaleStatus } from './constants.js';
4
5
 
5
- export const eventType = 'sales.status.updated.v1';
6
+ export const eventType = 'sales.pos.status.updated.v1';
6
7
 
7
- const SaleStatusUpdatedV1CommonPropertiesSchema = z.object({
8
+ const SalesPosStatusUpdatedV1CommonPropertiesSchema = z.object({
8
9
  orgId: z.string(),
9
10
  brandId: z.string(),
10
11
  propertyId: z.string(),
11
12
  salesChannelId: z.string(),
13
+ salesChannelType: z.nativeEnum(SalesChannelTypes),
12
14
  saleId: z.string(),
13
15
  externalId: z.string().optional(),
14
16
  });
15
17
 
16
- const SaleStatusUpdatedV1PropertiesSchema = z
18
+ const SalesPosStatusUpdatedV1PropertiesSchema = z
17
19
  .discriminatedUnion('status', [
18
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
20
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
19
21
  status: z.literal(SaleStatus.SALE_PREPARED_BY_KITCHEN),
20
22
  }),
21
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
23
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
22
24
  status: z.literal(SaleStatus.SALE_PICKUP_TIME_CHANGED),
23
25
  pickupTime: z.string().datetime(),
24
26
  }),
25
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
27
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
26
28
  status: z.literal(SaleStatus.SALE_DELIVERY_TIME_CHANGED),
27
29
  deliveryTime: z.string().datetime(),
28
30
  }),
29
- SaleStatusUpdatedV1CommonPropertiesSchema.extend({
31
+ SalesPosStatusUpdatedV1CommonPropertiesSchema.extend({
30
32
  status: z.literal(SaleStatus.SALE_CANCELLED),
31
33
  cancellationReason: z.string(),
32
34
  cancelledBy: z.string(),
33
35
  }),
34
36
  ])
35
37
  .openapi({
36
- description: 'Emitted when a sale status is updated',
38
+ description: 'Emitted when a sales POS status is updated',
37
39
  example: {
38
40
  orgId: 'org123',
39
41
  brandId: 'br123',
40
42
  propertyId: 'p123',
41
43
  salesChannelId: 'sc123',
44
+ salesChannelType: SalesChannelTypes.UberEats,
42
45
  saleId: 'sale-123',
43
46
  externalId: 'sale-external-123',
44
47
  status: SaleStatus.SALE_PREPARED_BY_KITCHEN,
45
48
  },
46
49
  });
47
50
 
48
- const SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
51
+ const SALES_POS_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
49
52
  source: 'rms',
50
53
  'detail-type': eventType,
51
54
  detail: {
@@ -54,6 +57,7 @@ const SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
54
57
  brandId: 'br123',
55
58
  propertyId: 'p123',
56
59
  salesChannelId: 'sc123',
60
+ salesChannelType: SalesChannelTypes.UberEats,
57
61
  saleId: 'sale-123',
58
62
  externalId: 'sale-external-123',
59
63
  status: SaleStatus.SALE_PREPARED_BY_KITCHEN,
@@ -69,7 +73,7 @@ const SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE = {
69
73
  },
70
74
  };
71
75
 
72
- export const SaleStatusUpdatedV1Schema = z
76
+ export const SalesPosStatusUpdatedV1Schema = z
73
77
  .object({
74
78
  source: z.string().openapi({
75
79
  description: 'Source of the event',
@@ -77,14 +81,14 @@ export const SaleStatusUpdatedV1Schema = z
77
81
  }),
78
82
  'detail-type': z.literal(eventType),
79
83
  detail: z.object({
80
- properties: SaleStatusUpdatedV1PropertiesSchema,
84
+ properties: SalesPosStatusUpdatedV1PropertiesSchema,
81
85
  metadata: metadataSchema,
82
86
  }),
83
87
  })
84
88
  .openapi({
85
- description: 'Emitted when a sale status is updated',
89
+ description: 'Emitted when a sales POS status is updated',
86
90
  'x-webhook-group': 'Sale Status Updated',
87
- 'x-example': SALE_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
91
+ 'x-example': SALES_POS_STATUS_UPDATED_V1_WEBHOOK_EXAMPLE,
88
92
  });
89
93
 
90
- export type SaleStatusUpdatedV1 = z.infer<typeof SaleStatusUpdatedV1Schema>;
94
+ export type SalesPosStatusUpdatedV1 = z.infer<typeof SalesPosStatusUpdatedV1Schema>;
package/webhooks/index.js CHANGED
@@ -7,8 +7,8 @@ export const webhookEventTypes = [
7
7
  rmsSnoozeEvents.MENU_ITEM_UNSNOOZED_V1,
8
8
  rmsSnoozeEvents.SALES_CHANNEL_SNOOZED_V1,
9
9
  rmsSnoozeEvents.SALES_CHANNEL_UNSNOOZED_V1,
10
- rmsSalesEvents.SALE_STATUS_UPDATED_V1,
11
- rmsSalesEvents.SALE_DELIVERY_STATUS_UPDATED_V1,
10
+ rmsSalesEvents.SALES_POS_STATUS_UPDATED_V1,
11
+ rmsSalesEvents.SALES_DELIVERY_STATUS_UPDATED_V1,
12
12
  ];
13
13
  // Export a consolidated schema map for all webhook event types we expose
14
14
  export const eventSchemaMap = {
package/webhooks/index.ts CHANGED
@@ -17,8 +17,8 @@ export const webhookEventTypes = [
17
17
  rmsSnoozeEvents.MENU_ITEM_UNSNOOZED_V1,
18
18
  rmsSnoozeEvents.SALES_CHANNEL_SNOOZED_V1,
19
19
  rmsSnoozeEvents.SALES_CHANNEL_UNSNOOZED_V1,
20
- rmsSalesEvents.SALE_STATUS_UPDATED_V1,
21
- rmsSalesEvents.SALE_DELIVERY_STATUS_UPDATED_V1,
20
+ rmsSalesEvents.SALES_POS_STATUS_UPDATED_V1,
21
+ rmsSalesEvents.SALES_DELIVERY_STATUS_UPDATED_V1,
22
22
  ] as const;
23
23
 
24
24
  // Export a consolidated schema map for all webhook event types we expose