swoop-common 2.0.6 → 2.0.7

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 (48) hide show
  1. package/dist/api/generated/core/exports.d.ts +5 -6
  2. package/dist/api/generated/core/index.d.ts +5 -7
  3. package/dist/api/generated/core/models/Component.d.ts +24 -0
  4. package/dist/api/generated/core/models/ComponentInstance.d.ts +6 -0
  5. package/dist/api/generated/core/models/DTORegionUpdate.d.ts +6 -0
  6. package/dist/api/generated/core/models/Fee.d.ts +9 -0
  7. package/dist/api/generated/core/models/Itinerary.d.ts +14 -0
  8. package/dist/api/generated/core/models/Template.d.ts +13 -0
  9. package/dist/api/generated/itinerary/index.d.ts +5 -7
  10. package/dist/api/generated/itinerary/models/Component.d.ts +24 -0
  11. package/dist/api/generated/itinerary/models/ComponentInstance.d.ts +6 -0
  12. package/dist/api/generated/itinerary/models/DTORegionUpdate.d.ts +6 -0
  13. package/dist/api/generated/itinerary/models/Fee.d.ts +9 -0
  14. package/dist/api/generated/itinerary/models/Itinerary.d.ts +14 -0
  15. package/dist/api/generated/itinerary/models/Template.d.ts +13 -0
  16. package/dist/rendering/renderers/Subset.d.ts +1 -20
  17. package/dist/rendering/renderers/Subset.js +22 -42
  18. package/dist/rendering/schema/generate/jsonSchemaGenerate.js +22 -13
  19. package/dist/rendering/type_registration/register.js +14 -0
  20. package/package.json +1 -1
  21. package/dist/api/generated/core/models/BookingResponse.d.ts +0 -19
  22. package/dist/api/generated/core/models/CurrencyResponse.d.ts +0 -20
  23. package/dist/api/generated/core/models/Partner.d.ts +0 -10
  24. package/dist/api/generated/core/models/PartnerResponse.d.ts +0 -28
  25. package/dist/api/generated/core/models/SwooperResponse.d.ts +0 -7
  26. package/dist/api/generated/core/models/Traveller.d.ts +0 -37
  27. package/dist/api/generated/core/models/TravellerResponse.d.ts +0 -87
  28. package/dist/api/generated/itinerary/models/BookingResponse.d.ts +0 -19
  29. package/dist/api/generated/itinerary/models/CurrencyResponse.d.ts +0 -20
  30. package/dist/api/generated/itinerary/models/Partner.d.ts +0 -10
  31. package/dist/api/generated/itinerary/models/PartnerResponse.d.ts +0 -28
  32. package/dist/api/generated/itinerary/models/PartnerResponse.js +0 -1
  33. package/dist/api/generated/itinerary/models/SwooperResponse.d.ts +0 -7
  34. package/dist/api/generated/itinerary/models/SwooperResponse.js +0 -1
  35. package/dist/api/generated/itinerary/models/Traveller.d.ts +0 -37
  36. package/dist/api/generated/itinerary/models/Traveller.js +0 -1
  37. package/dist/api/generated/itinerary/models/TravellerResponse.d.ts +0 -87
  38. package/dist/api/generated/itinerary/models/TravellerResponse.js +0 -1
  39. /package/dist/api/generated/core/models/{BookingResponse.js → Component.js} +0 -0
  40. /package/dist/api/generated/core/models/{CurrencyResponse.js → DTORegionUpdate.js} +0 -0
  41. /package/dist/api/generated/core/models/{Partner.js → Fee.js} +0 -0
  42. /package/dist/api/generated/core/models/{PartnerResponse.js → Itinerary.js} +0 -0
  43. /package/dist/api/generated/core/models/{SwooperResponse.js → Template.js} +0 -0
  44. /package/dist/api/generated/{core/models/Traveller.js → itinerary/models/Component.js} +0 -0
  45. /package/dist/api/generated/{core/models/TravellerResponse.js → itinerary/models/DTORegionUpdate.js} +0 -0
  46. /package/dist/api/generated/itinerary/models/{BookingResponse.js → Fee.js} +0 -0
  47. /package/dist/api/generated/itinerary/models/{CurrencyResponse.js → Itinerary.js} +0 -0
  48. /package/dist/api/generated/itinerary/models/{Partner.js → Template.js} +0 -0
@@ -5,16 +5,15 @@ export type { AssignedTravellerGroup } from './index';
5
5
  export type { Assignments } from './index';
6
6
  export type { BookingItem } from './index';
7
7
  export type { BookingItemResponse } from './index';
8
- export type { BookingResponse } from './index';
9
8
  export type { Bundle } from './index';
10
9
  export type { BundleDay } from './index';
11
10
  export type { BundleItem } from './index';
11
+ export type { Component } from './index';
12
12
  export type { ComponentDetails } from './index';
13
13
  export type { componentId } from './index';
14
14
  export type { ComponentInstance } from './index';
15
15
  export type { CurrencyItem } from './index';
16
16
  export type { CurrencyItemResponse } from './index';
17
- export type { CurrencyResponse } from './index';
18
17
  export type { DTOComponentCreate } from './index';
19
18
  export type { DTOComponentRead } from './index';
20
19
  export type { DTOComponentUpdate } from './index';
@@ -23,29 +22,29 @@ export type { DTOItineraryRead } from './index';
23
22
  export type { DTOItineraryUpdate } from './index';
24
23
  export type { DTORegionCreate } from './index';
25
24
  export type { DTORegionRead } from './index';
25
+ export type { DTORegionUpdate } from './index';
26
26
  export type { DTOTemplateCreate } from './index';
27
27
  export type { DTOTemplateRead } from './index';
28
28
  export type { DTOTemplateUpdate } from './index';
29
29
  export type { enquiryId } from './index';
30
+ export type { Fee } from './index';
30
31
  export type { Field } from './index';
31
32
  export type { IBEvent } from './index';
32
33
  export type { id } from './index';
33
34
  export type { itemsPerPage } from './index';
35
+ export type { Itinerary } from './index';
34
36
  export type { itineraryId } from './index';
35
37
  export type { Limit } from './index';
36
38
  export type { Member } from './index';
37
39
  export type { Metadata } from './index';
38
40
  export type { Page } from './index';
39
41
  export type { Pagination } from './index';
40
- export type { Partner } from './index';
41
- export type { PartnerResponse } from './index';
42
42
  export type { Region } from './index';
43
43
  export { regionParam } from './index';
44
44
  export { regionRequired } from './index';
45
45
  export type { search } from './index';
46
46
  export type { sortParam } from './index';
47
- export type { SwooperResponse } from './index';
47
+ export type { Template } from './index';
48
48
  export type { templateId } from './index';
49
- export type { TravellerResponse } from './index';
50
49
  export type { UserComponentInstanceField } from './index';
51
50
  export type { ValidationSchemas } from './index';
@@ -7,16 +7,15 @@ export type { AssignedTravellerGroup } from './models/AssignedTravellerGroup';
7
7
  export type { Assignments } from './models/Assignments';
8
8
  export type { BookingItem } from './models/BookingItem';
9
9
  export type { BookingItemResponse } from './models/BookingItemResponse';
10
- export type { BookingResponse } from './models/BookingResponse';
11
10
  export type { Bundle } from './models/Bundle';
12
11
  export type { BundleDay } from './models/BundleDay';
13
12
  export type { BundleItem } from './models/BundleItem';
13
+ export type { Component } from './models/Component';
14
14
  export type { ComponentDetails } from './models/ComponentDetails';
15
15
  export type { componentId } from './models/componentId';
16
16
  export type { ComponentInstance } from './models/ComponentInstance';
17
17
  export type { CurrencyItem } from './models/CurrencyItem';
18
18
  export type { CurrencyItemResponse } from './models/CurrencyItemResponse';
19
- export type { CurrencyResponse } from './models/CurrencyResponse';
20
19
  export type { DTOComponentCreate } from './models/DTOComponentCreate';
21
20
  export type { DTOComponentRead } from './models/DTOComponentRead';
22
21
  export type { DTOComponentUpdate } from './models/DTOComponentUpdate';
@@ -25,31 +24,30 @@ export type { DTOItineraryRead } from './models/DTOItineraryRead';
25
24
  export type { DTOItineraryUpdate } from './models/DTOItineraryUpdate';
26
25
  export type { DTORegionCreate } from './models/DTORegionCreate';
27
26
  export type { DTORegionRead } from './models/DTORegionRead';
27
+ export type { DTORegionUpdate } from './models/DTORegionUpdate';
28
28
  export type { DTOTemplateCreate } from './models/DTOTemplateCreate';
29
29
  export type { DTOTemplateRead } from './models/DTOTemplateRead';
30
30
  export type { DTOTemplateUpdate } from './models/DTOTemplateUpdate';
31
31
  export type { enquiryId } from './models/enquiryId';
32
+ export type { Fee } from './models/Fee';
32
33
  export type { Field } from './models/Field';
33
34
  export type { IBEvent } from './models/IBEvent';
34
35
  export type { id } from './models/id';
35
36
  export type { itemsPerPage } from './models/itemsPerPage';
37
+ export type { Itinerary } from './models/Itinerary';
36
38
  export type { itineraryId } from './models/itineraryId';
37
39
  export type { Limit } from './models/Limit';
38
40
  export type { Member } from './models/Member';
39
41
  export type { Metadata } from './models/Metadata';
40
42
  export type { Page } from './models/Page';
41
43
  export type { Pagination } from './models/Pagination';
42
- export type { Partner } from './models/Partner';
43
- export type { PartnerResponse } from './models/PartnerResponse';
44
44
  export type { Region } from './models/Region';
45
45
  export { regionParam } from './models/regionParam';
46
46
  export { regionRequired } from './models/regionRequired';
47
47
  export type { search } from './models/search';
48
48
  export type { sortParam } from './models/sortParam';
49
- export type { SwooperResponse } from './models/SwooperResponse';
49
+ export type { Template } from './models/Template';
50
50
  export type { templateId } from './models/templateId';
51
- export type { Traveller } from './models/Traveller';
52
- export type { TravellerResponse } from './models/TravellerResponse';
53
51
  export type { UserComponentInstanceField } from './models/UserComponentInstanceField';
54
52
  export type { ValidationSchemas } from './models/ValidationSchemas';
55
53
  export { CoreService } from './services/CoreService';
@@ -0,0 +1,24 @@
1
+ import type { Bundle } from './Bundle';
2
+ import type { ComponentDetails } from './ComponentDetails';
3
+ import type { Field } from './Field';
4
+ import type { Metadata } from './Metadata';
5
+ export type Component = {
6
+ /**
7
+ * Unique identifier
8
+ */
9
+ id: string;
10
+ orgId: string;
11
+ templateId: string;
12
+ revisionGroupId: string;
13
+ revision: number;
14
+ metadata: Metadata;
15
+ name: string;
16
+ componentFields: Array<Field>;
17
+ partners: Array<string>;
18
+ startDate?: string | null;
19
+ endDate?: string | null;
20
+ duration?: number | null;
21
+ details: ComponentDetails;
22
+ bundle: Bundle;
23
+ state?: string | null;
24
+ };
@@ -11,4 +11,10 @@ export type ComponentInstance = {
11
11
  userComponentInstanceFields: Array<UserComponentInstanceField>;
12
12
  assignedPassengers: Array<AssignedPassenger>;
13
13
  assignedTravellerGroups: Array<AssignedTravellerGroup>;
14
+ startDate?: string;
15
+ endDate?: string;
16
+ price?: number;
17
+ currency?: string;
18
+ commissionPercent?: number;
19
+ partner?: string;
14
20
  };
@@ -0,0 +1,6 @@
1
+ export type DTORegionUpdate = {
2
+ name: string;
3
+ description: string;
4
+ destination: string;
5
+ images: Array<string>;
6
+ };
@@ -0,0 +1,9 @@
1
+ import type { AssignedPassenger } from './AssignedPassenger';
2
+ export type Fee = {
3
+ name: string;
4
+ reason: string;
5
+ type: string;
6
+ price: number;
7
+ currency: string;
8
+ assignedPassenger: AssignedPassenger;
9
+ };
@@ -0,0 +1,14 @@
1
+ import type { ComponentInstance } from './ComponentInstance';
2
+ import type { Fee } from './Fee';
3
+ import type { Metadata } from './Metadata';
4
+ export type Itinerary = {
5
+ /**
6
+ * Unique identifier
7
+ */
8
+ id: string;
9
+ title: string;
10
+ enquirerId: string;
11
+ metadata: Metadata;
12
+ componentInstances: Array<ComponentInstance>;
13
+ fees: Array<Fee>;
14
+ };
@@ -0,0 +1,13 @@
1
+ import type { Metadata } from './Metadata';
2
+ import type { ValidationSchemas } from './ValidationSchemas';
3
+ export type Template = {
4
+ id: string;
5
+ orgId: string;
6
+ parentRevisionGroupId: string;
7
+ revisionGroupId: string;
8
+ revision: number;
9
+ metadata: Metadata;
10
+ name: string;
11
+ masterSchema: string;
12
+ validationSchemas: ValidationSchemas;
13
+ };
@@ -7,16 +7,15 @@ export type { AssignedTravellerGroup } from './models/AssignedTravellerGroup';
7
7
  export type { Assignments } from './models/Assignments';
8
8
  export type { BookingItem } from './models/BookingItem';
9
9
  export type { BookingItemResponse } from './models/BookingItemResponse';
10
- export type { BookingResponse } from './models/BookingResponse';
11
10
  export type { Bundle } from './models/Bundle';
12
11
  export type { BundleDay } from './models/BundleDay';
13
12
  export type { BundleItem } from './models/BundleItem';
13
+ export type { Component } from './models/Component';
14
14
  export type { ComponentDetails } from './models/ComponentDetails';
15
15
  export type { componentId } from './models/componentId';
16
16
  export type { ComponentInstance } from './models/ComponentInstance';
17
17
  export type { CurrencyItem } from './models/CurrencyItem';
18
18
  export type { CurrencyItemResponse } from './models/CurrencyItemResponse';
19
- export type { CurrencyResponse } from './models/CurrencyResponse';
20
19
  export type { DTOComponentCreate } from './models/DTOComponentCreate';
21
20
  export type { DTOComponentRead } from './models/DTOComponentRead';
22
21
  export type { DTOComponentUpdate } from './models/DTOComponentUpdate';
@@ -25,31 +24,30 @@ export type { DTOItineraryRead } from './models/DTOItineraryRead';
25
24
  export type { DTOItineraryUpdate } from './models/DTOItineraryUpdate';
26
25
  export type { DTORegionCreate } from './models/DTORegionCreate';
27
26
  export type { DTORegionRead } from './models/DTORegionRead';
27
+ export type { DTORegionUpdate } from './models/DTORegionUpdate';
28
28
  export type { DTOTemplateCreate } from './models/DTOTemplateCreate';
29
29
  export type { DTOTemplateRead } from './models/DTOTemplateRead';
30
30
  export type { DTOTemplateUpdate } from './models/DTOTemplateUpdate';
31
31
  export type { enquiryId } from './models/enquiryId';
32
+ export type { Fee } from './models/Fee';
32
33
  export type { Field } from './models/Field';
33
34
  export type { IBEvent } from './models/IBEvent';
34
35
  export type { id } from './models/id';
35
36
  export type { itemsPerPage } from './models/itemsPerPage';
37
+ export type { Itinerary } from './models/Itinerary';
36
38
  export type { itineraryId } from './models/itineraryId';
37
39
  export type { Limit } from './models/Limit';
38
40
  export type { Member } from './models/Member';
39
41
  export type { Metadata } from './models/Metadata';
40
42
  export type { Page } from './models/Page';
41
43
  export type { Pagination } from './models/Pagination';
42
- export type { Partner } from './models/Partner';
43
- export type { PartnerResponse } from './models/PartnerResponse';
44
44
  export type { Region } from './models/Region';
45
45
  export { regionParam } from './models/regionParam';
46
46
  export { regionRequired } from './models/regionRequired';
47
47
  export type { search } from './models/search';
48
48
  export type { sortParam } from './models/sortParam';
49
- export type { SwooperResponse } from './models/SwooperResponse';
49
+ export type { Template } from './models/Template';
50
50
  export type { templateId } from './models/templateId';
51
- export type { Traveller } from './models/Traveller';
52
- export type { TravellerResponse } from './models/TravellerResponse';
53
51
  export type { UserComponentInstanceField } from './models/UserComponentInstanceField';
54
52
  export type { ValidationSchemas } from './models/ValidationSchemas';
55
53
  export { ItineraryService } from './services/ItineraryService';
@@ -0,0 +1,24 @@
1
+ import type { Bundle } from './Bundle';
2
+ import type { ComponentDetails } from './ComponentDetails';
3
+ import type { Field } from './Field';
4
+ import type { Metadata } from './Metadata';
5
+ export type Component = {
6
+ /**
7
+ * Unique identifier
8
+ */
9
+ id: string;
10
+ orgId: string;
11
+ templateId: string;
12
+ revisionGroupId: string;
13
+ revision: number;
14
+ metadata: Metadata;
15
+ name: string;
16
+ componentFields: Array<Field>;
17
+ partners: Array<string>;
18
+ startDate?: string | null;
19
+ endDate?: string | null;
20
+ duration?: number | null;
21
+ details: ComponentDetails;
22
+ bundle: Bundle;
23
+ state?: string | null;
24
+ };
@@ -11,4 +11,10 @@ export type ComponentInstance = {
11
11
  userComponentInstanceFields: Array<UserComponentInstanceField>;
12
12
  assignedPassengers: Array<AssignedPassenger>;
13
13
  assignedTravellerGroups: Array<AssignedTravellerGroup>;
14
+ startDate?: string;
15
+ endDate?: string;
16
+ price?: number;
17
+ currency?: string;
18
+ commissionPercent?: number;
19
+ partner?: string;
14
20
  };
@@ -0,0 +1,6 @@
1
+ export type DTORegionUpdate = {
2
+ name: string;
3
+ description: string;
4
+ destination: string;
5
+ images: Array<string>;
6
+ };
@@ -0,0 +1,9 @@
1
+ import type { AssignedPassenger } from './AssignedPassenger';
2
+ export type Fee = {
3
+ name: string;
4
+ reason: string;
5
+ type: string;
6
+ price: number;
7
+ currency: string;
8
+ assignedPassenger: AssignedPassenger;
9
+ };
@@ -0,0 +1,14 @@
1
+ import type { ComponentInstance } from './ComponentInstance';
2
+ import type { Fee } from './Fee';
3
+ import type { Metadata } from './Metadata';
4
+ export type Itinerary = {
5
+ /**
6
+ * Unique identifier
7
+ */
8
+ id: string;
9
+ title: string;
10
+ enquirerId: string;
11
+ metadata: Metadata;
12
+ componentInstances: Array<ComponentInstance>;
13
+ fees: Array<Fee>;
14
+ };
@@ -0,0 +1,13 @@
1
+ import type { Metadata } from './Metadata';
2
+ import type { ValidationSchemas } from './ValidationSchemas';
3
+ export type Template = {
4
+ id: string;
5
+ orgId: string;
6
+ parentRevisionGroupId: string;
7
+ revisionGroupId: string;
8
+ revision: number;
9
+ metadata: Metadata;
10
+ name: string;
11
+ masterSchema: string;
12
+ validationSchemas: ValidationSchemas;
13
+ };
@@ -1,20 +1 @@
1
- import { DTOComponentRead } from '../../api/generated/core/exports';
2
- export declare const fetchComponents: () => Promise<{
3
- data: {
4
- revisions: DTOComponentRead[];
5
- id: string;
6
- templateId: string;
7
- revisionGroupId: string;
8
- revision: number;
9
- metadata: import("../../api/generated/core").Metadata;
10
- name: string;
11
- componentFields: Array<import("../../api/generated/core").Field>;
12
- partners: Array<string>;
13
- bundle: Array<import("../../api/generated/core").Bundle>;
14
- startDate?: string | null;
15
- endDate?: string | null;
16
- duration?: number | null;
17
- details: import("../../api/generated/core").ComponentDetails;
18
- state?: string | null;
19
- }[];
20
- }>;
1
+ export {};
@@ -7,61 +7,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import React, { useEffect, useMemo, useState } from 'react';
11
- import { Paper, Typography, Box, TextField, Autocomplete } from '@mui/material';
10
+ import React, { useEffect, useState } from 'react';
12
11
  import { useLocalErrors } from '../hooks/errors';
13
12
  import { ComponentPool } from '../registry/types';
14
13
  import { registerComponent } from '../registry/components';
15
14
  import { CoreService } from '../../api/generated/core';
16
- const FormComponentPicker = ({ components, selectedComponent, onChange, set, getError, label, enabled }) => {
17
- const selected = components.find(c => c.id === selectedComponent) || null;
18
- return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
19
- React.createElement(Typography, { variant: 'h6' }, label),
20
- React.createElement(Autocomplete, { options: components, getOptionLabel: (option) => option.name, getOptionKey: o => o.id, value: selected, onChange: (_, newValue) => onChange(newValue ? newValue.id : null), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { variant: "outlined", placeholder: "Search and select a component", disabled: !enabled }))), renderOption: (props, option) => (React.createElement("li", Object.assign({}, props),
21
- React.createElement(Box, null,
22
- React.createElement(Typography, { variant: "body1" }, option.name),
23
- React.createElement(Typography, { variant: "caption", color: "text.secondary" },
24
- "Version: v",
25
- option.revision)))), isOptionEqualToValue: (option, value) => option.id === value.id })));
26
- };
27
- const FormRendererComponentPicker = ({ data, handleChange, path, label, enabled, schema }) => {
28
- const [components, setComponents] = useState([]);
15
+ const FormRendererSubset = ({ data, handleChange, path, label, enabled, schema }) => {
16
+ // This needs to know the template and the component id... wip
17
+ const componentId = "";
18
+ const templateId = "";
19
+ const [component, setComponent] = useState();
29
20
  const getError = useLocalErrors(path);
30
- const set = useMemo(() =>
31
21
  // @ts-ignore
32
- schema['x-set'] || [], [schema]);
22
+ const set = schema['x-set'] || [];
33
23
  useEffect(() => {
34
24
  const load = () => __awaiter(void 0, void 0, void 0, function* () {
35
25
  try {
36
- const fetched = yield fetchComponents();
37
- let filtered = fetched.data;
38
- if (set.length > 0) {
39
- filtered = filtered.filter(c => set.includes(c.templateId));
40
- }
41
- setComponents(filtered);
26
+ const comp = yield (new CoreService).componentGet(componentId);
27
+ setComponent(comp);
42
28
  }
43
29
  catch (err) {
44
- console.error('Error loading components:', err);
30
+ console.error('Error loading component:', err);
45
31
  }
46
32
  });
47
33
  load();
48
34
  }, [set]);
49
- return (React.createElement(FormComponentPicker, { components: components, selectedComponent: data || null, onChange: (id) => handleChange(path, id), set: set, getError: getError, label: label, enabled: enabled }));
35
+ const compData = component === null || component === void 0 ? void 0 : component.componentFields.find(f => f.templateId === templateId);
36
+ // Extract correct data obj, should be array of strings
37
+ const extracted = compData === null || compData === void 0 ? void 0 : compData.data; //.evalPath(path)
38
+ return React.createElement(React.Fragment, null, "WIP");
39
+ /*
40
+ return (
41
+ <Autocomplete
42
+ options={ }>
43
+
44
+ </Autocomplete>
45
+ )*/
50
46
  };
51
- registerComponent("TEMP DONT USE", FormRendererComponentPicker, ComponentPool.FORM);
52
- export const fetchComponents = () => __awaiter(void 0, void 0, void 0, function* () {
53
- const componentsByGroup = new Map();
54
- const data = yield (new CoreService).componentList(1, 1000);
55
- (data.data || []).forEach((component) => {
56
- const groupId = component.revisionGroupId;
57
- if (!componentsByGroup.has(groupId)) {
58
- componentsByGroup.set(groupId, []);
59
- }
60
- componentsByGroup.get(groupId).push(component);
61
- });
62
- const latestComponents = Array.from(componentsByGroup.values()).map((components) => {
63
- const sortedComponents = components.sort((a, b) => b.revision - a.revision);
64
- return Object.assign(Object.assign({}, sortedComponents[0]), { revisions: sortedComponents });
65
- });
66
- return { data: latestComponents };
67
- });
47
+ registerComponent("TEMP DONT USE", FormRendererSubset, ComponentPool.FORM);
@@ -9,7 +9,7 @@ export const generateJsonSchema = (formSchema, stage, onlyEditableFields) => {
9
9
  properties: {},
10
10
  required: [],
11
11
  };
12
- formSchema.forEach(s => {
12
+ formSchema.forEach((s) => {
13
13
  if (stage < s.existsFrom)
14
14
  return;
15
15
  if (onlyEditableFields && !s.editableIn.includes(stage))
@@ -32,12 +32,17 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
32
32
  field.fieldType = (_a = field.fieldType) !== null && _a !== void 0 ? _a : "string";
33
33
  let schema = getType(field.fieldType);
34
34
  if (!schema)
35
- throw new Error("tried to generate schema from unknown type: " + field.fieldType + "\nFull object: " + JSON.stringify(field, null, 2));
35
+ throw new Error("tried to generate schema from unknown type: " +
36
+ field.fieldType +
37
+ "\nFull object: " +
38
+ JSON.stringify(field, null, 2));
36
39
  const requiredFields = [];
37
40
  if (field.required)
38
41
  requiredFields.push(field.name);
39
42
  // Specific for array
40
- let arrayItems = field.fieldType === "array" ? defaultConverter((_b = field.arrayOptions) === null || _b === void 0 ? void 0 : _b.itemDefinition, stage, true, true) : undefined;
43
+ let arrayItems = field.fieldType === "array"
44
+ ? defaultConverter((_b = field.arrayOptions) === null || _b === void 0 ? void 0 : _b.itemDefinition, stage, true, true)
45
+ : undefined;
41
46
  // Obj childs
42
47
  const properties = {};
43
48
  for (const child of (_d = (_c = field.objectOptions) === null || _c === void 0 ? void 0 : _c.properties) !== null && _d !== void 0 ? _d : []) {
@@ -46,16 +51,20 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
46
51
  if (child.required)
47
52
  requiredFields.push(fieldId);
48
53
  }
49
- // Enum fails if empty, fixes
50
- let enumOpts = field.fieldType === "enum" ? (() => {
51
- var _a;
52
- let enumOptions = (((_a = field.enumOptions) === null || _a === void 0 ? void 0 : _a.enumValues) || []);
53
- if (enumOptions.length === 0)
54
- enumOptions.push("");
55
- return enumOptions;
56
- })() : undefined;
54
+ let enumOpts = field.fieldType === "enum" || field.fieldType === "stagedEnum"
55
+ ? (() => {
56
+ var _a;
57
+ let enumOptions = (((_a = field.enumOptions) === null || _a === void 0 ? void 0 : _a.enumValues) ||
58
+ []);
59
+ if (enumOptions.length === 0)
60
+ enumOptions.push("");
61
+ return enumOptions;
62
+ })()
63
+ : undefined;
57
64
  // Component (probably should change this)
58
- let templates = field.fieldType === "componentPicker" ? { "x-templateIds": (_e = field.componentOptions) === null || _e === void 0 ? void 0 : _e.templateIds } : {};
65
+ let templates = field.fieldType === "componentPicker"
66
+ ? { "x-templateIds": (_e = field.componentOptions) === null || _e === void 0 ? void 0 : _e.templateIds }
67
+ : {};
59
68
  let title = omitTitle ? undefined : field.name;
60
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((!isChild && !field.editableIn.includes(stage)) && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), { required: requiredFields }), (enumOpts && { enum: enumOpts })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties }));
69
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (!isChild && !field.editableIn.includes(stage) && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), { required: requiredFields }), (enumOpts && { enum: enumOpts })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties }));
61
70
  };
@@ -40,6 +40,20 @@ registerType("enum", "Dropdown", { type: "string" }, {
40
40
  }
41
41
  }
42
42
  }, true);
43
+ registerType("stagedEnum", "Staged Dropdown", {
44
+ type: "array",
45
+ items: { type: "string" },
46
+ }, {
47
+ type: "object",
48
+ title: "Dropdown Options",
49
+ properties: {
50
+ enumValues: {
51
+ title: "Dropdown Values",
52
+ type: "array",
53
+ items: { type: "string" },
54
+ },
55
+ },
56
+ }, true);
43
57
  registerType("array", "List", { type: "array" }, {
44
58
  type: "object",
45
59
  title: "List Options",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swoop-common",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "main": "dist/api/index.js",
5
5
  "types": "dist/api/index.d.ts",
6
6
  "exports": {
@@ -1,19 +0,0 @@
1
- export type BookingResponse = {
2
- '@type': string;
3
- categories: {
4
- '@context': string;
5
- '@id': string;
6
- '@type': string;
7
- totalItems: number;
8
- member: {
9
- '@id': string;
10
- '@type': string;
11
- id: string;
12
- categoryId: number;
13
- title: string;
14
- alias: string;
15
- entitytype: string;
16
- active: boolean;
17
- };
18
- };
19
- };
@@ -1,20 +0,0 @@
1
- export type CurrencyResponse = {
2
- '@type': string;
3
- currencies: {
4
- '@context': string;
5
- '@id': string;
6
- '@type': string;
7
- totalItems: number;
8
- member: {
9
- '@id': string;
10
- '@type': string;
11
- id: string;
12
- currencyId: number;
13
- title: string;
14
- alias: string;
15
- iso3: string;
16
- symbol: string;
17
- active: boolean;
18
- };
19
- };
20
- };
@@ -1,10 +0,0 @@
1
- export type Partner = {
2
- '@context': string;
3
- '@id': string;
4
- '@type': string;
5
- id: string;
6
- partnerId: number;
7
- title: string;
8
- alias: string;
9
- description: string;
10
- };
@@ -1,28 +0,0 @@
1
- export type PartnerResponse = {
2
- '@context': string;
3
- '@id': string;
4
- '@type': string;
5
- totalItems: number;
6
- member: Array<{
7
- '@id': string;
8
- '@type': string;
9
- id: string;
10
- partnerId: number;
11
- title: string;
12
- alias?: string;
13
- description?: string;
14
- telephone?: string;
15
- email?: string;
16
- name?: string;
17
- }>;
18
- search: {
19
- '@type': string;
20
- template: string;
21
- variableRepresentation: string;
22
- mapping: Record<string, any>;
23
- };
24
- view: {
25
- '@id': string;
26
- '@type': string;
27
- };
28
- };
@@ -1,7 +0,0 @@
1
- import type { Member } from './Member';
2
- export type SwooperResponse = {
3
- people: {
4
- totalItems: number;
5
- member: Array<Member>;
6
- };
7
- };
@@ -1,37 +0,0 @@
1
- export type Traveller = {
2
- id: string;
3
- travellerId: number;
4
- customer: {
5
- '@id': string;
6
- '@type': string;
7
- id: string;
8
- customerId: number;
9
- firstName: string;
10
- email: string;
11
- telephone1: string;
12
- region: string;
13
- 'time|one': string;
14
- address: Record<string, any>;
15
- passport: {
16
- '@type': string;
17
- '@id': string;
18
- country: {
19
- '@type': string;
20
- '@id': string;
21
- country_id: number;
22
- title: string;
23
- alias: string;
24
- };
25
- };
26
- emergencyDetails: Record<string, any>;
27
- };
28
- travellerGroup: {
29
- '@type': string;
30
- '@id': string;
31
- id: string;
32
- traveller_group_id: number;
33
- enquiry_id: number;
34
- title: string;
35
- payment_status: string;
36
- };
37
- };
@@ -1,87 +0,0 @@
1
- import type { Assignments } from './Assignments';
2
- export type TravellerResponse = {
3
- '@id': string;
4
- travellers: {
5
- '@context': string;
6
- '@id': string;
7
- '@type': string;
8
- totalItems: number;
9
- member: {
10
- '@id': string;
11
- '@type': string;
12
- id: string;
13
- travellerId: number;
14
- customer: {
15
- '@id': string;
16
- '@type': string;
17
- id: number;
18
- customerId: string;
19
- firstName: string;
20
- lastName: string;
21
- email: string;
22
- telephone1: string;
23
- dateOfBirth: string;
24
- region: string;
25
- timeZone?: string;
26
- dietaryRequirements: string;
27
- foodAllergies: string;
28
- medicalConditions: string;
29
- specialOccasion: string;
30
- roomTyoe: string;
31
- roomNotes: string;
32
- address: {
33
- '@type': string;
34
- '@id': string;
35
- address_1: string;
36
- town: string;
37
- state: string;
38
- postcode: string;
39
- };
40
- passport: {
41
- '@type': string;
42
- '@id': string;
43
- passport_number: string;
44
- passport_expiry_date: string;
45
- passport_issue_date: string;
46
- country: {
47
- '@type': string;
48
- '@id': string;
49
- country_id: number;
50
- title: string;
51
- alias: string;
52
- };
53
- };
54
- emergencyDetails: {
55
- '@type': string;
56
- '@id': string;
57
- name: string;
58
- phone_number: string;
59
- relationship: string;
60
- email: string;
61
- };
62
- };
63
- travellerGroup: {
64
- '@type': string;
65
- '@id': string;
66
- id: string;
67
- traveller_group_id: number;
68
- enquiry_id: number;
69
- title: string;
70
- payment_status: string;
71
- srf_completed_at: string;
72
- srf_pg2_completed_at: string;
73
- };
74
- };
75
- search: {
76
- '@type': string;
77
- template: string;
78
- variableRepresentation: string;
79
- mapping: Record<string, any>;
80
- };
81
- view: {
82
- '@id': string;
83
- '@type': string;
84
- };
85
- };
86
- assignments: Assignments;
87
- };
@@ -1,19 +0,0 @@
1
- export type BookingResponse = {
2
- '@type': string;
3
- categories: {
4
- '@context': string;
5
- '@id': string;
6
- '@type': string;
7
- totalItems: number;
8
- member: {
9
- '@id': string;
10
- '@type': string;
11
- id: string;
12
- categoryId: number;
13
- title: string;
14
- alias: string;
15
- entitytype: string;
16
- active: boolean;
17
- };
18
- };
19
- };
@@ -1,20 +0,0 @@
1
- export type CurrencyResponse = {
2
- '@type': string;
3
- currencies: {
4
- '@context': string;
5
- '@id': string;
6
- '@type': string;
7
- totalItems: number;
8
- member: {
9
- '@id': string;
10
- '@type': string;
11
- id: string;
12
- currencyId: number;
13
- title: string;
14
- alias: string;
15
- iso3: string;
16
- symbol: string;
17
- active: boolean;
18
- };
19
- };
20
- };
@@ -1,10 +0,0 @@
1
- export type Partner = {
2
- '@context': string;
3
- '@id': string;
4
- '@type': string;
5
- id: string;
6
- partnerId: number;
7
- title: string;
8
- alias: string;
9
- description: string;
10
- };
@@ -1,28 +0,0 @@
1
- export type PartnerResponse = {
2
- '@context': string;
3
- '@id': string;
4
- '@type': string;
5
- totalItems: number;
6
- member: Array<{
7
- '@id': string;
8
- '@type': string;
9
- id: string;
10
- partnerId: number;
11
- title: string;
12
- alias?: string;
13
- description?: string;
14
- telephone?: string;
15
- email?: string;
16
- name?: string;
17
- }>;
18
- search: {
19
- '@type': string;
20
- template: string;
21
- variableRepresentation: string;
22
- mapping: Record<string, any>;
23
- };
24
- view: {
25
- '@id': string;
26
- '@type': string;
27
- };
28
- };
@@ -1,7 +0,0 @@
1
- import type { Member } from './Member';
2
- export type SwooperResponse = {
3
- people: {
4
- totalItems: number;
5
- member: Array<Member>;
6
- };
7
- };
@@ -1,37 +0,0 @@
1
- export type Traveller = {
2
- id: string;
3
- travellerId: number;
4
- customer: {
5
- '@id': string;
6
- '@type': string;
7
- id: string;
8
- customerId: number;
9
- firstName: string;
10
- email: string;
11
- telephone1: string;
12
- region: string;
13
- 'time|one': string;
14
- address: Record<string, any>;
15
- passport: {
16
- '@type': string;
17
- '@id': string;
18
- country: {
19
- '@type': string;
20
- '@id': string;
21
- country_id: number;
22
- title: string;
23
- alias: string;
24
- };
25
- };
26
- emergencyDetails: Record<string, any>;
27
- };
28
- travellerGroup: {
29
- '@type': string;
30
- '@id': string;
31
- id: string;
32
- traveller_group_id: number;
33
- enquiry_id: number;
34
- title: string;
35
- payment_status: string;
36
- };
37
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,87 +0,0 @@
1
- import type { Assignments } from './Assignments';
2
- export type TravellerResponse = {
3
- '@id': string;
4
- travellers: {
5
- '@context': string;
6
- '@id': string;
7
- '@type': string;
8
- totalItems: number;
9
- member: {
10
- '@id': string;
11
- '@type': string;
12
- id: string;
13
- travellerId: number;
14
- customer: {
15
- '@id': string;
16
- '@type': string;
17
- id: number;
18
- customerId: string;
19
- firstName: string;
20
- lastName: string;
21
- email: string;
22
- telephone1: string;
23
- dateOfBirth: string;
24
- region: string;
25
- timeZone?: string;
26
- dietaryRequirements: string;
27
- foodAllergies: string;
28
- medicalConditions: string;
29
- specialOccasion: string;
30
- roomTyoe: string;
31
- roomNotes: string;
32
- address: {
33
- '@type': string;
34
- '@id': string;
35
- address_1: string;
36
- town: string;
37
- state: string;
38
- postcode: string;
39
- };
40
- passport: {
41
- '@type': string;
42
- '@id': string;
43
- passport_number: string;
44
- passport_expiry_date: string;
45
- passport_issue_date: string;
46
- country: {
47
- '@type': string;
48
- '@id': string;
49
- country_id: number;
50
- title: string;
51
- alias: string;
52
- };
53
- };
54
- emergencyDetails: {
55
- '@type': string;
56
- '@id': string;
57
- name: string;
58
- phone_number: string;
59
- relationship: string;
60
- email: string;
61
- };
62
- };
63
- travellerGroup: {
64
- '@type': string;
65
- '@id': string;
66
- id: string;
67
- traveller_group_id: number;
68
- enquiry_id: number;
69
- title: string;
70
- payment_status: string;
71
- srf_completed_at: string;
72
- srf_pg2_completed_at: string;
73
- };
74
- };
75
- search: {
76
- '@type': string;
77
- template: string;
78
- variableRepresentation: string;
79
- mapping: Record<string, any>;
80
- };
81
- view: {
82
- '@id': string;
83
- '@type': string;
84
- };
85
- };
86
- assignments: Assignments;
87
- };