swoop-common 2.1.57 → 2.1.59

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 (40) hide show
  1. package/README.md +204 -204
  2. package/dist/api/fetch.d.ts +1 -0
  3. package/dist/api/fetch.js +20 -0
  4. package/dist/api/generated/core/exports.d.ts +6 -0
  5. package/dist/api/generated/core/index.d.ts +6 -0
  6. package/dist/api/generated/core/models/Amendment.d.ts +2 -0
  7. package/dist/api/generated/core/models/BranchId.d.ts +1 -0
  8. package/dist/api/generated/core/models/BranchId.js +1 -0
  9. package/dist/api/generated/core/models/BranchTag.d.ts +1 -0
  10. package/dist/api/generated/core/models/BranchTag.js +1 -0
  11. package/dist/api/generated/core/models/ComponentInstance.d.ts +2 -1
  12. package/dist/api/generated/core/models/DTOBranchCreate.d.ts +8 -0
  13. package/dist/api/generated/core/models/DTOBranchCreate.js +1 -0
  14. package/dist/api/generated/core/models/DTOBranchEntity.d.ts +11 -0
  15. package/dist/api/generated/core/models/DTOBranchEntity.js +1 -0
  16. package/dist/api/generated/core/models/DTOBranchRead.d.ts +11 -0
  17. package/dist/api/generated/core/models/DTOBranchRead.js +1 -0
  18. package/dist/api/generated/core/models/DTOBranchUpdate.d.ts +4 -0
  19. package/dist/api/generated/core/models/DTOBranchUpdate.js +1 -0
  20. package/dist/api/generated/core/models/DTOTemplateUpdate.d.ts +2 -1
  21. package/dist/api/generated/core/models/Package.d.ts +0 -2
  22. package/dist/api/generated/itinerary/index.d.ts +6 -0
  23. package/dist/api/generated/itinerary/models/Amendment.d.ts +2 -0
  24. package/dist/api/generated/itinerary/models/BranchId.d.ts +1 -0
  25. package/dist/api/generated/itinerary/models/BranchId.js +1 -0
  26. package/dist/api/generated/itinerary/models/BranchTag.d.ts +1 -0
  27. package/dist/api/generated/itinerary/models/BranchTag.js +1 -0
  28. package/dist/api/generated/itinerary/models/ComponentInstance.d.ts +2 -1
  29. package/dist/api/generated/itinerary/models/DTOBranchCreate.d.ts +8 -0
  30. package/dist/api/generated/itinerary/models/DTOBranchCreate.js +1 -0
  31. package/dist/api/generated/itinerary/models/DTOBranchEntity.d.ts +11 -0
  32. package/dist/api/generated/itinerary/models/DTOBranchEntity.js +1 -0
  33. package/dist/api/generated/itinerary/models/DTOBranchRead.d.ts +11 -0
  34. package/dist/api/generated/itinerary/models/DTOBranchRead.js +1 -0
  35. package/dist/api/generated/itinerary/models/DTOBranchUpdate.d.ts +4 -0
  36. package/dist/api/generated/itinerary/models/DTOBranchUpdate.js +1 -0
  37. package/dist/api/generated/itinerary/models/DTOTemplateUpdate.d.ts +2 -1
  38. package/dist/api/generated/itinerary/models/Package.d.ts +0 -2
  39. package/dist/rendering/schema/generate/jsonSchemaGenerate.js +5 -6
  40. package/package.json +63 -62
package/README.md CHANGED
@@ -1,204 +1,204 @@
1
- # Swoop Library
2
-
3
- This library is used for rendering **Swoop itinerary templates**.
4
- It provides tools for defining **custom field types**, registering **custom components**,
5
- rendering templates from a **MasterSchema**, and includes SDKs for all related services.
6
- It supports both input mode (for creating templates) and presentation mode (for rendering them for end users).
7
- The schema system is stage-aware, enabling precise control over what data is editable or displayed at which stage.
8
-
9
- > Note: This package is intended for internal use only.
10
-
11
- ---
12
-
13
- # Swoop Library
14
-
15
- ## Initialization
16
-
17
- Before using the Swoop Library, you must initialize it with service URLs:
18
-
19
- ```ts
20
- import { init } from 'swoop-common';
21
-
22
- init({
23
- itineraryServiceUrl: 'https://your.itinerary.service',
24
- coreServiceUrl: 'https://your.core.service',
25
- swoopServiceForwardUrl: 'https://your.forward.service'
26
- });
27
- ```
28
-
29
- ## Service Interfaces
30
-
31
- The library provides three primary service interfaces to interact with backend systems:
32
-
33
- - **SwoopService** — Interfaces with the Swoop API.
34
- - **ItineraryService** — For itinerary service.
35
- - **CoreService** — For core service.
36
-
37
- These interfaces offer convenient methods to work seamlessly with the underlying services required by the itinerary system.
38
-
39
- ## StyledFormView
40
-
41
- The `StyledFormView` component is the entry point for rendering a full itinerary template. It handles schema parsing and renderer injection based on mode and form stage.
42
-
43
- ```tsx
44
- import { StyledFormView } from 'your-form-library';
45
-
46
- <StyledFormView
47
- initialData={/* object */}
48
- schema={/* MasterSchema */}
49
- onChange={(val) => console.log(val)}
50
- pool="FORM"
51
- readonly={false}
52
- stage="Inst"
53
- />
54
- ```
55
-
56
- ### Props
57
-
58
- | Name | Type | Description |
59
- |--------------|-------------------------------|-----------------------------------------------------------------------------|
60
- | initialData | `any` | Initial values for the template. Should not be updated frequently. |
61
- | schema | `MasterSchema` | Template definition object. |
62
- | onChange | `(val: any) => void` | Callback with updated data. |
63
- | pool | `ComponentPool` | `"FORM"` or `"PRESENTATION"` depending on context. |
64
- | readonly | `boolean` | Disables inputs if true (only relevant in FORM pool). |
65
- | stage | `Stage` | Controls which data segment is being rendered. |
66
-
67
- ### Stages
68
-
69
- The template system is divided into stages:
70
-
71
- - **Stage.Comp** – Data stored on the root component, often static (e.g. metadata, titles). Does not include any dynamic or time-based fields.
72
- - **Stage.Inst** – Instance-specific data (e.g. timings, localized notes). This is the most common stage for editable fields.
73
- - **Stage.User** – Data unique to individual users (e.g. room number).
74
-
75
- Each stage builds on the one before it. For example, `Stage.User` includes everything from `Stage.Comp` and `Stage.Inst`. Fields are editable based on the current stage. If a value is defined in two stages, the lower stage will take priority.
76
-
77
- ---
78
-
79
- ## Custom Components
80
-
81
- Custom components define how individual fields render. These can behave like typical form inputs or be used for display-only formatting in the `PRESENTATION` pool.
82
-
83
- ### Example
84
-
85
- ```tsx
86
- const FormExample: React.FC<Props> = ({ text, onChange, getError, label, enabled }) => {
87
- const [val, setVal] = useState(text);
88
- const error = getError ? getError("example")?.message : undefined;
89
- const onChangeDebounced = useMemo(() => debounce(onChange, 300), [onChange]);
90
-
91
- const update = (value: string) => {
92
- setVal(value);
93
- onChangeDebounced(value);
94
- };
95
-
96
- return (
97
- <Paper sx={{ display: 'flex', flexDirection: 'column', gap: 1, p: 2, background: "#CBC3E3", mb: 1 }}>
98
- {!enabled && "THIS IS DISABLED"}
99
- <Typography variant='h6'>{label}</Typography>
100
- <TextField
101
- label="Example label"
102
- value={val}
103
- onChange={(e) => update(e.target.value)}
104
- error={!!error}
105
- helperText={error}
106
- disabled={!enabled}
107
- />
108
- </Paper>
109
- );
110
- };
111
-
112
- const FormRendererExample: React.FC<ControlProps> = ({ data, handleChange, path, label, enabled }) => {
113
- const getError = useLocalErrors(path);
114
- return (
115
- <FormExample
116
- text={data as string}
117
- onChange={(val) => handleChange(path, val)}
118
- getError={getError}
119
- label={label}
120
- enabled={enabled}
121
- />
122
- );
123
- };
124
-
125
- registerComponent("example", FormRendererExample, ComponentPool.FORM);
126
- registerComponent("example", FormRendererExample, ComponentPool.PRESENTATION);
127
- ```
128
-
129
- > Important: You **cannot register two components with the same name within the same pool**. You *can* register the same component name across different pools (e.g., `"example"` in both `"FORM"` and `"PRESENTATION"`).
130
-
131
- ### Presentation Pool
132
-
133
- The `PRESENTATION` pool is more than just read-only. It is designed for **customer-facing output**, rendering fields in a clean, non-form-like layout for readability and professionalism.
134
-
135
- ---
136
-
137
- ## Custom Types
138
-
139
- Custom field types define what kinds of fields can be used when **building a template**. These appear in the template builder UI as selectable field types and control how data is validated and configured.
140
-
141
- ### Syntax
142
-
143
- ```ts
144
- registerType(
145
- "typeId", // Unique type string
146
- "Display Name", // Name shown in template builder
147
- schema, // JSON Schema defining the data structure
148
- optionsSchema, // JSON Schema defining configuration data structure
149
- requiredOptions // boolean: must the options be filled?
150
- );
151
- ```
152
-
153
- ### Example
154
-
155
- ```ts
156
- registerType("enum", "Dropdown",
157
- { type: "array" },
158
- {
159
- type: "object",
160
- title: "Dropdown Options",
161
- properties: {
162
- enumValues: {
163
- title: "Dropdown Values",
164
- type: "array",
165
- items: { type: "string" }
166
- }
167
- }
168
- },
169
- true
170
- );
171
- ```
172
-
173
- This type defines a dropdown field where the values are defined via the `enumValues` property in the template configuration.
174
-
175
- ### Custom Option Editors
176
-
177
- If you want to render a **custom options block** (i.e., how the field type's options are displayed in the template editor), you must do the following:
178
-
179
- 1. In the top-level `optionsSchema` of the type, define `"x-type": "yourTypeName"`
180
- 2. Create and register a custom component with the name `"yourTypeName"` in the `"FORM"` pool.
181
-
182
- This component will then be used to render the configuration UI for that field type.
183
-
184
- ---
185
-
186
- ## File Locations
187
-
188
- - **Custom components** must be placed in `src/renderers`. They may be nested within subfolders. All files inside `renderers/` will be automatically imported in the correct order.
189
- - **Custom types** must be added to `src/default_registration/fields_base.tsx`.
190
-
191
- No manual import wiring is required beyond placing the file in the correct folder.
192
-
193
- ---
194
-
195
- ## Publishing to NPM
196
-
197
- To publish a new version of the package:
198
-
199
- ```bash
200
- npm run build # Compile the package
201
- npm version patch # Bump the patch version (or use minor/major as needed)
202
- npm adduser # Log in to NPM (if not already)
203
- npm publish # Publish the package
204
- ```
1
+ # Swoop Library
2
+
3
+ This library is used for rendering **Swoop itinerary templates**.
4
+ It provides tools for defining **custom field types**, registering **custom components**,
5
+ rendering templates from a **MasterSchema**, and includes SDKs for all related services.
6
+ It supports both input mode (for creating templates) and presentation mode (for rendering them for end users).
7
+ The schema system is stage-aware, enabling precise control over what data is editable or displayed at which stage.
8
+
9
+ > Note: This package is intended for internal use only.
10
+
11
+ ---
12
+
13
+ # Swoop Library
14
+
15
+ ## Initialization
16
+
17
+ Before using the Swoop Library, you must initialize it with service URLs:
18
+
19
+ ```ts
20
+ import { init } from 'swoop-common';
21
+
22
+ init({
23
+ itineraryServiceUrl: 'https://your.itinerary.service',
24
+ coreServiceUrl: 'https://your.core.service',
25
+ swoopServiceForwardUrl: 'https://your.forward.service'
26
+ });
27
+ ```
28
+
29
+ ## Service Interfaces
30
+
31
+ The library provides three primary service interfaces to interact with backend systems:
32
+
33
+ - **SwoopService** — Interfaces with the Swoop API.
34
+ - **ItineraryService** — For itinerary service.
35
+ - **CoreService** — For core service.
36
+
37
+ These interfaces offer convenient methods to work seamlessly with the underlying services required by the itinerary system.
38
+
39
+ ## StyledFormView
40
+
41
+ The `StyledFormView` component is the entry point for rendering a full itinerary template. It handles schema parsing and renderer injection based on mode and form stage.
42
+
43
+ ```tsx
44
+ import { StyledFormView } from 'your-form-library';
45
+
46
+ <StyledFormView
47
+ initialData={/* object */}
48
+ schema={/* MasterSchema */}
49
+ onChange={(val) => console.log(val)}
50
+ pool="FORM"
51
+ readonly={false}
52
+ stage="Inst"
53
+ />
54
+ ```
55
+
56
+ ### Props
57
+
58
+ | Name | Type | Description |
59
+ |--------------|-------------------------------|-----------------------------------------------------------------------------|
60
+ | initialData | `any` | Initial values for the template. Should not be updated frequently. |
61
+ | schema | `MasterSchema` | Template definition object. |
62
+ | onChange | `(val: any) => void` | Callback with updated data. |
63
+ | pool | `ComponentPool` | `"FORM"` or `"PRESENTATION"` depending on context. |
64
+ | readonly | `boolean` | Disables inputs if true (only relevant in FORM pool). |
65
+ | stage | `Stage` | Controls which data segment is being rendered. |
66
+
67
+ ### Stages
68
+
69
+ The template system is divided into stages:
70
+
71
+ - **Stage.Comp** – Data stored on the root component, often static (e.g. metadata, titles). Does not include any dynamic or time-based fields.
72
+ - **Stage.Inst** – Instance-specific data (e.g. timings, localized notes). This is the most common stage for editable fields.
73
+ - **Stage.User** – Data unique to individual users (e.g. room number).
74
+
75
+ Each stage builds on the one before it. For example, `Stage.User` includes everything from `Stage.Comp` and `Stage.Inst`. Fields are editable based on the current stage. If a value is defined in two stages, the lower stage will take priority.
76
+
77
+ ---
78
+
79
+ ## Custom Components
80
+
81
+ Custom components define how individual fields render. These can behave like typical form inputs or be used for display-only formatting in the `PRESENTATION` pool.
82
+
83
+ ### Example
84
+
85
+ ```tsx
86
+ const FormExample: React.FC<Props> = ({ text, onChange, getError, label, enabled }) => {
87
+ const [val, setVal] = useState(text);
88
+ const error = getError ? getError("example")?.message : undefined;
89
+ const onChangeDebounced = useMemo(() => debounce(onChange, 300), [onChange]);
90
+
91
+ const update = (value: string) => {
92
+ setVal(value);
93
+ onChangeDebounced(value);
94
+ };
95
+
96
+ return (
97
+ <Paper sx={{ display: 'flex', flexDirection: 'column', gap: 1, p: 2, background: "#CBC3E3", mb: 1 }}>
98
+ {!enabled && "THIS IS DISABLED"}
99
+ <Typography variant='h6'>{label}</Typography>
100
+ <TextField
101
+ label="Example label"
102
+ value={val}
103
+ onChange={(e) => update(e.target.value)}
104
+ error={!!error}
105
+ helperText={error}
106
+ disabled={!enabled}
107
+ />
108
+ </Paper>
109
+ );
110
+ };
111
+
112
+ const FormRendererExample: React.FC<ControlProps> = ({ data, handleChange, path, label, enabled }) => {
113
+ const getError = useLocalErrors(path);
114
+ return (
115
+ <FormExample
116
+ text={data as string}
117
+ onChange={(val) => handleChange(path, val)}
118
+ getError={getError}
119
+ label={label}
120
+ enabled={enabled}
121
+ />
122
+ );
123
+ };
124
+
125
+ registerComponent("example", FormRendererExample, ComponentPool.FORM);
126
+ registerComponent("example", FormRendererExample, ComponentPool.PRESENTATION);
127
+ ```
128
+
129
+ > Important: You **cannot register two components with the same name within the same pool**. You *can* register the same component name across different pools (e.g., `"example"` in both `"FORM"` and `"PRESENTATION"`).
130
+
131
+ ### Presentation Pool
132
+
133
+ The `PRESENTATION` pool is more than just read-only. It is designed for **customer-facing output**, rendering fields in a clean, non-form-like layout for readability and professionalism.
134
+
135
+ ---
136
+
137
+ ## Custom Types
138
+
139
+ Custom field types define what kinds of fields can be used when **building a template**. These appear in the template builder UI as selectable field types and control how data is validated and configured.
140
+
141
+ ### Syntax
142
+
143
+ ```ts
144
+ registerType(
145
+ "typeId", // Unique type string
146
+ "Display Name", // Name shown in template builder
147
+ schema, // JSON Schema defining the data structure
148
+ optionsSchema, // JSON Schema defining configuration data structure
149
+ requiredOptions // boolean: must the options be filled?
150
+ );
151
+ ```
152
+
153
+ ### Example
154
+
155
+ ```ts
156
+ registerType("enum", "Dropdown",
157
+ { type: "array" },
158
+ {
159
+ type: "object",
160
+ title: "Dropdown Options",
161
+ properties: {
162
+ enumValues: {
163
+ title: "Dropdown Values",
164
+ type: "array",
165
+ items: { type: "string" }
166
+ }
167
+ }
168
+ },
169
+ true
170
+ );
171
+ ```
172
+
173
+ This type defines a dropdown field where the values are defined via the `enumValues` property in the template configuration.
174
+
175
+ ### Custom Option Editors
176
+
177
+ If you want to render a **custom options block** (i.e., how the field type's options are displayed in the template editor), you must do the following:
178
+
179
+ 1. In the top-level `optionsSchema` of the type, define `"x-type": "yourTypeName"`
180
+ 2. Create and register a custom component with the name `"yourTypeName"` in the `"FORM"` pool.
181
+
182
+ This component will then be used to render the configuration UI for that field type.
183
+
184
+ ---
185
+
186
+ ## File Locations
187
+
188
+ - **Custom components** must be placed in `src/renderers`. They may be nested within subfolders. All files inside `renderers/` will be automatically imported in the correct order.
189
+ - **Custom types** must be added to `src/default_registration/fields_base.tsx`.
190
+
191
+ No manual import wiring is required beyond placing the file in the correct folder.
192
+
193
+ ---
194
+
195
+ ## Publishing to NPM
196
+
197
+ To publish a new version of the package:
198
+
199
+ ```bash
200
+ npm run build # Compile the package
201
+ npm version patch # Bump the patch version (or use minor/major as needed)
202
+ npm adduser # Log in to NPM (if not already)
203
+ npm publish # Publish the package
204
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from "fs";
11
+ const getSpec = (file) => __awaiter(void 0, void 0, void 0, function* () {
12
+ const gotted = yield fetch("https://openapi-specs.vercel.app/" + file);
13
+ return gotted.text();
14
+ });
15
+ const saveSpec = (file, specs) => {
16
+ fs.writeFileSync("./openapi/" + file, specs);
17
+ };
18
+ getSpec("models.yaml").then(spec => saveSpec("models.yaml", spec));
19
+ getSpec("core_data_service.yaml").then(spec => saveSpec("core_service.yaml", spec));
20
+ getSpec("itinerary_service.yaml").then(spec => saveSpec("itinerary_service.yaml", spec));
@@ -4,6 +4,8 @@ export type { Amendment } from './index';
4
4
  export type { AssignedPassenger } from './index';
5
5
  export type { AssignedTravellerGroup } from './index';
6
6
  export { BookingStatus } from './index';
7
+ export type { BranchId } from './index';
8
+ export type { BranchTag } from './index';
7
9
  export type { ComponentDescription } from './index';
8
10
  export type { ComponentFAQ } from './index';
9
11
  export type { ComponentId } from './index';
@@ -16,6 +18,10 @@ export { ComponentState } from './index';
16
18
  export { Currency } from './index';
17
19
  export { Destination } from './index';
18
20
  export type { Discount } from './index';
21
+ export type { DTOBranchCreate } from './index';
22
+ export type { DTOBranchEntity } from './index';
23
+ export type { DTOBranchRead } from './index';
24
+ export type { DTOBranchUpdate } from './index';
19
25
  export type { DTOComponentCreate } from './index';
20
26
  export type { DTOComponentEntity } from './index';
21
27
  export type { DTOComponentRead } from './index';
@@ -6,6 +6,8 @@ export type { Amendment } from './models/Amendment';
6
6
  export type { AssignedPassenger } from './models/AssignedPassenger';
7
7
  export type { AssignedTravellerGroup } from './models/AssignedTravellerGroup';
8
8
  export { BookingStatus } from './models/BookingStatus';
9
+ export type { BranchId } from './models/BranchId';
10
+ export type { BranchTag } from './models/BranchTag';
9
11
  export type { ComponentDescription } from './models/ComponentDescription';
10
12
  export type { ComponentFAQ } from './models/ComponentFAQ';
11
13
  export type { ComponentId } from './models/ComponentId';
@@ -18,6 +20,10 @@ export { ComponentState } from './models/ComponentState';
18
20
  export { Currency } from './models/Currency';
19
21
  export { Destination } from './models/Destination';
20
22
  export type { Discount } from './models/Discount';
23
+ export type { DTOBranchCreate } from './models/DTOBranchCreate';
24
+ export type { DTOBranchEntity } from './models/DTOBranchEntity';
25
+ export type { DTOBranchRead } from './models/DTOBranchRead';
26
+ export type { DTOBranchUpdate } from './models/DTOBranchUpdate';
21
27
  export type { DTOComponentCreate } from './models/DTOComponentCreate';
22
28
  export type { DTOComponentEntity } from './models/DTOComponentEntity';
23
29
  export type { DTOComponentRead } from './models/DTOComponentRead';
@@ -1,6 +1,8 @@
1
+ import type { AssignedPassenger } from './AssignedPassenger';
1
2
  import type { Price } from './Price';
2
3
  import type { Title } from './Title';
3
4
  export type Amendment = {
4
5
  name: Title;
5
6
  price: Price;
7
+ assignedPassenger: AssignedPassenger;
6
8
  };
@@ -0,0 +1 @@
1
+ export type BranchId = string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type BranchTag = string;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,12 +2,13 @@ import type { Amendment } from './Amendment';
2
2
  import type { AssignedPassenger } from './AssignedPassenger';
3
3
  import type { AssignedTravellerGroup } from './AssignedTravellerGroup';
4
4
  import type { BookingStatus } from './BookingStatus';
5
+ import type { ComponentId } from './ComponentId';
5
6
  import type { Field } from './Field';
6
7
  import type { Price } from './Price';
7
8
  import type { UserComponentInstanceField } from './UserComponentInstanceField';
8
9
  export type ComponentInstance = {
9
10
  id: string;
10
- componentId: string;
11
+ componentId: ComponentId;
11
12
  componentInstanceFields: Array<Field>;
12
13
  userComponentInstanceFields: Array<UserComponentInstanceField>;
13
14
  assignedPassengers: Array<AssignedPassenger>;
@@ -0,0 +1,8 @@
1
+ import type { BranchId } from './BranchId';
2
+ import type { BranchTag } from './BranchTag';
3
+ import type { ItineraryRevisionGroupId } from './ItineraryRevisionGroupId';
4
+ export type DTOBranchCreate = {
5
+ tag: BranchTag;
6
+ parentId: BranchId;
7
+ currentRevisionGroupId: ItineraryRevisionGroupId;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { BranchId } from './BranchId';
2
+ import type { BranchTag } from './BranchTag';
3
+ import type { ItineraryRevisionGroupId } from './ItineraryRevisionGroupId';
4
+ import type { Metadata } from './Metadata';
5
+ export type DTOBranchEntity = {
6
+ id: BranchId;
7
+ tag: BranchTag;
8
+ metadata: Metadata;
9
+ parentId: BranchId;
10
+ currentRevisionGroupId: ItineraryRevisionGroupId;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { BranchId } from './BranchId';
2
+ import type { BranchTag } from './BranchTag';
3
+ import type { ItineraryRevisionGroupId } from './ItineraryRevisionGroupId';
4
+ import type { Metadata } from './Metadata';
5
+ export type DTOBranchRead = {
6
+ id: BranchId;
7
+ tag: BranchTag;
8
+ metadata: Metadata;
9
+ parentId: BranchId;
10
+ currentRevisionGroupId: ItineraryRevisionGroupId;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { BranchTag } from './BranchTag';
2
+ export type DTOBranchUpdate = {
3
+ tag: BranchTag;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
+ import type { Title } from './Title';
1
2
  import type { ValidationSchemas } from './ValidationSchemas';
2
3
  export type DTOTemplateUpdate = {
3
- name?: string;
4
+ name?: Title;
4
5
  masterSchema?: string;
5
6
  validationSchemas?: ValidationSchemas;
6
7
  };
@@ -4,6 +4,4 @@ export type Package = {
4
4
  spans?: Array<PackageSpan>;
5
5
  title: Title;
6
6
  description: string;
7
- startDate: string;
8
- endDate: string;
9
7
  };
@@ -6,6 +6,8 @@ export type { Amendment } from './models/Amendment';
6
6
  export type { AssignedPassenger } from './models/AssignedPassenger';
7
7
  export type { AssignedTravellerGroup } from './models/AssignedTravellerGroup';
8
8
  export { BookingStatus } from './models/BookingStatus';
9
+ export type { BranchId } from './models/BranchId';
10
+ export type { BranchTag } from './models/BranchTag';
9
11
  export type { ComponentDescription } from './models/ComponentDescription';
10
12
  export type { ComponentFAQ } from './models/ComponentFAQ';
11
13
  export type { ComponentId } from './models/ComponentId';
@@ -18,6 +20,10 @@ export { ComponentState } from './models/ComponentState';
18
20
  export { Currency } from './models/Currency';
19
21
  export { Destination } from './models/Destination';
20
22
  export type { Discount } from './models/Discount';
23
+ export type { DTOBranchCreate } from './models/DTOBranchCreate';
24
+ export type { DTOBranchEntity } from './models/DTOBranchEntity';
25
+ export type { DTOBranchRead } from './models/DTOBranchRead';
26
+ export type { DTOBranchUpdate } from './models/DTOBranchUpdate';
21
27
  export type { DTOComponentCreate } from './models/DTOComponentCreate';
22
28
  export type { DTOComponentEntity } from './models/DTOComponentEntity';
23
29
  export type { DTOComponentRead } from './models/DTOComponentRead';
@@ -1,6 +1,8 @@
1
+ import type { AssignedPassenger } from './AssignedPassenger';
1
2
  import type { Price } from './Price';
2
3
  import type { Title } from './Title';
3
4
  export type Amendment = {
4
5
  name: Title;
5
6
  price: Price;
7
+ assignedPassenger: AssignedPassenger;
6
8
  };
@@ -0,0 +1 @@
1
+ export type BranchId = string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type BranchTag = string;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,12 +2,13 @@ import type { Amendment } from './Amendment';
2
2
  import type { AssignedPassenger } from './AssignedPassenger';
3
3
  import type { AssignedTravellerGroup } from './AssignedTravellerGroup';
4
4
  import type { BookingStatus } from './BookingStatus';
5
+ import type { ComponentId } from './ComponentId';
5
6
  import type { Field } from './Field';
6
7
  import type { Price } from './Price';
7
8
  import type { UserComponentInstanceField } from './UserComponentInstanceField';
8
9
  export type ComponentInstance = {
9
10
  id: string;
10
- componentId: string;
11
+ componentId: ComponentId;
11
12
  componentInstanceFields: Array<Field>;
12
13
  userComponentInstanceFields: Array<UserComponentInstanceField>;
13
14
  assignedPassengers: Array<AssignedPassenger>;
@@ -0,0 +1,8 @@
1
+ import type { BranchId } from './BranchId';
2
+ import type { BranchTag } from './BranchTag';
3
+ import type { ItineraryRevisionGroupId } from './ItineraryRevisionGroupId';
4
+ export type DTOBranchCreate = {
5
+ tag: BranchTag;
6
+ parentId: BranchId;
7
+ currentRevisionGroupId: ItineraryRevisionGroupId;
8
+ };
@@ -0,0 +1,11 @@
1
+ import type { BranchId } from './BranchId';
2
+ import type { BranchTag } from './BranchTag';
3
+ import type { ItineraryRevisionGroupId } from './ItineraryRevisionGroupId';
4
+ import type { Metadata } from './Metadata';
5
+ export type DTOBranchEntity = {
6
+ id: BranchId;
7
+ tag: BranchTag;
8
+ metadata: Metadata;
9
+ parentId: BranchId;
10
+ currentRevisionGroupId: ItineraryRevisionGroupId;
11
+ };
@@ -0,0 +1,11 @@
1
+ import type { BranchId } from './BranchId';
2
+ import type { BranchTag } from './BranchTag';
3
+ import type { ItineraryRevisionGroupId } from './ItineraryRevisionGroupId';
4
+ import type { Metadata } from './Metadata';
5
+ export type DTOBranchRead = {
6
+ id: BranchId;
7
+ tag: BranchTag;
8
+ metadata: Metadata;
9
+ parentId: BranchId;
10
+ currentRevisionGroupId: ItineraryRevisionGroupId;
11
+ };
@@ -0,0 +1,4 @@
1
+ import type { BranchTag } from './BranchTag';
2
+ export type DTOBranchUpdate = {
3
+ tag: BranchTag;
4
+ };
@@ -1,6 +1,7 @@
1
+ import type { Title } from './Title';
1
2
  import type { ValidationSchemas } from './ValidationSchemas';
2
3
  export type DTOTemplateUpdate = {
3
- name?: string;
4
+ name?: Title;
4
5
  masterSchema?: string;
5
6
  validationSchemas?: ValidationSchemas;
6
7
  };
@@ -4,6 +4,4 @@ export type Package = {
4
4
  spans?: Array<PackageSpan>;
5
5
  title: Title;
6
6
  description: string;
7
- startDate: string;
8
- endDate: string;
9
7
  };
@@ -19,7 +19,7 @@ export const generateJsonSchema = (formSchema, stage, onlyEditableFields) => {
19
19
  return;
20
20
  const fieldSchema = defaultConverter(s, stage);
21
21
  built.properties[generateFieldId(s.name)] = fieldSchema;
22
- if (s.required)
22
+ if (s.required && s.fieldType !== "boolean")
23
23
  built.required.push(generateFieldId(s.name));
24
24
  });
25
25
  return built;
@@ -49,7 +49,8 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
49
49
  for (const child of (_d = (_c = field.objectOptions) === null || _c === void 0 ? void 0 : _c.properties) !== null && _d !== void 0 ? _d : []) {
50
50
  const fieldId = generateFieldId(child.name);
51
51
  properties[fieldId] = defaultConverter(child, stage, false, true);
52
- if (child.required && child.fieldType !== "boolean")
52
+ console.log("FILD TYPE", child.fieldType, "REWQUIRED", child.required);
53
+ if (child.required && child.fieldType != "boolean")
53
54
  requiredFields.push(fieldId);
54
55
  }
55
56
  let enumOpts = field.fieldType === "enum"
@@ -77,8 +78,6 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
77
78
  ? { "x-templateIds": field.componentOptions["x-templateIds"] }
78
79
  : {};
79
80
  let title = omitTitle ? undefined : field.name;
80
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (!isChild &&
81
- !(Array.isArray(field.editableIn) ? field.editableIn : [])
82
- .map(Number)
83
- .includes(stage) && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), (field.fieldType === "object" && { required: requiredFields })), (enumOpts && { enum: enumOpts })), (stagedEnumOpts && { items: { enum: stagedEnumOpts, type: "string" } })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties })), (field.fieldType === "string" && Object.assign({}, field.stringOptions)));
81
+ let isReadonly = !isChild && !field.editableIn.map(Number).includes(stage);
82
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (isReadonly && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), (field.fieldType === "object" && { required: requiredFields })), (enumOpts && { enum: enumOpts })), (stagedEnumOpts && { items: { enum: stagedEnumOpts, type: "string" } })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties })), (field.fieldType === "string" && Object.assign({}, field.stringOptions)));
84
83
  };
package/package.json CHANGED
@@ -1,62 +1,63 @@
1
- {
2
- "name": "swoop-common",
3
- "version": "2.1.57",
4
- "main": "dist/api/index.js",
5
- "types": "dist/api/index.d.ts",
6
- "exports": {
7
- ".": {
8
- "import": "./dist/api/index.js",
9
- "require": "./dist/api/index.js",
10
- "types": "./dist/api/index.d.ts"
11
- },
12
- "./rendering": {
13
- "import": "./dist/rendering/index.js",
14
- "require": "./dist/rendering/index.js",
15
- "types": "./dist/rendering/index.d.ts"
16
- }
17
- },
18
- "files": [
19
- "dist"
20
- ],
21
- "scripts": {
22
- "test": "echo \"Error: no test specified\" && exit 1",
23
- "build": "rimraf ./dist && tsc",
24
- "build-imports": "tsx ./src/rendering/prebuild/import.ts",
25
- "build-core-sdk": "npx openapi-typescript-codegen --input ./openapi/generated/core_bundled.yaml --output ./src/api/generated/core --client fetch",
26
- "build-itinerary-sdk": "npx openapi-typescript-codegen --input ./openapi/generated/itinerary_bundled.yaml --output ./src/api/generated/itinerary --client fetch",
27
- "build-swoop-sdk": "npx openapi-typescript-codegen --input ./openapi/swoop_service.yaml --output ./src/api/generated/swoop --client fetch --postfixModels Swoop --request ./src/api/templates/request.ts",
28
- "prebuild": "npm run build-imports && npm run bundle && npm run build-sdk",
29
- "build-sdk-exports": "tsx ./src/api/gen.ts",
30
- "bundle": "tsx ./src/api/bundler.ts",
31
- "build-sdk": "npm run build-core-sdk && npm run build-itinerary-sdk && npm run build-swoop-sdk && npm run build-sdk-exports"
32
- },
33
- "author": "",
34
- "license": "ISC",
35
- "description": "",
36
- "dependencies": {
37
- "@apidevtools/swagger-parser": "^12.0.0",
38
- "@emotion/react": "^11.14.0",
39
- "@emotion/styled": "^11.14.1",
40
- "@jsonforms/core": "^3.5.1",
41
- "@jsonforms/material-renderers": "^3.5.1",
42
- "@jsonforms/react": "^3.5.1",
43
- "ajv": "^8.17.1",
44
- "js-yaml": "^4.1.0",
45
- "lodash.merge": "^4.6.2",
46
- "openapi-ts": "^0.3.4",
47
- "react": "^19.0.0",
48
- "rimraf": "^6.0.1",
49
- "swoop-common": "^2.1.55"
50
- },
51
- "devDependencies": {
52
- "@apidevtools/swagger-cli": "^4.0.4",
53
- "@hey-api/openapi-ts": "^0.80.2",
54
- "@types/js-yaml": "^4.0.9",
55
- "@types/lodash.merge": "^4.6.9",
56
- "@types/node": "^24.0.14",
57
- "@types/react": "^19",
58
- "openapi-typescript-codegen": "^0.29.0",
59
- "tsx": "^4.20.3",
60
- "typescript": "^5.8.3"
61
- }
62
- }
1
+ {
2
+ "name": "swoop-common",
3
+ "version": "2.1.59",
4
+ "main": "dist/api/index.js",
5
+ "types": "dist/api/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/api/index.js",
9
+ "require": "./dist/api/index.js",
10
+ "types": "./dist/api/index.d.ts"
11
+ },
12
+ "./rendering": {
13
+ "import": "./dist/rendering/index.js",
14
+ "require": "./dist/rendering/index.js",
15
+ "types": "./dist/rendering/index.d.ts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "test": "echo \"Error: no test specified\" && exit 1",
23
+ "build": "rimraf ./dist && tsc",
24
+ "build-imports": "tsx ./src/rendering/prebuild/import.ts",
25
+ "build-core-sdk": "npx openapi-typescript-codegen --input ./openapi/generated/core_bundled.yaml --output ./src/api/generated/core --client fetch",
26
+ "build-itinerary-sdk": "npx openapi-typescript-codegen --input ./openapi/generated/itinerary_bundled.yaml --output ./src/api/generated/itinerary --client fetch",
27
+ "build-swoop-sdk": "npx openapi-typescript-codegen --input ./openapi/swoop_service.yaml --output ./src/api/generated/swoop --client fetch --postfixModels Swoop --request ./src/api/templates/request.ts",
28
+ "prebuild": "npm run build-imports && npm run fetch-specs && npm run bundle && npm run build-sdk",
29
+ "build-sdk-exports": "tsx ./src/api/gen.ts",
30
+ "bundle": "tsx ./src/api/bundler.ts",
31
+ "build-sdk": "npm run build-core-sdk && npm run build-itinerary-sdk && npm run build-swoop-sdk && npm run build-sdk-exports",
32
+ "fetch-specs": "tsx ./src/api/fetch.ts"
33
+ },
34
+ "author": "",
35
+ "license": "ISC",
36
+ "description": "",
37
+ "dependencies": {
38
+ "@apidevtools/swagger-parser": "^12.0.0",
39
+ "@emotion/react": "^11.14.0",
40
+ "@emotion/styled": "^11.14.1",
41
+ "@jsonforms/core": "^3.5.1",
42
+ "@jsonforms/material-renderers": "^3.5.1",
43
+ "@jsonforms/react": "^3.5.1",
44
+ "ajv": "^8.17.1",
45
+ "js-yaml": "^4.1.0",
46
+ "lodash.merge": "^4.6.2",
47
+ "openapi-ts": "^0.3.4",
48
+ "react": "^19.0.0",
49
+ "rimraf": "^6.0.1",
50
+ "swoop-common": "^2.1.55"
51
+ },
52
+ "devDependencies": {
53
+ "@apidevtools/swagger-cli": "^4.0.4",
54
+ "@hey-api/openapi-ts": "^0.80.2",
55
+ "@types/js-yaml": "^4.0.9",
56
+ "@types/lodash.merge": "^4.6.9",
57
+ "@types/node": "^24.0.14",
58
+ "@types/react": "^19",
59
+ "openapi-typescript-codegen": "^0.29.0",
60
+ "tsx": "^4.20.3",
61
+ "typescript": "^5.8.3"
62
+ }
63
+ }