@uniformdev/project-map 19.173.1-alpha.17 → 19.173.2-alpha.258

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.mts CHANGED
@@ -193,7 +193,7 @@ interface paths {
193
193
  id?: string;
194
194
  /** The path of the root node to retrieve, cannot have both this parameter and `id` */
195
195
  path?: string;
196
- /** Composition id to find associated sitemap nodes for */
196
+ /** Composition id to find associated project map node for */
197
197
  compositionId?: string;
198
198
  /** Limit the number or records returned by a number */
199
199
  limit?: number;
@@ -412,18 +412,27 @@ interface components {
412
412
  */
413
413
  id?: string;
414
414
  }[];
415
- /** @description Basic information about a composition from the context of a project map node */
415
+ /**
416
+ * @description Basic information about the linked composition from the context of a project map node.
417
+ * If the linked composition has editions, the editions are included in the `editions` property.
418
+ */
416
419
  ProjectMapNodeCompositionData: {
417
- /** @description Type of the composition instance (public_id of its definition) */
420
+ /** @description Type of the linked composition (id of its definition) */
418
421
  type: string;
419
422
  /**
420
423
  * Format: uuid
421
- * @description The public UUID of the composition
424
+ * @description The UUID of the linked composition
422
425
  */
423
426
  id: string;
424
- /** @description Slug pattern of this composition */
427
+ /**
428
+ * Format: uuid
429
+ * @description The edition UUID underneath the linked composition
430
+ * This is only present if the composition has not been published, but an edition has
431
+ */
432
+ editionId?: string;
433
+ /** @description Slug pattern of the linked composition or edition */
425
434
  slug?: string | null;
426
- /** @description Friendly name of this composition */
435
+ /** @description Friendly name of this composition or edition */
427
436
  name: string;
428
437
  /**
429
438
  * @deprecated
@@ -438,8 +447,67 @@ interface components {
438
447
  icon?: string;
439
448
  /** @description Friendly name of this Composition's Definition */
440
449
  typeName?: string;
441
- /** @description List of locales that the composition is available in. If empty, available in all locales */
450
+ /**
451
+ * @description List of locales that the composition _or any of its editions_ is available in.
452
+ * If empty, available in all locales.
453
+ */
454
+ locales: string[];
455
+ /** @description Priority of the composition relative to any editions */
456
+ editionPriority?: number;
457
+ /** @description Friendly name of the edition */
458
+ editionName?: string;
459
+ /**
460
+ * @deprecated
461
+ * @description List of editions available for this composition. The composition is included in the list, it is the edition
462
+ * where the editionID equals the node's compositionID.
463
+ */
464
+ editions?: components["schemas"]["ProjectMapNodeCompositionEditionData"][];
465
+ };
466
+ /**
467
+ * @deprecated
468
+ * @description Basic information about a composition edition from the context of a project map node
469
+ */
470
+ ProjectMapNodeCompositionEditionData: {
471
+ /**
472
+ * Format: uuid
473
+ * @description The UUID of the linked composition
474
+ */
475
+ id: string;
476
+ /** @description Type of the edition instance (public_id of its definition) */
477
+ type: string;
478
+ /**
479
+ * Format: uuid
480
+ * @description The edition UUID underneath the linked composition
481
+ */
482
+ editionId?: string;
483
+ /** @description Slug pattern of this edition */
484
+ slug?: string | null;
485
+ /** @description Friendly name of the linked composition */
486
+ name: string;
487
+ /** @description Friendly name of the edition */
488
+ editionName?: string;
489
+ /** @description Priority of the edition */
490
+ editionPriority?: number;
491
+ /**
492
+ * @deprecated
493
+ * @description UI status value. Subject to change without notice; do not rely on this value. Only present when `withCompositionUIStatus` option is true
494
+ * @enum {string}
495
+ */
496
+ uiStatus?: "Draft" | "Modified" | "Published" | "Orphan";
497
+ /**
498
+ * @description Icon name or URL for the composition edition (e.g. 'screen' or 'https://s3/my-component.jpg')
499
+ * @default screen
500
+ */
501
+ icon?: string;
502
+ /** @description Friendly name of this edition's definition */
503
+ typeName?: string;
504
+ /** @description List of locales that the edition is available in. If empty, available in all locales */
442
505
  locales: string[];
506
+ /**
507
+ * Format: date-time
508
+ * @description Date and time the composition was last modified (or created if never modified). Uses ISO-8859-1 formatting and UTC timezone.
509
+ */
510
+ modified?: string;
443
511
  };
444
512
  ProjectMapNodeUpdate: {
445
513
  /**
@@ -566,6 +634,8 @@ type ProjectMapNodeGetResponse = paths['/api/v1/project-map-nodes']['get']['resp
566
634
  type ProjectMapNode = NonNullable<ProjectMapNodeGetResponse['nodes']>[0];
567
635
  type ProjectMapNodeLocale = NonNullable<ProjectMapNode['locales']>[string];
568
636
  type ProjectMapNodeWithId = ProjectMapNode & Required<Pick<ProjectMapNode, 'id' | 'name'>>;
637
+ type ProjectMapNodeCompositionData = NonNullable<ProjectMapNode['compositionData']>;
638
+ type ProjectMapNodeCompositionEditionData = NonNullable<NonNullable<ProjectMapNode['compositionData']>['editions']>[0];
569
639
  type ProjectMapGetRequest = paths$1['/api/v1/project-map']['get']['parameters']['query'];
570
640
  type ProjectMapGetResponse = paths$1['/api/v1/project-map']['get']['responses']['200']['content']['application/json'];
571
641
  type ProjectMapUpsertRequest = paths$1['/api/v1/project-map']['put']['requestBody']['content']['application/json'];
@@ -614,25 +684,13 @@ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
614
684
  * Get available project map defintions
615
685
  */
616
686
  getProjectMapDefinitions: () => Promise<{
617
- projectMaps: {
618
- id?: string | undefined;
619
- name: string;
620
- description?: string | undefined;
621
- baseUrl?: string | undefined;
622
- default?: boolean | undefined;
623
- }[];
687
+ projectMaps: components$1["schemas"]["ProjectMapDefinition"][];
624
688
  }>;
625
689
  /**
626
690
  * Get specific project map definition
627
691
  */
628
692
  getProjectMapDefinition: (options: WithoutProjectId<ProjectMapGetRequest>) => Promise<{
629
- projectMaps: {
630
- id?: string | undefined;
631
- name: string;
632
- description?: string | undefined;
633
- baseUrl?: string | undefined;
634
- default?: boolean | undefined;
635
- }[];
693
+ projectMaps: components$1["schemas"]["ProjectMapDefinition"][];
636
694
  }>;
637
695
  /**
638
696
  * Update or insert a project map definition
@@ -664,6 +722,61 @@ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
664
722
  declare class UncachedProjectMapClient extends ProjectMapClient {
665
723
  constructor(options: Omit<ProjectMapClientOptions, 'bypassCache'>);
666
724
  }
725
+ /**
726
+ * Internal use only.
727
+ *
728
+ * @deprecated
729
+ */
730
+ declare const __INTERNAL_MISSING_PARENT_NODE_ERROR = "Upsert failed, parent node not found.";
731
+
732
+ interface ObjectWithEditionMetadata {
733
+ editionId?: string;
734
+ editionPriority?: number;
735
+ editionName?: string;
736
+ }
737
+ /**
738
+ * @deprecated pre-release functionality subject to change
739
+ */
740
+ interface GetActiveEditionOptions<T> {
741
+ /** Node to pick the active edition for */
742
+ editions: Array<T>;
743
+ /** Selects the composition/entry ID from the edition */
744
+ selectId: (edition: T) => string;
745
+ /** Selects locales that are enabled on an edition */
746
+ selectEnabledLocales: (edition: T) => string[];
747
+ selectEdition: (edition: T) => ObjectWithEditionMetadata;
748
+ /**
749
+ * The current locale to resolve an edition for.
750
+ * When undefined, the default edition/composition is always matched if it exists.
751
+ */
752
+ targetLocale: string | undefined;
753
+ }
754
+ /**
755
+ * Finds the active edition for a given locale in an array of all editions.
756
+ * The active edition is the highest priority edition that enables the target locale.
757
+ * If there is no target locale, then the default edition is returned if there is one.
758
+ * Otherwise, undefined is returned (no edition matches).
759
+ * @deprecated pre-release functionality subject to change
760
+ */
761
+ declare function getActiveEdition<T>({ editions, selectEdition, selectId, selectEnabledLocales, targetLocale, }: GetActiveEditionOptions<T>): T | undefined;
762
+
763
+ /**
764
+ * Finds the active edition for a given locale in a node's compositionData.
765
+ * Note: All editions, including the composition, are stored in the editions array when it is present.
766
+ * @deprecated pre-release functionality subject to change
767
+ */
768
+ declare function getNodeActiveCompositionEdition({ node, targetLocale, fallbackWhenLocaleNotMatched, }: {
769
+ /** Node to pick the active edition for */
770
+ node: Pick<ProjectMapNode, 'compositionData'>;
771
+ /** The current locale to resolve an edition for. When undefined, the compositionData is always matched. */
772
+ targetLocale: string | undefined;
773
+ /**
774
+ * Whether to fallback to the composition if nothing enables the target locale
775
+ * false (default): return undefined if nothing enables the target locale
776
+ * true: return the composition if nothing enables the target locale
777
+ */
778
+ fallbackWhenLocaleNotMatched?: boolean;
779
+ }): ProjectMapNode['compositionData'] | undefined;
667
780
 
668
781
  type LocalePathNode = Pick<ProjectMapNode, 'path'> & {
669
782
  locales?: Record<string, {
@@ -729,4 +842,4 @@ declare class Route {
729
842
  static dynamicSegmentPrefix: string;
730
843
  }
731
844
 
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 };
845
+ export { type AlternateLocaleUrls, type ExpandOptions, type GetActiveEditionOptions, type LocalePathNode, type MatchedRoute, type NodeType, type ObjectWithEditionMetadata, ProjectMapClient, type ProjectMapClientOptions, type ProjectMapDefinition, type ProjectMapDefinitionWithId, type ProjectMapDefinitions, type ProjectMapDeleteRequest, type ProjectMapGetRequest, type ProjectMapGetResponse, type ProjectMapNode, type ProjectMapNodeAllowedQueryString, type ProjectMapNodeCompositionData, type ProjectMapNodeCompositionEditionData, 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, __INTERNAL_MISSING_PARENT_NODE_ERROR, getActiveEdition, getNodeActiveCompositionEdition, getNodeLocalePath, getRouteAlternateLocalesUrls };
package/dist/index.d.ts CHANGED
@@ -193,7 +193,7 @@ interface paths {
193
193
  id?: string;
194
194
  /** The path of the root node to retrieve, cannot have both this parameter and `id` */
195
195
  path?: string;
196
- /** Composition id to find associated sitemap nodes for */
196
+ /** Composition id to find associated project map node for */
197
197
  compositionId?: string;
198
198
  /** Limit the number or records returned by a number */
199
199
  limit?: number;
@@ -412,18 +412,27 @@ interface components {
412
412
  */
413
413
  id?: string;
414
414
  }[];
415
- /** @description Basic information about a composition from the context of a project map node */
415
+ /**
416
+ * @description Basic information about the linked composition from the context of a project map node.
417
+ * If the linked composition has editions, the editions are included in the `editions` property.
418
+ */
416
419
  ProjectMapNodeCompositionData: {
417
- /** @description Type of the composition instance (public_id of its definition) */
420
+ /** @description Type of the linked composition (id of its definition) */
418
421
  type: string;
419
422
  /**
420
423
  * Format: uuid
421
- * @description The public UUID of the composition
424
+ * @description The UUID of the linked composition
422
425
  */
423
426
  id: string;
424
- /** @description Slug pattern of this composition */
427
+ /**
428
+ * Format: uuid
429
+ * @description The edition UUID underneath the linked composition
430
+ * This is only present if the composition has not been published, but an edition has
431
+ */
432
+ editionId?: string;
433
+ /** @description Slug pattern of the linked composition or edition */
425
434
  slug?: string | null;
426
- /** @description Friendly name of this composition */
435
+ /** @description Friendly name of this composition or edition */
427
436
  name: string;
428
437
  /**
429
438
  * @deprecated
@@ -438,8 +447,67 @@ interface components {
438
447
  icon?: string;
439
448
  /** @description Friendly name of this Composition's Definition */
440
449
  typeName?: string;
441
- /** @description List of locales that the composition is available in. If empty, available in all locales */
450
+ /**
451
+ * @description List of locales that the composition _or any of its editions_ is available in.
452
+ * If empty, available in all locales.
453
+ */
454
+ locales: string[];
455
+ /** @description Priority of the composition relative to any editions */
456
+ editionPriority?: number;
457
+ /** @description Friendly name of the edition */
458
+ editionName?: string;
459
+ /**
460
+ * @deprecated
461
+ * @description List of editions available for this composition. The composition is included in the list, it is the edition
462
+ * where the editionID equals the node's compositionID.
463
+ */
464
+ editions?: components["schemas"]["ProjectMapNodeCompositionEditionData"][];
465
+ };
466
+ /**
467
+ * @deprecated
468
+ * @description Basic information about a composition edition from the context of a project map node
469
+ */
470
+ ProjectMapNodeCompositionEditionData: {
471
+ /**
472
+ * Format: uuid
473
+ * @description The UUID of the linked composition
474
+ */
475
+ id: string;
476
+ /** @description Type of the edition instance (public_id of its definition) */
477
+ type: string;
478
+ /**
479
+ * Format: uuid
480
+ * @description The edition UUID underneath the linked composition
481
+ */
482
+ editionId?: string;
483
+ /** @description Slug pattern of this edition */
484
+ slug?: string | null;
485
+ /** @description Friendly name of the linked composition */
486
+ name: string;
487
+ /** @description Friendly name of the edition */
488
+ editionName?: string;
489
+ /** @description Priority of the edition */
490
+ editionPriority?: number;
491
+ /**
492
+ * @deprecated
493
+ * @description UI status value. Subject to change without notice; do not rely on this value. Only present when `withCompositionUIStatus` option is true
494
+ * @enum {string}
495
+ */
496
+ uiStatus?: "Draft" | "Modified" | "Published" | "Orphan";
497
+ /**
498
+ * @description Icon name or URL for the composition edition (e.g. 'screen' or 'https://s3/my-component.jpg')
499
+ * @default screen
500
+ */
501
+ icon?: string;
502
+ /** @description Friendly name of this edition's definition */
503
+ typeName?: string;
504
+ /** @description List of locales that the edition is available in. If empty, available in all locales */
442
505
  locales: string[];
506
+ /**
507
+ * Format: date-time
508
+ * @description Date and time the composition was last modified (or created if never modified). Uses ISO-8859-1 formatting and UTC timezone.
509
+ */
510
+ modified?: string;
443
511
  };
444
512
  ProjectMapNodeUpdate: {
445
513
  /**
@@ -566,6 +634,8 @@ type ProjectMapNodeGetResponse = paths['/api/v1/project-map-nodes']['get']['resp
566
634
  type ProjectMapNode = NonNullable<ProjectMapNodeGetResponse['nodes']>[0];
567
635
  type ProjectMapNodeLocale = NonNullable<ProjectMapNode['locales']>[string];
568
636
  type ProjectMapNodeWithId = ProjectMapNode & Required<Pick<ProjectMapNode, 'id' | 'name'>>;
637
+ type ProjectMapNodeCompositionData = NonNullable<ProjectMapNode['compositionData']>;
638
+ type ProjectMapNodeCompositionEditionData = NonNullable<NonNullable<ProjectMapNode['compositionData']>['editions']>[0];
569
639
  type ProjectMapGetRequest = paths$1['/api/v1/project-map']['get']['parameters']['query'];
570
640
  type ProjectMapGetResponse = paths$1['/api/v1/project-map']['get']['responses']['200']['content']['application/json'];
571
641
  type ProjectMapUpsertRequest = paths$1['/api/v1/project-map']['put']['requestBody']['content']['application/json'];
@@ -614,25 +684,13 @@ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
614
684
  * Get available project map defintions
615
685
  */
616
686
  getProjectMapDefinitions: () => Promise<{
617
- projectMaps: {
618
- id?: string | undefined;
619
- name: string;
620
- description?: string | undefined;
621
- baseUrl?: string | undefined;
622
- default?: boolean | undefined;
623
- }[];
687
+ projectMaps: components$1["schemas"]["ProjectMapDefinition"][];
624
688
  }>;
625
689
  /**
626
690
  * Get specific project map definition
627
691
  */
628
692
  getProjectMapDefinition: (options: WithoutProjectId<ProjectMapGetRequest>) => Promise<{
629
- projectMaps: {
630
- id?: string | undefined;
631
- name: string;
632
- description?: string | undefined;
633
- baseUrl?: string | undefined;
634
- default?: boolean | undefined;
635
- }[];
693
+ projectMaps: components$1["schemas"]["ProjectMapDefinition"][];
636
694
  }>;
637
695
  /**
638
696
  * Update or insert a project map definition
@@ -664,6 +722,61 @@ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
664
722
  declare class UncachedProjectMapClient extends ProjectMapClient {
665
723
  constructor(options: Omit<ProjectMapClientOptions, 'bypassCache'>);
666
724
  }
725
+ /**
726
+ * Internal use only.
727
+ *
728
+ * @deprecated
729
+ */
730
+ declare const __INTERNAL_MISSING_PARENT_NODE_ERROR = "Upsert failed, parent node not found.";
731
+
732
+ interface ObjectWithEditionMetadata {
733
+ editionId?: string;
734
+ editionPriority?: number;
735
+ editionName?: string;
736
+ }
737
+ /**
738
+ * @deprecated pre-release functionality subject to change
739
+ */
740
+ interface GetActiveEditionOptions<T> {
741
+ /** Node to pick the active edition for */
742
+ editions: Array<T>;
743
+ /** Selects the composition/entry ID from the edition */
744
+ selectId: (edition: T) => string;
745
+ /** Selects locales that are enabled on an edition */
746
+ selectEnabledLocales: (edition: T) => string[];
747
+ selectEdition: (edition: T) => ObjectWithEditionMetadata;
748
+ /**
749
+ * The current locale to resolve an edition for.
750
+ * When undefined, the default edition/composition is always matched if it exists.
751
+ */
752
+ targetLocale: string | undefined;
753
+ }
754
+ /**
755
+ * Finds the active edition for a given locale in an array of all editions.
756
+ * The active edition is the highest priority edition that enables the target locale.
757
+ * If there is no target locale, then the default edition is returned if there is one.
758
+ * Otherwise, undefined is returned (no edition matches).
759
+ * @deprecated pre-release functionality subject to change
760
+ */
761
+ declare function getActiveEdition<T>({ editions, selectEdition, selectId, selectEnabledLocales, targetLocale, }: GetActiveEditionOptions<T>): T | undefined;
762
+
763
+ /**
764
+ * Finds the active edition for a given locale in a node's compositionData.
765
+ * Note: All editions, including the composition, are stored in the editions array when it is present.
766
+ * @deprecated pre-release functionality subject to change
767
+ */
768
+ declare function getNodeActiveCompositionEdition({ node, targetLocale, fallbackWhenLocaleNotMatched, }: {
769
+ /** Node to pick the active edition for */
770
+ node: Pick<ProjectMapNode, 'compositionData'>;
771
+ /** The current locale to resolve an edition for. When undefined, the compositionData is always matched. */
772
+ targetLocale: string | undefined;
773
+ /**
774
+ * Whether to fallback to the composition if nothing enables the target locale
775
+ * false (default): return undefined if nothing enables the target locale
776
+ * true: return the composition if nothing enables the target locale
777
+ */
778
+ fallbackWhenLocaleNotMatched?: boolean;
779
+ }): ProjectMapNode['compositionData'] | undefined;
667
780
 
668
781
  type LocalePathNode = Pick<ProjectMapNode, 'path'> & {
669
782
  locales?: Record<string, {
@@ -729,4 +842,4 @@ declare class Route {
729
842
  static dynamicSegmentPrefix: string;
730
843
  }
731
844
 
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 };
845
+ export { type AlternateLocaleUrls, type ExpandOptions, type GetActiveEditionOptions, type LocalePathNode, type MatchedRoute, type NodeType, type ObjectWithEditionMetadata, ProjectMapClient, type ProjectMapClientOptions, type ProjectMapDefinition, type ProjectMapDefinitionWithId, type ProjectMapDefinitions, type ProjectMapDeleteRequest, type ProjectMapGetRequest, type ProjectMapGetResponse, type ProjectMapNode, type ProjectMapNodeAllowedQueryString, type ProjectMapNodeCompositionData, type ProjectMapNodeCompositionEditionData, 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, __INTERNAL_MISSING_PARENT_NODE_ERROR, getActiveEdition, getNodeActiveCompositionEdition, getNodeLocalePath, getRouteAlternateLocalesUrls };
package/dist/index.esm.js CHANGED
@@ -178,6 +178,72 @@ var cutReferences = (node) => node ? {
178
178
  parent: void 0,
179
179
  children: void 0
180
180
  } : void 0;
181
+ var __INTERNAL_MISSING_PARENT_NODE_ERROR = "Upsert failed, parent node not found.";
182
+
183
+ // src/util/getActiveEdition.ts
184
+ function getActiveEdition({
185
+ editions,
186
+ selectEdition,
187
+ selectId,
188
+ selectEnabledLocales,
189
+ targetLocale
190
+ }) {
191
+ if (!editions || !editions.length) {
192
+ return void 0;
193
+ }
194
+ if (!targetLocale) {
195
+ return editions.find((t) => {
196
+ const edition = selectEdition(t);
197
+ return !edition.editionId || edition.editionId === selectId(t);
198
+ });
199
+ }
200
+ let activeT = void 0;
201
+ editions.forEach((t) => {
202
+ var _a, _b, _c, _d;
203
+ const edition = selectEdition(t);
204
+ const activeEdition = activeT ? selectEdition(activeT) : void 0;
205
+ const editionPriority = (_a = edition.editionPriority) != null ? _a : 0;
206
+ const activeEditionPriority = (_b = activeEdition == null ? void 0 : activeEdition.editionPriority) != null ? _b : Number.MIN_SAFE_INTEGER;
207
+ if (selectEnabledLocales(t).includes(targetLocale) && (editionPriority > activeEditionPriority || editionPriority === activeEditionPriority && ((_c = edition.editionName) != null ? _c : "").localeCompare((_d = activeEdition == null ? void 0 : activeEdition.editionName) != null ? _d : "", "en", {
208
+ sensitivity: "base"
209
+ }) < 0)) {
210
+ activeT = t;
211
+ }
212
+ });
213
+ return activeT;
214
+ }
215
+
216
+ // src/util/getNodeActiveCompositionEdition.ts
217
+ function getNodeActiveCompositionEdition({
218
+ node,
219
+ targetLocale,
220
+ fallbackWhenLocaleNotMatched = false
221
+ }) {
222
+ var _a;
223
+ if (!node.compositionData) {
224
+ return void 0;
225
+ }
226
+ if (!targetLocale) {
227
+ return node.compositionData;
228
+ }
229
+ const activeEdition = getActiveEdition({
230
+ editions: (_a = node.compositionData.editions) != null ? _a : [],
231
+ selectId: (edition) => {
232
+ var _a2;
233
+ return (_a2 = edition.editionId) != null ? _a2 : "";
234
+ },
235
+ selectEnabledLocales: (edition) => edition.locales,
236
+ selectEdition: (edition) => edition,
237
+ targetLocale
238
+ });
239
+ if (!node.compositionData.editions && node.compositionData.locales.includes(targetLocale)) {
240
+ return node.compositionData;
241
+ }
242
+ if (fallbackWhenLocaleNotMatched && !activeEdition) {
243
+ return node.compositionData;
244
+ }
245
+ return activeEdition;
246
+ }
181
247
 
182
248
  // src/util/getNodeLocalePath.ts
183
249
  function getNodeLocalePath(node, locale) {
@@ -341,6 +407,9 @@ export {
341
407
  ROOT_NODE_PATH,
342
408
  Route,
343
409
  UncachedProjectMapClient,
410
+ __INTERNAL_MISSING_PARENT_NODE_ERROR,
411
+ getActiveEdition,
412
+ getNodeActiveCompositionEdition,
344
413
  getNodeLocalePath,
345
414
  getRouteAlternateLocalesUrls
346
415
  };
package/dist/index.js CHANGED
@@ -32,6 +32,9 @@ __export(src_exports, {
32
32
  ROOT_NODE_PATH: () => ROOT_NODE_PATH,
33
33
  Route: () => Route,
34
34
  UncachedProjectMapClient: () => UncachedProjectMapClient,
35
+ __INTERNAL_MISSING_PARENT_NODE_ERROR: () => __INTERNAL_MISSING_PARENT_NODE_ERROR,
36
+ getActiveEdition: () => getActiveEdition,
37
+ getNodeActiveCompositionEdition: () => getNodeActiveCompositionEdition,
35
38
  getNodeLocalePath: () => getNodeLocalePath,
36
39
  getRouteAlternateLocalesUrls: () => getRouteAlternateLocalesUrls
37
40
  });
@@ -208,6 +211,72 @@ var cutReferences = (node) => node ? {
208
211
  parent: void 0,
209
212
  children: void 0
210
213
  } : void 0;
214
+ var __INTERNAL_MISSING_PARENT_NODE_ERROR = "Upsert failed, parent node not found.";
215
+
216
+ // src/util/getActiveEdition.ts
217
+ function getActiveEdition({
218
+ editions,
219
+ selectEdition,
220
+ selectId,
221
+ selectEnabledLocales,
222
+ targetLocale
223
+ }) {
224
+ if (!editions || !editions.length) {
225
+ return void 0;
226
+ }
227
+ if (!targetLocale) {
228
+ return editions.find((t) => {
229
+ const edition = selectEdition(t);
230
+ return !edition.editionId || edition.editionId === selectId(t);
231
+ });
232
+ }
233
+ let activeT = void 0;
234
+ editions.forEach((t) => {
235
+ var _a, _b, _c, _d;
236
+ const edition = selectEdition(t);
237
+ const activeEdition = activeT ? selectEdition(activeT) : void 0;
238
+ const editionPriority = (_a = edition.editionPriority) != null ? _a : 0;
239
+ const activeEditionPriority = (_b = activeEdition == null ? void 0 : activeEdition.editionPriority) != null ? _b : Number.MIN_SAFE_INTEGER;
240
+ if (selectEnabledLocales(t).includes(targetLocale) && (editionPriority > activeEditionPriority || editionPriority === activeEditionPriority && ((_c = edition.editionName) != null ? _c : "").localeCompare((_d = activeEdition == null ? void 0 : activeEdition.editionName) != null ? _d : "", "en", {
241
+ sensitivity: "base"
242
+ }) < 0)) {
243
+ activeT = t;
244
+ }
245
+ });
246
+ return activeT;
247
+ }
248
+
249
+ // src/util/getNodeActiveCompositionEdition.ts
250
+ function getNodeActiveCompositionEdition({
251
+ node,
252
+ targetLocale,
253
+ fallbackWhenLocaleNotMatched = false
254
+ }) {
255
+ var _a;
256
+ if (!node.compositionData) {
257
+ return void 0;
258
+ }
259
+ if (!targetLocale) {
260
+ return node.compositionData;
261
+ }
262
+ const activeEdition = getActiveEdition({
263
+ editions: (_a = node.compositionData.editions) != null ? _a : [],
264
+ selectId: (edition) => {
265
+ var _a2;
266
+ return (_a2 = edition.editionId) != null ? _a2 : "";
267
+ },
268
+ selectEnabledLocales: (edition) => edition.locales,
269
+ selectEdition: (edition) => edition,
270
+ targetLocale
271
+ });
272
+ if (!node.compositionData.editions && node.compositionData.locales.includes(targetLocale)) {
273
+ return node.compositionData;
274
+ }
275
+ if (fallbackWhenLocaleNotMatched && !activeEdition) {
276
+ return node.compositionData;
277
+ }
278
+ return activeEdition;
279
+ }
211
280
 
212
281
  // src/util/getNodeLocalePath.ts
213
282
  function getNodeLocalePath(node, locale) {
@@ -372,6 +441,9 @@ function getRouteAlternateLocalesUrls(routeResponse) {
372
441
  ROOT_NODE_PATH,
373
442
  Route,
374
443
  UncachedProjectMapClient,
444
+ __INTERNAL_MISSING_PARENT_NODE_ERROR,
445
+ getActiveEdition,
446
+ getNodeActiveCompositionEdition,
375
447
  getNodeLocalePath,
376
448
  getRouteAlternateLocalesUrls
377
449
  });
package/dist/index.mjs CHANGED
@@ -178,6 +178,72 @@ var cutReferences = (node) => node ? {
178
178
  parent: void 0,
179
179
  children: void 0
180
180
  } : void 0;
181
+ var __INTERNAL_MISSING_PARENT_NODE_ERROR = "Upsert failed, parent node not found.";
182
+
183
+ // src/util/getActiveEdition.ts
184
+ function getActiveEdition({
185
+ editions,
186
+ selectEdition,
187
+ selectId,
188
+ selectEnabledLocales,
189
+ targetLocale
190
+ }) {
191
+ if (!editions || !editions.length) {
192
+ return void 0;
193
+ }
194
+ if (!targetLocale) {
195
+ return editions.find((t) => {
196
+ const edition = selectEdition(t);
197
+ return !edition.editionId || edition.editionId === selectId(t);
198
+ });
199
+ }
200
+ let activeT = void 0;
201
+ editions.forEach((t) => {
202
+ var _a, _b, _c, _d;
203
+ const edition = selectEdition(t);
204
+ const activeEdition = activeT ? selectEdition(activeT) : void 0;
205
+ const editionPriority = (_a = edition.editionPriority) != null ? _a : 0;
206
+ const activeEditionPriority = (_b = activeEdition == null ? void 0 : activeEdition.editionPriority) != null ? _b : Number.MIN_SAFE_INTEGER;
207
+ if (selectEnabledLocales(t).includes(targetLocale) && (editionPriority > activeEditionPriority || editionPriority === activeEditionPriority && ((_c = edition.editionName) != null ? _c : "").localeCompare((_d = activeEdition == null ? void 0 : activeEdition.editionName) != null ? _d : "", "en", {
208
+ sensitivity: "base"
209
+ }) < 0)) {
210
+ activeT = t;
211
+ }
212
+ });
213
+ return activeT;
214
+ }
215
+
216
+ // src/util/getNodeActiveCompositionEdition.ts
217
+ function getNodeActiveCompositionEdition({
218
+ node,
219
+ targetLocale,
220
+ fallbackWhenLocaleNotMatched = false
221
+ }) {
222
+ var _a;
223
+ if (!node.compositionData) {
224
+ return void 0;
225
+ }
226
+ if (!targetLocale) {
227
+ return node.compositionData;
228
+ }
229
+ const activeEdition = getActiveEdition({
230
+ editions: (_a = node.compositionData.editions) != null ? _a : [],
231
+ selectId: (edition) => {
232
+ var _a2;
233
+ return (_a2 = edition.editionId) != null ? _a2 : "";
234
+ },
235
+ selectEnabledLocales: (edition) => edition.locales,
236
+ selectEdition: (edition) => edition,
237
+ targetLocale
238
+ });
239
+ if (!node.compositionData.editions && node.compositionData.locales.includes(targetLocale)) {
240
+ return node.compositionData;
241
+ }
242
+ if (fallbackWhenLocaleNotMatched && !activeEdition) {
243
+ return node.compositionData;
244
+ }
245
+ return activeEdition;
246
+ }
181
247
 
182
248
  // src/util/getNodeLocalePath.ts
183
249
  function getNodeLocalePath(node, locale) {
@@ -341,6 +407,9 @@ export {
341
407
  ROOT_NODE_PATH,
342
408
  Route,
343
409
  UncachedProjectMapClient,
410
+ __INTERNAL_MISSING_PARENT_NODE_ERROR,
411
+ getActiveEdition,
412
+ getNodeActiveCompositionEdition,
344
413
  getNodeLocalePath,
345
414
  getRouteAlternateLocalesUrls
346
415
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/project-map",
3
- "version": "19.173.1-alpha.17+25c1176cea",
3
+ "version": "19.173.2-alpha.258+e8775b83de",
4
4
  "description": "Uniform Project Map",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "dev": "run-s update-openapi dev:ts",
24
24
  "dev:ts": "tsup --watch",
25
25
  "clean": "rimraf dist",
26
- "test": "jest --maxWorkers=1 --passWithNoTests",
26
+ "test": "jest --passWithNoTests",
27
27
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
28
28
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
29
29
  "update-openapi": "tsx ./scripts/update-openapi.cts",
@@ -33,11 +33,11 @@
33
33
  "/dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@uniformdev/canvas": "19.173.1-alpha.17+25c1176cea",
37
- "@uniformdev/context": "19.173.1-alpha.17+25c1176cea"
36
+ "@uniformdev/canvas": "19.173.2-alpha.258+e8775b83de",
37
+ "@uniformdev/context": "19.173.2-alpha.258+e8775b83de"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "25c1176cea8d5114b92fc75cdd8bba4aa6463a50"
42
+ "gitHead": "e8775b83dec606ce6e2198182152d8b386e15f94"
43
43
  }