@tinacms/schema-tools 0.0.0-20222301112 → 0.0.0-2022230155428

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 CHANGED
@@ -1,18 +1,19 @@
1
1
  # @tinacms/schema-tools
2
2
 
3
- ## 0.0.0-20222301112
3
+ ## 0.0.0-2022230155428
4
+
4
5
  ### Patch Changes
5
6
 
6
7
  - abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
7
-
8
+
8
9
  ### How to migrate.
9
-
10
+
10
11
  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
+
12
13
  ```tsx
13
14
  import TinaCMS from 'tinacms'
14
15
  import schema, { tinaConfig } from '../schema.ts'
15
-
16
+
16
17
  // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
17
18
  // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
18
19
  /**
@@ -26,7 +27,41 @@
26
27
  </TinaCMS>
27
28
  )
28
29
  }
29
-
30
+
30
31
  export default TinaProvider
31
32
  ```
33
+
34
+ - 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.
35
+
36
+ ## 0.0.0-2022230154143
37
+
38
+ ### Patch Changes
39
+
40
+ - abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
41
+
42
+ ### How to migrate.
43
+
44
+ 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.
45
+
46
+ ```tsx
47
+ import TinaCMS from 'tinacms'
48
+ import schema, { tinaConfig } from '../schema.ts'
49
+
50
+ // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
51
+ // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
52
+ /**
53
+ *
54
+ * @private Do not import this directly, please import the dynamic provider instead
55
+ */
56
+ const TinaProvider = ({ children }) => {
57
+ return (
58
+ <TinaCMS {...tinaConfig} schema={schema}>
59
+ {children}
60
+ </TinaCMS>
61
+ )
62
+ }
63
+
64
+ export default TinaProvider
65
+ ```
66
+
32
67
  - 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.d.ts CHANGED
@@ -1,14 +1 @@
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
- export * from './schema';
14
- export * from './types';
1
+ export * from "../src/index"
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ var __toModule = (module2) => {
51
51
  return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
52
52
  };
53
53
 
54
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/index.ts
54
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/index.ts
55
55
  __export(exports, {
56
56
  TinaSchema: () => TinaSchema,
57
57
  addNamespaceToSchema: () => addNamespaceToSchema,
@@ -59,7 +59,7 @@ __export(exports, {
59
59
  resolveForm: () => resolveForm
60
60
  });
61
61
 
62
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/schema/addNamespaceToSchema.ts
62
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/schema/addNamespaceToSchema.ts
63
63
  function addNamespaceToSchema(maybeNode, namespace = []) {
64
64
  if (typeof maybeNode === "string") {
65
65
  return maybeNode;
@@ -96,7 +96,7 @@ function addNamespaceToSchema(maybeNode, namespace = []) {
96
96
  return __spreadProps(__spreadValues({}, newNode), { namespace });
97
97
  }
98
98
 
99
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/util/validate.ts
99
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/util/validate.ts
100
100
  var yup = __toModule(require("yup"));
101
101
  function assertShape(value, yupSchema, errorMessage) {
102
102
  const shape = yupSchema(yup);
@@ -108,7 +108,7 @@ function assertShape(value, yupSchema, errorMessage) {
108
108
  }
109
109
  }
110
110
 
111
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/util/lastItem.ts
111
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/util/lastItem.ts
112
112
  var lastItem = (arr) => {
113
113
  if (typeof arr === "undefined") {
114
114
  throw new Error("Can not call lastItem when arr is undefined");
@@ -116,7 +116,7 @@ var lastItem = (arr) => {
116
116
  return arr[arr.length - 1];
117
117
  };
118
118
 
119
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/util/namer.ts
119
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/util/namer.ts
120
120
  var capitalize = (s) => {
121
121
  if (typeof s !== "string")
122
122
  return "";
@@ -170,7 +170,7 @@ var NAMER = {
170
170
  }
171
171
  };
172
172
 
173
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/schema/TinaSchema.ts
173
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/schema/TinaSchema.ts
174
174
  var TinaSchema = class {
175
175
  constructor(config) {
176
176
  this.config = config;
@@ -315,7 +315,7 @@ var TinaSchema = class {
315
315
  }
316
316
  };
317
317
 
318
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/schema/resolveField.ts
318
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/schema/resolveField.ts
319
319
  var resolveField = (_a, schema) => {
320
320
  var _b = _a, { namespace } = _b, field = __objRest(_b, ["namespace"]);
321
321
  var _a2;
@@ -429,7 +429,7 @@ var resolveField = (_a, schema) => {
429
429
  }
430
430
  };
431
431
 
432
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/schema-tools/src/schema/resolveForm.ts
432
+ // pnp:/Users/brent/Desktop/forestry/tinacms/packages/@tinacms/schema-tools/src/schema/resolveForm.ts
433
433
  var resolveForm = ({
434
434
  collection,
435
435
  basename,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "0.0.0-20222301112",
3
+ "version": "0.0.0-2022230155428",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -1,80 +0,0 @@
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 { TinaCloudSchemaEnriched, TinaCloudSchemaBase, TinaCloudCollection, Templateable, Collectable, CollectionTemplateable } from '../types';
14
- declare type Version = {
15
- fullVersion: string;
16
- major: string;
17
- minor: string;
18
- patch: string;
19
- };
20
- declare type Meta = {
21
- flags?: string[];
22
- };
23
- /**
24
- * TinaSchema is responsible for allowing you to look up certain
25
- * properties of the user-provided schema with ease.
26
- *
27
- */
28
- export declare class TinaSchema {
29
- config: {
30
- version?: Version;
31
- meta?: Meta;
32
- } & TinaCloudSchemaBase;
33
- schema: TinaCloudSchemaEnriched;
34
- /**
35
- *
36
- * Create a schema class from a user defined schema object
37
- *
38
- * @param {{version?:Version;meta?:Meta}&TinaCloudSchemaBase} config
39
- */
40
- constructor(config: {
41
- version?: Version;
42
- meta?: Meta;
43
- } & TinaCloudSchemaBase);
44
- getCollectionsByName: (collectionNames: string[]) => TinaCloudCollection<true>[];
45
- getAllCollectionPaths: () => string[];
46
- getCollection: (collectionName: string) => TinaCloudCollection<true>;
47
- getCollections: () => TinaCloudCollection<true>[];
48
- getGlobalTemplate: (templateName: string) => {
49
- label: string;
50
- name: string;
51
- ui?: object | (import("../types").UIField<any, any> & {
52
- previewSrc: string;
53
- });
54
- fields: import("../types").TinaFieldInner<true>[];
55
- namespace: string[];
56
- };
57
- getCollectionByFullPath: (filepath: string) => TinaCloudCollection<true>;
58
- getCollectionAndTemplateByFullPath: (filepath: string, templateName?: string) => {
59
- collection: TinaCloudCollection<true>;
60
- template: Templateable;
61
- };
62
- getTemplateForData: ({ data, collection, }: {
63
- data?: unknown;
64
- collection: Collectable;
65
- }) => Templateable;
66
- isMarkdownCollection: (collectionName: string) => boolean;
67
- /**
68
- * Gets the template or templates from the item.
69
- * Both `object` fields and collections support
70
- * the ability for an object to be polymorphic,
71
- * and if it is, we need to build unions, which
72
- * are more of a headache for non-polymorphic
73
- * needs, so we also need the ability to just
74
- * build object types
75
- *
76
- *
77
- */
78
- getTemplatesForCollectable: (collection: Collectable) => CollectionTemplateable;
79
- }
80
- export {};
@@ -1,13 +0,0 @@
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
- export declare function addNamespaceToSchema<T extends object | string>(maybeNode: T, namespace?: string[]): T;
@@ -1,16 +0,0 @@
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
- export * from './addNamespaceToSchema';
14
- export * from './TinaSchema';
15
- export * from './resolveField';
16
- export * from './resolveForm';
@@ -1,24 +0,0 @@
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 { TinaFieldEnriched } from '../types';
14
- import { TinaSchema } from './TinaSchema';
15
- /**
16
- *
17
- * Turns a field the schema (schema.{js,ts} file) into a valid front end FieldConfig
18
- *
19
- *
20
- * @param {TinaFieldEnriched} field. The field that will be transformed
21
- * @param {TinaSchema} schema the entireT Tina Schema
22
- * @returns unknown
23
- */
24
- export declare const resolveField: ({ namespace, ...field }: TinaFieldEnriched, schema: TinaSchema) => unknown;
@@ -1,22 +0,0 @@
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 type { ResolveFormArgs } from '../types';
14
- /**
15
- * Given a collection, basename, template and schema. This will transform the given information into a valid frontend form config
16
- */
17
- export declare const resolveForm: ({ collection, basename, template, schema, }: ResolveFormArgs) => {
18
- id: string;
19
- label: string;
20
- name: string;
21
- fields: unknown[];
22
- };
@@ -1,348 +0,0 @@
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 { TinaSchema } from '../schema';
14
- import type { FC } from 'react';
15
- export declare type UIField<F extends UIField = any, Shape = any> = {
16
- label?: string;
17
- description?: string;
18
- component?: FC<any> | string | null;
19
- parse?: (value: Shape, name: string, field: F) => any;
20
- format?: (value: Shape, name: string, field: F) => any;
21
- validate?(value: Shape, allValues: any, meta: any, field: UIField<F, Shape>): string | object | undefined | void;
22
- defaultValue?: Shape;
23
- };
24
- export interface TinaCloudSchema<WithNamespace extends boolean> {
25
- templates?: GlobalTemplate<WithNamespace>[];
26
- collections: TinaCloudCollection<WithNamespace>[];
27
- }
28
- export declare type TinaCloudSchemaBase = TinaCloudSchema<false>;
29
- export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
30
- /**
31
- * As part of the build process, each node is given a `path: string[]` key
32
- * to help with namespacing type names, this is added as part of the
33
- * createTinaSchema step
34
- */
35
- export interface TinaCloudSchemaWithNamespace {
36
- templates?: GlobalTemplate<true>[];
37
- collections: TinaCloudCollection<true>[];
38
- namespace: string[];
39
- }
40
- export declare type TinaCloudCollection<WithNamespace extends boolean> = CollectionFields<WithNamespace> | CollectionTemplates<WithNamespace>;
41
- export declare type TinaCloudCollectionBase = TinaCloudCollection<false>;
42
- export declare type TinaCloudCollectionEnriched = TinaCloudCollection<true>;
43
- declare type FormatType = 'json' | 'md' | 'markdown' | 'mdx';
44
- interface BaseCollection {
45
- label?: string;
46
- name: string;
47
- path: string;
48
- format?: FormatType;
49
- match?: string;
50
- }
51
- declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
52
- interface CollectionTemplatesInner<WithNamespace extends boolean> extends BaseCollection {
53
- templates: (string | Template<WithNamespace>)[];
54
- fields?: undefined;
55
- }
56
- export interface CollectionTemplatesWithNamespace<WithNamespace extends boolean> extends BaseCollection {
57
- templates: (string | Template<WithNamespace>)[];
58
- fields?: undefined;
59
- references?: ReferenceType<WithNamespace>[];
60
- namespace: WithNamespace extends true ? string[] : undefined;
61
- }
62
- declare type CollectionFields<WithNamespace extends boolean> = WithNamespace extends true ? CollectionFieldsWithNamespace<WithNamespace> : CollectionFieldsInner<WithNamespace>;
63
- export interface CollectionFieldsWithNamespace<WithNamespace extends boolean> extends BaseCollection {
64
- fields: string | TinaFieldInner<WithNamespace>[];
65
- templates?: undefined;
66
- references?: ReferenceType<WithNamespace>[];
67
- namespace: string[];
68
- }
69
- interface CollectionFieldsInner<WithNamespace extends boolean> extends BaseCollection {
70
- fields: string | TinaFieldInner<WithNamespace>[];
71
- templates?: undefined;
72
- }
73
- export declare type TinaFieldInner<WithNamespace extends boolean> = ScalarType<WithNamespace> | ObjectType<WithNamespace> | ReferenceType<WithNamespace> | RichType<WithNamespace>;
74
- export declare type TinaFieldBase = TinaFieldInner<false>;
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
- };
82
- interface TinaField {
83
- name: string;
84
- label?: string;
85
- description?: string;
86
- required?: boolean;
87
- /**
88
- * Any items passed to the UI field will be passed to the underlying field.
89
- * NOTE: only serializable values are supported, so functions like `validate`
90
- * will be ignored.
91
- */
92
- ui?: object;
93
- }
94
- declare type ScalarType<WithNamespace extends boolean> = WithNamespace extends true ? ScalarTypeWithNamespace : ScalarTypeInner;
95
- declare type Option = string | {
96
- label: string;
97
- value: string;
98
- };
99
- declare type ScalarTypeInner = TinaField & TinaScalarField & {
100
- options?: Option[];
101
- };
102
- declare type ScalarTypeWithNamespace = TinaField & TinaScalarField & {
103
- options?: Option[];
104
- namespace: string[];
105
- };
106
- declare type TinaScalarField = StringField | BooleanField | DateTimeField | NumberField | ImageField;
107
- declare type StringField = {
108
- type: 'string';
109
- isBody?: boolean;
110
- list?: false;
111
- ui?: UIField<any, string>;
112
- } | {
113
- type: 'string';
114
- isBody?: boolean;
115
- list: true;
116
- ui?: UIField<any, string[]>;
117
- };
118
- declare type BooleanField = {
119
- type: 'boolean';
120
- list?: false;
121
- ui?: object | UIField<any, boolean>;
122
- } | {
123
- type: 'boolean';
124
- list: true;
125
- ui?: object | UIField<any, boolean[]>;
126
- };
127
- declare type NumberField = {
128
- type: 'number';
129
- list?: false;
130
- ui?: object | UIField<any, number>;
131
- } | {
132
- type: 'number';
133
- list: true;
134
- ui?: object | UIField<any, number[]>;
135
- };
136
- declare type DateTimeField = {
137
- type: 'datetime';
138
- dateFormat?: string;
139
- timeFormat?: string;
140
- list?: false;
141
- ui?: object | UIField<any, string>;
142
- } | {
143
- type: 'datetime';
144
- dateFormat?: string;
145
- timeFormat?: string;
146
- list: true;
147
- ui?: object | UIField<any, string[]>;
148
- };
149
- declare type ImageField = {
150
- type: 'image';
151
- list?: false;
152
- ui?: object | UIField<any, string>;
153
- } | {
154
- type: 'image';
155
- list: true;
156
- ui?: object | UIField<any, string[]>;
157
- };
158
- export declare type ReferenceType<WithNamespace extends boolean> = WithNamespace extends true ? ReferenceTypeWithNamespace : ReferenceTypeInner;
159
- export declare type RichType<WithNamespace extends boolean> = WithNamespace extends true ? RichTypeWithNamespace : RichTypeInner;
160
- export interface ReferenceTypeInner extends TinaField {
161
- type: 'reference';
162
- list?: boolean;
163
- reverseLookup?: {
164
- label: string;
165
- name: string;
166
- };
167
- collections: string[];
168
- }
169
- export interface ReferenceTypeWithNamespace extends TinaField {
170
- type: 'reference';
171
- list?: boolean;
172
- collections: string[];
173
- reverseLookup?: {
174
- label: string;
175
- name: string;
176
- };
177
- namespace: string[];
178
- }
179
- export interface RichTypeWithNamespace extends TinaField {
180
- type: 'rich-text';
181
- namespace: string[];
182
- isBody?: boolean;
183
- list?: boolean;
184
- templates?: (string | (Template<true> & {
185
- inline?: boolean;
186
- }))[];
187
- }
188
- export interface RichTypeInner extends TinaField {
189
- type: 'rich-text';
190
- isBody?: boolean;
191
- list?: boolean;
192
- templates?: (string | (Template<false> & {
193
- inline?: boolean;
194
- }))[];
195
- }
196
- export declare type ObjectType<WithNamespace extends boolean> = ObjectTemplates<WithNamespace> | ObjectFields<WithNamespace>;
197
- declare type ObjectTemplates<WithNamespace extends boolean> = WithNamespace extends true ? ObjectTemplatesWithNamespace<WithNamespace> : ObjectTemplatesInner<WithNamespace>;
198
- declare type ObjectTemplatesInner<WithNamespace extends boolean> = ObjectTemplatesInnerWithList<WithNamespace> | ObjectTemplatesInnerWithoutList<WithNamespace>;
199
- interface ObjectTemplatesInnerWithList<WithNamespace extends boolean> extends ObjectTemplatesInnerBase<WithNamespace> {
200
- list?: true;
201
- ui?: object | ({
202
- itemProps?(item: Record<string, any>): {
203
- key?: string;
204
- label?: string;
205
- };
206
- } & UIField<any, string>);
207
- }
208
- interface ObjectTemplatesInnerWithoutList<WithNamespace extends boolean> extends ObjectTemplatesInnerBase<WithNamespace> {
209
- list?: false;
210
- ui?: object | UIField<any, string>;
211
- }
212
- interface ObjectTemplatesInnerBase<WithNamespace extends boolean> extends TinaField {
213
- type: 'object';
214
- visualSelector?: boolean;
215
- required?: false;
216
- list?: boolean;
217
- /**
218
- * templates can either be an array of Tina templates or a reference to
219
- * global template definition.
220
- *
221
- * You should use `templates` when your object can be any one of multiple shapes (polymorphic)
222
- *
223
- * You can only provide one of `fields` or `template`, but not both
224
- */
225
- templates: (string | Template<WithNamespace>)[];
226
- fields?: undefined;
227
- }
228
- interface ObjectTemplatesWithNamespace<WithNamespace extends boolean> extends TinaField {
229
- type: 'object';
230
- visualSelector?: boolean;
231
- required?: false;
232
- list?: boolean;
233
- /**
234
- * templates can either be an array of Tina templates or a reference to
235
- * global template definition.
236
- *
237
- * You should use `templates` when your object can be any one of multiple shapes (polymorphic)
238
- *
239
- * You can only provide one of `fields` or `template`, but not both
240
- */
241
- templates: (string | Template<WithNamespace>)[];
242
- fields?: undefined;
243
- namespace: WithNamespace extends true ? string[] : undefined;
244
- }
245
- declare type ObjectFields<WithNamespace extends boolean> = WithNamespace extends true ? InnerObjectFieldsWithNamespace<WithNamespace> : InnerObjectFields<WithNamespace>;
246
- interface InnerObjectFields<WithNamespace extends boolean> extends TinaField {
247
- type: 'object';
248
- visualSelector?: boolean;
249
- required?: false;
250
- /**
251
- * fields can either be an array of Tina fields, or a reference to the fields
252
- * of a global template definition.
253
- *
254
- * You can only provide one of `fields` or `templates`, but not both.
255
- */
256
- fields: string | TinaFieldInner<WithNamespace>[];
257
- templates?: undefined;
258
- list?: boolean;
259
- }
260
- interface InnerObjectFieldsWithNamespace<WithNamespace extends boolean> extends TinaField {
261
- type: 'object';
262
- visualSelector?: boolean;
263
- required?: false;
264
- /**
265
- * fields can either be an array of Tina fields, or a reference to the fields
266
- * of a global template definition.
267
- *
268
- * You can only provide one of `fields` or `templates`, but not both.
269
- */
270
- fields: string | TinaFieldInner<WithNamespace>[];
271
- templates?: undefined;
272
- namespace: WithNamespace extends true ? string[] : undefined;
273
- list?: boolean;
274
- }
275
- /**
276
- * Global Templates are defined once, and can be used anywhere by referencing the 'name' of the template
277
- *
278
- * TODO: ensure we don't permit infite loop with self-references
279
- */
280
- export declare type GlobalTemplate<WithNamespace extends boolean> = WithNamespace extends true ? {
281
- label: string;
282
- name: string;
283
- ui?: object | (UIField<any, any> & {
284
- previewSrc: string;
285
- });
286
- fields: TinaFieldInner<WithNamespace>[];
287
- namespace: WithNamespace extends true ? string[] : undefined;
288
- } : {
289
- label: string;
290
- name: string;
291
- ui?: object | (UIField<any, any> & {
292
- previewSrc: string;
293
- });
294
- fields: TinaFieldInner<WithNamespace>[];
295
- };
296
- export declare type TinaCloudTemplateBase = GlobalTemplate<false>;
297
- export declare type TinaCloudTemplateEnriched = GlobalTemplate<true>;
298
- /**
299
- * Templates allow you to define an object as polymorphic
300
- */
301
- export declare type Template<WithNamespace extends boolean> = WithNamespace extends true ? {
302
- label: string;
303
- name: string;
304
- fields: TinaFieldInner<WithNamespace>[];
305
- ui?: object | (UIField<any, any> & {
306
- previewSrc: string;
307
- });
308
- namespace: WithNamespace extends true ? string[] : undefined;
309
- } : {
310
- label: string;
311
- name: string;
312
- ui?: object | (UIField<any, any> & {
313
- previewSrc: string;
314
- });
315
- fields: TinaFieldInner<WithNamespace>[];
316
- };
317
- export declare type CollectionTemplateableUnion = {
318
- namespace: string[];
319
- type: 'union';
320
- templates: Templateable[];
321
- };
322
- export declare type CollectionTemplateableObject = {
323
- namespace: string[];
324
- type: 'object';
325
- visualSelector?: boolean;
326
- required?: false;
327
- template: Templateable;
328
- };
329
- export declare type CollectionTemplateable = CollectionTemplateableUnion | CollectionTemplateableObject;
330
- export declare type Collectable = {
331
- namespace: string[];
332
- templates?: (string | Templateable)[];
333
- fields?: string | TinaFieldEnriched[];
334
- references?: ReferenceType<true>[];
335
- };
336
- export declare type Templateable = {
337
- name: string;
338
- namespace: string[];
339
- fields: TinaFieldEnriched[];
340
- ui?: object;
341
- };
342
- export declare type ResolveFormArgs = {
343
- collection: TinaCloudCollection<true>;
344
- basename: string;
345
- template: Templateable;
346
- schema: TinaSchema;
347
- };
348
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
-
3
- Copyright 2021 Forestry.io Holdings, Inc.
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
-
17
- */
18
- export * from './SchemaTypes';
@@ -1,16 +0,0 @@
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
- export * from './validate';
14
- export * from './lastItem';
15
- export * from './namer';
16
- export * from './sequential';
@@ -1,13 +0,0 @@
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
- export declare const lastItem: (arr: (number | string)[]) => string | number;
@@ -1,28 +0,0 @@
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
- export declare const NAMER: {
14
- dataFilterTypeNameOn: (namespace: string[]) => string;
15
- dataFilterTypeName: (namespace: string[]) => string;
16
- dataMutationTypeNameOn: (namespace: string[]) => string;
17
- dataMutationTypeName: (namespace: string[]) => string;
18
- updateName: (namespace: string[]) => string;
19
- createName: (namespace: string[]) => string;
20
- queryName: (namespace: string[]) => string;
21
- generateQueryListName: (namespace: string[]) => string;
22
- fragmentName: (namespace: string[]) => string;
23
- collectionTypeName: (namespace: string[]) => string;
24
- documentTypeName: (namespace: string[]) => string;
25
- dataTypeName: (namespace: string[]) => string;
26
- referenceConnectionType: (namespace: string[]) => string;
27
- referenceConnectionEdgesTypeName: (namespace: string[]) => string;
28
- };
@@ -1,23 +0,0 @@
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
- /**
14
- * Iterate through an array of promises sequentially, ensuring the order
15
- * is preserved.
16
- *
17
- * ```js
18
- * await sequential(templates, async (template) => {
19
- * await doSomething(template)
20
- * })
21
- * ```
22
- */
23
- export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
@@ -1,15 +0,0 @@
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 * as yup from 'yup';
14
- import type { Schema } from 'yup';
15
- export declare function assertShape<T extends unknown>(value: unknown, yupSchema: (args: typeof yup) => Schema<any, any>, errorMessage?: string): asserts value is T;