@uniformdev/project-map 19.79.1-alpha.13 → 19.79.1-alpha.25

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 */
@@ -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 { type ExpandOptions, 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 ProjectMapNodeUpsertRequest, type ProjectMapNodeUpsertRequestNode, type ProjectMapNodeWithId, type ProjectMapNodeWithProjectMapReference, type ProjectMapSubtree, type ProjectMapUpsertRequest, type ProjectMapUpsertResponse, ROOT_NODE_PATH, Route, UncachedProjectMapClient, type 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 */
@@ -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 { type ExpandOptions, 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 ProjectMapNodeUpsertRequest, type ProjectMapNodeUpsertRequestNode, type ProjectMapNodeWithId, type ProjectMapNodeWithProjectMapReference, type ProjectMapSubtree, type ProjectMapUpsertRequest, type ProjectMapUpsertResponse, ROOT_NODE_PATH, Route, UncachedProjectMapClient, type 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;
@@ -293,6 +302,9 @@ parseRouteOrPath_fn = function(path) {
293
302
  };
294
303
  _isDynamicRouteSegment = new WeakSet();
295
304
  isDynamicRouteSegment_fn = function(segment) {
305
+ if (!segment) {
306
+ return false;
307
+ }
296
308
  return segment.startsWith(_Route.dynamicSegmentPrefix);
297
309
  };
298
310
  __privateAdd(_Route, _parseRouteOrPath);
@@ -313,9 +325,39 @@ function encodeRouteComponent(value, doNotEscapeVariables) {
313
325
  });
314
326
  return result.join("");
315
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
+ }
316
356
  export {
317
357
  ProjectMapClient,
318
358
  ROOT_NODE_PATH,
319
359
  Route,
320
- UncachedProjectMapClient
360
+ UncachedProjectMapClient,
361
+ getNodeLocalePath,
362
+ getRouteAlternateLocalesUrls
321
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;
@@ -321,6 +332,9 @@ parseRouteOrPath_fn = function(path) {
321
332
  };
322
333
  _isDynamicRouteSegment = new WeakSet();
323
334
  isDynamicRouteSegment_fn = function(segment) {
335
+ if (!segment) {
336
+ return false;
337
+ }
324
338
  return segment.startsWith(_Route.dynamicSegmentPrefix);
325
339
  };
326
340
  __privateAdd(_Route, _parseRouteOrPath);
@@ -341,10 +355,40 @@ function encodeRouteComponent(value, doNotEscapeVariables) {
341
355
  });
342
356
  return result.join("");
343
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
+ }
344
386
  // Annotate the CommonJS export names for ESM import in node:
345
387
  0 && (module.exports = {
346
388
  ProjectMapClient,
347
389
  ROOT_NODE_PATH,
348
390
  Route,
349
- UncachedProjectMapClient
391
+ UncachedProjectMapClient,
392
+ getNodeLocalePath,
393
+ getRouteAlternateLocalesUrls
350
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;
@@ -293,6 +302,9 @@ parseRouteOrPath_fn = function(path) {
293
302
  };
294
303
  _isDynamicRouteSegment = new WeakSet();
295
304
  isDynamicRouteSegment_fn = function(segment) {
305
+ if (!segment) {
306
+ return false;
307
+ }
296
308
  return segment.startsWith(_Route.dynamicSegmentPrefix);
297
309
  };
298
310
  __privateAdd(_Route, _parseRouteOrPath);
@@ -313,9 +325,39 @@ function encodeRouteComponent(value, doNotEscapeVariables) {
313
325
  });
314
326
  return result.join("");
315
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
+ }
316
356
  export {
317
357
  ProjectMapClient,
318
358
  ROOT_NODE_PATH,
319
359
  Route,
320
- UncachedProjectMapClient
360
+ UncachedProjectMapClient,
361
+ getNodeLocalePath,
362
+ getRouteAlternateLocalesUrls
321
363
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/project-map",
3
- "version": "19.79.1-alpha.13+608a273da",
3
+ "version": "19.79.1-alpha.25+87cea1cd47",
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.79.1-alpha.13+608a273da",
37
- "@uniformdev/context": "19.79.1-alpha.13+608a273da"
36
+ "@uniformdev/canvas": "19.79.1-alpha.25+87cea1cd47",
37
+ "@uniformdev/context": "19.79.1-alpha.25+87cea1cd47"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "608a273da87aa432f17b2c8ce15d747dadab0cd1"
42
+ "gitHead": "87cea1cd47c691f7d32b876660d5f7c984bb1d87"
43
43
  }