swoop-common 2.0.1 → 2.0.2

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.
@@ -7,7 +7,7 @@ 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 { services } from "../init";
10
+ import { CoreService } from "../generated/core";
11
11
  const buildTemplateTree = (templates) => {
12
12
  const revisionGroups = new Map();
13
13
  // Step 1: Group templates by revisionGroupId
@@ -43,7 +43,7 @@ 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 services.CoreService.templateList(1);
46
+ const allTemplates = yield (new CoreService).templateList(1);
47
47
  // Find the initial template
48
48
  const initialTemplate = allTemplates.data.find((t) => t.id === templateId);
49
49
  if (!initialTemplate) {
@@ -1,11 +1,6 @@
1
1
  import * as Core from "./generated/core/index";
2
2
  import * as Itinerary from "./generated/itinerary/index";
3
3
  import * as Swoop from "./generated/swoop/index";
4
- export declare const services: {
5
- SwoopService: Swoop.SwoopService;
6
- CoreService: Core.CoreService;
7
- ItineraryService: Itinerary.ItineraryService;
8
- };
9
4
  export declare const init: (opts: {
10
5
  itineraryServiceUrl: string;
11
6
  coreServiceUrl: string;
package/dist/api/init.js CHANGED
@@ -2,11 +2,6 @@ import * as Core from "./generated/core/index";
2
2
  import * as Itinerary from "./generated/itinerary/index";
3
3
  import * as Swoop from "./generated/swoop/index";
4
4
  let initalised = false;
5
- export const services = {
6
- SwoopService: new Swoop.SwoopService(),
7
- CoreService: new Core.CoreService(),
8
- ItineraryService: new Itinerary.ItineraryService(),
9
- };
10
5
  export const init = (opts) => {
11
6
  // Keeps it consitent
12
7
  if (opts.coreServiceUrl.endsWith("/"))
@@ -20,7 +15,11 @@ export const init = (opts) => {
20
15
  Itinerary.OpenAPI.BASE = opts.itineraryServiceUrl;
21
16
  Swoop.OpenAPI.BASE = opts.swoopServiceForwardUrl;
22
17
  initalised = true;
23
- return services;
18
+ return {
19
+ SwoopService: new Swoop.SwoopService(),
20
+ CoreService: new Core.CoreService(),
21
+ ItineraryService: new Itinerary.ItineraryService(),
22
+ };
24
23
  };
25
24
  export const initialisedCheck = () => {
26
25
  if (initalised)
@@ -6,15 +6,15 @@ export declare const fetchComponents: () => Promise<{
6
6
  templateId: string;
7
7
  revisionGroupId: string;
8
8
  revision: number;
9
- metadata: import("../../api/generated/core/exports").Metadata;
9
+ metadata: import("../../api/generated/core").Metadata;
10
10
  name: string;
11
- componentFields: Array<import("../../api/generated/core/exports").Field>;
11
+ componentFields: Array<import("../../api/generated/core").Field>;
12
12
  partners: Array<string>;
13
- bundle: Array<import("../../api/generated/core/exports").Bundle>;
13
+ bundle: Array<import("../../api/generated/core").Bundle>;
14
14
  startDate?: string | null;
15
15
  endDate?: string | null;
16
16
  duration?: number | null;
17
- details: import("../../api/generated/core/exports").ComponentDetails;
17
+ details: import("../../api/generated/core").ComponentDetails;
18
18
  state?: string | null;
19
19
  }[];
20
20
  }>;
@@ -12,7 +12,7 @@ import { Paper, Typography, Box, TextField, Autocomplete } from '@mui/material';
12
12
  import { useLocalErrors } from '../hooks/errors';
13
13
  import { ComponentPool } from '../registry/types';
14
14
  import { registerComponent } from '../registry/components';
15
- import { services } from '../../api/init';
15
+ import { CoreService } from '../../api/generated/core';
16
16
  const FormComponentPicker = ({ components, selectedComponent, onChange, templateIds, getError, label, enabled }) => {
17
17
  const selected = components.find(c => c.id === selectedComponent) || null;
18
18
  return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
@@ -51,7 +51,7 @@ const FormRendererComponentPicker = ({ data, handleChange, path, label, enabled,
51
51
  registerComponent("component", FormRendererComponentPicker, ComponentPool.FORM);
52
52
  export const fetchComponents = () => __awaiter(void 0, void 0, void 0, function* () {
53
53
  const componentsByGroup = new Map();
54
- const data = yield services.CoreService.componentList(1, 1000);
54
+ const data = yield (new CoreService).componentList(1, 1000);
55
55
  (data.data || []).forEach((component) => {
56
56
  const groupId = component.revisionGroupId;
57
57
  if (!componentsByGroup.has(groupId)) {
@@ -13,7 +13,7 @@ import { Paper, Typography, Box, TextField, Chip, Autocomplete } from '@mui/mate
13
13
  import { useLocalErrors } from '../hooks/errors';
14
14
  import { registerComponent } from '../registry/components';
15
15
  import { ComponentPool } from '../registry/types';
16
- import { services } from '../../api/init';
16
+ import { CoreService } from '../../api/generated/core';
17
17
  const FormTemplatePicker = ({ templates, selectedTemplates, onChange, label, enabled }) => {
18
18
  const selectedValues = templates.filter(t => selectedTemplates.includes(t.id));
19
19
  return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 2, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
@@ -33,7 +33,7 @@ const FormRendererTemplatePicker = ({ data, handleChange, path, label, enabled }
33
33
  useEffect(() => {
34
34
  const load = () => __awaiter(void 0, void 0, void 0, function* () {
35
35
  try {
36
- const result = yield services.CoreService.templateList(1);
36
+ const result = yield (new CoreService).templateList(1);
37
37
  setTemplates(result.data);
38
38
  }
39
39
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swoop-common",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "main": "dist/api/index.js",
5
5
  "types": "dist/api/index.d.ts",
6
6
  "exports": {