@ibiliaze/global-vars 1.183.0 → 1.185.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
@@ -32,6 +32,7 @@ export interface CanISeeSeatArgs<Id, TDate> {
32
32
  where: WhereOf<Id, TDate>;
33
33
  userFlowIds: UserFlowIdsOf<Id, TDate>;
34
34
  occupanceCategory?: OccupanceCategoryOf<Id, TDate>;
35
+ sectionCategory?: OccupanceCategoryOf<Id, TDate>;
35
36
  eventCategories: EventCategoryOf<Id>[];
36
37
  signedFlowId?: Id | null;
37
38
  }
package/dist/flows.js CHANGED
@@ -36,7 +36,7 @@ function makeSaleLogic() {
36
36
  const guestSeesOnline = (flow) => flow.type === 'Online';
37
37
  const cashierSeesOffline = (flow, userFlowIds) => flow.type === 'Offline' && (0, exports.arrayHasId)(userFlowIds, flow.flowId);
38
38
  const comesFromSpecialLink = (flow, signedFlowId) => flow.type === 'Special link' && (0, exports.idsEqual)(flow.flowId, signedFlowId);
39
- const authoriser = ({ who, where, effectiveFlows, signedFlowId, userFlowIds, }) => {
39
+ const authoriser = ({ who, where, effectiveFlows, signedFlowId, userFlowIds }) => {
40
40
  // Guest
41
41
  if (who === 'guest') {
42
42
  if (where === 'Offline')
@@ -59,17 +59,17 @@ function makeSaleLogic() {
59
59
  }
60
60
  return false;
61
61
  };
62
- function canISeeSection({ who, where, sectionId, userFlowIds, signedFlowId, eventCategories, }) {
62
+ function canISeeSection({ who, where, sectionId, userFlowIds, signedFlowId, eventCategories }) {
63
63
  try {
64
64
  if (who === 'root')
65
65
  return true;
66
66
  if (!eventCategories || !eventCategories.length)
67
67
  return false;
68
68
  const sectionFlows = [
69
- ...eventCategories.flatMap(link => link.sections?.flatMap(section => ((0, exports.idsEqual)(section.sectionId, sectionId) ? section.flows : []))),
69
+ ...eventCategories.flatMap(link => link.sections?.flatMap(section => ((0, exports.idsEqual)(section.sectionId, sectionId) ? section?.flows ?? [] : []))),
70
70
  ];
71
71
  const categoryFlows = [
72
- ...eventCategories.flatMap(link => link.sections?.some(section => (0, exports.idsEqual)(section.sectionId, sectionId)) ? link.flows : []),
72
+ ...eventCategories.flatMap(link => (link.sections?.some(section => (0, exports.idsEqual)(section.sectionId, sectionId)) ? link?.flows ?? [] : [])),
73
73
  ];
74
74
  const effectiveFlows = sectionFlows.length ? sectionFlows : categoryFlows;
75
75
  return authoriser({ who, where, effectiveFlows, signedFlowId, userFlowIds });
@@ -78,15 +78,14 @@ function makeSaleLogic() {
78
78
  return false;
79
79
  }
80
80
  }
81
- function canISeeSeat({ who, where, signedFlowId, userFlowIds, occupanceCategory, eventCategories, }) {
81
+ function canISeeSeat({ who, where, signedFlowId, userFlowIds, occupanceCategory, eventCategories, sectionCategory }) {
82
82
  try {
83
83
  if (who === 'root')
84
84
  return true;
85
- if (!occupanceCategory || !occupanceCategory.categoryId)
86
- return true;
87
- const effectiveFlows = (eventCategories || [])
88
- .filter(link => (0, exports.idsEqual)(link.categoryId, occupanceCategory.categoryId))
89
- .flatMap(link => link.flows);
85
+ const effectiveCategory = occupanceCategory || sectionCategory;
86
+ if (!effectiveCategory || !effectiveCategory.categoryId)
87
+ return false;
88
+ const effectiveFlows = (eventCategories || []).filter(link => (0, exports.idsEqual)(link.categoryId, effectiveCategory.categoryId)).flatMap(link => link?.flows ?? []);
90
89
  return authoriser({ who, where, effectiveFlows, signedFlowId, userFlowIds });
91
90
  }
92
91
  catch {
@@ -110,7 +109,7 @@ function makeSaleLogic() {
110
109
  return undefined;
111
110
  }
112
111
  }
113
- function getOccupanceCategory({ occupanceCategory, eventCategories, }) {
112
+ function getOccupanceCategory({ occupanceCategory, eventCategories }) {
114
113
  try {
115
114
  const occupanceCat = eventCategories?.find(link => (0, exports.idsEqual)(link.categoryId, occupanceCategory?.categoryId));
116
115
  return {
@@ -723,9 +723,6 @@ export interface ItemBase<Id, TDate> {
723
723
  createdAt?: TDate;
724
724
  updatedAt?: TDate;
725
725
  }
726
- export type ItemWithTimeLeftBase<TId, TDate> = ItemBase<TId, TDate> & {
727
- timeLeft: number;
728
- };
729
726
  export interface SaleBase<Id, TDate> {
730
727
  _id?: Id;
731
728
  customerId: Id;
@@ -1,11 +1,11 @@
1
- import type { ItemWithTimeLeftBase } from '../inputsDefault';
1
+ import type { ItemBase } from '../inputsDefault';
2
2
  export declare const itemRoleDefs: <TId, TDate>() => readonly [{
3
3
  readonly method: "get";
4
4
  readonly path: "/item";
5
5
  readonly role: "getItems";
6
6
  readonly name: "Get items";
7
7
  readonly response_200: {
8
- itemsWithTimeLeft: ItemWithTimeLeftBase<TId, TDate>[];
8
+ items: ItemBase<TId, TDate>[];
9
9
  count: number;
10
10
  };
11
11
  readonly response_500: {
@@ -1,4 +1,4 @@
1
- import type { SeatBase, OccupanceBase, FlatOccupanceWithSeat, FlatOccupance, ItemWithTimeLeftBase } from '../inputsDefault';
1
+ import type { SeatBase, OccupanceBase, FlatOccupanceWithSeat, FlatOccupance, ItemBase } from '../inputsDefault';
2
2
  export declare const occupanceRoleDefs: <TId, TDate>() => readonly [{
3
3
  readonly method: "get";
4
4
  readonly path: "/seat";
@@ -92,7 +92,7 @@ export declare const occupanceRoleDefs: <TId, TDate>() => readonly [{
92
92
  readonly role: "postOccupanceReserveById";
93
93
  readonly name: "Reserve occupance by ID";
94
94
  readonly response_200: {
95
- itemWithTimeLeft: ItemWithTimeLeftBase<TId, TDate>;
95
+ item: ItemBase<TId, TDate>;
96
96
  occupance: OccupanceBase<TId, TDate>;
97
97
  message: string;
98
98
  };
@@ -117,7 +117,7 @@ export declare const occupanceRoleDefs: <TId, TDate>() => readonly [{
117
117
  readonly role: "postSeasonalOccupanceReserveById";
118
118
  readonly name: "Reserve seasonal occupance by ID";
119
119
  readonly response_200: {
120
- itemWithTimeLeft: ItemWithTimeLeftBase<TId, TDate>;
120
+ item: ItemBase<TId, TDate>;
121
121
  occupance: OccupanceBase<TId, TDate>;
122
122
  message: string;
123
123
  };
@@ -12,22 +12,6 @@ export declare const sectionRoleDefs: <TId, TDate>() => readonly [{
12
12
  message: string;
13
13
  error: string;
14
14
  };
15
- }, {
16
- readonly method: "post";
17
- readonly path: "/section/seats/:id";
18
- readonly role: "postSectionSeatsById";
19
- readonly name: "Create section seats";
20
- readonly response_201: {
21
- section: SectionBase<TId, TDate>;
22
- message: string;
23
- };
24
- readonly response_404: {
25
- message: string;
26
- };
27
- readonly response_500: {
28
- message: string;
29
- error: string;
30
- };
31
15
  }, {
32
16
  readonly method: "get";
33
17
  readonly path: "/section";
@@ -11,15 +11,6 @@ const sectionRoleDefs = () => {
11
11
  response_201: {},
12
12
  response_500: {},
13
13
  },
14
- {
15
- method: 'post',
16
- path: '/section/seats/:id',
17
- role: 'postSectionSeatsById',
18
- name: 'Create section seats',
19
- response_201: {},
20
- response_404: {},
21
- response_500: {},
22
- },
23
14
  {
24
15
  method: 'get',
25
16
  path: '/section',
@@ -504,7 +504,7 @@ export declare const apis: <TId, TDate>() => readonly [{
504
504
  readonly role: "getItems";
505
505
  readonly name: "Get items";
506
506
  readonly response_200: {
507
- itemsWithTimeLeft: import("./inputsDefault").ItemWithTimeLeftBase<TId_5, TDate_5>[];
507
+ items: import("./inputsDefault").ItemBase<TId_5, TDate_5>[];
508
508
  count: number;
509
509
  };
510
510
  readonly response_500: {
@@ -1847,7 +1847,7 @@ export declare const apis: <TId, TDate>() => readonly [{
1847
1847
  readonly role: "postOccupanceReserveById";
1848
1848
  readonly name: "Reserve occupance by ID";
1849
1849
  readonly response_200: {
1850
- itemWithTimeLeft: import("./inputsDefault").ItemWithTimeLeftBase<TId_21, TDate_21>;
1850
+ item: import("./inputsDefault").ItemBase<TId_21, TDate_21>;
1851
1851
  occupance: import("./inputsDefault").OccupanceBase<TId_21, TDate_21>;
1852
1852
  message: string;
1853
1853
  };
@@ -1872,7 +1872,7 @@ export declare const apis: <TId, TDate>() => readonly [{
1872
1872
  readonly role: "postSeasonalOccupanceReserveById";
1873
1873
  readonly name: "Reserve seasonal occupance by ID";
1874
1874
  readonly response_200: {
1875
- itemWithTimeLeft: import("./inputsDefault").ItemWithTimeLeftBase<TId_21, TDate_21>;
1875
+ item: import("./inputsDefault").ItemBase<TId_21, TDate_21>;
1876
1876
  occupance: import("./inputsDefault").OccupanceBase<TId_21, TDate_21>;
1877
1877
  message: string;
1878
1878
  };
@@ -1972,22 +1972,6 @@ export declare const apis: <TId, TDate>() => readonly [{
1972
1972
  message: string;
1973
1973
  error: string;
1974
1974
  };
1975
- }, {
1976
- readonly method: "post";
1977
- readonly path: "/section/seats/:id";
1978
- readonly role: "postSectionSeatsById";
1979
- readonly name: "Create section seats";
1980
- readonly response_201: {
1981
- section: import("./inputsDefault").SectionBase<TId_22, TDate_22>;
1982
- message: string;
1983
- };
1984
- readonly response_404: {
1985
- message: string;
1986
- };
1987
- readonly response_500: {
1988
- message: string;
1989
- error: string;
1990
- };
1991
1975
  }, {
1992
1976
  readonly method: "get";
1993
1977
  readonly path: "/section";
@@ -2996,7 +2980,7 @@ declare const allApis: readonly [{
2996
2980
  readonly role: "getItems";
2997
2981
  readonly name: "Get items";
2998
2982
  readonly response_200: {
2999
- itemsWithTimeLeft: import("./inputsDefault").ItemWithTimeLeftBase<TId_4, TDate_4>[];
2983
+ items: import("./inputsDefault").ItemBase<TId_4, TDate_4>[];
3000
2984
  count: number;
3001
2985
  };
3002
2986
  readonly response_500: {
@@ -4339,7 +4323,7 @@ declare const allApis: readonly [{
4339
4323
  readonly role: "postOccupanceReserveById";
4340
4324
  readonly name: "Reserve occupance by ID";
4341
4325
  readonly response_200: {
4342
- itemWithTimeLeft: import("./inputsDefault").ItemWithTimeLeftBase<TId_20, TDate_20>;
4326
+ item: import("./inputsDefault").ItemBase<TId_20, TDate_20>;
4343
4327
  occupance: import("./inputsDefault").OccupanceBase<TId_20, TDate_20>;
4344
4328
  message: string;
4345
4329
  };
@@ -4364,7 +4348,7 @@ declare const allApis: readonly [{
4364
4348
  readonly role: "postSeasonalOccupanceReserveById";
4365
4349
  readonly name: "Reserve seasonal occupance by ID";
4366
4350
  readonly response_200: {
4367
- itemWithTimeLeft: import("./inputsDefault").ItemWithTimeLeftBase<TId_20, TDate_20>;
4351
+ item: import("./inputsDefault").ItemBase<TId_20, TDate_20>;
4368
4352
  occupance: import("./inputsDefault").OccupanceBase<TId_20, TDate_20>;
4369
4353
  message: string;
4370
4354
  };
@@ -4464,22 +4448,6 @@ declare const allApis: readonly [{
4464
4448
  message: string;
4465
4449
  error: string;
4466
4450
  };
4467
- }, {
4468
- readonly method: "post";
4469
- readonly path: "/section/seats/:id";
4470
- readonly role: "postSectionSeatsById";
4471
- readonly name: "Create section seats";
4472
- readonly response_201: {
4473
- section: import("./inputsDefault").SectionBase<TId_21, TDate_21>;
4474
- message: string;
4475
- };
4476
- readonly response_404: {
4477
- message: string;
4478
- };
4479
- readonly response_500: {
4480
- message: string;
4481
- error: string;
4482
- };
4483
4451
  }, {
4484
4452
  readonly method: "get";
4485
4453
  readonly path: "/section";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiliaze/global-vars",
3
- "version": "1.183.0",
3
+ "version": "1.185.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.183.0 -m 'v1.183.0'; git push origin v1.183.0; git push",
25
+ "git": "git add .; git commit -m 'changes'; git tag -a v1.185.0 -m 'v1.185.0'; git push origin v1.185.0; git push",
26
26
  "push": "npm run build; npm run git; npm run pub"
27
27
  },
28
28
  "author": "Ibi Hasanli",