@tinacms/schema-tools 1.4.9 → 1.4.10

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
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("micromatch"), require("yup"), require("url-pattern"), require("zod")) : typeof define === "function" && define.amd ? define(["exports", "micromatch", "yup", "url-pattern", "zod"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@tinacms/schema-tools"] = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
- })(this, function(exports2, micromatch, yup, UrlPattern, z) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("picomatch-browser"), require("yup"), require("url-pattern"), require("zod")) : typeof define === "function" && define.amd ? define(["exports", "picomatch-browser", "yup", "url-pattern", "zod"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@tinacms/schema-tools"] = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, picomatch, yup, UrlPattern, z) {
4
4
  "use strict";
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -238,7 +238,7 @@
238
238
  }
239
239
  if (((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) || ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude)) {
240
240
  const matches = this.getMatches({ collection });
241
- const match = micromatch([filepath], matches).length > 0;
241
+ const match = picomatch([filepath], matches).length > 0;
242
242
  if (!match) {
243
243
  return false;
244
244
  }
@@ -527,7 +527,7 @@
527
527
  files
528
528
  }) {
529
529
  const matches = this.getMatches({ collection });
530
- const matchedFiles = micromatch(files, matches);
530
+ const matchedFiles = picomatch(files, matches);
531
531
  return matchedFiles;
532
532
  }
533
533
  }
@@ -963,7 +963,8 @@ ${JSON.stringify(
963
963
  });
964
964
  const tinaConfigKey = z.object({
965
965
  publicFolder: z.string(),
966
- mediaRoot: z.string()
966
+ mediaRoot: z.string(),
967
+ static: z.boolean().nullish()
967
968
  }).strict().optional();
968
969
  const tinaSearchKey = z.object({
969
970
  indexerToken: z.string().optional(),
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import micromatch from "micromatch";
1
+ import picomatch from "picomatch-browser";
2
2
  import * as yup from "yup";
3
3
  import UrlPattern from "url-pattern";
4
4
  import z$1, { z, ZodError } from "zod";
@@ -221,7 +221,7 @@ class TinaSchema {
221
221
  }
222
222
  if (((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) || ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude)) {
223
223
  const matches = this.getMatches({ collection });
224
- const match = micromatch([filepath], matches).length > 0;
224
+ const match = picomatch([filepath], matches).length > 0;
225
225
  if (!match) {
226
226
  return false;
227
227
  }
@@ -510,7 +510,7 @@ class TinaSchema {
510
510
  files
511
511
  }) {
512
512
  const matches = this.getMatches({ collection });
513
- const matchedFiles = micromatch(files, matches);
513
+ const matchedFiles = picomatch(files, matches);
514
514
  return matchedFiles;
515
515
  }
516
516
  }
@@ -946,7 +946,8 @@ ${JSON.stringify(
946
946
  });
947
947
  const tinaConfigKey = z$1.object({
948
948
  publicFolder: z$1.string(),
949
- mediaRoot: z$1.string()
949
+ mediaRoot: z$1.string(),
950
+ static: z$1.boolean().nullish()
950
951
  }).strict().optional();
951
952
  const tinaSearchKey = z$1.object({
952
953
  indexerToken: z$1.string().optional(),
@@ -76,6 +76,6 @@ export declare class TinaSchema {
76
76
  matchFiles({ collection, files, }: {
77
77
  collection: string | Collection;
78
78
  files: string[];
79
- }): string[];
79
+ }): any;
80
80
  }
81
81
  export {};
@@ -457,6 +457,10 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
457
457
  * would store content in `"<my-public-folder>/uploads"`
458
458
  */
459
459
  mediaRoot: string;
460
+ /**
461
+ * Indicates that media files cannot be uploaded or removed by editors
462
+ */
463
+ static?: boolean;
460
464
  };
461
465
  loadCustomStore?: never;
462
466
  };
@@ -578,7 +582,7 @@ declare type Document = {
578
582
  extension: string;
579
583
  };
580
584
  };
581
- export interface UICollection {
585
+ export interface UICollection<Form = any, CMS = any, TinaForm = any> {
582
586
  /**
583
587
  * Customize the way filenames are generated during content creation
584
588
  */
@@ -592,7 +596,10 @@ export interface UICollection {
592
596
  * slugify: (values) => values.title.toLowerCase().split(" ").join("-")
593
597
  * ```
594
598
  */
595
- slugify?: (values: Record<string, any>) => string;
599
+ slugify?: (values: Record<string, any>, meta: {
600
+ collection: Collection;
601
+ template: Template;
602
+ }) => string;
596
603
  /**
597
604
  * When set to `true`, editors won't be able to modify the filename
598
605
  */
@@ -627,6 +634,29 @@ export interface UICollection {
627
634
  document: Document;
628
635
  collection: Collection<true>;
629
636
  }) => string | undefined;
637
+ /**
638
+ * This function is called before a document is created or updated. It can be used to modify the values that are saved to the CMS. It can also be used to perform side effects such as sending a notification or triggering a build.
639
+ *
640
+ * @example
641
+ *
642
+ *
643
+ *```js
644
+ * beforeSubmit: async ({ values }) => {
645
+ * return {
646
+ * ...values,
647
+ * lastUpdated: new Date().toISOString(),
648
+ * };
649
+ * },
650
+ *```
651
+ *
652
+ *
653
+ *
654
+ */
655
+ beforeSubmit?: (arg: {
656
+ values: Record<string, unknown>;
657
+ cms: CMS;
658
+ form: TinaForm;
659
+ }) => Promise<void | Record<string, unknown>>;
630
660
  }
631
661
  export declare type DefaultItem<ReturnType> = ReturnType | (() => ReturnType);
632
662
  declare type IndexType = {
@@ -112,24 +112,29 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
112
112
  tina: z.ZodOptional<z.ZodObject<{
113
113
  publicFolder: z.ZodString;
114
114
  mediaRoot: z.ZodString;
115
+ static: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
115
116
  }, "strict", z.ZodTypeAny, {
116
117
  publicFolder?: string;
117
118
  mediaRoot?: string;
119
+ static?: boolean;
118
120
  }, {
119
121
  publicFolder?: string;
120
122
  mediaRoot?: string;
123
+ static?: boolean;
121
124
  }>>;
122
125
  loadCustomStore: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
123
126
  }, "strip", z.ZodTypeAny, {
124
127
  tina?: {
125
128
  publicFolder?: string;
126
129
  mediaRoot?: string;
130
+ static?: boolean;
127
131
  };
128
132
  loadCustomStore?: (...args: unknown[]) => unknown;
129
133
  }, {
130
134
  tina?: {
131
135
  publicFolder?: string;
132
136
  mediaRoot?: string;
137
+ static?: boolean;
133
138
  };
134
139
  loadCustomStore?: (...args: unknown[]) => unknown;
135
140
  }>>;
@@ -187,6 +192,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
187
192
  tina?: {
188
193
  publicFolder?: string;
189
194
  mediaRoot?: string;
195
+ static?: boolean;
190
196
  };
191
197
  loadCustomStore?: (...args: unknown[]) => unknown;
192
198
  };
@@ -208,6 +214,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
208
214
  tina?: {
209
215
  publicFolder?: string;
210
216
  mediaRoot?: string;
217
+ static?: boolean;
211
218
  };
212
219
  loadCustomStore?: (...args: unknown[]) => unknown;
213
220
  };
@@ -243,6 +250,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
243
250
  tina?: {
244
251
  publicFolder?: string;
245
252
  mediaRoot?: string;
253
+ static?: boolean;
246
254
  };
247
255
  loadCustomStore?: (...args: unknown[]) => unknown;
248
256
  };
@@ -278,6 +286,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
278
286
  tina?: {
279
287
  publicFolder?: string;
280
288
  mediaRoot?: string;
289
+ static?: boolean;
281
290
  };
282
291
  loadCustomStore?: (...args: unknown[]) => unknown;
283
292
  };
@@ -313,6 +322,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
313
322
  tina?: {
314
323
  publicFolder?: string;
315
324
  mediaRoot?: string;
325
+ static?: boolean;
316
326
  };
317
327
  loadCustomStore?: (...args: unknown[]) => unknown;
318
328
  };
@@ -348,6 +358,7 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
348
358
  tina?: {
349
359
  publicFolder?: string;
350
360
  mediaRoot?: string;
361
+ static?: boolean;
351
362
  };
352
363
  loadCustomStore?: (...args: unknown[]) => unknown;
353
364
  };
@@ -15,24 +15,29 @@ export declare const tinaConfigZod: z.ZodObject<{
15
15
  tina: z.ZodOptional<z.ZodObject<{
16
16
  publicFolder: z.ZodString;
17
17
  mediaRoot: z.ZodString;
18
+ static: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
18
19
  }, "strict", z.ZodTypeAny, {
19
20
  publicFolder?: string;
20
21
  mediaRoot?: string;
22
+ static?: boolean;
21
23
  }, {
22
24
  publicFolder?: string;
23
25
  mediaRoot?: string;
26
+ static?: boolean;
24
27
  }>>;
25
28
  loadCustomStore: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
26
29
  }, "strip", z.ZodTypeAny, {
27
30
  tina?: {
28
31
  publicFolder?: string;
29
32
  mediaRoot?: string;
33
+ static?: boolean;
30
34
  };
31
35
  loadCustomStore?: (...args: unknown[]) => unknown;
32
36
  }, {
33
37
  tina?: {
34
38
  publicFolder?: string;
35
39
  mediaRoot?: string;
40
+ static?: boolean;
36
41
  };
37
42
  loadCustomStore?: (...args: unknown[]) => unknown;
38
43
  }>>;
@@ -90,6 +95,7 @@ export declare const tinaConfigZod: z.ZodObject<{
90
95
  tina?: {
91
96
  publicFolder?: string;
92
97
  mediaRoot?: string;
98
+ static?: boolean;
93
99
  };
94
100
  loadCustomStore?: (...args: unknown[]) => unknown;
95
101
  };
@@ -111,6 +117,7 @@ export declare const tinaConfigZod: z.ZodObject<{
111
117
  tina?: {
112
118
  publicFolder?: string;
113
119
  mediaRoot?: string;
120
+ static?: boolean;
114
121
  };
115
122
  loadCustomStore?: (...args: unknown[]) => unknown;
116
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "exports": {
@@ -23,7 +23,7 @@
23
23
  ]
24
24
  },
25
25
  "devDependencies": {
26
- "@tinacms/scripts": "1.1.1",
26
+ "@tinacms/scripts": "1.1.2",
27
27
  "@types/micromatch": "^4.0.2",
28
28
  "@types/yup": "^0.29.10",
29
29
  "jest": "^29.5.0",
@@ -43,7 +43,7 @@
43
43
  "directory": "packages/@tinacms/cli"
44
44
  },
45
45
  "dependencies": {
46
- "micromatch": "4.0.5",
46
+ "picomatch-browser": "2.2.6",
47
47
  "url-pattern": "^1.0.3",
48
48
  "zod": "^3.14.3"
49
49
  },