@revolugo/common 7.13.0-rc.0 → 7.13.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolugo/common",
3
- "version": "7.13.0-rc.0",
3
+ "version": "7.13.0-rc.1",
4
4
  "private": false,
5
5
  "description": "Revolugo common",
6
6
  "author": "Revolugo",
@@ -29,7 +29,7 @@
29
29
  "dayjs": "1.11.21",
30
30
  "ky": "2.0.2",
31
31
  "slugify": "1.6.9",
32
- "type-fest": "5.6.0",
32
+ "type-fest": "5.7.0",
33
33
  "uuid": "14.0.0",
34
34
  "zod": "4.4.3"
35
35
  },
@@ -10,6 +10,7 @@ export * from './legal.ts'
10
10
  export * from './locales.ts'
11
11
  export * from './measurement.ts'
12
12
  export * from './poller.ts'
13
+ export * from './product-type.ts'
13
14
  export * from './stay-taxes-info.ts'
14
15
  export * from './tax.ts'
15
16
  export * from './time.ts'
@@ -0,0 +1,45 @@
1
+ import { MEETCH_INSURANCE_TYPE_SLUG } from './insurance.ts'
2
+
3
+ /**
4
+ * Single source of truth for every known product-type slug and whether it is
5
+ * read-only. Read-only types are provider-managed (created by integrations such
6
+ * as Pretix or Meetch) and must not be created, edited or deleted by admins;
7
+ * the others are manual types the dashboard lets admins create.
8
+ *
9
+ * Unknown slugs (e.g. custom types an admin creates on the fly) default to
10
+ * non-read-only — see {@link isReadonlyProductType}.
11
+ */
12
+
13
+ export enum ProductTypePackages {
14
+ Accommodation = 'accommodation',
15
+ Package = 'package',
16
+ PackageFees = 'package-fees',
17
+ Tickets = 'tickets',
18
+ }
19
+
20
+ export enum ProductType {
21
+ CarRental = 'car-rental',
22
+ Flight = 'flight',
23
+ Insurance = 'insurance',
24
+ Train = 'train',
25
+ Transfer = 'transfer',
26
+ }
27
+
28
+ export const PRODUCT_TYPES = {
29
+ // provider-managed (read-only)
30
+ [MEETCH_INSURANCE_TYPE_SLUG]: { readonly: true },
31
+ [ProductType.CarRental]: { readonly: false },
32
+ [ProductType.Flight]: { readonly: false },
33
+ [ProductType.Insurance]: { readonly: false },
34
+ [ProductType.Train]: { readonly: false },
35
+ [ProductType.Transfer]: { readonly: false },
36
+ [ProductTypePackages.Accommodation]: { readonly: true },
37
+ [ProductTypePackages.Package]: { readonly: true },
38
+ [ProductTypePackages.PackageFees]: { readonly: true },
39
+ [ProductTypePackages.Tickets]: { readonly: true },
40
+ } as const
41
+
42
+ export type ProductTypeSlug = keyof typeof PRODUCT_TYPES
43
+
44
+ export const isReadonlyProductType = (slug?: string | null): boolean =>
45
+ slug ? (PRODUCT_TYPES[slug as ProductTypeSlug]?.readonly ?? false) : false