@tinacms/schema-tools 0.0.0-20220629020212

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.
@@ -0,0 +1,81 @@
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
+ getIsTitleFieldName: (collection: string) => string;
45
+ getCollectionsByName: (collectionNames: string[]) => TinaCloudCollection<true>[];
46
+ getAllCollectionPaths: () => string[];
47
+ getCollection: (collectionName: string) => TinaCloudCollection<true>;
48
+ getCollections: () => TinaCloudCollection<true>[];
49
+ getGlobalTemplate: (templateName: string) => {
50
+ label: string;
51
+ name: string;
52
+ ui?: object | (import("../types").UIField<any, any> & {
53
+ previewSrc: string;
54
+ });
55
+ fields: import("../types").TinaFieldInner<true>[];
56
+ namespace: string[];
57
+ };
58
+ getCollectionByFullPath: (filepath: string) => TinaCloudCollection<true>;
59
+ getCollectionAndTemplateByFullPath: (filepath: string, templateName?: string) => {
60
+ collection: TinaCloudCollection<true>;
61
+ template: Templateable;
62
+ };
63
+ getTemplateForData: ({ data, collection, }: {
64
+ data?: unknown;
65
+ collection: Collectable;
66
+ }) => Templateable;
67
+ isMarkdownCollection: (collectionName: string) => boolean;
68
+ /**
69
+ * Gets the template or templates from the item.
70
+ * Both `object` fields and collections support
71
+ * the ability for an object to be polymorphic,
72
+ * and if it is, we need to build unions, which
73
+ * are more of a headache for non-polymorphic
74
+ * needs, so we also need the ability to just
75
+ * build object types
76
+ *
77
+ *
78
+ */
79
+ getTemplatesForCollectable: (collection: Collectable) => CollectionTemplateable;
80
+ }
81
+ export {};
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,16 @@
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';
@@ -0,0 +1,24 @@
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;
@@ -0,0 +1,22 @@
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
+ };
@@ -0,0 +1,362 @@
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 TinaCloudSchemaConfig {
25
+ media?: {
26
+ tina?: {
27
+ publicFolder: string;
28
+ mediaRoot: string;
29
+ };
30
+ };
31
+ }
32
+ export interface TinaCloudSchema<WithNamespace extends boolean> {
33
+ templates?: GlobalTemplate<WithNamespace>[];
34
+ collections: TinaCloudCollection<WithNamespace>[];
35
+ config?: TinaCloudSchemaConfig;
36
+ }
37
+ export declare type TinaCloudSchemaBase = TinaCloudSchema<false>;
38
+ export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
39
+ /**
40
+ * As part of the build process, each node is given a `path: string[]` key
41
+ * to help with namespacing type names, this is added as part of the
42
+ * createTinaSchema step
43
+ */
44
+ export interface TinaCloudSchemaWithNamespace {
45
+ templates?: GlobalTemplate<true>[];
46
+ collections: TinaCloudCollection<true>[];
47
+ config?: TinaCloudSchemaConfig;
48
+ namespace: string[];
49
+ }
50
+ export declare type TinaCloudCollection<WithNamespace extends boolean> = CollectionFields<WithNamespace> | CollectionTemplates<WithNamespace>;
51
+ export declare type TinaCloudCollectionBase = TinaCloudCollection<false>;
52
+ export declare type TinaCloudCollectionEnriched = TinaCloudCollection<true>;
53
+ declare type FormatType = 'json' | 'md' | 'markdown' | 'mdx';
54
+ interface BaseCollection {
55
+ label?: string;
56
+ name: string;
57
+ path: string;
58
+ format?: FormatType;
59
+ match?: string;
60
+ }
61
+ declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
62
+ interface CollectionTemplatesInner<WithNamespace extends boolean> extends BaseCollection {
63
+ templates: (string | Template<WithNamespace>)[];
64
+ fields?: undefined;
65
+ }
66
+ export interface CollectionTemplatesWithNamespace<WithNamespace extends boolean> extends BaseCollection {
67
+ templates: (string | Template<WithNamespace>)[];
68
+ fields?: undefined;
69
+ references?: ReferenceType<WithNamespace>[];
70
+ namespace: WithNamespace extends true ? string[] : undefined;
71
+ }
72
+ declare type CollectionFields<WithNamespace extends boolean> = WithNamespace extends true ? CollectionFieldsWithNamespace<WithNamespace> : CollectionFieldsInner<WithNamespace>;
73
+ export interface CollectionFieldsWithNamespace<WithNamespace extends boolean> extends BaseCollection {
74
+ fields: TinaFieldInner<WithNamespace>[];
75
+ templates?: undefined;
76
+ references?: ReferenceType<WithNamespace>[];
77
+ namespace: string[];
78
+ }
79
+ interface CollectionFieldsInner<WithNamespace extends boolean> extends BaseCollection {
80
+ fields: TinaFieldInner<WithNamespace>[];
81
+ templates?: undefined;
82
+ }
83
+ export declare type TinaFieldInner<WithNamespace extends boolean> = ScalarType<WithNamespace> | ObjectType<WithNamespace> | ReferenceType<WithNamespace> | RichType<WithNamespace>;
84
+ export declare type TinaFieldBase = TinaFieldInner<false>;
85
+ export declare type TinaFieldEnriched = TinaFieldInner<true> & {
86
+ /**
87
+ * The parentTypename will always be an object type, either the type of a
88
+ * collection (ie. `Post`) or of an object field (ie. `PageBlocks`).
89
+ */
90
+ parentTypename?: string;
91
+ };
92
+ interface TinaField {
93
+ name: string;
94
+ label?: string;
95
+ description?: string;
96
+ required?: boolean;
97
+ /**
98
+ * Any items passed to the UI field will be passed to the underlying field.
99
+ * NOTE: only serializable values are supported, so functions like `validate`
100
+ * will be ignored.
101
+ */
102
+ ui?: Record<string, any>;
103
+ }
104
+ declare type ScalarType<WithNamespace extends boolean> = WithNamespace extends true ? ScalarTypeWithNamespace : ScalarTypeInner;
105
+ declare type Option = string | {
106
+ label: string;
107
+ value: string;
108
+ };
109
+ declare type ScalarTypeInner = TinaField & TinaScalarField & {
110
+ options?: Option[];
111
+ };
112
+ declare type ScalarTypeWithNamespace = TinaField & TinaScalarField & {
113
+ options?: Option[];
114
+ namespace: string[];
115
+ };
116
+ declare type TinaScalarField = StringField | BooleanField | DateTimeField | NumberField | ImageField;
117
+ declare type StringField = {
118
+ type: 'string';
119
+ isBody?: boolean;
120
+ list?: false;
121
+ isTitle?: boolean;
122
+ ui?: UIField<any, string>;
123
+ } | {
124
+ type: 'string';
125
+ isBody?: boolean;
126
+ list: true;
127
+ isTitle?: never;
128
+ ui?: UIField<any, string[]>;
129
+ };
130
+ declare type BooleanField = {
131
+ type: 'boolean';
132
+ list?: false;
133
+ ui?: object | UIField<any, boolean>;
134
+ } | {
135
+ type: 'boolean';
136
+ list: true;
137
+ ui?: object | UIField<any, boolean[]>;
138
+ };
139
+ declare type NumberField = {
140
+ type: 'number';
141
+ list?: false;
142
+ ui?: object | UIField<any, number>;
143
+ } | {
144
+ type: 'number';
145
+ list: true;
146
+ ui?: object | UIField<any, number[]>;
147
+ };
148
+ declare type DateTimeField = {
149
+ type: 'datetime';
150
+ dateFormat?: string;
151
+ timeFormat?: string;
152
+ list?: false;
153
+ ui?: object | UIField<any, string>;
154
+ } | {
155
+ type: 'datetime';
156
+ dateFormat?: string;
157
+ timeFormat?: string;
158
+ list: true;
159
+ ui?: object | UIField<any, string[]>;
160
+ };
161
+ declare type ImageField = {
162
+ type: 'image';
163
+ list?: false;
164
+ ui?: object | UIField<any, string>;
165
+ } | {
166
+ type: 'image';
167
+ list: true;
168
+ ui?: object | UIField<any, string[]>;
169
+ };
170
+ export declare type ReferenceType<WithNamespace extends boolean> = WithNamespace extends true ? ReferenceTypeWithNamespace : ReferenceTypeInner;
171
+ export declare type RichType<WithNamespace extends boolean> = WithNamespace extends true ? RichTypeWithNamespace : RichTypeInner;
172
+ export interface ReferenceTypeInner extends TinaField {
173
+ type: 'reference';
174
+ list?: boolean;
175
+ reverseLookup?: {
176
+ label: string;
177
+ name: string;
178
+ };
179
+ collections: string[];
180
+ ui?: UIField<any, string[]>;
181
+ }
182
+ export interface ReferenceTypeWithNamespace extends TinaField {
183
+ type: 'reference';
184
+ list?: boolean;
185
+ collections: string[];
186
+ reverseLookup?: {
187
+ label: string;
188
+ name: string;
189
+ };
190
+ namespace: string[];
191
+ ui?: UIField<any, string[]>;
192
+ }
193
+ export interface RichTypeWithNamespace extends TinaField {
194
+ type: 'rich-text';
195
+ namespace: string[];
196
+ isBody?: boolean;
197
+ list?: boolean;
198
+ templates?: (string | (Template<true> & {
199
+ inline?: boolean;
200
+ }))[];
201
+ }
202
+ export interface RichTypeInner extends TinaField {
203
+ type: 'rich-text';
204
+ isBody?: boolean;
205
+ list?: boolean;
206
+ templates?: (string | (Template<false> & {
207
+ inline?: boolean;
208
+ }))[];
209
+ }
210
+ export declare type ObjectType<WithNamespace extends boolean> = ObjectTemplates<WithNamespace> | ObjectFields<WithNamespace>;
211
+ declare type ObjectTemplates<WithNamespace extends boolean> = WithNamespace extends true ? ObjectTemplatesWithNamespace<WithNamespace> : ObjectTemplatesInner<WithNamespace>;
212
+ declare type ObjectTemplatesInner<WithNamespace extends boolean> = ObjectTemplatesInnerWithList<WithNamespace> | ObjectTemplatesInnerWithoutList<WithNamespace>;
213
+ interface ObjectTemplatesInnerWithList<WithNamespace extends boolean> extends ObjectTemplatesInnerBase<WithNamespace> {
214
+ list?: true;
215
+ ui?: object | ({
216
+ itemProps?(item: Record<string, any>): {
217
+ key?: string;
218
+ label?: string;
219
+ };
220
+ } & UIField<any, string>);
221
+ }
222
+ interface ObjectTemplatesInnerWithoutList<WithNamespace extends boolean> extends ObjectTemplatesInnerBase<WithNamespace> {
223
+ list?: false;
224
+ ui?: object | UIField<any, string>;
225
+ }
226
+ interface ObjectTemplatesInnerBase<WithNamespace extends boolean> extends TinaField {
227
+ type: 'object';
228
+ visualSelector?: boolean;
229
+ required?: false;
230
+ list?: boolean;
231
+ /**
232
+ * templates can either be an array of Tina templates or a reference to
233
+ * global template definition.
234
+ *
235
+ * You should use `templates` when your object can be any one of multiple shapes (polymorphic)
236
+ *
237
+ * You can only provide one of `fields` or `template`, but not both
238
+ */
239
+ templates: (string | Template<WithNamespace>)[];
240
+ fields?: undefined;
241
+ }
242
+ interface ObjectTemplatesWithNamespace<WithNamespace extends boolean> extends TinaField {
243
+ type: 'object';
244
+ visualSelector?: boolean;
245
+ required?: false;
246
+ list?: boolean;
247
+ /**
248
+ * templates can either be an array of Tina templates or a reference to
249
+ * global template definition.
250
+ *
251
+ * You should use `templates` when your object can be any one of multiple shapes (polymorphic)
252
+ *
253
+ * You can only provide one of `fields` or `template`, but not both
254
+ */
255
+ templates: (string | Template<WithNamespace>)[];
256
+ fields?: undefined;
257
+ namespace: WithNamespace extends true ? string[] : undefined;
258
+ }
259
+ declare type ObjectFields<WithNamespace extends boolean> = WithNamespace extends true ? InnerObjectFieldsWithNamespace<WithNamespace> : InnerObjectFields<WithNamespace>;
260
+ interface InnerObjectFields<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
+ list?: boolean;
273
+ }
274
+ interface InnerObjectFieldsWithNamespace<WithNamespace extends boolean> extends TinaField {
275
+ type: 'object';
276
+ visualSelector?: boolean;
277
+ required?: false;
278
+ /**
279
+ * fields can either be an array of Tina fields, or a reference to the fields
280
+ * of a global template definition.
281
+ *
282
+ * You can only provide one of `fields` or `templates`, but not both.
283
+ */
284
+ fields: string | TinaFieldInner<WithNamespace>[];
285
+ templates?: undefined;
286
+ namespace: WithNamespace extends true ? string[] : undefined;
287
+ list?: boolean;
288
+ }
289
+ /**
290
+ * Global Templates are defined once, and can be used anywhere by referencing the 'name' of the template
291
+ *
292
+ * TODO: ensure we don't permit infite loop with self-references
293
+ */
294
+ export declare type GlobalTemplate<WithNamespace extends boolean> = WithNamespace extends true ? {
295
+ label: string;
296
+ name: string;
297
+ ui?: object | (UIField<any, any> & {
298
+ previewSrc: string;
299
+ });
300
+ fields: TinaFieldInner<WithNamespace>[];
301
+ namespace: WithNamespace extends true ? string[] : undefined;
302
+ } : {
303
+ label: string;
304
+ name: string;
305
+ ui?: object | (UIField<any, any> & {
306
+ previewSrc: string;
307
+ });
308
+ fields: TinaFieldInner<WithNamespace>[];
309
+ };
310
+ export declare type TinaCloudTemplateBase = GlobalTemplate<false>;
311
+ export declare type TinaCloudTemplateEnriched = GlobalTemplate<true>;
312
+ /**
313
+ * Templates allow you to define an object as polymorphic
314
+ */
315
+ export declare type Template<WithNamespace extends boolean> = WithNamespace extends true ? {
316
+ label: string;
317
+ name: string;
318
+ fields: TinaFieldInner<WithNamespace>[];
319
+ ui?: object | (UIField<any, any> & {
320
+ previewSrc: string;
321
+ });
322
+ namespace: WithNamespace extends true ? string[] : undefined;
323
+ } : {
324
+ label: string;
325
+ name: string;
326
+ ui?: object | (UIField<any, any> & {
327
+ previewSrc: string;
328
+ });
329
+ fields: TinaFieldInner<WithNamespace>[];
330
+ };
331
+ export declare type CollectionTemplateableUnion = {
332
+ namespace: string[];
333
+ type: 'union';
334
+ templates: Templateable[];
335
+ };
336
+ export declare type CollectionTemplateableObject = {
337
+ namespace: string[];
338
+ type: 'object';
339
+ visualSelector?: boolean;
340
+ required?: false;
341
+ template: Templateable;
342
+ };
343
+ export declare type CollectionTemplateable = CollectionTemplateableUnion | CollectionTemplateableObject;
344
+ export declare type Collectable = {
345
+ namespace: string[];
346
+ templates?: (string | Templateable)[];
347
+ fields?: string | TinaFieldEnriched[];
348
+ references?: ReferenceType<true>[];
349
+ };
350
+ export declare type Templateable = {
351
+ name: string;
352
+ namespace: string[];
353
+ fields: TinaFieldEnriched[];
354
+ ui?: object;
355
+ };
356
+ export declare type ResolveFormArgs = {
357
+ collection: TinaCloudCollection<true>;
358
+ basename: string;
359
+ template: Templateable;
360
+ schema: TinaSchema;
361
+ };
362
+ export {};
@@ -0,0 +1,18 @@
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';
@@ -0,0 +1,13 @@
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 hasDuplicates<T = any>(array: T[]): boolean;
@@ -0,0 +1,17 @@
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';
17
+ export * from './hasDuplicates';
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,28 @@
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
+ };
@@ -0,0 +1,16 @@
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 { ZodError } from 'zod';
14
+ export declare const parseZodError: ({ zodError }: {
15
+ zodError: ZodError;
16
+ }) => string[];
@@ -0,0 +1,23 @@
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[]>;
@@ -0,0 +1,15 @@
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 { AnySchema } from 'yup';
15
+ export declare function assertShape<T extends unknown>(value: unknown, yupSchema: (args: typeof yup) => AnySchema, errorMessage?: string): asserts value is T;