@tinacms/schema-tools 0.0.1 → 0.0.2
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/CHANGELOG.md +33 -0
- package/dist/index.js +1 -0
- package/dist/types/SchemaTypes.d.ts +12 -4
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @tinacms/schema-tools
|
|
2
|
+
|
|
3
|
+
## 0.0.2
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
|
|
7
|
+
|
|
8
|
+
### How to migrate.
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import TinaCMS from 'tinacms'
|
|
14
|
+
import schema, { tinaConfig } from '../schema.ts'
|
|
15
|
+
|
|
16
|
+
// Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
|
|
17
|
+
// Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @private Do not import this directly, please import the dynamic provider instead
|
|
21
|
+
*/
|
|
22
|
+
const TinaProvider = ({ children }) => {
|
|
23
|
+
return (
|
|
24
|
+
<TinaCMS {...tinaConfig} schema={schema}>
|
|
25
|
+
{children}
|
|
26
|
+
</TinaCMS>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default TinaProvider
|
|
31
|
+
```
|
|
32
|
+
- 801f39f62: Update types
|
|
33
|
+
- 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.
|
package/dist/index.js
CHANGED
|
@@ -319,6 +319,7 @@ var TinaSchema = class {
|
|
|
319
319
|
var resolveField = (_a, schema) => {
|
|
320
320
|
var _b = _a, { namespace } = _b, field = __objRest(_b, ["namespace"]);
|
|
321
321
|
var _a2;
|
|
322
|
+
field.parentTypename = NAMER.dataTypeName(namespace.filter((_, i) => i < namespace.length - 1));
|
|
322
323
|
const extraFields = field.ui || {};
|
|
323
324
|
switch (field.type) {
|
|
324
325
|
case "number":
|
|
@@ -61,18 +61,24 @@ export interface CollectionTemplatesWithNamespace<WithNamespace extends boolean>
|
|
|
61
61
|
}
|
|
62
62
|
declare type CollectionFields<WithNamespace extends boolean> = WithNamespace extends true ? CollectionFieldsWithNamespace<WithNamespace> : CollectionFieldsInner<WithNamespace>;
|
|
63
63
|
export interface CollectionFieldsWithNamespace<WithNamespace extends boolean> extends BaseCollection {
|
|
64
|
-
fields:
|
|
64
|
+
fields: TinaFieldInner<WithNamespace>[];
|
|
65
65
|
templates?: undefined;
|
|
66
66
|
references?: ReferenceType<WithNamespace>[];
|
|
67
67
|
namespace: string[];
|
|
68
68
|
}
|
|
69
69
|
interface CollectionFieldsInner<WithNamespace extends boolean> extends BaseCollection {
|
|
70
|
-
fields:
|
|
70
|
+
fields: TinaFieldInner<WithNamespace>[];
|
|
71
71
|
templates?: undefined;
|
|
72
72
|
}
|
|
73
73
|
export declare type TinaFieldInner<WithNamespace extends boolean> = ScalarType<WithNamespace> | ObjectType<WithNamespace> | ReferenceType<WithNamespace> | RichType<WithNamespace>;
|
|
74
74
|
export declare type TinaFieldBase = TinaFieldInner<false>;
|
|
75
|
-
export declare type TinaFieldEnriched = TinaFieldInner<true
|
|
75
|
+
export declare type TinaFieldEnriched = TinaFieldInner<true> & {
|
|
76
|
+
/**
|
|
77
|
+
* The parentTypename will always be an object type, either the type of a
|
|
78
|
+
* collection (ie. `Post`) or of an object field (ie. `PageBlocks`).
|
|
79
|
+
*/
|
|
80
|
+
parentTypename?: string;
|
|
81
|
+
};
|
|
76
82
|
interface TinaField {
|
|
77
83
|
name: string;
|
|
78
84
|
label?: string;
|
|
@@ -83,7 +89,7 @@ interface TinaField {
|
|
|
83
89
|
* NOTE: only serializable values are supported, so functions like `validate`
|
|
84
90
|
* will be ignored.
|
|
85
91
|
*/
|
|
86
|
-
ui?:
|
|
92
|
+
ui?: Record<string, any>;
|
|
87
93
|
}
|
|
88
94
|
declare type ScalarType<WithNamespace extends boolean> = WithNamespace extends true ? ScalarTypeWithNamespace : ScalarTypeInner;
|
|
89
95
|
declare type Option = string | {
|
|
@@ -159,6 +165,7 @@ export interface ReferenceTypeInner extends TinaField {
|
|
|
159
165
|
name: string;
|
|
160
166
|
};
|
|
161
167
|
collections: string[];
|
|
168
|
+
ui?: UIField<any, string[]>;
|
|
162
169
|
}
|
|
163
170
|
export interface ReferenceTypeWithNamespace extends TinaField {
|
|
164
171
|
type: 'reference';
|
|
@@ -169,6 +176,7 @@ export interface ReferenceTypeWithNamespace extends TinaField {
|
|
|
169
176
|
name: string;
|
|
170
177
|
};
|
|
171
178
|
namespace: string[];
|
|
179
|
+
ui?: UIField<any, string[]>;
|
|
172
180
|
}
|
|
173
181
|
export interface RichTypeWithNamespace extends TinaField {
|
|
174
182
|
type: 'rich-text';
|