@tinacms/graphql 0.0.0-2022229175036 → 0.0.0-20222301112

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # tina-graphql
2
2
 
3
- ## 0.0.0-2022229175036
3
+ ## 0.0.0-20222301112
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -38,7 +38,8 @@
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-2022229175036
41
+ - Updated dependencies [b01f2e382]
42
+ - @tinacms/datalayer@0.0.0-20222301112
42
43
 
43
44
  ## 0.59.8
44
45
 
@@ -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,27 +23859,8 @@ var Database = class {
23859
23859
  }
23860
23860
  }
23861
23861
  };
23862
- this.indexContentByPaths = async (documentPaths) => {
23863
- const pathsByCollection = {};
23864
- const nonCollectionPaths = [];
23865
- const collections = {};
23866
- const tinaSchema = await this.getSchema();
23867
- for (const documentPath of documentPaths) {
23868
- const collection = tinaSchema.schema.collections.find((collection2) => documentPath.startsWith(collection2.path));
23869
- if (collection) {
23870
- if (!pathsByCollection[collection.name]) {
23871
- pathsByCollection[collection.name] = [];
23872
- }
23873
- collections[collection.name] = collection;
23874
- pathsByCollection[collection.name].push(documentPath);
23875
- } else {
23876
- nonCollectionPaths.push(documentPath);
23877
- }
23878
- }
23879
- for (const collection of Object.keys(pathsByCollection)) {
23880
- await _indexContent(this, pathsByCollection[collection], collections[collection]);
23881
- }
23882
- await _indexContent(this, nonCollectionPaths);
23862
+ this.indexContentByPaths = async (documentPaths, collection) => {
23863
+ await _indexContent(this, documentPaths, collection);
23883
23864
  };
23884
23865
  this._indexAllContent = async () => {
23885
23866
  const tinaSchema = await this.getSchema();
@@ -23909,27 +23890,23 @@ function hasOwnProperty2(obj, prop) {
23909
23890
  return obj.hasOwnProperty(prop);
23910
23891
  }
23911
23892
  var _indexContent = async (database, documentPaths, collection) => {
23912
- let seedOptions = void 0;
23913
- if (collection) {
23914
- const indexDefinitions = await database.getIndexDefinitions();
23915
- const collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
23916
- if (!collectionIndexDefinitions) {
23917
- throw new Error(`No indexDefinitions for collection ${collection.name}`);
23918
- }
23919
- const numIndexes = Object.keys(collectionIndexDefinitions).length;
23920
- if (numIndexes > 20) {
23921
- 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.`);
23922
- }
23923
- seedOptions = {
23924
- collection: collection.name,
23925
- indexDefinitions: collectionIndexDefinitions
23926
- };
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.`);
23927
23901
  }
23928
23902
  await sequential(documentPaths, async (filepath) => {
23929
23903
  const dataString = await database.bridge.get(filepath);
23930
23904
  const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
23931
23905
  if (database.store.supportsSeeding()) {
23932
- await database.store.seed(filepath, data, seedOptions);
23906
+ await database.store.seed(filepath, data, {
23907
+ collection: collection.name,
23908
+ indexDefinitions: collectionIndexDefinitions
23909
+ });
23933
23910
  }
23934
23911
  });
23935
23912
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.0.0-2022229175036",
3
+ "version": "0.0.0-20222301112",
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-2022229175036",
49
+ "@tinacms/datalayer": "0.0.0-20222301112",
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-2022229175036",
99
+ "@tinacms/datalayer": "0.0.0-20222301112",
100
100
  "@tinacms/scripts": "0.50.7",
101
101
  "@types/cors": "^2.8.7",
102
102
  "@types/estree": "^0.0.50",