@tinacms/graphql 0.63.9 → 0.63.10

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/dist/build.d.ts CHANGED
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import { DocumentNode } from 'graphql';
14
- import type { TinaSchema } from './schema';
14
+ import { TinaSchema } from '@tinacms/schema-tools';
15
15
  import { Database } from './database';
16
16
  export declare const buildDotTinaFiles: ({ database, config, flags, buildSDK, }: {
17
17
  database: Database;
@@ -12,8 +12,8 @@ limitations under the License.
12
12
  */
13
13
  import { Database } from '../database';
14
14
  import type { ObjectTypeDefinitionNode, InlineFragmentNode, FieldDefinitionNode } from 'graphql';
15
- import type { TinaCloudCollectionEnriched, Template } from '../types';
16
- import { TinaSchema } from '../schema';
15
+ import type { TinaCloudCollectionEnriched, Template } from '@tinacms/schema-tools';
16
+ import { TinaSchema } from '@tinacms/schema-tools';
17
17
  export declare const createBuilder: ({ database, tinaSchema, }: {
18
18
  database: Database;
19
19
  tinaSchema: TinaSchema;
@@ -12,8 +12,8 @@ limitations under the License.
12
12
  */
13
13
  import type { BinaryFilter, IndexDefinition, Store, TernaryFilter } from '@tinacms/datalayer';
14
14
  import type { DocumentNode } from 'graphql';
15
- import type { TinaSchema } from '../schema';
16
- import type { TinaCloudSchemaBase } from '../types';
15
+ import type { TinaSchema } from '@tinacms/schema-tools';
16
+ import type { TinaCloudSchemaBase } from '@tinacms/schema-tools';
17
17
  import type { Bridge } from './bridge';
18
18
  declare type IndexStatusEvent = {
19
19
  status: 'inprogress' | 'complete' | 'failed';
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
+ export type { Store } from '@tinacms/datalayer';
14
+ import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from '@tinacms/schema-tools';
13
15
  import { buildDotTinaFiles } from './build';
14
16
  export { resolve } from './resolve';
15
17
  export * from './resolver/error';
@@ -17,19 +19,17 @@ export { createDatabase } from './database';
17
19
  export type { QueryOptions } from './database';
18
20
  import type { Database } from './database';
19
21
  export type { Database } from './database';
20
- export type { Store } from '@tinacms/datalayer';
21
22
  export type { Bridge } from './database/bridge';
22
23
  export { sequential, assertShape } from './util';
23
24
  export { stringifyFile, parseFile } from './database/util';
24
- export { createSchema } from './schema';
25
+ export { createSchema } from './schema/createSchema';
25
26
  export { buildDotTinaFiles };
26
27
  export declare type DummyType = unknown;
27
28
  export declare const buildSchema: (rootPath: string, database: Database, flags?: string[]) => Promise<{
28
29
  graphQLSchema: import("graphql").DocumentNode;
29
- tinaSchema: import("./schema").TinaSchema;
30
+ tinaSchema: import("@tinacms/schema-tools").TinaSchema;
30
31
  }>;
31
32
  export declare const getASTSchema: (database: Database) => Promise<import("graphql").GraphQLSchema>;
32
- import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from './types';
33
33
  export declare type TinaCloudSchema = TinaCloudSchemaBase<false>;
34
34
  export declare type TinaSchema = TinaCloudSchema;
35
35
  export declare type TinaCloudCollection = TinaCloudCollectionBase<false>;
package/dist/index.js CHANGED
@@ -925,6 +925,15 @@ var astBuilder = {
925
925
  selectionSet: {
926
926
  kind: "SelectionSet",
927
927
  selections: [
928
+ {
929
+ kind: "Field",
930
+ name: {
931
+ kind: "Name",
932
+ value: "cursor"
933
+ },
934
+ arguments: [],
935
+ directives: []
936
+ },
928
937
  {
929
938
  kind: "Field",
930
939
  name: {
@@ -2323,6 +2332,9 @@ var filterSelections = (arr) => {
2323
2332
  return arr.filter(Boolean);
2324
2333
  };
2325
2334
 
2335
+ // src/schema/createSchema.ts
2336
+ var import_schema_tools2 = __toModule(require("@tinacms/schema-tools"));
2337
+
2326
2338
  // src/schema/validate.ts
2327
2339
  var import_lodash2 = __toModule(require("lodash"));
2328
2340
  var yup2 = __toModule(require("yup"));
@@ -2439,7 +2451,7 @@ var validateField = async (field) => {
2439
2451
 
2440
2452
  // package.json
2441
2453
  var name = "@tinacms/graphql";
2442
- var version = "0.63.9";
2454
+ var version = "0.63.10";
2443
2455
  var main = "dist/index.js";
2444
2456
  var typings = "dist/index.d.ts";
2445
2457
  var files = [
@@ -2558,56 +2570,7 @@ var package_default = {
2558
2570
  devDependencies
2559
2571
  };
2560
2572
 
2561
- // src/resolver/error.ts
2562
- var TinaGraphQLError = class extends Error {
2563
- constructor(message, extensions) {
2564
- super(message);
2565
- if (!this.name) {
2566
- Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
2567
- }
2568
- this.extensions = __spreadValues({}, extensions);
2569
- }
2570
- };
2571
- var TinaFetchError = class extends Error {
2572
- constructor(message, args) {
2573
- super(message);
2574
- this.name = "TinaFetchError";
2575
- this.collection = args.collection;
2576
- this.stack = args.stack;
2577
- this.file = args.file;
2578
- this.originalError = args.originalError;
2579
- }
2580
- };
2581
- var TinaQueryError = class extends TinaFetchError {
2582
- constructor(args) {
2583
- super(`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`, args);
2584
- }
2585
- };
2586
- var TinaParseDocumentError = class extends TinaFetchError {
2587
- constructor(args) {
2588
- super(`Error Parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`, args);
2589
- }
2590
- toString() {
2591
- return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
2592
- }
2593
- };
2594
- var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
2595
- var handleFetchErrorError = (e, verbose) => {
2596
- if (e instanceof Error) {
2597
- if (e instanceof TinaFetchError) {
2598
- if (verbose) {
2599
- console.log(e.toString());
2600
- console.log(e);
2601
- console.log(e.stack);
2602
- }
2603
- }
2604
- } else {
2605
- console.error(e);
2606
- }
2607
- throw e;
2608
- };
2609
-
2610
- // src/schema/index.ts
2573
+ // src/schema/createSchema.ts
2611
2574
  var createSchema = async ({
2612
2575
  schema,
2613
2576
  flags = []
@@ -2618,7 +2581,7 @@ var createSchema = async ({
2618
2581
  if (flags && flags.length > 0) {
2619
2582
  meta["flags"] = flags;
2620
2583
  }
2621
- return new TinaSchema(__spreadValues({
2584
+ return new import_schema_tools2.TinaSchema(__spreadValues({
2622
2585
  version: {
2623
2586
  fullVersion: package_default.version,
2624
2587
  major,
@@ -2628,148 +2591,6 @@ var createSchema = async ({
2628
2591
  meta
2629
2592
  }, validSchema));
2630
2593
  };
2631
- var TinaSchema = class {
2632
- constructor(config) {
2633
- this.config = config;
2634
- this.getCollectionsByName = (collectionNames) => {
2635
- return this.schema.collections.filter((collection) => collectionNames.includes(collection.name));
2636
- };
2637
- this.getAllCollectionPaths = () => {
2638
- const paths = this.getCollections().map((collection) => `${collection.path}${collection.match || ""}`);
2639
- return paths;
2640
- };
2641
- this.getCollection = (collectionName) => {
2642
- const collection = this.schema.collections.find((collection2) => collection2.name === collectionName);
2643
- if (!collection) {
2644
- throw new Error(`Expected to find collection named ${collectionName}`);
2645
- }
2646
- const extraFields = {};
2647
- const templateInfo = this.getTemplatesForCollectable(collection);
2648
- switch (templateInfo.type) {
2649
- case "object":
2650
- extraFields["fields"] = templateInfo.template.fields;
2651
- break;
2652
- case "union":
2653
- extraFields["templates"] = templateInfo.templates;
2654
- break;
2655
- }
2656
- return __spreadProps(__spreadValues(__spreadValues({
2657
- slug: collection.name
2658
- }, extraFields), collection), {
2659
- format: collection.format || "md"
2660
- });
2661
- };
2662
- this.getCollections = () => {
2663
- return this.schema.collections.map((collection) => this.getCollection(collection.name)) || [];
2664
- };
2665
- this.getGlobalTemplate = (templateName) => {
2666
- var _a;
2667
- const globalTemplate = (_a = this.schema.templates) == null ? void 0 : _a.find((template) => template.name === templateName);
2668
- if (!globalTemplate) {
2669
- throw new Error(`Expected to find global template of name ${templateName}`);
2670
- }
2671
- return globalTemplate;
2672
- };
2673
- this.getCollectionByFullPath = (filepath) => {
2674
- const collection = this.getCollections().find((collection2) => {
2675
- return filepath.replace(/\\/g, "/").startsWith(collection2.path.replace(/\/?$/, "/"));
2676
- });
2677
- if (!collection) {
2678
- throw new Error(`Unable to find collection for file at ${filepath}`);
2679
- }
2680
- return collection;
2681
- };
2682
- this.getCollectionAndTemplateByFullPath = (filepath, templateName) => {
2683
- let template;
2684
- const collection = this.getCollectionByFullPath(filepath);
2685
- const templates = this.getTemplatesForCollectable(collection);
2686
- if (templates.type === "union") {
2687
- if (templateName) {
2688
- template = templates.templates.find((template2) => lastItem(template2.namespace) === templateName);
2689
- if (!template) {
2690
- throw new Error(`Unable to determine template for item at ${filepath}`);
2691
- }
2692
- } else {
2693
- throw new Error(`Unable to determine template for item at ${filepath}, no template name provided for collection with multiple templates`);
2694
- }
2695
- }
2696
- if (templates.type === "object") {
2697
- template = templates.template;
2698
- }
2699
- if (!template) {
2700
- throw new Error(`Something went wrong while trying to determine template for ${filepath}`);
2701
- }
2702
- return { collection, template };
2703
- };
2704
- this.getTemplateForData = async ({
2705
- data,
2706
- collection
2707
- }) => {
2708
- const templateInfo = this.getTemplatesForCollectable(collection);
2709
- switch (templateInfo.type) {
2710
- case "object":
2711
- return templateInfo.template;
2712
- case "union":
2713
- assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
2714
- const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
2715
- if (!template) {
2716
- throw new TinaGraphQLError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
2717
- collection: lastItem(collection.namespace),
2718
- possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
2719
- data
2720
- });
2721
- }
2722
- return template;
2723
- }
2724
- };
2725
- this.isMarkdownCollection = (collectionName) => {
2726
- const collection = this.getCollection(collectionName);
2727
- const format = collection.format;
2728
- if (!format) {
2729
- return true;
2730
- }
2731
- if (["markdown", "md"].includes(format)) {
2732
- return true;
2733
- }
2734
- return false;
2735
- };
2736
- this.getTemplatesForCollectable = (collection) => {
2737
- let extraFields = [];
2738
- if (collection.references) {
2739
- extraFields = collection.references;
2740
- }
2741
- if (collection.fields) {
2742
- const template = typeof collection.fields === "string" ? this.getGlobalTemplate(collection.fields) : collection;
2743
- if (typeof template.fields === "string" || typeof template.fields === "undefined") {
2744
- throw new Error("Exptected template to have fields but none were found");
2745
- }
2746
- return {
2747
- namespace: collection.namespace,
2748
- type: "object",
2749
- template: __spreadProps(__spreadValues({}, template), {
2750
- fields: [...template.fields, ...extraFields]
2751
- })
2752
- };
2753
- } else {
2754
- if (collection.templates) {
2755
- return {
2756
- namespace: collection.namespace,
2757
- type: "union",
2758
- templates: collection.templates.map((templateOrTemplateString) => {
2759
- const template = typeof templateOrTemplateString === "string" ? this.getGlobalTemplate(templateOrTemplateString) : templateOrTemplateString;
2760
- return __spreadProps(__spreadValues({}, template), {
2761
- fields: [...template.fields, ...extraFields]
2762
- });
2763
- })
2764
- };
2765
- } else {
2766
- throw new Error(`Expected either fields or templates array to be defined on collection ${collection.namespace.join("_")}`);
2767
- }
2768
- }
2769
- };
2770
- this.schema = config;
2771
- }
2772
- };
2773
2594
 
2774
2595
  // src/build.ts
2775
2596
  var import_path = __toModule(require("path"));
@@ -2907,6 +2728,55 @@ var import_isValid = __toModule(require("date-fns/isValid"));
2907
2728
  // src/mdx/index.ts
2908
2729
  var import_mdx = __toModule(require("@tinacms/mdx"));
2909
2730
 
2731
+ // src/resolver/error.ts
2732
+ var TinaGraphQLError = class extends Error {
2733
+ constructor(message, extensions) {
2734
+ super(message);
2735
+ if (!this.name) {
2736
+ Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
2737
+ }
2738
+ this.extensions = __spreadValues({}, extensions);
2739
+ }
2740
+ };
2741
+ var TinaFetchError = class extends Error {
2742
+ constructor(message, args) {
2743
+ super(message);
2744
+ this.name = "TinaFetchError";
2745
+ this.collection = args.collection;
2746
+ this.stack = args.stack;
2747
+ this.file = args.file;
2748
+ this.originalError = args.originalError;
2749
+ }
2750
+ };
2751
+ var TinaQueryError = class extends TinaFetchError {
2752
+ constructor(args) {
2753
+ super(`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`, args);
2754
+ }
2755
+ };
2756
+ var TinaParseDocumentError = class extends TinaFetchError {
2757
+ constructor(args) {
2758
+ super(`Error Parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`, args);
2759
+ }
2760
+ toString() {
2761
+ return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
2762
+ }
2763
+ };
2764
+ var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
2765
+ var handleFetchErrorError = (e, verbose) => {
2766
+ if (e instanceof Error) {
2767
+ if (e instanceof TinaFetchError) {
2768
+ if (verbose) {
2769
+ console.log(e.toString());
2770
+ console.log(e);
2771
+ console.log(e.stack);
2772
+ }
2773
+ }
2774
+ } else {
2775
+ console.error(e);
2776
+ }
2777
+ throw e;
2778
+ };
2779
+
2910
2780
  // src/resolver/index.ts
2911
2781
  var import_datalayer = __toModule(require("@tinacms/datalayer"));
2912
2782
 
@@ -4086,7 +3956,7 @@ var Database = class {
4086
3956
  } else if (last) {
4087
3957
  storeQueryOptions.limit = last;
4088
3958
  } else {
4089
- storeQueryOptions.limit = 10;
3959
+ storeQueryOptions.limit = 50;
4090
3960
  }
4091
3961
  if (after) {
4092
3962
  storeQueryOptions.gt = (0, import_datalayer2.atob)(after);
@@ -15,9 +15,10 @@ See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
 
17
17
  */
18
- import type { Content } from 'mdast';
19
- import type { GraphQLConfig, RichTypeInner } from '../types';
18
+ import type { RichTypeInner } from '@tinacms/schema-tools';
19
+ import type { GraphQLConfig } from '../types';
20
20
  import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
21
+ import type { Content } from 'mdast';
21
22
  export declare const parseMDX: (value: string, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => {
22
23
  type: string;
23
24
  children: any;
@@ -15,11 +15,11 @@ See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
 
17
17
  */
18
- import type { GraphQLConfig, RichTypeInner } from '../types';
18
+ import type { GraphQLConfig } from '../types';
19
19
  import type { TinaCloudSchemaEnriched } from '@tinacms/schema-tools';
20
20
  import { plateElements } from './parse';
21
21
  import type { Content } from 'mdast';
22
- export declare const stringifyMDX: (value: unknown, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
22
+ export declare const stringifyMDX: (value: unknown, field: any, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => string;
23
23
  export declare const stringify: (node: {
24
24
  type: typeof plateElements;
25
- }, field: RichTypeInner, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => Content;
25
+ }, field: any, graphQLconfig: GraphQLConfig, schema: TinaCloudSchemaEnriched) => Content;
package/dist/resolve.d.ts CHANGED
@@ -10,8 +10,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import type { Database } from './database';
14
13
  import type { GraphQLConfig } from './types';
14
+ import type { Database } from './database';
15
15
  export declare const resolve: ({ config, query, variables, database, silenceErrors, verbose, isAudit, }: {
16
16
  config?: GraphQLConfig;
17
17
  query: string;
@@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import { ReferenceTypeInner, TinaFieldInner } from '../types';
13
+ import type { ReferenceTypeInner, TinaFieldInner } from '@tinacms/schema-tools';
14
14
  import type { FilterCondition } from '@tinacms/datalayer';
15
15
  export declare type ReferenceResolver = (filter: Record<string, object>, fieldDefinition: ReferenceTypeInner) => Promise<{
16
16
  edges: {
@@ -39,6 +39,7 @@ export declare class Resolver {
39
39
  label?: string;
40
40
  name: string;
41
41
  path: string;
42
+ indexes?: import("@tinacms/schema-tools").TinaIndex[];
42
43
  format?: "json" | "md" | "markdown" | "mdx";
43
44
  ui?: {
44
45
  global?: boolean | {
@@ -86,6 +87,7 @@ export declare class Resolver {
86
87
  label?: string;
87
88
  name: string;
88
89
  path: string;
90
+ indexes?: import("@tinacms/schema-tools").TinaIndex[];
89
91
  format?: "json" | "md" | "markdown" | "mdx";
90
92
  ui?: {
91
93
  global?: 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
+ import { TinaSchema, TinaCloudSchemaBase } from '@tinacms/schema-tools';
14
+ export declare const createSchema: ({ schema, flags, }: {
15
+ schema: TinaCloudSchemaBase;
16
+ flags?: string[];
17
+ }) => Promise<TinaSchema>;
@@ -10,5 +10,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import type { TinaCloudSchemaBase } from '../types';
13
+ import { TinaCloudSchemaBase } from '@tinacms/schema-tools';
14
14
  export declare const validateSchema: (schema: TinaCloudSchemaBase) => Promise<TinaCloudSchemaBase>;
@@ -10,5 +10,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import type { TinaSchema } from '../schema';
13
+ import type { TinaSchema } from '@tinacms/schema-tools';
14
14
  export declare const buildSKD: (tinaSchema: TinaSchema) => string;
@@ -10,9 +10,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import { Database } from '../database';
14
13
  import type { Store } from '@tinacms/datalayer';
15
- import type { TinaCloudSchema } from '../types';
14
+ import type { TinaCloudSchema } from '@tinacms/schema-tools';
15
+ import { Database } from '../database';
16
16
  export declare const setup: (rootPath: string, schema: TinaCloudSchema<false>, store: Store) => Promise<{
17
17
  database: Database;
18
18
  }>;
package/dist/types.d.ts CHANGED
@@ -10,259 +10,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- export interface TinaCloudSchema<WithNamespace extends boolean> {
14
- templates?: GlobalTemplate<WithNamespace>[];
15
- collections: TinaCloudCollection<WithNamespace>[];
16
- }
17
- export declare type TinaCloudSchemaBase = TinaCloudSchema<false>;
18
- export declare type TinaCloudSchemaEnriched = TinaCloudSchema<true>;
19
- /**
20
- * As part of the build process, each node is given a `path: string[]` key
21
- * to help with namespacing type names, this is added as part of the
22
- * createTinaSchema step
23
- */
24
- export interface TinaCloudSchemaWithNamespace {
25
- templates?: GlobalTemplate<true>[];
26
- collections: TinaCloudCollection<true>[];
27
- namespace: string[];
28
- }
29
- export declare type TinaCloudCollection<WithNamespace extends boolean> = CollectionFields<WithNamespace> | CollectionTemplates<WithNamespace>;
30
- export declare type TinaCloudCollectionBase = TinaCloudCollection<false>;
31
- export declare type TinaCloudCollectionEnriched = TinaCloudCollection<true>;
32
- declare type FormatType = 'json' | 'md' | 'markdown' | 'mdx';
33
- interface BaseCollection {
34
- label?: string;
35
- name: string;
36
- path: string;
37
- format?: FormatType;
38
- match?: string;
39
- indexes?: TinaIndex[];
40
- }
41
- declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
42
- interface CollectionTemplatesInner<WithNamespace extends boolean> extends BaseCollection {
43
- templates: (string | Template<WithNamespace>)[];
44
- fields?: undefined;
45
- }
46
- export interface CollectionTemplatesWithNamespace<WithNamespace extends boolean> extends BaseCollection {
47
- templates: (string | Template<WithNamespace>)[];
48
- fields?: undefined;
49
- references?: ReferenceType<WithNamespace>[];
50
- namespace: WithNamespace extends true ? string[] : undefined;
51
- }
52
- declare type CollectionFields<WithNamespace extends boolean> = WithNamespace extends true ? CollectionFieldsWithNamespace<WithNamespace> : CollectionFieldsInner<WithNamespace>;
53
- export interface CollectionFieldsWithNamespace<WithNamespace extends boolean> extends BaseCollection {
54
- fields: string | TinaFieldInner<WithNamespace>[];
55
- templates?: undefined;
56
- references?: ReferenceType<WithNamespace>[];
57
- namespace: string[];
58
- }
59
- interface CollectionFieldsInner<WithNamespace extends boolean> extends BaseCollection {
60
- fields: string | TinaFieldInner<WithNamespace>[];
61
- templates?: undefined;
62
- }
63
- export declare type TinaFieldInner<WithNamespace extends boolean> = ScalarType<WithNamespace> | ObjectType<WithNamespace> | ReferenceType<WithNamespace> | RichType<WithNamespace>;
64
- export declare type TinaIndex = {
65
- name: string;
66
- fields: {
67
- name: string;
68
- }[];
69
- };
70
- export declare type TinaFieldBase = TinaFieldInner<false>;
71
- export declare type TinaFieldEnriched = TinaFieldInner<true>;
72
- interface TinaField {
73
- name: string;
74
- label?: string;
75
- description?: string;
76
- required?: boolean;
77
- list?: boolean;
78
- indexed?: boolean;
79
- /**
80
- * Any items passed to the UI field will be passed to the underlying field.
81
- * NOTE: only serializable values are supported, so functions like `validate`
82
- * will be ignored.
83
- */
84
- ui?: object;
85
- }
86
- declare type ScalarType<WithNamespace extends boolean> = WithNamespace extends true ? ScalarTypeWithNamespace : ScalarTypeInner;
87
- declare type Option = string | {
88
- label: string;
89
- value: string;
90
- };
91
- declare type ScalarTypeInner = TinaField & TinaScalarField & {
92
- options?: Option[];
93
- };
94
- declare type ScalarTypeWithNamespace = TinaField & TinaScalarField & {
95
- options?: Option[];
96
- namespace: string[];
97
- };
98
- declare type TinaScalarField = StringField | BooleanField | DateTimeField | NumberField | ImageField;
99
- declare type StringField = {
100
- type: 'string';
101
- isBody?: boolean;
102
- };
103
- declare type BooleanField = {
104
- type: 'boolean';
105
- };
106
- declare type NumberField = {
107
- type: 'number';
108
- };
109
- declare type DateTimeField = {
110
- type: 'datetime';
111
- dateFormat?: string;
112
- timeFormat?: string;
113
- };
114
- declare type ImageField = {
115
- type: 'image';
116
- };
117
- export declare type ReferenceType<WithNamespace extends boolean> = WithNamespace extends true ? ReferenceTypeWithNamespace : ReferenceTypeInner;
118
- export declare type RichType<WithNamespace extends boolean> = WithNamespace extends true ? RichTypeWithNamespace : RichTypeInner;
119
- export interface ReferenceTypeInner extends TinaField {
120
- type: 'reference';
121
- reverseLookup?: {
122
- label: string;
123
- name: string;
124
- };
125
- collections: string[];
126
- }
127
- export interface ReferenceTypeWithNamespace extends TinaField {
128
- type: 'reference';
129
- collections: string[];
130
- reverseLookup?: {
131
- label: string;
132
- name: string;
133
- };
134
- namespace: string[];
135
- }
136
- export interface RichTypeWithNamespace extends TinaField {
137
- type: 'rich-text';
138
- namespace: string[];
139
- isBody?: boolean;
140
- templates?: (string | (Template<true> & {
141
- inline?: boolean;
142
- }))[];
143
- }
144
- export interface RichTypeInner extends TinaField {
145
- type: 'rich-text';
146
- isBody?: boolean;
147
- templates?: (string | (Template<false> & {
148
- inline?: boolean;
149
- }))[];
150
- }
151
- export declare type ObjectType<WithNamespace extends boolean> = ObjectTemplates<WithNamespace> | ObjectFields<WithNamespace>;
152
- declare type ObjectTemplates<WithNamespace extends boolean> = WithNamespace extends true ? ObjectTemplatesWithNamespace<WithNamespace> : ObjectTemplatesInner<WithNamespace>;
153
- interface ObjectTemplatesInner<WithNamespace extends boolean> extends TinaField {
154
- type: 'object';
155
- required?: false;
156
- /**
157
- * templates can either be an array of Tina templates or a reference to
158
- * global template definition.
159
- *
160
- * You should use `templates` when your object can be any one of multiple shapes (polymorphic)
161
- *
162
- * You can only provide one of `fields` or `template`, but not both
163
- */
164
- templates: (string | Template<WithNamespace>)[];
165
- fields?: undefined;
166
- }
167
- interface ObjectTemplatesWithNamespace<WithNamespace extends boolean> extends TinaField {
168
- type: 'object';
169
- required?: false;
170
- /**
171
- * templates can either be an array of Tina templates or a reference to
172
- * global template definition.
173
- *
174
- * You should use `templates` when your object can be any one of multiple shapes (polymorphic)
175
- *
176
- * You can only provide one of `fields` or `template`, but not both
177
- */
178
- templates: (string | Template<WithNamespace>)[];
179
- fields?: undefined;
180
- namespace: WithNamespace extends true ? string[] : undefined;
181
- }
182
- declare type ObjectFields<WithNamespace extends boolean> = WithNamespace extends true ? InnerObjectFieldsWithNamespace<WithNamespace> : InnerObjectFields<WithNamespace>;
183
- interface InnerObjectFields<WithNamespace extends boolean> extends TinaField {
184
- type: 'object';
185
- required?: false;
186
- /**
187
- * fields can either be an array of Tina fields, or a reference to the fields
188
- * of a global template definition.
189
- *
190
- * You can only provide one of `fields` or `templates`, but not both.
191
- */
192
- fields: string | TinaFieldInner<WithNamespace>[];
193
- templates?: undefined;
194
- }
195
- interface InnerObjectFieldsWithNamespace<WithNamespace extends boolean> extends TinaField {
196
- type: 'object';
197
- required?: false;
198
- /**
199
- * fields can either be an array of Tina fields, or a reference to the fields
200
- * of a global template definition.
201
- *
202
- * You can only provide one of `fields` or `templates`, but not both.
203
- */
204
- fields: string | TinaFieldInner<WithNamespace>[];
205
- templates?: undefined;
206
- namespace: WithNamespace extends true ? string[] : undefined;
207
- }
208
- /**
209
- * Global Templates are defined once, and can be used anywhere by referencing the 'name' of the template
210
- *
211
- * TODO: ensure we don't permit infite loop with self-references
212
- */
213
- export declare type GlobalTemplate<WithNamespace extends boolean> = WithNamespace extends true ? {
214
- label: string;
215
- name: string;
216
- ui?: object;
217
- fields: TinaFieldInner<WithNamespace>[];
218
- namespace: WithNamespace extends true ? string[] : undefined;
219
- } : {
220
- label: string;
221
- name: string;
222
- ui?: object;
223
- fields: TinaFieldInner<WithNamespace>[];
224
- };
225
- export declare type TinaCloudTemplateBase = GlobalTemplate<false>;
226
- export declare type TinaCloudTemplateEnriched = GlobalTemplate<true>;
227
- /**
228
- * Templates allow you to define an object as polymorphic
229
- */
230
- export declare type Template<WithNamespace extends boolean> = WithNamespace extends true ? {
231
- label: string;
232
- name: string;
233
- fields: TinaFieldInner<WithNamespace>[];
234
- ui?: object;
235
- namespace: WithNamespace extends true ? string[] : undefined;
236
- } : {
237
- label: string;
238
- name: string;
239
- ui?: object;
240
- fields: TinaFieldInner<WithNamespace>[];
241
- };
242
- export declare type CollectionTemplateableUnion = {
243
- namespace: string[];
244
- type: 'union';
245
- templates: Templateable[];
246
- };
247
- export declare type CollectionTemplateableObject = {
248
- namespace: string[];
249
- type: 'object';
250
- required?: false;
251
- template: Templateable;
252
- };
253
- export declare type CollectionTemplateable = CollectionTemplateableUnion | CollectionTemplateableObject;
254
- export declare type Collectable = {
255
- namespace: string[];
256
- templates?: (string | Templateable)[];
257
- fields?: string | TinaFieldEnriched[];
258
- references?: ReferenceType<true>[];
259
- };
260
- export declare type Templateable = {
261
- name: string;
262
- namespace: string[];
263
- fields: TinaFieldEnriched[];
264
- ui?: object;
265
- };
266
13
  export declare type GraphQLConfig = {
267
14
  useRelativeMedia: true;
268
15
  } | {
@@ -270,4 +17,3 @@ export declare type GraphQLConfig = {
270
17
  clientId: string;
271
18
  assetsHost: string;
272
19
  };
273
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.63.9",
3
+ "version": "0.63.10",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
22
- "@tinacms/datalayer": "0.2.3",
23
- "@tinacms/schema-tools": "0.1.3",
24
- "@tinacms/mdx": "0.61.7",
22
+ "@tinacms/datalayer": "0.2.4",
23
+ "@tinacms/schema-tools": "0.1.4",
24
+ "@tinacms/mdx": "0.61.8",
25
25
  "body-parser": "^1.19.0",
26
26
  "cors": "^2.8.5",
27
27
  "dataloader": "^2.0.0",
@@ -71,8 +71,8 @@
71
71
  "directory": "packages/tina-graphql"
72
72
  },
73
73
  "devDependencies": {
74
- "@tinacms/datalayer": "0.2.3",
75
- "@tinacms/schema-tools": "0.1.3",
74
+ "@tinacms/datalayer": "0.2.4",
75
+ "@tinacms/schema-tools": "0.1.4",
76
76
  "@tinacms/scripts": "0.51.1",
77
77
  "@types/cors": "^2.8.7",
78
78
  "@types/estree": "^0.0.50",
@@ -1,78 +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 { CollectionTemplateable, Collectable, TinaCloudSchemaEnriched, TinaCloudSchemaBase, Templateable, TinaCloudCollection } from '../types';
14
- export declare const createSchema: ({ schema, flags, }: {
15
- schema: TinaCloudSchemaBase;
16
- flags?: string[];
17
- }) => Promise<TinaSchema>;
18
- declare type Version = {
19
- fullVersion: string;
20
- major: string;
21
- minor: string;
22
- patch: string;
23
- };
24
- /**
25
- * Metadata about how the schema was built
26
- */
27
- declare type Meta = {
28
- flags?: string[];
29
- };
30
- /**
31
- * TinaSchema is responsible for allowing you to look up certain
32
- * properties of the user-provided schema with ease.
33
- */
34
- export declare class TinaSchema {
35
- config: {
36
- version?: Version;
37
- meta?: Meta;
38
- } & TinaCloudSchemaBase;
39
- schema: TinaCloudSchemaEnriched;
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;
52
- fields: import("../types").TinaFieldInner<true>[];
53
- namespace: string[];
54
- };
55
- getCollectionByFullPath: (filepath: string) => TinaCloudCollection<true>;
56
- getCollectionAndTemplateByFullPath: (filepath: string, templateName?: string) => {
57
- collection: TinaCloudCollection<true>;
58
- template: Templateable;
59
- };
60
- getTemplateForData: ({ data, collection, }: {
61
- data?: unknown;
62
- collection: Collectable;
63
- }) => Promise<Templateable>;
64
- isMarkdownCollection: (collectionName: string) => boolean;
65
- /**
66
- * Gets the template or templates from the item.
67
- * Both `object` fields and collections support
68
- * the ability for an object to be polymorphic,
69
- * and if it is, we need to build unions, which
70
- * are more of a headache for non-polymorphic
71
- * needs, so we also need the ability to just
72
- * build object types
73
- *
74
- *
75
- */
76
- getTemplatesForCollectable: (collection: Collectable) => CollectionTemplateable;
77
- }
78
- export {};