tinacms 3.3.2 → 3.4.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/dist/index.js CHANGED
@@ -46532,7 +46532,7 @@ const NavProvider = ({
46532
46532
  };
46533
46533
  return /* @__PURE__ */ React__default.createElement(NavContext.Provider, { value }, children);
46534
46534
  };
46535
- const version$1 = "3.3.2";
46535
+ const version$1 = "3.4.1";
46536
46536
  const VersionInfo = () => {
46537
46537
  var _a2, _b, _c, _d, _e, _f;
46538
46538
  const cms = useCMS();
@@ -48661,6 +48661,11 @@ const EDITORIAL_WORKFLOW_STATUS = {
48661
48661
  ERROR: "error",
48662
48662
  TIMEOUT: "timeout"
48663
48663
  };
48664
+ const EDITORIAL_WORKFLOW_ERROR = {
48665
+ BRANCH_EXISTS: "BRANCH_EXISTS",
48666
+ BRANCH_HIERARCHY_CONFLICT: "BRANCH_HIERARCHY_CONFLICT",
48667
+ VALIDATION_FAILED: "VALIDATION_FAILED"
48668
+ };
48664
48669
  const num123 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
48665
48670
  const numFas = ["۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "۰"];
48666
48671
  const numKor = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
@@ -64237,7 +64242,27 @@ const CreateBranchModal = ({
64237
64242
  close2();
64238
64243
  } catch (e3) {
64239
64244
  console.error(e3);
64240
- const errorMessage2 = e3.message && e3.message.includes("Branch already exists") ? "Branch already exists" : "Branch operation failed, please try again. If the problem persists please contact support.";
64245
+ let errorMessage2 = "Branch operation failed, please try again. If the problem persists please contact support.";
64246
+ const err = e3;
64247
+ if (err.errorCode) {
64248
+ switch (err.errorCode) {
64249
+ case EDITORIAL_WORKFLOW_ERROR.BRANCH_EXISTS:
64250
+ errorMessage2 = "A branch with this name already exists";
64251
+ break;
64252
+ case EDITORIAL_WORKFLOW_ERROR.BRANCH_HIERARCHY_CONFLICT:
64253
+ errorMessage2 = err.message || "Branch name conflicts with an existing branch";
64254
+ break;
64255
+ case EDITORIAL_WORKFLOW_ERROR.VALIDATION_FAILED:
64256
+ errorMessage2 = err.message || "Invalid branch name";
64257
+ break;
64258
+ }
64259
+ } else if (err.message) {
64260
+ if (err.message.toLowerCase().includes("already exists")) {
64261
+ errorMessage2 = "A branch with this name already exists";
64262
+ } else if (err.message.toLowerCase().includes("conflict")) {
64263
+ errorMessage2 = err.message;
64264
+ }
64265
+ }
64241
64266
  setErrorMessage(errorMessage2);
64242
64267
  setDisabled(false);
64243
64268
  setIsExecuting(false);
@@ -119749,9 +119774,16 @@ mutation addPendingDocumentMutation(
119749
119774
  const responseBody = await res.json();
119750
119775
  if (!res.ok) {
119751
119776
  console.error("There was an error starting editorial workflow.");
119752
- throw new Error(
119777
+ const error2 = new Error(
119753
119778
  (responseBody == null ? void 0 : responseBody.message) || "Failed to start editorial workflow"
119754
119779
  );
119780
+ if (responseBody == null ? void 0 : responseBody.errorCode) {
119781
+ error2.errorCode = responseBody.errorCode;
119782
+ }
119783
+ if (responseBody == null ? void 0 : responseBody.conflictingBranch) {
119784
+ error2.conflictingBranch = responseBody.conflictingBranch;
119785
+ }
119786
+ throw error2;
119755
119787
  }
119756
119788
  const requestId = responseBody.requestId;
119757
119789
  if (!requestId) {
@@ -121341,7 +121373,7 @@ const CollectionListPage = () => {
121341
121373
  search
121342
121374
  },
121343
121375
  (collection, _loading, reFetchCollection, collectionExtra) => {
121344
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
121376
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
121345
121377
  const documents = collection.documents.edges;
121346
121378
  const admin = cms.api.admin;
121347
121379
  const pageInfo = collection.documents.pageInfo;
@@ -121358,10 +121390,11 @@ const CollectionListPage = () => {
121358
121390
  const collectionDefinition = cms.api.tina.schema.getCollection(
121359
121391
  collection.name
121360
121392
  );
121361
- const allowCreate = ((_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.create) ?? true;
121362
- const allowDelete = ((_h = (_g = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _g.allowedActions) == null ? void 0 : _h.delete) ?? true;
121363
- const allowCreateFolder = ((_j = (_i = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _i.allowedActions) == null ? void 0 : _j.createFolder) ?? true;
121364
- const allowCreateNestedFolder = ((_l = (_k = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _k.allowedActions) == null ? void 0 : _l.createNestedFolder) ?? true;
121393
+ const parse2 = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.filename) == null ? void 0 : _f.parse;
121394
+ const allowCreate = ((_h = (_g = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _g.allowedActions) == null ? void 0 : _h.create) ?? true;
121395
+ const allowDelete = ((_j = (_i = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _i.allowedActions) == null ? void 0 : _j.delete) ?? true;
121396
+ const allowCreateFolder = ((_l = (_k = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _k.allowedActions) == null ? void 0 : _l.createFolder) ?? true;
121397
+ const allowCreateNestedFolder = ((_n = (_m = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _m.allowedActions) == null ? void 0 : _n.createNestedFolder) ?? true;
121365
121398
  const folderView = folder.fullyQualifiedName !== "";
121366
121399
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React__default.createElement(
121367
121400
  DeleteModal,
@@ -121433,6 +121466,7 @@ const CollectionListPage = () => {
121433
121466
  ), renameModalOpen && /* @__PURE__ */ React__default.createElement(
121434
121467
  RenameModal,
121435
121468
  {
121469
+ parser: parse2,
121436
121470
  filename: vars.relativePathWithoutExtension,
121437
121471
  newRelativePath: vars.newRelativePath,
121438
121472
  setNewRelativePath: (newRelativePath) => {
@@ -121477,7 +121511,7 @@ const CollectionListPage = () => {
121477
121511
  return { ...vars2, folderName };
121478
121512
  });
121479
121513
  },
121480
- validationRegex: (_o = (_n = (_m = cms.api.tina) == null ? void 0 : _m.schema.config.config.ui) == null ? void 0 : _n.regexValidation) == null ? void 0 : _o.folderNameRegex,
121514
+ validationRegex: (_q = (_p = (_o = cms.api.tina) == null ? void 0 : _o.schema.config.config.ui) == null ? void 0 : _p.regexValidation) == null ? void 0 : _q.folderNameRegex,
121481
121515
  createFunc: async () => {
121482
121516
  try {
121483
121517
  admin.createFolder(
@@ -122100,6 +122134,7 @@ const FolderModal = ({
122100
122134
  ))));
122101
122135
  };
122102
122136
  const RenameModal = ({
122137
+ parser,
122103
122138
  close: close2,
122104
122139
  renameFunc,
122105
122140
  filename,
@@ -122111,7 +122146,13 @@ const RenameModal = ({
122111
122146
  {
122112
122147
  placeholder: "Enter a new name for the document's file",
122113
122148
  value: newRelativePath,
122114
- onChange: (event) => setNewRelativePath(event.target.value)
122149
+ onChange: (event) => {
122150
+ let value = event.target.value;
122151
+ if (parser) {
122152
+ value = parser(value);
122153
+ }
122154
+ setNewRelativePath(value);
122155
+ }
122115
122156
  }
122116
122157
  ))), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$2, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
122117
122158
  Button$2,
@@ -122450,7 +122491,7 @@ const RenderForm$1 = ({
122450
122491
  mutationInfo,
122451
122492
  customDefaults
122452
122493
  }) => {
122453
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
122494
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
122454
122495
  const navigate = useNavigate();
122455
122496
  const [formIsPristine, setFormIsPristine] = useState(true);
122456
122497
  const schema = cms.api.tina.schema;
@@ -122481,9 +122522,11 @@ const RenderForm$1 = ({
122481
122522
  ((_d = template.ui) == null ? void 0 : _d.defaultItem) || // @ts-ignore
122482
122523
  (template == null ? void 0 : template.defaultItem) || {};
122483
122524
  const fileReadOnly = (_f = (_e = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _e.filename) == null ? void 0 : _f.readonly;
122525
+ const parse2 = (_h = (_g = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _g.filename) == null ? void 0 : _h.parse;
122484
122526
  const filenameField = {
122485
122527
  name: "filename",
122486
122528
  label: "Filename",
122529
+ parse: parse2,
122487
122530
  component: slugFunction && !fileReadOnly ? wrapFieldsWithMeta(({ field, input, meta }) => {
122488
122531
  var _a3, _b2;
122489
122532
  return /* @__PURE__ */ React__default.createElement(
@@ -122494,8 +122537,8 @@ const RenderForm$1 = ({
122494
122537
  }
122495
122538
  );
122496
122539
  }) : "text",
122497
- disabled: (_h = (_g = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _g.filename) == null ? void 0 : _h.readonly,
122498
- description: ((_j = (_i = collection.ui) == null ? void 0 : _i.filename) == null ? void 0 : _j.description) ? /* @__PURE__ */ React__default.createElement(
122540
+ disabled: (_j = (_i = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _i.filename) == null ? void 0 : _j.readonly,
122541
+ description: ((_l = (_k = collection.ui) == null ? void 0 : _k.filename) == null ? void 0 : _l.description) ? /* @__PURE__ */ React__default.createElement(
122499
122542
  "span",
122500
122543
  {
122501
122544
  dangerouslySetInnerHTML: { __html: collection.ui.filename.description }
@@ -15,3 +15,20 @@ export declare const EDITORIAL_WORKFLOW_STATUS: {
15
15
  readonly TIMEOUT: "timeout";
16
16
  };
17
17
  export type EditorialWorkflowStatus = (typeof EDITORIAL_WORKFLOW_STATUS)[keyof typeof EDITORIAL_WORKFLOW_STATUS];
18
+ /**
19
+ * Editorial Workflow Error Codes
20
+ * These match the server-side constants in tinacloud/common/src/editorial-workflow-constants.ts
21
+ */
22
+ export declare const EDITORIAL_WORKFLOW_ERROR: {
23
+ readonly BRANCH_EXISTS: "BRANCH_EXISTS";
24
+ readonly BRANCH_HIERARCHY_CONFLICT: "BRANCH_HIERARCHY_CONFLICT";
25
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
26
+ };
27
+ export type EditorialWorkflowError = (typeof EDITORIAL_WORKFLOW_ERROR)[keyof typeof EDITORIAL_WORKFLOW_ERROR];
28
+ /**
29
+ * Error type for editorial workflow operations with additional error details
30
+ */
31
+ export type EditorialWorkflowErrorDetails = Error & {
32
+ errorCode?: string;
33
+ conflictingBranch?: string;
34
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tinacms",
3
3
  "type": "module",
4
4
  "typings": "dist/index.d.ts",
5
- "version": "3.3.2",
5
+ "version": "3.4.1",
6
6
  "main": "dist/index.js",
7
7
  "module": "./dist/index.js",
8
8
  "exports": {
@@ -110,9 +110,9 @@
110
110
  "webfontloader": "1.6.28",
111
111
  "yup": "^1.6.1",
112
112
  "zod": "^3.24.2",
113
- "@tinacms/mdx": "2.0.4",
114
- "@tinacms/search": "1.2.1",
115
- "@tinacms/schema-tools": "2.4.0"
113
+ "@tinacms/mdx": "2.0.5",
114
+ "@tinacms/schema-tools": "2.5.0",
115
+ "@tinacms/search": "1.2.2"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@graphql-tools/utils": "^10.8.1",