@uniformdev/project-map 19.1.1-alpha.1 → 19.3.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/index.d.ts CHANGED
@@ -335,10 +335,7 @@ interface components {
335
335
  path: string;
336
336
  /** @description Ordering of the node, higher numbers go after lower numbers. */
337
337
  order?: number;
338
- /** @description Data associated with this projectMap node */
339
- data?: {
340
- [key: string]: unknown;
341
- };
338
+ data?: components["schemas"]["ProjectMapNodeData"];
342
339
  /** @description The name of the projectMap entry */
343
340
  name: string;
344
341
  /**
@@ -398,10 +395,7 @@ interface components {
398
395
  path: string;
399
396
  /** @description Ordering of the node, higher numbers go after lower numbers. */
400
397
  order?: number;
401
- /** @description Data associated with this projectMap node */
402
- data?: {
403
- [key: string]: unknown;
404
- };
398
+ data?: components["schemas"]["ProjectMapNodeData"];
405
399
  /** @description The name of the projectMap entry */
406
400
  name: string;
407
401
  /**
@@ -417,6 +411,20 @@ interface components {
417
411
  /** @description Description of the projectMap node */
418
412
  description?: string;
419
413
  };
414
+ ProjectMapNodeData: {
415
+ /** @description While performing a search if a node is a hit, this property will return true. If it's supporting structure, like a parent of a search hit, it will return false */
416
+ isSearchHit?: boolean;
417
+ /** @description Query strings that are allowed to be passed to the node */
418
+ queryStrings?: components["schemas"]["ProjectMapNodeAllowedQueryString"][];
419
+ };
420
+ ProjectMapNodeAllowedQueryString: {
421
+ /** @description The name of the query string parameter */
422
+ name?: string;
423
+ /** @description The default value of the query string if it is not provided by an incoming route path */
424
+ value?: string;
425
+ /** @description Help text for authors who might be setting up a preview value for this query string */
426
+ helpText?: string;
427
+ };
420
428
  };
421
429
  }
422
430
  interface external {
@@ -500,6 +508,8 @@ type ProjectMapDefinitions = {
500
508
  projectMaps: ProjectMapDefinitionWithId[];
501
509
  projectMapNodes: ProjectMapNodeWithProjectMapReference[];
502
510
  };
511
+ type ProjectMapNodeData = components['schemas']['ProjectMapNodeData'];
512
+ type ProjectMapNodeAllowedQueryString = components['schemas']['ProjectMapNodeAllowedQueryString'];
503
513
 
504
514
  declare const ROOT_NODE_PATH = "/";
505
515
  type ProjectMapClientOptions = {
@@ -558,4 +568,26 @@ declare class UncachedProjectMapClient extends ProjectMapClient {
558
568
  constructor(options: Omit<ProjectMapClientOptions, 'bypassCache'>);
559
569
  }
560
570
 
561
- export { NodeType, ProjectMapClient, ProjectMapClientOptions, ProjectMapDefinition, ProjectMapDefinitionWithId, ProjectMapDefinitions, ProjectMapDeleteRequest, ProjectMapGetRequest, ProjectMapGetResponse, ProjectMapNode, ProjectMapNodeDeleteRequest, ProjectMapNodeGetRequest, ProjectMapNodeGetResponse, ProjectMapNodeUpsertRequest, ProjectMapNodeUpsertRequestNode, ProjectMapNodeWithId, ProjectMapNodeWithProjectMapReference, ProjectMapSubtree, ProjectMapUpsertRequest, ProjectMapUpsertResponse, ROOT_NODE_PATH, UncachedProjectMapClient };
571
+ type MatchedRoute = {
572
+ match: true;
573
+ dynamicSegmentCount: number;
574
+ pathParams: {
575
+ [key: string]: string;
576
+ };
577
+ queryParams: {
578
+ [key: string]: string;
579
+ };
580
+ };
581
+ type UnmatchedRoute = {
582
+ match: false;
583
+ };
584
+ declare class Route {
585
+ #private;
586
+ readonly route: string;
587
+ constructor(route: string);
588
+ get dynamicSegmentCount(): number;
589
+ matches(path: string): MatchedRoute | UnmatchedRoute;
590
+ static dynamicSegmentPrefix: string;
591
+ }
592
+
593
+ export { MatchedRoute, NodeType, ProjectMapClient, ProjectMapClientOptions, ProjectMapDefinition, ProjectMapDefinitionWithId, ProjectMapDefinitions, ProjectMapDeleteRequest, ProjectMapGetRequest, ProjectMapGetResponse, ProjectMapNode, ProjectMapNodeAllowedQueryString, ProjectMapNodeData, ProjectMapNodeDeleteRequest, ProjectMapNodeGetRequest, ProjectMapNodeGetResponse, ProjectMapNodeUpsertRequest, ProjectMapNodeUpsertRequestNode, ProjectMapNodeWithId, ProjectMapNodeWithProjectMapReference, ProjectMapSubtree, ProjectMapUpsertRequest, ProjectMapUpsertResponse, ROOT_NODE_PATH, Route, UncachedProjectMapClient, UnmatchedRoute };
package/dist/index.esm.js CHANGED
@@ -1,3 +1,26 @@
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+ var __privateMethod = (obj, member, method) => {
20
+ __accessCheck(obj, member, "access private method");
21
+ return method;
22
+ };
23
+
1
24
  // src/projectMapClient.ts
2
25
  import { ApiClient } from "@uniformdev/context/api";
3
26
  var ROOT_NODE_PATH = "/";
@@ -160,8 +183,78 @@ var cutReferences = (node) => node ? {
160
183
  parent: void 0,
161
184
  children: void 0
162
185
  } : void 0;
186
+
187
+ // src/util/Route.ts
188
+ var _routeInfo, _parseRouteOrPath, parseRouteOrPath_fn, _isDynamicRouteSegment, isDynamicRouteSegment_fn;
189
+ var _Route = class {
190
+ constructor(route) {
191
+ this.route = route;
192
+ __privateAdd(this, _routeInfo, void 0);
193
+ var _a;
194
+ __privateSet(this, _routeInfo, __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, this.route));
195
+ }
196
+ get dynamicSegmentCount() {
197
+ return __privateGet(this, _routeInfo).segments.reduce(
198
+ (count, segment) => {
199
+ var _a;
200
+ return __privateMethod(_a = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
201
+ },
202
+ 0
203
+ );
204
+ }
205
+ matches(path) {
206
+ var _a, _b;
207
+ const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, path);
208
+ const { segments: routeSegments } = __privateGet(this, _routeInfo);
209
+ if (pathSegments.length !== routeSegments.length) {
210
+ return { match: false };
211
+ }
212
+ const possibleMatch = {
213
+ match: true,
214
+ dynamicSegmentCount: 0,
215
+ pathParams: {},
216
+ queryParams: {}
217
+ };
218
+ for (let i = 0; i < routeSegments.length; i++) {
219
+ const routeSegment = routeSegments[i];
220
+ const pathSegment = pathSegments[i];
221
+ if (__privateMethod(_b = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_b, routeSegment)) {
222
+ const key = routeSegment.slice(1);
223
+ possibleMatch.pathParams[key] = pathSegment;
224
+ possibleMatch.dynamicSegmentCount++;
225
+ } else if (routeSegment !== pathSegment) {
226
+ return { match: false };
227
+ }
228
+ }
229
+ for (const [key, value] of __privateGet(this, _routeInfo).queryParams) {
230
+ possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
231
+ }
232
+ return possibleMatch;
233
+ }
234
+ };
235
+ var Route = _Route;
236
+ _routeInfo = new WeakMap();
237
+ _parseRouteOrPath = new WeakSet();
238
+ parseRouteOrPath_fn = function(path) {
239
+ if (!path.startsWith("/") || path === "") {
240
+ throw new Error(`Path must start with a slash: ${path}`);
241
+ }
242
+ const pathSegments = path.substring(1).split("/");
243
+ const [lastSegmentWithoutQuery, queryString] = pathSegments[pathSegments.length - 1].split("?");
244
+ pathSegments[pathSegments.length - 1] = lastSegmentWithoutQuery;
245
+ const queryParams = new URLSearchParams(queryString);
246
+ return { segments: pathSegments, queryParams };
247
+ };
248
+ _isDynamicRouteSegment = new WeakSet();
249
+ isDynamicRouteSegment_fn = function(segment) {
250
+ return segment.startsWith(_Route.dynamicSegmentPrefix);
251
+ };
252
+ __privateAdd(Route, _parseRouteOrPath);
253
+ __privateAdd(Route, _isDynamicRouteSegment);
254
+ Route.dynamicSegmentPrefix = ":";
163
255
  export {
164
256
  ProjectMapClient,
165
257
  ROOT_NODE_PATH,
258
+ Route,
166
259
  UncachedProjectMapClient
167
260
  };
package/dist/index.js CHANGED
@@ -16,12 +16,35 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __accessCheck = (obj, member, msg) => {
20
+ if (!member.has(obj))
21
+ throw TypeError("Cannot " + msg);
22
+ };
23
+ var __privateGet = (obj, member, getter) => {
24
+ __accessCheck(obj, member, "read from private field");
25
+ return getter ? getter.call(obj) : member.get(obj);
26
+ };
27
+ var __privateAdd = (obj, member, value) => {
28
+ if (member.has(obj))
29
+ throw TypeError("Cannot add the same private member more than once");
30
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
31
+ };
32
+ var __privateSet = (obj, member, value, setter) => {
33
+ __accessCheck(obj, member, "write to private field");
34
+ setter ? setter.call(obj, value) : member.set(obj, value);
35
+ return value;
36
+ };
37
+ var __privateMethod = (obj, member, method) => {
38
+ __accessCheck(obj, member, "access private method");
39
+ return method;
40
+ };
19
41
 
20
42
  // src/index.ts
21
43
  var src_exports = {};
22
44
  __export(src_exports, {
23
45
  ProjectMapClient: () => ProjectMapClient,
24
46
  ROOT_NODE_PATH: () => ROOT_NODE_PATH,
47
+ Route: () => Route,
25
48
  UncachedProjectMapClient: () => UncachedProjectMapClient
26
49
  });
27
50
  module.exports = __toCommonJS(src_exports);
@@ -188,9 +211,79 @@ var cutReferences = (node) => node ? {
188
211
  parent: void 0,
189
212
  children: void 0
190
213
  } : void 0;
214
+
215
+ // src/util/Route.ts
216
+ var _routeInfo, _parseRouteOrPath, parseRouteOrPath_fn, _isDynamicRouteSegment, isDynamicRouteSegment_fn;
217
+ var _Route = class {
218
+ constructor(route) {
219
+ this.route = route;
220
+ __privateAdd(this, _routeInfo, void 0);
221
+ var _a;
222
+ __privateSet(this, _routeInfo, __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, this.route));
223
+ }
224
+ get dynamicSegmentCount() {
225
+ return __privateGet(this, _routeInfo).segments.reduce(
226
+ (count, segment) => {
227
+ var _a;
228
+ return __privateMethod(_a = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
229
+ },
230
+ 0
231
+ );
232
+ }
233
+ matches(path) {
234
+ var _a, _b;
235
+ const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, path);
236
+ const { segments: routeSegments } = __privateGet(this, _routeInfo);
237
+ if (pathSegments.length !== routeSegments.length) {
238
+ return { match: false };
239
+ }
240
+ const possibleMatch = {
241
+ match: true,
242
+ dynamicSegmentCount: 0,
243
+ pathParams: {},
244
+ queryParams: {}
245
+ };
246
+ for (let i = 0; i < routeSegments.length; i++) {
247
+ const routeSegment = routeSegments[i];
248
+ const pathSegment = pathSegments[i];
249
+ if (__privateMethod(_b = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_b, routeSegment)) {
250
+ const key = routeSegment.slice(1);
251
+ possibleMatch.pathParams[key] = pathSegment;
252
+ possibleMatch.dynamicSegmentCount++;
253
+ } else if (routeSegment !== pathSegment) {
254
+ return { match: false };
255
+ }
256
+ }
257
+ for (const [key, value] of __privateGet(this, _routeInfo).queryParams) {
258
+ possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
259
+ }
260
+ return possibleMatch;
261
+ }
262
+ };
263
+ var Route = _Route;
264
+ _routeInfo = new WeakMap();
265
+ _parseRouteOrPath = new WeakSet();
266
+ parseRouteOrPath_fn = function(path) {
267
+ if (!path.startsWith("/") || path === "") {
268
+ throw new Error(`Path must start with a slash: ${path}`);
269
+ }
270
+ const pathSegments = path.substring(1).split("/");
271
+ const [lastSegmentWithoutQuery, queryString] = pathSegments[pathSegments.length - 1].split("?");
272
+ pathSegments[pathSegments.length - 1] = lastSegmentWithoutQuery;
273
+ const queryParams = new URLSearchParams(queryString);
274
+ return { segments: pathSegments, queryParams };
275
+ };
276
+ _isDynamicRouteSegment = new WeakSet();
277
+ isDynamicRouteSegment_fn = function(segment) {
278
+ return segment.startsWith(_Route.dynamicSegmentPrefix);
279
+ };
280
+ __privateAdd(Route, _parseRouteOrPath);
281
+ __privateAdd(Route, _isDynamicRouteSegment);
282
+ Route.dynamicSegmentPrefix = ":";
191
283
  // Annotate the CommonJS export names for ESM import in node:
192
284
  0 && (module.exports = {
193
285
  ProjectMapClient,
194
286
  ROOT_NODE_PATH,
287
+ Route,
195
288
  UncachedProjectMapClient
196
289
  });
package/dist/index.mjs CHANGED
@@ -1,3 +1,26 @@
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+ var __privateMethod = (obj, member, method) => {
20
+ __accessCheck(obj, member, "access private method");
21
+ return method;
22
+ };
23
+
1
24
  // src/projectMapClient.ts
2
25
  import { ApiClient } from "@uniformdev/context/api";
3
26
  var ROOT_NODE_PATH = "/";
@@ -160,8 +183,78 @@ var cutReferences = (node) => node ? {
160
183
  parent: void 0,
161
184
  children: void 0
162
185
  } : void 0;
186
+
187
+ // src/util/Route.ts
188
+ var _routeInfo, _parseRouteOrPath, parseRouteOrPath_fn, _isDynamicRouteSegment, isDynamicRouteSegment_fn;
189
+ var _Route = class {
190
+ constructor(route) {
191
+ this.route = route;
192
+ __privateAdd(this, _routeInfo, void 0);
193
+ var _a;
194
+ __privateSet(this, _routeInfo, __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, this.route));
195
+ }
196
+ get dynamicSegmentCount() {
197
+ return __privateGet(this, _routeInfo).segments.reduce(
198
+ (count, segment) => {
199
+ var _a;
200
+ return __privateMethod(_a = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_a, segment) ? count + 1 : count;
201
+ },
202
+ 0
203
+ );
204
+ }
205
+ matches(path) {
206
+ var _a, _b;
207
+ const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, path);
208
+ const { segments: routeSegments } = __privateGet(this, _routeInfo);
209
+ if (pathSegments.length !== routeSegments.length) {
210
+ return { match: false };
211
+ }
212
+ const possibleMatch = {
213
+ match: true,
214
+ dynamicSegmentCount: 0,
215
+ pathParams: {},
216
+ queryParams: {}
217
+ };
218
+ for (let i = 0; i < routeSegments.length; i++) {
219
+ const routeSegment = routeSegments[i];
220
+ const pathSegment = pathSegments[i];
221
+ if (__privateMethod(_b = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_b, routeSegment)) {
222
+ const key = routeSegment.slice(1);
223
+ possibleMatch.pathParams[key] = pathSegment;
224
+ possibleMatch.dynamicSegmentCount++;
225
+ } else if (routeSegment !== pathSegment) {
226
+ return { match: false };
227
+ }
228
+ }
229
+ for (const [key, value] of __privateGet(this, _routeInfo).queryParams) {
230
+ possibleMatch.queryParams[key] = pathQuery.has(key) ? pathQuery.get(key) : value;
231
+ }
232
+ return possibleMatch;
233
+ }
234
+ };
235
+ var Route = _Route;
236
+ _routeInfo = new WeakMap();
237
+ _parseRouteOrPath = new WeakSet();
238
+ parseRouteOrPath_fn = function(path) {
239
+ if (!path.startsWith("/") || path === "") {
240
+ throw new Error(`Path must start with a slash: ${path}`);
241
+ }
242
+ const pathSegments = path.substring(1).split("/");
243
+ const [lastSegmentWithoutQuery, queryString] = pathSegments[pathSegments.length - 1].split("?");
244
+ pathSegments[pathSegments.length - 1] = lastSegmentWithoutQuery;
245
+ const queryParams = new URLSearchParams(queryString);
246
+ return { segments: pathSegments, queryParams };
247
+ };
248
+ _isDynamicRouteSegment = new WeakSet();
249
+ isDynamicRouteSegment_fn = function(segment) {
250
+ return segment.startsWith(_Route.dynamicSegmentPrefix);
251
+ };
252
+ __privateAdd(Route, _parseRouteOrPath);
253
+ __privateAdd(Route, _isDynamicRouteSegment);
254
+ Route.dynamicSegmentPrefix = ":";
163
255
  export {
164
256
  ProjectMapClient,
165
257
  ROOT_NODE_PATH,
258
+ Route,
166
259
  UncachedProjectMapClient
167
260
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/project-map",
3
- "version": "19.1.1-alpha.1+3ec68fe9d",
3
+ "version": "19.3.0",
4
4
  "description": "Uniform Project Map",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -32,11 +32,11 @@
32
32
  "/dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "19.1.1-alpha.1+3ec68fe9d",
36
- "@uniformdev/context": "19.1.1-alpha.1+3ec68fe9d"
35
+ "@uniformdev/canvas": "19.3.0",
36
+ "@uniformdev/context": "19.3.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "3ec68fe9d54c7128e57cc8a5c8116fe968f65865"
41
+ "gitHead": "57552ffe10ca66f905d8908c82dde39935fb1803"
42
42
  }