@uniformdev/project-map 19.62.0 → 19.62.1-alpha.127

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/LICENSE.txt CHANGED
@@ -1,2 +1,2 @@
1
- © 2023 Uniform Systems, Inc. All Rights Reserved.
1
+ © 2024 Uniform Systems, Inc. All Rights Reserved.
2
2
  See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ApiClient } from '@uniformdev/context/api';
2
+ import { RouteGetResponse } from '@uniformdev/canvas';
2
3
 
3
4
  /**
4
5
  * This file was auto-generated by openapi-typescript.
@@ -179,6 +180,15 @@ interface paths {
179
180
  projectMapId?: string;
180
181
  /** The project id that contains the project map tree that this node belongs to */
181
182
  projectId: string;
183
+ /**
184
+ * The ID of a release to fetch the composition data for.
185
+ *
186
+ * - When unspecified, composition data is fetched from base.
187
+ * - When specified, all content is returned as it would appear in the release if it was released now. This includes both content copied to the release and changed, as well as content that is not part of the release.
188
+ *
189
+ * Content copied to a release can be differentiated from base content by the `releaseId` property on the content. If the content is not copied to the release, this property will not be defined.
190
+ */
191
+ releaseId?: string;
182
192
  /** The id of the node to retrieve, cannot have both this parameter and Path */
183
193
  id?: string;
184
194
  /** The path of the root node to retrieve, cannot have both this parameter and Id */
@@ -338,7 +348,7 @@ interface components {
338
348
  * @description The id of the projectMap entry
339
349
  */
340
350
  id: string;
341
- /** @description Dot delimited path representing the path to the current node */
351
+ /** @description Path representing the path to the current node */
342
352
  path: string;
343
353
  /** @description Ordering of the node, higher numbers go after lower numbers. */
344
354
  order?: number;
@@ -349,7 +359,7 @@ interface components {
349
359
  * @description The type of the projectMap entry
350
360
  * @enum {string}
351
361
  */
352
- type: "composition" | "redirect" | "placeholder";
362
+ type: "composition" | "placeholder";
353
363
  /**
354
364
  * Format: uuid
355
365
  * @description The composition id related to the projectMap entry
@@ -359,13 +369,34 @@ interface components {
359
369
  description?: string;
360
370
  /** @description Parent path of the current node, only included if requested with the expanded flag */
361
371
  parentPath?: string;
362
- /** @description Last segment of the url, only included if requested with the expanded flag */
372
+ /** @description Last segment of the url */
363
373
  pathSegment?: string;
364
374
  /** @description returns true if the node is a leaf node, meaning having no children, only included if requested with the expanded flag */
365
375
  isLeaf?: boolean;
366
376
  compositionData?: components["schemas"]["ProjectMapNodeCompositionData"];
367
377
  sourceRedirects?: components["schemas"]["ProjectMapSourceRedirectData"];
368
378
  targetRedirects?: components["schemas"]["ProjectMapTargetRedirectData"];
379
+ locales?: {
380
+ [key: string]: components["schemas"]["ProjectMapNodeLocale"];
381
+ };
382
+ };
383
+ ProjectMapNodeLocale: {
384
+ /** @description Name of node in the locale */
385
+ name?: string;
386
+ /** @description Full path to the current node in this locale, only included if requested with the expanded flag */
387
+ path?: string;
388
+ /** @description Last segment of the url in this locale */
389
+ pathSegment: string;
390
+ /**
391
+ * @description When false, the node explicitly defines a locale specific path segment.
392
+ *
393
+ * When true, an ancestor defines a locale specific path segment,
394
+ * which makes its descendants resolvable using that segment.
395
+ * This node does not define a locale specific path segment.
396
+ *
397
+ * Only included if requested with the expanded flag. Without the expanded flag, inherited locales are not included in the response.
398
+ */
399
+ inherited?: boolean;
369
400
  };
370
401
  ProjectMapSourceRedirectData: {
371
402
  /**
@@ -407,6 +438,8 @@ interface components {
407
438
  icon?: string;
408
439
  /** @description Friendly name of this Composition's Definition */
409
440
  typeName?: string;
441
+ /** @description List of locales that the composition is available in. If empty, available in all locales. */
442
+ locales: string[];
410
443
  };
411
444
  ProjectMapNodeUpdate: {
412
445
  /**
@@ -425,7 +458,7 @@ interface components {
425
458
  * @description The type of the projectMap entry
426
459
  * @enum {string}
427
460
  */
428
- type: "composition" | "redirect" | "placeholder";
461
+ type: "composition" | "placeholder";
429
462
  /**
430
463
  * Format: uuid
431
464
  * @description The composition id related to the projectMap entry
@@ -433,6 +466,15 @@ interface components {
433
466
  compositionId?: string;
434
467
  /** @description Description of the projectMap node */
435
468
  description?: string;
469
+ locales?: {
470
+ [key: string]: components["schemas"]["ProjectMapNodeLocaleUpdate"];
471
+ };
472
+ };
473
+ ProjectMapNodeLocaleUpdate: {
474
+ /** @description Name of node in the locale */
475
+ name?: string;
476
+ /** @description Locale specific path segment for this node (not a full path) */
477
+ pathSegment: string;
436
478
  };
437
479
  ProjectMapNodeData: {
438
480
  /** @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 */
@@ -450,7 +492,7 @@ interface components {
450
492
  /** @description The name of the query string parameter */
451
493
  name: string;
452
494
  /** @description The default value of the query string if it is not provided by an incoming route path */
453
- value: string;
495
+ value?: string;
454
496
  /** @description Help text for authors who might be setting up a preview value for this query string */
455
497
  helpText?: string;
456
498
  };
@@ -517,10 +559,12 @@ interface external {
517
559
 
518
560
  type ProjectMapNodeUpsertRequest = paths['/api/v1/project-map-nodes']['put']['requestBody']['content']['application/json'];
519
561
  type ProjectMapNodeUpsertRequestNode = ProjectMapNodeUpsertRequest['nodes'][0]['node'];
562
+ type ProjectMapNodeUpsertRequestNodeLocale = NonNullable<ProjectMapNodeUpsertRequestNode['locales']>[string];
520
563
  type ProjectMapNodeDeleteRequest = paths['/api/v1/project-map-nodes']['delete']['requestBody']['content']['application/json'];
521
564
  type ProjectMapNodeGetRequest = paths['/api/v1/project-map-nodes']['get']['parameters']['query'];
522
565
  type ProjectMapNodeGetResponse = paths['/api/v1/project-map-nodes']['get']['responses']['200']['content']['application/json'];
523
566
  type ProjectMapNode = NonNullable<ProjectMapNodeGetResponse['nodes']>[0];
567
+ type ProjectMapNodeLocale = NonNullable<ProjectMapNode['locales']>[string];
524
568
  type ProjectMapNodeWithId = ProjectMapNode & Required<Pick<ProjectMapNode, 'id' | 'name'>>;
525
569
  type ProjectMapGetRequest = paths$1['/api/v1/project-map']['get']['parameters']['query'];
526
570
  type ProjectMapGetResponse = paths$1['/api/v1/project-map']['get']['responses']['200']['content']['application/json'];
@@ -529,7 +573,7 @@ type ProjectMapDeleteRequest = paths$1['/api/v1/project-map']['delete']['request
529
573
  type ProjectMapDefinition = ProjectMapGetResponse['projectMaps'][0];
530
574
  type ProjectMapDefinitionWithId = ProjectMapDefinition & Required<Pick<ProjectMapDefinition, 'id'>>;
531
575
  type ProjectMapUpsertResponse = paths$1['/api/v1/project-map']['put']['responses']['200']['content']['application/json'];
532
- type NodeType = 'placeholder' | 'composition' | 'redirect';
576
+ type NodeType = ProjectMapNode['type'];
533
577
  type ProjectMapNodeWithProjectMapReference = ProjectMapNodeWithId & {
534
578
  projectMapId: string;
535
579
  };
@@ -621,6 +665,36 @@ declare class UncachedProjectMapClient extends ProjectMapClient {
621
665
  constructor(options: Omit<ProjectMapClientOptions, 'bypassCache'>);
622
666
  }
623
667
 
668
+ type LocalePathNode = Pick<ProjectMapNode, 'path'> & {
669
+ locales?: Record<string, {
670
+ path?: string | undefined;
671
+ }>;
672
+ };
673
+ /**
674
+ * Given a project map node and a locale, resolves the correct path for the locale
675
+ * This is computed as follows:
676
+ * - If the locale is unspecified, then use the fallback path
677
+ * - If the locale is specified, then use the locale-specific path if it exists, otherwise use the fallback path
678
+ */
679
+ declare function getNodeLocalePath(node: LocalePathNode, locale: string | undefined): string;
680
+ declare function getNodeLocalePath(node: LocalePathNode | undefined, locale: string | undefined): string | null;
681
+
682
+ type AlternateLocaleUrls = {
683
+ [locale: string]: string;
684
+ };
685
+ /**
686
+ * Gets all possible locale specific URLs for a composition route response
687
+ *
688
+ * This is appropriate for generating links to other locale versions of the current composition,
689
+ * such as for alternate language tags, language switchers, etc.
690
+ *
691
+ * The URLs will be:
692
+ * * Computed based on the attached project map node path
693
+ * * Not include a base URL from the project map, if one is set
694
+ * * If a dynamic locale path segment exists, it will be rewritten automatically to the target locale
695
+ */
696
+ declare function getRouteAlternateLocalesUrls(routeResponse: RouteGetResponse): AlternateLocaleUrls | undefined;
697
+
624
698
  type MatchedRoute = {
625
699
  match: true;
626
700
  dynamicSegmentCount: number;
@@ -655,4 +729,4 @@ declare class Route {
655
729
  static dynamicSegmentPrefix: string;
656
730
  }
657
731
 
658
- 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 };
732
+ export { type AlternateLocaleUrls, type ExpandOptions, type LocalePathNode, type MatchedRoute, type NodeType, ProjectMapClient, type ProjectMapClientOptions, type ProjectMapDefinition, type ProjectMapDefinitionWithId, type ProjectMapDefinitions, type ProjectMapDeleteRequest, type ProjectMapGetRequest, type ProjectMapGetResponse, type ProjectMapNode, type ProjectMapNodeAllowedQueryString, type ProjectMapNodeData, type ProjectMapNodeDeleteRequest, type ProjectMapNodeGetRequest, type ProjectMapNodeGetResponse, type ProjectMapNodeLocale, type ProjectMapNodeUpsertRequest, type ProjectMapNodeUpsertRequestNode, type ProjectMapNodeUpsertRequestNodeLocale, type ProjectMapNodeWithId, type ProjectMapNodeWithProjectMapReference, type ProjectMapSubtree, type ProjectMapUpsertRequest, type ProjectMapUpsertResponse, ROOT_NODE_PATH, Route, UncachedProjectMapClient, type UnmatchedRoute, getNodeLocalePath, getRouteAlternateLocalesUrls };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ApiClient } from '@uniformdev/context/api';
2
+ import { RouteGetResponse } from '@uniformdev/canvas';
2
3
 
3
4
  /**
4
5
  * This file was auto-generated by openapi-typescript.
@@ -179,6 +180,15 @@ interface paths {
179
180
  projectMapId?: string;
180
181
  /** The project id that contains the project map tree that this node belongs to */
181
182
  projectId: string;
183
+ /**
184
+ * The ID of a release to fetch the composition data for.
185
+ *
186
+ * - When unspecified, composition data is fetched from base.
187
+ * - When specified, all content is returned as it would appear in the release if it was released now. This includes both content copied to the release and changed, as well as content that is not part of the release.
188
+ *
189
+ * Content copied to a release can be differentiated from base content by the `releaseId` property on the content. If the content is not copied to the release, this property will not be defined.
190
+ */
191
+ releaseId?: string;
182
192
  /** The id of the node to retrieve, cannot have both this parameter and Path */
183
193
  id?: string;
184
194
  /** The path of the root node to retrieve, cannot have both this parameter and Id */
@@ -338,7 +348,7 @@ interface components {
338
348
  * @description The id of the projectMap entry
339
349
  */
340
350
  id: string;
341
- /** @description Dot delimited path representing the path to the current node */
351
+ /** @description Path representing the path to the current node */
342
352
  path: string;
343
353
  /** @description Ordering of the node, higher numbers go after lower numbers. */
344
354
  order?: number;
@@ -349,7 +359,7 @@ interface components {
349
359
  * @description The type of the projectMap entry
350
360
  * @enum {string}
351
361
  */
352
- type: "composition" | "redirect" | "placeholder";
362
+ type: "composition" | "placeholder";
353
363
  /**
354
364
  * Format: uuid
355
365
  * @description The composition id related to the projectMap entry
@@ -359,13 +369,34 @@ interface components {
359
369
  description?: string;
360
370
  /** @description Parent path of the current node, only included if requested with the expanded flag */
361
371
  parentPath?: string;
362
- /** @description Last segment of the url, only included if requested with the expanded flag */
372
+ /** @description Last segment of the url */
363
373
  pathSegment?: string;
364
374
  /** @description returns true if the node is a leaf node, meaning having no children, only included if requested with the expanded flag */
365
375
  isLeaf?: boolean;
366
376
  compositionData?: components["schemas"]["ProjectMapNodeCompositionData"];
367
377
  sourceRedirects?: components["schemas"]["ProjectMapSourceRedirectData"];
368
378
  targetRedirects?: components["schemas"]["ProjectMapTargetRedirectData"];
379
+ locales?: {
380
+ [key: string]: components["schemas"]["ProjectMapNodeLocale"];
381
+ };
382
+ };
383
+ ProjectMapNodeLocale: {
384
+ /** @description Name of node in the locale */
385
+ name?: string;
386
+ /** @description Full path to the current node in this locale, only included if requested with the expanded flag */
387
+ path?: string;
388
+ /** @description Last segment of the url in this locale */
389
+ pathSegment: string;
390
+ /**
391
+ * @description When false, the node explicitly defines a locale specific path segment.
392
+ *
393
+ * When true, an ancestor defines a locale specific path segment,
394
+ * which makes its descendants resolvable using that segment.
395
+ * This node does not define a locale specific path segment.
396
+ *
397
+ * Only included if requested with the expanded flag. Without the expanded flag, inherited locales are not included in the response.
398
+ */
399
+ inherited?: boolean;
369
400
  };
370
401
  ProjectMapSourceRedirectData: {
371
402
  /**
@@ -407,6 +438,8 @@ interface components {
407
438
  icon?: string;
408
439
  /** @description Friendly name of this Composition's Definition */
409
440
  typeName?: string;
441
+ /** @description List of locales that the composition is available in. If empty, available in all locales. */
442
+ locales: string[];
410
443
  };
411
444
  ProjectMapNodeUpdate: {
412
445
  /**
@@ -425,7 +458,7 @@ interface components {
425
458
  * @description The type of the projectMap entry
426
459
  * @enum {string}
427
460
  */
428
- type: "composition" | "redirect" | "placeholder";
461
+ type: "composition" | "placeholder";
429
462
  /**
430
463
  * Format: uuid
431
464
  * @description The composition id related to the projectMap entry
@@ -433,6 +466,15 @@ interface components {
433
466
  compositionId?: string;
434
467
  /** @description Description of the projectMap node */
435
468
  description?: string;
469
+ locales?: {
470
+ [key: string]: components["schemas"]["ProjectMapNodeLocaleUpdate"];
471
+ };
472
+ };
473
+ ProjectMapNodeLocaleUpdate: {
474
+ /** @description Name of node in the locale */
475
+ name?: string;
476
+ /** @description Locale specific path segment for this node (not a full path) */
477
+ pathSegment: string;
436
478
  };
437
479
  ProjectMapNodeData: {
438
480
  /** @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 */
@@ -450,7 +492,7 @@ interface components {
450
492
  /** @description The name of the query string parameter */
451
493
  name: string;
452
494
  /** @description The default value of the query string if it is not provided by an incoming route path */
453
- value: string;
495
+ value?: string;
454
496
  /** @description Help text for authors who might be setting up a preview value for this query string */
455
497
  helpText?: string;
456
498
  };
@@ -517,10 +559,12 @@ interface external {
517
559
 
518
560
  type ProjectMapNodeUpsertRequest = paths['/api/v1/project-map-nodes']['put']['requestBody']['content']['application/json'];
519
561
  type ProjectMapNodeUpsertRequestNode = ProjectMapNodeUpsertRequest['nodes'][0]['node'];
562
+ type ProjectMapNodeUpsertRequestNodeLocale = NonNullable<ProjectMapNodeUpsertRequestNode['locales']>[string];
520
563
  type ProjectMapNodeDeleteRequest = paths['/api/v1/project-map-nodes']['delete']['requestBody']['content']['application/json'];
521
564
  type ProjectMapNodeGetRequest = paths['/api/v1/project-map-nodes']['get']['parameters']['query'];
522
565
  type ProjectMapNodeGetResponse = paths['/api/v1/project-map-nodes']['get']['responses']['200']['content']['application/json'];
523
566
  type ProjectMapNode = NonNullable<ProjectMapNodeGetResponse['nodes']>[0];
567
+ type ProjectMapNodeLocale = NonNullable<ProjectMapNode['locales']>[string];
524
568
  type ProjectMapNodeWithId = ProjectMapNode & Required<Pick<ProjectMapNode, 'id' | 'name'>>;
525
569
  type ProjectMapGetRequest = paths$1['/api/v1/project-map']['get']['parameters']['query'];
526
570
  type ProjectMapGetResponse = paths$1['/api/v1/project-map']['get']['responses']['200']['content']['application/json'];
@@ -529,7 +573,7 @@ type ProjectMapDeleteRequest = paths$1['/api/v1/project-map']['delete']['request
529
573
  type ProjectMapDefinition = ProjectMapGetResponse['projectMaps'][0];
530
574
  type ProjectMapDefinitionWithId = ProjectMapDefinition & Required<Pick<ProjectMapDefinition, 'id'>>;
531
575
  type ProjectMapUpsertResponse = paths$1['/api/v1/project-map']['put']['responses']['200']['content']['application/json'];
532
- type NodeType = 'placeholder' | 'composition' | 'redirect';
576
+ type NodeType = ProjectMapNode['type'];
533
577
  type ProjectMapNodeWithProjectMapReference = ProjectMapNodeWithId & {
534
578
  projectMapId: string;
535
579
  };
@@ -621,6 +665,36 @@ declare class UncachedProjectMapClient extends ProjectMapClient {
621
665
  constructor(options: Omit<ProjectMapClientOptions, 'bypassCache'>);
622
666
  }
623
667
 
668
+ type LocalePathNode = Pick<ProjectMapNode, 'path'> & {
669
+ locales?: Record<string, {
670
+ path?: string | undefined;
671
+ }>;
672
+ };
673
+ /**
674
+ * Given a project map node and a locale, resolves the correct path for the locale
675
+ * This is computed as follows:
676
+ * - If the locale is unspecified, then use the fallback path
677
+ * - If the locale is specified, then use the locale-specific path if it exists, otherwise use the fallback path
678
+ */
679
+ declare function getNodeLocalePath(node: LocalePathNode, locale: string | undefined): string;
680
+ declare function getNodeLocalePath(node: LocalePathNode | undefined, locale: string | undefined): string | null;
681
+
682
+ type AlternateLocaleUrls = {
683
+ [locale: string]: string;
684
+ };
685
+ /**
686
+ * Gets all possible locale specific URLs for a composition route response
687
+ *
688
+ * This is appropriate for generating links to other locale versions of the current composition,
689
+ * such as for alternate language tags, language switchers, etc.
690
+ *
691
+ * The URLs will be:
692
+ * * Computed based on the attached project map node path
693
+ * * Not include a base URL from the project map, if one is set
694
+ * * If a dynamic locale path segment exists, it will be rewritten automatically to the target locale
695
+ */
696
+ declare function getRouteAlternateLocalesUrls(routeResponse: RouteGetResponse): AlternateLocaleUrls | undefined;
697
+
624
698
  type MatchedRoute = {
625
699
  match: true;
626
700
  dynamicSegmentCount: number;
@@ -655,4 +729,4 @@ declare class Route {
655
729
  static dynamicSegmentPrefix: string;
656
730
  }
657
731
 
658
- 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 };
732
+ export { type AlternateLocaleUrls, type ExpandOptions, type LocalePathNode, type MatchedRoute, type NodeType, ProjectMapClient, type ProjectMapClientOptions, type ProjectMapDefinition, type ProjectMapDefinitionWithId, type ProjectMapDefinitions, type ProjectMapDeleteRequest, type ProjectMapGetRequest, type ProjectMapGetResponse, type ProjectMapNode, type ProjectMapNodeAllowedQueryString, type ProjectMapNodeData, type ProjectMapNodeDeleteRequest, type ProjectMapNodeGetRequest, type ProjectMapNodeGetResponse, type ProjectMapNodeLocale, type ProjectMapNodeUpsertRequest, type ProjectMapNodeUpsertRequestNode, type ProjectMapNodeUpsertRequestNodeLocale, type ProjectMapNodeWithId, type ProjectMapNodeWithProjectMapReference, type ProjectMapSubtree, type ProjectMapUpsertRequest, type ProjectMapUpsertResponse, ROOT_NODE_PATH, Route, UncachedProjectMapClient, type UnmatchedRoute, getNodeLocalePath, getRouteAlternateLocalesUrls };
package/dist/index.esm.js CHANGED
@@ -177,7 +177,8 @@ var ProjectMapClient = class extends ApiClient {
177
177
  order: node.order,
178
178
  data: node.data,
179
179
  compositionId: node.compositionId,
180
- description: node.description
180
+ description: node.description,
181
+ locales: node.locales
181
182
  };
182
183
  }
183
184
  };
@@ -192,6 +193,14 @@ var cutReferences = (node) => node ? {
192
193
  children: void 0
193
194
  } : void 0;
194
195
 
196
+ // src/util/getNodeLocalePath.ts
197
+ function getNodeLocalePath(node, locale) {
198
+ var _a, _b;
199
+ if (!node)
200
+ return null;
201
+ return locale ? ((_b = (_a = node.locales) == null ? void 0 : _a[locale]) == null ? void 0 : _b.path) || node.path : node.path;
202
+ }
203
+
195
204
  // src/util/Route.ts
196
205
  import { createVariableReference, parseVariableExpression } from "@uniformdev/canvas";
197
206
  var _routeInfo, _parseRouteOrPath, parseRouteOrPath_fn, _isDynamicRouteSegment, isDynamicRouteSegment_fn;
@@ -253,13 +262,6 @@ var _Route = class _Route {
253
262
  }
254
263
  const dynamicSegmentValue = dynamicInputValues[dynamicSegmentName];
255
264
  if (!dynamicSegmentValue) {
256
- console.log(
257
- "Missing dynamic input value for",
258
- dynamicSegmentName,
259
- "in",
260
- this.route,
261
- "using literal value"
262
- );
263
265
  return segment;
264
266
  }
265
267
  return encodeRouteComponent(dynamicSegmentValue, doNotEscapeVariables);
@@ -290,14 +292,19 @@ parseRouteOrPath_fn = function(path) {
290
292
  if (!path.startsWith("/") || path === "") {
291
293
  throw new Error(`Path must start with a slash: ${path}`);
292
294
  }
293
- const pathSegments = path.substring(1).split("/");
294
- const [lastSegmentWithoutQuery, queryString] = pathSegments[pathSegments.length - 1].split("?");
295
- pathSegments[pathSegments.length - 1] = lastSegmentWithoutQuery;
295
+ const [pathname, queryString] = path.split("?");
296
+ const pathSegments = pathname.substring(1).split("/");
297
+ if (pathSegments[pathSegments.length - 1] === "") {
298
+ pathSegments.pop();
299
+ }
296
300
  const queryParams = new URLSearchParams(queryString);
297
301
  return { segments: pathSegments, queryParams };
298
302
  };
299
303
  _isDynamicRouteSegment = new WeakSet();
300
304
  isDynamicRouteSegment_fn = function(segment) {
305
+ if (!segment) {
306
+ return false;
307
+ }
301
308
  return segment.startsWith(_Route.dynamicSegmentPrefix);
302
309
  };
303
310
  __privateAdd(_Route, _parseRouteOrPath);
@@ -318,9 +325,39 @@ function encodeRouteComponent(value, doNotEscapeVariables) {
318
325
  });
319
326
  return result.join("");
320
327
  }
328
+
329
+ // src/util/getRouteAlternateLocaleUrls.ts
330
+ function getRouteAlternateLocalesUrls(routeResponse) {
331
+ var _a;
332
+ if (routeResponse.type === "notFound" || routeResponse.type === "redirect") {
333
+ return void 0;
334
+ }
335
+ const enabledLocalesOnComposition = routeResponse.compositionApiResponse.composition._locales;
336
+ if (!enabledLocalesOnComposition) {
337
+ return void 0;
338
+ }
339
+ const projectMapNode = (_a = routeResponse.compositionApiResponse.composition.projectMapNodes) == null ? void 0 : _a[0];
340
+ if (!projectMapNode) {
341
+ return void 0;
342
+ }
343
+ return enabledLocalesOnComposition.reduce((acc, locale) => {
344
+ const path = getNodeLocalePath(projectMapNode, locale);
345
+ const dynamicInputsWithCurrentLocale = {
346
+ ...routeResponse.dynamicInputs,
347
+ locale
348
+ };
349
+ const alternateLocalePath = new Route(path).expand({
350
+ dynamicInputValues: dynamicInputsWithCurrentLocale
351
+ });
352
+ acc[locale] = alternateLocalePath;
353
+ return acc;
354
+ }, {});
355
+ }
321
356
  export {
322
357
  ProjectMapClient,
323
358
  ROOT_NODE_PATH,
324
359
  Route,
325
- UncachedProjectMapClient
360
+ UncachedProjectMapClient,
361
+ getNodeLocalePath,
362
+ getRouteAlternateLocalesUrls
326
363
  };
package/dist/index.js CHANGED
@@ -45,7 +45,9 @@ __export(src_exports, {
45
45
  ProjectMapClient: () => ProjectMapClient,
46
46
  ROOT_NODE_PATH: () => ROOT_NODE_PATH,
47
47
  Route: () => Route,
48
- UncachedProjectMapClient: () => UncachedProjectMapClient
48
+ UncachedProjectMapClient: () => UncachedProjectMapClient,
49
+ getNodeLocalePath: () => getNodeLocalePath,
50
+ getRouteAlternateLocalesUrls: () => getRouteAlternateLocalesUrls
49
51
  });
50
52
  module.exports = __toCommonJS(src_exports);
51
53
 
@@ -205,7 +207,8 @@ var ProjectMapClient = class extends import_api.ApiClient {
205
207
  order: node.order,
206
208
  data: node.data,
207
209
  compositionId: node.compositionId,
208
- description: node.description
210
+ description: node.description,
211
+ locales: node.locales
209
212
  };
210
213
  }
211
214
  };
@@ -220,6 +223,14 @@ var cutReferences = (node) => node ? {
220
223
  children: void 0
221
224
  } : void 0;
222
225
 
226
+ // src/util/getNodeLocalePath.ts
227
+ function getNodeLocalePath(node, locale) {
228
+ var _a, _b;
229
+ if (!node)
230
+ return null;
231
+ return locale ? ((_b = (_a = node.locales) == null ? void 0 : _a[locale]) == null ? void 0 : _b.path) || node.path : node.path;
232
+ }
233
+
223
234
  // src/util/Route.ts
224
235
  var import_canvas = require("@uniformdev/canvas");
225
236
  var _routeInfo, _parseRouteOrPath, parseRouteOrPath_fn, _isDynamicRouteSegment, isDynamicRouteSegment_fn;
@@ -281,13 +292,6 @@ var _Route = class _Route {
281
292
  }
282
293
  const dynamicSegmentValue = dynamicInputValues[dynamicSegmentName];
283
294
  if (!dynamicSegmentValue) {
284
- console.log(
285
- "Missing dynamic input value for",
286
- dynamicSegmentName,
287
- "in",
288
- this.route,
289
- "using literal value"
290
- );
291
295
  return segment;
292
296
  }
293
297
  return encodeRouteComponent(dynamicSegmentValue, doNotEscapeVariables);
@@ -318,14 +322,19 @@ parseRouteOrPath_fn = function(path) {
318
322
  if (!path.startsWith("/") || path === "") {
319
323
  throw new Error(`Path must start with a slash: ${path}`);
320
324
  }
321
- const pathSegments = path.substring(1).split("/");
322
- const [lastSegmentWithoutQuery, queryString] = pathSegments[pathSegments.length - 1].split("?");
323
- pathSegments[pathSegments.length - 1] = lastSegmentWithoutQuery;
325
+ const [pathname, queryString] = path.split("?");
326
+ const pathSegments = pathname.substring(1).split("/");
327
+ if (pathSegments[pathSegments.length - 1] === "") {
328
+ pathSegments.pop();
329
+ }
324
330
  const queryParams = new URLSearchParams(queryString);
325
331
  return { segments: pathSegments, queryParams };
326
332
  };
327
333
  _isDynamicRouteSegment = new WeakSet();
328
334
  isDynamicRouteSegment_fn = function(segment) {
335
+ if (!segment) {
336
+ return false;
337
+ }
329
338
  return segment.startsWith(_Route.dynamicSegmentPrefix);
330
339
  };
331
340
  __privateAdd(_Route, _parseRouteOrPath);
@@ -346,10 +355,40 @@ function encodeRouteComponent(value, doNotEscapeVariables) {
346
355
  });
347
356
  return result.join("");
348
357
  }
358
+
359
+ // src/util/getRouteAlternateLocaleUrls.ts
360
+ function getRouteAlternateLocalesUrls(routeResponse) {
361
+ var _a;
362
+ if (routeResponse.type === "notFound" || routeResponse.type === "redirect") {
363
+ return void 0;
364
+ }
365
+ const enabledLocalesOnComposition = routeResponse.compositionApiResponse.composition._locales;
366
+ if (!enabledLocalesOnComposition) {
367
+ return void 0;
368
+ }
369
+ const projectMapNode = (_a = routeResponse.compositionApiResponse.composition.projectMapNodes) == null ? void 0 : _a[0];
370
+ if (!projectMapNode) {
371
+ return void 0;
372
+ }
373
+ return enabledLocalesOnComposition.reduce((acc, locale) => {
374
+ const path = getNodeLocalePath(projectMapNode, locale);
375
+ const dynamicInputsWithCurrentLocale = {
376
+ ...routeResponse.dynamicInputs,
377
+ locale
378
+ };
379
+ const alternateLocalePath = new Route(path).expand({
380
+ dynamicInputValues: dynamicInputsWithCurrentLocale
381
+ });
382
+ acc[locale] = alternateLocalePath;
383
+ return acc;
384
+ }, {});
385
+ }
349
386
  // Annotate the CommonJS export names for ESM import in node:
350
387
  0 && (module.exports = {
351
388
  ProjectMapClient,
352
389
  ROOT_NODE_PATH,
353
390
  Route,
354
- UncachedProjectMapClient
391
+ UncachedProjectMapClient,
392
+ getNodeLocalePath,
393
+ getRouteAlternateLocalesUrls
355
394
  });
package/dist/index.mjs CHANGED
@@ -177,7 +177,8 @@ var ProjectMapClient = class extends ApiClient {
177
177
  order: node.order,
178
178
  data: node.data,
179
179
  compositionId: node.compositionId,
180
- description: node.description
180
+ description: node.description,
181
+ locales: node.locales
181
182
  };
182
183
  }
183
184
  };
@@ -192,6 +193,14 @@ var cutReferences = (node) => node ? {
192
193
  children: void 0
193
194
  } : void 0;
194
195
 
196
+ // src/util/getNodeLocalePath.ts
197
+ function getNodeLocalePath(node, locale) {
198
+ var _a, _b;
199
+ if (!node)
200
+ return null;
201
+ return locale ? ((_b = (_a = node.locales) == null ? void 0 : _a[locale]) == null ? void 0 : _b.path) || node.path : node.path;
202
+ }
203
+
195
204
  // src/util/Route.ts
196
205
  import { createVariableReference, parseVariableExpression } from "@uniformdev/canvas";
197
206
  var _routeInfo, _parseRouteOrPath, parseRouteOrPath_fn, _isDynamicRouteSegment, isDynamicRouteSegment_fn;
@@ -253,13 +262,6 @@ var _Route = class _Route {
253
262
  }
254
263
  const dynamicSegmentValue = dynamicInputValues[dynamicSegmentName];
255
264
  if (!dynamicSegmentValue) {
256
- console.log(
257
- "Missing dynamic input value for",
258
- dynamicSegmentName,
259
- "in",
260
- this.route,
261
- "using literal value"
262
- );
263
265
  return segment;
264
266
  }
265
267
  return encodeRouteComponent(dynamicSegmentValue, doNotEscapeVariables);
@@ -290,14 +292,19 @@ parseRouteOrPath_fn = function(path) {
290
292
  if (!path.startsWith("/") || path === "") {
291
293
  throw new Error(`Path must start with a slash: ${path}`);
292
294
  }
293
- const pathSegments = path.substring(1).split("/");
294
- const [lastSegmentWithoutQuery, queryString] = pathSegments[pathSegments.length - 1].split("?");
295
- pathSegments[pathSegments.length - 1] = lastSegmentWithoutQuery;
295
+ const [pathname, queryString] = path.split("?");
296
+ const pathSegments = pathname.substring(1).split("/");
297
+ if (pathSegments[pathSegments.length - 1] === "") {
298
+ pathSegments.pop();
299
+ }
296
300
  const queryParams = new URLSearchParams(queryString);
297
301
  return { segments: pathSegments, queryParams };
298
302
  };
299
303
  _isDynamicRouteSegment = new WeakSet();
300
304
  isDynamicRouteSegment_fn = function(segment) {
305
+ if (!segment) {
306
+ return false;
307
+ }
301
308
  return segment.startsWith(_Route.dynamicSegmentPrefix);
302
309
  };
303
310
  __privateAdd(_Route, _parseRouteOrPath);
@@ -318,9 +325,39 @@ function encodeRouteComponent(value, doNotEscapeVariables) {
318
325
  });
319
326
  return result.join("");
320
327
  }
328
+
329
+ // src/util/getRouteAlternateLocaleUrls.ts
330
+ function getRouteAlternateLocalesUrls(routeResponse) {
331
+ var _a;
332
+ if (routeResponse.type === "notFound" || routeResponse.type === "redirect") {
333
+ return void 0;
334
+ }
335
+ const enabledLocalesOnComposition = routeResponse.compositionApiResponse.composition._locales;
336
+ if (!enabledLocalesOnComposition) {
337
+ return void 0;
338
+ }
339
+ const projectMapNode = (_a = routeResponse.compositionApiResponse.composition.projectMapNodes) == null ? void 0 : _a[0];
340
+ if (!projectMapNode) {
341
+ return void 0;
342
+ }
343
+ return enabledLocalesOnComposition.reduce((acc, locale) => {
344
+ const path = getNodeLocalePath(projectMapNode, locale);
345
+ const dynamicInputsWithCurrentLocale = {
346
+ ...routeResponse.dynamicInputs,
347
+ locale
348
+ };
349
+ const alternateLocalePath = new Route(path).expand({
350
+ dynamicInputValues: dynamicInputsWithCurrentLocale
351
+ });
352
+ acc[locale] = alternateLocalePath;
353
+ return acc;
354
+ }, {});
355
+ }
321
356
  export {
322
357
  ProjectMapClient,
323
358
  ROOT_NODE_PATH,
324
359
  Route,
325
- UncachedProjectMapClient
360
+ UncachedProjectMapClient,
361
+ getNodeLocalePath,
362
+ getRouteAlternateLocalesUrls
326
363
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/project-map",
3
- "version": "19.62.0",
3
+ "version": "19.62.1-alpha.127+d49e5a0782",
4
4
  "description": "Uniform Project Map",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -33,11 +33,11 @@
33
33
  "/dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@uniformdev/canvas": "19.62.0",
37
- "@uniformdev/context": "19.62.0"
36
+ "@uniformdev/canvas": "19.62.1-alpha.127+d49e5a0782",
37
+ "@uniformdev/context": "19.62.1-alpha.127+d49e5a0782"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "dcaa272276caccfec3318d2a028cf4efa8a569a8"
42
+ "gitHead": "d49e5a07824d69e5df3a92ff10bc9acd88d0bc22"
43
43
  }