@tinacms/schema-tools 2.8.3 → 2.10.0
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 +1454 -1349
- package/dist/types/index.d.ts +81 -2
- package/package.json +4 -5
package/dist/types/index.d.ts
CHANGED
|
@@ -206,6 +206,60 @@ type DateFormatProps = {
|
|
|
206
206
|
export type DateTimeField = (FieldGeneric<string, undefined, DateFormatProps> | FieldGeneric<string, true, DateFormatProps> | FieldGeneric<string, false, DateFormatProps>) & BaseField & {
|
|
207
207
|
type: 'datetime';
|
|
208
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* File extensions the media manager can filter on. Not a list of what may be
|
|
211
|
+
* uploaded — that is `media.accept` — but the vocabulary a field or filter
|
|
212
|
+
* uses to narrow what is shown.
|
|
213
|
+
*/
|
|
214
|
+
export declare const MEDIA_EXTENSIONS: readonly ["jpg", "jpeg", "png", "gif", "webp", "svg", "avif", "ico", "mp4", "webm", "mov", "mp3", "wav", "ogg", "pdf", "json", "csv", "txt"];
|
|
215
|
+
export type MediaExtension = (typeof MEDIA_EXTENSIONS)[number];
|
|
216
|
+
export declare const MEDIA_CATEGORIES: {
|
|
217
|
+
readonly image: readonly ["jpg", "jpeg", "png", "gif", "webp", "svg", "avif", "ico"];
|
|
218
|
+
readonly video: readonly ["mp4", "webm", "mov"];
|
|
219
|
+
readonly audio: readonly ["mp3", "wav", "ogg"];
|
|
220
|
+
readonly document: readonly ["pdf", "json", "csv", "txt"];
|
|
221
|
+
};
|
|
222
|
+
export type MediaCategory = keyof typeof MEDIA_CATEGORIES;
|
|
223
|
+
export type MediaAccept = MediaExtension | MediaCategory;
|
|
224
|
+
/**
|
|
225
|
+
* The MIME type each extension belongs to. Needed because react-dropzone
|
|
226
|
+
* keys its `accept` by MIME type and drops bare extensions from the native
|
|
227
|
+
* file picker.
|
|
228
|
+
*/
|
|
229
|
+
export declare const MEDIA_MIME_TYPES: {
|
|
230
|
+
readonly jpg: "image/jpeg";
|
|
231
|
+
readonly jpeg: "image/jpeg";
|
|
232
|
+
readonly png: "image/png";
|
|
233
|
+
readonly gif: "image/gif";
|
|
234
|
+
readonly webp: "image/webp";
|
|
235
|
+
readonly svg: "image/svg+xml";
|
|
236
|
+
readonly avif: "image/avif";
|
|
237
|
+
readonly ico: "image/x-icon";
|
|
238
|
+
readonly mp4: "video/mp4";
|
|
239
|
+
readonly webm: "video/webm";
|
|
240
|
+
readonly mov: "video/quicktime";
|
|
241
|
+
readonly mp3: "audio/mpeg";
|
|
242
|
+
readonly wav: "audio/wav";
|
|
243
|
+
readonly ogg: "audio/ogg";
|
|
244
|
+
readonly pdf: "application/pdf";
|
|
245
|
+
readonly json: "application/json";
|
|
246
|
+
readonly csv: "text/csv";
|
|
247
|
+
readonly txt: "text/plain";
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Lowercased extension without the dot, from a filename, path or URL.
|
|
251
|
+
* Query strings and hashes are dropped first, so a transformed asset URL
|
|
252
|
+
* like `hero.png?fit=crop` still reads as `png`. Dotfiles and extensionless
|
|
253
|
+
* names return ''.
|
|
254
|
+
*/
|
|
255
|
+
export declare const extensionOf: (value: string) => string;
|
|
256
|
+
/**
|
|
257
|
+
* Flattens a field's `accept` into concrete extensions, expanding any
|
|
258
|
+
* category shorthand and pulling in aliases. Unknown values are dropped
|
|
259
|
+
* rather than passed through, so a typo narrows to nothing visible instead
|
|
260
|
+
* of silently disabling the filter.
|
|
261
|
+
*/
|
|
262
|
+
export declare const resolveMediaAccept: (accept: MediaAccept | MediaAccept[] | undefined) => MediaExtension[];
|
|
209
263
|
export type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string, true> | FieldGeneric<string, false>) & BaseField & {
|
|
210
264
|
type: 'image';
|
|
211
265
|
/**
|
|
@@ -218,6 +272,19 @@ export type ImageField = (FieldGeneric<string, undefined> | FieldGeneric<string,
|
|
|
218
272
|
* ```
|
|
219
273
|
*/
|
|
220
274
|
uploadDir?: (formValues: Record<string, any>) => string;
|
|
275
|
+
/**
|
|
276
|
+
* Restricts this field to specific file types. Narrows what the media
|
|
277
|
+
* manager offers when browsing and what the field will accept on upload,
|
|
278
|
+
* overriding the global `media.accept`.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* accept: 'pdf'
|
|
283
|
+
* accept: ['png', 'svg']
|
|
284
|
+
* accept: 'image'
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
accept?: MediaAccept | MediaAccept[];
|
|
221
288
|
};
|
|
222
289
|
type ReferenceFieldOptions = {
|
|
223
290
|
optionComponent?: OptionComponent;
|
|
@@ -385,8 +452,8 @@ export type Template<WithNamespace extends boolean = false> = {
|
|
|
385
452
|
};
|
|
386
453
|
fields: Field<WithNamespace>[];
|
|
387
454
|
} & MaybeNamespace<WithNamespace>;
|
|
388
|
-
type TokenObject = {
|
|
389
|
-
id_token
|
|
455
|
+
export type TokenObject = {
|
|
456
|
+
id_token?: string;
|
|
390
457
|
access_token?: string;
|
|
391
458
|
refresh_token?: string;
|
|
392
459
|
};
|
|
@@ -429,7 +496,19 @@ export interface AuthProvider {
|
|
|
429
496
|
**/
|
|
430
497
|
authenticate: (props?: Record<string, any>) => Promise<any | null>;
|
|
431
498
|
fetchWithToken: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
499
|
+
/**
|
|
500
|
+
* Turns a tokened 401 into the CMS sending the user back to login. The
|
|
501
|
+
* Tina client assigns this automatically; providers extending
|
|
502
|
+
* AbstractAuthProvider get the invocation for free, while a provider that
|
|
503
|
+
* implements its own fetchWithToken must invoke it itself.
|
|
504
|
+
*/
|
|
505
|
+
sessionExpiredListener?: () => void;
|
|
432
506
|
isAuthorized: (context?: any) => Promise<boolean>;
|
|
507
|
+
/**
|
|
508
|
+
* May reject when the identity backend is unreachable (a transport
|
|
509
|
+
* failure is not an auth answer); callers should catch and treat that as
|
|
510
|
+
* an error rather than as logged-out.
|
|
511
|
+
*/
|
|
433
512
|
isAuthenticated: () => Promise<boolean>;
|
|
434
513
|
getLoginStrategy: () => LoginStrategy;
|
|
435
514
|
getLoginScreen: () => FC<LoginScreenProps> | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/schema-tools",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"ts-jest": "^29.2.5",
|
|
25
25
|
"typescript": "^5.7.3",
|
|
26
26
|
"yup": "^1.6.1",
|
|
27
|
-
"@tinacms/scripts": "1.6.
|
|
27
|
+
"@tinacms/scripts": "1.6.4"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": ">=16.14.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"url": "https://github.com/tinacms/tinacms.git",
|
|
38
|
-
"directory": "packages/@tinacms/
|
|
38
|
+
"directory": "packages/@tinacms/schema-tools"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"picomatch-browser": "2.2.6",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"build": "tinacms-scripts build",
|
|
47
47
|
"test": "jest --config jest.config.js",
|
|
48
48
|
"types": "pnpm tsc",
|
|
49
|
-
"test-watch": "jest --passWithNoTests --watch"
|
|
50
|
-
"generate:schema": "pnpm node scripts/generateSchema.js"
|
|
49
|
+
"test-watch": "jest --passWithNoTests --watch"
|
|
51
50
|
}
|
|
52
51
|
}
|