tinacms 0.58.1 → 0.60.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/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.60.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4700d7ae4]
8
+ - @tinacms/toolkit@0.56.3
9
+
10
+ ## 0.60.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 75974d0a4: Updates the tina cloud client to do id_token & access_token refreshes when needed
15
+
16
+ ### Patch Changes
17
+
18
+ - 88c209b45: Throw when Tina Cloud responds with non 200 code
19
+ - dcdf1ecf0: Updates `react-router` to `v6` for `TinaAdmin`
20
+ - 47d126029: Fix support of objects in a list for MDX templates
21
+ - Updated dependencies [bc4699d2b]
22
+ - @tinacms/toolkit@0.56.2
23
+
24
+ ## 0.59.1
25
+
26
+ ### Patch Changes
27
+
28
+ - ed9d48abc: Swaps starter's old admin for the new one
29
+ - f6876d30f: Alter empty sidebar message to be more specific to auto-generating logic
30
+ - Updated dependencies [f6876d30f]
31
+ - Updated dependencies [92268fc85]
32
+ - @tinacms/toolkit@0.56.1
33
+
34
+ ## 0.59.0
35
+
36
+ ### Minor Changes
37
+
38
+ - df3030990: Add basic branch switcher
39
+
40
+ ### Patch Changes
41
+
42
+ - 9ecceb59f: Always include `collection` for TinaAdmin `createDocument()` and `updateDocument()`
43
+ - Updated dependencies [df3030990]
44
+ - @tinacms/toolkit@0.56.0
45
+
3
46
  ## 0.58.1
4
47
 
5
48
  ### Patch Changes
@@ -0,0 +1,17 @@
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
+ declare const AuthTemplate: ({ message, children, }: {
14
+ message?: string;
15
+ children: any;
16
+ }) => JSX.Element;
17
+ export default AuthTemplate;
@@ -0,0 +1,17 @@
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
+ import type { TinaCMS } from '@tinacms/toolkit';
14
+ declare const Sidebar: ({ cms }: {
15
+ cms: TinaCMS;
16
+ }) => JSX.Element;
17
+ export default Sidebar;
@@ -0,0 +1,14 @@
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
+ declare const LogoutPage: () => JSX.Element;
14
+ export default LogoutPage;
@@ -11,9 +11,9 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import { TokenObject } from '../auth/authenticate';
14
+ import { BranchData, EventBus } from '@tinacms/toolkit';
14
15
  import { DocumentNode, GraphQLSchema } from 'graphql';
15
16
  import gql from 'graphql-tag';
16
- import { EventBus, BranchData } from '@tinacms/toolkit';
17
17
  export declare type TinaIOConfig = {
18
18
  frontendUrlOverride?: string;
19
19
  identityApiUrlOverride?: string;
@@ -23,7 +23,7 @@ interface ServerOptions {
23
23
  clientId: string;
24
24
  branch: string;
25
25
  customContentApiUrl?: string;
26
- getTokenFn?: () => TokenObject;
26
+ getTokenFn?: () => Promise<TokenObject>;
27
27
  tinaioConfig?: TinaIOConfig;
28
28
  tokenStorage?: 'MEMORY' | 'LOCAL_STORAGE' | 'CUSTOM';
29
29
  }
@@ -33,6 +33,7 @@ export declare class Client {
33
33
  identityApiUrl: string;
34
34
  schema: GraphQLSchema;
35
35
  clientId: string;
36
+ contentApiBase: string;
36
37
  query: string;
37
38
  setToken: (_token: TokenObject) => void;
38
39
  private getToken;
@@ -50,6 +51,8 @@ export declare class Client {
50
51
  request<ReturnType>(query: ((gqlTag: typeof gql) => DocumentNode) | string, { variables }: {
51
52
  variables: object;
52
53
  }): Promise<ReturnType>;
54
+ parseJwt(token: any): any;
55
+ getRefreshedToken(tokens: string): Promise<TokenObject>;
53
56
  isAuthorized(): Promise<boolean>;
54
57
  isAuthenticated(): Promise<boolean>;
55
58
  authenticate(): Promise<TokenObject>;
@@ -64,8 +67,8 @@ export declare class Client {
64
67
  */
65
68
  fetchWithToken(input: RequestInfo, init?: RequestInit): Promise<Response>;
66
69
  getUser(): Promise<any>;
67
- listBranches({ owner, repo }: BranchData): Promise<string>;
68
- createBranch({ owner, repo, baseBranch, branchName }: BranchData): Promise<string>;
70
+ listBranches(): Promise<any>;
71
+ createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
69
72
  }
70
73
  export declare const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
71
74
  export declare class LocalClient extends Client {
@@ -10,20 +10,11 @@ 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 { isEditing, setEditing, useEditState } from '@tinacms/sharedctx';
13
14
  import React from 'react';
15
+ export { isEditing, setEditing, useEditState };
14
16
  export declare const TinaEditProvider: ({ showEditButton, ...props }: {
15
17
  showEditButton?: boolean;
16
18
  children: React.ReactNode;
17
19
  editMode: React.ReactNode;
18
20
  }) => JSX.Element;
19
- export declare const isEditing: () => boolean;
20
- export declare const setEditing: (isEditing: boolean) => void;
21
- export declare const EditContext: React.Context<{
22
- edit: boolean;
23
- setEdit: (edit: boolean) => void;
24
- }>;
25
- export declare const EditProvider: React.FC;
26
- export declare const useEditState: () => {
27
- edit: boolean;
28
- setEdit: (edit: boolean) => void;
29
- };
@@ -26,7 +26,9 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
- import React, { useState, useContext } from "react";
29
+ import { EditProvider, useEditState } from "@tinacms/sharedctx";
30
+ export { isEditing, setEditing, useEditState } from "@tinacms/sharedctx";
31
+ import React from "react";
30
32
  const TinaEditProvider = (_a) => {
31
33
  var _b = _a, {
32
34
  showEditButton
@@ -37,7 +39,16 @@ const TinaEditProvider = (_a) => {
37
39
  };
38
40
  const ToggleButton = () => {
39
41
  const { edit } = useEditState();
40
- return edit ? null : /* @__PURE__ */ React.createElement("div", {
42
+ const [isOnAdmin, setIsOnAdmin] = React.useState(false);
43
+ React.useEffect(() => {
44
+ var _a;
45
+ if (window) {
46
+ if ((_a = window.location) == null ? void 0 : _a.pathname.startsWith("/admin")) {
47
+ setIsOnAdmin(true);
48
+ }
49
+ }
50
+ }, [setIsOnAdmin]);
51
+ return edit || isOnAdmin ? null : /* @__PURE__ */ React.createElement("div", {
41
52
  style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
42
53
  }, /* @__PURE__ */ React.createElement("a", {
43
54
  href: "/admin",
@@ -62,39 +73,4 @@ const TinaEditProviderInner = ({ children, editMode }) => {
62
73
  }
63
74
  return children;
64
75
  };
65
- const LOCALSTORAGEKEY = "tina.isEditing";
66
- const isSSR = typeof window === "undefined";
67
- const isEditing = () => {
68
- if (!isSSR) {
69
- const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
70
- return isEdit && isEdit === "true";
71
- }
72
- return false;
73
- };
74
- const setEditing = (isEditing2) => {
75
- if (!isSSR) {
76
- window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
77
- }
78
- };
79
- const EditContext = React.createContext({
80
- edit: isEditing(),
81
- setEdit: void 0
82
- });
83
- const EditProvider = ({ children }) => {
84
- const [edit, setEditState] = useState(isEditing());
85
- const setEdit = (edit2) => {
86
- setEditState(edit2);
87
- setEditing(edit2);
88
- };
89
- return /* @__PURE__ */ React.createElement(EditContext.Provider, {
90
- value: { edit, setEdit }
91
- }, children);
92
- };
93
- const useEditState = () => {
94
- const { edit, setEdit } = useContext(EditContext);
95
- if (!setEdit) {
96
- throw new Error("No `TinaEditProvider` found");
97
- }
98
- return { edit, setEdit };
99
- };
100
- export { EditContext, EditProvider, TinaEditProvider, isEditing, setEditing, useEditState };
76
+ export { TinaEditProvider };
@@ -27,8 +27,8 @@ var __objRest = (source, exclude) => {
27
27
  return target;
28
28
  };
29
29
  (function(global, factory) {
30
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
31
- })(this, function(exports2, React) {
30
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@tinacms/sharedctx"), require("react")) : typeof define === "function" && define.amd ? define(["exports", "@tinacms/sharedctx", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP));
31
+ })(this, function(exports2, sharedctx, React) {
32
32
  "use strict";
33
33
  function _interopDefaultLegacy(e) {
34
34
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
@@ -40,11 +40,20 @@ var __objRest = (source, exclude) => {
40
40
  } = _b, props = __objRest(_b, [
41
41
  "showEditButton"
42
42
  ]);
43
- return /* @__PURE__ */ React__default["default"].createElement(EditProvider, null, showEditButton && /* @__PURE__ */ React__default["default"].createElement(ToggleButton, null), /* @__PURE__ */ React__default["default"].createElement(TinaEditProviderInner, __spreadValues({}, props)));
43
+ return /* @__PURE__ */ React__default["default"].createElement(sharedctx.EditProvider, null, showEditButton && /* @__PURE__ */ React__default["default"].createElement(ToggleButton, null), /* @__PURE__ */ React__default["default"].createElement(TinaEditProviderInner, __spreadValues({}, props)));
44
44
  };
45
45
  const ToggleButton = () => {
46
- const { edit } = useEditState();
47
- return edit ? null : /* @__PURE__ */ React__default["default"].createElement("div", {
46
+ const { edit } = sharedctx.useEditState();
47
+ const [isOnAdmin, setIsOnAdmin] = React__default["default"].useState(false);
48
+ React__default["default"].useEffect(() => {
49
+ var _a;
50
+ if (window) {
51
+ if ((_a = window.location) == null ? void 0 : _a.pathname.startsWith("/admin")) {
52
+ setIsOnAdmin(true);
53
+ }
54
+ }
55
+ }, [setIsOnAdmin]);
56
+ return edit || isOnAdmin ? null : /* @__PURE__ */ React__default["default"].createElement("div", {
48
57
  style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
49
58
  }, /* @__PURE__ */ React__default["default"].createElement("a", {
50
59
  href: "/admin",
@@ -63,53 +72,31 @@ var __objRest = (source, exclude) => {
63
72
  }, "Edit with Tina"));
64
73
  };
65
74
  const TinaEditProviderInner = ({ children, editMode }) => {
66
- const { edit } = useEditState();
75
+ const { edit } = sharedctx.useEditState();
67
76
  if (edit) {
68
77
  return editMode;
69
78
  }
70
79
  return children;
71
80
  };
72
- const LOCALSTORAGEKEY = "tina.isEditing";
73
- const isSSR = typeof window === "undefined";
74
- const isEditing = () => {
75
- if (!isSSR) {
76
- const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
77
- return isEdit && isEdit === "true";
81
+ Object.defineProperty(exports2, "isEditing", {
82
+ enumerable: true,
83
+ get: function() {
84
+ return sharedctx.isEditing;
78
85
  }
79
- return false;
80
- };
81
- const setEditing = (isEditing2) => {
82
- if (!isSSR) {
83
- window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
86
+ });
87
+ Object.defineProperty(exports2, "setEditing", {
88
+ enumerable: true,
89
+ get: function() {
90
+ return sharedctx.setEditing;
84
91
  }
85
- };
86
- const EditContext = React__default["default"].createContext({
87
- edit: isEditing(),
88
- setEdit: void 0
89
92
  });
90
- const EditProvider = ({ children }) => {
91
- const [edit, setEditState] = React.useState(isEditing());
92
- const setEdit = (edit2) => {
93
- setEditState(edit2);
94
- setEditing(edit2);
95
- };
96
- return /* @__PURE__ */ React__default["default"].createElement(EditContext.Provider, {
97
- value: { edit, setEdit }
98
- }, children);
99
- };
100
- const useEditState = () => {
101
- const { edit, setEdit } = React.useContext(EditContext);
102
- if (!setEdit) {
103
- throw new Error("No `TinaEditProvider` found");
93
+ Object.defineProperty(exports2, "useEditState", {
94
+ enumerable: true,
95
+ get: function() {
96
+ return sharedctx.useEditState;
104
97
  }
105
- return { edit, setEdit };
106
- };
107
- exports2.EditContext = EditContext;
108
- exports2.EditProvider = EditProvider;
98
+ });
109
99
  exports2.TinaEditProvider = TinaEditProvider;
110
- exports2.isEditing = isEditing;
111
- exports2.setEditing = setEditing;
112
- exports2.useEditState = useEditState;
113
100
  Object.defineProperty(exports2, "__esModule", { value: true });
114
101
  exports2[Symbol.toStringTag] = "Module";
115
102
  });