tinacms 0.0.0-a4a2eeb-20250102014725 → 0.0.0-a577386-20250401050543
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/admin/api.d.ts +1 -0
- package/dist/admin/components/GetCollection.d.ts +2 -2
- package/dist/auth/TinaCloudProvider.d.ts +1 -1
- package/dist/client.d.ts +1 -4
- package/dist/client.js +71 -41
- package/dist/client.mjs +48 -30
- package/dist/hooks/create-page-plugin.d.ts +1 -1
- package/dist/index.d.ts +1 -61
- package/dist/index.js +1970 -617
- package/dist/index.mjs +1976 -623
- package/dist/{node-cache-4c336858.mjs → node-cache-5e8db9f0.mjs} +23 -10
- package/dist/react.d.ts +1 -33
- package/dist/react.js +13 -1
- package/dist/react.mjs +13 -1
- package/dist/rich-text/index.d.ts +1 -142
- package/dist/rich-text/prism.d.ts +1 -10
- package/dist/toolkit/fields/components/reference/reference-select.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +4 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +17 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mark-toolbar-button.d.ts +4 -18
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/index.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +6 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +5 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-provider.d.ts +2 -2
- package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +5 -4
- package/dist/toolkit/react-sidebar/components/sidebar-loading-placeholder.d.ts +2 -0
- package/dist/toolkit/react-sidebar/components/sidebar-no-forms-placeholder.d.ts +2 -0
- package/dist/toolkit/react-sidebar/sidebar.d.ts +2 -2
- package/dist/toolkit/tina-state.d.ts +4 -0
- package/dist/unifiedClient/index.d.ts +8 -1
- package/package.json +35 -34
- package/dist/toolkit/react-sidebar/components/no-forms-placeholder.d.ts +0 -8
package/dist/admin/api.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
|
|
3
3
|
*/
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import type { TinaCMS } from '@tinacms/toolkit';
|
|
6
4
|
import type { Collection } from '@tinacms/schema-tools';
|
|
5
|
+
import type { TinaCMS } from '@tinacms/toolkit';
|
|
6
|
+
import React from 'react';
|
|
7
7
|
import { FilterArgs } from '../api';
|
|
8
8
|
import type { CollectionResponse } from '../types';
|
|
9
9
|
export declare const useGetCollection: (cms: TinaCMS, collectionName: string, includeDocuments: boolean, folder: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { MediaStore, StaticMedia, TinaCMS } from '@tinacms/toolkit';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import { TinaCMS, MediaStore, StaticMedia } from '@tinacms/toolkit';
|
|
3
3
|
import { Client, TinaIOConfig } from '../internalClient';
|
|
4
4
|
import { CreateClientProps } from '../utils';
|
|
5
5
|
export interface TinaCloudMediaStoreClass {
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}));
|
|
3
|
-
})(this, function(exports2) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("async-lock")) : typeof define === "function" && define.amd ? define(["exports", "async-lock"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
|
|
3
|
+
})(this, function(exports2, AsyncLock) {
|
|
4
4
|
"use strict";
|
|
5
5
|
const TINA_HOST = "content.tinajs.io";
|
|
6
6
|
class TinaClient {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
27
27
|
const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
|
|
28
28
|
this.cache = await NodeCache2(this.cacheDir);
|
|
29
|
+
this.cacheLock = new AsyncLock();
|
|
29
30
|
}
|
|
30
31
|
} catch (e) {
|
|
31
32
|
console.error(e);
|
|
@@ -62,42 +63,58 @@
|
|
|
62
63
|
...providedFetchOptions
|
|
63
64
|
};
|
|
64
65
|
let key = "";
|
|
66
|
+
let result;
|
|
65
67
|
if (this.cache) {
|
|
66
68
|
key = this.cache.makeKey(bodyString);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
86
|
-
Errors:
|
|
87
|
-
${json.errors.map((error) => error.message).join("\n")}`
|
|
69
|
+
await this.cacheLock.acquire(key, async () => {
|
|
70
|
+
result = await this.cache.get(key);
|
|
71
|
+
if (!result) {
|
|
72
|
+
result = await requestFromServer(
|
|
73
|
+
url,
|
|
74
|
+
args.query,
|
|
75
|
+
optionsObject,
|
|
76
|
+
errorPolicyDefined
|
|
77
|
+
);
|
|
78
|
+
await this.cache.set(key, result);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
result = await requestFromServer(
|
|
83
|
+
url,
|
|
84
|
+
args.query,
|
|
85
|
+
optionsObject,
|
|
86
|
+
errorPolicyDefined
|
|
88
87
|
);
|
|
89
88
|
}
|
|
90
|
-
const result = {
|
|
91
|
-
data: json == null ? void 0 : json.data,
|
|
92
|
-
errors: (json == null ? void 0 : json.errors) || null,
|
|
93
|
-
query: args.query
|
|
94
|
-
};
|
|
95
|
-
if (this.cache) {
|
|
96
|
-
await this.cache.set(key, result);
|
|
97
|
-
}
|
|
98
89
|
return result;
|
|
99
90
|
}
|
|
100
91
|
}
|
|
92
|
+
async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
|
|
93
|
+
const res = await fetch(url, optionsObject);
|
|
94
|
+
if (!res.ok) {
|
|
95
|
+
let additionalInfo = "";
|
|
96
|
+
if (res.status === 401) {
|
|
97
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
98
|
+
}
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const json = await res.json();
|
|
104
|
+
if (json.errors && errorPolicyDefined === "throw") {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
107
|
+
Errors:
|
|
108
|
+
${json.errors.map((error) => error.message).join("\n")}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const result = {
|
|
112
|
+
data: json == null ? void 0 : json.data,
|
|
113
|
+
errors: (json == null ? void 0 : json.errors) || null,
|
|
114
|
+
query
|
|
115
|
+
};
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
101
118
|
function createClient(args) {
|
|
102
119
|
const client = new TinaClient(args);
|
|
103
120
|
return client;
|
|
@@ -129,22 +146,35 @@
|
|
|
129
146
|
return createHash("sha256").update(input).digest("hex");
|
|
130
147
|
},
|
|
131
148
|
get: async (key) => {
|
|
149
|
+
let readValue;
|
|
150
|
+
const cacheFilename = `${cacheDir}/${key}`;
|
|
132
151
|
try {
|
|
133
|
-
const data = await fs.promises.readFile(
|
|
134
|
-
|
|
152
|
+
const data = await fs.promises.readFile(cacheFilename, "utf-8");
|
|
153
|
+
readValue = JSON.parse(data);
|
|
135
154
|
} catch (e) {
|
|
136
|
-
if (e.code
|
|
137
|
-
|
|
155
|
+
if (e.code !== "ENOENT") {
|
|
156
|
+
console.error(
|
|
157
|
+
`Failed to read cache file to ${cacheFilename}: ${e.message}`
|
|
158
|
+
);
|
|
138
159
|
}
|
|
139
|
-
throw e;
|
|
140
160
|
}
|
|
161
|
+
return readValue;
|
|
141
162
|
},
|
|
142
163
|
set: async (key, value) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
JSON.stringify(value),
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
const cacheFilename = `${cacheDir}/${key}`;
|
|
165
|
+
try {
|
|
166
|
+
await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {
|
|
167
|
+
encoding: "utf-8",
|
|
168
|
+
flag: "wx"
|
|
169
|
+
// Don't overwrite existing caches
|
|
170
|
+
});
|
|
171
|
+
} catch (e) {
|
|
172
|
+
if (e.code !== "EEXIST") {
|
|
173
|
+
console.error(
|
|
174
|
+
`Failed to write cache file to ${cacheFilename}: ${e.message}`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
148
178
|
}
|
|
149
179
|
};
|
|
150
180
|
};
|
package/dist/client.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import AsyncLock from "async-lock";
|
|
1
2
|
const TINA_HOST = "content.tinajs.io";
|
|
2
3
|
class TinaClient {
|
|
3
4
|
constructor({
|
|
@@ -20,8 +21,9 @@ class TinaClient {
|
|
|
20
21
|
}
|
|
21
22
|
try {
|
|
22
23
|
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
23
|
-
const { NodeCache } = await import("./node-cache-
|
|
24
|
+
const { NodeCache } = await import("./node-cache-5e8db9f0.mjs");
|
|
24
25
|
this.cache = await NodeCache(this.cacheDir);
|
|
26
|
+
this.cacheLock = new AsyncLock();
|
|
25
27
|
}
|
|
26
28
|
} catch (e) {
|
|
27
29
|
console.error(e);
|
|
@@ -58,42 +60,58 @@ class TinaClient {
|
|
|
58
60
|
...providedFetchOptions
|
|
59
61
|
};
|
|
60
62
|
let key = "";
|
|
63
|
+
let result;
|
|
61
64
|
if (this.cache) {
|
|
62
65
|
key = this.cache.makeKey(bodyString);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
await this.cacheLock.acquire(key, async () => {
|
|
67
|
+
result = await this.cache.get(key);
|
|
68
|
+
if (!result) {
|
|
69
|
+
result = await requestFromServer(
|
|
70
|
+
url,
|
|
71
|
+
args.query,
|
|
72
|
+
optionsObject,
|
|
73
|
+
errorPolicyDefined
|
|
74
|
+
);
|
|
75
|
+
await this.cache.set(key, result);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
result = await requestFromServer(
|
|
80
|
+
url,
|
|
81
|
+
args.query,
|
|
82
|
+
optionsObject,
|
|
83
|
+
errorPolicyDefined
|
|
76
84
|
);
|
|
77
85
|
}
|
|
78
|
-
const json = await res.json();
|
|
79
|
-
if (json.errors && errorPolicyDefined === "throw") {
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
82
|
-
Errors:
|
|
83
|
-
${json.errors.map((error) => error.message).join("\n")}`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
const result = {
|
|
87
|
-
data: json == null ? void 0 : json.data,
|
|
88
|
-
errors: (json == null ? void 0 : json.errors) || null,
|
|
89
|
-
query: args.query
|
|
90
|
-
};
|
|
91
|
-
if (this.cache) {
|
|
92
|
-
await this.cache.set(key, result);
|
|
93
|
-
}
|
|
94
86
|
return result;
|
|
95
87
|
}
|
|
96
88
|
}
|
|
89
|
+
async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
|
|
90
|
+
const res = await fetch(url, optionsObject);
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
let additionalInfo = "";
|
|
93
|
+
if (res.status === 401) {
|
|
94
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
95
|
+
}
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const json = await res.json();
|
|
101
|
+
if (json.errors && errorPolicyDefined === "throw") {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
104
|
+
Errors:
|
|
105
|
+
${json.errors.map((error) => error.message).join("\n")}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const result = {
|
|
109
|
+
data: json == null ? void 0 : json.data,
|
|
110
|
+
errors: (json == null ? void 0 : json.errors) || null,
|
|
111
|
+
query
|
|
112
|
+
};
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
97
115
|
function createClient(args) {
|
|
98
116
|
const client = new TinaClient(args);
|
|
99
117
|
return client;
|
|
@@ -29,7 +29,7 @@ export type OnNewDocument = (args: {
|
|
|
29
29
|
path: string;
|
|
30
30
|
}) => void;
|
|
31
31
|
export declare class ContentCreatorPlugin implements AddContentPlugin<FormShape> {
|
|
32
|
-
__type:
|
|
32
|
+
__type: "content-creator";
|
|
33
33
|
fields: AddContentPlugin<FormShape>['fields'];
|
|
34
34
|
onNewDocument?: OnNewDocument;
|
|
35
35
|
onChange: (values: any) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export * from './internalClient';
|
|
5
|
-
export * from './auth';
|
|
6
|
-
export * from './utils';
|
|
7
|
-
export * from './tina-cms';
|
|
8
|
-
export { useDocumentCreatorPlugin } from './hooks/use-content-creator';
|
|
9
|
-
export { TinaAdmin } from './admin';
|
|
10
|
-
export { RouteMappingPlugin } from './admin/plugins/route-mapping';
|
|
11
|
-
export { TinaAdminApi } from './admin/api';
|
|
12
|
-
export { ErrorDialog } from './admin/components/ErrorDialog';
|
|
13
|
-
export * from './toolkit';
|
|
14
|
-
export { Form } from './toolkit/forms/form';
|
|
15
|
-
export { MdxFieldPluginExtendible } from '@tinacms/toolkit';
|
|
16
|
-
import { TinaCMSProvider2, DocumentCreatorCallback } from './tina-cms';
|
|
17
|
-
import type { TinaCMSProviderDefaultProps } from './types/cms';
|
|
18
|
-
export type { TinaCMSProviderDefaultProps };
|
|
19
|
-
export default TinaCMSProvider2;
|
|
20
|
-
import { MediaStore, TinaCMS } from '@tinacms/toolkit';
|
|
21
|
-
import { formifyCallback } from './hooks/use-graphql-forms';
|
|
22
|
-
export { NAMER, resolveField } from '@tinacms/schema-tools';
|
|
23
|
-
export type { LoginScreenProps, LoginStrategy } from '@tinacms/schema-tools';
|
|
24
|
-
import { TinaSchema, TinaField, Config, Schema, Collection, Template } from '@tinacms/schema-tools';
|
|
25
|
-
export type { Config, Schema, Collection, Template, TinaField, TinaSchema };
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated use `TinaField` instead
|
|
28
|
-
*/
|
|
29
|
-
export type TinaFieldEnriched = TinaField;
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated use `TinaField` instead
|
|
32
|
-
*/
|
|
33
|
-
export type SchemaField = TinaField;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated use `Template` instead
|
|
36
|
-
*/
|
|
37
|
-
export type TinaTemplate = Template;
|
|
38
|
-
/**
|
|
39
|
-
* @deprecated use `Template` instead
|
|
40
|
-
*/
|
|
41
|
-
export type TinaCloudTemplatebase = Template;
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated use `Collection` instead
|
|
44
|
-
*/
|
|
45
|
-
export type TinaCloudCollectionCollection = Collection;
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated use `Collection` instead
|
|
48
|
-
*/
|
|
49
|
-
export type TinaCollection = Collection;
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated use `Schema` instead
|
|
52
|
-
*/
|
|
53
|
-
export type TinaCloudSchema = Schema;
|
|
54
|
-
export declare const defineSchema: (config: Schema) => Schema<false>;
|
|
55
|
-
export declare const defineLegacyConfig: (config: Omit<TinaCMSProviderDefaultProps, "children">) => Omit<TinaCMSProviderDefaultProps, "children">;
|
|
56
|
-
export interface MediaStoreClass {
|
|
57
|
-
new (...args: any[]): MediaStore;
|
|
58
|
-
}
|
|
59
|
-
export declare const defineStaticConfig: (config: Config<(cms: TinaCMS) => TinaCMS, formifyCallback, DocumentCreatorCallback, MediaStoreClass>) => Config<(cms: TinaCMS) => TinaCMS, formifyCallback, import("./hooks/use-content-creator").DocumentCreatorArgs, MediaStoreClass, undefined>;
|
|
60
|
-
export declare const defineConfig: (config: Config<(cms: TinaCMS) => TinaCMS, formifyCallback, DocumentCreatorCallback, MediaStoreClass>) => Config<(cms: TinaCMS) => TinaCMS, formifyCallback, import("./hooks/use-content-creator").DocumentCreatorArgs, MediaStoreClass, undefined>;
|
|
61
|
-
export { tinaTableTemplate } from './table';
|
|
1
|
+
export * from "../src/index"
|