@automattic/jetpack-ai-client 0.14.6 → 0.15.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/CHANGELOG.md +8 -0
- package/build/ask-question/sync.d.ts +2 -8
- package/build/ask-question/sync.js +20 -19
- package/build/hooks/use-image-generator/index.js +1 -1
- package/build/hooks/use-save-to-media-library/index.d.ts +12 -0
- package/build/hooks/use-save-to-media-library/index.js +74 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +5 -0
- package/build/libs/index.d.ts +1 -1
- package/build/libs/index.js +1 -1
- package/build/libs/markdown/index.d.ts +2 -2
- package/build/libs/markdown/index.js +2 -2
- package/build/libs/markdown/markdown-to-html.d.ts +8 -1
- package/build/libs/markdown/markdown-to-html.js +10 -1
- package/build/logo-generator/assets/icons/ai.d.ts +6 -0
- package/build/logo-generator/assets/icons/ai.js +8 -0
- package/build/logo-generator/assets/icons/check.d.ts +6 -0
- package/build/logo-generator/assets/icons/check.js +8 -0
- package/build/logo-generator/assets/icons/logo.d.ts +6 -0
- package/build/logo-generator/assets/icons/logo.js +8 -0
- package/build/logo-generator/assets/icons/media.d.ts +6 -0
- package/build/logo-generator/assets/icons/media.js +8 -0
- package/build/logo-generator/components/feature-fetch-failure-screen.d.ts +8 -0
- package/build/logo-generator/components/feature-fetch-failure-screen.js +10 -0
- package/build/logo-generator/components/first-load-screen.d.ts +5 -0
- package/build/logo-generator/components/first-load-screen.js +16 -0
- package/build/logo-generator/components/generator-modal.d.ts +7 -0
- package/build/logo-generator/components/generator-modal.js +184 -0
- package/build/logo-generator/components/history-carousel.d.ts +6 -0
- package/build/logo-generator/components/history-carousel.js +36 -0
- package/build/logo-generator/components/image-loader.d.ts +7 -0
- package/build/logo-generator/components/image-loader.js +12 -0
- package/build/logo-generator/components/logo-presenter.d.ts +4 -0
- package/build/logo-generator/components/logo-presenter.js +106 -0
- package/build/logo-generator/components/prompt.d.ts +5 -0
- package/build/logo-generator/components/prompt.js +96 -0
- package/build/logo-generator/components/upgrade-nudge.d.ts +2 -0
- package/build/logo-generator/components/upgrade-nudge.js +30 -0
- package/build/logo-generator/components/upgrade-screen.d.ts +9 -0
- package/build/logo-generator/components/upgrade-screen.js +24 -0
- package/build/logo-generator/components/visit-site-banner.d.ts +10 -0
- package/build/logo-generator/components/visit-site-banner.js +16 -0
- package/build/logo-generator/constants.d.ts +16 -0
- package/build/logo-generator/constants.js +19 -0
- package/build/logo-generator/hooks/use-checkout.d.ts +4 -0
- package/build/logo-generator/hooks/use-checkout.js +26 -0
- package/build/logo-generator/hooks/use-logo-generator.d.ts +46 -0
- package/build/logo-generator/hooks/use-logo-generator.js +286 -0
- package/build/logo-generator/hooks/use-request-errors.d.ts +16 -0
- package/build/logo-generator/hooks/use-request-errors.js +46 -0
- package/build/logo-generator/index.d.ts +1 -0
- package/build/logo-generator/index.js +1 -0
- package/build/logo-generator/lib/logo-storage.d.ts +58 -0
- package/build/logo-generator/lib/logo-storage.js +123 -0
- package/build/logo-generator/lib/media-exists.d.ts +12 -0
- package/build/logo-generator/lib/media-exists.js +33 -0
- package/build/logo-generator/lib/set-site-logo.d.ts +13 -0
- package/build/logo-generator/lib/set-site-logo.js +26 -0
- package/build/logo-generator/lib/wpcom-limited-request.d.ts +7 -0
- package/build/logo-generator/lib/wpcom-limited-request.js +33 -0
- package/build/logo-generator/store/actions.d.ts +105 -0
- package/build/logo-generator/store/actions.js +193 -0
- package/build/logo-generator/store/constants.d.ts +44 -0
- package/build/logo-generator/store/constants.js +44 -0
- package/build/logo-generator/store/index.d.ts +1 -0
- package/build/logo-generator/store/index.js +19 -0
- package/build/logo-generator/store/initial-state.d.ts +3 -0
- package/build/logo-generator/store/initial-state.js +40 -0
- package/build/logo-generator/store/reducer.d.ts +347 -0
- package/build/logo-generator/store/reducer.js +293 -0
- package/build/logo-generator/store/selectors.d.ts +119 -0
- package/build/logo-generator/store/selectors.js +173 -0
- package/build/logo-generator/store/types.d.ts +164 -0
- package/build/logo-generator/store/types.js +1 -0
- package/build/logo-generator/types.d.ts +82 -0
- package/build/logo-generator/types.js +1 -0
- package/build/types.d.ts +6 -0
- package/package.json +5 -3
- package/src/ask-question/sync.ts +22 -27
- package/src/hooks/use-image-generator/index.ts +1 -1
- package/src/hooks/use-save-to-media-library/index.ts +95 -0
- package/src/index.ts +6 -0
- package/src/libs/index.ts +1 -0
- package/src/libs/markdown/index.ts +2 -2
- package/src/libs/markdown/markdown-to-html.ts +20 -3
- package/src/logo-generator/assets/icons/ai.tsx +21 -0
- package/src/logo-generator/assets/icons/check.tsx +23 -0
- package/src/logo-generator/assets/icons/icons.scss +5 -0
- package/src/logo-generator/assets/icons/logo.tsx +23 -0
- package/src/logo-generator/assets/icons/media.tsx +24 -0
- package/src/logo-generator/assets/images/jetpack-logo.svg +4 -0
- package/src/logo-generator/assets/images/loader.gif +0 -0
- package/src/logo-generator/assets/index.d.ts +3 -0
- package/src/logo-generator/components/feature-fetch-failure-screen.tsx +35 -0
- package/src/logo-generator/components/first-load-screen.scss +12 -0
- package/src/logo-generator/components/first-load-screen.tsx +32 -0
- package/src/logo-generator/components/generator-modal.scss +92 -0
- package/src/logo-generator/components/generator-modal.tsx +291 -0
- package/src/logo-generator/components/history-carousel.scss +36 -0
- package/src/logo-generator/components/history-carousel.tsx +57 -0
- package/src/logo-generator/components/image-loader.tsx +22 -0
- package/src/logo-generator/components/logo-presenter.scss +116 -0
- package/src/logo-generator/components/logo-presenter.tsx +234 -0
- package/src/logo-generator/components/prompt.scss +102 -0
- package/src/logo-generator/components/prompt.tsx +211 -0
- package/src/logo-generator/components/upgrade-nudge.scss +43 -0
- package/src/logo-generator/components/upgrade-nudge.tsx +58 -0
- package/src/logo-generator/components/upgrade-screen.tsx +67 -0
- package/src/logo-generator/components/visit-site-banner.scss +29 -0
- package/src/logo-generator/components/visit-site-banner.tsx +50 -0
- package/src/logo-generator/constants.ts +22 -0
- package/src/logo-generator/hooks/use-checkout.ts +37 -0
- package/src/logo-generator/hooks/use-logo-generator.ts +389 -0
- package/src/logo-generator/hooks/use-request-errors.ts +70 -0
- package/src/logo-generator/index.ts +1 -0
- package/src/logo-generator/lib/logo-storage.ts +166 -0
- package/src/logo-generator/lib/media-exists.ts +42 -0
- package/src/logo-generator/lib/set-site-logo.ts +32 -0
- package/src/logo-generator/lib/wpcom-limited-request.ts +41 -0
- package/src/logo-generator/store/actions.ts +251 -0
- package/src/logo-generator/store/constants.ts +49 -0
- package/src/logo-generator/store/index.ts +25 -0
- package/src/logo-generator/store/initial-state.ts +43 -0
- package/src/logo-generator/store/reducer.ts +387 -0
- package/src/logo-generator/store/selectors.ts +201 -0
- package/src/logo-generator/store/types.ts +207 -0
- package/src/logo-generator/types.ts +97 -0
- package/src/types.ts +8 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { AiFeatureProps, AiAssistantFeatureEndpointResponseProps, Logo, RequestError } from './types.js';
|
|
2
|
+
import type { SiteDetails } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map the response from the `sites/$site/ai-assistant-feature`
|
|
5
|
+
* endpoint to the AI Assistant feature props.
|
|
6
|
+
* @param { AiAssistantFeatureEndpointResponseProps } response - The response from the endpoint.
|
|
7
|
+
* @returns { AiFeatureProps } The AI Assistant feature props.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapAiFeatureResponseToAiFeatureProps(response: AiAssistantFeatureEndpointResponseProps): AiFeatureProps;
|
|
10
|
+
declare const actions: {
|
|
11
|
+
storeAiAssistantFeature(feature: AiFeatureProps): {
|
|
12
|
+
type: string;
|
|
13
|
+
feature: AiFeatureProps;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Thunk action to fetch the AI Assistant feature from the API.
|
|
17
|
+
* @returns {Function} The thunk action.
|
|
18
|
+
*/
|
|
19
|
+
fetchAiAssistantFeature(): ({ dispatch }: {
|
|
20
|
+
dispatch: any;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* This thunk action is used to increase
|
|
24
|
+
* the requests count for the current usage period.
|
|
25
|
+
* @param {number} count - The number of requests to increase. Default is 1.
|
|
26
|
+
* @returns {Function} The thunk action.
|
|
27
|
+
*/
|
|
28
|
+
increaseAiAssistantRequestsCount(count?: number): ({ dispatch }: {
|
|
29
|
+
dispatch: any;
|
|
30
|
+
}) => void;
|
|
31
|
+
setAiAssistantFeatureRequireUpgrade(requireUpgrade?: boolean): {
|
|
32
|
+
type: string;
|
|
33
|
+
requireUpgrade: boolean;
|
|
34
|
+
};
|
|
35
|
+
setTierPlansEnabled(tierPlansEnabled?: boolean): {
|
|
36
|
+
type: string;
|
|
37
|
+
tierPlansEnabled: boolean;
|
|
38
|
+
};
|
|
39
|
+
setSiteDetails(siteDetails: SiteDetails): {
|
|
40
|
+
type: string;
|
|
41
|
+
siteDetails: SiteDetails;
|
|
42
|
+
};
|
|
43
|
+
setSelectedLogoIndex(selectedLogoIndex: number): {
|
|
44
|
+
type: string;
|
|
45
|
+
selectedLogoIndex: number;
|
|
46
|
+
};
|
|
47
|
+
addLogoToHistory(logo: Logo): {
|
|
48
|
+
type: string;
|
|
49
|
+
logo: Logo;
|
|
50
|
+
};
|
|
51
|
+
setIsSavingLogoToLibrary(isSavingLogoToLibrary: boolean): {
|
|
52
|
+
type: string;
|
|
53
|
+
isSavingLogoToLibrary: boolean;
|
|
54
|
+
};
|
|
55
|
+
setIsApplyingLogo(isApplyingLogo: boolean): {
|
|
56
|
+
type: string;
|
|
57
|
+
isApplyingLogo: boolean;
|
|
58
|
+
};
|
|
59
|
+
updateSelectedLogo(mediaId: string, url: string): {
|
|
60
|
+
type: string;
|
|
61
|
+
mediaId: string;
|
|
62
|
+
url: string;
|
|
63
|
+
};
|
|
64
|
+
setIsRequestingImage(isRequestingImage: boolean): {
|
|
65
|
+
type: string;
|
|
66
|
+
isRequestingImage: boolean;
|
|
67
|
+
};
|
|
68
|
+
setIsEnhancingPrompt(isEnhancingPrompt: boolean): {
|
|
69
|
+
type: string;
|
|
70
|
+
isEnhancingPrompt: boolean;
|
|
71
|
+
};
|
|
72
|
+
loadLogoHistory(siteId: string): {
|
|
73
|
+
type: string;
|
|
74
|
+
history: Logo[];
|
|
75
|
+
};
|
|
76
|
+
setFeatureFetchError(error: RequestError): {
|
|
77
|
+
type: string;
|
|
78
|
+
error: RequestError;
|
|
79
|
+
};
|
|
80
|
+
setFirstLogoPromptFetchError(error: RequestError): {
|
|
81
|
+
type: string;
|
|
82
|
+
error: RequestError;
|
|
83
|
+
};
|
|
84
|
+
setEnhancePromptFetchError(error: RequestError): {
|
|
85
|
+
type: string;
|
|
86
|
+
error: RequestError;
|
|
87
|
+
};
|
|
88
|
+
setLogoFetchError(error: RequestError): {
|
|
89
|
+
type: string;
|
|
90
|
+
error: RequestError;
|
|
91
|
+
};
|
|
92
|
+
setSaveToLibraryError(error: RequestError): {
|
|
93
|
+
type: string;
|
|
94
|
+
error: RequestError;
|
|
95
|
+
};
|
|
96
|
+
setLogoUpdateError(error: RequestError): {
|
|
97
|
+
type: string;
|
|
98
|
+
error: RequestError;
|
|
99
|
+
};
|
|
100
|
+
setContext(context: string): {
|
|
101
|
+
type: string;
|
|
102
|
+
context: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export default actions;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getSiteLogoHistory } from '../lib/logo-storage.js';
|
|
5
|
+
import wpcomLimitedRequest from '../lib/wpcom-limited-request.js';
|
|
6
|
+
/**
|
|
7
|
+
* Types & Constants
|
|
8
|
+
*/
|
|
9
|
+
import { ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, ACTION_REQUEST_AI_ASSISTANT_FEATURE, ACTION_SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE, ACTION_SET_SITE_DETAILS, ACTION_STORE_AI_ASSISTANT_FEATURE, ACTION_SET_TIER_PLANS_ENABLED, ACTION_SET_SELECTED_LOGO_INDEX, ACTION_ADD_LOGO_TO_HISTORY, ACTION_SET_IS_SAVING_LOGO_TO_LIBRARY, ACTION_SAVE_SELECTED_LOGO, ACTION_SET_IS_REQUESTING_IMAGE, ACTION_SET_IS_APPLYING_LOGO, ACTION_SET_IS_ENHANCING_PROMPT, ACTION_SET_SITE_HISTORY, ACTION_SET_FEATURE_FETCH_ERROR, ACTION_SET_FIRST_LOGO_PROMPT_FETCH_ERROR, ACTION_SET_ENHANCE_PROMPT_FETCH_ERROR, ACTION_SET_LOGO_FETCH_ERROR, ACTION_SET_LOGO_UPDATE_ERROR, ACTION_SET_SAVE_TO_LIBRARY_ERROR, ACTION_SET_CONTEXT, } from './constants.js';
|
|
10
|
+
/**
|
|
11
|
+
* Map the response from the `sites/$site/ai-assistant-feature`
|
|
12
|
+
* endpoint to the AI Assistant feature props.
|
|
13
|
+
* @param { AiAssistantFeatureEndpointResponseProps } response - The response from the endpoint.
|
|
14
|
+
* @returns { AiFeatureProps } The AI Assistant feature props.
|
|
15
|
+
*/
|
|
16
|
+
export function mapAiFeatureResponseToAiFeatureProps(response) {
|
|
17
|
+
return {
|
|
18
|
+
hasFeature: !!response['has-feature'],
|
|
19
|
+
isOverLimit: !!response['is-over-limit'],
|
|
20
|
+
requestsCount: response['requests-count'],
|
|
21
|
+
requestsLimit: response['requests-limit'],
|
|
22
|
+
requireUpgrade: !!response['site-require-upgrade'],
|
|
23
|
+
errorMessage: response['error-message'],
|
|
24
|
+
errorCode: response['error-code'],
|
|
25
|
+
upgradeType: response['upgrade-type'],
|
|
26
|
+
usagePeriod: {
|
|
27
|
+
currentStart: response['usage-period']?.['current-start'],
|
|
28
|
+
nextStart: response['usage-period']?.['next-start'],
|
|
29
|
+
requestsCount: response['usage-period']?.['requests-count'] || 0,
|
|
30
|
+
},
|
|
31
|
+
currentTier: response['current-tier'],
|
|
32
|
+
nextTier: response['next-tier'],
|
|
33
|
+
tierPlansEnabled: !!response['tier-plans-enabled'],
|
|
34
|
+
costs: response.costs,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const actions = {
|
|
38
|
+
storeAiAssistantFeature(feature) {
|
|
39
|
+
return {
|
|
40
|
+
type: ACTION_STORE_AI_ASSISTANT_FEATURE,
|
|
41
|
+
feature,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Thunk action to fetch the AI Assistant feature from the API.
|
|
46
|
+
* @returns {Function} The thunk action.
|
|
47
|
+
*/
|
|
48
|
+
fetchAiAssistantFeature() {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
return async ({ dispatch }) => {
|
|
51
|
+
// Dispatch isFetching action.
|
|
52
|
+
dispatch({ type: ACTION_REQUEST_AI_ASSISTANT_FEATURE });
|
|
53
|
+
try {
|
|
54
|
+
const response = await wpcomLimitedRequest({
|
|
55
|
+
path: '/wpcom/v2/jetpack-ai/ai-assistant-feature',
|
|
56
|
+
query: 'force=wpcom',
|
|
57
|
+
});
|
|
58
|
+
// Store the feature in the store.
|
|
59
|
+
dispatch(actions.storeAiAssistantFeature(mapAiFeatureResponseToAiFeatureProps(response)));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
// Mark the fetch as failed.
|
|
63
|
+
dispatch({ type: ACTION_SET_FEATURE_FETCH_ERROR, error: err });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* This thunk action is used to increase
|
|
69
|
+
* the requests count for the current usage period.
|
|
70
|
+
* @param {number} count - The number of requests to increase. Default is 1.
|
|
71
|
+
* @returns {Function} The thunk action.
|
|
72
|
+
*/
|
|
73
|
+
increaseAiAssistantRequestsCount(count = 1) {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
return ({ dispatch }) => {
|
|
76
|
+
dispatch({
|
|
77
|
+
type: ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT,
|
|
78
|
+
count,
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
setAiAssistantFeatureRequireUpgrade(requireUpgrade = true) {
|
|
83
|
+
return {
|
|
84
|
+
type: ACTION_SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE,
|
|
85
|
+
requireUpgrade,
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
setTierPlansEnabled(tierPlansEnabled = true) {
|
|
89
|
+
return {
|
|
90
|
+
type: ACTION_SET_TIER_PLANS_ENABLED,
|
|
91
|
+
tierPlansEnabled,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
setSiteDetails(siteDetails) {
|
|
95
|
+
return {
|
|
96
|
+
type: ACTION_SET_SITE_DETAILS,
|
|
97
|
+
siteDetails,
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
setSelectedLogoIndex(selectedLogoIndex) {
|
|
101
|
+
return {
|
|
102
|
+
type: ACTION_SET_SELECTED_LOGO_INDEX,
|
|
103
|
+
selectedLogoIndex,
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
addLogoToHistory(logo) {
|
|
107
|
+
return {
|
|
108
|
+
type: ACTION_ADD_LOGO_TO_HISTORY,
|
|
109
|
+
logo,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
setIsSavingLogoToLibrary(isSavingLogoToLibrary) {
|
|
113
|
+
return {
|
|
114
|
+
type: ACTION_SET_IS_SAVING_LOGO_TO_LIBRARY,
|
|
115
|
+
isSavingLogoToLibrary,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
setIsApplyingLogo(isApplyingLogo) {
|
|
119
|
+
return {
|
|
120
|
+
type: ACTION_SET_IS_APPLYING_LOGO,
|
|
121
|
+
isApplyingLogo,
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
updateSelectedLogo(mediaId, url) {
|
|
125
|
+
return {
|
|
126
|
+
type: ACTION_SAVE_SELECTED_LOGO,
|
|
127
|
+
mediaId,
|
|
128
|
+
url,
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
setIsRequestingImage(isRequestingImage) {
|
|
132
|
+
return {
|
|
133
|
+
type: ACTION_SET_IS_REQUESTING_IMAGE,
|
|
134
|
+
isRequestingImage,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
setIsEnhancingPrompt(isEnhancingPrompt) {
|
|
138
|
+
return {
|
|
139
|
+
type: ACTION_SET_IS_ENHANCING_PROMPT,
|
|
140
|
+
isEnhancingPrompt,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
loadLogoHistory(siteId) {
|
|
144
|
+
const history = getSiteLogoHistory(siteId);
|
|
145
|
+
return {
|
|
146
|
+
type: ACTION_SET_SITE_HISTORY,
|
|
147
|
+
history,
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
setFeatureFetchError(error) {
|
|
151
|
+
return {
|
|
152
|
+
type: ACTION_SET_FEATURE_FETCH_ERROR,
|
|
153
|
+
error,
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
setFirstLogoPromptFetchError(error) {
|
|
157
|
+
return {
|
|
158
|
+
type: ACTION_SET_FIRST_LOGO_PROMPT_FETCH_ERROR,
|
|
159
|
+
error,
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
setEnhancePromptFetchError(error) {
|
|
163
|
+
return {
|
|
164
|
+
type: ACTION_SET_ENHANCE_PROMPT_FETCH_ERROR,
|
|
165
|
+
error,
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
setLogoFetchError(error) {
|
|
169
|
+
return {
|
|
170
|
+
type: ACTION_SET_LOGO_FETCH_ERROR,
|
|
171
|
+
error,
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
setSaveToLibraryError(error) {
|
|
175
|
+
return {
|
|
176
|
+
type: ACTION_SET_SAVE_TO_LIBRARY_ERROR,
|
|
177
|
+
error,
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
setLogoUpdateError(error) {
|
|
181
|
+
return {
|
|
182
|
+
type: ACTION_SET_LOGO_UPDATE_ERROR,
|
|
183
|
+
error,
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
setContext(context) {
|
|
187
|
+
return {
|
|
188
|
+
type: ACTION_SET_CONTEXT,
|
|
189
|
+
context,
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
export default actions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Assistant feature actions
|
|
3
|
+
*/
|
|
4
|
+
export declare const ACTION_STORE_AI_ASSISTANT_FEATURE = "STORE_AI_ASSISTANT_FEATURE";
|
|
5
|
+
export declare const ACTION_REQUEST_AI_ASSISTANT_FEATURE = "REQUEST_AI_ASSISTANT_FEATURE";
|
|
6
|
+
export declare const ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT = "INCREASE_AI_ASSISTANT_REQUESTS_COUNT";
|
|
7
|
+
export declare const ACTION_SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE = "SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE";
|
|
8
|
+
export declare const ACTION_SET_TIER_PLANS_ENABLED = "SET_TIER_PLANS_ENABLED";
|
|
9
|
+
export declare const ACTION_SET_SITE_DETAILS = "SET_SITE_DETAILS";
|
|
10
|
+
/**
|
|
11
|
+
* Endpoints
|
|
12
|
+
*/
|
|
13
|
+
export declare const ENDPOINT_AI_ASSISTANT_FEATURE = "/wpcom/v2/jetpack-ai/ai-assistant-feature";
|
|
14
|
+
/**
|
|
15
|
+
* New AI Assistant feature async request
|
|
16
|
+
*/
|
|
17
|
+
export declare const FREE_PLAN_REQUESTS_LIMIT = 20;
|
|
18
|
+
export declare const UNLIMITED_PLAN_REQUESTS_LIMIT = 999999999;
|
|
19
|
+
export declare const ASYNC_REQUEST_COUNTDOWN_INIT_VALUE = 3;
|
|
20
|
+
export declare const NEW_ASYNC_REQUEST_TIMER_INTERVAL = 5000;
|
|
21
|
+
export declare const ACTION_DECREASE_NEW_ASYNC_REQUEST_COUNTDOWN = "DECREASE_NEW_ASYNC_REQUEST_COUNTDOWN";
|
|
22
|
+
export declare const ACTION_ENQUEUE_ASYNC_REQUEST = "ENQUEUE_ASYNC_COUNTDOWN_REQUEST";
|
|
23
|
+
export declare const ACTION_DEQUEUE_ASYNC_REQUEST = "DEQUEUE_ASYNC_COUNTDOWN_REQUEST";
|
|
24
|
+
/**
|
|
25
|
+
* Logo generator actions
|
|
26
|
+
*/
|
|
27
|
+
export declare const ACTION_SET_CONTEXT = "SET_CONTEXT";
|
|
28
|
+
export declare const ACTION_SET_SELECTED_LOGO_INDEX = "SET_SELECTED_LOGO_INDEX";
|
|
29
|
+
export declare const ACTION_ADD_LOGO_TO_HISTORY = "ADD_LOGO_TO_HISTORY";
|
|
30
|
+
export declare const ACTION_SET_IS_SAVING_LOGO_TO_LIBRARY = "SET_IS_SAVING_LOGO_TO_LIBRARY";
|
|
31
|
+
export declare const ACTION_SET_IS_APPLYING_LOGO = "SET_IS_APPLYING_LOGO";
|
|
32
|
+
export declare const ACTION_SAVE_SELECTED_LOGO = "SAVE_SELECTED_LOGO";
|
|
33
|
+
export declare const ACTION_SET_IS_REQUESTING_IMAGE = "SET_IS_REQUESTING_IMAGE";
|
|
34
|
+
export declare const ACTION_SET_IS_ENHANCING_PROMPT = "SET_IS_ENHANCING_PROMPT";
|
|
35
|
+
export declare const ACTION_SET_SITE_HISTORY = "SET_SITE_HISTORY";
|
|
36
|
+
/**
|
|
37
|
+
* Logo generator error actions
|
|
38
|
+
*/
|
|
39
|
+
export declare const ACTION_SET_FEATURE_FETCH_ERROR = "SET_FEATURE_FETCH_ERROR";
|
|
40
|
+
export declare const ACTION_SET_FIRST_LOGO_PROMPT_FETCH_ERROR = "SET_FIRST_LOGO_PROMPT_FETCH_ERROR";
|
|
41
|
+
export declare const ACTION_SET_ENHANCE_PROMPT_FETCH_ERROR = "SET_ENHANCE_PROMPT_FETCH_ERROR";
|
|
42
|
+
export declare const ACTION_SET_LOGO_FETCH_ERROR = "SET_LOGO_FETCH_ERROR";
|
|
43
|
+
export declare const ACTION_SET_SAVE_TO_LIBRARY_ERROR = "SET_SAVE_TO_LIBRARY_ERROR";
|
|
44
|
+
export declare const ACTION_SET_LOGO_UPDATE_ERROR = "SET_LOGO_UPDATE_ERROR";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Assistant feature actions
|
|
3
|
+
*/
|
|
4
|
+
export const ACTION_STORE_AI_ASSISTANT_FEATURE = 'STORE_AI_ASSISTANT_FEATURE';
|
|
5
|
+
export const ACTION_REQUEST_AI_ASSISTANT_FEATURE = 'REQUEST_AI_ASSISTANT_FEATURE';
|
|
6
|
+
export const ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT = 'INCREASE_AI_ASSISTANT_REQUESTS_COUNT';
|
|
7
|
+
export const ACTION_SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE = 'SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE';
|
|
8
|
+
export const ACTION_SET_TIER_PLANS_ENABLED = 'SET_TIER_PLANS_ENABLED';
|
|
9
|
+
export const ACTION_SET_SITE_DETAILS = 'SET_SITE_DETAILS';
|
|
10
|
+
/**
|
|
11
|
+
* Endpoints
|
|
12
|
+
*/
|
|
13
|
+
export const ENDPOINT_AI_ASSISTANT_FEATURE = '/wpcom/v2/jetpack-ai/ai-assistant-feature';
|
|
14
|
+
/**
|
|
15
|
+
* New AI Assistant feature async request
|
|
16
|
+
*/
|
|
17
|
+
export const FREE_PLAN_REQUESTS_LIMIT = 20;
|
|
18
|
+
export const UNLIMITED_PLAN_REQUESTS_LIMIT = 999999999;
|
|
19
|
+
export const ASYNC_REQUEST_COUNTDOWN_INIT_VALUE = 3;
|
|
20
|
+
export const NEW_ASYNC_REQUEST_TIMER_INTERVAL = 5000;
|
|
21
|
+
export const ACTION_DECREASE_NEW_ASYNC_REQUEST_COUNTDOWN = 'DECREASE_NEW_ASYNC_REQUEST_COUNTDOWN';
|
|
22
|
+
export const ACTION_ENQUEUE_ASYNC_REQUEST = 'ENQUEUE_ASYNC_COUNTDOWN_REQUEST';
|
|
23
|
+
export const ACTION_DEQUEUE_ASYNC_REQUEST = 'DEQUEUE_ASYNC_COUNTDOWN_REQUEST';
|
|
24
|
+
/**
|
|
25
|
+
* Logo generator actions
|
|
26
|
+
*/
|
|
27
|
+
export const ACTION_SET_CONTEXT = 'SET_CONTEXT';
|
|
28
|
+
export const ACTION_SET_SELECTED_LOGO_INDEX = 'SET_SELECTED_LOGO_INDEX';
|
|
29
|
+
export const ACTION_ADD_LOGO_TO_HISTORY = 'ADD_LOGO_TO_HISTORY';
|
|
30
|
+
export const ACTION_SET_IS_SAVING_LOGO_TO_LIBRARY = 'SET_IS_SAVING_LOGO_TO_LIBRARY';
|
|
31
|
+
export const ACTION_SET_IS_APPLYING_LOGO = 'SET_IS_APPLYING_LOGO';
|
|
32
|
+
export const ACTION_SAVE_SELECTED_LOGO = 'SAVE_SELECTED_LOGO';
|
|
33
|
+
export const ACTION_SET_IS_REQUESTING_IMAGE = 'SET_IS_REQUESTING_IMAGE';
|
|
34
|
+
export const ACTION_SET_IS_ENHANCING_PROMPT = 'SET_IS_ENHANCING_PROMPT';
|
|
35
|
+
export const ACTION_SET_SITE_HISTORY = 'SET_SITE_HISTORY';
|
|
36
|
+
/**
|
|
37
|
+
* Logo generator error actions
|
|
38
|
+
*/
|
|
39
|
+
export const ACTION_SET_FEATURE_FETCH_ERROR = 'SET_FEATURE_FETCH_ERROR';
|
|
40
|
+
export const ACTION_SET_FIRST_LOGO_PROMPT_FETCH_ERROR = 'SET_FIRST_LOGO_PROMPT_FETCH_ERROR';
|
|
41
|
+
export const ACTION_SET_ENHANCE_PROMPT_FETCH_ERROR = 'SET_ENHANCE_PROMPT_FETCH_ERROR';
|
|
42
|
+
export const ACTION_SET_LOGO_FETCH_ERROR = 'SET_LOGO_FETCH_ERROR';
|
|
43
|
+
export const ACTION_SET_SAVE_TO_LIBRARY_ERROR = 'SET_SAVE_TO_LIBRARY_ERROR';
|
|
44
|
+
export const ACTION_SET_LOGO_UPDATE_ERROR = 'SET_LOGO_UPDATE_ERROR';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STORE_NAME = "jetpack-ai/logo-generator";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import actions from './actions.js';
|
|
9
|
+
import reducer from './reducer.js';
|
|
10
|
+
import selectors from './selectors.js';
|
|
11
|
+
export const STORE_NAME = 'jetpack-ai/logo-generator';
|
|
12
|
+
const jetpackAiLogoGeneratorStore = createReduxStore(STORE_NAME, {
|
|
13
|
+
// @ts-expect-error -- TSCONVERSION
|
|
14
|
+
__experimentalUseThunks: true,
|
|
15
|
+
actions,
|
|
16
|
+
reducer,
|
|
17
|
+
selectors,
|
|
18
|
+
});
|
|
19
|
+
register(jetpackAiLogoGeneratorStore);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types & Constants
|
|
3
|
+
*/
|
|
4
|
+
import { ASYNC_REQUEST_COUNTDOWN_INIT_VALUE, FREE_PLAN_REQUESTS_LIMIT } from './constants.js';
|
|
5
|
+
const INITIAL_STATE = {
|
|
6
|
+
siteDetails: {},
|
|
7
|
+
features: {
|
|
8
|
+
aiAssistantFeature: {
|
|
9
|
+
hasFeature: true,
|
|
10
|
+
isOverLimit: false,
|
|
11
|
+
requestsCount: 0,
|
|
12
|
+
requestsLimit: FREE_PLAN_REQUESTS_LIMIT,
|
|
13
|
+
requireUpgrade: false,
|
|
14
|
+
errorMessage: '',
|
|
15
|
+
errorCode: '',
|
|
16
|
+
upgradeType: 'default',
|
|
17
|
+
currentTier: {
|
|
18
|
+
slug: 'ai-assistant-tier-free',
|
|
19
|
+
value: 0,
|
|
20
|
+
limit: 20,
|
|
21
|
+
},
|
|
22
|
+
usagePeriod: {
|
|
23
|
+
currentStart: '',
|
|
24
|
+
nextStart: '',
|
|
25
|
+
requestsCount: 0,
|
|
26
|
+
},
|
|
27
|
+
nextTier: null,
|
|
28
|
+
tierPlansEnabled: false,
|
|
29
|
+
_meta: {
|
|
30
|
+
isRequesting: false,
|
|
31
|
+
asyncRequestCountdown: ASYNC_REQUEST_COUNTDOWN_INIT_VALUE,
|
|
32
|
+
asyncRequestTimerId: 0,
|
|
33
|
+
isRequestingImage: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
history: [],
|
|
38
|
+
selectedLogoIndex: 0,
|
|
39
|
+
};
|
|
40
|
+
export default INITIAL_STATE;
|