@contentful/react-apps-toolkit 0.5.8 → 0.5.11
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/README.md +23 -4
- package/dist/useCMA.js +2 -1
- package/dist/useFieldValue.d.ts +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ If it is not, the hook will throw an error.
|
|
|
30
30
|
Here is an example of how you can use it:
|
|
31
31
|
|
|
32
32
|
```tsx
|
|
33
|
+
import { useSDK } from '@contentful/react-apps-toolkit'
|
|
34
|
+
|
|
33
35
|
function App() {
|
|
34
36
|
const sdk = useSDK<FieldExtensionSDK>();
|
|
35
37
|
|
|
@@ -38,14 +40,31 @@ function App() {
|
|
|
38
40
|
|
|
39
41
|
```
|
|
40
42
|
|
|
43
|
+
### `useCMA`
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
Returns an initialized [plain client](https://github.com/contentful/contentful-management.js/#alternative-plain-api) for the Contentful Management API, which can immediately be used to communicate with the rest of your Contentful space. [Contentful Management API docs](https://www.contentful.com/developers/docs/references/content-management-api/).
|
|
43
46
|
|
|
44
|
-
Wrapper component, which makes the Apps SDK available to children via React Context. To use any of the hooks contained in this package, an application must be wrapped in the SDK provider, as all hooks depend on the Apps SDK.
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
```tsx
|
|
49
|
+
import { useCMA } from '@contentful/react-apps-toolkit'
|
|
50
|
+
|
|
51
|
+
function App() {
|
|
52
|
+
const cma = useCMA();
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
cma.entry.get({ entryId: '2VO9yOaeSyAFA19e649SxG' }).then((entry) => {
|
|
56
|
+
console.log(entry);
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
return <>Hello world!</>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### SDKProvider
|
|
66
|
+
|
|
67
|
+
Wrapper component, which makes the Apps SDK available to children via React Context. To use any of the hooks contained in this package, an application must be wrapped in the SDK provider, as all hooks depend on the Apps SDK.
|
|
49
68
|
|
|
50
69
|
### Resources
|
|
51
70
|
|
package/dist/useCMA.js
CHANGED
|
@@ -11,10 +11,11 @@ var useSDK_1 = require("./useSDK");
|
|
|
11
11
|
function useCMA() {
|
|
12
12
|
var sdk = (0, useSDK_1.useSDK)();
|
|
13
13
|
var cma = (0, react_1.useMemo)(function () {
|
|
14
|
+
var _a;
|
|
14
15
|
return (0, contentful_management_1.createClient)({ apiAdapter: sdk.cmaAdapter }, {
|
|
15
16
|
type: 'plain',
|
|
16
17
|
defaults: {
|
|
17
|
-
environmentId: sdk.ids.environment,
|
|
18
|
+
environmentId: (_a = sdk.ids.environmentAlias) !== null && _a !== void 0 ? _a : sdk.ids.environment,
|
|
18
19
|
spaceId: sdk.ids.space,
|
|
19
20
|
},
|
|
20
21
|
});
|
package/dist/useFieldValue.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare type UseFieldValueReturnValue<Value = unknown> = [
|
|
2
|
-
value: Value,
|
|
3
|
-
setValue: (newValue: Value) => Promise<void>
|
|
2
|
+
value: Value | undefined,
|
|
3
|
+
setValue: (newValue: Value | undefined) => Promise<void>
|
|
4
4
|
];
|
|
5
5
|
/**
|
|
6
6
|
* Returns field value and a function to update it.
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/react-apps-toolkit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"description": "Toolkit for building a Contentful app in React",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Contentful GmbH",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
|
+
"sideEffects": false,
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "git+https://github.com/contentful/create-contentful-app.git",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"@contentful/app-sdk": "^4.0.0",
|
|
50
51
|
"contentful-management": ">=7.30.0"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "61e3382ccad0a4bfb72625f5681271667e15acd6"
|
|
53
54
|
}
|