tinacms 0.68.1 → 0.68.4
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 +29 -0
- package/dist/auth/TinaCloudProvider.d.ts +1 -1
- package/dist/client.d.ts +13 -0
- package/dist/client.es.js +40 -0
- package/dist/client.js +51 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +7 -10
- package/dist/index.js +7 -10
- package/dist/{client → internalClient}/formify.d.ts +0 -0
- package/dist/{client → internalClient}/index.d.ts +0 -0
- package/dist/rich-text.es.js +1 -1
- package/dist/rich-text.js +1 -1
- package/dist/tina-cms.d.ts +42 -1
- package/dist/unifiedClient/index.d.ts +30 -0
- package/dist/utils/index.d.ts +2 -2
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# tinacms
|
|
2
2
|
|
|
3
|
+
## 0.68.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7372f90ca: Adds a new client that can be used on the backend and frontend.
|
|
8
|
+
- Updated dependencies [d4f98d0fc]
|
|
9
|
+
- Updated dependencies [7e2272442]
|
|
10
|
+
- @tinacms/toolkit@0.56.27
|
|
11
|
+
|
|
12
|
+
## 0.68.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 8b7ee346a: - Display label instead of name for mdx dropdown af306fa
|
|
17
|
+
- Fix issue where reset triggered chagnes to the wrong rich-text field 03f6191
|
|
18
|
+
- Fix issue where null children in a code block threw an error e454bce
|
|
19
|
+
- Updated dependencies [f6f56bcc0]
|
|
20
|
+
- Updated dependencies [59d33a74a]
|
|
21
|
+
- Updated dependencies [8b7ee346a]
|
|
22
|
+
- Updated dependencies [acb38bf9f]
|
|
23
|
+
- @tinacms/toolkit@0.56.26
|
|
24
|
+
|
|
25
|
+
## 0.68.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [e90647da3]
|
|
30
|
+
- @tinacms/toolkit@0.56.25
|
|
31
|
+
|
|
3
32
|
## 0.68.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -12,7 +12,7 @@ limitations under the License.
|
|
|
12
12
|
*/
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import { TinaCMS, MediaStore } from '@tinacms/toolkit';
|
|
15
|
-
import { Client, TinaIOConfig } from '../
|
|
15
|
+
import { Client, TinaIOConfig } from '../internalClient';
|
|
16
16
|
import { CreateClientProps } from '../utils';
|
|
17
17
|
export interface TinaCloudMediaStoreClass {
|
|
18
18
|
new (client: Client): MediaStore;
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
export * from './unifiedClient';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fetchPonyfill from "fetch-ponyfill";
|
|
2
|
+
const { fetch, Headers } = fetchPonyfill();
|
|
3
|
+
class TinaClient {
|
|
4
|
+
constructor({ token, url }) {
|
|
5
|
+
this.apiUrl = url;
|
|
6
|
+
this.readonlyToken = token;
|
|
7
|
+
}
|
|
8
|
+
async request(args) {
|
|
9
|
+
const headers = new Headers();
|
|
10
|
+
if (this.readonlyToken) {
|
|
11
|
+
headers.append("X-API-KEY", this.readonlyToken);
|
|
12
|
+
}
|
|
13
|
+
headers.append("Content-Type", "application/json");
|
|
14
|
+
const bodyString = JSON.stringify({
|
|
15
|
+
query: args.query,
|
|
16
|
+
variables: (args == null ? void 0 : args.variables) || {}
|
|
17
|
+
});
|
|
18
|
+
const url = (args == null ? void 0 : args.url) || this.apiUrl;
|
|
19
|
+
const res = await fetch(url, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers,
|
|
22
|
+
body: bodyString,
|
|
23
|
+
redirect: "follow"
|
|
24
|
+
});
|
|
25
|
+
const json = await res.json();
|
|
26
|
+
if (json.errors) {
|
|
27
|
+
throw new Error(`Unable to fetch, errors:
|
|
28
|
+
${json.errors.map((error) => error.message).join("\n")}`);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
data: json == null ? void 0 : json.data,
|
|
32
|
+
query: args.query
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const createClient = (args) => {
|
|
37
|
+
const client = new TinaClient(args);
|
|
38
|
+
return client;
|
|
39
|
+
};
|
|
40
|
+
export { TinaClient, createClient };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("fetch-ponyfill")) : typeof define === "function" && define.amd ? define(["exports", "fetch-ponyfill"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
|
|
3
|
+
})(this, function(exports2, fetchPonyfill) {
|
|
4
|
+
"use strict";
|
|
5
|
+
function _interopDefaultLegacy(e) {
|
|
6
|
+
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
7
|
+
}
|
|
8
|
+
var fetchPonyfill__default = /* @__PURE__ */ _interopDefaultLegacy(fetchPonyfill);
|
|
9
|
+
const { fetch, Headers } = fetchPonyfill__default["default"]();
|
|
10
|
+
class TinaClient {
|
|
11
|
+
constructor({ token, url }) {
|
|
12
|
+
this.apiUrl = url;
|
|
13
|
+
this.readonlyToken = token;
|
|
14
|
+
}
|
|
15
|
+
async request(args) {
|
|
16
|
+
const headers = new Headers();
|
|
17
|
+
if (this.readonlyToken) {
|
|
18
|
+
headers.append("X-API-KEY", this.readonlyToken);
|
|
19
|
+
}
|
|
20
|
+
headers.append("Content-Type", "application/json");
|
|
21
|
+
const bodyString = JSON.stringify({
|
|
22
|
+
query: args.query,
|
|
23
|
+
variables: (args == null ? void 0 : args.variables) || {}
|
|
24
|
+
});
|
|
25
|
+
const url = (args == null ? void 0 : args.url) || this.apiUrl;
|
|
26
|
+
const res = await fetch(url, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers,
|
|
29
|
+
body: bodyString,
|
|
30
|
+
redirect: "follow"
|
|
31
|
+
});
|
|
32
|
+
const json = await res.json();
|
|
33
|
+
if (json.errors) {
|
|
34
|
+
throw new Error(`Unable to fetch, errors:
|
|
35
|
+
${json.errors.map((error) => error.message).join("\n")}`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
data: json == null ? void 0 : json.data,
|
|
39
|
+
query: args.query
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const createClient = (args) => {
|
|
44
|
+
const client = new TinaClient(args);
|
|
45
|
+
return client;
|
|
46
|
+
};
|
|
47
|
+
exports2.TinaClient = TinaClient;
|
|
48
|
+
exports2.createClient = createClient;
|
|
49
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
50
|
+
exports2[Symbol.toStringTag] = "Module";
|
|
51
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
10
10
|
See the License for the specific language governing permissions and
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './internalClient';
|
|
14
14
|
export * from './auth';
|
|
15
15
|
export * from './utils';
|
|
16
16
|
export * from './tina-cms';
|
package/dist/index.es.js
CHANGED
|
@@ -1605,16 +1605,11 @@ function reducer(state, action) {
|
|
|
1605
1605
|
const blueprint = getFormNodeBlueprint(formNode, state);
|
|
1606
1606
|
if (blueprint.hasValuesField) {
|
|
1607
1607
|
changeSets.push(__spreadValues({
|
|
1608
|
-
path: [formNodePath(formNode), "
|
|
1609
|
-
}, buildChangeSet(event, formNode)));
|
|
1610
|
-
}
|
|
1611
|
-
if (blueprint.hasDataJSONField) {
|
|
1612
|
-
changeSets.push(__spreadValues({
|
|
1613
|
-
path: [formNodePath(formNode), "dataJSON"].join(".")
|
|
1608
|
+
path: [formNodePath(formNode), "_values"].join(".")
|
|
1614
1609
|
}, buildChangeSet(event, formNode)));
|
|
1615
1610
|
}
|
|
1616
1611
|
changeSets.push(__spreadValues({
|
|
1617
|
-
path: [formNodePath(formNode)
|
|
1612
|
+
path: [formNodePath(formNode)].join(".")
|
|
1618
1613
|
}, buildChangeSet(event, formNode)));
|
|
1619
1614
|
});
|
|
1620
1615
|
return __spreadProps(__spreadValues({}, state), { changeSets });
|
|
@@ -2985,11 +2980,13 @@ const TinaCMSProvider2 = (_c) => {
|
|
|
2985
2980
|
"formifyCallback",
|
|
2986
2981
|
"schema"
|
|
2987
2982
|
]);
|
|
2983
|
+
var _a;
|
|
2988
2984
|
const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
|
|
2989
|
-
|
|
2990
|
-
|
|
2985
|
+
const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
|
|
2986
|
+
if (!apiURL && !validOldSetup) {
|
|
2987
|
+
throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
|
|
2991
2988
|
}
|
|
2992
|
-
const { branch, clientId, isLocalClient } =
|
|
2989
|
+
const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
|
|
2993
2990
|
branch: props.branch,
|
|
2994
2991
|
clientId: props.clientId,
|
|
2995
2992
|
isLocalClient: props.isLocalClient
|
package/dist/index.js
CHANGED
|
@@ -1624,16 +1624,11 @@ var __objRest = (source, exclude) => {
|
|
|
1624
1624
|
const blueprint = getFormNodeBlueprint(formNode, state);
|
|
1625
1625
|
if (blueprint.hasValuesField) {
|
|
1626
1626
|
changeSets.push(__spreadValues({
|
|
1627
|
-
path: [formNodePath(formNode), "
|
|
1628
|
-
}, buildChangeSet(event, formNode)));
|
|
1629
|
-
}
|
|
1630
|
-
if (blueprint.hasDataJSONField) {
|
|
1631
|
-
changeSets.push(__spreadValues({
|
|
1632
|
-
path: [formNodePath(formNode), "dataJSON"].join(".")
|
|
1627
|
+
path: [formNodePath(formNode), "_values"].join(".")
|
|
1633
1628
|
}, buildChangeSet(event, formNode)));
|
|
1634
1629
|
}
|
|
1635
1630
|
changeSets.push(__spreadValues({
|
|
1636
|
-
path: [formNodePath(formNode)
|
|
1631
|
+
path: [formNodePath(formNode)].join(".")
|
|
1637
1632
|
}, buildChangeSet(event, formNode)));
|
|
1638
1633
|
});
|
|
1639
1634
|
return __spreadProps(__spreadValues({}, state), { changeSets });
|
|
@@ -3004,11 +2999,13 @@ mutation addPendingDocumentMutation(
|
|
|
3004
2999
|
"formifyCallback",
|
|
3005
3000
|
"schema"
|
|
3006
3001
|
]);
|
|
3002
|
+
var _a;
|
|
3007
3003
|
const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
|
|
3008
|
-
|
|
3009
|
-
|
|
3004
|
+
const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
|
|
3005
|
+
if (!apiURL && !validOldSetup) {
|
|
3006
|
+
throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
|
|
3010
3007
|
}
|
|
3011
|
-
const { branch, clientId, isLocalClient } =
|
|
3008
|
+
const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
|
|
3012
3009
|
branch: props.branch,
|
|
3013
3010
|
clientId: props.clientId,
|
|
3014
3011
|
isLocalClient: props.isLocalClient
|
|
File without changes
|
|
File without changes
|
package/dist/rich-text.es.js
CHANGED
|
@@ -108,7 +108,7 @@ const TinaMarkdown = ({
|
|
|
108
108
|
case "code_block":
|
|
109
109
|
const value = child.children.map((item) => {
|
|
110
110
|
var _a2;
|
|
111
|
-
return ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "";
|
|
111
|
+
return item.children ? ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "" : "";
|
|
112
112
|
}).join("\n");
|
|
113
113
|
if (components[child.type]) {
|
|
114
114
|
const Component2 = components[child.type];
|
package/dist/rich-text.js
CHANGED
|
@@ -115,7 +115,7 @@ var __objRest = (source, exclude) => {
|
|
|
115
115
|
case "code_block":
|
|
116
116
|
const value = child.children.map((item) => {
|
|
117
117
|
var _a2;
|
|
118
|
-
return ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "";
|
|
118
|
+
return item.children ? ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "" : "";
|
|
119
119
|
}).join("\n");
|
|
120
120
|
if (components[child.type]) {
|
|
121
121
|
const Component2 = components[child.type];
|
package/dist/tina-cms.d.ts
CHANGED
|
@@ -11,13 +11,19 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import React from 'react';
|
|
14
|
+
import type { TinaClient } from './client';
|
|
14
15
|
import { TinaCloudMediaStoreClass } from './auth';
|
|
15
16
|
import type { TinaCMS } from '@tinacms/toolkit';
|
|
16
17
|
import type { TinaCloudSchema } from '@tinacms/schema-tools';
|
|
17
|
-
import type { TinaIOConfig } from './
|
|
18
|
+
import type { TinaIOConfig } from './internalClient/index';
|
|
18
19
|
import type { formifyCallback } from './hooks/use-graphql-forms';
|
|
19
20
|
import { useDocumentCreatorPlugin } from './hooks/use-content-creator';
|
|
20
21
|
declare type APIProviderProps = {
|
|
22
|
+
/**
|
|
23
|
+
* The API url From this client will be used to make requests.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
client?: never;
|
|
21
27
|
/**
|
|
22
28
|
* Content API URL
|
|
23
29
|
*
|
|
@@ -42,6 +48,36 @@ declare type APIProviderProps = {
|
|
|
42
48
|
* @deprecated use apiURL instead
|
|
43
49
|
*/
|
|
44
50
|
clientId?: never;
|
|
51
|
+
} | {
|
|
52
|
+
/**
|
|
53
|
+
* The API url From this client will be used to make requests.
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
client: TinaClient;
|
|
57
|
+
/**
|
|
58
|
+
* Content API URL
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
apiURL?: never;
|
|
62
|
+
/**
|
|
63
|
+
* Point to the local version of GraphQL instead of tina.io
|
|
64
|
+
* https://tina.io/docs/tinacms-context/#adding-tina-to-the-sites-frontend
|
|
65
|
+
*
|
|
66
|
+
* @deprecated use apiURL instead
|
|
67
|
+
*/
|
|
68
|
+
isLocalClient?: never;
|
|
69
|
+
/**
|
|
70
|
+
* The base branch to pull content from. Note that this is ignored for local development
|
|
71
|
+
*
|
|
72
|
+
* @deprecated use apiURL instead
|
|
73
|
+
*/
|
|
74
|
+
branch?: never;
|
|
75
|
+
/**
|
|
76
|
+
* Your clientID from tina.aio
|
|
77
|
+
*
|
|
78
|
+
* @deprecated use apiURL instead
|
|
79
|
+
*/
|
|
80
|
+
clientId?: never;
|
|
45
81
|
} | {
|
|
46
82
|
/**
|
|
47
83
|
* Content API URL
|
|
@@ -67,6 +103,11 @@ declare type APIProviderProps = {
|
|
|
67
103
|
* @deprecated use apiURL instead
|
|
68
104
|
*/
|
|
69
105
|
clientId?: string;
|
|
106
|
+
/**
|
|
107
|
+
* The API url From this client will be used to make requests.
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
client: never;
|
|
70
111
|
};
|
|
71
112
|
interface BaseProviderProps {
|
|
72
113
|
/** Callback if you need access to the TinaCMS instance */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
export interface TinaClientArs {
|
|
14
|
+
url: string;
|
|
15
|
+
token?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare type TinaClientRequestArgs = {
|
|
18
|
+
variables?: Record<string, any>;
|
|
19
|
+
query: string;
|
|
20
|
+
} & Partial<TinaClientArs>;
|
|
21
|
+
export declare class TinaClient {
|
|
22
|
+
apiUrl: string;
|
|
23
|
+
readonlyToken?: string;
|
|
24
|
+
constructor({ token, url }: TinaClientArs);
|
|
25
|
+
request<DataType extends Record<string, any> = any>(args: TinaClientRequestArgs): Promise<{
|
|
26
|
+
data: DataType;
|
|
27
|
+
query: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export declare const createClient: (args: TinaClientArs) => TinaClient;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
10
10
|
See the License for the specific language governing permissions and
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
|
-
import { Client } from '../
|
|
14
|
-
import type { TinaIOConfig } from '../
|
|
13
|
+
import { Client } from '../internalClient';
|
|
14
|
+
import type { TinaIOConfig } from '../internalClient';
|
|
15
15
|
import * as yup from 'yup';
|
|
16
16
|
import { TinaCloudSchema } from '@tinacms/schema-tools';
|
|
17
17
|
export interface CreateClientProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "0.68.
|
|
3
|
+
"version": "0.68.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"entryPoints": [
|
|
10
10
|
"src/index.ts",
|
|
11
11
|
"src/edit-state.tsx",
|
|
12
|
-
"src/rich-text.tsx"
|
|
12
|
+
"src/rich-text.tsx",
|
|
13
|
+
"src/client.ts"
|
|
13
14
|
]
|
|
14
15
|
},
|
|
15
16
|
"typings": "dist/index.d.ts",
|
|
@@ -26,8 +27,9 @@
|
|
|
26
27
|
"@heroicons/react": "^1.0.4",
|
|
27
28
|
"@tinacms/schema-tools": "0.0.3",
|
|
28
29
|
"@tinacms/sharedctx": "0.1.1",
|
|
29
|
-
"@tinacms/toolkit": "0.56.
|
|
30
|
+
"@tinacms/toolkit": "0.56.27",
|
|
30
31
|
"crypto-js": "^4.0.0",
|
|
32
|
+
"fetch-ponyfill": "^7.1.0",
|
|
31
33
|
"final-form": "4.20.1",
|
|
32
34
|
"graphql": "^15.1.0",
|
|
33
35
|
"graphql-tag": "^2.11.0",
|