@automattic/jetpack-ai-client 0.16.1 → 0.16.3
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/CHANGELOG.md +13 -0
- package/build/ask-question/index.d.ts +3 -3
- package/build/ask-question/index.js +3 -3
- package/build/ask-question/sync.d.ts +3 -3
- package/build/ask-question/sync.js +3 -3
- package/build/audio-transcription/index.d.ts +3 -3
- package/build/audio-transcription/index.js +3 -3
- package/build/components/ai-control/ai-control.d.ts +1 -1
- package/build/components/ai-control/ai-control.js +1 -1
- package/build/components/ai-control/block-ai-control.d.ts +3 -3
- package/build/components/ai-control/block-ai-control.js +3 -3
- package/build/components/ai-control/extension-ai-control.d.ts +3 -3
- package/build/components/ai-control/extension-ai-control.js +3 -3
- package/build/components/ai-status-indicator/index.d.ts +1 -1
- package/build/components/ai-status-indicator/index.js +1 -1
- package/build/components/audio-duration-display/index.d.ts +1 -1
- package/build/components/audio-duration-display/index.js +1 -1
- package/build/components/audio-duration-display/lib/media.d.ts +2 -2
- package/build/components/audio-duration-display/lib/media.js +2 -2
- package/build/components/message/index.d.ts +4 -4
- package/build/components/message/index.js +4 -4
- package/build/data-flow/context.d.ts +2 -2
- package/build/data-flow/context.js +2 -2
- package/build/data-flow/use-ai-context.d.ts +1 -1
- package/build/data-flow/use-ai-context.js +1 -1
- package/build/data-flow/with-ai-assistant-data.d.ts +1 -1
- package/build/data-flow/with-ai-assistant-data.js +1 -1
- package/build/hooks/use-ai-suggestions/index.d.ts +3 -3
- package/build/hooks/use-ai-suggestions/index.js +11 -11
- package/build/hooks/use-audio-transcription/index.d.ts +1 -1
- package/build/hooks/use-audio-transcription/index.js +2 -2
- package/build/hooks/use-audio-validation/index.d.ts +1 -1
- package/build/hooks/use-audio-validation/index.js +1 -1
- package/build/hooks/use-image-generator/index.js +9 -9
- package/build/hooks/use-media-recording/index.d.ts +1 -1
- package/build/hooks/use-media-recording/index.js +4 -4
- package/build/hooks/use-save-to-media-library/index.d.ts +1 -1
- package/build/hooks/use-save-to-media-library/index.js +1 -1
- package/build/hooks/use-transcription-post-processing/index.d.ts +1 -1
- package/build/hooks/use-transcription-post-processing/index.js +1 -1
- package/build/jwt/index.d.ts +1 -1
- package/build/jwt/index.js +1 -1
- package/build/libs/markdown/html-to-markdown.d.ts +1 -1
- package/build/libs/markdown/html-to-markdown.js +1 -1
- package/build/libs/markdown/markdown-to-html.d.ts +4 -4
- package/build/libs/markdown/markdown-to-html.js +4 -4
- package/build/logo-generator/lib/logo-storage.d.ts +17 -17
- package/build/logo-generator/lib/logo-storage.js +17 -17
- package/build/logo-generator/lib/media-exists.d.ts +2 -2
- package/build/logo-generator/lib/media-exists.js +2 -2
- package/build/logo-generator/lib/set-site-logo.d.ts +3 -3
- package/build/logo-generator/lib/set-site-logo.js +3 -3
- package/build/logo-generator/lib/wpcom-limited-request.d.ts +1 -1
- package/build/logo-generator/lib/wpcom-limited-request.js +1 -1
- package/build/logo-generator/store/actions.d.ts +3 -3
- package/build/logo-generator/store/actions.js +3 -3
- package/build/logo-generator/store/reducer.d.ts +22 -22
- package/build/logo-generator/store/reducer.js +22 -22
- package/build/logo-generator/store/selectors.d.ts +20 -20
- package/build/logo-generator/store/selectors.js +20 -20
- package/build/suggestions-event-source/index.d.ts +1 -1
- package/build/suggestions-event-source/index.js +1 -1
- package/package.json +22 -21
- package/src/ask-question/index.ts +3 -3
- package/src/ask-question/sync.ts +3 -3
- package/src/audio-transcription/index.ts +3 -3
- package/src/components/ai-control/ai-control.tsx +1 -1
- package/src/components/ai-control/block-ai-control.tsx +3 -3
- package/src/components/ai-control/extension-ai-control.tsx +3 -3
- package/src/components/ai-status-indicator/index.tsx +1 -1
- package/src/components/audio-duration-display/index.tsx +1 -1
- package/src/components/audio-duration-display/lib/media.ts +2 -2
- package/src/components/message/index.tsx +4 -4
- package/src/data-flow/context.tsx +2 -2
- package/src/data-flow/use-ai-context.ts +1 -1
- package/src/data-flow/with-ai-assistant-data.tsx +1 -1
- package/src/hooks/use-ai-suggestions/index.ts +11 -11
- package/src/hooks/use-audio-transcription/index.ts +2 -2
- package/src/hooks/use-audio-validation/index.ts +1 -1
- package/src/hooks/use-image-generator/index.ts +9 -9
- package/src/hooks/use-media-recording/index.ts +4 -4
- package/src/hooks/use-save-to-media-library/index.ts +1 -1
- package/src/hooks/use-transcription-post-processing/index.ts +1 -1
- package/src/jwt/index.ts +1 -1
- package/src/libs/markdown/html-to-markdown.ts +1 -1
- package/src/libs/markdown/markdown-to-html.ts +4 -4
- package/src/logo-generator/lib/logo-storage.ts +17 -17
- package/src/logo-generator/lib/media-exists.ts +2 -2
- package/src/logo-generator/lib/set-site-logo.ts +3 -3
- package/src/logo-generator/lib/wpcom-limited-request.ts +1 -1
- package/src/logo-generator/store/actions.ts +3 -3
- package/src/logo-generator/store/reducer.ts +22 -22
- package/src/logo-generator/store/selectors.ts +20 -20
- package/src/suggestions-event-source/index.ts +1 -1
|
@@ -12,7 +12,7 @@ const MEDIA_TYPE_WEBM = 'audio/webm';
|
|
|
12
12
|
* react custom hook to handle media recording.
|
|
13
13
|
*
|
|
14
14
|
* @param {UseMediaRecordingProps} props - The props
|
|
15
|
-
* @
|
|
15
|
+
* @return {UseMediaRecordingReturn} The media recorder instance
|
|
16
16
|
*/
|
|
17
17
|
export default function useMediaRecording({ onDone, } = {}) {
|
|
18
18
|
// Reference to the media recorder instance
|
|
@@ -35,7 +35,7 @@ export default function useMediaRecording({ onDone, } = {}) {
|
|
|
35
35
|
/**
|
|
36
36
|
* Get the recorded blob.
|
|
37
37
|
*
|
|
38
|
-
* @
|
|
38
|
+
* @return {Blob} The recorded blob
|
|
39
39
|
*/
|
|
40
40
|
function getBlob() {
|
|
41
41
|
if (MediaRecorder.isTypeSupported(MEDIA_TYPE_MP4_MP4A)) {
|
|
@@ -158,7 +158,7 @@ export default function useMediaRecording({ onDone, } = {}) {
|
|
|
158
158
|
* `stop` event listener for the media recorder instance.
|
|
159
159
|
* Happens after the last `dataavailable` event.
|
|
160
160
|
*
|
|
161
|
-
* @
|
|
161
|
+
* @return {void}
|
|
162
162
|
*/
|
|
163
163
|
function onStopListener() {
|
|
164
164
|
const lastBlob = getBlob();
|
|
@@ -182,7 +182,7 @@ export default function useMediaRecording({ onDone, } = {}) {
|
|
|
182
182
|
* `dataavailable` event listener for the media recorder instance.
|
|
183
183
|
*
|
|
184
184
|
* @param {MediaRecorderEvent} event - The event object
|
|
185
|
-
* @
|
|
185
|
+
* @return {void}
|
|
186
186
|
*/
|
|
187
187
|
function onDataAvailableListener(event) {
|
|
188
188
|
const { data } = event;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook to save an image to the media library.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @return {object} Object with the loading state and the function to save the image to the media library.
|
|
5
5
|
*/
|
|
6
6
|
export default function useSaveToMediaLibrary(): {
|
|
7
7
|
isLoading: boolean;
|
|
@@ -9,7 +9,7 @@ const debug = debugFactory('ai-client:save-to-media-library');
|
|
|
9
9
|
/**
|
|
10
10
|
* Hook to save an image to the media library.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
12
|
+
* @return {object} Object with the loading state and the function to save the image to the media library.
|
|
13
13
|
*/
|
|
14
14
|
export default function useSaveToMediaLibrary() {
|
|
15
15
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -26,6 +26,6 @@ export type UseTranscriptionPostProcessingProps = {
|
|
|
26
26
|
* A hook to handle transcription post-processing.
|
|
27
27
|
*
|
|
28
28
|
* @param {string} feature - The feature name that is calling the post-processing actions.
|
|
29
|
-
* @
|
|
29
|
+
* @return {UseTranscriptionPostProcessingReturn} - Object with properties to get the post-processing results.
|
|
30
30
|
*/
|
|
31
31
|
export default function useTranscriptionPostProcessing({ feature, onReady, onError, onUpdate, }: UseTranscriptionPostProcessingProps): UseTranscriptionPostProcessingReturn;
|
|
@@ -16,7 +16,7 @@ export const TRANSCRIPTION_POST_PROCESSING_ACTION_SIMPLE_DRAFT = 'voice-to-conte
|
|
|
16
16
|
* A hook to handle transcription post-processing.
|
|
17
17
|
*
|
|
18
18
|
* @param {string} feature - The feature name that is calling the post-processing actions.
|
|
19
|
-
* @
|
|
19
|
+
* @return {UseTranscriptionPostProcessingReturn} - Object with properties to get the post-processing results.
|
|
20
20
|
*/
|
|
21
21
|
export default function useTranscriptionPostProcessing({ feature, onReady, onError, onUpdate, }) {
|
|
22
22
|
const [postProcessingResult, setPostProcessingResult] = useState('');
|
package/build/jwt/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type TokenDataProps = {
|
|
|
13
13
|
* Request a token from the Jetpack site.
|
|
14
14
|
*
|
|
15
15
|
* @param {RequestTokenOptions} options - Options
|
|
16
|
-
* @
|
|
16
|
+
* @return {Promise<TokenDataProps>} The token and the blogId
|
|
17
17
|
*/
|
|
18
18
|
export default function requestJwt({ apiNonce, siteId, expirationTime, }?: RequestTokenOptions): Promise<TokenDataProps>;
|
|
19
19
|
export {};
|
package/build/jwt/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const JWT_TOKEN_EXPIRATION_TIME = 2 * 60 * 1000; // 2 minutes
|
|
|
14
14
|
* Request a token from the Jetpack site.
|
|
15
15
|
*
|
|
16
16
|
* @param {RequestTokenOptions} options - Options
|
|
17
|
-
* @
|
|
17
|
+
* @return {Promise<TokenDataProps>} The token and the blogId
|
|
18
18
|
*/
|
|
19
19
|
export default async function requestJwt({ apiNonce, siteId, expirationTime, } = {}) {
|
|
20
20
|
// Default values
|
|
@@ -23,7 +23,7 @@ export default class HTMLToMarkdown {
|
|
|
23
23
|
* Renders HTML from Markdown content with specified processing rules.
|
|
24
24
|
* @param {object} options - The options to use when rendering the Markdown content
|
|
25
25
|
* @param {string} options.content - The HTML content to render
|
|
26
|
-
* @
|
|
26
|
+
* @return {string} The rendered Markdown content
|
|
27
27
|
*/
|
|
28
28
|
render({ content }: {
|
|
29
29
|
content: string;
|
|
@@ -34,7 +34,7 @@ export default class HTMLToMarkdown {
|
|
|
34
34
|
* Renders HTML from Markdown content with specified processing rules.
|
|
35
35
|
* @param {object} options - The options to use when rendering the Markdown content
|
|
36
36
|
* @param {string} options.content - The HTML content to render
|
|
37
|
-
* @
|
|
37
|
+
* @return {string} The rendered Markdown content
|
|
38
38
|
*/
|
|
39
39
|
render({ content }) {
|
|
40
40
|
const rendered = this.turndownService.turndown(content);
|
|
@@ -18,11 +18,11 @@ export default class MarkdownToHTML {
|
|
|
18
18
|
constructor(options?: Options);
|
|
19
19
|
/**
|
|
20
20
|
* Renders HTML from Markdown content with specified processing rules.
|
|
21
|
-
* @param {object}
|
|
22
|
-
* @param {string}
|
|
23
|
-
* @param {string}
|
|
21
|
+
* @param {object} options - The options to use when rendering the HTML content
|
|
22
|
+
* @param {string} options.content - The Markdown content to render
|
|
23
|
+
* @param {string} options.rules - The rules to apply to the rendered content
|
|
24
24
|
* @param {boolean} options.extension - Whether to apply the extension-specific rules
|
|
25
|
-
* @
|
|
25
|
+
* @return {string} The rendered HTML content
|
|
26
26
|
*/
|
|
27
27
|
render({ content, rules, extension, }: {
|
|
28
28
|
content: string;
|
|
@@ -65,11 +65,11 @@ export default class MarkdownToHTML {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Renders HTML from Markdown content with specified processing rules.
|
|
68
|
-
* @param {object}
|
|
69
|
-
* @param {string}
|
|
70
|
-
* @param {string}
|
|
68
|
+
* @param {object} options - The options to use when rendering the HTML content
|
|
69
|
+
* @param {string} options.content - The Markdown content to render
|
|
70
|
+
* @param {string} options.rules - The rules to apply to the rendered content
|
|
71
71
|
* @param {boolean} options.extension - Whether to apply the extension-specific rules
|
|
72
|
-
* @
|
|
72
|
+
* @return {string} The rendered HTML content
|
|
73
73
|
*/
|
|
74
74
|
render({ content, rules = assistantBlockRules, extension = false, }) {
|
|
75
75
|
const rendered = this.markdownConverter.render(content);
|
|
@@ -6,53 +6,53 @@ import { RemoveFromStorageProps, SaveToStorageProps, UpdateInStorageProps } from
|
|
|
6
6
|
/**
|
|
7
7
|
* Add an entry to the site's logo history.
|
|
8
8
|
*
|
|
9
|
-
* @param {SaveToStorageProps}
|
|
10
|
-
* @param {SaveToStorageProps.siteId}
|
|
11
|
-
* @param {SaveToStorageProps.url}
|
|
9
|
+
* @param {SaveToStorageProps} saveToStorageProps - The properties to save to storage
|
|
10
|
+
* @param {SaveToStorageProps.siteId} saveToStorageProps.siteId - The site ID
|
|
11
|
+
* @param {SaveToStorageProps.url} saveToStorageProps.url - The URL of the logo
|
|
12
12
|
* @param {SaveToStorageProps.description} saveToStorageProps.description - The description of the logo, based on the prompt used to generate it
|
|
13
|
-
* @param {SaveToStorageProps.mediaId}
|
|
13
|
+
* @param {SaveToStorageProps.mediaId} saveToStorageProps.mediaId - The media ID of the logo on the backend
|
|
14
14
|
*
|
|
15
|
-
* @
|
|
15
|
+
* @return {Logo} The logo that was saved
|
|
16
16
|
*/
|
|
17
17
|
export declare function stashLogo({ siteId, url, description, mediaId }: SaveToStorageProps): Logo;
|
|
18
18
|
/**
|
|
19
19
|
* Update an entry in the site's logo history.
|
|
20
20
|
*
|
|
21
|
-
* @param {UpdateInStorageProps}
|
|
22
|
-
* @param {UpdateInStorageProps.siteId}
|
|
23
|
-
* @param {UpdateInStorageProps.url}
|
|
24
|
-
* @param {UpdateInStorageProps.newUrl}
|
|
21
|
+
* @param {UpdateInStorageProps} updateInStorageProps - The properties to update in storage
|
|
22
|
+
* @param {UpdateInStorageProps.siteId} updateInStorageProps.siteId - The site ID
|
|
23
|
+
* @param {UpdateInStorageProps.url} updateInStorageProps.url - The URL of the logo to update
|
|
24
|
+
* @param {UpdateInStorageProps.newUrl} updateInStorageProps.newUrl - The new URL of the logo
|
|
25
25
|
* @param {UpdateInStorageProps.mediaId} updateInStorageProps.mediaId - The new media ID of the logo
|
|
26
|
-
* @
|
|
26
|
+
* @return {Logo} The logo that was updated
|
|
27
27
|
*/
|
|
28
28
|
export declare function updateLogo({ siteId, url, newUrl, mediaId }: UpdateInStorageProps): Logo;
|
|
29
29
|
/**
|
|
30
30
|
* Get the logo history for a site.
|
|
31
31
|
*
|
|
32
32
|
* @param {string} siteId - The site ID to get the logo history for
|
|
33
|
-
* @
|
|
33
|
+
* @return {Logo[]} The logo history for the site
|
|
34
34
|
*/
|
|
35
35
|
export declare function getSiteLogoHistory(siteId: string): Logo[];
|
|
36
36
|
/**
|
|
37
37
|
* Check if the logo history for a site is empty.
|
|
38
38
|
*
|
|
39
|
-
* @param {string }siteId - The site ID to check the logo history for
|
|
40
|
-
* @
|
|
39
|
+
* @param {string } siteId - The site ID to check the logo history for
|
|
40
|
+
* @return {boolean} Whether the logo history for the site is empty
|
|
41
41
|
*/
|
|
42
42
|
export declare function isLogoHistoryEmpty(siteId: string): boolean;
|
|
43
43
|
/**
|
|
44
44
|
* Remove an entry from the site's logo history.
|
|
45
45
|
*
|
|
46
|
-
* @param {RemoveFromStorageProps}
|
|
47
|
-
* @param {RemoveFromStorageProps.siteId}
|
|
46
|
+
* @param {RemoveFromStorageProps} removeFromStorageProps - The properties to remove from storage
|
|
47
|
+
* @param {RemoveFromStorageProps.siteId} removeFromStorageProps.siteId - The site ID
|
|
48
48
|
* @param {RemoveFromStorageProps.mediaId} removeFromStorageProps.mediaId - The media ID of the logo to remove
|
|
49
|
-
* @
|
|
49
|
+
* @return {void}
|
|
50
50
|
*/
|
|
51
51
|
export declare function removeLogo({ siteId, mediaId }: RemoveFromStorageProps): void;
|
|
52
52
|
/**
|
|
53
53
|
* Clear deleted media from the site's logo history, checking if the media still exists on the backend.
|
|
54
54
|
*
|
|
55
55
|
* @param {string} siteId - The site ID to clear deleted media for
|
|
56
|
-
* @
|
|
56
|
+
* @return {Promise<void>}
|
|
57
57
|
*/
|
|
58
58
|
export declare function clearDeletedMedia(siteId: string): Promise<void>;
|
|
@@ -3,13 +3,13 @@ const MAX_LOGOS = 10;
|
|
|
3
3
|
/**
|
|
4
4
|
* Add an entry to the site's logo history.
|
|
5
5
|
*
|
|
6
|
-
* @param {SaveToStorageProps}
|
|
7
|
-
* @param {SaveToStorageProps.siteId}
|
|
8
|
-
* @param {SaveToStorageProps.url}
|
|
6
|
+
* @param {SaveToStorageProps} saveToStorageProps - The properties to save to storage
|
|
7
|
+
* @param {SaveToStorageProps.siteId} saveToStorageProps.siteId - The site ID
|
|
8
|
+
* @param {SaveToStorageProps.url} saveToStorageProps.url - The URL of the logo
|
|
9
9
|
* @param {SaveToStorageProps.description} saveToStorageProps.description - The description of the logo, based on the prompt used to generate it
|
|
10
|
-
* @param {SaveToStorageProps.mediaId}
|
|
10
|
+
* @param {SaveToStorageProps.mediaId} saveToStorageProps.mediaId - The media ID of the logo on the backend
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
12
|
+
* @return {Logo} The logo that was saved
|
|
13
13
|
*/
|
|
14
14
|
export function stashLogo({ siteId, url, description, mediaId }) {
|
|
15
15
|
const storedContent = getSiteLogoHistory(siteId);
|
|
@@ -25,12 +25,12 @@ export function stashLogo({ siteId, url, description, mediaId }) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Update an entry in the site's logo history.
|
|
27
27
|
*
|
|
28
|
-
* @param {UpdateInStorageProps}
|
|
29
|
-
* @param {UpdateInStorageProps.siteId}
|
|
30
|
-
* @param {UpdateInStorageProps.url}
|
|
31
|
-
* @param {UpdateInStorageProps.newUrl}
|
|
28
|
+
* @param {UpdateInStorageProps} updateInStorageProps - The properties to update in storage
|
|
29
|
+
* @param {UpdateInStorageProps.siteId} updateInStorageProps.siteId - The site ID
|
|
30
|
+
* @param {UpdateInStorageProps.url} updateInStorageProps.url - The URL of the logo to update
|
|
31
|
+
* @param {UpdateInStorageProps.newUrl} updateInStorageProps.newUrl - The new URL of the logo
|
|
32
32
|
* @param {UpdateInStorageProps.mediaId} updateInStorageProps.mediaId - The new media ID of the logo
|
|
33
|
-
* @
|
|
33
|
+
* @return {Logo} The logo that was updated
|
|
34
34
|
*/
|
|
35
35
|
export function updateLogo({ siteId, url, newUrl, mediaId }) {
|
|
36
36
|
const storedContent = getSiteLogoHistory(siteId);
|
|
@@ -46,7 +46,7 @@ export function updateLogo({ siteId, url, newUrl, mediaId }) {
|
|
|
46
46
|
* Get the logo history for a site.
|
|
47
47
|
*
|
|
48
48
|
* @param {string} siteId - The site ID to get the logo history for
|
|
49
|
-
* @
|
|
49
|
+
* @return {Logo[]} The logo history for the site
|
|
50
50
|
*/
|
|
51
51
|
export function getSiteLogoHistory(siteId) {
|
|
52
52
|
const storedString = localStorage.getItem(`logo-history-${siteId}`);
|
|
@@ -74,8 +74,8 @@ export function getSiteLogoHistory(siteId) {
|
|
|
74
74
|
/**
|
|
75
75
|
* Check if the logo history for a site is empty.
|
|
76
76
|
*
|
|
77
|
-
* @param {string }siteId - The site ID to check the logo history for
|
|
78
|
-
* @
|
|
77
|
+
* @param {string } siteId - The site ID to check the logo history for
|
|
78
|
+
* @return {boolean} Whether the logo history for the site is empty
|
|
79
79
|
*/
|
|
80
80
|
export function isLogoHistoryEmpty(siteId) {
|
|
81
81
|
const storedContent = getSiteLogoHistory(siteId);
|
|
@@ -84,10 +84,10 @@ export function isLogoHistoryEmpty(siteId) {
|
|
|
84
84
|
/**
|
|
85
85
|
* Remove an entry from the site's logo history.
|
|
86
86
|
*
|
|
87
|
-
* @param {RemoveFromStorageProps}
|
|
88
|
-
* @param {RemoveFromStorageProps.siteId}
|
|
87
|
+
* @param {RemoveFromStorageProps} removeFromStorageProps - The properties to remove from storage
|
|
88
|
+
* @param {RemoveFromStorageProps.siteId} removeFromStorageProps.siteId - The site ID
|
|
89
89
|
* @param {RemoveFromStorageProps.mediaId} removeFromStorageProps.mediaId - The media ID of the logo to remove
|
|
90
|
-
* @
|
|
90
|
+
* @return {void}
|
|
91
91
|
*/
|
|
92
92
|
export function removeLogo({ siteId, mediaId }) {
|
|
93
93
|
const storedContent = getSiteLogoHistory(siteId);
|
|
@@ -102,7 +102,7 @@ export function removeLogo({ siteId, mediaId }) {
|
|
|
102
102
|
* Clear deleted media from the site's logo history, checking if the media still exists on the backend.
|
|
103
103
|
*
|
|
104
104
|
* @param {string} siteId - The site ID to clear deleted media for
|
|
105
|
-
* @
|
|
105
|
+
* @return {Promise<void>}
|
|
106
106
|
*/
|
|
107
107
|
export async function clearDeletedMedia(siteId) {
|
|
108
108
|
const storedContent = getSiteLogoHistory(siteId);
|
|
@@ -5,8 +5,8 @@ import type { CheckMediaProps } from '../types.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Uses the media information to confirm it exists or not on the server.
|
|
7
7
|
*
|
|
8
|
-
* @param {CheckMediaProps}
|
|
8
|
+
* @param {CheckMediaProps} checkMediaProps - the media details to check
|
|
9
9
|
* @param {CheckMediaProps.mediaId} checkMediaProps.mediaId - the id of the media to check
|
|
10
|
-
* @
|
|
10
|
+
* @return {Promise<boolean>} - true if the media exists, false otherwise
|
|
11
11
|
*/
|
|
12
12
|
export declare function mediaExists({ mediaId }: CheckMediaProps): Promise<boolean>;
|
|
@@ -5,9 +5,9 @@ import apiFetch from '../../api-fetch/index.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Uses the media information to confirm it exists or not on the server.
|
|
7
7
|
*
|
|
8
|
-
* @param {CheckMediaProps}
|
|
8
|
+
* @param {CheckMediaProps} checkMediaProps - the media details to check
|
|
9
9
|
* @param {CheckMediaProps.mediaId} checkMediaProps.mediaId - the id of the media to check
|
|
10
|
-
* @
|
|
10
|
+
* @return {Promise<boolean>} - true if the media exists, false otherwise
|
|
11
11
|
*/
|
|
12
12
|
export async function mediaExists({ mediaId }) {
|
|
13
13
|
const id = Number(mediaId);
|
|
@@ -5,9 +5,9 @@ import type { SetSiteLogoProps, SetSiteLogoResponseProps } from '../types.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Set the site logo using a backend request.
|
|
7
7
|
*
|
|
8
|
-
* @param {SetSiteLogoProps}
|
|
9
|
-
* @param {SetSiteLogoProps.siteId}
|
|
8
|
+
* @param {SetSiteLogoProps} setSiteLogoProps - The properties to set the site logo
|
|
9
|
+
* @param {SetSiteLogoProps.siteId} setSiteLogoProps.siteId - The site ID
|
|
10
10
|
* @param {SetSiteLogoProps.imageId} setSiteLogoProps.imageId - The image ID to set as the site logo
|
|
11
|
-
* @
|
|
11
|
+
* @return {Promise<SetSiteLogoResponseProps>} The response from the request
|
|
12
12
|
*/
|
|
13
13
|
export declare function setSiteLogo({ siteId, imageId }: SetSiteLogoProps): Promise<SetSiteLogoResponseProps>;
|
|
@@ -5,10 +5,10 @@ import wpcomLimitedRequest from './wpcom-limited-request.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Set the site logo using a backend request.
|
|
7
7
|
*
|
|
8
|
-
* @param {SetSiteLogoProps}
|
|
9
|
-
* @param {SetSiteLogoProps.siteId}
|
|
8
|
+
* @param {SetSiteLogoProps} setSiteLogoProps - The properties to set the site logo
|
|
9
|
+
* @param {SetSiteLogoProps.siteId} setSiteLogoProps.siteId - The site ID
|
|
10
10
|
* @param {SetSiteLogoProps.imageId} setSiteLogoProps.imageId - The image ID to set as the site logo
|
|
11
|
-
* @
|
|
11
|
+
* @return {Promise<SetSiteLogoResponseProps>} The response from the request
|
|
12
12
|
*/
|
|
13
13
|
export async function setSiteLogo({ siteId, imageId }) {
|
|
14
14
|
const body = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Concurrency-limited request to wpcom-proxy-request.
|
|
3
3
|
* @param { object } params - The request params, as expected by apiFetch.
|
|
4
|
-
* @
|
|
4
|
+
* @return { Promise } The response.
|
|
5
5
|
* @throws { Error } If there are too many concurrent requests.
|
|
6
6
|
*/
|
|
7
7
|
export default function wpcomLimitedRequest<T>(params: object): Promise<T>;
|
|
@@ -10,7 +10,7 @@ let concurrentCounter = 0;
|
|
|
10
10
|
/**
|
|
11
11
|
* Concurrency-limited request to wpcom-proxy-request.
|
|
12
12
|
* @param { object } params - The request params, as expected by apiFetch.
|
|
13
|
-
* @
|
|
13
|
+
* @return { Promise } The response.
|
|
14
14
|
* @throws { Error } If there are too many concurrent requests.
|
|
15
15
|
*/
|
|
16
16
|
export default async function wpcomLimitedRequest(params) {
|
|
@@ -4,7 +4,7 @@ import type { SiteDetails } from '../types.js';
|
|
|
4
4
|
* Map the response from the `sites/$site/ai-assistant-feature`
|
|
5
5
|
* endpoint to the AI Assistant feature props.
|
|
6
6
|
* @param { AiAssistantFeatureEndpointResponseProps } response - The response from the endpoint.
|
|
7
|
-
* @
|
|
7
|
+
* @return { AiFeatureProps } The AI Assistant feature props.
|
|
8
8
|
*/
|
|
9
9
|
export declare function mapAiFeatureResponseToAiFeatureProps(response: AiAssistantFeatureEndpointResponseProps): AiFeatureProps;
|
|
10
10
|
declare const actions: {
|
|
@@ -14,7 +14,7 @@ declare const actions: {
|
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Thunk action to fetch the AI Assistant feature from the API.
|
|
17
|
-
* @
|
|
17
|
+
* @return {Function} The thunk action.
|
|
18
18
|
*/
|
|
19
19
|
fetchAiAssistantFeature(): ({ dispatch }: {
|
|
20
20
|
dispatch: any;
|
|
@@ -23,7 +23,7 @@ declare const actions: {
|
|
|
23
23
|
* This thunk action is used to increase
|
|
24
24
|
* the requests count for the current usage period.
|
|
25
25
|
* @param {number} count - The number of requests to increase. Default is 1.
|
|
26
|
-
* @
|
|
26
|
+
* @return {Function} The thunk action.
|
|
27
27
|
*/
|
|
28
28
|
increaseAiAssistantRequestsCount(count?: number): ({ dispatch }: {
|
|
29
29
|
dispatch: any;
|
|
@@ -11,7 +11,7 @@ import { ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, ACTION_REQUEST_AI_ASSISTAN
|
|
|
11
11
|
* Map the response from the `sites/$site/ai-assistant-feature`
|
|
12
12
|
* endpoint to the AI Assistant feature props.
|
|
13
13
|
* @param { AiAssistantFeatureEndpointResponseProps } response - The response from the endpoint.
|
|
14
|
-
* @
|
|
14
|
+
* @return { AiFeatureProps } The AI Assistant feature props.
|
|
15
15
|
*/
|
|
16
16
|
export function mapAiFeatureResponseToAiFeatureProps(response) {
|
|
17
17
|
return {
|
|
@@ -43,7 +43,7 @@ const actions = {
|
|
|
43
43
|
},
|
|
44
44
|
/**
|
|
45
45
|
* Thunk action to fetch the AI Assistant feature from the API.
|
|
46
|
-
* @
|
|
46
|
+
* @return {Function} The thunk action.
|
|
47
47
|
*/
|
|
48
48
|
fetchAiAssistantFeature() {
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -68,7 +68,7 @@ const actions = {
|
|
|
68
68
|
* This thunk action is used to increase
|
|
69
69
|
* the requests count for the current usage period.
|
|
70
70
|
* @param {number} count - The number of requests to increase. Default is 1.
|
|
71
|
-
* @
|
|
71
|
+
* @return {Function} The thunk action.
|
|
72
72
|
*/
|
|
73
73
|
increaseAiAssistantRequestsCount(count = 1) {
|
|
74
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3,28 +3,28 @@ import type { SiteDetails } from '../types.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Reducer for the Logo Generator store.
|
|
5
5
|
*
|
|
6
|
-
* @param {LogoGeneratorStateProp}
|
|
7
|
-
* @param {object}
|
|
8
|
-
* @param {string}
|
|
9
|
-
* @param {AiFeatureStateProps}
|
|
10
|
-
* @param {number}
|
|
11
|
-
* @param {boolean}
|
|
12
|
-
* @param {boolean}
|
|
13
|
-
* @param {SiteDetails}
|
|
14
|
-
* @param {number}
|
|
15
|
-
* @param {boolean}
|
|
16
|
-
* @param {boolean}
|
|
17
|
-
* @param {object}
|
|
18
|
-
* @param {string}
|
|
19
|
-
* @param {string}
|
|
20
|
-
* @param {number}
|
|
21
|
-
* @param {string}
|
|
22
|
-
* @param {boolean}
|
|
23
|
-
* @param {boolean}
|
|
24
|
-
* @param {Array< { url: string; description: string; mediaId?: number } >} action.history
|
|
25
|
-
* @param {RequestError}
|
|
26
|
-
* @param {string}
|
|
27
|
-
* @
|
|
6
|
+
* @param {LogoGeneratorStateProp} state - The current state
|
|
7
|
+
* @param {object} action - The action to apply, as described by the properties below
|
|
8
|
+
* @param {string} action.type - The action type
|
|
9
|
+
* @param {AiFeatureStateProps} action.feature - The AI Assistant feature state
|
|
10
|
+
* @param {number} action.count - The number of requests to increase the counter by
|
|
11
|
+
* @param {boolean} action.requireUpgrade - Whether an upgrade is required
|
|
12
|
+
* @param {boolean} action.tierPlansEnabled - Whether tier plans are enabled
|
|
13
|
+
* @param {SiteDetails} action.siteDetails - The site details
|
|
14
|
+
* @param {number} action.selectedLogoIndex - The selected logo index
|
|
15
|
+
* @param {boolean} action.isSavingLogoToLibrary - Whether a logo is being saved to the library
|
|
16
|
+
* @param {boolean} action.isApplyingLogo - Whether a logo is being applied
|
|
17
|
+
* @param {object} action.logo - The logo to save, as described by the properties below
|
|
18
|
+
* @param {string} action.logo.url - The logo URL
|
|
19
|
+
* @param {string} action.logo.description - The logo description
|
|
20
|
+
* @param {number} action.mediaId - The media ID from backend
|
|
21
|
+
* @param {string} action.url - The URL to save
|
|
22
|
+
* @param {boolean} action.isRequestingImage - Whether an image is being requested
|
|
23
|
+
* @param {boolean} action.isEnhancingPrompt - Whether a prompt enhancement is being requested
|
|
24
|
+
* @param {Array< { url: string; description: string; mediaId?: number } >} action.history - The logo history
|
|
25
|
+
* @param {RequestError} action.error - The error to set
|
|
26
|
+
* @param {string} action.context - The context where the tool is being used
|
|
27
|
+
* @return {LogoGeneratorStateProp} The new state
|
|
28
28
|
*/
|
|
29
29
|
export default function reducer(state: LogoGeneratorStateProp, action: {
|
|
30
30
|
type: string;
|
|
@@ -7,28 +7,28 @@ import INITIAL_STATE from './initial-state.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* Reducer for the Logo Generator store.
|
|
9
9
|
*
|
|
10
|
-
* @param {LogoGeneratorStateProp}
|
|
11
|
-
* @param {object}
|
|
12
|
-
* @param {string}
|
|
13
|
-
* @param {AiFeatureStateProps}
|
|
14
|
-
* @param {number}
|
|
15
|
-
* @param {boolean}
|
|
16
|
-
* @param {boolean}
|
|
17
|
-
* @param {SiteDetails}
|
|
18
|
-
* @param {number}
|
|
19
|
-
* @param {boolean}
|
|
20
|
-
* @param {boolean}
|
|
21
|
-
* @param {object}
|
|
22
|
-
* @param {string}
|
|
23
|
-
* @param {string}
|
|
24
|
-
* @param {number}
|
|
25
|
-
* @param {string}
|
|
26
|
-
* @param {boolean}
|
|
27
|
-
* @param {boolean}
|
|
28
|
-
* @param {Array< { url: string; description: string; mediaId?: number } >} action.history
|
|
29
|
-
* @param {RequestError}
|
|
30
|
-
* @param {string}
|
|
31
|
-
* @
|
|
10
|
+
* @param {LogoGeneratorStateProp} state - The current state
|
|
11
|
+
* @param {object} action - The action to apply, as described by the properties below
|
|
12
|
+
* @param {string} action.type - The action type
|
|
13
|
+
* @param {AiFeatureStateProps} action.feature - The AI Assistant feature state
|
|
14
|
+
* @param {number} action.count - The number of requests to increase the counter by
|
|
15
|
+
* @param {boolean} action.requireUpgrade - Whether an upgrade is required
|
|
16
|
+
* @param {boolean} action.tierPlansEnabled - Whether tier plans are enabled
|
|
17
|
+
* @param {SiteDetails} action.siteDetails - The site details
|
|
18
|
+
* @param {number} action.selectedLogoIndex - The selected logo index
|
|
19
|
+
* @param {boolean} action.isSavingLogoToLibrary - Whether a logo is being saved to the library
|
|
20
|
+
* @param {boolean} action.isApplyingLogo - Whether a logo is being applied
|
|
21
|
+
* @param {object} action.logo - The logo to save, as described by the properties below
|
|
22
|
+
* @param {string} action.logo.url - The logo URL
|
|
23
|
+
* @param {string} action.logo.description - The logo description
|
|
24
|
+
* @param {number} action.mediaId - The media ID from backend
|
|
25
|
+
* @param {string} action.url - The URL to save
|
|
26
|
+
* @param {boolean} action.isRequestingImage - Whether an image is being requested
|
|
27
|
+
* @param {boolean} action.isEnhancingPrompt - Whether a prompt enhancement is being requested
|
|
28
|
+
* @param {Array< { url: string; description: string; mediaId?: number } >} action.history - The logo history
|
|
29
|
+
* @param {RequestError} action.error - The error to set
|
|
30
|
+
* @param {string} action.context - The context where the tool is being used
|
|
31
|
+
* @return {LogoGeneratorStateProp} The new state
|
|
32
32
|
*/
|
|
33
33
|
export default function reducer(state = INITIAL_STATE, action) {
|
|
34
34
|
switch (action.type) {
|