swoop-common 1.0.30 → 1.0.32

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.
@@ -20,6 +20,8 @@ export type { DTOComponentUpdate } from './index';
20
20
  export type { DTOItineraryCreate } from './index';
21
21
  export type { DTOItineraryRead } from './index';
22
22
  export type { DTOItineraryUpdate } from './index';
23
+ export type { DTORegionCreate } from './index';
24
+ export type { DTORegionRead } from './index';
23
25
  export type { DTOTemplateCreate } from './index';
24
26
  export type { DTOTemplateRead } from './index';
25
27
  export type { DTOTemplateUpdate } from './index';
@@ -40,6 +42,7 @@ export type { Region } from './index';
40
42
  export { regionParam } from './index';
41
43
  export { regionRequired } from './index';
42
44
  export type { search } from './index';
45
+ export type { sortParam } from './index';
43
46
  export type { SwooperResponse } from './index';
44
47
  export type { templateId } from './index';
45
48
  export type { TravellerResponse } from './index';
@@ -22,6 +22,8 @@ export type { DTOComponentUpdate } from './models/DTOComponentUpdate';
22
22
  export type { DTOItineraryCreate } from './models/DTOItineraryCreate';
23
23
  export type { DTOItineraryRead } from './models/DTOItineraryRead';
24
24
  export type { DTOItineraryUpdate } from './models/DTOItineraryUpdate';
25
+ export type { DTORegionCreate } from './models/DTORegionCreate';
26
+ export type { DTORegionRead } from './models/DTORegionRead';
25
27
  export type { DTOTemplateCreate } from './models/DTOTemplateCreate';
26
28
  export type { DTOTemplateRead } from './models/DTOTemplateRead';
27
29
  export type { DTOTemplateUpdate } from './models/DTOTemplateUpdate';
@@ -42,6 +44,7 @@ export type { Region } from './models/Region';
42
44
  export { regionParam } from './models/regionParam';
43
45
  export { regionRequired } from './models/regionRequired';
44
46
  export type { search } from './models/search';
47
+ export type { sortParam } from './models/sortParam';
45
48
  export type { SwooperResponse } from './models/SwooperResponse';
46
49
  export type { templateId } from './models/templateId';
47
50
  export type { Traveller } from './models/Traveller';
@@ -0,0 +1,6 @@
1
+ export type DTORegionCreate = {
2
+ name: string;
3
+ description: string;
4
+ destination: string;
5
+ images: Array<Array<any>>;
6
+ };
@@ -0,0 +1,9 @@
1
+ import type { Metadata } from './Metadata';
2
+ export type DTORegionRead = {
3
+ id: string;
4
+ metadata: Metadata;
5
+ name: string;
6
+ description: string;
7
+ destination: string;
8
+ images: Array<string>;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * List of fields to sort by
3
+ */
4
+ export type sortParam = any[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import fs from "fs";
2
+ // Super lazy bundler, just sticks models onto the end of specs and updates refs
3
+ const bundle = (sdk) => {
4
+ const specs = fs.readFileSync(`./openapi/${sdk}_service.yaml`, "utf-8");
5
+ const models = fs.readFileSync("./openapi/models.yaml", "utf-8");
6
+ // Remove header of models
7
+ const clean = models.split("\n");
8
+ let reached = false;
9
+ let full = "";
10
+ for (let i = 0; i < clean.length; i++) {
11
+ if (!reached && clean[i].startsWith("components"))
12
+ reached = true;
13
+ // Removes tags
14
+ if (clean[i].startsWith("tags"))
15
+ break;
16
+ if (reached)
17
+ full += "\n" + clean[i];
18
+ }
19
+ // Dont need to parse specs, can just look for references
20
+ const updatedSpecs = specs.replace(/\.\/models\.yaml/g, "") + "\n" + full;
21
+ // Make sure all refs are wrapped in '
22
+ const cleanedSpecs = updatedSpecs.split("\n").map(line => line.replace(/(\$ref:\s*)(?!')([^\s']+)(?!')/, (_, prefix, path) => `${prefix}'${path}'`)).join("\n");
23
+ fs.mkdirSync("./openapi/generated", { recursive: true });
24
+ fs.writeFileSync(`./openapi/generated/${sdk}_bundled.yaml`, cleanedSpecs);
25
+ };
26
+ bundle("core");
27
+ bundle("itinerary");
@@ -44,6 +44,7 @@ export type { Region } from './models/Region';
44
44
  export { regionParam } from './models/regionParam';
45
45
  export { regionRequired } from './models/regionRequired';
46
46
  export type { search } from './models/search';
47
+ export type { sortParam } from './models/sortParam';
47
48
  export type { SwooperResponse } from './models/SwooperResponse';
48
49
  export type { templateId } from './models/templateId';
49
50
  export type { Traveller } from './models/Traveller';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * List of fields to sort by
3
+ */
4
+ export type sortParam = any[];
@@ -0,0 +1 @@
1
+ export {};
@@ -12,10 +12,11 @@ export declare class ItineraryService {
12
12
  * @param page Pagination, starting at page 1
13
13
  * @param limit Number of items per page
14
14
  * @param search Search term
15
+ * @param sort List of fields to sort by
15
16
  * @returns any OK
16
17
  * @throws ApiError
17
18
  */
18
- itineraryList(page?: number, limit?: number, search?: string): CancelablePromise<{
19
+ itineraryList(page?: number, limit?: number, search?: string, sort?: any[]): CancelablePromise<{
19
20
  data: Array<DTOItineraryRead>;
20
21
  pagination?: Pagination;
21
22
  }>;
@@ -65,10 +66,11 @@ export declare class ItineraryService {
65
66
  * List all regions
66
67
  * @param page Pagination, starting at page 1
67
68
  * @param limit Number of items per page
69
+ * @param sort List of fields to sort by
68
70
  * @returns any OK
69
71
  * @throws ApiError
70
72
  */
71
- regionList(page?: number, limit?: number): CancelablePromise<{
73
+ regionList(page?: number, limit?: number, sort?: any[]): CancelablePromise<{
72
74
  data: Array<DTORegionRead>;
73
75
  pagination: Pagination;
74
76
  }>;
@@ -7,10 +7,11 @@ export class ItineraryService {
7
7
  * @param page Pagination, starting at page 1
8
8
  * @param limit Number of items per page
9
9
  * @param search Search term
10
+ * @param sort List of fields to sort by
10
11
  * @returns any OK
11
12
  * @throws ApiError
12
13
  */
13
- itineraryList(page, limit, search) {
14
+ itineraryList(page, limit, search, sort) {
14
15
  return __request(OpenAPI, {
15
16
  method: 'GET',
16
17
  url: '/itineraries',
@@ -18,6 +19,7 @@ export class ItineraryService {
18
19
  'page': page,
19
20
  'limit': limit,
20
21
  'search': search,
22
+ 'sort': sort,
21
23
  },
22
24
  });
23
25
  }
@@ -108,16 +110,18 @@ export class ItineraryService {
108
110
  * List all regions
109
111
  * @param page Pagination, starting at page 1
110
112
  * @param limit Number of items per page
113
+ * @param sort List of fields to sort by
111
114
  * @returns any OK
112
115
  * @throws ApiError
113
116
  */
114
- regionList(page, limit) {
117
+ regionList(page, limit, sort) {
115
118
  return __request(OpenAPI, {
116
119
  method: 'GET',
117
120
  url: '/regions',
118
121
  query: {
119
122
  'page': page,
120
123
  'limit': limit,
124
+ 'sort': sort,
121
125
  },
122
126
  });
123
127
  }
@@ -30,6 +30,8 @@ interface Props {
30
30
  * The stage at which to render this template
31
31
  */
32
32
  stage: Stage;
33
+ jsonSchema?: any;
34
+ uiSchema?: any;
33
35
  }
34
36
  export declare const StyledFormView: React.FC<Props>;
35
37
  export {};
@@ -5,9 +5,9 @@ import { getComponents } from '../registry/components';
5
5
  import { generateJsonSchema } from '../schema/generate/jsonSchemaGenerate';
6
6
  import { generateUiSchema } from '../schema/generate/uiSchemaGenerate';
7
7
  import { initialisedCheck } from '../../api/init';
8
- export const StyledFormView = ({ initialData, schema, onChange, stage, pool, readonly }) => {
8
+ export const StyledFormView = ({ initialData, schema, onChange, stage, pool, readonly, jsonSchema, uiSchema }) => {
9
9
  useEffect(initialisedCheck, []);
10
- const json = generateJsonSchema(schema, stage);
11
- const ui = generateUiSchema(schema, stage);
10
+ const json = jsonSchema || generateJsonSchema(schema, stage);
11
+ const ui = uiSchema || generateUiSchema(schema, stage);
12
12
  return (React.createElement(JsonForms, { onChange: onChange, data: initialData, schema: json, uischema: ui, renderers: [...materialRenderers, ...getComponents(pool)], readonly: readonly, cells: materialCells }));
13
13
  };
@@ -1,4 +1,4 @@
1
- import "../../default_registration/fields_base";
1
+ import "../../type_registration/register";
2
2
  import "../../renderers/Address";
3
3
  import "../../renderers/ComponentPicker";
4
4
  import "../../renderers/Debug";
@@ -1,5 +1,5 @@
1
1
  // Base field types
2
- import "../../default_registration/fields_base";
2
+ import "../../type_registration/register";
3
3
  // Custom component renderers
4
4
  import "../../renderers/Address";
5
5
  import "../../renderers/ComponentPicker";
@@ -21,7 +21,7 @@ const getImports = (base) => {
21
21
  return `import "../../renderers/${normalized}"`;
22
22
  });
23
23
  const templateFormSchemas = [`import "../../schema/formBuilders/formBuilderJsonSchema"`, `import "../../schema/formBuilders/formBuilderUiSchema"`];
24
- const baseFieldTypes = `import "../../default_registration/fields_base"`;
24
+ const baseFieldTypes = `import "../../type_registration/register"`;
25
25
  return [
26
26
  "// Base field types", baseFieldTypes, "",
27
27
  "// Custom component renderers",
@@ -0,0 +1 @@
1
+ export {};
@@ -117,13 +117,23 @@ registerType("address", "Address", {
117
117
  },
118
118
  required: ["line1", "city", "postcode"]
119
119
  }, {}, false);
120
- registerType("subset", "Subset", {
121
- title: "your address",
122
- description: "your address",
123
- type: "array",
124
- items: {
125
- type: "string"
126
- }
127
- }, {}, false);
120
+ /*
121
+ registerType(
122
+ "subset",
123
+ "Subset",
124
+ {
125
+ type: "object",
126
+ title: "Subset Options",
127
+ properties: {
128
+ minItems: { type: "integer", minimum: 0 },
129
+ maxItems: { type: "integer", minimum: 1 },
130
+ uniqueItems: { type: "boolean", default: false },
131
+ itemDefinition: { $ref: "#/$defs/arrayItemDefinition" },
132
+ },
133
+ },
134
+ {
135
+ },
136
+ false
137
+ );*/
128
138
  registerType("image", "Image", { type: "string" }, {}, false);
129
139
  registerType("multiline", "Multiline", { type: "string" }, {}, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swoop-common",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "main": "dist/api/index.js",
5
5
  "types": "dist/api/index.d.ts",
6
6
  "exports": {