tinacms 0.69.1 → 0.69.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/dist/index.es.js CHANGED
@@ -577,13 +577,13 @@ const buildForm = (doc, cms, formify2, showInSidebar = false, onSubmit) => {
577
577
  });
578
578
  cms.alerts.success("Document saved!");
579
579
  } catch (e) {
580
- cms.alerts.error("There was a problem saving your document");
580
+ cms.alerts.error("There was a problem saving your document.");
581
581
  console.error(e);
582
582
  }
583
583
  }
584
584
  } catch (e) {
585
585
  console.error(e);
586
- cms.alerts.error("There was a problem saving your document");
586
+ cms.alerts.error("There was a problem saving your document.");
587
587
  }
588
588
  }
589
589
  };
@@ -964,14 +964,16 @@ function buildPath({
964
964
  }
965
965
  const node = G.parse(`
966
966
  query Sample {
967
- _internalSys: _sys {
968
- path
969
- relativePath
970
- collection {
971
- name
972
- }
973
- }
974
- _values
967
+ ...on Document {
968
+ _internalSys: _sys {
969
+ path
970
+ relativePath
971
+ collection {
972
+ name
973
+ }
974
+ }
975
+ _values
976
+ }
975
977
  }`);
976
978
  const metaFields = node.definitions[0].selectionSet.selections;
977
979
  const getRelativeBlueprint = (path) => {
@@ -1906,7 +1908,7 @@ const useFormify = ({
1906
1908
  }
1907
1909
  });
1908
1910
  }).catch((e) => {
1909
- cms.alerts.error(`Unexpected error fetching reference`);
1911
+ cms.alerts.error(`Unexpected error fetching reference.`);
1910
1912
  console.log(e);
1911
1913
  });
1912
1914
  }
@@ -3857,9 +3859,9 @@ const useDocumentCreatorPlugin = (args) => {
3857
3859
  }
3858
3860
  return true;
3859
3861
  }
3860
- const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3862
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3861
3863
  if (value && !isValid) {
3862
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3864
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3863
3865
  }
3864
3866
  }
3865
3867
  }
@@ -4750,14 +4752,15 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, after =
4750
4752
  const [resetState, setResetSate] = useState(0);
4751
4753
  useEffect(() => {
4752
4754
  const fetchCollection = async () => {
4755
+ var _a;
4753
4756
  if (await api.isAuthenticated()) {
4754
4757
  const { name, order } = JSON.parse(sortKey || "{}");
4755
- const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4758
+ const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4756
4759
  try {
4757
4760
  const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4758
4761
  setCollection(collection2);
4759
4762
  } catch (error2) {
4760
- cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
4763
+ cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
4761
4764
  console.error(error2);
4762
4765
  setCollection(void 0);
4763
4766
  setError(error2);
@@ -4860,12 +4863,12 @@ const CollectionListPage = () => {
4860
4863
  startCursor: endCursor,
4861
4864
  sortKey
4862
4865
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
4863
- var _a, _b;
4866
+ var _a, _b, _c;
4864
4867
  const totalCount = collection.documents.totalCount;
4865
4868
  const documents = collection.documents.edges;
4866
4869
  const admin = cms.api.admin;
4867
4870
  const pageInfo = collection.documents.pageInfo;
4868
- const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4871
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
4869
4872
  return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, open && /* @__PURE__ */ React.createElement(DeleteModal, {
4870
4873
  filename: vars.relativePath,
4871
4874
  deleteFunc: async () => {
@@ -4881,12 +4884,12 @@ const CollectionListPage = () => {
4881
4884
  },
4882
4885
  close: () => setOpen(false)
4883
4886
  }), /* @__PURE__ */ React.createElement(PageHeader, {
4884
- isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4887
+ isLocalMode: (_c = (_b = cms == null ? void 0 : cms.api) == null ? void 0 : _b.tina) == null ? void 0 : _c.isLocalMode
4885
4888
  }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
4886
4889
  className: "flex flex-col gap-4"
4887
4890
  }, /* @__PURE__ */ React.createElement("h3", {
4888
4891
  className: "font-sans text-2xl text-gray-700"
4889
- }, collection.label ? collection.label : collection.name), fields.length > 0 && /* @__PURE__ */ React.createElement("div", {
4892
+ }, collection.label ? collection.label : collection.name), (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React.createElement("div", {
4890
4893
  className: "flex gap-2 items-center"
4891
4894
  }, /* @__PURE__ */ React.createElement("label", {
4892
4895
  htmlFor: "sort",
@@ -5074,8 +5077,8 @@ const createDocument = async (cms, collection, template, mutationInfo, values) =
5074
5077
  if (await api.isAuthenticated()) {
5075
5078
  await api.createDocument(collection.name, relativePath, params);
5076
5079
  } else {
5077
- const authMessage = `[Error] CreateDocument failed: User is no longer authenticated; please login and try again.`;
5078
- cms.alerts.error(authMessage, 30 * 1e3);
5080
+ const authMessage = `CreateDocument failed: User is no longer authenticated; please login and try again.`;
5081
+ cms.alerts.error(authMessage);
5079
5082
  console.error(authMessage);
5080
5083
  return false;
5081
5084
  }
@@ -5133,9 +5136,9 @@ const RenderForm$1 = ({ cms, collection, templateName, mutationInfo }) => {
5133
5136
  }
5134
5137
  return true;
5135
5138
  }
5136
- const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
5139
+ const isValid = /^[_a-zA-Z0-9][\.\-_\/a-zA-Z0-9]*$/.test(value);
5137
5140
  if (value && !isValid) {
5138
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5141
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5139
5142
  }
5140
5143
  }
5141
5144
  },
@@ -5191,7 +5194,7 @@ const useGetDocument = (cms, collectionName, relativePath) => {
5191
5194
  const response = await api.fetchDocument(collectionName, relativePath);
5192
5195
  setDocument(response.document);
5193
5196
  } catch (error2) {
5194
- cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`, 30 * 1e3);
5197
+ cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`);
5195
5198
  console.error(error2);
5196
5199
  setDocument(void 0);
5197
5200
  setError(error2);
@@ -5229,8 +5232,8 @@ const updateDocument = async (cms, relativePath, collection, mutationInfo, value
5229
5232
  if (await api.isAuthenticated()) {
5230
5233
  await api.updateDocument(collection.name, relativePath, params);
5231
5234
  } else {
5232
- const authMessage = `[Error] UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5233
- cms.alerts.error(authMessage, 30 * 1e3);
5235
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5236
+ cms.alerts.error(authMessage);
5234
5237
  console.error(authMessage);
5235
5238
  return false;
5236
5239
  }
package/dist/index.js CHANGED
@@ -595,13 +595,13 @@
595
595
  });
596
596
  cms.alerts.success("Document saved!");
597
597
  } catch (e) {
598
- cms.alerts.error("There was a problem saving your document");
598
+ cms.alerts.error("There was a problem saving your document.");
599
599
  console.error(e);
600
600
  }
601
601
  }
602
602
  } catch (e) {
603
603
  console.error(e);
604
- cms.alerts.error("There was a problem saving your document");
604
+ cms.alerts.error("There was a problem saving your document.");
605
605
  }
606
606
  }
607
607
  };
@@ -982,14 +982,16 @@
982
982
  }
983
983
  const node = G__namespace.parse(`
984
984
  query Sample {
985
- _internalSys: _sys {
986
- path
987
- relativePath
988
- collection {
989
- name
990
- }
991
- }
992
- _values
985
+ ...on Document {
986
+ _internalSys: _sys {
987
+ path
988
+ relativePath
989
+ collection {
990
+ name
991
+ }
992
+ }
993
+ _values
994
+ }
993
995
  }`);
994
996
  const metaFields = node.definitions[0].selectionSet.selections;
995
997
  const getRelativeBlueprint = (path) => {
@@ -1924,7 +1926,7 @@
1924
1926
  }
1925
1927
  });
1926
1928
  }).catch((e) => {
1927
- cms.alerts.error(`Unexpected error fetching reference`);
1929
+ cms.alerts.error(`Unexpected error fetching reference.`);
1928
1930
  console.log(e);
1929
1931
  });
1930
1932
  }
@@ -3875,9 +3877,9 @@ mutation addPendingDocumentMutation(
3875
3877
  }
3876
3878
  return true;
3877
3879
  }
3878
- const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3880
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3879
3881
  if (value && !isValid) {
3880
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3882
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3881
3883
  }
3882
3884
  }
3883
3885
  }
@@ -4768,14 +4770,15 @@ This will work when developing locally but NOT when deployed to production.
4768
4770
  const [resetState, setResetSate] = React.useState(0);
4769
4771
  React.useEffect(() => {
4770
4772
  const fetchCollection = async () => {
4773
+ var _a;
4771
4774
  if (await api.isAuthenticated()) {
4772
4775
  const { name, order } = JSON.parse(sortKey || "{}");
4773
- const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4776
+ const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4774
4777
  try {
4775
4778
  const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4776
4779
  setCollection(collection2);
4777
4780
  } catch (error2) {
4778
- cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
4781
+ cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
4779
4782
  console.error(error2);
4780
4783
  setCollection(void 0);
4781
4784
  setError(error2);
@@ -4878,12 +4881,12 @@ This will work when developing locally but NOT when deployed to production.
4878
4881
  startCursor: endCursor,
4879
4882
  sortKey
4880
4883
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
4881
- var _a, _b;
4884
+ var _a, _b, _c;
4882
4885
  const totalCount = collection.documents.totalCount;
4883
4886
  const documents = collection.documents.edges;
4884
4887
  const admin = cms.api.admin;
4885
4888
  const pageInfo = collection.documents.pageInfo;
4886
- const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4889
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
4887
4890
  return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, open && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
4888
4891
  filename: vars.relativePath,
4889
4892
  deleteFunc: async () => {
@@ -4899,12 +4902,12 @@ This will work when developing locally but NOT when deployed to production.
4899
4902
  },
4900
4903
  close: () => setOpen(false)
4901
4904
  }), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
4902
- isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4905
+ isLocalMode: (_c = (_b = cms == null ? void 0 : cms.api) == null ? void 0 : _b.tina) == null ? void 0 : _c.isLocalMode
4903
4906
  }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4904
4907
  className: "flex flex-col gap-4"
4905
4908
  }, /* @__PURE__ */ React__default["default"].createElement("h3", {
4906
4909
  className: "font-sans text-2xl text-gray-700"
4907
- }, collection.label ? collection.label : collection.name), fields.length > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
4910
+ }, collection.label ? collection.label : collection.name), (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
4908
4911
  className: "flex gap-2 items-center"
4909
4912
  }, /* @__PURE__ */ React__default["default"].createElement("label", {
4910
4913
  htmlFor: "sort",
@@ -5092,8 +5095,8 @@ This will work when developing locally but NOT when deployed to production.
5092
5095
  if (await api.isAuthenticated()) {
5093
5096
  await api.createDocument(collection.name, relativePath, params);
5094
5097
  } else {
5095
- const authMessage = `[Error] CreateDocument failed: User is no longer authenticated; please login and try again.`;
5096
- cms.alerts.error(authMessage, 30 * 1e3);
5098
+ const authMessage = `CreateDocument failed: User is no longer authenticated; please login and try again.`;
5099
+ cms.alerts.error(authMessage);
5097
5100
  console.error(authMessage);
5098
5101
  return false;
5099
5102
  }
@@ -5151,9 +5154,9 @@ This will work when developing locally but NOT when deployed to production.
5151
5154
  }
5152
5155
  return true;
5153
5156
  }
5154
- const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
5157
+ const isValid = /^[_a-zA-Z0-9][\.\-_\/a-zA-Z0-9]*$/.test(value);
5155
5158
  if (value && !isValid) {
5156
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5159
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5157
5160
  }
5158
5161
  }
5159
5162
  },
@@ -5209,7 +5212,7 @@ This will work when developing locally but NOT when deployed to production.
5209
5212
  const response = await api.fetchDocument(collectionName, relativePath);
5210
5213
  setDocument(response.document);
5211
5214
  } catch (error2) {
5212
- cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`, 30 * 1e3);
5215
+ cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`);
5213
5216
  console.error(error2);
5214
5217
  setDocument(void 0);
5215
5218
  setError(error2);
@@ -5247,8 +5250,8 @@ This will work when developing locally but NOT when deployed to production.
5247
5250
  if (await api.isAuthenticated()) {
5248
5251
  await api.updateDocument(collection.name, relativePath, params);
5249
5252
  } else {
5250
- const authMessage = `[Error] UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5251
- cms.alerts.error(authMessage, 30 * 1e3);
5253
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5254
+ cms.alerts.error(authMessage);
5252
5255
  console.error(authMessage);
5253
5256
  return false;
5254
5257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.69.1",
3
+ "version": "0.69.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -50,7 +50,7 @@
50
50
  "@react-hook/window-size": "^3.0.7",
51
51
  "@tinacms/schema-tools": "0.1.0",
52
52
  "@tinacms/sharedctx": "0.1.2",
53
- "@tinacms/toolkit": "0.57.0",
53
+ "@tinacms/toolkit": "0.57.2",
54
54
  "crypto-js": "^4.0.0",
55
55
  "fetch-ponyfill": "^7.1.0",
56
56
  "final-form": "4.20.1",
@@ -70,7 +70,7 @@
70
70
  "@testing-library/react": "^12.0.0",
71
71
  "@testing-library/react-hooks": "^7.0.2",
72
72
  "@testing-library/user-event": "^12.7.0",
73
- "@tinacms/scripts": "0.51.0",
73
+ "@tinacms/scripts": "0.51.1",
74
74
  "@types/jest": "^27.0.1",
75
75
  "@types/lodash": "^4.14.169",
76
76
  "@types/node": "^14.0.13",
@@ -80,7 +80,7 @@
80
80
  "isomorphic-fetch": "^3.0.0",
81
81
  "jest": "^27.0.6",
82
82
  "jest-file-snapshot": "^0.5.0",
83
- "next": "9.4.2",
83
+ "next": "12.2.4",
84
84
  "react": "17.0.2",
85
85
  "react-dom": "17.0.2",
86
86
  "react-is": "^17.0.2",