@tinacms/schema-tools 0.0.4 → 0.0.7
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.es.js +701 -0
- package/dist/index.js +676 -686
- package/dist/types/SchemaTypes.d.ts +12 -1
- package/dist/validate/index.d.ts +1 -0
- package/dist/validate/schema.d.ts +79 -0
- package/dist/validate/tinaCloudSchemaConfig.d.ts +58 -0
- package/package.json +20 -13
- package/CHANGELOG.md +0 -47
|
@@ -21,9 +21,19 @@ export declare type UIField<F extends UIField = any, Shape = any> = {
|
|
|
21
21
|
validate?(value: Shape, allValues: any, meta: any, field: UIField<F, Shape>): string | object | undefined | void;
|
|
22
22
|
defaultValue?: Shape;
|
|
23
23
|
};
|
|
24
|
-
export interface
|
|
24
|
+
export interface TinaCloudSchemaConfig<Store = any> {
|
|
25
|
+
media?: {
|
|
26
|
+
loadCustomStore?: () => Promise<Store>;
|
|
27
|
+
tina?: {
|
|
28
|
+
publicFolder: string;
|
|
29
|
+
mediaRoot: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface TinaCloudSchema<WithNamespace extends boolean, Store = any> {
|
|
25
34
|
templates?: GlobalTemplate<WithNamespace>[];
|
|
26
35
|
collections: TinaCloudCollection<WithNamespace>[];
|
|
36
|
+
config?: TinaCloudSchemaConfig<Store>;
|
|
27
37
|
}
|
|
28
38
|
export declare type TinaCloudSchemaBase = TinaCloudSchema<false>;
|
|
29
39
|
export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
|
|
@@ -35,6 +45,7 @@ export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
|
|
|
35
45
|
export interface TinaCloudSchemaWithNamespace {
|
|
36
46
|
templates?: GlobalTemplate<true>[];
|
|
37
47
|
collections: TinaCloudCollection<true>[];
|
|
48
|
+
config?: TinaCloudSchemaConfig;
|
|
38
49
|
namespace: string[];
|
|
39
50
|
}
|
|
40
51
|
export declare type TinaCloudCollection<WithNamespace extends boolean> = CollectionFields<WithNamespace> | CollectionTemplates<WithNamespace>;
|
package/dist/validate/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import { TinaCloudSchema } from '../types';
|
|
14
|
+
export { validateTinaCloudSchemaConfig } from './tinaCloudSchemaConfig';
|
|
14
15
|
export declare class TinaSchemaValidationError extends Error {
|
|
15
16
|
constructor(message: any);
|
|
16
17
|
}
|
|
@@ -88,6 +88,49 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
88
88
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
89
89
|
label?: string;
|
|
90
90
|
}>, "many">;
|
|
91
|
+
config: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
media: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
tina: z.ZodOptional<z.ZodObject<{
|
|
94
|
+
publicFolder: z.ZodString;
|
|
95
|
+
mediaRoot: z.ZodString;
|
|
96
|
+
}, "strict", z.ZodTypeAny, {
|
|
97
|
+
publicFolder?: string;
|
|
98
|
+
mediaRoot?: string;
|
|
99
|
+
}, {
|
|
100
|
+
publicFolder?: string;
|
|
101
|
+
mediaRoot?: string;
|
|
102
|
+
}>>;
|
|
103
|
+
loadCustomStore: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
tina?: {
|
|
106
|
+
publicFolder?: string;
|
|
107
|
+
mediaRoot?: string;
|
|
108
|
+
};
|
|
109
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
110
|
+
}, {
|
|
111
|
+
tina?: {
|
|
112
|
+
publicFolder?: string;
|
|
113
|
+
mediaRoot?: string;
|
|
114
|
+
};
|
|
115
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
116
|
+
}>>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
media?: {
|
|
119
|
+
tina?: {
|
|
120
|
+
publicFolder?: string;
|
|
121
|
+
mediaRoot?: string;
|
|
122
|
+
};
|
|
123
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
124
|
+
};
|
|
125
|
+
}, {
|
|
126
|
+
media?: {
|
|
127
|
+
tina?: {
|
|
128
|
+
publicFolder?: string;
|
|
129
|
+
mediaRoot?: string;
|
|
130
|
+
};
|
|
131
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
132
|
+
};
|
|
133
|
+
}>>;
|
|
91
134
|
}, "strip", z.ZodTypeAny, {
|
|
92
135
|
collections?: {
|
|
93
136
|
name?: string;
|
|
@@ -100,6 +143,15 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
100
143
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
101
144
|
label?: string;
|
|
102
145
|
}[];
|
|
146
|
+
config?: {
|
|
147
|
+
media?: {
|
|
148
|
+
tina?: {
|
|
149
|
+
publicFolder?: string;
|
|
150
|
+
mediaRoot?: string;
|
|
151
|
+
};
|
|
152
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
103
155
|
}, {
|
|
104
156
|
collections?: {
|
|
105
157
|
name?: string;
|
|
@@ -112,6 +164,15 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
112
164
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
113
165
|
label?: string;
|
|
114
166
|
}[];
|
|
167
|
+
config?: {
|
|
168
|
+
media?: {
|
|
169
|
+
tina?: {
|
|
170
|
+
publicFolder?: string;
|
|
171
|
+
mediaRoot?: string;
|
|
172
|
+
};
|
|
173
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
115
176
|
}>, {
|
|
116
177
|
collections?: {
|
|
117
178
|
name?: string;
|
|
@@ -124,6 +185,15 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
124
185
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
125
186
|
label?: string;
|
|
126
187
|
}[];
|
|
188
|
+
config?: {
|
|
189
|
+
media?: {
|
|
190
|
+
tina?: {
|
|
191
|
+
publicFolder?: string;
|
|
192
|
+
mediaRoot?: string;
|
|
193
|
+
};
|
|
194
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
127
197
|
}, {
|
|
128
198
|
collections?: {
|
|
129
199
|
name?: string;
|
|
@@ -136,4 +206,13 @@ export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
|
136
206
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
137
207
|
label?: string;
|
|
138
208
|
}[];
|
|
209
|
+
config?: {
|
|
210
|
+
media?: {
|
|
211
|
+
tina?: {
|
|
212
|
+
publicFolder?: string;
|
|
213
|
+
mediaRoot?: string;
|
|
214
|
+
};
|
|
215
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
139
218
|
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright 2021 Forestry.io Holdings, Inc.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
See the License for the specific language governing permissions and
|
|
11
|
+
limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import { TinaCloudSchemaConfig } from '../types';
|
|
14
|
+
import z from 'zod';
|
|
15
|
+
export declare const tinaConfigZod: z.ZodObject<{
|
|
16
|
+
media: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
tina: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
publicFolder: z.ZodString;
|
|
19
|
+
mediaRoot: z.ZodString;
|
|
20
|
+
}, "strict", z.ZodTypeAny, {
|
|
21
|
+
publicFolder?: string;
|
|
22
|
+
mediaRoot?: string;
|
|
23
|
+
}, {
|
|
24
|
+
publicFolder?: string;
|
|
25
|
+
mediaRoot?: string;
|
|
26
|
+
}>>;
|
|
27
|
+
loadCustomStore: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
tina?: {
|
|
30
|
+
publicFolder?: string;
|
|
31
|
+
mediaRoot?: string;
|
|
32
|
+
};
|
|
33
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
34
|
+
}, {
|
|
35
|
+
tina?: {
|
|
36
|
+
publicFolder?: string;
|
|
37
|
+
mediaRoot?: string;
|
|
38
|
+
};
|
|
39
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
40
|
+
}>>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
media?: {
|
|
43
|
+
tina?: {
|
|
44
|
+
publicFolder?: string;
|
|
45
|
+
mediaRoot?: string;
|
|
46
|
+
};
|
|
47
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
48
|
+
};
|
|
49
|
+
}, {
|
|
50
|
+
media?: {
|
|
51
|
+
tina?: {
|
|
52
|
+
publicFolder?: string;
|
|
53
|
+
mediaRoot?: string;
|
|
54
|
+
};
|
|
55
|
+
loadCustomStore?: (...args: unknown[]) => unknown;
|
|
56
|
+
};
|
|
57
|
+
}>;
|
|
58
|
+
export declare const validateTinaCloudSchemaConfig: (config: unknown) => TinaCloudSchemaConfig;
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/schema-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
+
"module": "./dist/index.es.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.es.js",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
5
13
|
"typings": "dist/index.d.ts",
|
|
6
14
|
"files": [
|
|
7
15
|
"dist"
|
|
@@ -10,30 +18,22 @@
|
|
|
10
18
|
"buildConfig": {
|
|
11
19
|
"entryPoints": [
|
|
12
20
|
{
|
|
13
|
-
"name": "src/index.ts"
|
|
14
|
-
"target": "node"
|
|
21
|
+
"name": "src/index.ts"
|
|
15
22
|
}
|
|
16
23
|
]
|
|
17
24
|
},
|
|
18
25
|
"devDependencies": {
|
|
19
|
-
"@tinacms/scripts": "0.50.
|
|
26
|
+
"@tinacms/scripts": "0.50.9",
|
|
20
27
|
"@types/yup": "^0.29.10",
|
|
21
28
|
"jest": "^27.0.6",
|
|
22
|
-
"react": "
|
|
23
|
-
"typescript": "
|
|
29
|
+
"react": "17.0.2",
|
|
30
|
+
"typescript": "4.3.5",
|
|
24
31
|
"yup": "^0.32.0"
|
|
25
32
|
},
|
|
26
33
|
"peerDependencies": {
|
|
27
34
|
"react": ">=16.14.0",
|
|
28
35
|
"yup": "^0.32.0"
|
|
29
36
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "echo \"Run `yarn build` from the root of the repository instead\"",
|
|
32
|
-
"test": "jest --passWithNoTests",
|
|
33
|
-
"types": "yarn tsc",
|
|
34
|
-
"test-watch": "jest --passWithNoTests --watch",
|
|
35
|
-
"generate:schema": "yarn node scripts/generateSchema.js"
|
|
36
|
-
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"registry": "https://registry.npmjs.org"
|
|
39
39
|
},
|
|
@@ -43,5 +43,12 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"zod": "^3.14.3"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tinacms-scripts build",
|
|
49
|
+
"test": "jest --passWithNoTests",
|
|
50
|
+
"types": "pnpm tsc",
|
|
51
|
+
"test-watch": "jest --passWithNoTests --watch",
|
|
52
|
+
"generate:schema": "yarn node scripts/generateSchema.js"
|
|
46
53
|
}
|
|
47
54
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# @tinacms/schema-tools
|
|
2
|
-
|
|
3
|
-
## 0.0.4
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
|
|
8
|
-
|
|
9
|
-
## 0.0.3
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- 921709a7e: Adds validation to the schema instead of only using typescript types
|
|
14
|
-
|
|
15
|
-
## 0.0.2
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
|
|
20
|
-
|
|
21
|
-
### How to migrate.
|
|
22
|
-
|
|
23
|
-
If you gone though the `tinacms init` process there should be a file called `.tina/components/TinaProvider`. In that file you can import the schema from `schema.ts` and add it to the TinaCMS wrapper component.
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import TinaCMS from 'tinacms'
|
|
27
|
-
import schema, { tinaConfig } from '../schema.ts'
|
|
28
|
-
|
|
29
|
-
// Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
|
|
30
|
-
// Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @private Do not import this directly, please import the dynamic provider instead
|
|
34
|
-
*/
|
|
35
|
-
const TinaProvider = ({ children }) => {
|
|
36
|
-
return (
|
|
37
|
-
<TinaCMS {...tinaConfig} schema={schema}>
|
|
38
|
-
{children}
|
|
39
|
-
</TinaCMS>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default TinaProvider
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
- 801f39f62: Update types
|
|
47
|
-
- e8b0de1f7: Add `parentTypename` to fields to allow us to disambiguate between fields which have the same field names but different types. Example, an event from field name of `blocks.0.title` could belong to a `Cta` block or a `Hero` block, both of which have a `title` field.
|