@uniformdev/project-map 19.11.0 → 19.12.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 +10 -1
- package/dist/index.esm.js +28 -0
- package/dist/index.js +28 -0
- package/dist/index.mjs +28 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -592,14 +592,23 @@ type MatchedRoute = {
|
|
|
592
592
|
type UnmatchedRoute = {
|
|
593
593
|
match: false;
|
|
594
594
|
};
|
|
595
|
+
type ExpandOptions = {
|
|
596
|
+
dynamicInputValues?: Record<string, string>;
|
|
597
|
+
allowedQueryParams?: Array<string>;
|
|
598
|
+
};
|
|
595
599
|
declare class Route {
|
|
596
600
|
#private;
|
|
597
601
|
readonly route: string;
|
|
598
602
|
constructor(route: string);
|
|
599
603
|
get dynamicSegmentCount(): number;
|
|
604
|
+
/** Tests if an incoming path matches this route */
|
|
600
605
|
matches(path: string): MatchedRoute | UnmatchedRoute;
|
|
606
|
+
/**
|
|
607
|
+
* Creates an expanded path value for this route given dynamic input values and allowed query string values
|
|
608
|
+
*/
|
|
609
|
+
expand(options?: ExpandOptions): string;
|
|
601
610
|
static getDynamicRouteSegmentName(segment: string): string | undefined;
|
|
602
611
|
static dynamicSegmentPrefix: string;
|
|
603
612
|
}
|
|
604
613
|
|
|
605
|
-
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 };
|
|
614
|
+
export { ExpandOptions, 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
|
@@ -188,6 +188,7 @@ var _Route = class {
|
|
|
188
188
|
0
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
|
+
/** Tests if an incoming path matches this route */
|
|
191
192
|
matches(path) {
|
|
192
193
|
var _a, _b;
|
|
193
194
|
const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, path);
|
|
@@ -217,6 +218,33 @@ var _Route = class {
|
|
|
217
218
|
}
|
|
218
219
|
return possibleMatch;
|
|
219
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Creates an expanded path value for this route given dynamic input values and allowed query string values
|
|
223
|
+
*/
|
|
224
|
+
expand(options) {
|
|
225
|
+
const { dynamicInputValues = {}, allowedQueryParams = [] } = options != null ? options : {};
|
|
226
|
+
const path = __privateGet(this, _routeInfo).segments.map((segment) => {
|
|
227
|
+
const dynamicSegmentName = _Route.getDynamicRouteSegmentName(segment);
|
|
228
|
+
if (!dynamicSegmentName) {
|
|
229
|
+
return segment;
|
|
230
|
+
}
|
|
231
|
+
const dynamicSegmentValue = dynamicInputValues[dynamicSegmentName];
|
|
232
|
+
if (!dynamicSegmentValue) {
|
|
233
|
+
console.warn(
|
|
234
|
+
"Missing dynamic input value for",
|
|
235
|
+
dynamicSegmentName,
|
|
236
|
+
"in",
|
|
237
|
+
this.route,
|
|
238
|
+
"using literal value"
|
|
239
|
+
);
|
|
240
|
+
return segment;
|
|
241
|
+
}
|
|
242
|
+
return encodeURIComponent(dynamicSegmentValue);
|
|
243
|
+
}).join("/");
|
|
244
|
+
const queries = allowedQueryParams.filter((qs) => typeof dynamicInputValues[qs] === "string").map((qs) => `${encodeURIComponent(qs)}=${encodeURIComponent(dynamicInputValues[qs])}`);
|
|
245
|
+
const query = queries.length ? `?${queries.join("&")}` : "";
|
|
246
|
+
return `/${path}${query}`;
|
|
247
|
+
}
|
|
220
248
|
static getDynamicRouteSegmentName(segment) {
|
|
221
249
|
var _a;
|
|
222
250
|
if (!__privateMethod(_a = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_a, segment)) {
|
package/dist/index.js
CHANGED
|
@@ -216,6 +216,7 @@ var _Route = class {
|
|
|
216
216
|
0
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
|
+
/** Tests if an incoming path matches this route */
|
|
219
220
|
matches(path) {
|
|
220
221
|
var _a, _b;
|
|
221
222
|
const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, path);
|
|
@@ -245,6 +246,33 @@ var _Route = class {
|
|
|
245
246
|
}
|
|
246
247
|
return possibleMatch;
|
|
247
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Creates an expanded path value for this route given dynamic input values and allowed query string values
|
|
251
|
+
*/
|
|
252
|
+
expand(options) {
|
|
253
|
+
const { dynamicInputValues = {}, allowedQueryParams = [] } = options != null ? options : {};
|
|
254
|
+
const path = __privateGet(this, _routeInfo).segments.map((segment) => {
|
|
255
|
+
const dynamicSegmentName = _Route.getDynamicRouteSegmentName(segment);
|
|
256
|
+
if (!dynamicSegmentName) {
|
|
257
|
+
return segment;
|
|
258
|
+
}
|
|
259
|
+
const dynamicSegmentValue = dynamicInputValues[dynamicSegmentName];
|
|
260
|
+
if (!dynamicSegmentValue) {
|
|
261
|
+
console.warn(
|
|
262
|
+
"Missing dynamic input value for",
|
|
263
|
+
dynamicSegmentName,
|
|
264
|
+
"in",
|
|
265
|
+
this.route,
|
|
266
|
+
"using literal value"
|
|
267
|
+
);
|
|
268
|
+
return segment;
|
|
269
|
+
}
|
|
270
|
+
return encodeURIComponent(dynamicSegmentValue);
|
|
271
|
+
}).join("/");
|
|
272
|
+
const queries = allowedQueryParams.filter((qs) => typeof dynamicInputValues[qs] === "string").map((qs) => `${encodeURIComponent(qs)}=${encodeURIComponent(dynamicInputValues[qs])}`);
|
|
273
|
+
const query = queries.length ? `?${queries.join("&")}` : "";
|
|
274
|
+
return `/${path}${query}`;
|
|
275
|
+
}
|
|
248
276
|
static getDynamicRouteSegmentName(segment) {
|
|
249
277
|
var _a;
|
|
250
278
|
if (!__privateMethod(_a = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_a, segment)) {
|
package/dist/index.mjs
CHANGED
|
@@ -188,6 +188,7 @@ var _Route = class {
|
|
|
188
188
|
0
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
|
+
/** Tests if an incoming path matches this route */
|
|
191
192
|
matches(path) {
|
|
192
193
|
var _a, _b;
|
|
193
194
|
const { segments: pathSegments, queryParams: pathQuery } = __privateMethod(_a = _Route, _parseRouteOrPath, parseRouteOrPath_fn).call(_a, path);
|
|
@@ -217,6 +218,33 @@ var _Route = class {
|
|
|
217
218
|
}
|
|
218
219
|
return possibleMatch;
|
|
219
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Creates an expanded path value for this route given dynamic input values and allowed query string values
|
|
223
|
+
*/
|
|
224
|
+
expand(options) {
|
|
225
|
+
const { dynamicInputValues = {}, allowedQueryParams = [] } = options != null ? options : {};
|
|
226
|
+
const path = __privateGet(this, _routeInfo).segments.map((segment) => {
|
|
227
|
+
const dynamicSegmentName = _Route.getDynamicRouteSegmentName(segment);
|
|
228
|
+
if (!dynamicSegmentName) {
|
|
229
|
+
return segment;
|
|
230
|
+
}
|
|
231
|
+
const dynamicSegmentValue = dynamicInputValues[dynamicSegmentName];
|
|
232
|
+
if (!dynamicSegmentValue) {
|
|
233
|
+
console.warn(
|
|
234
|
+
"Missing dynamic input value for",
|
|
235
|
+
dynamicSegmentName,
|
|
236
|
+
"in",
|
|
237
|
+
this.route,
|
|
238
|
+
"using literal value"
|
|
239
|
+
);
|
|
240
|
+
return segment;
|
|
241
|
+
}
|
|
242
|
+
return encodeURIComponent(dynamicSegmentValue);
|
|
243
|
+
}).join("/");
|
|
244
|
+
const queries = allowedQueryParams.filter((qs) => typeof dynamicInputValues[qs] === "string").map((qs) => `${encodeURIComponent(qs)}=${encodeURIComponent(dynamicInputValues[qs])}`);
|
|
245
|
+
const query = queries.length ? `?${queries.join("&")}` : "";
|
|
246
|
+
return `/${path}${query}`;
|
|
247
|
+
}
|
|
220
248
|
static getDynamicRouteSegmentName(segment) {
|
|
221
249
|
var _a;
|
|
222
250
|
if (!__privateMethod(_a = _Route, _isDynamicRouteSegment, isDynamicRouteSegment_fn).call(_a, segment)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/project-map",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.12.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.
|
|
36
|
-
"@uniformdev/context": "19.
|
|
35
|
+
"@uniformdev/canvas": "19.12.0",
|
|
36
|
+
"@uniformdev/context": "19.12.0"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "ca508c44f1b274e3e47d90717a98036256ae8379"
|
|
42
42
|
}
|