@telicent-oss/ds 0.28.2 → 0.29.0

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.
package/dist/ds.js CHANGED
@@ -83095,6 +83095,59 @@ const createApi = (baseURL) => {
83095
83095
  })
83096
83096
  };
83097
83097
  };
83098
+ const splitURIBaseAndTerm = (rawString) => {
83099
+ try {
83100
+ const input = rawString.trim();
83101
+ const url = new URL(input);
83102
+ let [base, term] = [input, ""];
83103
+ if (url.hash !== "") {
83104
+ [base, term] = [`${url.origin}${url.pathname}`, url.hash.substring(1)];
83105
+ } else if (url.pathname !== "") {
83106
+ const split = url.pathname.split("/");
83107
+ [term, base] = [split.pop() ?? "", `${url.origin}${split.join("/")}`];
83108
+ }
83109
+ return [base, term];
83110
+ } catch (e) {
83111
+ console.error(`URI '${rawString}' is not valid, ${e}`);
83112
+ return [rawString, ""];
83113
+ }
83114
+ };
83115
+ const addSpaces = (str) => str.replace(/(?!^)([A-Z])/g, " $1");
83116
+ const PreferredLabelCache = /* @__PURE__ */ function() {
83117
+ let cache2 = null;
83118
+ let initPromise = null;
83119
+ const init2 = async (ontologyService) => {
83120
+ if (cache2 !== null) return;
83121
+ if (!initPromise) {
83122
+ initPromise = (async () => {
83123
+ const res = await ontologyService.getAllPreferredLabels();
83124
+ const preferredLabelLookup = (res == null ? void 0 : res.reduce((acc, item) => {
83125
+ var _a2;
83126
+ const key = item.name.value;
83127
+ const value2 = (_a2 = item == null ? void 0 : item.label) == null ? void 0 : _a2.value;
83128
+ acc[key] = value2 ?? "";
83129
+ return acc;
83130
+ }, {})) ?? {};
83131
+ cache2 = Object.freeze(preferredLabelLookup);
83132
+ })();
83133
+ }
83134
+ await initPromise;
83135
+ };
83136
+ const get2 = (val) => {
83137
+ if (!val) return "";
83138
+ if (!cache2) {
83139
+ console.warn("The cache has not been popuplated. Please run `preferredLabels.init(<ontologyservice> first");
83140
+ return "";
83141
+ }
83142
+ const label = cache2[val];
83143
+ const [, humanFriendlyType] = splitURIBaseAndTerm(val);
83144
+ return !label || label === "" ? addSpaces(humanFriendlyType) : label;
83145
+ };
83146
+ return {
83147
+ init: init2,
83148
+ get: get2
83149
+ };
83150
+ }();
83098
83151
  const base64Codec = {
83099
83152
  param: "safeB64",
83100
83153
  encode: (str) => btoa(str),
@@ -84498,6 +84551,7 @@ export {
84498
84551
  PlayIcon,
84499
84552
  PlusCircleIcon,
84500
84553
  PopOver,
84554
+ PreferredLabelCache,
84501
84555
  RecentSearches,
84502
84556
  SearchAutocomplete,
84503
84557
  SearchAutocompleteDialog,
package/dist/ds.umd.cjs CHANGED
@@ -83113,6 +83113,59 @@ uniform ${i3} ${s4} u_${a3};
83113
83113
  })
83114
83114
  };
83115
83115
  };
83116
+ const splitURIBaseAndTerm = (rawString) => {
83117
+ try {
83118
+ const input = rawString.trim();
83119
+ const url = new URL(input);
83120
+ let [base, term] = [input, ""];
83121
+ if (url.hash !== "") {
83122
+ [base, term] = [`${url.origin}${url.pathname}`, url.hash.substring(1)];
83123
+ } else if (url.pathname !== "") {
83124
+ const split = url.pathname.split("/");
83125
+ [term, base] = [split.pop() ?? "", `${url.origin}${split.join("/")}`];
83126
+ }
83127
+ return [base, term];
83128
+ } catch (e) {
83129
+ console.error(`URI '${rawString}' is not valid, ${e}`);
83130
+ return [rawString, ""];
83131
+ }
83132
+ };
83133
+ const addSpaces = (str) => str.replace(/(?!^)([A-Z])/g, " $1");
83134
+ const PreferredLabelCache = /* @__PURE__ */ function() {
83135
+ let cache2 = null;
83136
+ let initPromise = null;
83137
+ const init2 = async (ontologyService) => {
83138
+ if (cache2 !== null) return;
83139
+ if (!initPromise) {
83140
+ initPromise = (async () => {
83141
+ const res = await ontologyService.getAllPreferredLabels();
83142
+ const preferredLabelLookup = (res == null ? void 0 : res.reduce((acc, item) => {
83143
+ var _a2;
83144
+ const key = item.name.value;
83145
+ const value2 = (_a2 = item == null ? void 0 : item.label) == null ? void 0 : _a2.value;
83146
+ acc[key] = value2 ?? "";
83147
+ return acc;
83148
+ }, {})) ?? {};
83149
+ cache2 = Object.freeze(preferredLabelLookup);
83150
+ })();
83151
+ }
83152
+ await initPromise;
83153
+ };
83154
+ const get2 = (val) => {
83155
+ if (!val) return "";
83156
+ if (!cache2) {
83157
+ console.warn("The cache has not been popuplated. Please run `preferredLabels.init(<ontologyservice> first");
83158
+ return "";
83159
+ }
83160
+ const label = cache2[val];
83161
+ const [, humanFriendlyType] = splitURIBaseAndTerm(val);
83162
+ return !label || label === "" ? addSpaces(humanFriendlyType) : label;
83163
+ };
83164
+ return {
83165
+ init: init2,
83166
+ get: get2
83167
+ };
83168
+ }();
83116
83169
  const base64Codec = {
83117
83170
  param: "safeB64",
83118
83171
  encode: (str) => btoa(str),
@@ -84520,6 +84573,7 @@ uniform ${i3} ${s4} u_${a3};
84520
84573
  exports2.PlayIcon = PlayIcon;
84521
84574
  exports2.PlusCircleIcon = PlusCircleIcon;
84522
84575
  exports2.PopOver = PopOver;
84576
+ exports2.PreferredLabelCache = PreferredLabelCache;
84523
84577
  exports2.RecentSearches = RecentSearches;
84524
84578
  exports2.SearchAutocomplete = SearchAutocomplete;
84525
84579
  exports2.SearchAutocompleteDialog = SearchAutocompleteDialog;
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="webworker" />
2
- console.info("sw.js version: 0.28.2");
2
+ console.info("sw.js version: 0.29.0");
3
3
  self.addEventListener("install", () => self.skipWaiting());
4
4
  self.addEventListener("activate", (event) =>
5
5
  event.waitUntil(self.clients.claim())
@@ -0,0 +1,6 @@
1
+ import { OntologyService } from '@telicent-oss/ontologyservice';
2
+
3
+ export declare const PreferredLabelCache: {
4
+ init: (ontologyService: OntologyService) => Promise<void>;
5
+ get: (val: string) => string;
6
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Splits a URI into its base and terminal segment.
3
+ *
4
+ * Handles both hash (`#`) and slash (`/`) based URIs.
5
+ * For example:
6
+ * - "http://example.com/foo#Bar" → ["http://example.com/foo", "Bar"]
7
+ * - "http://example.com/foo/Bar" → ["http://example.com/foo", "Bar"]
8
+ *
9
+ * If the URI is invalid, returns the original string as the base and an empty term.
10
+ *
11
+ * @param {string} rawString - The URI to split.
12
+ * @returns {[string, string]} A tuple where the first element is the base and the second is the term.
13
+ */
14
+ export declare const splitURIBaseAndTerm: (rawString: string) => string[];
@@ -17,6 +17,7 @@ export * from './candidate-packages/authorize-flow/AuthModal';
17
17
  export * from './candidate-packages/authorize-flow/broadcastChannelService';
18
18
  export * from './candidate-packages/authorize-flow/useAuthSync';
19
19
  export * from './candidate-packages/authorize-flow';
20
+ export * from './candidate-packages/preferred-label-lib';
20
21
  export { getCodec, type Codec, base64Codec, uriComponentCodec, ENCODE_SEARCH_PARAMS_MODES_Schema, type ENCODE_SEARCH_PARAMS_MODES_Type, toStringEncoded, type URLSearchParamsInit, GRAPH_APP, type LoggerLevelString, type LoggerLevel, loggerLevelOrder, Logger, } from './candidate-packages/utils-lib/src/index';
21
22
  export { setupWipe, WipeConfigSchema, type WipeConfig, } from './candidate-packages/logout-syncer/setupWipe';
22
23
  export { requestWipe } from './candidate-packages/logout-syncer/requestWipe';
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/telicent-oss/telicent-ds.git"
8
8
  },
9
9
  "type": "module",
10
- "version": "0.28.2",
10
+ "version": "0.29.0",
11
11
  "private": false,
12
12
  "dependencies": {
13
13
  "@emotion/react": "^11.10.6",
@@ -20,7 +20,6 @@
20
20
  "@mui/material": "^5.16.6",
21
21
  "@mui/x-tree-view": "7.3.1",
22
22
  "@react-spring/web": "9.7.3",
23
- "@telicent-oss/ontologyservice": "1.0.0",
24
23
  "@telicent-oss/react-lib": "^0.5.0",
25
24
  "@telicent-oss/telicent-frontend-cli": "^1.2.1",
26
25
  "classnames": "^2.3.1",
@@ -69,13 +68,14 @@
69
68
  "link-to-local-packages": "./scripts/link-to-local-packages.sh",
70
69
  "postinstall": "[ \"$LOCAL_MACHINE\" = \"false\" ] && echo 'Skipping tefe hook-postinstall' || tefe hook-postinstall",
71
70
  "local-publish": "git add --all && yarn build && npm publish --registry http://localhost:4873 --prepatch",
72
- "postlocal-publish": "./scripts/update-deps.mjs ../telicent-user-portal ../catalog ../telicent-access/frontend ../../IO/telicent-graph ../../IO/telicent-search",
71
+ "postlocal-publish": "./scripts/update-deps.mjs ../telicent-user-portal ../catalog ../telicent-access/frontend ../../IO/telicent-graph ../../IO/telicent-search ../../IO/visualisations",
73
72
  "local-add": "git add --registry http://localhost:4873 ",
74
73
  "prepare": "husky install"
75
74
  },
76
75
  "peerDependencies": {
77
76
  "react": "*",
78
77
  "react-dom": "*",
78
+ "@telicent-oss/ontologyservice": "^1.0.2",
79
79
  "axios": "*",
80
80
  "@tanstack/react-query": "*"
81
81
  },
@@ -92,6 +92,7 @@
92
92
  ]
93
93
  },
94
94
  "devDependencies": {
95
+ "@telicent-oss/ontologyservice": "^1.0.2",
95
96
  "axios": "^1.7.0",
96
97
  "@babel/core": "^7.20.12",
97
98
  "@chromatic-com/storybook": "^1.7.0",