tinacms 0.0.0-9b91b31-20241023063504 → 0.0.0-9c781c0-20250801015431
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 +1 -1
- package/dist/admin/api.d.ts +4 -0
- package/dist/admin/components/GetCollection.d.ts +2 -2
- package/dist/admin/components/Page.d.ts +3 -9
- package/dist/admin/components/Sidebar.d.ts +0 -3
- package/dist/admin/components/ui/tooltip.d.ts +7 -0
- package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
- package/dist/admin/pages/CollectionListPage.d.ts +2 -2
- package/dist/admin/pages/DashboardPage.d.ts +0 -3
- package/dist/admin/pages/ScreenPage.d.ts +0 -3
- package/dist/admin/types.d.ts +3 -0
- package/dist/auth/TinaCloudProvider.d.ts +1 -1
- package/dist/cache/node-cache.d.ts +1 -0
- package/dist/client.js +92 -64
- package/dist/client.mjs +59 -36
- package/dist/hooks/create-page-plugin.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +103827 -15012
- package/dist/index.mjs +103904 -15089
- package/dist/internalClient/index.d.ts +28 -3
- package/dist/node-cache-5e8db9f0.mjs +63 -0
- package/dist/react.d.ts +14 -6
- package/dist/react.js +73 -53
- package/dist/react.mjs +73 -53
- package/dist/rich-text/index.js +10 -4
- package/dist/rich-text/index.mjs +10 -4
- package/dist/rich-text/prism.js +1 -1
- package/dist/rich-text/prism.mjs +1 -1
- package/dist/rich-text/static.d.ts +148 -0
- package/dist/rich-text/static.js +239 -0
- package/dist/rich-text/static.mjs +236 -0
- package/dist/toolkit/components/ProgressBar.d.ts +11 -0
- package/dist/toolkit/components/media/media-item.d.ts +1 -1
- package/dist/toolkit/components/media/media-manager.d.ts +1 -1
- package/dist/toolkit/components/ui/breadcrumb.d.ts +11 -0
- package/dist/toolkit/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/toolkit/fields/components/password-field.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/components/button.d.ts +2 -2
- package/dist/toolkit/fields/components/reference/components/command.d.ts +21 -33
- package/dist/toolkit/fields/components/reference/components/popover.d.ts +1 -1
- package/dist/toolkit/fields/components/reference/model/reference-link-props.d.ts +2 -0
- package/dist/toolkit/fields/components/reference/reference-select.d.ts +2 -2
- package/dist/toolkit/fields/components/select.d.ts +2 -2
- package/dist/toolkit/fields/components/text-field.d.ts +1 -1
- package/dist/toolkit/fields/plugins/group-field-plugin.d.ts +1 -1
- package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +1 -0
- package/dist/toolkit/fields/plugins/list-field-meta.d.ts +1 -1
- package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +1 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +5 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +20 -18
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +14 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +3 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-leaf.d.ts +2 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +14 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-syntax-leaf.d.ts +2 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +112 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dialog.d.ts +12 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dropdown-menu.d.ts +10 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/floating-toolbar.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-element.d.ts +3 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-toolbar-button.d.ts +18 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/image-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +6 -7
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/inline-combobox.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/input.d.ts +3 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-element.d.ts +4 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-floating-toolbar.d.ts +4 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-toolbar-button.d.ts +4 -4
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +28 -11
- 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/components/plate-ui/mermaid-element.d.ts +3 -10
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +6 -8
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +15 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/popover.d.ts +7 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/quote-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/raw-markdown-toolbar-button.d.ts +6 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +24 -21
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/separator.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +15 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/block-selection.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +33 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/{table-dropdown-menu.d.ts → table/table-dropdown-menu.d.ts} +1 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +20 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +15 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/toolbar.d.ts +7 -7
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +10 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-state.d.ts +22 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-create-editor.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/index.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-block.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-lists.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-marks.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-utils.d.ts +3 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +11 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/formatting.d.ts +18 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/index.d.ts +0 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +6 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-img-plugin/index.d.ts +2 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-invalid-markdown-plugin/index.d.ts +5 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/component.d.ts +7 -4
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/index.d.ts +3 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +520 -0
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +262 -212
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/floating-toolbar-plugin.d.ts +1 -0
- 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/fields/plugins/mdx-field-plugin/plate/transforms/is-url.d.ts +1 -2
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
- package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
- package/dist/toolkit/form-builder/fields-builder.d.ts +1 -1
- package/dist/toolkit/form-builder/form-builder.d.ts +15 -5
- package/dist/toolkit/forms/field.d.ts +3 -0
- package/dist/toolkit/forms/form.d.ts +22 -3
- package/dist/toolkit/git-client/git-client.d.ts +25 -2
- package/dist/toolkit/git-client/git-file.d.ts +18 -0
- package/dist/toolkit/git-client/git-media-store.d.ts +13 -0
- package/dist/toolkit/git-client/use-git-file.d.ts +4 -0
- package/dist/toolkit/icons/Tina.d.ts +0 -5
- package/dist/toolkit/index.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +1 -0
- package/dist/toolkit/plugin-branch-switcher/branch-switcher-legacy.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-switcher.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/index.d.ts +0 -1
- package/dist/toolkit/react-cloud-config/cloud-config-plugin.d.ts +3 -3
- package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
- package/dist/toolkit/react-sidebar/components/alert.d.ts +5 -0
- package/dist/toolkit/react-sidebar/components/form-list.d.ts +1 -1
- package/dist/toolkit/react-sidebar/components/nav.d.ts +6 -3
- package/dist/toolkit/react-sidebar/components/resize-handle.d.ts +0 -5
- package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +7 -10
- 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/components/sidebar.d.ts +0 -7
- package/dist/toolkit/react-sidebar/components/sync-status.d.ts +5 -8
- package/dist/toolkit/react-sidebar/index.d.ts +1 -1
- package/dist/toolkit/react-sidebar/sidebar.d.ts +2 -2
- package/dist/toolkit/styles/button.d.ts +2 -2
- package/dist/toolkit/tina-cms.d.ts +3 -3
- package/dist/toolkit/tina-state.d.ts +15 -0
- package/dist/unifiedClient/index.d.ts +8 -1
- package/dist/utils/cn.d.ts +2 -0
- package/package.json +74 -61
- package/dist/__vite-browser-external-d06ac358.mjs +0 -4
- package/dist/admin/pages/IndexingPage.d.ts +0 -2
- package/dist/node-cache-2dadfb7c.mjs +0 -53
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +0 -27
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +0 -14
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +0 -13
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/with-correct-void-behavior.d.ts +0 -8
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-code-block/index.d.ts +0 -3
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-link-plugin/index.d.ts +0 -15
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +0 -2
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/create-soft-break-plugin.d.ts +0 -7
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/index.d.ts +0 -6
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/on-key-down-soft-break.d.ts +0 -5
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/types.d.ts +0 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +0 -11
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/insert-empty-block.d.ts +0 -2
- package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
- package/dist/toolkit/react-sidebar/components/no-forms-placeholder.d.ts +0 -8
package/README.md
CHANGED
package/dist/admin/api.d.ts
CHANGED
|
@@ -3,10 +3,14 @@ import type { Collection, TinaSchema } from '@tinacms/schema-tools';
|
|
|
3
3
|
import type { Client } from '../internalClient';
|
|
4
4
|
import type { CollectionResponse, DocumentForm } from './types';
|
|
5
5
|
import { SearchClient } from '@tinacms/search/dist/index-client';
|
|
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
|
+
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
|
+
export declare const DELETE_DOCUMENT_GQL = "#graphql\nmutation DeleteDocument($collection: String!, $relativePath: String!){\n deleteDocument(collection: $collection, relativePath: $relativePath){\n __typename\n }\n}";
|
|
6
9
|
export interface FilterArgs {
|
|
7
10
|
filterField: string;
|
|
8
11
|
collection?: string;
|
|
9
12
|
relativePath?: string;
|
|
13
|
+
relativePathWithoutExtension?: string;
|
|
10
14
|
newRelativePath?: string;
|
|
11
15
|
startsWith?: string;
|
|
12
16
|
endsWith?: string;
|
|
@@ -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,17 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
1
|
import React from 'react';
|
|
5
|
-
export declare const PageWrapper: ({ children }: {
|
|
2
|
+
export declare const PageWrapper: ({ headerClassName, children, }: {
|
|
3
|
+
headerClassName?: string;
|
|
6
4
|
children: React.ReactNode;
|
|
7
5
|
}) => React.JSX.Element;
|
|
8
|
-
export declare const PageHeader: ({
|
|
9
|
-
isLocalMode?: boolean;
|
|
6
|
+
export declare const PageHeader: ({ children, }: {
|
|
10
7
|
children: React.ReactNode;
|
|
11
8
|
}) => React.JSX.Element;
|
|
12
9
|
export declare const PageBody: ({ children }: {
|
|
13
10
|
children: React.ReactNode;
|
|
14
11
|
}) => React.JSX.Element;
|
|
15
|
-
export declare const PageBodyNarrow: ({ children }: {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}) => React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
4
|
+
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
5
|
+
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Collection } from '@tinacms/schema-tools';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import type { TinaCMS } from '@tinacms/toolkit';
|
|
4
4
|
declare const CollectionCreatePage: () => React.JSX.Element;
|
|
5
5
|
export declare const RenderForm: ({ cms, collection, folder, templateName, mutationInfo, customDefaults, }: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { Collection } from '@tinacms/schema-tools';
|
|
2
|
+
import { type TinaCMS } from '@tinacms/toolkit';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { type NavigateFunction } from 'react-router-dom';
|
|
3
|
-
import { type TinaCMS } from '@tinacms/toolkit';
|
|
4
5
|
import type { CollectionResponse, DocumentSys } from '../types';
|
|
5
|
-
import type { Collection } from '@tinacms/schema-tools';
|
|
6
6
|
export declare const handleNavigate: (navigate: NavigateFunction, cms: TinaCMS, collection: CollectionResponse, collectionDefinition: Collection<true>, document: DocumentSys) => Promise<any>;
|
|
7
7
|
declare const CollectionListPage: () => React.JSX.Element;
|
|
8
8
|
export default CollectionListPage;
|
package/dist/admin/types.d.ts
CHANGED
|
@@ -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.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("
|
|
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
|
-
const { fetch: fetchPonyfillFN, Headers: HeadersPonyfill } = fetchPonyfill();
|
|
6
|
-
const fetchDefined = typeof fetch === "undefined" ? fetchPonyfillFN : fetch;
|
|
7
|
-
const HeadersDefined = typeof Headers === "undefined" ? HeadersPonyfill : Headers;
|
|
8
5
|
const TINA_HOST = "content.tinajs.io";
|
|
6
|
+
function replaceGithubPathSplit(url, replacement) {
|
|
7
|
+
const parts = url.split("github/");
|
|
8
|
+
if (parts.length > 1 && replacement) {
|
|
9
|
+
return parts[0] + "github/" + replacement;
|
|
10
|
+
} else {
|
|
11
|
+
return url;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
9
14
|
class TinaClient {
|
|
10
15
|
constructor({
|
|
11
16
|
token,
|
|
@@ -29,6 +34,7 @@
|
|
|
29
34
|
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
30
35
|
const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
|
|
31
36
|
this.cache = await NodeCache2(this.cacheDir);
|
|
37
|
+
this.cacheLock = new AsyncLock();
|
|
32
38
|
}
|
|
33
39
|
} catch (e) {
|
|
34
40
|
console.error(e);
|
|
@@ -39,7 +45,7 @@
|
|
|
39
45
|
var _a;
|
|
40
46
|
await this.init();
|
|
41
47
|
const errorPolicyDefined = errorPolicy || this.errorPolicy;
|
|
42
|
-
const headers = new
|
|
48
|
+
const headers = new Headers();
|
|
43
49
|
if (this.readonlyToken) {
|
|
44
50
|
headers.append("X-API-KEY", this.readonlyToken);
|
|
45
51
|
}
|
|
@@ -56,7 +62,6 @@
|
|
|
56
62
|
query: args.query,
|
|
57
63
|
variables: (args == null ? void 0 : args.variables) || {}
|
|
58
64
|
});
|
|
59
|
-
const url = (args == null ? void 0 : args.url) || this.apiUrl;
|
|
60
65
|
const optionsObject = {
|
|
61
66
|
method: "POST",
|
|
62
67
|
headers,
|
|
@@ -64,58 +69,71 @@
|
|
|
64
69
|
redirect: "follow",
|
|
65
70
|
...providedFetchOptions
|
|
66
71
|
};
|
|
72
|
+
const draftBranch = headers.get("x-branch");
|
|
73
|
+
const url = replaceGithubPathSplit((args == null ? void 0 : args.url) || this.apiUrl, draftBranch);
|
|
67
74
|
let key = "";
|
|
75
|
+
let result;
|
|
68
76
|
if (this.cache) {
|
|
69
77
|
key = this.cache.makeKey(bodyString);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
89
|
-
Errors:
|
|
90
|
-
${json.errors.map((error) => error.message).join("\n")}`
|
|
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
|
|
91
96
|
);
|
|
92
97
|
}
|
|
93
|
-
const result = {
|
|
94
|
-
data: json == null ? void 0 : json.data,
|
|
95
|
-
errors: (json == null ? void 0 : json.errors) || null,
|
|
96
|
-
query: args.query
|
|
97
|
-
};
|
|
98
|
-
if (this.cache) {
|
|
99
|
-
await this.cache.set(key, result);
|
|
100
|
-
}
|
|
101
98
|
return result;
|
|
102
99
|
}
|
|
103
100
|
}
|
|
101
|
+
async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
|
|
102
|
+
const res = await fetch(url, optionsObject);
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
let additionalInfo = "";
|
|
105
|
+
if (res.status === 401) {
|
|
106
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
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/errors/faq/`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const json = await res.json();
|
|
113
|
+
if (json.errors && errorPolicyDefined === "throw") {
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
116
|
+
Errors:
|
|
117
|
+
${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
|
+
}
|
|
104
127
|
function createClient(args) {
|
|
105
128
|
const client = new TinaClient(args);
|
|
106
129
|
return client;
|
|
107
130
|
}
|
|
108
|
-
const makeCacheDir = async (dir, fs) => {
|
|
109
|
-
const
|
|
110
|
-
const os = require("node:os");
|
|
111
|
-
if (typeof dir !== "string" || !dir.trim()) {
|
|
112
|
-
throw new Error("Invalid directory path");
|
|
113
|
-
}
|
|
114
|
-
console.log("Path sep", path.sep);
|
|
115
|
-
const pathParts = dir.split(path.sep);
|
|
131
|
+
const makeCacheDir = async (dir, fs, path, os) => {
|
|
132
|
+
const pathParts = dir.split(path.sep).filter(Boolean);
|
|
116
133
|
const cacheHash = pathParts[pathParts.length - 1];
|
|
134
|
+
const rootUser = pathParts[0];
|
|
117
135
|
let cacheDir = dir;
|
|
118
|
-
if (!fs.existsSync(
|
|
136
|
+
if (!fs.existsSync(path.join(path.sep, rootUser))) {
|
|
119
137
|
cacheDir = path.join(os.tmpdir(), cacheHash);
|
|
120
138
|
}
|
|
121
139
|
try {
|
|
@@ -127,42 +145,52 @@
|
|
|
127
145
|
};
|
|
128
146
|
const NodeCache = async (dir) => {
|
|
129
147
|
const fs = require("node:fs");
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
const
|
|
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);
|
|
133
152
|
return {
|
|
134
153
|
makeKey: (key) => {
|
|
135
154
|
const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
|
|
136
155
|
return createHash("sha256").update(input).digest("hex");
|
|
137
156
|
},
|
|
138
157
|
get: async (key) => {
|
|
158
|
+
let readValue;
|
|
159
|
+
const cacheFilename = `${cacheDir}/${key}`;
|
|
139
160
|
try {
|
|
140
|
-
const data = await fs.promises.readFile(
|
|
141
|
-
|
|
161
|
+
const data = await fs.promises.readFile(cacheFilename, "utf-8");
|
|
162
|
+
readValue = JSON.parse(data);
|
|
142
163
|
} catch (e) {
|
|
143
|
-
if (e.code
|
|
144
|
-
|
|
164
|
+
if (e.code !== "ENOENT") {
|
|
165
|
+
console.error(
|
|
166
|
+
`Failed to read cache file to ${cacheFilename}: ${e.message}`
|
|
167
|
+
);
|
|
145
168
|
}
|
|
146
|
-
throw e;
|
|
147
169
|
}
|
|
170
|
+
return readValue;
|
|
148
171
|
},
|
|
149
172
|
set: async (key, value) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
JSON.stringify(value),
|
|
153
|
-
|
|
154
|
-
|
|
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
|
+
}
|
|
155
187
|
}
|
|
156
188
|
};
|
|
157
189
|
};
|
|
158
190
|
const nodeCache = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
159
191
|
__proto__: null,
|
|
160
|
-
NodeCache
|
|
161
|
-
|
|
162
|
-
const __viteBrowserExternal = {};
|
|
163
|
-
const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
164
|
-
__proto__: null,
|
|
165
|
-
default: __viteBrowserExternal
|
|
192
|
+
NodeCache,
|
|
193
|
+
makeCacheDir
|
|
166
194
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
167
195
|
exports2.TINA_HOST = TINA_HOST;
|
|
168
196
|
exports2.TinaClient = TinaClient;
|
package/dist/client.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { fetch: fetchPonyfillFN, Headers: HeadersPonyfill } = fetchPonyfill();
|
|
3
|
-
const fetchDefined = typeof fetch === "undefined" ? fetchPonyfillFN : fetch;
|
|
4
|
-
const HeadersDefined = typeof Headers === "undefined" ? HeadersPonyfill : Headers;
|
|
1
|
+
import AsyncLock from "async-lock";
|
|
5
2
|
const TINA_HOST = "content.tinajs.io";
|
|
3
|
+
function replaceGithubPathSplit(url, replacement) {
|
|
4
|
+
const parts = url.split("github/");
|
|
5
|
+
if (parts.length > 1 && replacement) {
|
|
6
|
+
return parts[0] + "github/" + replacement;
|
|
7
|
+
} else {
|
|
8
|
+
return url;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
class TinaClient {
|
|
7
12
|
constructor({
|
|
8
13
|
token,
|
|
@@ -24,8 +29,9 @@ class TinaClient {
|
|
|
24
29
|
}
|
|
25
30
|
try {
|
|
26
31
|
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
27
|
-
const { NodeCache } = await import("./node-cache-
|
|
32
|
+
const { NodeCache } = await import("./node-cache-5e8db9f0.mjs");
|
|
28
33
|
this.cache = await NodeCache(this.cacheDir);
|
|
34
|
+
this.cacheLock = new AsyncLock();
|
|
29
35
|
}
|
|
30
36
|
} catch (e) {
|
|
31
37
|
console.error(e);
|
|
@@ -36,7 +42,7 @@ class TinaClient {
|
|
|
36
42
|
var _a;
|
|
37
43
|
await this.init();
|
|
38
44
|
const errorPolicyDefined = errorPolicy || this.errorPolicy;
|
|
39
|
-
const headers = new
|
|
45
|
+
const headers = new Headers();
|
|
40
46
|
if (this.readonlyToken) {
|
|
41
47
|
headers.append("X-API-KEY", this.readonlyToken);
|
|
42
48
|
}
|
|
@@ -53,7 +59,6 @@ class TinaClient {
|
|
|
53
59
|
query: args.query,
|
|
54
60
|
variables: (args == null ? void 0 : args.variables) || {}
|
|
55
61
|
});
|
|
56
|
-
const url = (args == null ? void 0 : args.url) || this.apiUrl;
|
|
57
62
|
const optionsObject = {
|
|
58
63
|
method: "POST",
|
|
59
64
|
headers,
|
|
@@ -61,43 +66,61 @@ class TinaClient {
|
|
|
61
66
|
redirect: "follow",
|
|
62
67
|
...providedFetchOptions
|
|
63
68
|
};
|
|
69
|
+
const draftBranch = headers.get("x-branch");
|
|
70
|
+
const url = replaceGithubPathSplit((args == null ? void 0 : args.url) || this.apiUrl, draftBranch);
|
|
64
71
|
let key = "";
|
|
72
|
+
let result;
|
|
65
73
|
if (this.cache) {
|
|
66
74
|
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")}`
|
|
75
|
+
await this.cacheLock.acquire(key, async () => {
|
|
76
|
+
result = await this.cache.get(key);
|
|
77
|
+
if (!result) {
|
|
78
|
+
result = await requestFromServer(
|
|
79
|
+
url,
|
|
80
|
+
args.query,
|
|
81
|
+
optionsObject,
|
|
82
|
+
errorPolicyDefined
|
|
83
|
+
);
|
|
84
|
+
await this.cache.set(key, result);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
result = await requestFromServer(
|
|
89
|
+
url,
|
|
90
|
+
args.query,
|
|
91
|
+
optionsObject,
|
|
92
|
+
errorPolicyDefined
|
|
88
93
|
);
|
|
89
94
|
}
|
|
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
95
|
return result;
|
|
99
96
|
}
|
|
100
97
|
}
|
|
98
|
+
async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
|
|
99
|
+
const res = await fetch(url, optionsObject);
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
let additionalInfo = "";
|
|
102
|
+
if (res.status === 401) {
|
|
103
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
104
|
+
}
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
const json = await res.json();
|
|
110
|
+
if (json.errors && errorPolicyDefined === "throw") {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
113
|
+
Errors:
|
|
114
|
+
${json.errors.map((error) => error.message).join("\n")}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const result = {
|
|
118
|
+
data: json == null ? void 0 : json.data,
|
|
119
|
+
errors: (json == null ? void 0 : json.errors) || null,
|
|
120
|
+
query
|
|
121
|
+
};
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
101
124
|
function createClient(args) {
|
|
102
125
|
const client = new TinaClient(args);
|
|
103
126
|
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
|
@@ -53,7 +53,7 @@ export type TinaCollection = Collection;
|
|
|
53
53
|
export type TinaCloudSchema = Schema;
|
|
54
54
|
export declare const defineSchema: (config: Schema) => Schema<false>;
|
|
55
55
|
export declare const defineLegacyConfig: (config: Omit<TinaCMSProviderDefaultProps, "children">) => Omit<TinaCMSProviderDefaultProps, "children">;
|
|
56
|
-
interface MediaStoreClass {
|
|
56
|
+
export interface MediaStoreClass {
|
|
57
57
|
new (...args: any[]): MediaStore;
|
|
58
58
|
}
|
|
59
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>;
|