@automattic/jetpack-ai-client 0.1.11 → 0.1.13
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/SECURITY.md +11 -2
- package/package.json +15 -15
- package/src/data-flow/Readme.md +0 -20
- package/src/data-flow/index.ts +1 -4
- package/src/data-flow/with-ai-assistant-data.tsx +0 -79
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.13] - 2023-10-23
|
|
9
|
+
### Changed
|
|
10
|
+
- Updated package dependencies. [#33687]
|
|
11
|
+
|
|
12
|
+
### Removed
|
|
13
|
+
- AI Client: Remove obsolete blockListBlockWithAiDataProvider() HOC component. [#33726]
|
|
14
|
+
|
|
15
|
+
## [0.1.12] - 2023-10-16
|
|
16
|
+
### Changed
|
|
17
|
+
- Updated package dependencies. [#33584]
|
|
18
|
+
|
|
8
19
|
## [0.1.11] - 2023-10-10
|
|
9
20
|
### Changed
|
|
10
21
|
- Updated package dependencies. [#33428]
|
|
@@ -140,6 +151,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
140
151
|
- Updated package dependencies. [#31659]
|
|
141
152
|
- Updated package dependencies. [#31785]
|
|
142
153
|
|
|
154
|
+
[0.1.13]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.12...v0.1.13
|
|
155
|
+
[0.1.12]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.11...v0.1.12
|
|
143
156
|
[0.1.11]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.10...v0.1.11
|
|
144
157
|
[0.1.10]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.9...v0.1.10
|
|
145
158
|
[0.1.9]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.8...v0.1.9
|
package/SECURITY.md
CHANGED
|
@@ -4,11 +4,20 @@ Full details of the Automattic Security Policy can be found on [automattic.com](
|
|
|
4
4
|
|
|
5
5
|
## Supported Versions
|
|
6
6
|
|
|
7
|
-
Generally, only the latest version of Jetpack
|
|
7
|
+
Generally, only the latest version of Jetpack and its associated plugins have continued support. If a critical vulnerability is found in the current version of a plugin, we may opt to backport any patches to previous versions.
|
|
8
8
|
|
|
9
9
|
## Reporting a Vulnerability
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Our HackerOne program covers the below plugin software, as well as a variety of related projects and infrastructure:
|
|
12
|
+
|
|
13
|
+
* [Jetpack](https://jetpack.com/)
|
|
14
|
+
* Jetpack Backup
|
|
15
|
+
* Jetpack Boost
|
|
16
|
+
* Jetpack CRM
|
|
17
|
+
* Jetpack Protect
|
|
18
|
+
* Jetpack Search
|
|
19
|
+
* Jetpack Social
|
|
20
|
+
* Jetpack VideoPress
|
|
12
21
|
|
|
13
22
|
**For responsible disclosure of security issues and to be eligible for our bug bounty program, please submit your report via the [HackerOne](https://hackerone.com/automattic) portal.**
|
|
14
23
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.13",
|
|
5
5
|
"description": "A JS client for consuming Jetpack AI services",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"type": "module",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@storybook/addon-actions": "7.
|
|
25
|
-
"@storybook/blocks": "7.
|
|
26
|
-
"@storybook/react": "7.
|
|
24
|
+
"@storybook/addon-actions": "7.4.6",
|
|
25
|
+
"@storybook/blocks": "7.4.6",
|
|
26
|
+
"@storybook/react": "7.4.6",
|
|
27
27
|
"jest": "^29.6.2",
|
|
28
28
|
"jest-environment-jsdom": "29.5.0",
|
|
29
29
|
"typescript": "5.0.4"
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
".": "./index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
36
|
-
"@automattic/jetpack-connection": "^0.30.
|
|
37
|
-
"@automattic/jetpack-shared-extension-utils": "^0.12.
|
|
35
|
+
"@automattic/jetpack-base-styles": "^0.6.11",
|
|
36
|
+
"@automattic/jetpack-connection": "^0.30.5",
|
|
37
|
+
"@automattic/jetpack-shared-extension-utils": "^0.12.4",
|
|
38
38
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
39
|
-
"@wordpress/api-fetch": "6.
|
|
40
|
-
"@wordpress/block-editor": "12.
|
|
41
|
-
"@wordpress/components": "25.
|
|
42
|
-
"@wordpress/compose": "6.
|
|
43
|
-
"@wordpress/data": "9.
|
|
44
|
-
"@wordpress/element": "5.
|
|
45
|
-
"@wordpress/i18n": "4.
|
|
46
|
-
"@wordpress/icons": "9.
|
|
39
|
+
"@wordpress/api-fetch": "6.41.0",
|
|
40
|
+
"@wordpress/block-editor": "12.12.0",
|
|
41
|
+
"@wordpress/components": "25.10.0",
|
|
42
|
+
"@wordpress/compose": "6.21.0",
|
|
43
|
+
"@wordpress/data": "9.14.0",
|
|
44
|
+
"@wordpress/element": "5.21.0",
|
|
45
|
+
"@wordpress/i18n": "4.44.0",
|
|
46
|
+
"@wordpress/icons": "9.35.0",
|
|
47
47
|
"classnames": "2.3.2",
|
|
48
48
|
"debug": "4.3.4",
|
|
49
49
|
"react": "18.2.0",
|
package/src/data-flow/Readme.md
CHANGED
|
@@ -33,7 +33,6 @@ export default withAiAssistantData( MyComponent );
|
|
|
33
33
|
|
|
34
34
|
* [AI Data Context](#ai-assistant-content)
|
|
35
35
|
* [withAiDataProvider HOC](#with-ai-data-provider)
|
|
36
|
-
* [blockListBlockWithAiDataProvider](#block-list-block-with-ai-data-provider)
|
|
37
36
|
* [useAiContext Hook](#use-ai-context)
|
|
38
37
|
|
|
39
38
|
<h2 id="ai-assistant-content">Ai Data Context</h2>
|
|
@@ -116,25 +115,6 @@ These callbacks will be invoked with the detail of the corresponding event emitt
|
|
|
116
115
|
When called, the hook returns the Ai Data Context.
|
|
117
116
|
|
|
118
117
|
|
|
119
|
-
<h2 id="block-list-block-with-ai-data-provider">blockListBlockWithAiDataProvider Function</h2>
|
|
120
|
-
|
|
121
|
-
The `blockListBlockWithAiDataProvider` function returns a Higher Order Component (HOC) that wraps and provides the AI Assistant Data context to a specified set of blocks. Primarily designed for use with the `editor.BlockListBlock` filter in the WordPress Block Editor, it conditionally applies the data provider only to block types specified in the function options.
|
|
122
|
-
|
|
123
|
-
### Usage
|
|
124
|
-
|
|
125
|
-
To use the `blockListBlockWithAiDataProvider`, you'll need to specify which blocks should have access to the AI Assistant Data context:
|
|
126
|
-
|
|
127
|
-
```jsx
|
|
128
|
-
import { blockListBlockWithAiDataProvider } from '@automattic/jetpack-ai-client';
|
|
129
|
-
|
|
130
|
-
// Example usage with WordPress filters
|
|
131
|
-
const enhancedBlockListBlock = blockListBlockWithAiDataProvider( {
|
|
132
|
-
blocks: [ 'core/paragraph', 'core/heading' ]
|
|
133
|
-
} );
|
|
134
|
-
|
|
135
|
-
wp.hooks.addFilter( 'editor.BlockListBlock', 'my-plugin/with-ai-data', enhancedBlockListBlock );
|
|
136
|
-
```
|
|
137
|
-
|
|
138
118
|
### Parameters
|
|
139
119
|
|
|
140
120
|
The function accepts an optional options object:
|
package/src/data-flow/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { AiDataContext, AiDataContextProvider } from './context';
|
|
2
|
-
export {
|
|
3
|
-
default as withAiDataProvider,
|
|
4
|
-
blockListBlockWithAiDataProvider,
|
|
5
|
-
} from './with-ai-assistant-data';
|
|
2
|
+
export { default as withAiDataProvider } from './with-ai-assistant-data';
|
|
6
3
|
export { default as useAiContext } from './use-ai-context';
|
|
@@ -59,82 +59,3 @@ const withAiDataProvider = createHigherOrderComponent( ( WrappedComponent: React
|
|
|
59
59
|
}, 'withAiDataProvider' );
|
|
60
60
|
|
|
61
61
|
export default withAiDataProvider;
|
|
62
|
-
|
|
63
|
-
type OptionsProps = {
|
|
64
|
-
/**
|
|
65
|
-
* Array of block names to apply the data provider to.
|
|
66
|
-
*/
|
|
67
|
-
blocks: string[] | string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Function that returns a High Order Component that provides the
|
|
72
|
-
* AI Assistant Data context to the wrapped component.
|
|
73
|
-
*
|
|
74
|
-
* Ideally though to use with the `editor.BlockListBlock` filter.
|
|
75
|
-
*
|
|
76
|
-
* @see https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#editor-blocklistblock
|
|
77
|
-
* @param {OptionsProps} options - Options
|
|
78
|
-
* @param {string[]} options.blocks - Array of block names to apply the data provider to.
|
|
79
|
-
* @returns {ReactNode} Wrapped component, populated with the AI Assistant Data context.
|
|
80
|
-
*/
|
|
81
|
-
export const blockListBlockWithAiDataProvider = ( options: OptionsProps = { blocks: [ '' ] } ) => {
|
|
82
|
-
return createHigherOrderComponent( ( WrappedComponent: ReactNode ) => {
|
|
83
|
-
return props => {
|
|
84
|
-
const blockName = props?.block?.name;
|
|
85
|
-
if ( ! blockName ) {
|
|
86
|
-
return <WrappedComponent { ...props } />;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/*
|
|
90
|
-
* Extend only blocks that are specified in the blocks option.
|
|
91
|
-
* `blocks` option accepts a string or an array of strings.
|
|
92
|
-
*/
|
|
93
|
-
const blockTypesToExtend = Array.isArray( options.blocks )
|
|
94
|
-
? options.blocks
|
|
95
|
-
: [ options.blocks ];
|
|
96
|
-
|
|
97
|
-
if ( ! blockTypesToExtend.includes( blockName ) ) {
|
|
98
|
-
return <WrappedComponent { ...props } />;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Connect with the AI Assistant communication layer.
|
|
102
|
-
// @todo: this is a copy of the code above, we should refactor this.
|
|
103
|
-
const {
|
|
104
|
-
suggestion,
|
|
105
|
-
error: requestingError,
|
|
106
|
-
requestingState,
|
|
107
|
-
request: requestSuggestion,
|
|
108
|
-
stopSuggestion,
|
|
109
|
-
eventSource,
|
|
110
|
-
} = useAiSuggestions();
|
|
111
|
-
|
|
112
|
-
// Build the context value to pass to the ai assistant data provider.
|
|
113
|
-
const dataContextValue = useMemo(
|
|
114
|
-
() => ( {
|
|
115
|
-
suggestion,
|
|
116
|
-
requestingError,
|
|
117
|
-
requestingState,
|
|
118
|
-
eventSource,
|
|
119
|
-
|
|
120
|
-
requestSuggestion,
|
|
121
|
-
stopSuggestion,
|
|
122
|
-
} ),
|
|
123
|
-
[
|
|
124
|
-
suggestion,
|
|
125
|
-
requestingError,
|
|
126
|
-
requestingState,
|
|
127
|
-
eventSource,
|
|
128
|
-
requestSuggestion,
|
|
129
|
-
stopSuggestion,
|
|
130
|
-
]
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<AiDataContextProvider value={ dataContextValue }>
|
|
135
|
-
<WrappedComponent { ...props } />
|
|
136
|
-
</AiDataContextProvider>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
139
|
-
}, 'blockListBlockWithAiDataProvider' );
|
|
140
|
-
};
|