@epam/ai-dial-chat-hooks 1.4.0-dev.96 → 1.4.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-error/map-api-error.d.ts +10 -0
- package/api-error/map-api-error.d.ts.map +1 -0
- package/api-error/map-api-error.js +11 -0
- package/catalog/create-publish-api.d.ts +14 -10
- package/catalog/create-publish-api.d.ts.map +1 -1
- package/catalog/create-publish-api.js +8 -9
- package/catalog/map-deployment-to-catalog-item.d.ts.map +1 -1
- package/catalog/map-deployment-to-catalog-item.js +1 -0
- package/catalog/publish-target-taken.d.ts +31 -0
- package/catalog/publish-target-taken.d.ts.map +1 -0
- package/catalog/publish-target-taken.js +14 -0
- package/catalog/resource-name-conflict.d.ts.map +1 -1
- package/catalog/resource-name-conflict.js +19 -22
- package/catalog/resource-save.d.ts +2 -4
- package/catalog/resource-save.d.ts.map +1 -1
- package/catalog/resource-save.js +38 -32
- package/catalog/use-publish-target-guard.d.ts +45 -0
- package/catalog/use-publish-target-guard.d.ts.map +1 -0
- package/catalog/use-publish-target-guard.js +18 -0
- package/catalog/usePublishFolders/usePublishFolders.d.ts +11 -3
- package/catalog/usePublishFolders/usePublishFolders.d.ts.map +1 -1
- package/catalog/usePublishFolders/usePublishFolders.js +41 -31
- package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts +27 -11
- package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts.map +1 -1
- package/catalog/useResourceSavePanel/useResourceSavePanel.js +163 -138
- package/catalog.js +51 -49
- package/conversation/conversation-list.d.ts +7 -1
- package/conversation/conversation-list.d.ts.map +1 -1
- package/conversation/conversation-list.js +11 -2
- package/conversation/conversation-transfer/zip-export.d.ts +1 -1
- package/conversation/conversation-transfer/zip-export.d.ts.map +1 -1
- package/conversation/conversation-transfer/zip-export.js +7 -8
- package/conversation/conversation-transfer/zip-import.d.ts.map +1 -1
- package/conversation/conversation-transfer/zip-import.js +8 -9
- package/conversation/useConversationExport/useConversationExport.d.ts.map +1 -1
- package/conversation/useConversationExport/useConversationExport.js +3 -1
- package/conversation.js +3 -3
- package/entry-points/catalog.d.ts +2 -0
- package/entry-points/catalog.d.ts.map +1 -1
- package/entry-points/scheduled-tasks.d.ts +1 -0
- package/entry-points/scheduled-tasks.d.ts.map +1 -1
- package/entry-points/skill-editor.d.ts +1 -0
- package/entry-points/skill-editor.d.ts.map +1 -1
- package/entry-points/utils.d.ts +1 -0
- package/entry-points/utils.d.ts.map +1 -1
- package/file-manager.js +33 -33
- package/files/dial-file-manager.types.d.ts +4 -2
- package/files/dial-file-manager.types.d.ts.map +1 -1
- package/files/dial-file.d.ts +6 -0
- package/files/dial-file.d.ts.map +1 -1
- package/files/dial-file.js +17 -12
- package/files/useDialFileListing/useDialFileListing.d.ts +9 -1
- package/files/useDialFileListing/useDialFileListing.d.ts.map +1 -1
- package/files/useDialFileListing/useDialFileListing.js +205 -183
- package/files/useDialFileManager/useDialFileManager.d.ts +1 -1
- package/files/useDialFileManager/useDialFileManager.d.ts.map +1 -1
- package/files/useDialFileManager/useDialFileManager.js +114 -113
- package/files/useDialFileMutations/useDialFileMutations.d.ts +2 -1
- package/files/useDialFileMutations/useDialFileMutations.d.ts.map +1 -1
- package/files/useDialFileMutations/useDialFileMutations.js +5 -5
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -1
- package/index.js +267 -262
- package/org-units/org-unit-guards.d.ts +95 -1
- package/org-units/org-unit-guards.d.ts.map +1 -1
- package/org-units/org-unit-guards.js +51 -16
- package/org-units/useOrgUnits/useOrgUnits.d.ts +12 -4
- package/org-units/useOrgUnits/useOrgUnits.d.ts.map +1 -1
- package/org-units/useOrgUnits/useOrgUnits.js +44 -35
- package/package.json +20 -20
- package/project/project-conversation-data-source.js +4 -4
- package/project/project-refresh.d.ts +2 -0
- package/project/project-refresh.d.ts.map +1 -1
- package/project/project-refresh.js +1 -1
- package/project/use-project-actions.d.ts +3 -1
- package/project/use-project-actions.d.ts.map +1 -1
- package/project/use-project-actions.js +39 -38
- package/project/use-project.d.ts +3 -1
- package/project/use-project.d.ts.map +1 -1
- package/project/use-project.js +57 -44
- package/scheduled-task/scheduled-task-display.d.ts +51 -4
- package/scheduled-task/scheduled-task-display.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-display.js +53 -46
- package/scheduled-task/scheduled-task-next-occurrence.d.ts +2 -0
- package/scheduled-task/scheduled-task-next-occurrence.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-next-occurrence.js +2 -2
- package/scheduled-task/scheduled-task-time-format.d.ts +36 -0
- package/scheduled-task/scheduled-task-time-format.d.ts.map +1 -0
- package/scheduled-task/scheduled-task-time-format.js +34 -0
- package/scheduled-task/scheduled-task-trigger.d.ts.map +1 -1
- package/scheduled-task/scheduled-task-trigger.js +13 -14
- package/scheduled-tasks.js +14 -13
- package/skill/skill-archive.d.ts.map +1 -1
- package/skill/skill-archive.js +6 -7
- package/skill/skill-file-batch-validation.d.ts +6 -0
- package/skill/skill-file-batch-validation.d.ts.map +1 -1
- package/skill/skill-file-batch-validation.js +39 -37
- package/skill/skill-types.d.ts +0 -6
- package/skill/skill-types.d.ts.map +1 -1
- package/skill/skill-types.js +7 -8
- package/skill/skill.d.ts +2 -9
- package/skill/skill.d.ts.map +1 -1
- package/skill/skill.js +33 -34
- package/skill/types/skill-editor-submit.d.ts +8 -0
- package/skill/types/skill-editor-submit.d.ts.map +1 -0
- package/skill/types/skill-editor-submit.js +6 -0
- package/skill/useSkillEditorLoad.js +1 -1
- package/skill/useSkillEditorSubmit.d.ts +2 -3
- package/skill/useSkillEditorSubmit.d.ts.map +1 -1
- package/skill/useSkillEditorSubmit.js +103 -102
- package/skill/useSkillFileActions.d.ts +7 -1
- package/skill/useSkillFileActions.d.ts.map +1 -1
- package/skill/useSkillFileActions.js +55 -49
- package/skill-editor.js +7 -6
- package/utils.js +28 -27
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `operation` with a rejection replaced by the error `mapError` builds
|
|
3
|
+
* for it. A rejection `mapError` has no replacement for is rethrown unchanged.
|
|
4
|
+
* Reading an API error body is asynchronous, so the mapping lives here rather
|
|
5
|
+
* than in a synchronous predicate.
|
|
6
|
+
* @param operation - the request whose rejection may need a typed error
|
|
7
|
+
* @param mapError - resolves the replacement error, or `undefined` to keep the original
|
|
8
|
+
*/
|
|
9
|
+
export declare const withApiErrorMapping: <Args extends unknown[], Result>(operation: (...args: Args) => Promise<Result>, mapError: (error: unknown) => Promise<unknown>) => (...args: Args) => Promise<Result>;
|
|
10
|
+
//# sourceMappingURL=map-api-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-api-error.d.ts","sourceRoot":"","sources":["../../src/api-error/map-api-error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC7B,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EAC7B,WAAW,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,EAC7C,UAAU,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,MAEzC,GAAG,MAAM,IAAI,KAAG,OAAO,CAAC,MAAM,CAQpC,CAAC"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { CopyCatalogEntityToOrgUnitDto, PublishApi, PublishCatalogEntityDto, PublishHistoryEntryDto, PublishResultDto,
|
|
2
|
-
import { PublicationRule } from '@epam/ai-dial-publish-panel';
|
|
1
|
+
import { ApplicationValuesDependenciesRequestDto, CopyCatalogEntityToOrgUnitDto, PublishApi, PublishCatalogEntityDto, PublishHistoryEntryDto, PublishResultDto, PublishTargetCheckDto, ResourceIdResponseDto, ResourceDependenciesResultDto, UnpublishAccessDto, UnpublishCatalogEntityDto, UnpublishResultDto, VersionStatusEntryDto } from '@epam/ai-dial-chat-api-client';
|
|
3
2
|
import { CatalogPublishEntityType } from './publish';
|
|
4
|
-
/**
|
|
5
|
-
* Converts a `PublicationRule` (publish-panel lib model) to the generated
|
|
6
|
-
* client's `PublishRuleDto` shape. The two differ only in how the comparison
|
|
7
|
-
* function is typed, so the value passes through unchanged.
|
|
8
|
-
*/
|
|
9
|
-
export declare const toPublishRuleDto: (rule: PublicationRule) => PublishRuleDto;
|
|
10
3
|
/** The DIAL publish API surface produced by {@link createPublishApiClient}. */
|
|
11
4
|
export interface PublishApiClient {
|
|
12
5
|
/** Submits a publication request for one catalog entity into `folderPath`. */
|
|
@@ -31,12 +24,23 @@ export interface PublishApiClient {
|
|
|
31
24
|
* resolve them.
|
|
32
25
|
*/
|
|
33
26
|
getCatalogPublishDependencies: (entityType: CatalogPublishEntityType, entityId: string) => Promise<ResourceDependenciesResultDto>;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the private dependencies of application property values that are not
|
|
29
|
+
* saved yet, from the values alone; the backend reads no application. Advisory
|
|
30
|
+
* like {@link PublishApiClient.getCatalogPublishDependencies}.
|
|
31
|
+
*/
|
|
32
|
+
getApplicationValuesPublishDependencies: (body: ApplicationValuesDependenciesRequestDto) => Promise<ResourceDependenciesResultDto>;
|
|
34
33
|
/** Reads whether the caller may request removal of one catalog entity. */
|
|
35
34
|
getCatalogUnpublishAccess: (entityType: CatalogPublishEntityType, entityId: string) => Promise<UnpublishAccessDto>;
|
|
36
35
|
/** Reads the publication status of every saved version of one application or toolset. */
|
|
37
36
|
getCatalogVersionStatuses: (entityType: CatalogPublishEntityType, entityId: string) => Promise<VersionStatusEntryDto[]>;
|
|
38
|
-
/**
|
|
39
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Reads whether the published copy of one catalog entity would land on a path
|
|
39
|
+
* that is already taken, for `folderPath` (plain, `/`-joined) and `version`.
|
|
40
|
+
* Advisory: a copy hidden from the caller, or still pending approval, is not
|
|
41
|
+
* found, and the publish request still answers `409` for it.
|
|
42
|
+
*/
|
|
43
|
+
checkPublishTarget: (entityType: CatalogPublishEntityType, entityId: string, folderPath: string, version?: string) => Promise<PublishTargetCheckDto>;
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Wraps the generated `PublishApi` in the positional-argument surface the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-publish-api.d.ts","sourceRoot":"","sources":["../../src/catalog/create-publish-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"create-publish-api.d.ts","sourceRoot":"","sources":["../../src/catalog/create-publish-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,6BAA6B,EAC7B,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,oBAAoB,EAAE,CACpB,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,uBAAuB,KAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/B;;;;OAIG;IACH,0BAA0B,EAAE,CAC1B,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,6BAA6B,KAChC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpC;;;;OAIG;IACH,sBAAsB,EAAE,CACtB,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,yBAAyB,KAC5B,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjC,oEAAoE;IACpE,wBAAwB,EAAE,CACxB,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC;IACvC;;;;OAIG;IACH,6BAA6B,EAAE,CAC7B,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C;;;;OAIG;IACH,uCAAuC,EAAE,CACvC,IAAI,EAAE,uCAAuC,KAC1C,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,yBAAyB,EAAE,CACzB,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjC,yFAAyF;IACzF,yBAAyB,EAAE,CACzB,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACtC;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,KACb,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,YAAY,UAAU,KACrB,gBAsCD,CAAC"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
//#region src/catalog/create-publish-api.ts
|
|
2
2
|
var e = (e) => ({
|
|
3
|
-
source: e.source,
|
|
4
|
-
targets: e.targets,
|
|
5
|
-
function: e.function
|
|
6
|
-
}), t = (e) => ({
|
|
7
3
|
publishCatalogEntity: (t, n, r) => e.publishCatalogEntity({
|
|
8
4
|
entityType: t,
|
|
9
5
|
entityId: n,
|
|
@@ -27,6 +23,7 @@ var e = (e) => ({
|
|
|
27
23
|
entityType: t,
|
|
28
24
|
entityId: n
|
|
29
25
|
}),
|
|
26
|
+
getApplicationValuesPublishDependencies: (t) => e.getApplicationValuesPublishDependencies({ applicationValuesDependenciesRequestDto: t }),
|
|
30
27
|
getCatalogUnpublishAccess: (t, n) => e.getCatalogUnpublishAccess({
|
|
31
28
|
entityType: t,
|
|
32
29
|
entityId: n
|
|
@@ -35,10 +32,12 @@ var e = (e) => ({
|
|
|
35
32
|
entityType: t,
|
|
36
33
|
entityId: n
|
|
37
34
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
checkPublishTarget: (t, n, r, i) => e.getCatalogPublishTarget({
|
|
36
|
+
entityType: t,
|
|
37
|
+
entityId: n,
|
|
38
|
+
folderPath: r,
|
|
39
|
+
version: i
|
|
40
|
+
})
|
|
42
41
|
});
|
|
43
42
|
//#endregion
|
|
44
|
-
export {
|
|
43
|
+
export { e as createPublishApiClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-deployment-to-catalog-item.d.ts","sourceRoot":"","sources":["../../src/catalog/map-deployment-to-catalog-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,EACf,MAAM,+BAA+B,CAAC;AASvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,iCAAiC,CAAC;AAiBzC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,+BAA+B,GAC1C,WAAW,MAAM,EACjB,cAAc,0BAA0B,GAAG,SAAS,EACpD,SAAS,OAAO,KACf,sBAAsB,GAAG,SA4B3B,CAAC;AAiBF,yFAAyF;AACzF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,yGAAyG;AACzG,eAAO,MAAM,uBAAuB,GAClC,YAAY,IAAI,CACd,iBAAiB,EACjB,MAAM,GAAG,cAAc,GAAG,mBAAmB,CAC9C,GACC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,EAC1C,QAAQ,sBAAsB,KAC7B,MAAM,EA4BR,CAAC;AAmCF,yDAAyD;AACzD,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,YAAY,EAAE,sBAAsB,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uFAAuF;IACvF,YAAY,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;IACpE,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AA+BD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,YAAY,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,KAChD,OACsE,CAAC;AAE1E,+EAA+E;AAC/E,eAAO,MAAM,0BAA0B,GACrC,YAAY,iBAAiB,EAC7B,+KAWG,iCAAiC,KACnC,
|
|
1
|
+
{"version":3,"file":"map-deployment-to-catalog-item.d.ts","sourceRoot":"","sources":["../../src/catalog/map-deployment-to-catalog-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,EACf,MAAM,+BAA+B,CAAC;AASvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,iCAAiC,CAAC;AAiBzC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,+BAA+B,GAC1C,WAAW,MAAM,EACjB,cAAc,0BAA0B,GAAG,SAAS,EACpD,SAAS,OAAO,KACf,sBAAsB,GAAG,SA4B3B,CAAC;AAiBF,yFAAyF;AACzF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,yGAAyG;AACzG,eAAO,MAAM,uBAAuB,GAClC,YAAY,IAAI,CACd,iBAAiB,EACjB,MAAM,GAAG,cAAc,GAAG,mBAAmB,CAC9C,GACC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,EAC1C,QAAQ,sBAAsB,KAC7B,MAAM,EA4BR,CAAC;AAmCF,yDAAyD;AACzD,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,YAAY,EAAE,sBAAsB,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uFAAuF;IACvF,YAAY,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;IACpE,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AA+BD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,YAAY,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,KAChD,OACsE,CAAC;AAE1E,+EAA+E;AAC/E,eAAO,MAAM,0BAA0B,GACrC,YAAY,iBAAiB,EAC7B,+KAWG,iCAAiC,KACnC,WAiDF,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,8BAA8B;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,uFAAuF;IACvF,YAAY,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,aAAa,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;CACrE;AAED,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,GAClC,SAAS,cAAc,EACvB,sFAOG,8BAA8B,KAChC,WA6CF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ApiErrorDetails } from '../api-error/api-error';
|
|
2
|
+
/**
|
|
3
|
+
* A publish rejected because the published path already holds another resource
|
|
4
|
+
* (`409` with code `target-exists`). Thrown by {@link wrapPublishTargetTaken} so
|
|
5
|
+
* a synchronous predicate can recognise it.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PublishTargetTakenError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* @param cause - the rejection of the generated-client call
|
|
10
|
+
*/
|
|
11
|
+
constructor(cause: unknown);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether `error` is the publish endpoint's `409` for a taken target.
|
|
15
|
+
* @param error - the rejection of a generated-client call
|
|
16
|
+
*/
|
|
17
|
+
export declare const isPublishTargetTakenResponse: (error: unknown) => Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the details of a failed publish describe the endpoint's `409` for an
|
|
20
|
+
* application that is already being published (code `publish-in-progress`).
|
|
21
|
+
* @param details - the result of `getApiErrorDetails` for the rejection
|
|
22
|
+
*/
|
|
23
|
+
export declare const isPublishInProgressDetails: ({ status, code, }: Pick<ApiErrorDetails, "status" | "code">) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns `publish` rejecting a taken-target `409` as a {@link PublishTargetTakenError}
|
|
26
|
+
* and every other failure unchanged. Reading the error body is asynchronous, so the
|
|
27
|
+
* conversion happens here, before `usePublishFlow`'s synchronous predicate sees it.
|
|
28
|
+
* @param publish - the host's publish request
|
|
29
|
+
*/
|
|
30
|
+
export declare const wrapPublishTargetTaken: <Args extends unknown[], Result>(publish: (...args: Args) => Promise<Result>) => (...args: Args) => Promise<Result>;
|
|
31
|
+
//# sourceMappingURL=publish-target-taken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-target-taken.d.ts","sourceRoot":"","sources":["../../src/catalog/publish-target-taken.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD;;OAEG;gBACS,KAAK,EAAE,OAAO;CAI3B;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,OAAO,KACb,OAAO,CAAC,OAAO,CAGjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,mBAGxC,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,KAAG,OACoB,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACnE,SAAS,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,uCAM1C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getApiErrorDetails as e } from "../api-error/api-error.js";
|
|
2
|
+
import { withApiErrorMapping as t } from "../api-error/map-api-error.js";
|
|
3
|
+
import { PublishConflictCode as n } from "@epam/ai-dial-chat-api-client";
|
|
4
|
+
//#region src/catalog/publish-target-taken.ts
|
|
5
|
+
var r = class extends Error {
|
|
6
|
+
constructor(e) {
|
|
7
|
+
super("The published path is already taken", { cause: e }), this.name = "PublishTargetTakenError";
|
|
8
|
+
}
|
|
9
|
+
}, i = async (t) => {
|
|
10
|
+
let { status: r, code: i } = await e(t);
|
|
11
|
+
return r === 409 && i === n.TargetExists;
|
|
12
|
+
}, a = ({ status: e, code: t }) => e === 409 && t === n.PublishInProgress, o = (e) => t(e, async (e) => await i(e) ? new r(e) : void 0);
|
|
13
|
+
//#endregion
|
|
14
|
+
export { r as PublishTargetTakenError, a as isPublishInProgressDetails, i as isPublishTargetTakenResponse, o as wrapPublishTargetTaken };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-name-conflict.d.ts","sourceRoot":"","sources":["../../src/catalog/resource-name-conflict.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource-name-conflict.d.ts","sourceRoot":"","sources":["../../src/catalog/resource-name-conflict.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAEjC,4FAA4F;AAC5F,oBAAY,wBAAwB;IAClC,wCAAwC;IACxC,KAAK,UAAU;IACf,0BAA0B;IAC1B,OAAO,YAAY;CACpB;AAED,mFAAmF;AACnF,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAC/C,wBAAwB,EACxB,MAAM,CACP,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GACtC,OAAO,OAAO,KACb,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAI9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,GAC3C,SAAS,mBAAmB,EAC5B,UAAU,4BAA4B,KACrC,mBAyBF,CAAC"}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import { getApiErrorDetails as e } from "../api-error/api-error.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { withApiErrorMapping as t } from "../api-error/map-api-error.js";
|
|
3
|
+
import { ResourceSaveError as n, isResourceCreateAdapter as r } from "./resource-save-adapter.js";
|
|
4
|
+
import { ResourceNameConflictCode as i } from "@epam/ai-dial-chat-api-client";
|
|
4
5
|
//#region src/catalog/resource-name-conflict.ts
|
|
5
|
-
var
|
|
6
|
+
var a = /* @__PURE__ */ function(e) {
|
|
6
7
|
return e.Agent = "agent", e.Toolset = "toolset", e;
|
|
7
|
-
}({}),
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
},
|
|
8
|
+
}({}), o = {
|
|
9
|
+
[i.NameTakenAgent]: "agent",
|
|
10
|
+
[i.NameTakenToolset]: "toolset"
|
|
11
|
+
}, s = async (t) => {
|
|
11
12
|
let { status: n, code: r } = await e(t);
|
|
12
|
-
if (n === 409 && r != null) return
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw n == null ? e : new t(r[n]);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
return n(e) ? {
|
|
13
|
+
if (n === 409 && r != null) return o[r];
|
|
14
|
+
}, c = (e, i) => {
|
|
15
|
+
let a = (e) => t(e, async (e) => {
|
|
16
|
+
let t = await s(e);
|
|
17
|
+
return t == null ? void 0 : new n(i[t]);
|
|
18
|
+
});
|
|
19
|
+
return r(e) ? {
|
|
23
20
|
...e,
|
|
24
|
-
createIn:
|
|
21
|
+
createIn: a(e.createIn)
|
|
25
22
|
} : {
|
|
26
23
|
...e,
|
|
27
|
-
saveInPlace:
|
|
28
|
-
...e.saveAsNewVersion && { saveAsNewVersion:
|
|
24
|
+
saveInPlace: a(e.saveInPlace),
|
|
25
|
+
...e.saveAsNewVersion && { saveAsNewVersion: a(e.saveAsNewVersion) }
|
|
29
26
|
};
|
|
30
27
|
};
|
|
31
28
|
//#endregion
|
|
32
|
-
export {
|
|
29
|
+
export { a as ResourceNameConflictKind, s as getResourceNameConflictKind, c as withResourceNameConflictMessages };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SaveVersionMode, FolderDestination
|
|
1
|
+
import { SaveVersionMode, FolderDestination } from '@epam/ai-dial-publish-panel';
|
|
2
2
|
import { PublishApiClient } from './create-publish-api';
|
|
3
3
|
import { CatalogPublishEntityType } from './publish';
|
|
4
4
|
import { ResourceSaveAdapter } from './resource-save-adapter';
|
|
@@ -45,13 +45,11 @@ export interface ResourceSaveChoice {
|
|
|
45
45
|
versionMode: SaveVersionMode;
|
|
46
46
|
/** The new version, used when `versionMode` is `New`. */
|
|
47
47
|
newVersion: string;
|
|
48
|
-
/** Access rules sent with the publish request for an Organization destination. */
|
|
49
|
-
rules?: PublicationRule[];
|
|
50
48
|
/** Whether the Organization destination takes a direct write (an org unit the user may write to) instead of a publish request. Defaults to `false`. */
|
|
51
49
|
isDirectWrite?: boolean;
|
|
52
50
|
}
|
|
53
51
|
/** Sends the publish request for a saved resource. */
|
|
54
|
-
export type PublishSavedResource = (entityType: CatalogPublishEntityType, id: string, folderPath: string[], version: string | undefined
|
|
52
|
+
export type PublishSavedResource = (entityType: CatalogPublishEntityType, id: string, folderPath: string[], version: string | undefined) => Promise<void>;
|
|
55
53
|
/** The result of a save whose first step succeeded. */
|
|
56
54
|
export interface ResourceSaveResult {
|
|
57
55
|
/** How the later steps ended. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-save.d.ts","sourceRoot":"","sources":["../../src/catalog/resource-save.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource-save.d.ts","sourceRoot":"","sources":["../../src/catalog/resource-save.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAEf,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,cAAc,yBAAyB,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,MAAM,KACd,mBAAmB,GAAG,SAC4C,CAAC;AAEtE,6DAA6D;AAC7D,oBAAY,mBAAmB;IAC7B,4BAA4B;IAC5B,KAAK,UAAU;IACf,4EAA4E;IAC5E,kBAAkB,uBAAuB;IACzC,yDAAyD;IACzD,qBAAqB,0BAA0B;IAC/C,+EAA+E;IAC/E,0BAA0B,+BAA+B;CAC1D;AAED,kEAAkE;AAClE,oBAAY,wBAAwB;IAClC,oDAAoD;IACpD,OAAO,YAAY;IACnB,gDAAgD;IAChD,SAAS,cAAc;IACvB,6DAA6D;IAC7D,MAAM,WAAW;CAClB;AAED,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,+EAA+E;IAC/E,WAAW,EAAE,eAAe,CAAC;IAC7B,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,uJAAuJ;IACvJ,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,sDAAsD;AACtD,MAAM,MAAM,oBAAoB,GAAG,CACjC,UAAU,EAAE,wBAAwB,EACpC,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,EAAE,EACpB,OAAO,EAAE,MAAM,GAAG,SAAS,KACxB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,SAAS,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,YAAY,EAAE,OAAO,CAAC;IACtB,uDAAuD;IACvD,WAAW,EAAE,OAAO,CAAC;IACrB,4GAA4G;IAC5G,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAiBD,sGAAsG;AACtG,eAAO,MAAM,0BAA0B,GAEnC,QAAQ,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,KACrD,oBAMF,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,mBAAmB,EAC5B,QAAQ,kBAAkB,EAC1B,SAAS,oBAAoB,KAC5B,OAAO,CAAC,kBAAkB,CA0F5B,CAAC"}
|
package/catalog/resource-save.js
CHANGED
|
@@ -1,61 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ResourceSaveError as
|
|
3
|
-
import { SaveDestinationRoot as
|
|
4
|
-
import {
|
|
1
|
+
import { getApiErrorDetails as e, getApiErrorStatus as t } from "../api-error/api-error.js";
|
|
2
|
+
import { ResourceSaveError as n, isResourceCreateAdapter as r } from "./resource-save-adapter.js";
|
|
3
|
+
import { SaveDestinationRoot as i } from "./save-destination-root.js";
|
|
4
|
+
import { OrgUnitCopyErrorCode as a } from "@epam/ai-dial-chat-api-client";
|
|
5
|
+
import { SaveVersionMode as o, toFolderPathKey as s } from "@epam/ai-dial-publish-panel";
|
|
5
6
|
//#region src/catalog/resource-save.ts
|
|
6
|
-
var
|
|
7
|
+
var c = (e) => Object.values(i).find((t) => t === e), l = /* @__PURE__ */ function(e) {
|
|
7
8
|
return e.Saved = "saved", e.SavedButMoveFailed = "savedButMoveFailed", e.SavedButPublishFailed = "savedButPublishFailed", e.SavedButOrgUnitWriteFailed = "savedButOrgUnitWriteFailed", e;
|
|
8
|
-
}({}),
|
|
9
|
+
}({}), u = /* @__PURE__ */ function(e) {
|
|
9
10
|
return e.Invalid = "invalid", e.Unchanged = "unchanged", e.Exists = "exists", e;
|
|
10
|
-
}({}),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
}({}), d = async (n) => {
|
|
12
|
+
if (t(n) !== 422) return !1;
|
|
13
|
+
let { code: r } = await e(n);
|
|
14
|
+
return r === a.FolderReferenceNeedsRequest;
|
|
15
|
+
}, f = (e, t) => s(e) === s(t), p = (e) => async (t, n, r, i) => {
|
|
16
|
+
await e.publishCatalogEntity(t, n, {
|
|
17
|
+
folderPath: r.join("/"),
|
|
18
|
+
...i ? { version: i } : {}
|
|
15
19
|
});
|
|
16
|
-
},
|
|
17
|
-
let
|
|
18
|
-
if (
|
|
19
|
-
else if (
|
|
20
|
+
}, m = async (e, t, n) => {
|
|
21
|
+
let a = e.isVersioned && t.versionMode === o.New, s = t.destination.rootKey === i.Organization, c = s && t.isDirectWrite === !0 && e.saveIntoOrgUnit != null, l = s ? t.currentFolderPath : t.destination.path, u, p = !1;
|
|
22
|
+
if (r(e)) ({id: u} = await e.createIn(l));
|
|
23
|
+
else if (a) {
|
|
20
24
|
if (!e.saveAsNewVersion) throw Error("This resource cannot be saved as a new version");
|
|
21
|
-
({id:
|
|
22
|
-
} else ({id:
|
|
23
|
-
let
|
|
25
|
+
({id: u} = await e.saveAsNewVersion(t.newVersion, l));
|
|
26
|
+
} else ({id: u} = await e.saveInPlace()), p = !s && !f(l, t.currentFolderPath);
|
|
27
|
+
let m = {
|
|
24
28
|
outcome: "saved",
|
|
25
|
-
savedId:
|
|
26
|
-
isCreated:
|
|
27
|
-
isNewVersion:
|
|
29
|
+
savedId: u,
|
|
30
|
+
isCreated: r(e),
|
|
31
|
+
isNewVersion: a,
|
|
28
32
|
isPublished: !1,
|
|
29
33
|
isWrittenToOrgUnit: !1
|
|
30
34
|
};
|
|
31
|
-
if (
|
|
32
|
-
({id:
|
|
35
|
+
if (p && !r(e)) try {
|
|
36
|
+
({id: m.savedId} = await e.move(u, l));
|
|
33
37
|
} catch (e) {
|
|
34
38
|
return {
|
|
35
|
-
...
|
|
39
|
+
...m,
|
|
36
40
|
outcome: "savedButMoveFailed",
|
|
37
41
|
error: e
|
|
38
42
|
};
|
|
39
43
|
}
|
|
44
|
+
let h = !1;
|
|
40
45
|
if (s && c) try {
|
|
41
|
-
await e.saveIntoOrgUnit?.(
|
|
46
|
+
await e.saveIntoOrgUnit?.(m.savedId, t.destination.path), m.isWrittenToOrgUnit = !0;
|
|
42
47
|
} catch (e) {
|
|
43
|
-
return {
|
|
44
|
-
...
|
|
48
|
+
if (!await d(e)) return {
|
|
49
|
+
...m,
|
|
45
50
|
outcome: "savedButOrgUnitWriteFailed",
|
|
46
51
|
error: e
|
|
47
52
|
};
|
|
53
|
+
h = !0;
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
await
|
|
55
|
+
if (s && (!c || h)) try {
|
|
56
|
+
await n(e.publishEntityType, m.savedId, t.destination.path, a ? t.newVersion : t.currentVersion), m.isPublished = !0;
|
|
51
57
|
} catch (e) {
|
|
52
58
|
return {
|
|
53
|
-
...
|
|
59
|
+
...m,
|
|
54
60
|
outcome: "savedButPublishFailed",
|
|
55
61
|
error: e
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
|
-
return
|
|
64
|
+
return m;
|
|
59
65
|
};
|
|
60
66
|
//#endregion
|
|
61
|
-
export {
|
|
67
|
+
export { n as ResourceSaveError, l as ResourceSaveOutcome, u as ResourceSaveVersionError, i as SaveDestinationRoot, p as createPublishSavedResource, r as isResourceCreateAdapter, m as runResourceSave, c as toSaveDestinationRoot };
|
|
@@ -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 };
|
|
@@ -28,10 +28,18 @@ export interface UsePublishFoldersParams {
|
|
|
28
28
|
onRememberedFolderKeysChange?: (folderKeys: string[]) => void;
|
|
29
29
|
/**
|
|
30
30
|
* Host rule for whether a destination accepts a publish, replacing the
|
|
31
|
-
* `Production` placeholder when given.
|
|
32
|
-
*
|
|
31
|
+
* `Production` placeholder when given. Also hides a remembered destination
|
|
32
|
+
* the rule refuses. Omit it while the rule is unknown (feature off, rights
|
|
33
|
+
* not loaded) so the placeholder stays the fallback.
|
|
33
34
|
*/
|
|
34
35
|
canPublishTo?: (folderPath: string[]) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Host rule for whether a folder is listed at all. A folder it refuses is
|
|
38
|
+
* dropped with its whole subtree — also when it comes from
|
|
39
|
+
* `rememberedFolderKeys` or a folder created in this session — so a hidden
|
|
40
|
+
* folder never comes back through them. Omit it to list every folder.
|
|
41
|
+
*/
|
|
42
|
+
isFolderVisible?: (folderPath: string[]) => boolean;
|
|
35
43
|
}
|
|
36
44
|
/** Result returned by {@link usePublishFolders}. */
|
|
37
45
|
export interface UsePublishFoldersResult {
|
|
@@ -83,5 +91,5 @@ export interface UsePublishFoldersResult {
|
|
|
83
91
|
* Takes `listPublicFiles` as a parameter and hands remembered destinations
|
|
84
92
|
* back through a callback, so it imports no app context and no storage API.
|
|
85
93
|
*/
|
|
86
|
-
export declare const usePublishFolders: ({ listPublicFiles, rememberedFolderKeys, onRememberedFolderKeysChange, canPublishTo, }: UsePublishFoldersParams) => UsePublishFoldersResult;
|
|
94
|
+
export declare const usePublishFolders: ({ listPublicFiles, rememberedFolderKeys, onRememberedFolderKeysChange, canPublishTo, isFolderVisible, }: UsePublishFoldersParams) => UsePublishFoldersResult;
|
|
87
95
|
//# 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;
|
|
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;AA8CF,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;IAC9D;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;IACjD;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;CACrD;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,6IAA6I;IAC7I,qBAAqB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB,GAAI,yGAM/B,uBAAuB,KAAG,uBAsI5B,CAAC"}
|
|
@@ -15,61 +15,71 @@ 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 = (
|
|
19
|
-
|
|
18
|
+
}, p = (e, t) => e.reduce((e, n) => {
|
|
19
|
+
if (!t(n.path)) return e;
|
|
20
|
+
if (!n.children) return e.push(n), e;
|
|
21
|
+
let r = p(n.children, t);
|
|
22
|
+
return e.push(r.length === n.children.length && r.every((e, t) => e === n.children?.[t]) ? n : {
|
|
23
|
+
...n,
|
|
24
|
+
children: r
|
|
25
|
+
}), e;
|
|
26
|
+
}, []), m = ({ listPublicFiles: e, rememberedFolderKeys: c, onRememberedFolderKeysChange: l, canPublishTo: m, isFolderVisible: h }) => {
|
|
27
|
+
let [g, _] = i(() => /* @__PURE__ */ new Map()), [v, y] = i(() => /* @__PURE__ */ new Set()), [b, x] = i(() => /* @__PURE__ */ new Set()), [S, C] = i([]), w = r(() => {
|
|
20
28
|
let e = /* @__PURE__ */ new Set();
|
|
21
|
-
return
|
|
29
|
+
return v.forEach((t) => {
|
|
22
30
|
let n = t ? `${t}/` : "";
|
|
23
|
-
|
|
31
|
+
g.has(n) && e.add(t);
|
|
24
32
|
}), e;
|
|
25
|
-
}, [
|
|
26
|
-
|
|
33
|
+
}, [v, g]), T = t(async (t) => {
|
|
34
|
+
x((e) => new Set(e).add(t));
|
|
27
35
|
try {
|
|
28
36
|
let { items: n } = await e({ path: t || void 0 });
|
|
29
|
-
|
|
37
|
+
_((e) => new Map(e).set(t, n));
|
|
30
38
|
} finally {
|
|
31
|
-
|
|
39
|
+
x((e) => {
|
|
32
40
|
let n = new Set(e);
|
|
33
41
|
return n.delete(t), n;
|
|
34
42
|
});
|
|
35
43
|
}
|
|
36
44
|
}, [e]);
|
|
37
45
|
n(() => {
|
|
38
|
-
|
|
46
|
+
T("");
|
|
39
47
|
}, []);
|
|
40
|
-
let
|
|
41
|
-
|
|
48
|
+
let E = t((e) => {
|
|
49
|
+
y(e), e.forEach((e) => {
|
|
42
50
|
let t = `${e}/`;
|
|
43
|
-
!
|
|
51
|
+
!g.has(t) && !b.has(t) && T(t);
|
|
44
52
|
});
|
|
45
53
|
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
]),
|
|
54
|
+
g,
|
|
55
|
+
b,
|
|
56
|
+
T
|
|
57
|
+
]), D = t((e, t) => {
|
|
50
58
|
let n = s([...e, t]);
|
|
51
|
-
return
|
|
52
|
-
}, []),
|
|
59
|
+
return C((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
|
|
60
|
+
}, []), O = t((e) => {
|
|
53
61
|
let t = d(c, s(e));
|
|
54
62
|
t && l?.(t);
|
|
55
|
-
}, [c, l]),
|
|
63
|
+
}, [c, l]), k = m ?? u;
|
|
56
64
|
return {
|
|
57
65
|
folderItems: r(() => {
|
|
58
|
-
let e = Array.isArray(c) ? c.filter((e) => typeof e == "string") : [];
|
|
59
|
-
return
|
|
66
|
+
let e = (Array.isArray(c) ? c.filter((e) => typeof e == "string") : []).map(a).filter((e) => m == null || m(e)), t = o(f(g, "", []), [...e, ...S.map(a)]);
|
|
67
|
+
return h ? p(t, h) : t;
|
|
60
68
|
}, [
|
|
61
|
-
|
|
69
|
+
g,
|
|
62
70
|
c,
|
|
63
|
-
|
|
71
|
+
S,
|
|
72
|
+
m,
|
|
73
|
+
h
|
|
64
74
|
]),
|
|
65
|
-
expandedPaths:
|
|
66
|
-
loadedPaths:
|
|
67
|
-
loadingPaths: r(() => new Set([...
|
|
68
|
-
onExpandedPathsChange:
|
|
69
|
-
onCreatePublishFolder:
|
|
70
|
-
rememberPublishFolder:
|
|
71
|
-
hasPublishWriteAccess:
|
|
75
|
+
expandedPaths: v,
|
|
76
|
+
loadedPaths: w,
|
|
77
|
+
loadingPaths: r(() => new Set([...b].map((e) => e.replace(/\/$/, ""))), [b]),
|
|
78
|
+
onExpandedPathsChange: E,
|
|
79
|
+
onCreatePublishFolder: D,
|
|
80
|
+
rememberPublishFolder: O,
|
|
81
|
+
hasPublishWriteAccess: k
|
|
72
82
|
};
|
|
73
83
|
};
|
|
74
84
|
//#endregion
|
|
75
|
-
export { u as hasPublishFolderWriteAccess, d as rememberPublishFolderKey,
|
|
85
|
+
export { u as hasPublishFolderWriteAccess, d as rememberPublishFolderKey, m as usePublishFolders };
|