swoop-common 2.1.50 → 2.1.52

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.
Files changed (29) hide show
  1. package/dist/api/additions/templateHierarchyResolver.js +52 -49
  2. package/dist/api/generated/core/core/OpenAPI.js +2 -2
  3. package/dist/api/generated/core/index.d.ts +2 -0
  4. package/dist/api/generated/core/index.js +2 -0
  5. package/dist/api/generated/core/models/DTOSnapshotCreate.d.ts +1 -0
  6. package/dist/api/generated/core/models/DTOSnapshotEntity.d.ts +1 -0
  7. package/dist/api/generated/core/models/DTOSnapshotRead.d.ts +1 -0
  8. package/dist/api/generated/core/services/ComponentService.d.ts +73 -0
  9. package/dist/api/generated/core/services/ComponentService.js +171 -0
  10. package/dist/api/generated/core/services/CoreService.d.ts +48 -36
  11. package/dist/api/generated/core/services/CoreService.js +131 -32
  12. package/dist/api/generated/core/services/TemplateService.d.ts +53 -0
  13. package/dist/api/generated/core/services/TemplateService.js +121 -0
  14. package/dist/api/generated/itinerary/index.d.ts +3 -0
  15. package/dist/api/generated/itinerary/index.js +3 -0
  16. package/dist/api/generated/itinerary/models/DTOSnapshotCreate.d.ts +1 -0
  17. package/dist/api/generated/itinerary/models/DTOSnapshotEntity.d.ts +1 -0
  18. package/dist/api/generated/itinerary/models/DTOSnapshotRead.d.ts +1 -0
  19. package/dist/api/generated/itinerary/services/AuditService.d.ts +12 -0
  20. package/dist/api/generated/itinerary/services/AuditService.js +28 -0
  21. package/dist/api/generated/itinerary/services/ItineraryService.d.ts +2 -1
  22. package/dist/api/generated/itinerary/services/ItineraryService.js +3 -1
  23. package/dist/api/generated/itinerary/services/RegionService.d.ts +27 -0
  24. package/dist/api/generated/itinerary/services/RegionService.js +51 -0
  25. package/dist/api/generated/itinerary/services/SnapshotService.d.ts +52 -0
  26. package/dist/api/generated/itinerary/services/SnapshotService.js +119 -0
  27. package/dist/rendering/components/ComponentPicker.js +1 -1
  28. package/dist/rendering/renderers/TemplatePicker.js +15 -15
  29. package/package.json +1 -1
@@ -43,59 +43,62 @@ const buildTemplateTree = (templates) => {
43
43
  };
44
44
  export const resolveTemplateHierarchy = (templateId) => __awaiter(void 0, void 0, void 0, function* () {
45
45
  // First fetch all templates
46
- const allTemplates = yield (new CoreService).templateList(1);
47
- // Find the initial template
48
- const initialTemplate = allTemplates.data.find((t) => t.id === templateId);
49
- if (!initialTemplate) {
50
- throw new Error(`Template with ID ${templateId} not found`);
51
- }
52
- // Build the complete template tree
53
- const templateTree = buildTemplateTree(allTemplates.data);
54
- // Find the group containing our template
55
- const findGroup = (groups) => {
56
- for (const group of groups) {
57
- if (group.versions.some((t) => t.id === templateId)) {
58
- return group;
46
+ const allTemplates = yield new CoreService().templateList(1);
47
+ if (allTemplates.data) {
48
+ // Find the initial template
49
+ const initialTemplate = allTemplates.data.find((t) => t.id === templateId);
50
+ if (!initialTemplate) {
51
+ throw new Error(`Template with ID ${templateId} not found`);
52
+ }
53
+ // Build the complete template tree
54
+ const templateTree = buildTemplateTree(allTemplates.data);
55
+ // Find the group containing our template
56
+ const findGroup = (groups) => {
57
+ for (const group of groups) {
58
+ if (group.versions.some((t) => t.id === templateId)) {
59
+ return group;
60
+ }
61
+ const found = findGroup(group.children);
62
+ if (found)
63
+ return found;
59
64
  }
60
- const found = findGroup(group.children);
61
- if (found)
62
- return found;
65
+ return undefined;
66
+ };
67
+ const targetGroup = findGroup(templateTree);
68
+ if (!targetGroup) {
69
+ throw new Error(`Could not find template group for template ${templateId}`);
63
70
  }
64
- return undefined;
65
- };
66
- const targetGroup = findGroup(templateTree);
67
- if (!targetGroup) {
68
- throw new Error(`Could not find template group for template ${templateId}`);
69
- }
70
- // Build the hierarchy by following parent links
71
- const hierarchy = [];
72
- let currentGroup = targetGroup;
73
- while (currentGroup) {
74
- // Get the latest version of the current group
75
- const latestTemplate = currentGroup.versions.reduce((a, b) => a.revision > b.revision ? a : b);
76
- hierarchy.unshift(latestTemplate); // Add to beginning to get root -> leaf order
77
- // Move up to parent group
78
- if (currentGroup.parentRevisionGroupId) {
79
- // Find the parent group in the tree
80
- const findParentGroup = (groups) => {
81
- for (const group of groups) {
82
- if (group.revisionGroupId === currentGroup.parentRevisionGroupId) {
83
- return group;
71
+ // Build the hierarchy by following parent links
72
+ const hierarchy = [];
73
+ let currentGroup = targetGroup;
74
+ while (currentGroup) {
75
+ // Get the latest version of the current group
76
+ const latestTemplate = currentGroup.versions.reduce((a, b) => a.revision > b.revision ? a : b);
77
+ hierarchy.unshift(latestTemplate); // Add to beginning to get root -> leaf order
78
+ // Move up to parent group
79
+ if (currentGroup.parentRevisionGroupId) {
80
+ // Find the parent group in the tree
81
+ const findParentGroup = (groups) => {
82
+ for (const group of groups) {
83
+ if (group.revisionGroupId === currentGroup.parentRevisionGroupId) {
84
+ return group;
85
+ }
86
+ const found = findParentGroup(group.children);
87
+ if (found)
88
+ return found;
84
89
  }
85
- const found = findParentGroup(group.children);
86
- if (found)
87
- return found;
88
- }
89
- return undefined;
90
- };
91
- const parentGroup = findParentGroup(templateTree);
92
- if (!parentGroup)
90
+ return undefined;
91
+ };
92
+ const parentGroup = findParentGroup(templateTree);
93
+ if (!parentGroup)
94
+ break;
95
+ currentGroup = parentGroup;
96
+ }
97
+ else {
93
98
  break;
94
- currentGroup = parentGroup;
95
- }
96
- else {
97
- break;
99
+ }
98
100
  }
101
+ return hierarchy; // Already in root -> leaf order
99
102
  }
100
- return hierarchy; // Already in root -> leaf order
103
+ return [];
101
104
  });
@@ -1,6 +1,6 @@
1
1
  export const OpenAPI = {
2
- BASE: 'placeholder',
3
- VERSION: '1.0.0',
2
+ BASE: 'https://data-api-dev.swoop-adventures.com/core-data-service/v1',
3
+ VERSION: '1',
4
4
  WITH_CREDENTIALS: false,
5
5
  CREDENTIALS: 'include',
6
6
  TOKEN: undefined,
@@ -67,4 +67,6 @@ export type { sortParam } from './models/sortParam';
67
67
  export type { templateId } from './models/templateId';
68
68
  export type { UserComponentInstanceField } from './models/UserComponentInstanceField';
69
69
  export type { ValidationSchemas } from './models/ValidationSchemas';
70
+ export { ComponentService } from './services/ComponentService';
70
71
  export { CoreService } from './services/CoreService';
72
+ export { TemplateService } from './services/TemplateService';
@@ -11,4 +11,6 @@ export { Currency } from './models/Currency';
11
11
  export { Meals } from './models/Meals';
12
12
  export { regionParam } from './models/regionParam';
13
13
  export { regionRequired } from './models/regionRequired';
14
+ export { ComponentService } from './services/ComponentService';
14
15
  export { CoreService } from './services/CoreService';
16
+ export { TemplateService } from './services/TemplateService';
@@ -1,4 +1,5 @@
1
1
  export type DTOSnapshotCreate = {
2
2
  name: string;
3
3
  itineraryId: string;
4
+ enquiryId: string;
4
5
  };
@@ -4,4 +4,5 @@ export type DTOSnapshotEntity = {
4
4
  metadata: Metadata;
5
5
  name: string;
6
6
  itineraryId: string;
7
+ enquiryId: string;
7
8
  };
@@ -4,4 +4,5 @@ export type DTOSnapshotRead = {
4
4
  metadata: Metadata;
5
5
  name: string;
6
6
  itineraryId: string;
7
+ enquiryId: string;
7
8
  };
@@ -0,0 +1,73 @@
1
+ import type { DTOComponentCreate } from '../models/DTOComponentCreate';
2
+ import type { DTOComponentRead } from '../models/DTOComponentRead';
3
+ import type { DTOComponentUpdate } from '../models/DTOComponentUpdate';
4
+ import type { Pagination } from '../models/Pagination';
5
+ import type { CancelablePromise } from '../core/CancelablePromise';
6
+ export declare class ComponentService {
7
+ /**
8
+ * List Component
9
+ * List all available component
10
+ * @param page Pagination, starting at page 1
11
+ * @param limit Number of items per page
12
+ * @param sort List of fields to sort by
13
+ * @returns any The list of all component given the parameters used
14
+ * @throws ApiError
15
+ */
16
+ static componentList(page?: number, limit?: number, sort?: any[]): CancelablePromise<{
17
+ data?: Array<DTOComponentRead>;
18
+ pagination?: Pagination;
19
+ }>;
20
+ /**
21
+ * Create a Component
22
+ * Creates a new Component
23
+ * @param requestBody
24
+ * @returns DTOComponentRead When a component is created
25
+ * @throws ApiError
26
+ */
27
+ static componentCreate(requestBody: DTOComponentCreate): CancelablePromise<DTOComponentRead>;
28
+ /**
29
+ * Get Component
30
+ * Get Component via ID
31
+ * @param componentId Id of a component
32
+ * @returns any OK
33
+ * @throws ApiError
34
+ */
35
+ static componentGet(componentId: string): CancelablePromise<any>;
36
+ /**
37
+ * Update Component as New Revision
38
+ * Updates an component as a new revision
39
+ * @param componentId Id of a component
40
+ * @param requestBody
41
+ * @returns DTOComponentRead When a new component is created successfully
42
+ * @throws ApiError
43
+ */
44
+ static componentUpdateAsNewRevision(componentId: string, requestBody: DTOComponentUpdate): CancelablePromise<DTOComponentRead>;
45
+ /**
46
+ * Update Component
47
+ * Updates an component
48
+ * @param componentId Id of a component
49
+ * @param requestBody
50
+ * @returns DTOComponentRead When a component is updated successfully
51
+ * @throws ApiError
52
+ */
53
+ static componentUpdate(componentId: string, requestBody: DTOComponentUpdate): CancelablePromise<DTOComponentRead>;
54
+ /**
55
+ * Delete Component via ID
56
+ * Deletes a specific component given its Id
57
+ * @param componentId Id of a component
58
+ * @returns void
59
+ * @throws ApiError
60
+ */
61
+ static componentDelete(componentId: string): CancelablePromise<void>;
62
+ /**
63
+ * Update Component State
64
+ * Directly update component state. This does not create a new revision
65
+ * @param componentId Id of a component
66
+ * @param requestBody
67
+ * @returns any OK
68
+ * @throws ApiError
69
+ */
70
+ static componentStateUpdate(componentId: string, requestBody: {
71
+ state?: 'published' | 'deprecated' | 'unpublished';
72
+ }): CancelablePromise<any>;
73
+ }
@@ -0,0 +1,171 @@
1
+ import { OpenAPI } from '../core/OpenAPI';
2
+ import { request as __request } from '../core/request';
3
+ export class ComponentService {
4
+ /**
5
+ * List Component
6
+ * List all available component
7
+ * @param page Pagination, starting at page 1
8
+ * @param limit Number of items per page
9
+ * @param sort List of fields to sort by
10
+ * @returns any The list of all component given the parameters used
11
+ * @throws ApiError
12
+ */
13
+ static componentList(page, limit, sort) {
14
+ return __request(OpenAPI, {
15
+ method: 'GET',
16
+ url: '/components',
17
+ query: {
18
+ 'page': page,
19
+ 'limit': limit,
20
+ 'sort': sort,
21
+ },
22
+ errors: {
23
+ 400: `If the filter options or query parameters contain invalid values`,
24
+ 401: `Unauthorized - Missing or invalid Authorization header`,
25
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
26
+ 500: `When an internal server error occurs when listing all related component`,
27
+ },
28
+ });
29
+ }
30
+ /**
31
+ * Create a Component
32
+ * Creates a new Component
33
+ * @param requestBody
34
+ * @returns DTOComponentRead When a component is created
35
+ * @throws ApiError
36
+ */
37
+ static componentCreate(requestBody) {
38
+ return __request(OpenAPI, {
39
+ method: 'POST',
40
+ url: '/components',
41
+ body: requestBody,
42
+ mediaType: 'application/json',
43
+ errors: {
44
+ 400: `If the payload is malformed`,
45
+ 401: `Unauthorized - Missing or invalid Authorization header`,
46
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
47
+ 500: `Internal Server Error`,
48
+ },
49
+ });
50
+ }
51
+ /**
52
+ * Get Component
53
+ * Get Component via ID
54
+ * @param componentId Id of a component
55
+ * @returns any OK
56
+ * @throws ApiError
57
+ */
58
+ static componentGet(componentId) {
59
+ return __request(OpenAPI, {
60
+ method: 'GET',
61
+ url: '/components/{componentId}',
62
+ path: {
63
+ 'componentId': componentId,
64
+ },
65
+ errors: {
66
+ 401: `Unauthorized - Missing or invalid Authorization header`,
67
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
68
+ 404: `If the component does not exist`,
69
+ },
70
+ });
71
+ }
72
+ /**
73
+ * Update Component as New Revision
74
+ * Updates an component as a new revision
75
+ * @param componentId Id of a component
76
+ * @param requestBody
77
+ * @returns DTOComponentRead When a new component is created successfully
78
+ * @throws ApiError
79
+ */
80
+ static componentUpdateAsNewRevision(componentId, requestBody) {
81
+ return __request(OpenAPI, {
82
+ method: 'PATCH',
83
+ url: '/components/{componentId}',
84
+ path: {
85
+ 'componentId': componentId,
86
+ },
87
+ body: requestBody,
88
+ mediaType: 'application/json',
89
+ errors: {
90
+ 400: `If the payload is malformed`,
91
+ 401: `Unauthorized - Missing or invalid Authorization header`,
92
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
93
+ 404: `When the component id to create a new revision from is not found`,
94
+ 500: `When an internal server error occurs updating a component as a new revision`,
95
+ },
96
+ });
97
+ }
98
+ /**
99
+ * Update Component
100
+ * Updates an component
101
+ * @param componentId Id of a component
102
+ * @param requestBody
103
+ * @returns DTOComponentRead When a component is updated successfully
104
+ * @throws ApiError
105
+ */
106
+ static componentUpdate(componentId, requestBody) {
107
+ return __request(OpenAPI, {
108
+ method: 'PUT',
109
+ url: '/components/{componentId}',
110
+ path: {
111
+ 'componentId': componentId,
112
+ },
113
+ body: requestBody,
114
+ mediaType: 'application/json',
115
+ errors: {
116
+ 400: `If the payload is malformed`,
117
+ 401: `Unauthorized - Missing or invalid Authorization header`,
118
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
119
+ 404: `When the component id to update is not found`,
120
+ 500: `When an internal server error occurs updating a component`,
121
+ },
122
+ });
123
+ }
124
+ /**
125
+ * Delete Component via ID
126
+ * Deletes a specific component given its Id
127
+ * @param componentId Id of a component
128
+ * @returns void
129
+ * @throws ApiError
130
+ */
131
+ static componentDelete(componentId) {
132
+ return __request(OpenAPI, {
133
+ method: 'DELETE',
134
+ url: '/components/{componentId}',
135
+ path: {
136
+ 'componentId': componentId,
137
+ },
138
+ errors: {
139
+ 400: `When the component doesn't exist in the first place, or when a before hook fails before deleting the item`,
140
+ 401: `Unauthorized - Missing or invalid Authorization header`,
141
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
142
+ 404: `Not Found`,
143
+ 500: `When the component fails to delete due to an internal server error`,
144
+ },
145
+ });
146
+ }
147
+ /**
148
+ * Update Component State
149
+ * Directly update component state. This does not create a new revision
150
+ * @param componentId Id of a component
151
+ * @param requestBody
152
+ * @returns any OK
153
+ * @throws ApiError
154
+ */
155
+ static componentStateUpdate(componentId, requestBody) {
156
+ return __request(OpenAPI, {
157
+ method: 'GET',
158
+ url: '/components/{componentId}/state',
159
+ path: {
160
+ 'componentId': componentId,
161
+ },
162
+ body: requestBody,
163
+ mediaType: 'application/json',
164
+ errors: {
165
+ 401: `Unauthorized - Missing or invalid Authorization header`,
166
+ 403: `Forbidden - The client is authenticated but not authorized to access this resource`,
167
+ 404: `Not Found`,
168
+ },
169
+ });
170
+ }
171
+ }
@@ -9,93 +9,105 @@ import { CancelablePromise } from '../core/CancelablePromise';
9
9
  export declare class CoreService {
10
10
  /**
11
11
  * List Templates
12
- * List all templates with pagination
12
+ * List all available templates
13
13
  * @param page Pagination, starting at page 1
14
- * @returns any OK
14
+ * @param limit Number of items per page
15
+ * @param sort List of fields to sort by
16
+ * @returns any The list of all templates given the parameters used
15
17
  * @throws ApiError
16
18
  */
17
- templateList(page?: number): CancelablePromise<{
18
- data: Array<DTOTemplateRead>;
19
+ templateList(page?: number, limit?: number, sort?: any[]): CancelablePromise<{
20
+ data?: Array<DTOTemplateRead>;
19
21
  pagination?: Pagination;
20
22
  }>;
21
23
  /**
22
- * Create Template
23
- * Create a new template
24
+ * Create a Template
25
+ * Creates a new Template
24
26
  * @param requestBody
25
- * @returns DTOTemplateRead OK
27
+ * @returns DTOTemplateRead When a template is created
26
28
  * @throws ApiError
27
29
  */
28
30
  templateCreate(requestBody: DTOTemplateCreate): CancelablePromise<DTOTemplateRead>;
29
31
  /**
30
- * Get Template
31
- * Get a template via id
32
+ * Get Itinerary
33
+ * Get itinerary via ID
32
34
  * @param templateId Id of a template
33
- * @returns DTOTemplateRead OK
35
+ * @returns any OK
34
36
  * @throws ApiError
35
37
  */
36
- templateGet(templateId: string): CancelablePromise<DTOTemplateRead>;
38
+ itineraryGet(templateId: string): CancelablePromise<any>;
37
39
  /**
38
- * Update Template
39
- * Updates a template as a new revision
40
+ * Update Template as New Revision
41
+ * Updates an template as a new revision
40
42
  * @param templateId Id of a template
41
43
  * @param requestBody
42
- * @returns DTOTemplateRead OK
44
+ * @returns DTOTemplateRead When a new revision is created successfully
43
45
  * @throws ApiError
44
46
  */
45
- templateUpdate(templateId: string, requestBody: DTOTemplateUpdate): CancelablePromise<DTOTemplateRead>;
47
+ templateUpdateAsNewRevision(templateId: string, requestBody: DTOTemplateUpdate): CancelablePromise<DTOTemplateRead>;
46
48
  /**
47
- * Delete Template
48
- * Delete a template via id
49
+ * Delete Template via ID
50
+ * Deletes a specific template given its Id
49
51
  * @param templateId Id of a template
50
- * @returns any OK
52
+ * @returns void
51
53
  * @throws ApiError
52
54
  */
53
- templateDelete(templateId: string): CancelablePromise<any>;
55
+ templateDelete(templateId: string): CancelablePromise<void>;
54
56
  /**
55
- * List components
56
- * List all components
57
+ * List Component
58
+ * List all available component
57
59
  * @param page Pagination, starting at page 1
58
60
  * @param limit Number of items per page
59
- * @returns any OK
61
+ * @param sort List of fields to sort by
62
+ * @returns any The list of all component given the parameters used
60
63
  * @throws ApiError
61
64
  */
62
- componentList(page?: number, limit?: number): CancelablePromise<{
63
- data: Array<DTOComponentRead>;
65
+ componentList(page?: number, limit?: number, sort?: any[]): CancelablePromise<{
66
+ data?: Array<DTOComponentRead>;
64
67
  pagination?: Pagination;
65
68
  }>;
66
69
  /**
67
- * Create Component
68
- * Create a new component
70
+ * Create a Component
71
+ * Creates a new Component
69
72
  * @param requestBody
70
- * @returns DTOComponentRead OK
73
+ * @returns DTOComponentRead When a component is created
71
74
  * @throws ApiError
72
75
  */
73
76
  componentCreate(requestBody: DTOComponentCreate): CancelablePromise<DTOComponentRead>;
74
77
  /**
75
78
  * Get Component
76
- * Get a component via id
79
+ * Get Component via ID
80
+ * @param componentId Id of a component
81
+ * @returns any OK
82
+ * @throws ApiError
83
+ */
84
+ componentGet(componentId: string): CancelablePromise<any>;
85
+ /**
86
+ * Update Component as New Revision
87
+ * Updates an component as a new revision
77
88
  * @param componentId Id of a component
78
- * @returns DTOComponentRead OK
89
+ * @param requestBody
90
+ * @returns DTOComponentRead When a new component is created successfully
79
91
  * @throws ApiError
80
92
  */
81
- componentGet(componentId: string): CancelablePromise<DTOComponentRead>;
93
+ componentUpdateAsNewRevision(componentId: string, requestBody: DTOComponentUpdate): CancelablePromise<DTOComponentRead>;
82
94
  /**
83
95
  * Update Component
84
- * Update a component as a new revision
96
+ * Updates an component
85
97
  * @param componentId Id of a component
86
98
  * @param requestBody
87
- * @returns DTOComponentRead OK
99
+ * @returns DTOComponentRead When a component is updated successfully
88
100
  * @throws ApiError
89
101
  */
90
102
  componentUpdate(componentId: string, requestBody: DTOComponentUpdate): CancelablePromise<DTOComponentRead>;
91
103
  /**
92
- * Delete Component
93
- * Delete a component via id
104
+ * Delete Component via ID
105
+ * Deletes a specific component given its Id
94
106
  * @param componentId Id of a component
95
- * @returns any OK
107
+ * @returns void
96
108
  * @throws ApiError
97
109
  */
98
- componentDelete(componentId: string): CancelablePromise<any>;
110
+ componentDelete(componentId: string): CancelablePromise<void>;
99
111
  /**
100
112
  * Update Component State
101
113
  * Directly update component state. This does not create a new revision