@tinacms/schema-tools 1.4.11 → 1.4.13
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/LICENSE +1 -9
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -2
- package/dist/types/index.d.ts +17 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Portions of the TinaCMS software are licensed as follows:
|
|
4
|
-
|
|
5
|
-
* All software that resides under the "packages/@tinacms/datalayer/" and the "packages/@tinacms/graphql/" directories (the "Tina Data Layer"), is licensed under the license defined in "packages/@tinacms/datalayer/LICENSE".
|
|
6
|
-
|
|
7
|
-
* All software outside of the above-mentioned directories is available under the "Apache 2.0" license as set forth below.
|
|
8
|
-
|
|
9
|
-
Apache License
|
|
1
|
+
Apache License
|
|
10
2
|
Version 2.0, January 2004
|
|
11
3
|
http://www.apache.org/licenses/
|
|
12
4
|
|
package/dist/index.js
CHANGED
|
@@ -231,6 +231,7 @@
|
|
|
231
231
|
};
|
|
232
232
|
this.getCollectionByFullPath = (filepath) => {
|
|
233
233
|
const fileExtension = filepath.split(".").pop();
|
|
234
|
+
const normalizedPath = filepath.replace(/\\/g, "/");
|
|
234
235
|
const possibleCollections = this.getCollections().filter((collection) => {
|
|
235
236
|
var _a, _b;
|
|
236
237
|
if (fileExtension !== (collection.format || "md")) {
|
|
@@ -238,13 +239,13 @@
|
|
|
238
239
|
}
|
|
239
240
|
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
241
|
const matches = this.getMatches({ collection });
|
|
241
|
-
const match = picomatch(
|
|
242
|
+
const match = picomatch.isMatch(normalizedPath, matches);
|
|
242
243
|
if (!match) {
|
|
243
244
|
return false;
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
const path = collection.path ? collection.path.replace(/\/?$/, "/") : "";
|
|
247
|
-
return
|
|
248
|
+
return normalizedPath.startsWith(path);
|
|
248
249
|
});
|
|
249
250
|
if (possibleCollections.length === 0) {
|
|
250
251
|
throw new Error(`Unable to find collection for file at ${filepath}`);
|
package/dist/index.mjs
CHANGED
|
@@ -214,6 +214,7 @@ class TinaSchema {
|
|
|
214
214
|
};
|
|
215
215
|
this.getCollectionByFullPath = (filepath) => {
|
|
216
216
|
const fileExtension = filepath.split(".").pop();
|
|
217
|
+
const normalizedPath = filepath.replace(/\\/g, "/");
|
|
217
218
|
const possibleCollections = this.getCollections().filter((collection) => {
|
|
218
219
|
var _a, _b;
|
|
219
220
|
if (fileExtension !== (collection.format || "md")) {
|
|
@@ -221,13 +222,13 @@ class TinaSchema {
|
|
|
221
222
|
}
|
|
222
223
|
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
224
|
const matches = this.getMatches({ collection });
|
|
224
|
-
const match = picomatch(
|
|
225
|
+
const match = picomatch.isMatch(normalizedPath, matches);
|
|
225
226
|
if (!match) {
|
|
226
227
|
return false;
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
const path = collection.path ? collection.path.replace(/\/?$/, "/") : "";
|
|
230
|
-
return
|
|
231
|
+
return normalizedPath.startsWith(path);
|
|
231
232
|
});
|
|
232
233
|
if (possibleCollections.length === 0) {
|
|
233
234
|
throw new Error(`Unable to find collection for file at ${filepath}`);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -317,6 +317,16 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
317
317
|
*
|
|
318
318
|
**/
|
|
319
319
|
getUser?: () => Promise<any | null>;
|
|
320
|
+
/**
|
|
321
|
+
* Used to authorize the user with the custom auth provider.
|
|
322
|
+
*
|
|
323
|
+
* If this returns a truthy value, the user will be logged in and the CMS will be enabled.
|
|
324
|
+
*
|
|
325
|
+
* If not provided, the existence of a user will be enough to authorize the user.
|
|
326
|
+
*
|
|
327
|
+
* @param context
|
|
328
|
+
*/
|
|
329
|
+
authorize?: (context?: any) => Promise<any | null>;
|
|
320
330
|
/**
|
|
321
331
|
* Used to authenticate the user with the custom auth provider. This is called when the user clicks the login button.
|
|
322
332
|
*
|
|
@@ -387,6 +397,12 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
387
397
|
* @default 2
|
|
388
398
|
*/
|
|
389
399
|
referenceDepth?: number;
|
|
400
|
+
/**
|
|
401
|
+
* Determines how the client will handle errors. If it is set to `throw` the client will throw an error when a query fails. If it is set to `include` the client will return the error in the response.
|
|
402
|
+
*
|
|
403
|
+
* @default 'throw'
|
|
404
|
+
*/
|
|
405
|
+
errorPolicy?: 'throw' | 'include';
|
|
390
406
|
};
|
|
391
407
|
/**
|
|
392
408
|
*
|
|
@@ -633,7 +649,7 @@ export interface UICollection<Form = any, CMS = any, TinaForm = any> {
|
|
|
633
649
|
router?: (args: {
|
|
634
650
|
document: Document;
|
|
635
651
|
collection: Collection<true>;
|
|
636
|
-
}) => Promise<string | undefined
|
|
652
|
+
}) => Promise<string | undefined> | string | undefined;
|
|
637
653
|
/**
|
|
638
654
|
* 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
655
|
*
|