@epam/ai-dial-chat-hooks 1.4.0-dev.12 → 1.4.0-dev.122

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.
Files changed (189) hide show
  1. package/api-error/map-api-error.d.ts +10 -0
  2. package/api-error/map-api-error.d.ts.map +1 -0
  3. package/api-error/map-api-error.js +11 -0
  4. package/attachment/useAttachmentAction/useAttachmentAction.d.ts +1 -1
  5. package/attachment/useAttachmentAction/useAttachmentAction.d.ts.map +1 -1
  6. package/attachment/useAttachmentAction/useAttachmentAction.js +35 -44
  7. package/catalog/create-publish-api.d.ts +22 -1
  8. package/catalog/create-publish-api.d.ts.map +1 -1
  9. package/catalog/create-publish-api.js +20 -1
  10. package/catalog/entity-details.d.ts +5 -2
  11. package/catalog/entity-details.d.ts.map +1 -1
  12. package/catalog/map-entity-details-to-catalog.d.ts +4 -0
  13. package/catalog/map-entity-details-to-catalog.d.ts.map +1 -1
  14. package/catalog/map-entity-details-to-catalog.js +15 -13
  15. package/catalog/publish-dependency-icons.d.ts +22 -0
  16. package/catalog/publish-dependency-icons.d.ts.map +1 -0
  17. package/catalog/publish-dependency-icons.js +11 -0
  18. package/catalog/publish-target-taken.d.ts +31 -0
  19. package/catalog/publish-target-taken.d.ts.map +1 -0
  20. package/catalog/publish-target-taken.js +14 -0
  21. package/catalog/publish.d.ts +15 -2
  22. package/catalog/publish.d.ts.map +1 -1
  23. package/catalog/publish.js +15 -4
  24. package/catalog/resource-name-conflict.d.ts.map +1 -1
  25. package/catalog/resource-name-conflict.js +19 -22
  26. package/catalog/resource-save-adapter.d.ts +7 -2
  27. package/catalog/resource-save-adapter.d.ts.map +1 -1
  28. package/catalog/resource-save-adapters.d.ts +32 -7
  29. package/catalog/resource-save-adapters.d.ts.map +1 -1
  30. package/catalog/resource-save-adapters.js +47 -41
  31. package/catalog/resource-save.d.ts +17 -9
  32. package/catalog/resource-save.d.ts.map +1 -1
  33. package/catalog/resource-save.js +34 -25
  34. package/catalog/save-destination-root.d.ts +12 -0
  35. package/catalog/save-destination-root.d.ts.map +1 -0
  36. package/catalog/save-destination-root.js +6 -0
  37. package/catalog/use-publish-dependencies.d.ts +19 -0
  38. package/catalog/use-publish-dependencies.d.ts.map +1 -0
  39. package/catalog/use-publish-dependencies.js +25 -0
  40. package/catalog/use-publish-target-guard.d.ts +45 -0
  41. package/catalog/use-publish-target-guard.d.ts.map +1 -0
  42. package/catalog/use-publish-target-guard.js +18 -0
  43. package/catalog/usePublishFolders/usePublishFolders.d.ts +8 -2
  44. package/catalog/usePublishFolders/usePublishFolders.d.ts.map +1 -1
  45. package/catalog/usePublishFolders/usePublishFolders.js +29 -29
  46. package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts +7 -3
  47. package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts.map +1 -1
  48. package/catalog/useResourceSavePanel/useResourceSavePanel.js +107 -97
  49. package/catalog/useVersionHistory/useVersionHistory.d.ts +38 -0
  50. package/catalog/useVersionHistory/useVersionHistory.d.ts.map +1 -0
  51. package/catalog/useVersionHistory/useVersionHistory.js +49 -0
  52. package/catalog/useVersionHistory/useVersionHistorySection.d.ts +30 -0
  53. package/catalog/useVersionHistory/useVersionHistorySection.d.ts.map +1 -0
  54. package/catalog/useVersionHistory/useVersionHistorySection.js +31 -0
  55. package/catalog/version-history.d.ts +42 -0
  56. package/catalog/version-history.d.ts.map +1 -0
  57. package/catalog/version-history.js +27 -0
  58. package/catalog.js +39 -31
  59. package/conversation/announcement-message.d.ts +12 -0
  60. package/conversation/announcement-message.d.ts.map +1 -1
  61. package/conversation/announcement-message.js +16 -10
  62. package/conversation/conversation-list.d.ts +7 -1
  63. package/conversation/conversation-list.d.ts.map +1 -1
  64. package/conversation/conversation-list.js +11 -2
  65. package/conversation/conversation-transfer/zip-export.d.ts +1 -1
  66. package/conversation/conversation-transfer/zip-export.d.ts.map +1 -1
  67. package/conversation/conversation-transfer/zip-export.js +7 -8
  68. package/conversation/conversation-transfer/zip-import.d.ts.map +1 -1
  69. package/conversation/conversation-transfer/zip-import.js +8 -9
  70. package/conversation/useConversationExport/useConversationExport.d.ts.map +1 -1
  71. package/conversation/useConversationExport/useConversationExport.js +3 -1
  72. package/conversation/useConversationStream/generation-resume.d.ts.map +1 -1
  73. package/conversation/useConversationStream/generation-resume.js +119 -96
  74. package/conversation.js +44 -44
  75. package/entry-points/catalog.d.ts +7 -0
  76. package/entry-points/catalog.d.ts.map +1 -1
  77. package/entry-points/file-manager.d.ts +1 -0
  78. package/entry-points/file-manager.d.ts.map +1 -1
  79. package/entry-points/project.d.ts +5 -0
  80. package/entry-points/project.d.ts.map +1 -1
  81. package/entry-points/scheduled-tasks.d.ts +2 -0
  82. package/entry-points/scheduled-tasks.d.ts.map +1 -1
  83. package/entry-points/usage-limits.d.ts +1 -0
  84. package/entry-points/usage-limits.d.ts.map +1 -1
  85. package/entry-points/utils.d.ts +7 -0
  86. package/entry-points/utils.d.ts.map +1 -1
  87. package/file-manager.js +33 -32
  88. package/files/annotation.d.ts +3 -3
  89. package/files/annotation.d.ts.map +1 -1
  90. package/files/annotation.js +12 -11
  91. package/files/attachment-canvas.d.ts +1 -1
  92. package/files/attachment-canvas.d.ts.map +1 -1
  93. package/files/attachment-canvas.js +135 -135
  94. package/files/attachment-type-labels.d.ts +3 -0
  95. package/files/attachment-type-labels.d.ts.map +1 -0
  96. package/files/attachment-type-labels.js +12 -0
  97. package/files/attachment-types.d.ts +0 -2
  98. package/files/attachment-types.d.ts.map +1 -1
  99. package/files/attachment-types.js +7 -14
  100. package/files/dial-file.d.ts +18 -0
  101. package/files/dial-file.d.ts.map +1 -1
  102. package/files/dial-file.js +30 -5
  103. package/index.d.ts +23 -0
  104. package/index.d.ts.map +1 -1
  105. package/index.js +266 -244
  106. package/org-units/models.d.ts +11 -0
  107. package/org-units/models.d.ts.map +1 -0
  108. package/org-units/org-unit-guards.d.ts +64 -0
  109. package/org-units/org-unit-guards.d.ts.map +1 -0
  110. package/org-units/org-unit-guards.js +28 -0
  111. package/org-units/types.d.ts +14 -0
  112. package/org-units/types.d.ts.map +1 -0
  113. package/org-units/types.js +6 -0
  114. package/org-units/useFolderGuards/useFolderGuards.d.ts +31 -0
  115. package/org-units/useFolderGuards/useFolderGuards.d.ts.map +1 -0
  116. package/org-units/useFolderGuards/useFolderGuards.js +50 -0
  117. package/org-units/useOrgUnits/useOrgUnits.d.ts +34 -0
  118. package/org-units/useOrgUnits/useOrgUnits.d.ts.map +1 -0
  119. package/org-units/useOrgUnits/useOrgUnits.js +54 -0
  120. package/package.json +19 -19
  121. package/project/project-sharing-client.d.ts +8 -0
  122. package/project/project-sharing-client.d.ts.map +1 -0
  123. package/project/project-sharing-client.js +11 -0
  124. package/project/project-sharing.d.ts +28 -0
  125. package/project/project-sharing.d.ts.map +1 -0
  126. package/project/project-sharing.js +22 -0
  127. package/project/use-pinned-project-chats.d.ts +4 -2
  128. package/project/use-pinned-project-chats.d.ts.map +1 -1
  129. package/project/use-pinned-project-chats.js +152 -96
  130. package/project/use-project-conversations.d.ts.map +1 -1
  131. package/project/use-project-conversations.js +2 -2
  132. package/project/use-project-remove-from-list.d.ts +30 -0
  133. package/project/use-project-remove-from-list.d.ts.map +1 -0
  134. package/project/use-project-remove-from-list.js +39 -0
  135. package/project/use-project-revoke-access.d.ts +15 -0
  136. package/project/use-project-revoke-access.d.ts.map +1 -0
  137. package/project/use-project-revoke-access.js +32 -0
  138. package/project/use-project-share-recipients.d.ts +7 -0
  139. package/project/use-project-share-recipients.d.ts.map +1 -0
  140. package/project/use-project-share-recipients.js +36 -0
  141. package/project/use-projects.d.ts +1 -0
  142. package/project/use-projects.d.ts.map +1 -1
  143. package/project/use-projects.js +2 -1
  144. package/project.js +7 -2
  145. package/scheduled-task/scheduled-task-description.d.ts +19 -13
  146. package/scheduled-task/scheduled-task-description.d.ts.map +1 -1
  147. package/scheduled-task/scheduled-task-description.js +39 -55
  148. package/scheduled-task/scheduled-task-display.d.ts +20 -6
  149. package/scheduled-task/scheduled-task-display.d.ts.map +1 -1
  150. package/scheduled-task/scheduled-task-display.js +39 -43
  151. package/scheduled-task/scheduled-task-next-occurrence.d.ts +9 -5
  152. package/scheduled-task/scheduled-task-next-occurrence.d.ts.map +1 -1
  153. package/scheduled-task/scheduled-task-next-occurrence.js +16 -16
  154. package/scheduled-task/scheduled-task-time-format.d.ts +34 -0
  155. package/scheduled-task/scheduled-task-time-format.d.ts.map +1 -0
  156. package/scheduled-task/scheduled-task-time-format.js +33 -0
  157. package/scheduled-task/scheduled-task-trigger.d.ts +6 -4
  158. package/scheduled-task/scheduled-task-trigger.d.ts.map +1 -1
  159. package/scheduled-task/scheduled-task-trigger.js +92 -115
  160. package/scheduled-tasks.js +15 -13
  161. package/shared/timezones.d.ts +30 -0
  162. package/shared/timezones.d.ts.map +1 -0
  163. package/shared/timezones.js +102 -0
  164. package/skill/skill-archive.d.ts.map +1 -1
  165. package/skill/skill-archive.js +6 -7
  166. package/skill/skill.d.ts +2 -2
  167. package/skill/skill.d.ts.map +1 -1
  168. package/skill/skill.js +33 -34
  169. package/skill/useSkillEditorLoad.js +1 -1
  170. package/skill/useSkillEditorSubmit.d.ts +4 -1
  171. package/skill/useSkillEditorSubmit.d.ts.map +1 -1
  172. package/skill/useSkillEditorSubmit.js +125 -121
  173. package/usage/map-usage-data-to-dashboard.d.ts +22 -1
  174. package/usage/map-usage-data-to-dashboard.d.ts.map +1 -1
  175. package/usage/map-usage-data-to-dashboard.js +33 -2
  176. package/usage/spending-limits-mode.d.ts +37 -0
  177. package/usage/spending-limits-mode.d.ts.map +1 -0
  178. package/usage/spending-limits-mode.js +15 -0
  179. package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.d.ts +6 -2
  180. package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.d.ts.map +1 -1
  181. package/usage/useUsageLimitBanner/useUsageLimitBanner.d.ts +4 -1
  182. package/usage/useUsageLimitBanner/useUsageLimitBanner.d.ts.map +1 -1
  183. package/usage/useUsageLimitBanner/useUsageLimitBanner.js +55 -47
  184. package/usage-limits.js +6 -5
  185. package/usage.js +3 -3
  186. package/utils.js +27 -21
  187. package/shared/cron-day-of-month.d.ts +0 -21
  188. package/shared/cron-day-of-month.d.ts.map +0 -1
  189. package/shared/cron-day-of-month.js +0 -13
@@ -0,0 +1,45 @@
1
+ import { PublishApiClient } from './create-publish-api';
2
+ import { CatalogPublishEntityType } from './publish';
3
+ /** The catalog entity a published item stands for. */
4
+ export interface PublishTargetEntity {
5
+ /** Catalog entity kind. */
6
+ entityType: CatalogPublishEntityType;
7
+ /** Resource id of the entity. */
8
+ entityId: string;
9
+ }
10
+ /** Host inputs of {@link usePublishTargetGuard}. */
11
+ export interface UsePublishTargetGuardOptions<TItem extends {
12
+ version?: string;
13
+ }> {
14
+ /** The configured publish requests; only `checkPublishTarget` is used. Must be referentially stable. */
15
+ client: Pick<PublishApiClient, 'checkPublishTarget'>;
16
+ /**
17
+ * Resolves the entity behind a publish-flow item, or `undefined` for an item
18
+ * that is not publishable (it is then never reported as taken). Must be
19
+ * referentially stable.
20
+ */
21
+ getEntity: (item: TItem) => PublishTargetEntity | undefined;
22
+ }
23
+ /** What {@link usePublishTargetGuard} hands to `usePublishFlow` and the host's publish call. */
24
+ export interface PublishTargetGuard<TItem extends {
25
+ version?: string;
26
+ }> {
27
+ /** `usePublishFlow`'s `onCheckTargetExists`: asks the backend whether the published path is taken. */
28
+ onCheckTargetExists: (item: TItem, folderPath: string[]) => Promise<boolean>;
29
+ /** `usePublishFlow`'s `isTargetTakenError`: true for the error {@link PublishTargetGuard.wrapPublish} throws. */
30
+ isTargetTakenError: (error: unknown) => boolean;
31
+ /** Wraps the host's publish call so a taken-target `409` is rejected as a `PublishTargetTakenError`. */
32
+ wrapPublish: <Args extends unknown[], Result>(publish: (...args: Args) => Promise<Result>) => (...args: Args) => Promise<Result>;
33
+ }
34
+ /**
35
+ * Wires the target check of a publish panel: the check request
36
+ * (folder segments joined with `/`, the item's version when it has one), the
37
+ * predicate that recognises a taken-target rejection, and the wrapper that
38
+ * produces it. The request and its mapping stay in {@link PublishApiClient};
39
+ * the panel and `usePublishFlow` only receive callbacks.
40
+ * @param options - the publish client and the lookup of an item's entity
41
+ */
42
+ export declare const usePublishTargetGuard: <TItem extends {
43
+ version?: string;
44
+ }>({ client, getEntity, }: UsePublishTargetGuardOptions<TItem>) => PublishTargetGuard<TItem>;
45
+ //# sourceMappingURL=use-publish-target-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-publish-target-guard.d.ts","sourceRoot":"","sources":["../../src/catalog/use-publish-target-guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAM1D,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,UAAU,EAAE,wBAAwB,CAAC;IACrC,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,oDAAoD;AACpD,MAAM,WAAW,4BAA4B,CAC3C,KAAK,SAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;IAElC,wGAAwG;IACxG,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACrD;;;;OAIG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,mBAAmB,GAAG,SAAS,CAAC;CAC7D;AAED,gGAAgG;AAChG,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;IACpE,sGAAsG;IACtG,mBAAmB,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7E,iHAAiH;IACjH,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAChD,wGAAwG;IACxG,WAAW,EAAE,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EAC1C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,KACxC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,KAAK,SAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,wBAGvE,4BAA4B,CAAC,KAAK,CAAC,KAAG,kBAAkB,CAAC,KAAK,CAwBhE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { PublishTargetTakenError as e, wrapPublishTargetTaken as t } from "./publish-target-taken.js";
2
+ import { useCallback as n, useMemo as r } from "react";
3
+ //#region src/catalog/use-publish-target-guard.ts
4
+ var i = (t) => t instanceof e, a = ({ client: e, getEntity: a }) => {
5
+ let o = n(async (t, n) => {
6
+ let r = a(t);
7
+ if (r == null) return !1;
8
+ let { taken: i } = await e.checkPublishTarget(r.entityType, r.entityId, n.join("/"), t.version || void 0);
9
+ return i;
10
+ }, [e, a]);
11
+ return r(() => ({
12
+ onCheckTargetExists: o,
13
+ isTargetTakenError: i,
14
+ wrapPublish: t
15
+ }), [o]);
16
+ };
17
+ //#endregion
18
+ export { a as usePublishTargetGuard };
@@ -26,6 +26,12 @@ export interface UsePublishFoldersParams {
26
26
  * Omit it for a host that does not persist destinations.
27
27
  */
28
28
  onRememberedFolderKeysChange?: (folderKeys: string[]) => void;
29
+ /**
30
+ * Host rule for whether a destination accepts a publish, replacing the
31
+ * `Production` placeholder when given. Omit it while the rule is unknown
32
+ * (feature off, rights not loaded) so the placeholder stays the fallback.
33
+ */
34
+ canPublishTo?: (folderPath: string[]) => boolean;
29
35
  }
30
36
  /** Result returned by {@link usePublishFolders}. */
31
37
  export interface UsePublishFoldersResult {
@@ -57,7 +63,7 @@ export interface UsePublishFoldersResult {
57
63
  * later publishes. Call it after a successful publish.
58
64
  */
59
65
  rememberPublishFolder: (folderPath: string[]) => void;
60
- /** Heuristic write-access check for a folder path (see the TODO above). */
66
+ /** Write-access check for a folder path: the host's `canPublishTo` when given, otherwise the `Production` heuristic (see the TODO above). */
61
67
  hasPublishWriteAccess: (folderPath: string[]) => boolean;
62
68
  }
63
69
  /**
@@ -77,5 +83,5 @@ export interface UsePublishFoldersResult {
77
83
  * Takes `listPublicFiles` as a parameter and hands remembered destinations
78
84
  * back through a callback, so it imports no app context and no storage API.
79
85
  */
80
- export declare const usePublishFolders: ({ listPublicFiles, rememberedFolderKeys, onRememberedFolderKeysChange, }: UsePublishFoldersParams) => UsePublishFoldersResult;
86
+ export declare const usePublishFolders: ({ listPublicFiles, rememberedFolderKeys, onRememberedFolderKeysChange, canPublishTo, }: UsePublishFoldersParams) => UsePublishFoldersResult;
81
87
  //# sourceMappingURL=usePublishFolders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePublishFolders.d.ts","sourceRoot":"","sources":["../../../src/catalog/usePublishFolders/usePublishFolders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAgBrC,gHAAgH;AAChH,eAAO,MAAM,2BAA2B,GAAI,YAAY,MAAM,EAAE,KAAG,OAClB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,YAAY,OAAO,EACnB,WAAW,MAAM,KAChB,MAAM,EAAE,GAAG,SAUb,CAAC;AAyBF,gDAAgD;AAChD,MAAM,WAAW,uBAAuB;IACtC,sEAAsE;IACtE,eAAe,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9E;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC/D;AAED,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,uDAAuD;IACvD,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,iEAAiE;IACjE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,gDAAgD;IAChD,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,0EAA0E;IAC1E,qBAAqB,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACpD;;;;;;;;;;OAUG;IACH,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E;;;;OAIG;IACH,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACtD,2EAA2E;IAC3E,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB,GAAI,0EAI/B,uBAAuB,KAAG,uBAsH5B,CAAC"}
1
+ {"version":3,"file":"usePublishFolders.d.ts","sourceRoot":"","sources":["../../../src/catalog/usePublishFolders/usePublishFolders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAgBrC,gHAAgH;AAChH,eAAO,MAAM,2BAA2B,GAAI,YAAY,MAAM,EAAE,KAAG,OAClB,CAAC;AAElD;;;;GAIG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AACH,eAAO,MAAM,iBAAiB,GAAI,wFAK/B,uBAAuB,KAAG,uBAsH5B,CAAC"}
@@ -15,60 +15,60 @@ var c = "Production", l = 50, u = (e) => !e.includes(c), d = (e, t) => {
15
15
  children: t.has(o) ? f(t, o, a) : void 0
16
16
  };
17
17
  });
18
- }, p = ({ listPublicFiles: e, rememberedFolderKeys: c, onRememberedFolderKeysChange: l }) => {
19
- let [p, m] = i(() => /* @__PURE__ */ new Map()), [h, g] = i(() => /* @__PURE__ */ new Set()), [_, v] = i(() => /* @__PURE__ */ new Set()), [y, b] = i([]), x = r(() => {
18
+ }, p = ({ listPublicFiles: e, rememberedFolderKeys: c, onRememberedFolderKeysChange: l, canPublishTo: p }) => {
19
+ let [m, h] = i(() => /* @__PURE__ */ new Map()), [g, _] = i(() => /* @__PURE__ */ new Set()), [v, y] = i(() => /* @__PURE__ */ new Set()), [b, x] = i([]), S = r(() => {
20
20
  let e = /* @__PURE__ */ new Set();
21
- return h.forEach((t) => {
21
+ return g.forEach((t) => {
22
22
  let n = t ? `${t}/` : "";
23
- p.has(n) && e.add(t);
23
+ m.has(n) && e.add(t);
24
24
  }), e;
25
- }, [h, p]), S = t(async (t) => {
26
- v((e) => new Set(e).add(t));
25
+ }, [g, m]), C = t(async (t) => {
26
+ y((e) => new Set(e).add(t));
27
27
  try {
28
28
  let { items: n } = await e({ path: t || void 0 });
29
- m((e) => new Map(e).set(t, n));
29
+ h((e) => new Map(e).set(t, n));
30
30
  } finally {
31
- v((e) => {
31
+ y((e) => {
32
32
  let n = new Set(e);
33
33
  return n.delete(t), n;
34
34
  });
35
35
  }
36
36
  }, [e]);
37
37
  n(() => {
38
- S("");
38
+ C("");
39
39
  }, []);
40
- let C = t((e) => {
41
- g(e), e.forEach((e) => {
40
+ let w = t((e) => {
41
+ _(e), e.forEach((e) => {
42
42
  let t = `${e}/`;
43
- !p.has(t) && !_.has(t) && S(t);
43
+ !m.has(t) && !v.has(t) && C(t);
44
44
  });
45
45
  }, [
46
- p,
47
- _,
48
- S
49
- ]), w = t((e, t) => {
46
+ m,
47
+ v,
48
+ C
49
+ ]), T = t((e, t) => {
50
50
  let n = s([...e, t]);
51
- return b((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
52
- }, []), T = t((e) => {
51
+ return x((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
52
+ }, []), E = t((e) => {
53
53
  let t = d(c, s(e));
54
54
  t && l?.(t);
55
- }, [c, l]), E = u;
55
+ }, [c, l]), D = p ?? u;
56
56
  return {
57
57
  folderItems: r(() => {
58
58
  let e = Array.isArray(c) ? c.filter((e) => typeof e == "string") : [];
59
- return o(f(p, "", []), [...e.map(a), ...y.map(a)]);
59
+ return o(f(m, "", []), [...e.map(a), ...b.map(a)]);
60
60
  }, [
61
- p,
61
+ m,
62
62
  c,
63
- y
63
+ b
64
64
  ]),
65
- expandedPaths: h,
66
- loadedPaths: x,
67
- loadingPaths: r(() => new Set([..._].map((e) => e.replace(/\/$/, ""))), [_]),
68
- onExpandedPathsChange: C,
69
- onCreatePublishFolder: w,
70
- rememberPublishFolder: T,
71
- hasPublishWriteAccess: E
65
+ expandedPaths: g,
66
+ loadedPaths: S,
67
+ loadingPaths: r(() => new Set([...v].map((e) => e.replace(/\/$/, ""))), [v]),
68
+ onExpandedPathsChange: w,
69
+ onCreatePublishFolder: T,
70
+ rememberPublishFolder: E,
71
+ hasPublishWriteAccess: D
72
72
  };
73
73
  };
74
74
  //#endregion
@@ -1,7 +1,7 @@
1
1
  import { ResourceFoldersResponseDto } from '@epam/ai-dial-chat-api-client';
2
2
  import { PublishAccessRulesLabels, StandaloneSaveToFolderPanelProps } from '@epam/ai-dial-publish-panel';
3
3
  import { PublishApiClient } from '../create-publish-api';
4
- import { ResourceSaveVersionError, ResourceSaveAdapter, ResourceSaveChoice, ResourceSaveResult } from '../resource-save';
4
+ import { ResourceSaveVersionError, SaveDestinationRoot, ResourceSaveAdapter, ResourceSaveChoice, ResourceSaveResult } from '../resource-save';
5
5
  import { UsePublishFoldersResult } from '../usePublishFolders/usePublishFolders';
6
6
  /** Translated copy the Save flow puts into the panel's state; the panel's own labels stay with the host. */
7
7
  export interface UseResourceSavePanelLabels {
@@ -38,6 +38,10 @@ export interface UseResourceSavePanelParams {
38
38
  organizationFolders?: UsePublishFoldersResult;
39
39
  /** Publish operations used for an Organization destination. */
40
40
  publishClient: Pick<PublishApiClient, 'publishCatalogEntity' | 'getPublishRules'>;
41
+ /** Whether an Organization destination takes a direct write into an org unit (the user may write there); omit while the org-unit rule does not apply, which keeps every Organization destination on the publish path. */
42
+ canSaveDirectlyTo?: (folderPath: string[], root: SaveDestinationRoot) => boolean;
43
+ /** Reason a folder is unavailable as a destination in the given root, or `undefined` when usable; omit while the org-unit rule does not apply. A committed destination with a reason shows it and disables Save. */
44
+ getDisabledReason?: (folderPath: string[], root: SaveDestinationRoot) => string | undefined;
41
45
  /** Options offered in the access-rules editor's source picker. */
42
46
  ruleSourceOptions: string[];
43
47
  /** Translated copy. */
@@ -46,7 +50,7 @@ export interface UseResourceSavePanelParams {
46
50
  onSaved: (result: ResourceSaveResult, choice: ResourceSaveChoice) => void;
47
51
  }
48
52
  /** The {@link StandaloneSaveToFolderPanelProps} the Save flow owns; the host adds the open state, resource summary and labels. */
49
- export type ResourceSavePanelStateProps = Pick<StandaloneSaveToFolderPanelProps, 'onSubmit' | 'isSubmitDisabled' | 'isSubmitting' | 'submitError' | 'roots' | 'destination' | 'onDestinationChange' | 'onCreateFolder' | 'version' | 'accessRules' | 'onPendingDestinationChange' | 'foldersError' | 'onRetryFolders'>;
53
+ export type ResourceSavePanelStateProps = Pick<StandaloneSaveToFolderPanelProps, 'onSubmit' | 'isSubmitDisabled' | 'isSubmitting' | 'submitError' | 'roots' | 'destination' | 'onDestinationChange' | 'onCreateFolder' | 'getDisabledReason' | 'version' | 'accessRules' | 'onPendingDestinationChange' | 'foldersError' | 'onRetryFolders'>;
50
54
  /** Result of {@link useResourceSavePanel}. */
51
55
  export interface UseResourceSavePanelResult {
52
56
  /** Props to spread on `StandaloneSaveToFolderPanel`. */
@@ -60,5 +64,5 @@ export interface UseResourceSavePanelResult {
60
64
  * folder's access rules — and runs the choice through the resource's
61
65
  * adapter. Notifications stay with the host through `onSaved`.
62
66
  */
63
- export declare const useResourceSavePanel: ({ isOpen, adapter, resourceId, currentFolderPath, currentVersion, versionPattern, listPersonalFolders, organizationFolders, publishClient, ruleSourceOptions, labels, onSaved, }: UseResourceSavePanelParams) => UseResourceSavePanelResult;
67
+ export declare const useResourceSavePanel: ({ isOpen, adapter, resourceId, currentFolderPath, currentVersion, versionPattern, listPersonalFolders, organizationFolders, publishClient, canSaveDirectlyTo, getDisabledReason: getFolderDisabledReason, ruleSourceOptions, labels, onSaved, }: UseResourceSavePanelParams) => UseResourceSavePanelResult;
64
68
  //# sourceMappingURL=useResourceSavePanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResourceSavePanel.d.ts","sourceRoot":"","sources":["../../../src/catalog/useResourceSavePanel/useResourceSavePanel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAML,KAAK,wBAAwB,EAG7B,KAAK,gCAAgC,EACtC,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAGL,wBAAwB,EAGxB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAGtF,4GAA4G;AAC5G,MAAM,WAAW,0BAA0B;IACzC,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,gBAAgB,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE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8C;AAC9C,MAAM,WAAW,0BAA0B;IACzC,wDAAwD;IACxD,UAAU,EAAE,2BAA2B,CAAC;IACxC,4CAA4C;IAC5C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,kLAalC,0BAA0B,KAAG,0BAuR/B,CAAC"}
1
+ {"version":3,"file":"useResourceSavePanel.d.ts","sourceRoot":"","sources":["../../../src/catalog/useResourceSavePanel/useResourceSavePanel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAML,KAAK,wBAAwB,EAG7B,KAAK,gCAAgC,EACtC,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAGL,wBAAwB,EAExB,mBAAmB,EAEnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAGtF,4GAA4G;AAC5G,MAAM,WAAW,0BAA0B;IACzC,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,gBAAgB,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,+FAA+F;IAC/F,eAAe,EAAE,CAAC,KAAK,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9E,mDAAmD;IACnD,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC;AAED,mDAAmD;AACnD,MAAM,WAAW,0BAA0B;IACzC,wGAAwG;IACxG,MAAM,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,O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DAAwD;IACxD,UAAU,EAAE,2BAA2B,CAAC;IACxC,4CAA4C;IAC5C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,iPAelC,0BAA0B,KAAG,0BAuT/B,CAAC"}
@@ -1,23 +1,24 @@
1
1
  import { getApiErrorDetails as e } from "../../api-error/api-error.js";
2
2
  import { useResourceFolders as t } from "../useResourceFolders/useResourceFolders.js";
3
3
  import { ResourceSaveError as n } from "../resource-save-adapter.js";
4
- import { ResourceSaveVersionError as r, SaveDestinationRoot as i, createPublishSavedResource as ee, runResourceSave as te } from "../resource-save.js";
5
- import { useCallback as a, useEffect as ne, useMemo as o, useRef as re, useState as s } from "react";
6
- import { SaveVersionMode as c, toFolderPathKey as ie } from "@epam/ai-dial-publish-panel";
4
+ import { SaveDestinationRoot as r } from "../save-destination-root.js";
5
+ import { ResourceSaveVersionError as i, createPublishSavedResource as ee, runResourceSave as te, toSaveDestinationRoot as ne } from "../resource-save.js";
6
+ import { useCallback as a, useEffect as re, useMemo as o, useRef as ie, useState as s } from "react";
7
+ import { SaveVersionMode as c, toFolderPathKey as ae } from "@epam/ai-dial-publish-panel";
7
8
  //#region src/catalog/useResourceSavePanel/useResourceSavePanel.ts
8
- var l = ({ isOpen: l, adapter: u, resourceId: d, currentFolderPath: f, currentVersion: p, versionPattern: m, listPersonalFolders: ae, organizationFolders: h, publishClient: g, ruleSourceOptions: _, labels: v, onSaved: y }) => {
9
- let b = t({
10
- listFolders: ae,
9
+ var l = ({ isOpen: l, adapter: u, resourceId: d, currentFolderPath: f, currentVersion: p, versionPattern: oe, listPersonalFolders: se, organizationFolders: m, publishClient: h, canSaveDirectlyTo: g, getDisabledReason: _, ruleSourceOptions: v, labels: y, onSaved: b }) => {
10
+ let x = t({
11
+ listFolders: se,
11
12
  isEnabled: l
12
- }), { getPublishRules: x } = g, S = o(() => ee(g), [g]), C = o(() => ({
13
- rootKey: i.Personal,
13
+ }), { getPublishRules: S } = h, C = o(() => ee(h), [h]), w = o(() => ({
14
+ rootKey: r.Personal,
14
15
  path: f
15
- }), [f]), [w, T] = s(C), [E, D] = s(c.Keep), [O, oe] = s(""), [k, A] = s(!1), [j, M] = s(), [se, N] = s(!1), [ce, P] = s(), [F, I] = s([]), [L, R] = s(!1), [z, B] = s(!1), V = re(void 0), le = a((e) => {
16
- if (e?.rootKey !== i.Organization) return;
17
- let t = ie(e.path);
16
+ }), [f]), [T, E] = s(w), [D, O] = s(c.Keep), [k, ce] = s(""), [le, A] = s(!1), [j, M] = s(), [ue, N] = s(!1), [de, P] = s(), [F, I] = s([]), [L, R] = s(!1), [z, B] = s(!1), V = ie(void 0), H = a((e) => e.rootKey === r.Organization && u.saveIntoOrgUnit != null && g?.(e.path, r.Organization) === !0, [u.saveIntoOrgUnit, g]), fe = a((e) => {
17
+ if (e?.rootKey !== r.Organization || H(e)) return;
18
+ let t = ae(e.path);
18
19
  t !== V.current && (V.current = t, I([]), B(!1), R(!0), (async () => {
19
20
  try {
20
- let n = await x(e.path.join("/"));
21
+ let n = await S(e.path.join("/"));
21
22
  V.current === t && I(n);
22
23
  } catch {
23
24
  V.current === t && B(!0);
@@ -25,50 +26,54 @@ var l = ({ isOpen: l, adapter: u, resourceId: d, currentFolderPath: f, currentVe
25
26
  V.current === t && R(!1);
26
27
  }
27
28
  })());
28
- }, [x]);
29
- ne(() => {
30
- l && (V.current = void 0, I([]), R(!1), B(!1), T(C), D(c.Keep), oe(""), A(!1), M(void 0), P(void 0));
29
+ }, [S, H]);
30
+ re(() => {
31
+ l && (V.current = void 0, I([]), R(!1), B(!1), E(w), O(c.Keep), ce(""), A(!1), M(void 0), P(void 0));
31
32
  }, [l]);
32
- let H = u.isVersioned && E === c.New, U = O.trim(), W = o(() => {
33
- if (H) {
34
- if (!m.test(U)) return r.Invalid;
35
- if (U === p) return r.Unchanged;
36
- if (U === j) return r.Exists;
33
+ let U = u.isVersioned && D === c.New, W = k.trim(), G = o(() => {
34
+ if (U) {
35
+ if (!oe.test(W)) return i.Invalid;
36
+ if (W === p) return i.Unchanged;
37
+ if (W === j) return i.Exists;
37
38
  }
38
39
  }, [
39
- H,
40
- m,
41
40
  U,
41
+ oe,
42
+ W,
42
43
  p,
43
44
  j
44
- ]), G = w.rootKey === i.Organization && (L || z), K = a((e) => {
45
- oe(e), P(void 0);
46
- }, []), q = a(() => A(!0), []), J = h?.rememberPublishFolder, { saveError: Y } = v, X = a(async () => {
47
- if (A(!0), W || G) return;
45
+ ]), K = o(() => _ && ((e) => {
46
+ let t = ne(e.rootKey);
47
+ return t ? _(e.path, t) : void 0;
48
+ }), [_]), q = K?.(T), J = H(T), Y = T.rootKey === r.Organization && !J && (L || z), X = a((e) => {
49
+ ce(e), P(void 0);
50
+ }, []), pe = a(() => A(!0), []), me = m?.rememberPublishFolder, { saveError: he } = y, Z = a(async () => {
51
+ if (A(!0), G || Y || q) return;
48
52
  N(!0), P(void 0);
49
53
  let t = {
50
54
  resourceId: d,
51
55
  currentFolderPath: f,
52
56
  currentVersion: p,
53
- destination: w,
54
- versionMode: E,
55
- newVersion: U,
56
- rules: F
57
+ destination: T,
58
+ versionMode: D,
59
+ newVersion: W,
60
+ rules: F,
61
+ isDirectWrite: J
57
62
  };
58
63
  try {
59
- let e = await te(u, t, S);
60
- e.isPublished && J?.(w.path), y(e, t);
64
+ let e = await te(u, t, C);
65
+ e.isPublished && me?.(T.path), b(e, t);
61
66
  } catch (t) {
62
67
  if (t instanceof n) {
63
68
  P(t.message);
64
69
  return;
65
70
  }
66
71
  let { message: r, status: i } = await e(t);
67
- if (H && i === 409) {
68
- M(U);
72
+ if (U && i === 409) {
73
+ M(W);
69
74
  return;
70
75
  }
71
- P(r ?? Y);
76
+ P(r ?? he);
72
77
  } finally {
73
78
  N(!1);
74
79
  }
@@ -76,96 +81,101 @@ var l = ({ isOpen: l, adapter: u, resourceId: d, currentFolderPath: f, currentVe
76
81
  u,
77
82
  f,
78
83
  p,
79
- w,
80
- H,
81
- G,
82
- y,
83
- S,
84
+ T,
85
+ U,
84
86
  J,
87
+ Y,
88
+ q,
89
+ b,
90
+ C,
91
+ me,
85
92
  d,
86
93
  F,
87
- Y,
88
- U,
89
- E,
90
- W
91
- ]), ue = a(() => void X(), [X]), { personalRoot: Z, organizationRoot: Q } = v, de = o(() => {
94
+ he,
95
+ W,
96
+ D,
97
+ G
98
+ ]), ge = a(() => void Z(), [Z]), { personalRoot: _e, organizationRoot: Q } = y, ve = o(() => {
92
99
  let e = {
93
- key: i.Personal,
94
- label: Z,
95
- items: b.folderItems,
96
- expandedPaths: b.expandedPaths,
97
- onExpandedPathsChange: b.onExpandedPathsChange,
98
- loadingPaths: b.loadingPaths
100
+ key: r.Personal,
101
+ label: _e,
102
+ items: x.folderItems,
103
+ expandedPaths: x.expandedPaths,
104
+ onExpandedPathsChange: x.onExpandedPathsChange,
105
+ loadingPaths: x.loadingPaths
99
106
  };
100
- return h ? [e, {
101
- key: i.Organization,
107
+ return m ? [e, {
108
+ key: r.Organization,
102
109
  label: Q,
103
- items: h.folderItems,
104
- expandedPaths: h.expandedPaths,
105
- onExpandedPathsChange: h.onExpandedPathsChange,
106
- loadingPaths: h.loadingPaths,
110
+ items: m.folderItems,
111
+ expandedPaths: m.expandedPaths,
112
+ onExpandedPathsChange: m.onExpandedPathsChange,
113
+ loadingPaths: m.loadingPaths,
107
114
  hasAccessRules: !0
108
115
  }] : [e];
109
116
  }, [
110
- h,
117
+ m,
111
118
  Q,
112
- b.expandedPaths,
113
- b.folderItems,
114
- b.loadingPaths,
115
- b.onExpandedPathsChange,
116
- Z
117
- ]), { onCreateFolder: $ } = b, fe = h?.onCreatePublishFolder, pe = a(async (e, t, n) => {
118
- e === i.Organization ? await fe?.(t, n) : await $(t, n);
119
- }, [$, fe]), { getVersionError: me } = v, he = o(() => u.isVersioned && p != null ? {
120
- versionMode: E,
121
- onVersionModeChange: D,
119
+ x.expandedPaths,
120
+ x.folderItems,
121
+ x.loadingPaths,
122
+ x.onExpandedPathsChange,
123
+ _e
124
+ ]), { onCreateFolder: ye } = x, be = m?.onCreatePublishFolder, xe = a(async (e, t, n) => {
125
+ e === r.Organization ? await be?.(t, n) : await ye(t, n);
126
+ }, [ye, be]), { getVersionError: Se } = y, Ce = o(() => u.isVersioned && p != null ? {
127
+ versionMode: D,
128
+ onVersionModeChange: O,
122
129
  currentVersion: p,
123
- newVersion: O,
124
- onNewVersionChange: K,
125
- onNewVersionBlur: q,
126
- newVersionError: k && W ? me(W, U) : void 0
130
+ newVersion: k,
131
+ onNewVersionChange: X,
132
+ onNewVersionBlur: pe,
133
+ newVersionError: le && G ? Se(G, W) : void 0
127
134
  } : void 0, [
128
135
  u.isVersioned,
129
136
  p,
130
- me,
137
+ Se,
138
+ le,
139
+ pe,
131
140
  k,
132
- q,
133
- O,
134
- K,
135
- U,
141
+ X,
136
142
  W,
137
- E
138
- ]), { accessRules: ge } = v, _e = o(() => ({
143
+ G,
144
+ D
145
+ ]), { accessRules: $ } = y, we = o(() => ({
139
146
  rules: F,
140
147
  onRulesChange: I,
141
- sourceOptions: _,
148
+ sourceOptions: v,
142
149
  isLoading: L,
143
150
  hasLoadError: z,
144
- labels: ge
151
+ labels: $,
152
+ isHiddenFor: H
145
153
  }), [
146
- ge,
154
+ $,
147
155
  z,
156
+ H,
148
157
  L,
149
- _,
158
+ v,
150
159
  F
151
160
  ]);
152
161
  return {
153
162
  panelProps: {
154
- onSubmit: ue,
155
- isSubmitDisabled: H && !!W || G,
156
- isSubmitting: se,
157
- submitError: ce,
158
- roots: de,
159
- destination: w,
160
- onDestinationChange: T,
161
- onCreateFolder: pe,
162
- version: he,
163
- accessRules: _e,
164
- onPendingDestinationChange: le,
165
- foldersError: b.hasError ? v.foldersLoadError : void 0,
166
- onRetryFolders: b.retry
163
+ onSubmit: ge,
164
+ isSubmitDisabled: U && !!G || Y || q != null,
165
+ isSubmitting: ue,
166
+ submitError: de,
167
+ roots: ve,
168
+ destination: T,
169
+ onDestinationChange: E,
170
+ onCreateFolder: xe,
171
+ getDisabledReason: K,
172
+ version: Ce,
173
+ accessRules: we,
174
+ onPendingDestinationChange: fe,
175
+ foldersError: x.hasError ? y.foldersLoadError : void 0,
176
+ onRetryFolders: x.retry
167
177
  },
168
- submit: X
178
+ submit: Z
169
179
  };
170
180
  };
171
181
  //#endregion
@@ -0,0 +1,38 @@
1
+ import { VersionHistoryRow } from '@epam/ai-dial-publish-panel';
2
+ import { PublishApiClient } from '../create-publish-api';
3
+ import { CatalogPublishEntityType } from '../publish';
4
+ import { VersionHistoryFormatters, VersionHistoryListingItem } from '../version-history';
5
+ /** Parameters of {@link useVersionHistory}. */
6
+ export interface UseVersionHistoryParams {
7
+ /** Items of the already-loaded deployments or toolsets listing. */
8
+ items: readonly VersionHistoryListingItem[];
9
+ /** Id of the resource being edited or published. */
10
+ resourceId: string;
11
+ /** Publish API entity type of the resource. */
12
+ entityType: CatalogPublishEntityType;
13
+ /** Whether the panel showing the history is open; statuses load only while it is. */
14
+ isEnabled: boolean;
15
+ /** Configured client that reads the version statuses. */
16
+ client: Pick<PublishApiClient, 'getCatalogVersionStatuses'>;
17
+ /** Host text and date formatting; keep it referentially stable. */
18
+ formatters: VersionHistoryFormatters;
19
+ }
20
+ /** Result of {@link useVersionHistory}. */
21
+ export interface UseVersionHistoryResult {
22
+ /** The other saved versions of the resource, newest first; statuses fill in once loaded. */
23
+ rows: VersionHistoryRow[];
24
+ /** Whether the listing holds another version the section can show; the host renders no section when it is `false`. */
25
+ hasVersions: boolean;
26
+ /** Whether the statuses are being loaded. */
27
+ isLoading: boolean;
28
+ /** Whether the last statuses request failed. */
29
+ hasError: boolean;
30
+ /** Reloads the statuses. */
31
+ onRetry: () => void;
32
+ }
33
+ /**
34
+ * Groups the listing by `versionGroupId`, builds the Versions history rows of the other versions and loads their publication statuses in the background while the panel is open.
35
+ * @param params - listing items, edited resource, open state, client and formatters
36
+ */
37
+ export declare const useVersionHistory: ({ items, resourceId, entityType, isEnabled, client, formatters, }: UseVersionHistoryParams) => UseVersionHistoryResult;
38
+ //# sourceMappingURL=useVersionHistory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVersionHistory.d.ts","sourceRoot":"","sources":["../../../src/catalog/useVersionHistory/useVersionHistory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,oBAAoB,CAAC;AAE5B,+CAA+C;AAC/C,MAAM,WAAW,uBAAuB;IACtC,mEAAmE;IACnE,KAAK,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAC5C,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,UAAU,EAAE,wBAAwB,CAAC;IACrC,qFAAqF;IACrF,SAAS,EAAE,OAAO,CAAC;IACnB,yDAAyD;IACzD,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,2BAA2B,CAAC,CAAC;IAC5D,mEAAmE;IACnE,UAAU,EAAE,wBAAwB,CAAC;CACtC;AAED,2CAA2C;AAC3C,MAAM,WAAW,uBAAuB;IACtC,4FAA4F;IAC5F,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,sHAAsH;IACtH,WAAW,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;IACnB,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;IAClB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAOD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,mEAO/B,uBAAuB,KAAG,uBA2D5B,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { safeDecodeURIComponent as e } from "../../shared/string-utils.js";
2
+ import { buildVersionHistoryRows as t, selectOtherVersions as n } from "../version-history.js";
3
+ import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
4
+ //#region src/catalog/useVersionHistory/useVersionHistory.ts
5
+ var s = ({ items: s, resourceId: c, entityType: l, isEnabled: u, client: d, formatters: f }) => {
6
+ let p = a(() => n(s, c), [s, c]), m = p.length > 0, [h, g] = o(0), [_, v] = o(), [y, b] = o(), [x, S] = o(u);
7
+ x !== u && (S(u), u || (v(void 0), b(void 0)));
8
+ let C = `${l}:${c}:${h}`, w = u && m;
9
+ i(() => {
10
+ if (!w) return;
11
+ let t = !1;
12
+ return (async () => {
13
+ try {
14
+ let n = await d.getCatalogVersionStatuses(l, c);
15
+ if (t) return;
16
+ v({
17
+ key: C,
18
+ statuses: new Map(n.map((t) => [e(t.id), t]))
19
+ }), b(void 0);
20
+ } catch {
21
+ t || b(C);
22
+ }
23
+ })(), () => {
24
+ t = !0;
25
+ };
26
+ }, [
27
+ w,
28
+ d,
29
+ l,
30
+ c,
31
+ C
32
+ ]);
33
+ let T = a(() => t(p, _?.statuses, f), [
34
+ p,
35
+ _,
36
+ f
37
+ ]), E = w && y === C;
38
+ return {
39
+ rows: T,
40
+ hasVersions: m,
41
+ isLoading: w && !E && _?.key !== C,
42
+ hasError: E,
43
+ onRetry: r(() => {
44
+ b(void 0), g((e) => e + 1);
45
+ }, [])
46
+ };
47
+ };
48
+ //#endregion
49
+ export { s as useVersionHistory };