@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.
Files changed (94) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/ask-question/index.d.ts +3 -3
  3. package/build/ask-question/index.js +3 -3
  4. package/build/ask-question/sync.d.ts +3 -3
  5. package/build/ask-question/sync.js +3 -3
  6. package/build/audio-transcription/index.d.ts +3 -3
  7. package/build/audio-transcription/index.js +3 -3
  8. package/build/components/ai-control/ai-control.d.ts +1 -1
  9. package/build/components/ai-control/ai-control.js +1 -1
  10. package/build/components/ai-control/block-ai-control.d.ts +3 -3
  11. package/build/components/ai-control/block-ai-control.js +3 -3
  12. package/build/components/ai-control/extension-ai-control.d.ts +3 -3
  13. package/build/components/ai-control/extension-ai-control.js +3 -3
  14. package/build/components/ai-status-indicator/index.d.ts +1 -1
  15. package/build/components/ai-status-indicator/index.js +1 -1
  16. package/build/components/audio-duration-display/index.d.ts +1 -1
  17. package/build/components/audio-duration-display/index.js +1 -1
  18. package/build/components/audio-duration-display/lib/media.d.ts +2 -2
  19. package/build/components/audio-duration-display/lib/media.js +2 -2
  20. package/build/components/message/index.d.ts +4 -4
  21. package/build/components/message/index.js +4 -4
  22. package/build/data-flow/context.d.ts +2 -2
  23. package/build/data-flow/context.js +2 -2
  24. package/build/data-flow/use-ai-context.d.ts +1 -1
  25. package/build/data-flow/use-ai-context.js +1 -1
  26. package/build/data-flow/with-ai-assistant-data.d.ts +1 -1
  27. package/build/data-flow/with-ai-assistant-data.js +1 -1
  28. package/build/hooks/use-ai-suggestions/index.d.ts +3 -3
  29. package/build/hooks/use-ai-suggestions/index.js +11 -11
  30. package/build/hooks/use-audio-transcription/index.d.ts +1 -1
  31. package/build/hooks/use-audio-transcription/index.js +2 -2
  32. package/build/hooks/use-audio-validation/index.d.ts +1 -1
  33. package/build/hooks/use-audio-validation/index.js +1 -1
  34. package/build/hooks/use-image-generator/index.js +9 -9
  35. package/build/hooks/use-media-recording/index.d.ts +1 -1
  36. package/build/hooks/use-media-recording/index.js +4 -4
  37. package/build/hooks/use-save-to-media-library/index.d.ts +1 -1
  38. package/build/hooks/use-save-to-media-library/index.js +1 -1
  39. package/build/hooks/use-transcription-post-processing/index.d.ts +1 -1
  40. package/build/hooks/use-transcription-post-processing/index.js +1 -1
  41. package/build/jwt/index.d.ts +1 -1
  42. package/build/jwt/index.js +1 -1
  43. package/build/libs/markdown/html-to-markdown.d.ts +1 -1
  44. package/build/libs/markdown/html-to-markdown.js +1 -1
  45. package/build/libs/markdown/markdown-to-html.d.ts +4 -4
  46. package/build/libs/markdown/markdown-to-html.js +4 -4
  47. package/build/logo-generator/lib/logo-storage.d.ts +17 -17
  48. package/build/logo-generator/lib/logo-storage.js +17 -17
  49. package/build/logo-generator/lib/media-exists.d.ts +2 -2
  50. package/build/logo-generator/lib/media-exists.js +2 -2
  51. package/build/logo-generator/lib/set-site-logo.d.ts +3 -3
  52. package/build/logo-generator/lib/set-site-logo.js +3 -3
  53. package/build/logo-generator/lib/wpcom-limited-request.d.ts +1 -1
  54. package/build/logo-generator/lib/wpcom-limited-request.js +1 -1
  55. package/build/logo-generator/store/actions.d.ts +3 -3
  56. package/build/logo-generator/store/actions.js +3 -3
  57. package/build/logo-generator/store/reducer.d.ts +22 -22
  58. package/build/logo-generator/store/reducer.js +22 -22
  59. package/build/logo-generator/store/selectors.d.ts +20 -20
  60. package/build/logo-generator/store/selectors.js +20 -20
  61. package/build/suggestions-event-source/index.d.ts +1 -1
  62. package/build/suggestions-event-source/index.js +1 -1
  63. package/package.json +22 -21
  64. package/src/ask-question/index.ts +3 -3
  65. package/src/ask-question/sync.ts +3 -3
  66. package/src/audio-transcription/index.ts +3 -3
  67. package/src/components/ai-control/ai-control.tsx +1 -1
  68. package/src/components/ai-control/block-ai-control.tsx +3 -3
  69. package/src/components/ai-control/extension-ai-control.tsx +3 -3
  70. package/src/components/ai-status-indicator/index.tsx +1 -1
  71. package/src/components/audio-duration-display/index.tsx +1 -1
  72. package/src/components/audio-duration-display/lib/media.ts +2 -2
  73. package/src/components/message/index.tsx +4 -4
  74. package/src/data-flow/context.tsx +2 -2
  75. package/src/data-flow/use-ai-context.ts +1 -1
  76. package/src/data-flow/with-ai-assistant-data.tsx +1 -1
  77. package/src/hooks/use-ai-suggestions/index.ts +11 -11
  78. package/src/hooks/use-audio-transcription/index.ts +2 -2
  79. package/src/hooks/use-audio-validation/index.ts +1 -1
  80. package/src/hooks/use-image-generator/index.ts +9 -9
  81. package/src/hooks/use-media-recording/index.ts +4 -4
  82. package/src/hooks/use-save-to-media-library/index.ts +1 -1
  83. package/src/hooks/use-transcription-post-processing/index.ts +1 -1
  84. package/src/jwt/index.ts +1 -1
  85. package/src/libs/markdown/html-to-markdown.ts +1 -1
  86. package/src/libs/markdown/markdown-to-html.ts +4 -4
  87. package/src/logo-generator/lib/logo-storage.ts +17 -17
  88. package/src/logo-generator/lib/media-exists.ts +2 -2
  89. package/src/logo-generator/lib/set-site-logo.ts +3 -3
  90. package/src/logo-generator/lib/wpcom-limited-request.ts +1 -1
  91. package/src/logo-generator/store/actions.ts +3 -3
  92. package/src/logo-generator/store/reducer.ts +22 -22
  93. package/src/logo-generator/store/selectors.ts +20 -20
  94. package/src/suggestions-event-source/index.ts +1 -1
@@ -134,7 +134,7 @@ type useAiSuggestionsProps = {
134
134
  * Get the error data for a given error code.
135
135
  *
136
136
  * @param {SuggestionErrorCode} errorCode - The error code.
137
- * @returns {RequestingErrorProps} The error data.
137
+ * @return {RequestingErrorProps} The error data.
138
138
  */
139
139
  export function getErrorData( errorCode: SuggestionErrorCode ): RequestingErrorProps {
140
140
  switch ( errorCode ) {
@@ -194,7 +194,7 @@ export function getErrorData( errorCode: SuggestionErrorCode ): RequestingErrorP
194
194
  * Remove the llama artifact from a suggestion.
195
195
  *
196
196
  * @param {string} suggestion - The suggestion.
197
- * @returns {string} The suggestion without the llama artifact.
197
+ * @return {string} The suggestion without the llama artifact.
198
198
  */
199
199
  export function removeLlamaArtifact( suggestion: string ): string {
200
200
  return suggestion.replace( /^<\|start_header_id\|>assistant<\|end_header_id\|>[\n]+/, '' );
@@ -205,7 +205,7 @@ export function removeLlamaArtifact( suggestion: string ): string {
205
205
  * by hitting the query endpoint.
206
206
  *
207
207
  * @param {useAiSuggestionsOptions} options - The options for the hook.
208
- * @returns {useAiSuggestionsProps} The props for the hook.
208
+ * @return {useAiSuggestionsProps} The props for the hook.
209
209
  */
210
210
  export default function useAiSuggestions( {
211
211
  prompt,
@@ -230,7 +230,7 @@ export default function useAiSuggestions( {
230
230
  * onSuggestion function handler.
231
231
  *
232
232
  * @param {string} suggestion - The suggestion.
233
- * @returns {void}
233
+ * @return {void}
234
234
  */
235
235
  const handleSuggestion = useCallback(
236
236
  ( event: CustomEvent ) => {
@@ -250,7 +250,7 @@ export default function useAiSuggestions( {
250
250
  * onDone function handler.
251
251
  *
252
252
  * @param {string} content - The content.
253
- * @returns {void}
253
+ * @return {void}
254
254
  */
255
255
  const handleDone = useCallback(
256
256
  ( event: CustomEvent ) => {
@@ -300,9 +300,9 @@ export default function useAiSuggestions( {
300
300
  /**
301
301
  * Request handler.
302
302
  *
303
- * @param {PromptProp} promptArg - The messages array of the prompt.
304
- * @param {AskQuestionOptionsArgProps} options - The options for the askQuestion request. Uses the hook's askQuestionOptions by default.
305
- * @returns {Promise<void>} The promise.
303
+ * @param {PromptProp} promptArg - The messages array of the prompt.
304
+ * @param {AskQuestionOptionsArgProps} options - The options for the askQuestion request. Uses the hook's askQuestionOptions by default.
305
+ * @return {Promise<void>} The promise.
306
306
  */
307
307
  const request = useCallback(
308
308
  async (
@@ -352,7 +352,7 @@ export default function useAiSuggestions( {
352
352
  /**
353
353
  * Reset the request state.
354
354
  *
355
- * @returns {void}
355
+ * @return {void}
356
356
  */
357
357
  const reset = useCallback( () => {
358
358
  setRequestingState( 'init' );
@@ -363,7 +363,7 @@ export default function useAiSuggestions( {
363
363
  /**
364
364
  * Close the event source connection.
365
365
  *
366
- * @returns {void}
366
+ * @return {void}
367
367
  */
368
368
  const closeEventSource = useCallback( () => {
369
369
  if ( ! eventSourceRef?.current ) {
@@ -400,7 +400,7 @@ export default function useAiSuggestions( {
400
400
  /**
401
401
  * Stop suggestion handler.
402
402
  *
403
- * @returns {void}
403
+ * @return {void}
404
404
  */
405
405
  const stopSuggestion = useCallback( () => {
406
406
  closeEventSource();
@@ -49,7 +49,7 @@ type AudioTranscriptionErrorResponse = {
49
49
  /**
50
50
  * Map error response to a string.
51
51
  * @param {Error | string | AudioTranscriptionErrorResponse} error - The error response from the audio transcription service.
52
- * @returns {string} the translated error message
52
+ * @return {string} the translated error message
53
53
  */
54
54
  const mapErrorResponse = ( error: Error | string | AudioTranscriptionErrorResponse ): string => {
55
55
  if ( typeof error === 'string' ) {
@@ -92,7 +92,7 @@ const mapErrorResponse = ( error: Error | string | AudioTranscriptionErrorRespon
92
92
  * A hook to handle audio transcription.
93
93
  *
94
94
  * @param {string} feature - The feature name that is calling the transcription.
95
- * @returns {UseAudioTranscriptionReturn} - Object with properties to get the transcription data.
95
+ * @return {UseAudioTranscriptionReturn} - Object with properties to get the transcription data.
96
96
  */
97
97
  export default function useAudioTranscription( {
98
98
  feature,
@@ -45,7 +45,7 @@ export type ValidatedAudioInformation = {
45
45
  /**
46
46
  * Hook to handle the validation of an audio file.
47
47
  *
48
- * @returns {UseAudioValidationReturn} - Object with the audio validation state and the function to validate the audio.
48
+ * @return {UseAudioValidationReturn} - Object with the audio validation state and the function to validate the audio.
49
49
  */
50
50
  export default function useAudioValidation(): UseAudioValidationReturn {
51
51
  const [ isValidatingAudio, setIsValidatingAudio ] = useState< boolean >( false );
@@ -19,9 +19,9 @@ type ImageGenerationResponse = {
19
19
 
20
20
  /**
21
21
  * Cut the post content on a given lenght so the total length of the prompt is not longer than 4000 characters.
22
- * @param {string} content - the content to be truncated
22
+ * @param {string} content - the content to be truncated
23
23
  * @param {number} currentPromptLength - the length of the prompt already in use
24
- * @returns {string} a truncated version of the content respecting the prompt length limit
24
+ * @return {string} a truncated version of the content respecting the prompt length limit
25
25
  */
26
26
  const truncateContent = ( content: string, currentPromptLength: number ): string => {
27
27
  const maxLength = 4000;
@@ -35,8 +35,8 @@ const truncateContent = ( content: string, currentPromptLength: number ): string
35
35
  /**
36
36
  * Create the prompt string based on the provided context.
37
37
  * @param {string} postContent - the content of the post
38
- * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated.
39
- * @returns {string} the prompt string
38
+ * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated.
39
+ * @return {string} the prompt string
40
40
  */
41
41
  const getDalleImageGenerationPrompt = ( postContent: string, userPrompt?: string ): string => {
42
42
  /**
@@ -89,8 +89,8 @@ This is the post content:
89
89
  /**
90
90
  * Create the Stable Diffusion pre-processing prompt based on the provided context.
91
91
  * @param {string} postContent - the content of the post.
92
- * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated.
93
- * @returns {string} the prompt string to be fed to the AI Assistant model.
92
+ * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated.
93
+ * @return {string} the prompt string to be fed to the AI Assistant model.
94
94
  */
95
95
  const getStableDiffusionPreProcessingPrompt = (
96
96
  postContent: string,
@@ -134,9 +134,9 @@ Return just the prompt, without comments. The content is:
134
134
  /**
135
135
  * Uses the Jetpack AI query endpoint to produce a prompt for the stable diffusion model.
136
136
  * @param {string} postContent - the content of the post.
137
- * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated
138
- * @param {string} feature - the feature to be used for the image generation.
139
- * @returns {string} the prompt string to be used on stable diffusion image generation.
137
+ * @param {string} userPrompt - the user prompt for the image generation, if provided. Max length is 1000 characters, will be truncated
138
+ * @param {string} feature - the feature to be used for the image generation.
139
+ * @return {string} the prompt string to be used on stable diffusion image generation.
140
140
  */
141
141
  const getStableDiffusionImageGenerationPrompt = async (
142
142
  postContent: string,
@@ -84,7 +84,7 @@ type MediaRecorderEvent = {
84
84
  * react custom hook to handle media recording.
85
85
  *
86
86
  * @param {UseMediaRecordingProps} props - The props
87
- * @returns {UseMediaRecordingReturn} The media recorder instance
87
+ * @return {UseMediaRecordingReturn} The media recorder instance
88
88
  */
89
89
  export default function useMediaRecording( {
90
90
  onDone,
@@ -118,7 +118,7 @@ export default function useMediaRecording( {
118
118
  /**
119
119
  * Get the recorded blob.
120
120
  *
121
- * @returns {Blob} The recorded blob
121
+ * @return {Blob} The recorded blob
122
122
  */
123
123
  function getBlob() {
124
124
  if ( MediaRecorder.isTypeSupported( MEDIA_TYPE_MP4_MP4A ) ) {
@@ -265,7 +265,7 @@ export default function useMediaRecording( {
265
265
  * `stop` event listener for the media recorder instance.
266
266
  * Happens after the last `dataavailable` event.
267
267
  *
268
- * @returns {void}
268
+ * @return {void}
269
269
  */
270
270
  function onStopListener(): void {
271
271
  const lastBlob = getBlob();
@@ -293,7 +293,7 @@ export default function useMediaRecording( {
293
293
  * `dataavailable` event listener for the media recorder instance.
294
294
  *
295
295
  * @param {MediaRecorderEvent} event - The event object
296
- * @returns {void}
296
+ * @return {void}
297
297
  */
298
298
  function onDataAvailableListener( event: MediaRecorderEvent ): void {
299
299
  const { data } = event;
@@ -15,7 +15,7 @@ const debug = debugFactory( 'ai-client:save-to-media-library' );
15
15
  /**
16
16
  * Hook to save an image to the media library.
17
17
  *
18
- * @returns {object} Object with the loading state and the function to save the image to the media library.
18
+ * @return {object} Object with the loading state and the function to save the image to the media library.
19
19
  */
20
20
  export default function useSaveToMediaLibrary() {
21
21
  const [ isLoading, setIsLoading ] = useState( false );
@@ -42,7 +42,7 @@ export type UseTranscriptionPostProcessingProps = {
42
42
  * A hook to handle transcription post-processing.
43
43
  *
44
44
  * @param {string} feature - The feature name that is calling the post-processing actions.
45
- * @returns {UseTranscriptionPostProcessingReturn} - Object with properties to get the post-processing results.
45
+ * @return {UseTranscriptionPostProcessingReturn} - Object with properties to get the post-processing results.
46
46
  */
47
47
  export default function useTranscriptionPostProcessing( {
48
48
  feature,
package/src/jwt/index.ts CHANGED
@@ -37,7 +37,7 @@ const JWT_TOKEN_EXPIRATION_TIME = 2 * 60 * 1000; // 2 minutes
37
37
  * Request a token from the Jetpack site.
38
38
  *
39
39
  * @param {RequestTokenOptions} options - Options
40
- * @returns {Promise<TokenDataProps>} The token and the blogId
40
+ * @return {Promise<TokenDataProps>} The token and the blogId
41
41
  */
42
42
  export default async function requestJwt( {
43
43
  apiNonce,
@@ -61,7 +61,7 @@ export default class HTMLToMarkdown {
61
61
  * Renders HTML from Markdown content with specified processing rules.
62
62
  * @param {object} options - The options to use when rendering the Markdown content
63
63
  * @param {string} options.content - The HTML content to render
64
- * @returns {string} The rendered Markdown content
64
+ * @return {string} The rendered Markdown content
65
65
  */
66
66
  render( { content }: { content: string } ): string {
67
67
  const rendered = this.turndownService.turndown( content );
@@ -96,11 +96,11 @@ export default class MarkdownToHTML {
96
96
 
97
97
  /**
98
98
  * Renders HTML from Markdown content with specified processing rules.
99
- * @param {object} options - The options to use when rendering the HTML content
100
- * @param {string} options.content - The Markdown content to render
101
- * @param {string} options.rules - The rules to apply to the rendered content
99
+ * @param {object} options - The options to use when rendering the HTML content
100
+ * @param {string} options.content - The Markdown content to render
101
+ * @param {string} options.rules - The rules to apply to the rendered content
102
102
  * @param {boolean} options.extension - Whether to apply the extension-specific rules
103
- * @returns {string} The rendered HTML content
103
+ * @return {string} The rendered HTML content
104
104
  */
105
105
  render( {
106
106
  content,
@@ -10,13 +10,13 @@ const MAX_LOGOS = 10;
10
10
  /**
11
11
  * Add an entry to the site's logo history.
12
12
  *
13
- * @param {SaveToStorageProps} saveToStorageProps - The properties to save to storage
14
- * @param {SaveToStorageProps.siteId} saveToStorageProps.siteId - The site ID
15
- * @param {SaveToStorageProps.url} saveToStorageProps.url - The URL of the logo
13
+ * @param {SaveToStorageProps} saveToStorageProps - The properties to save to storage
14
+ * @param {SaveToStorageProps.siteId} saveToStorageProps.siteId - The site ID
15
+ * @param {SaveToStorageProps.url} saveToStorageProps.url - The URL of the logo
16
16
  * @param {SaveToStorageProps.description} saveToStorageProps.description - The description of the logo, based on the prompt used to generate it
17
- * @param {SaveToStorageProps.mediaId} saveToStorageProps.mediaId - The media ID of the logo on the backend
17
+ * @param {SaveToStorageProps.mediaId} saveToStorageProps.mediaId - The media ID of the logo on the backend
18
18
  *
19
- * @returns {Logo} The logo that was saved
19
+ * @return {Logo} The logo that was saved
20
20
  */
21
21
  export function stashLogo( { siteId, url, description, mediaId }: SaveToStorageProps ) {
22
22
  const storedContent = getSiteLogoHistory( siteId );
@@ -40,12 +40,12 @@ export function stashLogo( { siteId, url, description, mediaId }: SaveToStorageP
40
40
  /**
41
41
  * Update an entry in the site's logo history.
42
42
  *
43
- * @param {UpdateInStorageProps} updateInStorageProps - The properties to update in storage
44
- * @param {UpdateInStorageProps.siteId} updateInStorageProps.siteId - The site ID
45
- * @param {UpdateInStorageProps.url} updateInStorageProps.url - The URL of the logo to update
46
- * @param {UpdateInStorageProps.newUrl} updateInStorageProps.newUrl - The new URL of the logo
43
+ * @param {UpdateInStorageProps} updateInStorageProps - The properties to update in storage
44
+ * @param {UpdateInStorageProps.siteId} updateInStorageProps.siteId - The site ID
45
+ * @param {UpdateInStorageProps.url} updateInStorageProps.url - The URL of the logo to update
46
+ * @param {UpdateInStorageProps.newUrl} updateInStorageProps.newUrl - The new URL of the logo
47
47
  * @param {UpdateInStorageProps.mediaId} updateInStorageProps.mediaId - The new media ID of the logo
48
- * @returns {Logo} The logo that was updated
48
+ * @return {Logo} The logo that was updated
49
49
  */
50
50
  export function updateLogo( { siteId, url, newUrl, mediaId }: UpdateInStorageProps ) {
51
51
  const storedContent = getSiteLogoHistory( siteId );
@@ -69,7 +69,7 @@ export function updateLogo( { siteId, url, newUrl, mediaId }: UpdateInStoragePro
69
69
  * Get the logo history for a site.
70
70
  *
71
71
  * @param {string} siteId - The site ID to get the logo history for
72
- * @returns {Logo[]} The logo history for the site
72
+ * @return {Logo[]} The logo history for the site
73
73
  */
74
74
  export function getSiteLogoHistory( siteId: string ) {
75
75
  const storedString = localStorage.getItem( `logo-history-${ siteId }` );
@@ -104,8 +104,8 @@ export function getSiteLogoHistory( siteId: string ) {
104
104
  /**
105
105
  * Check if the logo history for a site is empty.
106
106
  *
107
- * @param {string }siteId - The site ID to check the logo history for
108
- * @returns {boolean} Whether the logo history for the site is empty
107
+ * @param {string } siteId - The site ID to check the logo history for
108
+ * @return {boolean} Whether the logo history for the site is empty
109
109
  */
110
110
  export function isLogoHistoryEmpty( siteId: string ) {
111
111
  const storedContent = getSiteLogoHistory( siteId );
@@ -116,10 +116,10 @@ export function isLogoHistoryEmpty( siteId: string ) {
116
116
  /**
117
117
  * Remove an entry from the site's logo history.
118
118
  *
119
- * @param {RemoveFromStorageProps} removeFromStorageProps - The properties to remove from storage
120
- * @param {RemoveFromStorageProps.siteId} removeFromStorageProps.siteId - The site ID
119
+ * @param {RemoveFromStorageProps} removeFromStorageProps - The properties to remove from storage
120
+ * @param {RemoveFromStorageProps.siteId} removeFromStorageProps.siteId - The site ID
121
121
  * @param {RemoveFromStorageProps.mediaId} removeFromStorageProps.mediaId - The media ID of the logo to remove
122
- * @returns {void}
122
+ * @return {void}
123
123
  */
124
124
  export function removeLogo( { siteId, mediaId }: RemoveFromStorageProps ) {
125
125
  const storedContent = getSiteLogoHistory( siteId );
@@ -137,7 +137,7 @@ export function removeLogo( { siteId, mediaId }: RemoveFromStorageProps ) {
137
137
  * Clear deleted media from the site's logo history, checking if the media still exists on the backend.
138
138
  *
139
139
  * @param {string} siteId - The site ID to clear deleted media for
140
- * @returns {Promise<void>}
140
+ * @return {Promise<void>}
141
141
  */
142
142
  export async function clearDeletedMedia( siteId: string ) {
143
143
  const storedContent = getSiteLogoHistory( siteId );
@@ -10,9 +10,9 @@ import type { CheckMediaProps } from '../types.js';
10
10
  /**
11
11
  * Uses the media information to confirm it exists or not on the server.
12
12
  *
13
- * @param {CheckMediaProps} checkMediaProps - the media details to check
13
+ * @param {CheckMediaProps} checkMediaProps - the media details to check
14
14
  * @param {CheckMediaProps.mediaId} checkMediaProps.mediaId - the id of the media to check
15
- * @returns {Promise<boolean>} - true if the media exists, false otherwise
15
+ * @return {Promise<boolean>} - true if the media exists, false otherwise
16
16
  */
17
17
  export async function mediaExists( { mediaId }: CheckMediaProps ): Promise< boolean > {
18
18
  const id = Number( mediaId );
@@ -10,10 +10,10 @@ import type { SetSiteLogoProps, SetSiteLogoResponseProps } from '../types.js';
10
10
  /**
11
11
  * Set the site logo using a backend request.
12
12
  *
13
- * @param {SetSiteLogoProps} setSiteLogoProps - The properties to set the site logo
14
- * @param {SetSiteLogoProps.siteId} setSiteLogoProps.siteId - The site ID
13
+ * @param {SetSiteLogoProps} setSiteLogoProps - The properties to set the site logo
14
+ * @param {SetSiteLogoProps.siteId} setSiteLogoProps.siteId - The site ID
15
15
  * @param {SetSiteLogoProps.imageId} setSiteLogoProps.imageId - The image ID to set as the site logo
16
- * @returns {Promise<SetSiteLogoResponseProps>} The response from the request
16
+ * @return {Promise<SetSiteLogoResponseProps>} The response from the request
17
17
  */
18
18
  export async function setSiteLogo( { siteId, imageId }: SetSiteLogoProps ) {
19
19
  const body = {
@@ -13,7 +13,7 @@ let concurrentCounter = 0;
13
13
  /**
14
14
  * Concurrency-limited request to wpcom-proxy-request.
15
15
  * @param { object } params - The request params, as expected by apiFetch.
16
- * @returns { Promise } The response.
16
+ * @return { Promise } The response.
17
17
  * @throws { Error } If there are too many concurrent requests.
18
18
  */
19
19
  export default async function wpcomLimitedRequest< T >( params: object ): Promise< T > {
@@ -41,7 +41,7 @@ import type { SiteDetails } from '../types.js';
41
41
  * Map the response from the `sites/$site/ai-assistant-feature`
42
42
  * endpoint to the AI Assistant feature props.
43
43
  * @param { AiAssistantFeatureEndpointResponseProps } response - The response from the endpoint.
44
- * @returns { AiFeatureProps } The AI Assistant feature props.
44
+ * @return { AiFeatureProps } The AI Assistant feature props.
45
45
  */
46
46
  export function mapAiFeatureResponseToAiFeatureProps(
47
47
  response: AiAssistantFeatureEndpointResponseProps
@@ -77,7 +77,7 @@ const actions = {
77
77
 
78
78
  /**
79
79
  * Thunk action to fetch the AI Assistant feature from the API.
80
- * @returns {Function} The thunk action.
80
+ * @return {Function} The thunk action.
81
81
  */
82
82
  fetchAiAssistantFeature() {
83
83
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -106,7 +106,7 @@ const actions = {
106
106
  * This thunk action is used to increase
107
107
  * the requests count for the current usage period.
108
108
  * @param {number} count - The number of requests to increase. Default is 1.
109
- * @returns {Function} The thunk action.
109
+ * @return {Function} The thunk action.
110
110
  */
111
111
  increaseAiAssistantRequestsCount( count: number = 1 ) {
112
112
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -40,28 +40,28 @@ import type { SiteDetails } from '../types.js';
40
40
  /**
41
41
  * Reducer for the Logo Generator store.
42
42
  *
43
- * @param {LogoGeneratorStateProp} state - The current state
44
- * @param {object} action - The action to apply, as described by the properties below
45
- * @param {string} action.type - The action type
46
- * @param {AiFeatureStateProps} action.feature - The AI Assistant feature state
47
- * @param {number} action.count - The number of requests to increase the counter by
48
- * @param {boolean} action.requireUpgrade - Whether an upgrade is required
49
- * @param {boolean} action.tierPlansEnabled - Whether tier plans are enabled
50
- * @param {SiteDetails} action.siteDetails - The site details
51
- * @param {number} action.selectedLogoIndex - The selected logo index
52
- * @param {boolean} action.isSavingLogoToLibrary - Whether a logo is being saved to the library
53
- * @param {boolean} action.isApplyingLogo - Whether a logo is being applied
54
- * @param {object} action.logo - The logo to save, as described by the properties below
55
- * @param {string} action.logo.url - The logo URL
56
- * @param {string} action.logo.description - The logo description
57
- * @param {number} action.mediaId - The media ID from backend
58
- * @param {string} action.url - The URL to save
59
- * @param {boolean} action.isRequestingImage - Whether an image is being requested
60
- * @param {boolean} action.isEnhancingPrompt - Whether a prompt enhancement is being requested
61
- * @param {Array< { url: string; description: string; mediaId?: number } >} action.history - The logo history
62
- * @param {RequestError} action.error - The error to set
63
- * @param {string} action.context - The context where the tool is being used
64
- * @returns {LogoGeneratorStateProp} The new state
43
+ * @param {LogoGeneratorStateProp} state - The current state
44
+ * @param {object} action - The action to apply, as described by the properties below
45
+ * @param {string} action.type - The action type
46
+ * @param {AiFeatureStateProps} action.feature - The AI Assistant feature state
47
+ * @param {number} action.count - The number of requests to increase the counter by
48
+ * @param {boolean} action.requireUpgrade - Whether an upgrade is required
49
+ * @param {boolean} action.tierPlansEnabled - Whether tier plans are enabled
50
+ * @param {SiteDetails} action.siteDetails - The site details
51
+ * @param {number} action.selectedLogoIndex - The selected logo index
52
+ * @param {boolean} action.isSavingLogoToLibrary - Whether a logo is being saved to the library
53
+ * @param {boolean} action.isApplyingLogo - Whether a logo is being applied
54
+ * @param {object} action.logo - The logo to save, as described by the properties below
55
+ * @param {string} action.logo.url - The logo URL
56
+ * @param {string} action.logo.description - The logo description
57
+ * @param {number} action.mediaId - The media ID from backend
58
+ * @param {string} action.url - The URL to save
59
+ * @param {boolean} action.isRequestingImage - Whether an image is being requested
60
+ * @param {boolean} action.isEnhancingPrompt - Whether a prompt enhancement is being requested
61
+ * @param {Array< { url: string; description: string; mediaId?: number } >} action.history - The logo history
62
+ * @param {RequestError} action.error - The error to set
63
+ * @param {string} action.context - The context where the tool is being used
64
+ * @return {LogoGeneratorStateProp} The new state
65
65
  */
66
66
  export default function reducer(
67
67
  state = INITIAL_STATE,
@@ -9,7 +9,7 @@ const selectors = {
9
9
  /**
10
10
  * Return the AI Assistant feature.
11
11
  * @param {LogoGeneratorStateProp} state - The app state tree.
12
- * @returns {Partial<AiFeatureProps>} The AI Assistant feature data.
12
+ * @return {Partial<AiFeatureProps>} The AI Assistant feature data.
13
13
  */
14
14
  getAiAssistantFeature( state: LogoGeneratorStateProp ): Partial< AiFeatureProps > {
15
15
  // Clean up the _meta property.
@@ -21,8 +21,8 @@ const selectors = {
21
21
 
22
22
  /**
23
23
  * Return the site details.
24
- * @param {LogoGeneratorStateProp} state - The app state tree.
25
- * @returns {Partial<SiteDetails> | undefined} The site details.
24
+ * @param {LogoGeneratorStateProp} state - The app state tree.
25
+ * @return {Partial<SiteDetails> | undefined} The site details.
26
26
  */
27
27
  getSiteDetails( state: LogoGeneratorStateProp ): Partial< SiteDetails > | undefined {
28
28
  return state.siteDetails;
@@ -31,7 +31,7 @@ const selectors = {
31
31
  /**
32
32
  * Get the isRequesting flag for the AI Assistant feature.
33
33
  * @param {LogoGeneratorStateProp} state - The app state tree.
34
- * @returns {boolean} The isRequesting flag.
34
+ * @return {boolean} The isRequesting flag.
35
35
  */
36
36
  getIsRequestingAiAssistantFeature( state: LogoGeneratorStateProp ): boolean {
37
37
  return state.features.aiAssistantFeature?._meta?.isRequesting ?? false;
@@ -40,7 +40,7 @@ const selectors = {
40
40
  /**
41
41
  * Get the logos history.
42
42
  * @param {LogoGeneratorStateProp} state - The app state tree.
43
- * @returns {Array<Logo>} The logos history array.
43
+ * @return {Array<Logo>} The logos history array.
44
44
  */
45
45
  getLogos( state: LogoGeneratorStateProp ): Array< Logo > {
46
46
  return state.history ?? [];
@@ -49,7 +49,7 @@ const selectors = {
49
49
  /**
50
50
  * Get the selected logo index.
51
51
  * @param {LogoGeneratorStateProp} state - The app state tree.
52
- * @returns {number | null} The selected logo index.
52
+ * @return {number | null} The selected logo index.
53
53
  */
54
54
  getSelectedLogoIndex( state: LogoGeneratorStateProp ): number | null {
55
55
  return state.selectedLogoIndex ?? null;
@@ -58,7 +58,7 @@ const selectors = {
58
58
  /**
59
59
  * Get the selected logo.
60
60
  * @param {LogoGeneratorStateProp} state - The app state tree.
61
- * @returns {Logo} The selected logo.
61
+ * @return {Logo} The selected logo.
62
62
  */
63
63
  getSelectedLogo( state: LogoGeneratorStateProp ): Logo {
64
64
  return state.history?.[ state.selectedLogoIndex ] ?? null;
@@ -67,7 +67,7 @@ const selectors = {
67
67
  /**
68
68
  * Get the isSavingToLibrary flag.
69
69
  * @param {LogoGeneratorStateProp} state - The app state tree.
70
- * @returns {boolean} The isSavingToLibrary flag.
70
+ * @return {boolean} The isSavingToLibrary flag.
71
71
  */
72
72
  getIsSavingLogoToLibrary( state: LogoGeneratorStateProp ): boolean {
73
73
  return state._meta?.isSavingLogoToLibrary ?? false;
@@ -76,7 +76,7 @@ const selectors = {
76
76
  /**
77
77
  * Get the isApplyingLogo flag.
78
78
  * @param {LogoGeneratorStateProp} state - The app state tree.
79
- * @returns {boolean} The isApplyingLogo flag.
79
+ * @return {boolean} The isApplyingLogo flag.
80
80
  */
81
81
  getIsApplyingLogo( state: LogoGeneratorStateProp ): boolean {
82
82
  return state._meta?.isApplyingLogo ?? false;
@@ -85,7 +85,7 @@ const selectors = {
85
85
  /**
86
86
  * Get the isEnhancingPrompt flag.
87
87
  * @param {LogoGeneratorStateProp} state - The app state tree.
88
- * @returns {boolean} The isEnhancingPrompt flag.
88
+ * @return {boolean} The isEnhancingPrompt flag.
89
89
  */
90
90
  getIsEnhancingPrompt( state: LogoGeneratorStateProp ): boolean {
91
91
  return state._meta?.isEnhancingPrompt ?? false;
@@ -94,7 +94,7 @@ const selectors = {
94
94
  /**
95
95
  * Get the isRequestingImage flag.
96
96
  * @param {LogoGeneratorStateProp} state - The app state tree.
97
- * @returns {boolean} The isRequestingImage flag.
97
+ * @return {boolean} The isRequestingImage flag.
98
98
  */
99
99
  getIsRequestingImage( state: LogoGeneratorStateProp ): boolean {
100
100
  return state._meta?.isRequestingImage ?? false;
@@ -103,7 +103,7 @@ const selectors = {
103
103
  /**
104
104
  * Get an aggregated isBusy flag, based on the loading states of the app.
105
105
  * @param {LogoGeneratorStateProp} state - The app state tree.
106
- * @returns {boolean} The isBusy flag.
106
+ * @return {boolean} The isBusy flag.
107
107
  */
108
108
  getIsBusy( state: LogoGeneratorStateProp ): boolean {
109
109
  return (
@@ -117,7 +117,7 @@ const selectors = {
117
117
  /**
118
118
  * Get the requireUpgrade value from aiAssistantFeature
119
119
  * @param {LogoGeneratorStateProp} state - The app state tree.
120
- * @returns {boolean} The requireUpgrade flag.
120
+ * @return {boolean} The requireUpgrade flag.
121
121
  */
122
122
  getRequireUpgrade( state: LogoGeneratorStateProp ): boolean {
123
123
  const feature = state.features.aiAssistantFeature;
@@ -137,7 +137,7 @@ const selectors = {
137
137
  /**
138
138
  * Get the featureFetchError value.
139
139
  * @param {LogoGeneratorStateProp} state - The app state tree.
140
- * @returns {RequestError} The featureFetchError value.
140
+ * @return {RequestError} The featureFetchError value.
141
141
  */
142
142
  getFeatureFetchError( state: LogoGeneratorStateProp ): RequestError {
143
143
  return state._meta?.featureFetchError ?? null;
@@ -146,7 +146,7 @@ const selectors = {
146
146
  /**
147
147
  * Get the firstLogoPromptFetchError value.
148
148
  * @param {LogoGeneratorStateProp} state - The app state tree.
149
- * @returns {RequestError} The firstLogoPromptFetchError value.
149
+ * @return {RequestError} The firstLogoPromptFetchError value.
150
150
  */
151
151
  getFirstLogoPromptFetchError( state: LogoGeneratorStateProp ): RequestError {
152
152
  return state._meta?.firstLogoPromptFetchError ?? null;
@@ -155,7 +155,7 @@ const selectors = {
155
155
  /**
156
156
  * Get the enhancePromptFetchError value.
157
157
  * @param {LogoGeneratorStateProp} state - The app state tree.
158
- * @returns {RequestError} The enhancePromptFetchError value.
158
+ * @return {RequestError} The enhancePromptFetchError value.
159
159
  */
160
160
  getEnhancePromptFetchError( state: LogoGeneratorStateProp ): RequestError {
161
161
  return state._meta?.enhancePromptFetchError ?? null;
@@ -164,7 +164,7 @@ const selectors = {
164
164
  /**
165
165
  * Get the logoFetchError value.
166
166
  * @param {LogoGeneratorStateProp} state - The app state tree.
167
- * @returns {RequestError} The logoFetchError value.
167
+ * @return {RequestError} The logoFetchError value.
168
168
  */
169
169
  getLogoFetchError( state: LogoGeneratorStateProp ): RequestError {
170
170
  return state._meta?.logoFetchError ?? null;
@@ -173,7 +173,7 @@ const selectors = {
173
173
  /**
174
174
  * Get the saveToLibraryError value.
175
175
  * @param {LogoGeneratorStateProp} state - The app state tree.
176
- * @returns {RequestError} The saveToLibraryError value.
176
+ * @return {RequestError} The saveToLibraryError value.
177
177
  */
178
178
  getSaveToLibraryError( state: LogoGeneratorStateProp ): RequestError {
179
179
  return state._meta?.saveToLibraryError ?? null;
@@ -182,7 +182,7 @@ const selectors = {
182
182
  /**
183
183
  * Get the logoUpdateError value.
184
184
  * @param {LogoGeneratorStateProp} state - The app state tree.
185
- * @returns {RequestError} The logoUpdateError value.
185
+ * @return {RequestError} The logoUpdateError value.
186
186
  */
187
187
  getLogoUpdateError( state: LogoGeneratorStateProp ): RequestError {
188
188
  return state._meta?.logoUpdateError ?? null;
@@ -191,7 +191,7 @@ const selectors = {
191
191
  /**
192
192
  * Get the context value.
193
193
  * @param {LogoGeneratorStateProp} state - The app state tree.
194
- * @returns {string} The context value.
194
+ * @return {string} The context value.
195
195
  */
196
196
  getContext( state: LogoGeneratorStateProp ): string {
197
197
  return state._meta?.context ?? '';
@@ -53,7 +53,7 @@ const debug = debugFactory( 'jetpack-ai-client:suggestions-event-source' );
53
53
  * when the stream is closed.
54
54
  * It also emits a 'suggestion' event with the full suggestion received so far
55
55
  *
56
- * @returns {EventSource} The event source
56
+ * @return {EventSource} The event source
57
57
  * @fires SuggestionsEventSource#suggestion - The full suggestion has been received so far
58
58
  * @fires SuggestionsEventSource#message - A message has been received
59
59
  * @fires SuggestionsEventSource#chunk - A chunk of data has been received