@ibiliaze/global-vars 1.125.0 → 1.127.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/dist/flows.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FixtureCategoryBase, FixtureCategoryFlowBase, FlowBase, OccupanceBase, StaffBase } from './ticketops/inputsDefault';
2
- export declare const flows: readonly ["Online", "Offline", "Special link", "Seasonal ticket"];
2
+ export declare const flows: readonly ["Online", "Offline", "Special link"];
3
3
  export declare const idsEqual: <Id>(a: Id | null | undefined, b: Id | null | undefined) => boolean;
4
4
  export declare const arrayHasId: <Id>(list: readonly (Id | null | undefined)[] | null | undefined, target: Id | null | undefined) => boolean;
5
5
  export declare function makeSaleLogic<Id, TDate>(): SaleLogic<Id, TDate>;
@@ -50,10 +50,7 @@ export interface GetOccupanceCategoryArgs<Id, TDate> {
50
50
  occupanceCategory: OccupanceCategoryOf<Id, TDate>;
51
51
  fixtureCategories: FixtureCategoryOf<Id>[];
52
52
  }
53
- export interface GetCategoryArgs<Id, TDate> {
54
- where: WhereOf<Id, TDate>;
55
- fixtureCategories: FixtureCategoryOf<Id>[];
56
- sectionId: Id;
53
+ export interface GetCategoryArgs<Id> {
57
54
  occupanceCategory: FixtureCategoryOf<Id> | undefined;
58
55
  sectionCategory: FixtureCategoryOf<Id> | undefined;
59
56
  }
@@ -63,6 +60,6 @@ export interface SaleLogic<Id, TDate> {
63
60
  canISeeSeat(args: CanISeeSeatArgs<Id, TDate>): boolean;
64
61
  getSectorCategory(args: GetSectorCategoryArgs<Id>): FixtureCategoryOf<Id> | undefined;
65
62
  getOccupanceCategory(args: GetOccupanceCategoryArgs<Id, TDate>): FixtureCategoryOf<Id> | undefined;
66
- getCategory(args: GetCategoryArgs<Id, TDate>): FixtureCategoryOf<Id> | undefined;
63
+ getCategory(args: GetCategoryArgs<Id>): FixtureCategoryOf<Id> | undefined;
67
64
  }
68
65
  export {};
package/dist/flows.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.arrayHasId = exports.idsEqual = exports.flows = void 0;
4
4
  exports.makeSaleLogic = makeSaleLogic;
5
- exports.flows = ['Online', 'Offline', 'Special link', 'Seasonal ticket'];
5
+ exports.flows = ['Online', 'Offline', 'Special link'];
6
6
  const idsEqual = (a, b) => {
7
7
  if (a == null || b == null)
8
8
  return false;
@@ -25,8 +25,6 @@ function makeSaleLogic() {
25
25
  return 'Special link';
26
26
  case 'pos':
27
27
  return 'Offline';
28
- case 'seasonal':
29
- return 'Seasonal ticket';
30
28
  default:
31
29
  return 'Online';
32
30
  }
@@ -35,9 +33,8 @@ function makeSaleLogic() {
35
33
  return 'Online';
36
34
  }
37
35
  }
38
- const guestSeesSeasonalAndOnline = (flow) => flow.type === 'Seasonal ticket' || flow.type === 'Online';
39
- const cashierSeesSeasonal = (flow, staffFlowIds) => flow.type === 'Seasonal ticket' && (0, exports.arrayHasId)(staffFlowIds, flow.flowId);
40
- const cashierSeesSeasonalAndOffline = (flow, staffFlowIds) => (flow.type === 'Seasonal ticket' || flow.type === 'Offline') && (0, exports.arrayHasId)(staffFlowIds, flow.flowId);
36
+ const guestSeesOnline = (flow) => flow.type === 'Online';
37
+ const cashierSeesOffline = (flow, staffFlowIds) => flow.type === 'Offline' && (0, exports.arrayHasId)(staffFlowIds, flow.flowId);
41
38
  const comesFromSpecialLink = (flow, signedFlowId) => flow.type === 'Special link' && (0, exports.idsEqual)(flow.flowId, signedFlowId);
42
39
  const authoriser = ({ who, where, effectiveFlows, signedFlowId, staffFlowIds, }) => {
43
40
  // Guest
@@ -47,9 +44,7 @@ function makeSaleLogic() {
47
44
  if (where === 'Special link')
48
45
  return effectiveFlows.some(f => comesFromSpecialLink(f, signedFlowId));
49
46
  if (where === 'Online')
50
- return effectiveFlows.some(f => guestSeesSeasonalAndOnline(f));
51
- if (where === 'Seasonal ticket')
52
- return effectiveFlows.some(f => f.type === 'Seasonal ticket');
47
+ return effectiveFlows.some(f => guestSeesOnline(f));
53
48
  }
54
49
  // Cashier
55
50
  if (who === 'cashier') {
@@ -60,9 +55,7 @@ function makeSaleLogic() {
60
55
  if (where === 'Special link')
61
56
  return false;
62
57
  if (where === 'Offline')
63
- return effectiveFlows.some(f => cashierSeesSeasonalAndOffline(f, staffFlowIds));
64
- if (where === 'Seasonal ticket')
65
- return effectiveFlows.some(f => cashierSeesSeasonal(f, staffFlowIds));
58
+ return effectiveFlows.some(f => cashierSeesOffline(f, staffFlowIds));
66
59
  }
67
60
  return false;
68
61
  };
@@ -108,6 +101,7 @@ function makeSaleLogic() {
108
101
  name: sectionCat?.name ?? '',
109
102
  color: sectionCat?.color || 'blue.4',
110
103
  disabled: sectionCat?.disabled ?? false,
104
+ seasonal: sectionCat?.seasonal ?? false,
111
105
  price: sectionCat?.price ?? 0,
112
106
  flows: sectionCat?.flows ?? [],
113
107
  sections: sectionCat?.sections ?? [],
@@ -125,6 +119,7 @@ function makeSaleLogic() {
125
119
  name: occupanceCat?.name ?? '',
126
120
  color: occupanceCat?.color || 'blue.4',
127
121
  disabled: occupanceCat?.disabled ?? false,
122
+ seasonal: occupanceCat?.seasonal ?? false,
128
123
  price: occupanceCat?.price ?? 0,
129
124
  flows: occupanceCat?.flows ?? [],
130
125
  sections: occupanceCat?.sections ?? [],
@@ -134,29 +129,21 @@ function makeSaleLogic() {
134
129
  return undefined;
135
130
  }
136
131
  }
137
- function getCategory({ where, sectionId, fixtureCategories, occupanceCategory, sectionCategory, }) {
132
+ function getCategory({ occupanceCategory, sectionCategory }) {
138
133
  try {
139
134
  const occupanceCatOverride = !!occupanceCategory?.categoryId;
140
135
  const category = occupanceCatOverride ? occupanceCategory : sectionCategory;
141
- const isSeasonal = category?.flows.find(flow => flow.type === 'Seasonal ticket');
142
136
  const effectiveCategory = {
143
137
  categoryId: (category?.categoryId ?? undefined),
144
138
  name: category?.name ?? '',
145
139
  color: category?.color || 'blue',
146
140
  disabled: category?.disabled ?? false,
141
+ seasonal: category?.seasonal ?? false,
147
142
  price: category?.price ?? 0,
148
143
  flows: category?.flows ?? [],
149
144
  sections: category?.sections ?? [],
150
145
  };
151
- // If it isn't a seasonal seat, return the effective cat
152
- if (!isSeasonal)
153
- return effectiveCategory;
154
- // Return the effective category is Sale Channel is Seasonal
155
- if (where === 'Seasonal ticket')
156
- return effectiveCategory;
157
- // If sale channel is not seasonal but the seat is seasonal, return a default category
158
- const defaultFlowCategory = fixtureCategories.find(cat => cat.sections?.some(sec => (0, exports.idsEqual)(sec.sectionId, sectionId)));
159
- return defaultFlowCategory;
146
+ return effectiveCategory;
160
147
  }
161
148
  catch {
162
149
  return undefined;
@@ -293,6 +293,7 @@ export interface CampaignBase<Id, TDate> {
293
293
  export interface CategoryBase<Id, TDate> {
294
294
  _id?: Id;
295
295
  name: string;
296
+ seasonal?: boolean;
296
297
  description?: string;
297
298
  color?: string;
298
299
  createdAt?: TDate;
@@ -365,10 +366,16 @@ export interface FileBase<Id, TDate> {
365
366
  createdAt?: TDate;
366
367
  updatedAt?: TDate;
367
368
  }
369
+ export interface FixtureCategoryFlowBase<Id> {
370
+ flowId: Id;
371
+ name: string;
372
+ type: FlowBase<Id, Date>['type'];
373
+ }
368
374
  export interface FixtureCategoryBase<Id> {
369
375
  categoryId: Id;
370
376
  name: string;
371
377
  color: string;
378
+ seasonal: boolean;
372
379
  price: number;
373
380
  flows: FixtureCategoryFlowBase<Id>[];
374
381
  sections: {
@@ -377,11 +384,6 @@ export interface FixtureCategoryBase<Id> {
377
384
  }[];
378
385
  disabled?: boolean;
379
386
  }
380
- export interface FixtureCategoryFlowBase<Id> {
381
- flowId: Id;
382
- name: string;
383
- type: FlowBase<Id, Date>['type'];
384
- }
385
387
  export interface FixtureBase<Id, TDate> {
386
388
  _id?: Id;
387
389
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiliaze/global-vars",
3
- "version": "1.125.0",
3
+ "version": "1.127.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,
@@ -22,7 +22,7 @@
22
22
  "scripts": {
23
23
  "build": "tsc",
24
24
  "pub": "npm publish --access public",
25
- "git": "git add .; git commit -m 'changes'; git tag -a v1.125.0 -m 'v1.125.0'; git push origin v1.125.0; git push",
25
+ "git": "git add .; git commit -m 'changes'; git tag -a v1.127.0 -m 'v1.127.0'; git push origin v1.127.0; git push",
26
26
  "push": "npm run build; npm run git; npm run pub"
27
27
  },
28
28
  "author": "Ibi Hasanli",