@tinacms/graphql 1.1.0 → 1.2.0

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 CHANGED
@@ -1,176 +1,37 @@
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
1
+ This license is based on the Fair Source License, version 0.9, with explanatory changes to the Use Limitation.
2
+
3
+ Copyright ©2023 Forestry.io Holdings Inc.
4
+ Licensor: Forestry.io Holdings Inc.
5
+ Software: Tina Data Layer
6
+ Use Limitation: 5 users, 2 roles, and 500 documents per website
7
+
8
+ License Grant.
9
+ Licensor hereby grants to each recipient of the Software (“you”) a non-exclusive, non-transferable, royalty-free
10
+ and fully-paid-up license, under all of the Licensor’s copyright and patent rights, to use, copy, distribute,
11
+ prepare derivative works of, publicly perform and display the Software, subject to the Use Limitation and the
12
+ conditions set forth below.
13
+
14
+ Use Limitation.
15
+ The license granted above allows use by up to the number of users, roles, and documents, per website set forth
16
+ above (the “Use Limitation”). You may only use one copy of the software per website. For determining the number of
17
+ users, roles, and documents, “you” includes all affiliates, meaning legal entities controlling, controlled by, or
18
+ under common control with you. If you exceed the Use Limitation, your use is subject to payment of Licensor’s
19
+ then-current list price for licenses.
20
+
21
+ Conditions.
22
+ Redistribution in source code or other forms must include a copy of this license document to be provided in a
23
+ reasonable manner. Any redistribution of the Software is only allowed subject to this license.
24
+
25
+ Trademarks.
26
+ This license does not grant you any right in the trademarks, service marks, brand names or logos of Licensor.
27
+
28
+ DISCLAIMER.
29
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OR CONDITION, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
30
+ TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. LICENSORS HEREBY DISCLAIM
31
+ ALL LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32
+ SOFTWARE.
33
+
34
+ Termination.
35
+ If you violate the terms of this license, your rights will terminate automatically and will not be
36
+ reinstated without the prior written consent of Licensor. Any such termination will not affect the right of others
37
+ who may have received copies of the Software from you.
@@ -1,14 +1,5 @@
1
1
  /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
2
+
12
3
  */
13
4
  import { FieldDefinitionNode, ScalarTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, NamedTypeNode, UnionTypeDefinitionNode, TypeDefinitionNode, DirectiveNode, EnumTypeDefinitionNode, InputObjectTypeDefinitionNode, DocumentNode, FragmentDefinitionNode, SelectionNode, FieldNode, InlineFragmentNode, OperationDefinitionNode } from 'graphql';
14
5
  /**
package/dist/build.d.ts CHANGED
@@ -1,14 +1,5 @@
1
1
  /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
2
+
12
3
  */
13
4
  import { DocumentNode } from 'graphql';
14
5
  import { TinaSchema } from '@tinacms/schema-tools';
@@ -1,14 +1,5 @@
1
1
  /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
2
+
12
3
  */
13
4
  import { Database } from '../database';
14
5
  import type { ObjectTypeDefinitionNode, InlineFragmentNode, FieldDefinitionNode } from 'graphql';
@@ -1,13 +1,4 @@
1
1
  /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
2
+
12
3
  */
13
4
  export declare const staticDefinitions: (import("graphql").ScalarTypeDefinitionNode | import("graphql").ObjectTypeDefinitionNode | import("graphql").InterfaceTypeDefinitionNode[])[];
@@ -0,0 +1,24 @@
1
+ import type { Bridge } from './index';
2
+ /**
3
+ * This is the bridge from whatever datasource we need for I/O.
4
+ * The basic example here is for the filesystem, one is needed
5
+ * for Github has well.
6
+ */
7
+ export declare class FilesystemBridge implements Bridge {
8
+ rootPath: string;
9
+ outputPath?: string;
10
+ constructor(rootPath: string);
11
+ addOutputPath(outputPath: string): void;
12
+ glob(pattern: string, extension: string): Promise<string[]>;
13
+ supportsBuilding(): boolean;
14
+ delete(filepath: string): Promise<void>;
15
+ get(filepath: string): Promise<string>;
16
+ putConfig(filepath: string, data: string): Promise<void>;
17
+ put(filepath: string, data: string, basePathOverride?: string): Promise<void>;
18
+ }
19
+ /**
20
+ * Same as the `FileSystemBridge` except it does not save files
21
+ */
22
+ export declare class AuditFileSystemBridge extends FilesystemBridge {
23
+ put(filepath: string, data: string): Promise<void>;
24
+ }
@@ -1,21 +1,9 @@
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
1
  export interface Bridge {
14
2
  rootPath: string;
15
3
  glob(pattern: string, extension: string): Promise<string[]>;
4
+ delete(filepath: string): Promise<void>;
16
5
  get(filepath: string): Promise<string>;
17
6
  put(filepath: string, data: string): Promise<void>;
18
- delete(filepath: string): Promise<void>;
19
7
  /**
20
8
  * Whether this bridge supports the ability to build the schema.
21
9
  */
@@ -0,0 +1,96 @@
1
+ import { CallbackFsClient, PromiseFsClient } from 'isomorphic-git';
2
+ import type { Bridge } from './index';
3
+ export declare type IsomorphicGitBridgeOptions = {
4
+ gitRoot: string;
5
+ fsModule?: CallbackFsClient | PromiseFsClient;
6
+ commitMessage?: string;
7
+ author: {
8
+ name: string;
9
+ email: string;
10
+ };
11
+ committer?: {
12
+ name: string;
13
+ email: string;
14
+ };
15
+ ref?: string;
16
+ onPut?: (filepath: string, data: string) => Promise<void>;
17
+ onDelete?: (filepath: string) => Promise<void>;
18
+ };
19
+ /**
20
+ * Bridge backed by isomorphic-git
21
+ */
22
+ export declare class IsomorphicBridge implements Bridge {
23
+ rootPath: string;
24
+ relativePath: string;
25
+ gitRoot: string;
26
+ fsModule: CallbackFsClient | PromiseFsClient;
27
+ isomorphicConfig: {
28
+ fs: CallbackFsClient | PromiseFsClient;
29
+ dir: string;
30
+ };
31
+ commitMessage: string;
32
+ author: {
33
+ name: string;
34
+ email: string;
35
+ };
36
+ committer: {
37
+ name: string;
38
+ email: string;
39
+ };
40
+ ref: string | undefined;
41
+ private readonly onPut;
42
+ private readonly onDelete;
43
+ private cache;
44
+ constructor(rootPath: string, { gitRoot, author, committer, fsModule, commitMessage, ref, onPut, onDelete, }: IsomorphicGitBridgeOptions);
45
+ private getAuthor;
46
+ private getCommitter;
47
+ /**
48
+ * Recursively populate paths matching `pattern` for the given `entry`
49
+ *
50
+ * @param pattern - pattern to filter paths by
51
+ * @param entry - TreeEntry to start building list from
52
+ * @param path - base path
53
+ * @param results
54
+ * @private
55
+ */
56
+ private listEntries;
57
+ /**
58
+ * For the specified path, returns an object with an array containing the parts of the path (pathParts)
59
+ * and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
60
+ * pathEntries are placeholders for non-existent entries.
61
+ *
62
+ * @param path - path being resolved
63
+ * @param ref - ref to resolve path entries for
64
+ * @private
65
+ */
66
+ private resolvePathEntries;
67
+ /**
68
+ * Updates tree entry and associated parent tree entries
69
+ *
70
+ * @param existingOid - the existing OID
71
+ * @param updatedOid - the updated OID
72
+ * @param path - the path of the entry being updated
73
+ * @param type - the type of the entry being updated (blob or tree)
74
+ * @param pathEntries - parent path entries
75
+ * @param pathParts - parent path parts
76
+ * @private
77
+ */
78
+ private updateTreeHierarchy;
79
+ /**
80
+ * Creates a commit for the specified tree and updates the specified ref to point to the commit
81
+ *
82
+ * @param treeSha - sha of the new tree
83
+ * @param ref - the ref that should be updated
84
+ * @private
85
+ */
86
+ private commitTree;
87
+ private getRef;
88
+ glob(pattern: string, extension: string): Promise<string[]>;
89
+ supportsBuilding(): boolean;
90
+ delete(filepath: string): Promise<void>;
91
+ private qualifyPath;
92
+ private unqualifyPath;
93
+ get(filepath: string): Promise<string>;
94
+ putConfig(filepath: string, data: string): Promise<void>;
95
+ put(filepath: string, data: string): Promise<void>;
96
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+
3
+ */
4
+ import { BatchOp, Level } from './level';
5
+ export declare enum OP {
6
+ EQ = "eq",
7
+ GT = "gt",
8
+ LT = "lt",
9
+ GTE = "gte",
10
+ LTE = "lte",
11
+ STARTS_WITH = "startsWith",
12
+ IN = "in"
13
+ }
14
+ export declare type BinaryFilter = {
15
+ pathExpression: string;
16
+ rightOperand: FilterOperand;
17
+ operator: OP.EQ | OP.GT | OP.LT | OP.GTE | OP.LTE | OP.STARTS_WITH | OP.IN;
18
+ type: string;
19
+ pad?: PadDefinition;
20
+ };
21
+ export declare type TernaryFilter = {
22
+ pathExpression: string;
23
+ leftOperand: FilterOperand;
24
+ rightOperand: FilterOperand;
25
+ leftOperator: OP.GTE | OP.GT;
26
+ rightOperator: OP.LT | OP.LTE;
27
+ type: string;
28
+ pad?: PadDefinition;
29
+ };
30
+ export declare type IndexDefinition = {
31
+ fields: {
32
+ name: string;
33
+ type?: string;
34
+ pad?: PadDefinition;
35
+ }[];
36
+ };
37
+ export declare type PadDefinition = {
38
+ fillString: string;
39
+ maxLength: number;
40
+ };
41
+ export declare type FilterOperand = string | number | boolean | string[] | number[];
42
+ export declare type FilterCondition = {
43
+ filterExpression: Record<string, FilterOperand>;
44
+ filterPath: string;
45
+ };
46
+ declare type StringEscaper = <T extends string | string[]>(input: T) => T;
47
+ export declare const DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
48
+ export declare const DEFAULT_NUMERIC_LPAD = 4;
49
+ export declare const coerceFilterChainOperands: (filterChain: (BinaryFilter | TernaryFilter)[], escapeString?: StringEscaper) => (BinaryFilter | TernaryFilter)[];
50
+ export declare const makeFilter: ({ filterChain, }: {
51
+ filterChain?: (BinaryFilter | TernaryFilter)[];
52
+ }) => (values: Record<string, object | FilterOperand>) => boolean;
53
+ export declare const makeFilterChain: ({ conditions, }: {
54
+ conditions: FilterCondition[];
55
+ }) => (BinaryFilter | TernaryFilter)[];
56
+ export declare const makeFilterSuffixes: (filterChain: (BinaryFilter | TernaryFilter)[], index: IndexDefinition) => {
57
+ left?: string;
58
+ right?: string;
59
+ } | undefined;
60
+ export declare const makeIndexOpsForDocument: <T extends object>(filepath: string, collection: string | undefined, indexDefinitions: IndexDefinition[], data: T, opType: 'put' | 'del', level: Level, escapeStr?: StringEscaper) => BatchOp[];
61
+ export declare const makeStringEscaper: (regex: RegExp, replacement: string) => StringEscaper;
62
+ export declare const stringEscaper: StringEscaper;
63
+ export {};
@@ -1,32 +1,28 @@
1
1
  /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
2
+
12
3
  */
13
- import type { BinaryFilter, IndexDefinition, Store, TernaryFilter } from '@tinacms/datalayer';
14
4
  import type { DocumentNode } from 'graphql';
15
- import type { TinaSchema } from '@tinacms/schema-tools';
16
- import type { TinaCloudSchemaBase } from '@tinacms/schema-tools';
17
- import type { Bridge } from './bridge';
5
+ import type { TinaCloudSchemaBase, TinaSchema } from '@tinacms/schema-tools';
6
+ import type { Bridge } from '../database/bridge';
7
+ import { BinaryFilter, IndexDefinition, TernaryFilter } from './datalayer';
8
+ import { Level } from './level';
18
9
  declare type IndexStatusEvent = {
19
10
  status: 'inprogress' | 'complete' | 'failed';
20
11
  error?: Error;
21
12
  };
22
13
  declare type IndexStatusCallback = (event: IndexStatusEvent) => Promise<void>;
23
- declare type CreateDatabase = {
24
- bridge: Bridge;
25
- store: Store;
14
+ export declare type OnPutCallback = (key: string, value: any) => Promise<void>;
15
+ export declare type OnDeleteCallback = (key: string) => Promise<void>;
16
+ export declare type CreateDatabase = {
17
+ bridge?: Bridge;
18
+ level: Level;
19
+ onPut?: (key: string, value: any) => Promise<void>;
20
+ onDelete?: (key: string) => Promise<void>;
26
21
  tinaDirectory?: string;
27
22
  indexStatusCallback?: IndexStatusCallback;
23
+ version?: boolean;
28
24
  };
29
- export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
25
+ export declare const createDatabase: (config: CreateDatabase) => Database;
30
26
  /** Options for {@link Database.query} **/
31
27
  export declare type QueryOptions = {
32
28
  fileExtension?: string;
@@ -40,10 +36,13 @@ export declare type QueryOptions = {
40
36
  };
41
37
  export declare class Database {
42
38
  config: CreateDatabase;
43
- bridge: Bridge;
44
- store: Store;
39
+ bridge?: Bridge;
40
+ rootLevel: Level;
41
+ level: Level | undefined;
45
42
  tinaDirectory: string;
46
43
  indexStatusCallback: IndexStatusCallback | undefined;
44
+ private onPut;
45
+ private onDelete;
47
46
  private tinaSchema;
48
47
  private collectionIndexDefinitions;
49
48
  private _lookup;
@@ -51,6 +50,9 @@ export declare class Database {
51
50
  private collectionForPath;
52
51
  private getGeneratedFolder;
53
52
  private partitionPathsByCollection;
53
+ private updateDatabaseVersion;
54
+ private getDatabaseVersion;
55
+ private initLevel;
54
56
  get: <T extends object>(filepath: string) => Promise<T>;
55
57
  addPendingDocument: (filepath: string, data: {
56
58
  [key: string]: unknown;
@@ -75,9 +77,9 @@ export declare class Database {
75
77
  getLookup: (returnType: string) => Promise<LookupMapType>;
76
78
  getGraphQLSchema: () => Promise<DocumentNode>;
77
79
  getGraphQLSchemaFromBridge: () => Promise<DocumentNode>;
78
- getTinaSchema: () => Promise<TinaCloudSchemaBase>;
79
- getSchema: () => Promise<TinaSchema>;
80
- getIndexDefinitions: () => Promise<Record<string, Record<string, IndexDefinition>>>;
80
+ getTinaSchema: (level?: Level) => Promise<TinaCloudSchemaBase>;
81
+ getSchema: (level?: Level) => Promise<TinaSchema>;
82
+ getIndexDefinitions: (level?: Level) => Promise<Record<string, Record<string, IndexDefinition>>>;
81
83
  documentExists: (fullpath: unknown) => Promise<boolean>;
82
84
  query: (queryOptions: QueryOptions, hydrator: any) => Promise<{
83
85
  edges: {
@@ -104,7 +106,7 @@ export declare class Database {
104
106
  deleteContentByPaths: (documentPaths: string[]) => Promise<void>;
105
107
  indexContentByPaths: (documentPaths: string[]) => Promise<void>;
106
108
  delete: (filepath: string) => Promise<void>;
107
- _indexAllContent: () => Promise<void>;
109
+ _indexAllContent: (level: Level) => Promise<void>;
108
110
  addToLookupMap: (lookup: LookupMapType) => Promise<void>;
109
111
  }
110
112
  export declare type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument;
@@ -0,0 +1,21 @@
1
+ /**
2
+
3
+ */
4
+ /// <reference types="node" />
5
+ import { AbstractLevel, AbstractSublevel, AbstractSublevelOptions } from 'abstract-level';
6
+ export declare type Level = AbstractLevel<Buffer | Uint8Array | string, string, Record<string, any>>;
7
+ export declare type PutOp = {
8
+ type: 'put';
9
+ key: string;
10
+ value: Record<string, any>;
11
+ sublevel?: AbstractSublevel<Level, Buffer | Uint8Array | string, string, Record<string, any>>;
12
+ };
13
+ export declare type DelOp = {
14
+ type: 'del';
15
+ key: string;
16
+ sublevel?: AbstractSublevel<Level, Buffer | Uint8Array | string, string, Record<string, Record<string, any>>>;
17
+ };
18
+ export declare type BatchOp = PutOp | DelOp;
19
+ export declare const INDEX_KEY_FIELD_SEPARATOR = "\u001D";
20
+ export declare const CONTENT_ROOT_PREFIX = "~";
21
+ export declare const SUBLEVEL_OPTIONS: AbstractSublevelOptions<string, Record<string, any>>;
@@ -1,14 +1,5 @@
1
1
  /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
2
+
12
3
  */
13
4
  import * as yup from 'yup';
14
5
  export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean, markdownParseConfig?: {
@@ -21,3 +12,5 @@ export declare const parseFile: <T extends object>(content: string, format: Form
21
12
  }) => T;
22
13
  export declare type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
23
14
  export declare const normalizePath: (filepath: string) => string;
15
+ export declare const atob: (b64Encoded: string) => string;
16
+ export declare const btoa: (string: string) => string;