@epam/ai-dial-publish-panel 1.1.0-dev.55

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.
@@ -0,0 +1,90 @@
1
+ /** A single folder in the "publish to folder" destination tree. */
2
+ export interface PublishFolderNode {
3
+ /** Full path segments to this folder, outermost first. Also serves as the unique key. */
4
+ path: string[];
5
+ /** Display name of this folder (its last path segment). */
6
+ name: string;
7
+ /** Child folders, if any. */
8
+ children?: PublishFolderNode[];
9
+ }
10
+ /**
11
+ * A previously published version of a catalog entity, or a previous
12
+ * publication of an unversioned resource (e.g. a conversation).
13
+ */
14
+ export interface PublishHistoryEntry {
15
+ /**
16
+ * Semantic version string, e.g. "4.0.0". `undefined` for unversioned
17
+ * resources (e.g. a conversation), where a folder having any entry at all
18
+ * already means "already published here" — see `usePublishFlow`.
19
+ */
20
+ version?: string;
21
+ /** Unix timestamp (ms) when this version was published. */
22
+ publishedAt: number;
23
+ /** Display name of the user who published this version. */
24
+ publishedBy: string;
25
+ /** Folder path segments this version was published to, outermost first. */
26
+ folderPath: string[];
27
+ }
28
+ /**
29
+ * Minimal display data for the Publish flow's entity-summary row and for
30
+ * version-derived behavior (the replace-warning callout, the publish-history
31
+ * section's visibility), covering both versioned entities and unversioned
32
+ * resources (e.g. a conversation). `PublishPanel` renders a title-only row
33
+ * from this by default; a host needing a richer summary (icon, type badge)
34
+ * passes `renderSummary` alongside this instead.
35
+ */
36
+ export interface PublishResourceSummary {
37
+ /** Display title/name shown in the summary row. */
38
+ title: string;
39
+ /** Icon URL, if any. */
40
+ iconUrl?: string;
41
+ /** Version, when the resource is versioned. `undefined` for conversations. */
42
+ version?: string;
43
+ }
44
+ /** Which callout (if any) the publish panel should show below the folder picker. */
45
+ export declare enum PublishCalloutKind {
46
+ /** No callout — no folder selected, or a request is in flight. */
47
+ None = "none",
48
+ /** Informational callout describing who gets access once published. */
49
+ Info = "info",
50
+ /** Warning callout — publishing will replace an existing version in this folder. */
51
+ ReplaceWarning = "replaceWarning",
52
+ /** Error callout — the user lacks write access to the selected folder. */
53
+ NoAccess = "noAccess",
54
+ /** Error callout — the most recent submit attempt failed. */
55
+ SubmitError = "submitError"
56
+ }
57
+ /** Inputs used to derive the publish panel's callout and submit-button state. */
58
+ export interface PublishDerivationInput {
59
+ /** Whether a destination folder is currently selected. */
60
+ hasSelectedFolder: boolean;
61
+ /**
62
+ * Whether the selected folder already has this publication — this exact
63
+ * version, for a versioned catalog entity, or any prior publication at
64
+ * all, for an unversioned resource (e.g. a conversation).
65
+ */
66
+ hasExistingPublicationInFolder: boolean;
67
+ /** Whether the current user can publish to the selected folder. */
68
+ hasWriteAccess: boolean;
69
+ /** Whether a publish request is currently in flight. */
70
+ isSubmitting: boolean;
71
+ /** Whether the most recent submit attempt failed. */
72
+ hasSubmitError: boolean;
73
+ /**
74
+ * Whether resubmitting when `hasExistingPublicationInFolder` is true is
75
+ * allowed (catalog: republishing replaces the existing version) or
76
+ * blocked entirely (conversations have no update/replace semantics —
77
+ * publishing again to the same folder is not supported). Default `true`.
78
+ */
79
+ allowReplace?: boolean;
80
+ }
81
+ /** Derived, render-ready state for the publish panel. */
82
+ export interface PublishDerivedState {
83
+ /** Which callout (if any) to show below the folder picker. */
84
+ calloutKind: PublishCalloutKind;
85
+ /** Whether the submit button is disabled. */
86
+ isSubmitDisabled: boolean;
87
+ /** Whether the submit button should show its loading/spinner state. */
88
+ isSubmitLoading: boolean;
89
+ }
90
+ //# sourceMappingURL=publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/models/publish.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAChC;AA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+ "description": "Publish-to-folder UI and state flow shared by catalog entity publish and conversation publish",
4
+ "version": "1.1.0-dev.55",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./index.js",
8
+ "module": "./index.js",
9
+ "types": "./index.d.ts",
10
+ "exports": {
11
+ "./package.json": "./package.json",
12
+ "./styles.css": "./style.css",
13
+ ".": {
14
+ "types": "./index.d.ts",
15
+ "import": "./index.js",
16
+ "default": "./index.js"
17
+ }
18
+ },
19
+ "peerDependencies": {
20
+ "react": "^19.0.0",
21
+ "@tabler/icons-react": "^3.0.0",
22
+ "@epam/ai-dial-kit": "1.1.0-dev.55",
23
+ "@epam/ai-dial-sidebar": "1.1.0-dev.55",
24
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.55",
25
+ "@epam/ai-dial-ui-kit": "^0.13.0-dev.17"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/epam/ai-dial-chat.git",
30
+ "directory": "libs/publish-panel"
31
+ }
32
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=test-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a publish timestamp for display: a relative phrase ("Today",
3
+ * "Yesterday", "N days ago") within the last week, and an exact date
4
+ * (e.g. "Nov 20, 2024") once it's a week old or more. The exact date uses
5
+ * `locale` (default: the browser/runtime locale) rather than a fixed one.
6
+ */
7
+ export declare const formatPublishedDate: (publishedAt: number, now?: number, locale?: string) => string;
8
+ //# sourceMappingURL=format-published-date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-published-date.d.ts","sourceRoot":"","sources":["../../src/utils/format-published-date.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,MAAM,EACnB,MAAK,MAAmB,EACxB,SAAS,MAAM,KACd,MAkBF,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { DialFile } from '@epam/ai-dial-ui-kit';
2
+ import { PublishFolderNode } from '../models/publish';
3
+ /**
4
+ * Returns the subset of `items` whose name matches `query`, or that contain a
5
+ * descendant whose name matches. Matched branches keep only their matching
6
+ * descendants. Matching is case-insensitive substring matching.
7
+ */
8
+ export declare const filterFolderTree: (items: PublishFolderNode[], query: string) => PublishFolderNode[];
9
+ /** Returns every folder path (joined by "/") in `items`, recursively. */
10
+ export declare const collectFolderKeys: (items: PublishFolderNode[]) => string[];
11
+ /** Joins folder path segments into the string path key used by `DialFile`/`DialFoldersTree`. */
12
+ export declare const toFolderPathKey: (path: string[]) => string;
13
+ /** Splits a `DialFile`/`DialFoldersTree` string path back into folder path segments. */
14
+ export declare const fromFolderPathKey: (pathKey: string) => string[];
15
+ /** Converts `PublishFolderNode[]` to the `DialFile[]` shape `DialFoldersTree` requires. */
16
+ export declare const toDialFileTree: (items: PublishFolderNode[]) => DialFile[];
17
+ /** Error messages returned by {@link validateFolderName} for each rejection reason. */
18
+ export interface FolderNameValidationMessages {
19
+ /** Shown when the trimmed name is empty. */
20
+ empty: string;
21
+ /** Shown when the name contains `..` or a forbidden character. */
22
+ invalid: string;
23
+ /** Shown when a sibling folder already has this name (case-insensitive). */
24
+ duplicate: string;
25
+ }
26
+ /** Returns an error message from `messages`, or `null` when `rawValue` is a valid non-duplicate folder name for the publish destination tree. */
27
+ export declare const validateFolderName: (rawValue: string, siblingNames: string[], messages: FolderNameValidationMessages) => string | null;
28
+ /** Returns `baseName` if no sibling already has that name, otherwise appends a number suffix (`2`, `3`, …) until the name is free. */
29
+ export declare const getUniqueFolderName: (baseName: string, siblingNames: string[]) => string;
30
+ /** Names of the direct children of the folder at `parentPath` (root siblings when empty). */
31
+ export declare const getSiblingFolderNames: (items: PublishFolderNode[], parentPath: string[]) => string[];
32
+ //# sourceMappingURL=publish-folder-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-folder-tree.d.ts","sourceRoot":"","sources":["../../src/utils/publish-folder-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,iBAAiB,EAAE,EAC1B,OAAO,MAAM,KACZ,iBAAiB,EAoBnB,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,GAAI,OAAO,iBAAiB,EAAE,KAAG,MAAM,EAIjE,CAAC;AAEL,gGAAgG;AAChG,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,KAAG,MAAwB,CAAC;AAE1E,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,MAAM,EACtB,CAAC;AAErC,2FAA2F;AAC3F,eAAO,MAAM,cAAc,GAAI,OAAO,iBAAiB,EAAE,KAAG,QAAQ,EAUhE,CAAC;AAKL,uFAAuF;AACvF,MAAM,WAAW,4BAA4B;IAC3C,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,iJAAiJ;AACjJ,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,cAAc,MAAM,EAAE,EACtB,UAAU,4BAA4B,KACrC,MAAM,GAAG,IAcX,CAAC;AAEF,sIAAsI;AACtI,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,cAAc,MAAM,EAAE,KACrB,MAYF,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,qBAAqB,GAChC,OAAO,iBAAiB,EAAE,EAC1B,YAAY,MAAM,EAAE,KACnB,MAAM,EAoBR,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PublishDerivationInput, PublishDerivedState } from '../models/publish';
2
+ /** Derives the callout kind and submit-button state for the publish panel from the current folder context. */
3
+ export declare const derivePublishState: (input: PublishDerivationInput) => PublishDerivedState;
4
+ //# sourceMappingURL=publish-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-state.d.ts","sourceRoot":"","sources":["../../src/utils/publish-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,8GAA8G;AAC9G,eAAO,MAAM,kBAAkB,GAC7B,OAAO,sBAAsB,KAC5B,mBA8CF,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { PublishFolderNode, PublishHistoryEntry } from '../models/publish';
2
+ /** An item publishable through {@link usePublishFlow} — versioned or not (e.g. a conversation). */
3
+ export interface PublishFlowItem {
4
+ /** Version, when the item is versioned. `undefined` for unversioned resources. */
5
+ version?: string;
6
+ }
7
+ /** Options for {@link usePublishFlow}. */
8
+ export interface UsePublishFlowOptions<TItem extends PublishFlowItem> {
9
+ /** The item being published — versioned, or an unversioned resource (e.g. a conversation). */
10
+ item: TItem;
11
+ /** Previously published entries for this item. */
12
+ history: PublishHistoryEntry[];
13
+ /** Root-level destination folder nodes, as currently known to the host. */
14
+ folderItems: PublishFolderNode[];
15
+ /**
16
+ * Resolves whether the current user can publish to a given folder path.
17
+ * Defaults to always allowing (`() => true`) when omitted.
18
+ */
19
+ hasWriteAccess?: (folderPath: string[]) => boolean;
20
+ /**
21
+ * Called when the user confirms a new folder name. The host owns
22
+ * persisting the folder; the hook also adds it locally so it is
23
+ * immediately selectable within this session. If the returned promise
24
+ * rejects, the optimistically added folder is rolled back and the submit-
25
+ * error callout is surfaced.
26
+ */
27
+ onCreateFolder?: (parentPath: string[], name: string) => void | Promise<void>;
28
+ /** Called with the destination folder path when the user confirms publish/update. */
29
+ onPublish: (item: TItem, folderPath: string[]) => Promise<void>;
30
+ /** Called after a successful publish; the host surfaces its own success notification. */
31
+ onPublishSuccess?: (item: TItem, folderPath: string[]) => void;
32
+ }
33
+ /** State and handlers returned by {@link usePublishFlow}. */
34
+ export interface UsePublishFlowResult {
35
+ /** Folder tree, including any folders created (but not yet persisted) during this session. */
36
+ folderItems: PublishFolderNode[];
37
+ /**
38
+ * Currently selected destination folder path. `undefined` means nothing
39
+ * is selected; `[]` means the bucket root itself is selected (a distinct,
40
+ * valid destination).
41
+ */
42
+ selectedFolderPath?: string[];
43
+ /** Selects a destination folder or the root (`[]`); pass `undefined` to deselect. */
44
+ setSelectedFolderPath: (path: string[] | undefined) => void;
45
+ /** Confirms a new folder name: adds it locally and reports it to the host, rolling back and surfacing an error if the host rejects. */
46
+ handleCreateFolder: (parentPath: string[], name: string) => Promise<void>;
47
+ /**
48
+ * Whether `selectedFolderPath` already has this publication — this exact
49
+ * version, for a versioned item, or any prior entry at all, for an
50
+ * unversioned item (whose `version` is `undefined`).
51
+ */
52
+ hasExistingPublicationInFolder: boolean;
53
+ /** Whether the current user can publish to `selectedFolderPath`. */
54
+ hasWriteAccess: boolean;
55
+ /** Whether a publish request is currently in flight. */
56
+ isSubmitting: boolean;
57
+ /** Whether the most recent submit attempt failed. */
58
+ hasSubmitError: boolean;
59
+ /**
60
+ * Submits the publish/update request for the selected folder. Resolves to
61
+ * `true` on success and `false` if `onPublish` rejected, so the caller can
62
+ * decide whether to close the flow.
63
+ */
64
+ handleSubmit: () => Promise<boolean>;
65
+ /** Resets folder selection, any locally-created folders, and the submit error back to their initial state. */
66
+ reset: () => void;
67
+ }
68
+ /** Manages all state for the Publish flow: folder selection, local folder creation, existing-publication detection, and submit handling. */
69
+ export declare const usePublishFlow: <TItem extends PublishFlowItem = PublishFlowItem>({ item, history, folderItems: initialFolderItems, hasWriteAccess: resolveWriteAccess, onCreateFolder, onPublish, onPublishSuccess, }: UsePublishFlowOptions<TItem>) => UsePublishFlowResult;
70
+ //# sourceMappingURL=use-publish-flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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