tinacms 0.69.0 → 0.69.3

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
  };
@@ -1175,7 +1175,8 @@ const formify = async ({
1175
1175
  return formifyInlineFragmentNode({
1176
1176
  inlineFragmentNode: selectionNode,
1177
1177
  parentType: type,
1178
- path
1178
+ path,
1179
+ showInSidebar: true
1179
1180
  });
1180
1181
  }
1181
1182
  case "Field": {
@@ -1245,7 +1246,8 @@ const formify = async ({
1245
1246
  return formifyInlineFragmentNode({
1246
1247
  inlineFragmentNode: selectionNode,
1247
1248
  parentType: field.type,
1248
- path: fieldPath
1249
+ path: fieldPath,
1250
+ showInSidebar: false
1249
1251
  });
1250
1252
  }
1251
1253
  default:
@@ -1259,7 +1261,8 @@ const formify = async ({
1259
1261
  const formifyInlineFragmentNode = ({
1260
1262
  inlineFragmentNode,
1261
1263
  parentType,
1262
- path
1264
+ path,
1265
+ showInSidebar
1263
1266
  }) => {
1264
1267
  const type = getSelectedUnionType(parentType, inlineFragmentNode);
1265
1268
  if (!type) {
@@ -1270,7 +1273,7 @@ const formify = async ({
1270
1273
  inlineFragmentNode,
1271
1274
  type,
1272
1275
  path,
1273
- showInSidebar: false
1276
+ showInSidebar
1274
1277
  });
1275
1278
  }
1276
1279
  return {
@@ -1903,7 +1906,7 @@ const useFormify = ({
1903
1906
  }
1904
1907
  });
1905
1908
  }).catch((e) => {
1906
- cms.alerts.error(`Unexpected error fetching reference`);
1909
+ cms.alerts.error(`Unexpected error fetching reference.`);
1907
1910
  console.log(e);
1908
1911
  });
1909
1912
  }
@@ -3854,9 +3857,9 @@ const useDocumentCreatorPlugin = (args) => {
3854
3857
  }
3855
3858
  return true;
3856
3859
  }
3857
- const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3860
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3858
3861
  if (value && !isValid) {
3859
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3862
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3860
3863
  }
3861
3864
  }
3862
3865
  }
@@ -4747,14 +4750,15 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, after =
4747
4750
  const [resetState, setResetSate] = useState(0);
4748
4751
  useEffect(() => {
4749
4752
  const fetchCollection = async () => {
4753
+ var _a;
4750
4754
  if (await api.isAuthenticated()) {
4751
4755
  const { name, order } = JSON.parse(sortKey || "{}");
4752
- const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4756
+ const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4753
4757
  try {
4754
4758
  const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4755
4759
  setCollection(collection2);
4756
4760
  } catch (error2) {
4757
- cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
4761
+ cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
4758
4762
  console.error(error2);
4759
4763
  setCollection(void 0);
4760
4764
  setError(error2);
@@ -4857,12 +4861,12 @@ const CollectionListPage = () => {
4857
4861
  startCursor: endCursor,
4858
4862
  sortKey
4859
4863
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
4860
- var _a, _b;
4864
+ var _a, _b, _c;
4861
4865
  const totalCount = collection.documents.totalCount;
4862
4866
  const documents = collection.documents.edges;
4863
4867
  const admin = cms.api.admin;
4864
4868
  const pageInfo = collection.documents.pageInfo;
4865
- const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4869
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
4866
4870
  return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, open && /* @__PURE__ */ React.createElement(DeleteModal, {
4867
4871
  filename: vars.relativePath,
4868
4872
  deleteFunc: async () => {
@@ -4878,12 +4882,12 @@ const CollectionListPage = () => {
4878
4882
  },
4879
4883
  close: () => setOpen(false)
4880
4884
  }), /* @__PURE__ */ React.createElement(PageHeader, {
4881
- isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4885
+ isLocalMode: (_c = (_b = cms == null ? void 0 : cms.api) == null ? void 0 : _b.tina) == null ? void 0 : _c.isLocalMode
4882
4886
  }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
4883
4887
  className: "flex flex-col gap-4"
4884
4888
  }, /* @__PURE__ */ React.createElement("h3", {
4885
4889
  className: "font-sans text-2xl text-gray-700"
4886
- }, collection.label ? collection.label : collection.name), fields.length > 0 && /* @__PURE__ */ React.createElement("div", {
4890
+ }, collection.label ? collection.label : collection.name), (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React.createElement("div", {
4887
4891
  className: "flex gap-2 items-center"
4888
4892
  }, /* @__PURE__ */ React.createElement("label", {
4889
4893
  htmlFor: "sort",
@@ -5071,8 +5075,8 @@ const createDocument = async (cms, collection, template, mutationInfo, values) =
5071
5075
  if (await api.isAuthenticated()) {
5072
5076
  await api.createDocument(collection.name, relativePath, params);
5073
5077
  } else {
5074
- const authMessage = `[Error] CreateDocument failed: User is no longer authenticated; please login and try again.`;
5075
- cms.alerts.error(authMessage, 30 * 1e3);
5078
+ const authMessage = `CreateDocument failed: User is no longer authenticated; please login and try again.`;
5079
+ cms.alerts.error(authMessage);
5076
5080
  console.error(authMessage);
5077
5081
  return false;
5078
5082
  }
@@ -5130,9 +5134,9 @@ const RenderForm$1 = ({ cms, collection, templateName, mutationInfo }) => {
5130
5134
  }
5131
5135
  return true;
5132
5136
  }
5133
- const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
5137
+ const isValid = /^[_a-zA-Z0-9][\.\-_\/a-zA-Z0-9]*$/.test(value);
5134
5138
  if (value && !isValid) {
5135
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5139
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5136
5140
  }
5137
5141
  }
5138
5142
  },
@@ -5188,7 +5192,7 @@ const useGetDocument = (cms, collectionName, relativePath) => {
5188
5192
  const response = await api.fetchDocument(collectionName, relativePath);
5189
5193
  setDocument(response.document);
5190
5194
  } catch (error2) {
5191
- cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`, 30 * 1e3);
5195
+ cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`);
5192
5196
  console.error(error2);
5193
5197
  setDocument(void 0);
5194
5198
  setError(error2);
@@ -5226,8 +5230,8 @@ const updateDocument = async (cms, relativePath, collection, mutationInfo, value
5226
5230
  if (await api.isAuthenticated()) {
5227
5231
  await api.updateDocument(collection.name, relativePath, params);
5228
5232
  } else {
5229
- const authMessage = `[Error] UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5230
- cms.alerts.error(authMessage, 30 * 1e3);
5233
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5234
+ cms.alerts.error(authMessage);
5231
5235
  console.error(authMessage);
5232
5236
  return false;
5233
5237
  }
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
  };
@@ -1193,7 +1193,8 @@
1193
1193
  return formifyInlineFragmentNode({
1194
1194
  inlineFragmentNode: selectionNode,
1195
1195
  parentType: type,
1196
- path
1196
+ path,
1197
+ showInSidebar: true
1197
1198
  });
1198
1199
  }
1199
1200
  case "Field": {
@@ -1263,7 +1264,8 @@
1263
1264
  return formifyInlineFragmentNode({
1264
1265
  inlineFragmentNode: selectionNode,
1265
1266
  parentType: field.type,
1266
- path: fieldPath
1267
+ path: fieldPath,
1268
+ showInSidebar: false
1267
1269
  });
1268
1270
  }
1269
1271
  default:
@@ -1277,7 +1279,8 @@
1277
1279
  const formifyInlineFragmentNode = ({
1278
1280
  inlineFragmentNode,
1279
1281
  parentType,
1280
- path
1282
+ path,
1283
+ showInSidebar
1281
1284
  }) => {
1282
1285
  const type = getSelectedUnionType(parentType, inlineFragmentNode);
1283
1286
  if (!type) {
@@ -1288,7 +1291,7 @@
1288
1291
  inlineFragmentNode,
1289
1292
  type,
1290
1293
  path,
1291
- showInSidebar: false
1294
+ showInSidebar
1292
1295
  });
1293
1296
  }
1294
1297
  return {
@@ -1921,7 +1924,7 @@
1921
1924
  }
1922
1925
  });
1923
1926
  }).catch((e) => {
1924
- cms.alerts.error(`Unexpected error fetching reference`);
1927
+ cms.alerts.error(`Unexpected error fetching reference.`);
1925
1928
  console.log(e);
1926
1929
  });
1927
1930
  }
@@ -3872,9 +3875,9 @@ mutation addPendingDocumentMutation(
3872
3875
  }
3873
3876
  return true;
3874
3877
  }
3875
- const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3878
+ const isValid = /^[_a-zA-Z0-9][\-_a-zA-Z0-9]*$/.test(value);
3876
3879
  if (value && !isValid) {
3877
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3880
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, - or _";
3878
3881
  }
3879
3882
  }
3880
3883
  }
@@ -4765,14 +4768,15 @@ This will work when developing locally but NOT when deployed to production.
4765
4768
  const [resetState, setResetSate] = React.useState(0);
4766
4769
  React.useEffect(() => {
4767
4770
  const fetchCollection = async () => {
4771
+ var _a;
4768
4772
  if (await api.isAuthenticated()) {
4769
4773
  const { name, order } = JSON.parse(sortKey || "{}");
4770
- const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4774
+ const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4771
4775
  try {
4772
4776
  const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4773
4777
  setCollection(collection2);
4774
4778
  } catch (error2) {
4775
- cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
4779
+ cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
4776
4780
  console.error(error2);
4777
4781
  setCollection(void 0);
4778
4782
  setError(error2);
@@ -4875,12 +4879,12 @@ This will work when developing locally but NOT when deployed to production.
4875
4879
  startCursor: endCursor,
4876
4880
  sortKey
4877
4881
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
4878
- var _a, _b;
4882
+ var _a, _b, _c;
4879
4883
  const totalCount = collection.documents.totalCount;
4880
4884
  const documents = collection.documents.edges;
4881
4885
  const admin = cms.api.admin;
4882
4886
  const pageInfo = collection.documents.pageInfo;
4883
- const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4887
+ const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
4884
4888
  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, {
4885
4889
  filename: vars.relativePath,
4886
4890
  deleteFunc: async () => {
@@ -4896,12 +4900,12 @@ This will work when developing locally but NOT when deployed to production.
4896
4900
  },
4897
4901
  close: () => setOpen(false)
4898
4902
  }), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
4899
- isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4903
+ isLocalMode: (_c = (_b = cms == null ? void 0 : cms.api) == null ? void 0 : _b.tina) == null ? void 0 : _c.isLocalMode
4900
4904
  }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4901
4905
  className: "flex flex-col gap-4"
4902
4906
  }, /* @__PURE__ */ React__default["default"].createElement("h3", {
4903
4907
  className: "font-sans text-2xl text-gray-700"
4904
- }, collection.label ? collection.label : collection.name), fields.length > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
4908
+ }, collection.label ? collection.label : collection.name), (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
4905
4909
  className: "flex gap-2 items-center"
4906
4910
  }, /* @__PURE__ */ React__default["default"].createElement("label", {
4907
4911
  htmlFor: "sort",
@@ -5089,8 +5093,8 @@ This will work when developing locally but NOT when deployed to production.
5089
5093
  if (await api.isAuthenticated()) {
5090
5094
  await api.createDocument(collection.name, relativePath, params);
5091
5095
  } else {
5092
- const authMessage = `[Error] CreateDocument failed: User is no longer authenticated; please login and try again.`;
5093
- cms.alerts.error(authMessage, 30 * 1e3);
5096
+ const authMessage = `CreateDocument failed: User is no longer authenticated; please login and try again.`;
5097
+ cms.alerts.error(authMessage);
5094
5098
  console.error(authMessage);
5095
5099
  return false;
5096
5100
  }
@@ -5148,9 +5152,9 @@ This will work when developing locally but NOT when deployed to production.
5148
5152
  }
5149
5153
  return true;
5150
5154
  }
5151
- const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
5155
+ const isValid = /^[_a-zA-Z0-9][\.\-_\/a-zA-Z0-9]*$/.test(value);
5152
5156
  if (value && !isValid) {
5153
- return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5157
+ return "Must begin with a-z, A-Z, 0-9, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
5154
5158
  }
5155
5159
  }
5156
5160
  },
@@ -5206,7 +5210,7 @@ This will work when developing locally but NOT when deployed to production.
5206
5210
  const response = await api.fetchDocument(collectionName, relativePath);
5207
5211
  setDocument(response.document);
5208
5212
  } catch (error2) {
5209
- cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`, 30 * 1e3);
5213
+ cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`);
5210
5214
  console.error(error2);
5211
5215
  setDocument(void 0);
5212
5216
  setError(error2);
@@ -5244,8 +5248,8 @@ This will work when developing locally but NOT when deployed to production.
5244
5248
  if (await api.isAuthenticated()) {
5245
5249
  await api.updateDocument(collection.name, relativePath, params);
5246
5250
  } else {
5247
- const authMessage = `[Error] UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5248
- cms.alerts.error(authMessage, 30 * 1e3);
5251
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5252
+ cms.alerts.error(authMessage);
5249
5253
  console.error(authMessage);
5250
5254
  return false;
5251
5255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.69.0",
3
+ "version": "0.69.3",
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",