@tinacms/graphql 0.0.0-2022229173235 → 0.0.0-20222301036
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/dist/database/index.d.ts +2 -2
- package/dist/index.js +14 -30
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20222301036
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
- e8b0de1f7: Add `parentTypename` to fields to allow us to disambiguate between fields which have the same field names but different types. Example, an event from field name of `blocks.0.title` could belong to a `Cta` block or a `Hero` block, both of which have a `title` field.
|
|
40
40
|
- Updated dependencies [a87e1e6fa]
|
|
41
|
-
- @tinacms/datalayer@0.0.0-
|
|
41
|
+
- @tinacms/datalayer@0.0.0-20222301036
|
|
42
42
|
|
|
43
43
|
## 0.59.8
|
|
44
44
|
|
package/dist/database/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ limitations under the License.
|
|
|
13
13
|
import type { BinaryFilter, IndexDefinition, Store, TernaryFilter } from '@tinacms/datalayer';
|
|
14
14
|
import type { DocumentNode } from 'graphql';
|
|
15
15
|
import type { TinaSchema } from '../schema';
|
|
16
|
-
import type { TinaCloudSchemaBase } from '../types';
|
|
16
|
+
import type { TinaCloudSchemaBase, CollectionFieldsWithNamespace, CollectionTemplatesWithNamespace } from '../types';
|
|
17
17
|
import type { Bridge } from './bridge';
|
|
18
18
|
declare type CreateDatabase = {
|
|
19
19
|
bridge: Bridge;
|
|
@@ -84,7 +84,7 @@ export declare class Database {
|
|
|
84
84
|
graphQLSchema: DocumentNode;
|
|
85
85
|
tinaSchema: TinaSchema;
|
|
86
86
|
}) => Promise<void>;
|
|
87
|
-
indexContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
87
|
+
indexContentByPaths: (documentPaths: string[], collection: CollectionFieldsWithNamespace<true> | CollectionTemplatesWithNamespace<true>) => Promise<void>;
|
|
88
88
|
_indexAllContent: () => Promise<void>;
|
|
89
89
|
addToLookupMap: (lookup: LookupMapType) => Promise<void>;
|
|
90
90
|
}
|
package/dist/index.js
CHANGED
|
@@ -23859,20 +23859,8 @@ var Database = class {
|
|
|
23859
23859
|
}
|
|
23860
23860
|
}
|
|
23861
23861
|
};
|
|
23862
|
-
this.indexContentByPaths = async (documentPaths) => {
|
|
23863
|
-
|
|
23864
|
-
const collections = {};
|
|
23865
|
-
const tinaSchema = await this.getSchema();
|
|
23866
|
-
for (const documentPath of documentPaths) {
|
|
23867
|
-
const collection = tinaSchema.schema.collections.find((collection2) => documentPath.startsWith(collection2.path));
|
|
23868
|
-
if (!pathsByCollection[collection.name]) {
|
|
23869
|
-
pathsByCollection[collection.name] = [];
|
|
23870
|
-
}
|
|
23871
|
-
pathsByCollection[collection.name].push(documentPath);
|
|
23872
|
-
}
|
|
23873
|
-
for (const collection of Object.keys(pathsByCollection)) {
|
|
23874
|
-
await _indexContent(this, pathsByCollection[collection], collections[collection]);
|
|
23875
|
-
}
|
|
23862
|
+
this.indexContentByPaths = async (documentPaths, collection) => {
|
|
23863
|
+
await _indexContent(this, documentPaths, collection);
|
|
23876
23864
|
};
|
|
23877
23865
|
this._indexAllContent = async () => {
|
|
23878
23866
|
const tinaSchema = await this.getSchema();
|
|
@@ -23902,27 +23890,23 @@ function hasOwnProperty2(obj, prop) {
|
|
|
23902
23890
|
return obj.hasOwnProperty(prop);
|
|
23903
23891
|
}
|
|
23904
23892
|
var _indexContent = async (database, documentPaths, collection) => {
|
|
23905
|
-
|
|
23906
|
-
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
if (numIndexes > 20) {
|
|
23914
|
-
throw new Error(`A maximum of 20 indexes are allowed per field. Currently collection ${collection.name} has ${numIndexes} indexes. Add 'indexed: false' to exclude a field from indexing.`);
|
|
23915
|
-
}
|
|
23916
|
-
seedOptions = {
|
|
23917
|
-
collection: collection.name,
|
|
23918
|
-
indexDefinitions: collectionIndexDefinitions
|
|
23919
|
-
};
|
|
23893
|
+
const indexDefinitions = await database.getIndexDefinitions();
|
|
23894
|
+
const collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23895
|
+
if (!collectionIndexDefinitions) {
|
|
23896
|
+
throw new Error(`No indexDefinitions for collection ${collection.name}`);
|
|
23897
|
+
}
|
|
23898
|
+
const numIndexes = Object.keys(collectionIndexDefinitions).length;
|
|
23899
|
+
if (numIndexes > 20) {
|
|
23900
|
+
throw new Error(`A maximum of 20 indexes are allowed per field. Currently collection ${collection.name} has ${numIndexes} indexes. Add 'indexed: false' to exclude a field from indexing.`);
|
|
23920
23901
|
}
|
|
23921
23902
|
await sequential(documentPaths, async (filepath) => {
|
|
23922
23903
|
const dataString = await database.bridge.get(filepath);
|
|
23923
23904
|
const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
|
|
23924
23905
|
if (database.store.supportsSeeding()) {
|
|
23925
|
-
await database.store.seed(filepath, data,
|
|
23906
|
+
await database.store.seed(filepath, data, {
|
|
23907
|
+
collection: collection.name,
|
|
23908
|
+
indexDefinitions: collectionIndexDefinitions
|
|
23909
|
+
});
|
|
23926
23910
|
}
|
|
23927
23911
|
});
|
|
23928
23912
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20222301036",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
49
|
-
"@tinacms/datalayer": "0.0.0-
|
|
49
|
+
"@tinacms/datalayer": "0.0.0-20222301036",
|
|
50
50
|
"body-parser": "^1.19.0",
|
|
51
51
|
"cors": "^2.8.5",
|
|
52
52
|
"dataloader": "^2.0.0",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"directory": "packages/tina-graphql"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@tinacms/datalayer": "0.0.0-
|
|
99
|
+
"@tinacms/datalayer": "0.0.0-20222301036",
|
|
100
100
|
"@tinacms/scripts": "0.50.7",
|
|
101
101
|
"@types/cors": "^2.8.7",
|
|
102
102
|
"@types/estree": "^0.0.50",
|