tinacms 2.10.1 → 3.0.1
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/dist/__vite-browser-external-d06ac358.js +4 -0
- package/dist/admin/api.d.ts +1 -1
- package/dist/client.js +131 -185
- package/dist/index.js +118281 -118351
- package/dist/internalClient/index.d.ts +1 -1
- package/dist/{node-cache-5e8db9f0.mjs → node-cache-c9558e1e.js} +5 -5
- package/dist/react.js +210 -213
- package/dist/rich-text/index.js +234 -237
- package/dist/rich-text/prism.js +16 -18
- package/dist/rich-text/static.js +229 -232
- package/dist/toolkit/components/ui/button.d.ts +11 -0
- package/dist/toolkit/components/ui/calendar.d.ts +8 -0
- package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
- package/dist/toolkit/components/ui/input.d.ts +3 -0
- package/dist/toolkit/components/ui/popover.d.ts +7 -0
- package/dist/toolkit/components/ui/select.d.ts +13 -0
- package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +18 -18
- package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
- package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
- package/dist/toolkit/index.d.ts +1 -1
- package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
- package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
- package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
- package/dist/toolkit/react-sidebar/components/nav.d.ts +3 -3
- package/dist/toolkit/react-sidebar/index.d.ts +3 -0
- package/package.json +20 -43
- package/dist/client.mjs +0 -132
- package/dist/index.mjs +0 -123232
- package/dist/react.mjs +0 -254
- package/dist/rich-text/index.mjs +0 -256
- package/dist/rich-text/prism.mjs +0 -16
- package/dist/rich-text/static.mjs +0 -243
- package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
- /package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -0
package/dist/admin/api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TinaCMS } from '@tinacms/toolkit';
|
|
|
2
2
|
import type { Collection, TinaSchema } from '@tinacms/schema-tools';
|
|
3
3
|
import type { Client } from '../internalClient';
|
|
4
4
|
import type { CollectionResponse, DocumentForm } from './types';
|
|
5
|
-
import { SearchClient } from '@tinacms/search/
|
|
5
|
+
import { SearchClient } from '@tinacms/search/index-client';
|
|
6
6
|
export declare const CREATE_DOCUMENT_GQL = "#graphql\nmutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {\n createDocument(\n collection: $collection,\n relativePath: $relativePath,\n params: $params\n ){__typename}\n}";
|
|
7
7
|
export declare const UPDATE_DOCUMENT_GQL = "#graphql\nmutation($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {\n updateDocument(\n collection: $collection,\n relativePath: $relativePath,\n params: $params\n ){__typename}\n}";
|
|
8
8
|
export declare const DELETE_DOCUMENT_GQL = "#graphql\nmutation DeleteDocument($collection: String!, $relativePath: String!){\n deleteDocument(collection: $collection, relativePath: $relativePath){\n __typename\n }\n}";
|
package/dist/client.js
CHANGED
|
@@ -1,199 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import AsyncLock from "async-lock";
|
|
8
|
+
const TINA_HOST = "content.tinajs.io";
|
|
9
|
+
function replaceGithubPathSplit(url, replacement) {
|
|
10
|
+
const parts = url.split("github/");
|
|
11
|
+
if (parts.length > 1 && replacement) {
|
|
12
|
+
return parts[0] + "github/" + replacement;
|
|
13
|
+
} else {
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class TinaClient {
|
|
18
|
+
constructor({
|
|
19
|
+
token,
|
|
20
|
+
url,
|
|
21
|
+
queries,
|
|
22
|
+
errorPolicy,
|
|
23
|
+
cacheDir
|
|
24
|
+
}) {
|
|
25
|
+
__publicField(this, "apiUrl");
|
|
26
|
+
__publicField(this, "readonlyToken");
|
|
27
|
+
__publicField(this, "queries");
|
|
28
|
+
__publicField(this, "errorPolicy");
|
|
29
|
+
__publicField(this, "initialized", false);
|
|
30
|
+
__publicField(this, "cacheLock");
|
|
31
|
+
__publicField(this, "cacheDir");
|
|
32
|
+
__publicField(this, "cache");
|
|
33
|
+
this.apiUrl = url;
|
|
34
|
+
this.readonlyToken = token == null ? void 0 : token.trim();
|
|
35
|
+
this.queries = queries(this);
|
|
36
|
+
this.errorPolicy = errorPolicy || "throw";
|
|
37
|
+
this.cacheDir = cacheDir || "";
|
|
13
38
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
url,
|
|
18
|
-
queries,
|
|
19
|
-
errorPolicy,
|
|
20
|
-
cacheDir
|
|
21
|
-
}) {
|
|
22
|
-
this.initialized = false;
|
|
23
|
-
this.apiUrl = url;
|
|
24
|
-
this.readonlyToken = token == null ? void 0 : token.trim();
|
|
25
|
-
this.queries = queries(this);
|
|
26
|
-
this.errorPolicy = errorPolicy || "throw";
|
|
27
|
-
this.cacheDir = cacheDir || "";
|
|
39
|
+
async init() {
|
|
40
|
+
if (this.initialized) {
|
|
41
|
+
return;
|
|
28
42
|
}
|
|
29
|
-
|
|
30
|
-
if (this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
35
|
-
const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
|
|
36
|
-
this.cache = await NodeCache2(this.cacheDir);
|
|
37
|
-
this.cacheLock = new AsyncLock();
|
|
38
|
-
}
|
|
39
|
-
} catch (e) {
|
|
40
|
-
console.error(e);
|
|
43
|
+
try {
|
|
44
|
+
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
45
|
+
const { NodeCache } = await import("./node-cache-c9558e1e.js");
|
|
46
|
+
this.cache = await NodeCache(this.cacheDir);
|
|
47
|
+
this.cacheLock = new AsyncLock();
|
|
41
48
|
}
|
|
42
|
-
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error(e);
|
|
51
|
+
}
|
|
52
|
+
this.initialized = true;
|
|
53
|
+
}
|
|
54
|
+
async request({ errorPolicy, ...args }, options) {
|
|
55
|
+
var _a;
|
|
56
|
+
await this.init();
|
|
57
|
+
const errorPolicyDefined = errorPolicy || this.errorPolicy;
|
|
58
|
+
const headers = new Headers();
|
|
59
|
+
if (this.readonlyToken) {
|
|
60
|
+
headers.append("X-API-KEY", this.readonlyToken);
|
|
43
61
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
headers.append("X-API-KEY", this.readonlyToken);
|
|
62
|
+
headers.append("Content-Type", "application/json");
|
|
63
|
+
if (options == null ? void 0 : options.fetchOptions) {
|
|
64
|
+
if ((_a = options == null ? void 0 : options.fetchOptions) == null ? void 0 : _a.headers) {
|
|
65
|
+
Object.entries(options.fetchOptions.headers).forEach(([key2, value]) => {
|
|
66
|
+
headers.append(key2, value);
|
|
67
|
+
});
|
|
51
68
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
}
|
|
70
|
+
const { headers: _, ...providedFetchOptions } = (options == null ? void 0 : options.fetchOptions) || {};
|
|
71
|
+
const bodyString = JSON.stringify({
|
|
72
|
+
query: args.query,
|
|
73
|
+
variables: (args == null ? void 0 : args.variables) || {}
|
|
74
|
+
});
|
|
75
|
+
const optionsObject = {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers,
|
|
78
|
+
body: bodyString,
|
|
79
|
+
redirect: "follow",
|
|
80
|
+
...providedFetchOptions
|
|
81
|
+
};
|
|
82
|
+
const draftBranch = headers.get("x-branch");
|
|
83
|
+
const url = replaceGithubPathSplit((args == null ? void 0 : args.url) || this.apiUrl, draftBranch);
|
|
84
|
+
let key = "";
|
|
85
|
+
let result;
|
|
86
|
+
if (this.cache) {
|
|
87
|
+
key = this.cache.makeKey(bodyString);
|
|
88
|
+
await this.cacheLock.acquire(key, async () => {
|
|
89
|
+
result = await this.cache.get(key);
|
|
90
|
+
if (!result) {
|
|
91
|
+
result = await requestFromServer(
|
|
92
|
+
url,
|
|
93
|
+
args.query,
|
|
94
|
+
optionsObject,
|
|
95
|
+
errorPolicyDefined
|
|
96
|
+
);
|
|
97
|
+
await this.cache.set(key, result);
|
|
58
98
|
}
|
|
59
|
-
}
|
|
60
|
-
const { headers: _, ...providedFetchOptions } = (options == null ? void 0 : options.fetchOptions) || {};
|
|
61
|
-
const bodyString = JSON.stringify({
|
|
62
|
-
query: args.query,
|
|
63
|
-
variables: (args == null ? void 0 : args.variables) || {}
|
|
64
99
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const draftBranch = headers.get("x-branch");
|
|
73
|
-
const url = replaceGithubPathSplit((args == null ? void 0 : args.url) || this.apiUrl, draftBranch);
|
|
74
|
-
let key = "";
|
|
75
|
-
let result;
|
|
76
|
-
if (this.cache) {
|
|
77
|
-
key = this.cache.makeKey(bodyString);
|
|
78
|
-
await this.cacheLock.acquire(key, async () => {
|
|
79
|
-
result = await this.cache.get(key);
|
|
80
|
-
if (!result) {
|
|
81
|
-
result = await requestFromServer(
|
|
82
|
-
url,
|
|
83
|
-
args.query,
|
|
84
|
-
optionsObject,
|
|
85
|
-
errorPolicyDefined
|
|
86
|
-
);
|
|
87
|
-
await this.cache.set(key, result);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
result = await requestFromServer(
|
|
92
|
-
url,
|
|
93
|
-
args.query,
|
|
94
|
-
optionsObject,
|
|
95
|
-
errorPolicyDefined
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
100
|
+
} else {
|
|
101
|
+
result = await requestFromServer(
|
|
102
|
+
url,
|
|
103
|
+
args.query,
|
|
104
|
+
optionsObject,
|
|
105
|
+
errorPolicyDefined
|
|
106
|
+
);
|
|
99
107
|
}
|
|
108
|
+
return result;
|
|
100
109
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new Error(
|
|
109
|
-
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
|
|
110
|
-
);
|
|
110
|
+
}
|
|
111
|
+
async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
|
|
112
|
+
const res = await fetch(url, optionsObject);
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
let additionalInfo = "";
|
|
115
|
+
if (res.status === 401) {
|
|
116
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
111
117
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/r/FAQ/`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const json = await res.json();
|
|
123
|
+
if (json.errors && errorPolicyDefined === "throw") {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/r/FAQ/
|
|
116
126
|
Errors:
|
|
117
127
|
${json.errors.map((error) => error.message).join("\n")}`
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
const result = {
|
|
121
|
-
data: json == null ? void 0 : json.data,
|
|
122
|
-
errors: (json == null ? void 0 : json.errors) || null,
|
|
123
|
-
query
|
|
124
|
-
};
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
function createClient(args) {
|
|
128
|
-
const client = new TinaClient(args);
|
|
129
|
-
return client;
|
|
128
|
+
);
|
|
130
129
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
let cacheDir = dir;
|
|
136
|
-
if (!fs.existsSync(path.join(path.sep, rootUser))) {
|
|
137
|
-
cacheDir = path.join(os.tmpdir(), cacheHash);
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
141
|
-
} catch (error) {
|
|
142
|
-
throw new Error(`Failed to create cache directory: ${error.message}`);
|
|
143
|
-
}
|
|
144
|
-
return cacheDir;
|
|
145
|
-
};
|
|
146
|
-
const NodeCache = async (dir) => {
|
|
147
|
-
const fs = require("node:fs");
|
|
148
|
-
const path = require("node:path");
|
|
149
|
-
const os = require("node:os");
|
|
150
|
-
const { createHash } = require("node:crypto");
|
|
151
|
-
const cacheDir = await makeCacheDir(dir, fs, path, os);
|
|
152
|
-
return {
|
|
153
|
-
makeKey: (key) => {
|
|
154
|
-
const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
|
|
155
|
-
return createHash("sha256").update(input).digest("hex");
|
|
156
|
-
},
|
|
157
|
-
get: async (key) => {
|
|
158
|
-
let readValue;
|
|
159
|
-
const cacheFilename = `${cacheDir}/${key}`;
|
|
160
|
-
try {
|
|
161
|
-
const data = await fs.promises.readFile(cacheFilename, "utf-8");
|
|
162
|
-
readValue = JSON.parse(data);
|
|
163
|
-
} catch (e) {
|
|
164
|
-
if (e.code !== "ENOENT") {
|
|
165
|
-
console.error(
|
|
166
|
-
`Failed to read cache file to ${cacheFilename}: ${e.message}`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return readValue;
|
|
171
|
-
},
|
|
172
|
-
set: async (key, value) => {
|
|
173
|
-
const cacheFilename = `${cacheDir}/${key}`;
|
|
174
|
-
try {
|
|
175
|
-
await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {
|
|
176
|
-
encoding: "utf-8",
|
|
177
|
-
flag: "wx"
|
|
178
|
-
// Don't overwrite existing caches
|
|
179
|
-
});
|
|
180
|
-
} catch (e) {
|
|
181
|
-
if (e.code !== "EEXIST") {
|
|
182
|
-
console.error(
|
|
183
|
-
`Failed to write cache file to ${cacheFilename}: ${e.message}`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
130
|
+
const result = {
|
|
131
|
+
data: json == null ? void 0 : json.data,
|
|
132
|
+
errors: (json == null ? void 0 : json.errors) || null,
|
|
133
|
+
query
|
|
189
134
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
function createClient(args) {
|
|
138
|
+
const client = new TinaClient(args);
|
|
139
|
+
return client;
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
TINA_HOST,
|
|
143
|
+
TinaClient,
|
|
144
|
+
createClient
|
|
145
|
+
};
|