@tinacms/graphql 0.0.0-202212201119 → 0.0.0-20221220191333

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -126,9 +126,11 @@ export declare const astBuilder: {
126
126
  queryName: string;
127
127
  fragName: string;
128
128
  }) => OperationDefinitionNode;
129
- ListQueryOperationDefinition: ({ queryName, fragName, }: {
129
+ ListQueryOperationDefinition: ({ queryName, fragName, filterType, dataLayer, }: {
130
130
  queryName: string;
131
131
  fragName: string;
132
+ filterType: string;
133
+ dataLayer: boolean;
132
134
  }) => OperationDefinitionNode;
133
135
  toGraphQLAst: (ast: {
134
136
  globalTemplates: TypeDefinitionNode[];
@@ -147,6 +149,10 @@ export declare const NAMER: {
147
149
  dataMutationTypeName: (namespace: string[]) => string;
148
150
  updateName: (namespace: string[]) => string;
149
151
  createName: (namespace: string[]) => string;
152
+ documentQueryName: () => string;
153
+ documentConnectionQueryName: () => string;
154
+ collectionQueryName: () => string;
155
+ collectionListQueryName: () => string;
150
156
  queryName: (namespace: string[]) => string;
151
157
  generateQueryListName: (namespace: string[]) => string;
152
158
  fragmentName: (namespace: string[]) => string;
package/dist/build.d.ts CHANGED
@@ -10,10 +10,15 @@ 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 { DocumentNode } from 'graphql';
14
+ import { TinaSchema } from '@tinacms/schema-tools';
14
15
  import { Database } from './database';
15
- export declare const indexDB: ({ database, config, buildSDK, }: {
16
+ export declare const buildDotTinaFiles: ({ database, config, flags, buildSDK, }: {
16
17
  database: Database;
17
18
  config: TinaSchema['config'];
19
+ flags?: string[];
18
20
  buildSDK?: boolean;
19
- }) => Promise<void>;
21
+ }) => Promise<{
22
+ graphQLSchema: DocumentNode;
23
+ tinaSchema: TinaSchema;
24
+ }>;
@@ -11,9 +11,9 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import { Database } from '../database';
14
- import type { ObjectTypeDefinitionNode, InlineFragmentNode } from 'graphql';
15
- import type { TinaCloudCollectionEnriched, Template } from '../types';
16
- import { TinaSchema } from '../schema';
14
+ import type { ObjectTypeDefinitionNode, InlineFragmentNode, FieldDefinitionNode } from 'graphql';
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;
@@ -28,6 +28,7 @@ export declare class Builder {
28
28
  database: Database;
29
29
  tinaSchema: TinaSchema;
30
30
  };
31
+ private maxDepth;
31
32
  tinaSchema: TinaSchema;
32
33
  database: Database;
33
34
  constructor(config: {
@@ -47,7 +48,7 @@ export declare class Builder {
47
48
  *
48
49
  * @param collections
49
50
  */
50
- buildCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
51
+ buildCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
51
52
  /**
52
53
  * ```graphql
53
54
  * # ex.
@@ -61,7 +62,7 @@ export declare class Builder {
61
62
  *
62
63
  * @param collections
63
64
  */
64
- buildMultiCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
65
+ buildMultiCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
65
66
  /**
66
67
  * ```graphql
67
68
  * # ex.
@@ -73,7 +74,7 @@ export declare class Builder {
73
74
  * }
74
75
  * ```
75
76
  */
76
- multiNodeDocument: () => Promise<import("graphql").FieldDefinitionNode>;
77
+ multiNodeDocument: () => Promise<FieldDefinitionNode>;
77
78
  /**
78
79
  * ```graphql
79
80
  * # ex.
@@ -87,15 +88,7 @@ export declare class Builder {
87
88
  *
88
89
  * @param collections
89
90
  */
90
- multiCollectionDocument: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
91
- /**
92
- * ```graphql
93
- * {
94
- * getDocumentFields()
95
- * }
96
- * ```
97
- */
98
- multiCollectionDocumentFields: () => Promise<import("graphql").FieldDefinitionNode>;
91
+ multiCollectionDocument: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
99
92
  /**
100
93
  * ```graphql
101
94
  * # ex.
@@ -109,7 +102,7 @@ export declare class Builder {
109
102
  *
110
103
  * @param collections
111
104
  */
112
- addMultiCollectionDocumentMutation: () => Promise<import("graphql").FieldDefinitionNode>;
105
+ addMultiCollectionDocumentMutation: () => Promise<FieldDefinitionNode>;
113
106
  /**
114
107
  * ```graphql
115
108
  * # ex.
@@ -123,7 +116,7 @@ export declare class Builder {
123
116
  *
124
117
  * @param collections
125
118
  */
126
- buildCreateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
119
+ buildCreateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
127
120
  /**
128
121
  * ```graphql
129
122
  * # ex.
@@ -137,24 +130,21 @@ export declare class Builder {
137
130
  *
138
131
  * @param collections
139
132
  */
140
- buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
133
+ buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
141
134
  /**
142
135
  * ```graphql
143
136
  * # ex.
144
137
  * {
145
- * getDocumentList(first: 10) {
146
- * edges {
147
- * node {
148
- * id
149
- * }
150
- * }
138
+ * deleteDocument(relativePath: $relativePath, params: $params) {
139
+ * id
140
+ * data {...}
151
141
  * }
152
142
  * }
153
143
  * ```
154
144
  *
155
145
  * @param collections
156
146
  */
157
- multiCollectionDocumentList: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
147
+ buildDeleteCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
158
148
  /**
159
149
  * ```graphql
160
150
  * # ex.
@@ -168,7 +158,7 @@ export declare class Builder {
168
158
  *
169
159
  * @param collection
170
160
  */
171
- collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
161
+ collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
172
162
  /**
173
163
  * Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
174
164
  * ```graphql
@@ -184,8 +174,23 @@ export declare class Builder {
184
174
  * @param collection a Tina Cloud collection
185
175
  */
186
176
  collectionFragment: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FragmentDefinitionNode>;
177
+ /**
178
+ * Given a collection this function returns its selections set. For example for Post this would return
179
+ *
180
+ * "
181
+ * body
182
+ * title
183
+ * ... on Author {
184
+ * name
185
+ * heroImg
186
+ * }
187
+ *
188
+ * But in the AST format
189
+ *
190
+ * */
191
+ private _getCollectionFragmentSelections;
187
192
  private _buildFieldNodeForFragments;
188
- buildTemplateFragments(template: Template<true>): Promise<InlineFragmentNode>;
193
+ buildTemplateFragments(template: Template<true>, depth: number): Promise<InlineFragmentNode | boolean>;
189
194
  /**
190
195
  * ```graphql
191
196
  * # ex.
@@ -199,7 +204,7 @@ export declare class Builder {
199
204
  *
200
205
  * @param collection
201
206
  */
202
- updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
207
+ updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
203
208
  /**
204
209
  * ```graphql
205
210
  * # ex.
@@ -213,7 +218,7 @@ export declare class Builder {
213
218
  *
214
219
  * @param collection
215
220
  */
216
- createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
221
+ createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
217
222
  /**
218
223
  * ```graphql
219
224
  * # ex.
@@ -230,7 +235,7 @@ export declare class Builder {
230
235
  *
231
236
  * @param collection
232
237
  */
233
- collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<import("graphql").FieldDefinitionNode>;
238
+ collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
234
239
  /**
235
240
  * GraphQL type definitions which remain unchanged regardless
236
241
  * of the supplied Tina schema. Ex. "node" interface
@@ -12,9 +12,10 @@ limitations under the License.
12
12
  */
13
13
  export interface Bridge {
14
14
  rootPath: string;
15
- glob(pattern: string): Promise<string[]>;
15
+ glob(pattern: string, extension: string): Promise<string[]>;
16
16
  get(filepath: string): Promise<string>;
17
17
  put(filepath: string, data: string): Promise<void>;
18
+ delete(filepath: string): Promise<void>;
18
19
  /**
19
20
  * Whether this bridge supports the ability to build the schema.
20
21
  */
@@ -0,0 +1,60 @@
1
+ import { BatchOp, Level } from './level';
2
+ export declare enum OP {
3
+ EQ = "eq",
4
+ GT = "gt",
5
+ LT = "lt",
6
+ GTE = "gte",
7
+ LTE = "lte",
8
+ STARTS_WITH = "startsWith",
9
+ IN = "in"
10
+ }
11
+ export declare type BinaryFilter = {
12
+ pathExpression: string;
13
+ rightOperand: FilterOperand;
14
+ operator: OP.EQ | OP.GT | OP.LT | OP.GTE | OP.LTE | OP.STARTS_WITH | OP.IN;
15
+ type: string;
16
+ pad?: PadDefinition;
17
+ };
18
+ export declare type TernaryFilter = {
19
+ pathExpression: string;
20
+ leftOperand: FilterOperand;
21
+ rightOperand: FilterOperand;
22
+ leftOperator: OP.GTE | OP.GT;
23
+ rightOperator: OP.LT | OP.LTE;
24
+ type: string;
25
+ pad?: PadDefinition;
26
+ };
27
+ export declare type IndexDefinition = {
28
+ fields: {
29
+ name: string;
30
+ type?: string;
31
+ pad?: PadDefinition;
32
+ }[];
33
+ };
34
+ export declare type PadDefinition = {
35
+ fillString: string;
36
+ maxLength: number;
37
+ };
38
+ export declare type FilterOperand = string | number | boolean | string[] | number[];
39
+ export declare type FilterCondition = {
40
+ filterExpression: Record<string, FilterOperand>;
41
+ filterPath: string;
42
+ };
43
+ declare type StringEscaper = <T extends string | string[]>(input: T) => T;
44
+ export declare const DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
45
+ export declare const DEFAULT_NUMERIC_LPAD = 4;
46
+ export declare const coerceFilterChainOperands: (filterChain: (BinaryFilter | TernaryFilter)[], escapeString?: StringEscaper) => (BinaryFilter | TernaryFilter)[];
47
+ export declare const makeFilter: ({ filterChain, }: {
48
+ filterChain?: (BinaryFilter | TernaryFilter)[];
49
+ }) => (values: Record<string, object | FilterOperand>) => boolean;
50
+ export declare const makeFilterChain: ({ conditions, }: {
51
+ conditions: FilterCondition[];
52
+ }) => (BinaryFilter | TernaryFilter)[];
53
+ export declare const makeFilterSuffixes: (filterChain: (BinaryFilter | TernaryFilter)[], index: IndexDefinition) => {
54
+ left?: string;
55
+ right?: string;
56
+ } | undefined;
57
+ export declare const makeIndexOpsForDocument: <T extends object>(filepath: string, collection: string | undefined, indexDefinitions: IndexDefinition[], data: T, opType: 'put' | 'del', level: Level, escapeStr?: StringEscaper) => BatchOp[];
58
+ export declare const makeStringEscaper: (regex: RegExp, replacement: string) => StringEscaper;
59
+ export declare const stringEscaper: StringEscaper;
60
+ export {};
@@ -11,31 +11,50 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import type { DocumentNode } from 'graphql';
14
- import type { TinaSchema } from '../schema';
15
- import type { TinaCloudSchemaBase } from '../types';
16
- import type { Store } from './store';
14
+ import type { TinaCloudSchemaBase, TinaSchema } from '@tinacms/schema-tools';
17
15
  import type { Bridge } from './bridge';
16
+ import { BinaryFilter, IndexDefinition, TernaryFilter } from './datalayer';
17
+ import { Level } from './level';
18
+ declare type IndexStatusEvent = {
19
+ status: 'inprogress' | 'complete' | 'failed';
20
+ error?: Error;
21
+ };
22
+ declare type IndexStatusCallback = (event: IndexStatusEvent) => Promise<void>;
18
23
  declare type CreateDatabase = {
19
24
  bridge: Bridge;
20
- store: Store;
25
+ level: Level;
26
+ indexStatusCallback?: IndexStatusCallback;
27
+ };
28
+ export declare const createDatabase: (config: CreateDatabase) => Database;
29
+ /** Options for {@link Database.query} **/
30
+ export declare type QueryOptions = {
31
+ fileExtension?: string;
32
+ collection: string;
33
+ filterChain?: (BinaryFilter | TernaryFilter)[];
34
+ sort?: string;
35
+ first?: number;
36
+ last?: number;
37
+ after?: string;
38
+ before?: string;
21
39
  };
22
- export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
23
40
  export declare class Database {
24
41
  config: CreateDatabase;
25
42
  bridge: Bridge;
26
- store: Store;
43
+ level: Level;
44
+ indexStatusCallback: IndexStatusCallback | undefined;
27
45
  private tinaSchema;
46
+ private collectionIndexDefinitions;
28
47
  private _lookup;
29
- private _graphql;
30
- private _tinaSchema;
31
48
  constructor(config: CreateDatabase);
49
+ private collectionForPath;
50
+ private partitionPathsByCollection;
32
51
  get: <T extends object>(filepath: string) => Promise<T>;
33
52
  addPendingDocument: (filepath: string, data: {
34
53
  [key: string]: unknown;
35
54
  }) => Promise<void>;
36
55
  put: (filepath: string, data: {
37
56
  [key: string]: unknown;
38
- }) => Promise<boolean>;
57
+ }, collection?: string) => Promise<boolean>;
39
58
  stringifyFile: (filepath: string, data: {
40
59
  [key: string]: unknown;
41
60
  }) => Promise<{
@@ -45,23 +64,42 @@ export declare class Database {
45
64
  };
46
65
  keepTemplateKey: boolean;
47
66
  }>;
67
+ /**
68
+ * Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
69
+ */
70
+ clearCache(): void;
48
71
  flush: (filepath: string) => Promise<string>;
49
72
  getLookup: (returnType: string) => Promise<LookupMapType>;
50
73
  getGraphQLSchema: () => Promise<DocumentNode>;
51
74
  getGraphQLSchemaFromBridge: () => Promise<DocumentNode>;
52
75
  getTinaSchema: () => Promise<TinaCloudSchemaBase>;
53
76
  getSchema: () => Promise<TinaSchema>;
77
+ getIndexDefinitions: () => Promise<Record<string, Record<string, IndexDefinition>>>;
54
78
  documentExists: (fullpath: unknown) => Promise<boolean>;
55
- query: (queryStrings: string[], hydrator: any) => Promise<object[]>;
79
+ query: (queryOptions: QueryOptions, hydrator: any) => Promise<{
80
+ edges: {
81
+ node: any;
82
+ cursor: string;
83
+ }[];
84
+ pageInfo: {
85
+ hasPreviousPage: boolean;
86
+ hasNextPage: boolean;
87
+ startCursor: string;
88
+ endCursor: string;
89
+ };
90
+ }>;
56
91
  putConfigFiles: ({ graphQLSchema, tinaSchema, }: {
57
92
  graphQLSchema: DocumentNode;
58
93
  tinaSchema: TinaSchema;
59
94
  }) => Promise<void>;
95
+ private indexStatusCallbackWrapper;
60
96
  indexContent: ({ graphQLSchema, tinaSchema, }: {
61
97
  graphQLSchema: DocumentNode;
62
98
  tinaSchema: TinaSchema;
63
99
  }) => Promise<void>;
100
+ deleteContentByPaths: (documentPaths: string[]) => Promise<void>;
64
101
  indexContentByPaths: (documentPaths: string[]) => Promise<void>;
102
+ delete: (filepath: string) => Promise<void>;
65
103
  _indexAllContent: () => Promise<void>;
66
104
  addToLookupMap: (lookup: LookupMapType) => Promise<void>;
67
105
  }
@@ -99,6 +137,7 @@ export declare type CollectionDocumentListLookup = {
99
137
  declare type UnionDataLookup = {
100
138
  type: string;
101
139
  resolveType: 'unionData';
140
+ collection?: string;
102
141
  typeMap: {
103
142
  [templateName: string]: string;
104
143
  };
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ import { AbstractLevel, AbstractSublevel, AbstractSublevelOptions } from 'abstract-level';
3
+ export declare type Level = AbstractLevel<Buffer | Uint8Array | string, string, Record<string, any>>;
4
+ export declare type PutOp = {
5
+ type: 'put';
6
+ key: string;
7
+ value: Record<string, any>;
8
+ sublevel?: AbstractSublevel<Level, Buffer | Uint8Array | string, string, Record<string, any>>;
9
+ };
10
+ export declare type DelOp = {
11
+ type: 'del';
12
+ key: string;
13
+ sublevel?: AbstractSublevel<Level, Buffer | Uint8Array | string, string, Record<string, Record<string, any>>>;
14
+ };
15
+ export declare type BatchOp = PutOp | DelOp;
16
+ export declare const INDEX_KEY_FIELD_SEPARATOR = "#";
17
+ export declare const ROOT_PREFIX = "~";
18
+ export declare const SUBLEVEL_OPTIONS: AbstractSublevelOptions<string, Record<string, any>>;
@@ -14,3 +14,6 @@ import * as yup from 'yup';
14
14
  export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean) => string;
15
15
  export declare const parseFile: <T extends object>(content: string, format: FormatType | string, yupSchema: (args: typeof yup) => yup.ObjectSchema<any>) => T;
16
16
  export declare type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
17
+ export declare const normalizePath: (filepath: string) => string;
18
+ export declare const atob: (b64Encoded: string) => string;
19
+ export declare const btoa: (string: string) => string;
package/dist/index.d.ts CHANGED
@@ -10,17 +10,25 @@ 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 { indexDB } from './build';
13
+ import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from '@tinacms/schema-tools';
14
+ import { buildDotTinaFiles } from './build';
14
15
  export { resolve } from './resolve';
16
+ export * from './resolver/error';
15
17
  export { createDatabase } from './database';
18
+ export type { QueryOptions } from './database';
16
19
  import type { Database } from './database';
17
20
  export type { Database } from './database';
18
- export type { Store } from './database/store';
19
21
  export type { Bridge } from './database/bridge';
20
22
  export { sequential, assertShape } from './util';
21
23
  export { stringifyFile, parseFile } from './database/util';
22
- export declare const buildSchema: (rootPath: string, database: Database) => Promise<import("graphql").GraphQLSchema>;
23
- import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from './types';
24
+ export { createSchema } from './schema/createSchema';
25
+ export { buildDotTinaFiles };
26
+ export declare type DummyType = unknown;
27
+ export declare const buildSchema: (rootPath: string, database: Database, flags?: string[]) => Promise<{
28
+ graphQLSchema: import("graphql").DocumentNode;
29
+ tinaSchema: import("@tinacms/schema-tools").TinaSchema;
30
+ }>;
31
+ export declare const getASTSchema: (database: Database) => Promise<import("graphql").GraphQLSchema>;
24
32
  export declare type TinaCloudSchema = TinaCloudSchemaBase<false>;
25
33
  export declare type TinaSchema = TinaCloudSchema;
26
34
  export declare type TinaCloudCollection = TinaCloudCollectionBase<false>;