@tinacms/schema-tools 0.0.0-00d7b85-20251222014449
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 +176 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2789 -0
- package/dist/schema/TinaSchema.d.ts +101 -0
- package/dist/schema/addNamespaceToSchema.d.ts +8 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/resolveField.d.ts +14 -0
- package/dist/schema/resolveForm.d.ts +26 -0
- package/dist/types/index.d.ts +971 -0
- package/dist/util/hasDuplicates.d.ts +10 -0
- package/dist/util/index.d.ts +9 -0
- package/dist/util/lastItem.d.ts +4 -0
- package/dist/util/namer.d.ts +19 -0
- package/dist/util/normalizePath.d.ts +9 -0
- package/dist/util/parseURL.d.ts +10 -0
- package/dist/util/parseZodErrors.d.ts +7 -0
- package/dist/util/sequential.d.ts +14 -0
- package/dist/util/validate.d.ts +6 -0
- package/dist/validate/fields.d.ts +3 -0
- package/dist/validate/index.d.ts +8 -0
- package/dist/validate/properties.d.ts +5 -0
- package/dist/validate/schema.d.ts +552 -0
- package/dist/validate/tinaCloudSchemaConfig.d.ts +230 -0
- package/dist/validate/util.d.ts +3 -0
- package/package.json +52 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Schema, Collection, Template, Collectable, CollectionTemplateable, TinaField } from '../types/index';
|
|
2
|
+
type Version = {
|
|
3
|
+
fullVersion: string;
|
|
4
|
+
major: string;
|
|
5
|
+
minor: string;
|
|
6
|
+
patch: string;
|
|
7
|
+
};
|
|
8
|
+
type Meta = {
|
|
9
|
+
flags?: string[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* TinaSchema is responsible for allowing you to look up certain
|
|
13
|
+
* properties of the user-provided schema with ease.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare class TinaSchema {
|
|
17
|
+
config: {
|
|
18
|
+
version?: Version;
|
|
19
|
+
meta?: Meta;
|
|
20
|
+
} & Schema;
|
|
21
|
+
schema: Schema<true>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a schema class from a user defined schema object
|
|
24
|
+
*/
|
|
25
|
+
constructor(config: {
|
|
26
|
+
version?: Version;
|
|
27
|
+
meta?: Meta;
|
|
28
|
+
} & Schema);
|
|
29
|
+
getIsTitleFieldName: (collection: string) => string;
|
|
30
|
+
getCollectionsByName: (collectionNames: string[]) => Collection<true>[];
|
|
31
|
+
findReferencesFromCollection(name: string): Record<string, string[]>;
|
|
32
|
+
getCollection: (collectionName: string) => Collection<true>;
|
|
33
|
+
getCollections: () => Collection<true>[];
|
|
34
|
+
getCollectionByFullPath: (filepath: string) => Collection<true>;
|
|
35
|
+
getCollectionAndTemplateByFullPath: (filepath: string, templateName?: string) => {
|
|
36
|
+
collection: Collection<true>;
|
|
37
|
+
template: Template<true>;
|
|
38
|
+
} | undefined;
|
|
39
|
+
getTemplateForData: ({ data, collection, }: {
|
|
40
|
+
data?: unknown;
|
|
41
|
+
collection: Collectable;
|
|
42
|
+
}) => Template<true>;
|
|
43
|
+
transformPayload: (collectionName: string, payload: object) => {
|
|
44
|
+
[x: string]: {
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
private transformCollectablePayload;
|
|
49
|
+
private transformField;
|
|
50
|
+
isMarkdownCollection: (collectionName: string) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the template or templates from the item.
|
|
53
|
+
* Both `object` fields and collections support
|
|
54
|
+
* the ability for an object to be polymorphic,
|
|
55
|
+
* and if it is, we need to build unions, which
|
|
56
|
+
* are more of a headache for non-polymorphic
|
|
57
|
+
* needs, so we also need the ability to just
|
|
58
|
+
* build object types
|
|
59
|
+
*
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
getTemplatesForCollectable: (collection: Collectable) => CollectionTemplateable;
|
|
63
|
+
/**
|
|
64
|
+
* Walk all fields in tina schema
|
|
65
|
+
*
|
|
66
|
+
* @param cb callback function invoked for each field
|
|
67
|
+
*/
|
|
68
|
+
walkFields(cb: (args: {
|
|
69
|
+
field: any;
|
|
70
|
+
collection: any;
|
|
71
|
+
path: string;
|
|
72
|
+
isListItem?: boolean;
|
|
73
|
+
}) => void): void;
|
|
74
|
+
/**
|
|
75
|
+
* Walk all fields in Tina Schema
|
|
76
|
+
*
|
|
77
|
+
* This is a legacy version to preserve backwards compatibility for the tina generated schema. It does not
|
|
78
|
+
* traverse fields in object lists in rich-text templates.
|
|
79
|
+
*
|
|
80
|
+
* @param cb callback function invoked for each field
|
|
81
|
+
*/
|
|
82
|
+
legacyWalkFields: (cb: (args: {
|
|
83
|
+
field: TinaField;
|
|
84
|
+
collection: Collection;
|
|
85
|
+
path: string[];
|
|
86
|
+
}) => void) => void;
|
|
87
|
+
/**
|
|
88
|
+
* This function returns an array of glob matches for a given collection.
|
|
89
|
+
*
|
|
90
|
+
* @param collection The collection to get the matches for. Can be a string or a collection object.
|
|
91
|
+
* @returns An array of glob matches.
|
|
92
|
+
*/
|
|
93
|
+
getMatches({ collection: collectionOrString, }: {
|
|
94
|
+
collection: string | Collection;
|
|
95
|
+
}): string[];
|
|
96
|
+
matchFiles({ collection, files, }: {
|
|
97
|
+
collection: string | Collection;
|
|
98
|
+
files: string[];
|
|
99
|
+
}): string[];
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import type { TinaField } from '../types/index';
|
|
5
|
+
import type { TinaSchema } from './TinaSchema';
|
|
6
|
+
/**
|
|
7
|
+
* Turns a field the schema (schema.{js,ts} file) into a valid front end FieldConfig
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveField: (field: TinaField<true>, schema: TinaSchema) => {
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
name: string;
|
|
12
|
+
component: NonNullable<TinaField<true>["ui"]>["component"];
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import type { Template, Collection } from '../types/index';
|
|
5
|
+
import type { TinaSchema } from './TinaSchema';
|
|
6
|
+
/**
|
|
7
|
+
* Given a collection, basename, template and schema. This will transform the given information into a valid frontend form config
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveForm: ({ collection, basename, template, schema, }: ResolveFormArgs) => {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
name: string;
|
|
13
|
+
fields: {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
name: string;
|
|
16
|
+
component: NonNullable<import("..").TinaField<true>["ui"]>["component"];
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
type ResolveFormArgs = {
|
|
21
|
+
collection: Collection<true>;
|
|
22
|
+
basename: string;
|
|
23
|
+
template: Template<true>;
|
|
24
|
+
schema: TinaSchema;
|
|
25
|
+
};
|
|
26
|
+
export {};
|