@tinacms/graphql 1.4.4 → 1.4.5

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.
@@ -1,6 +1,6 @@
1
1
  import type { DocumentNode } from 'graphql';
2
- import type { CollectionTemplateable, TinaCloudCollection, Schema, TinaSchema } from '@tinacms/schema-tools';
3
- import type { Bridge } from '../database/bridge';
2
+ import type { CollectionTemplateable, Schema, TinaCloudCollection, TinaSchema } from '@tinacms/schema-tools';
3
+ import type { Bridge } from './bridge';
4
4
  import { BinaryFilter, IndexDefinition, TernaryFilter } from './datalayer';
5
5
  import { Level } from './level';
6
6
  declare type IndexStatusEvent = {
package/dist/index.es.js CHANGED
@@ -2491,7 +2491,7 @@ var validateField = async (field) => {
2491
2491
  // package.json
2492
2492
  var package_default = {
2493
2493
  name: "@tinacms/graphql",
2494
- version: "1.4.4",
2494
+ version: "1.4.5",
2495
2495
  main: "dist/index.js",
2496
2496
  module: "dist/index.es.js",
2497
2497
  typings: "dist/index.d.ts",
@@ -5116,49 +5116,53 @@ var Database = class {
5116
5116
  throw new Error("No bridge configured");
5117
5117
  }
5118
5118
  await this.initLevel();
5119
- const result = await this.indexStatusCallbackWrapper(async () => {
5120
- const lookup = lookupFromLockFile || JSON.parse(
5121
- await this.bridge.get(
5122
- normalizePath(path2.join(this.getGeneratedFolder(), "_lookup.json"))
5123
- )
5124
- );
5125
- let nextLevel;
5126
- let nextVersion;
5127
- if (!this.config.version) {
5128
- await this.level.clear();
5129
- nextLevel = this.level;
5130
- } else {
5131
- const version = await this.getDatabaseVersion();
5132
- nextVersion = version ? `${parseInt(version) + 1}` : "0";
5133
- nextLevel = this.rootLevel.sublevel(nextVersion, SUBLEVEL_OPTIONS);
5134
- }
5135
- const contentRootLevel = nextLevel.sublevel(
5136
- CONTENT_ROOT_PREFIX,
5137
- SUBLEVEL_OPTIONS
5138
- );
5139
- await contentRootLevel.put(
5140
- normalizePath(path2.join(this.getGeneratedFolder(), "_graphql.json")),
5141
- graphQLSchema
5142
- );
5143
- await contentRootLevel.put(
5144
- normalizePath(path2.join(this.getGeneratedFolder(), "_schema.json")),
5145
- tinaSchema.schema
5146
- );
5147
- await contentRootLevel.put(
5148
- normalizePath(path2.join(this.getGeneratedFolder(), "_lookup.json")),
5149
- lookup
5150
- );
5151
- const result2 = await this._indexAllContent(nextLevel);
5152
- if (this.config.version) {
5153
- await this.updateDatabaseVersion(nextVersion);
5154
- if (this.level) {
5119
+ let nextLevel;
5120
+ return await this.indexStatusCallbackWrapper(
5121
+ async () => {
5122
+ const lookup = lookupFromLockFile || JSON.parse(
5123
+ await this.bridge.get(
5124
+ normalizePath(
5125
+ path2.join(this.getGeneratedFolder(), "_lookup.json")
5126
+ )
5127
+ )
5128
+ );
5129
+ let nextVersion;
5130
+ if (!this.config.version) {
5155
5131
  await this.level.clear();
5132
+ nextLevel = this.level;
5133
+ } else {
5134
+ const version = await this.getDatabaseVersion();
5135
+ nextVersion = version ? `${parseInt(version) + 1}` : "0";
5136
+ nextLevel = this.rootLevel.sublevel(nextVersion, SUBLEVEL_OPTIONS);
5137
+ }
5138
+ const contentRootLevel = nextLevel.sublevel(CONTENT_ROOT_PREFIX, SUBLEVEL_OPTIONS);
5139
+ await contentRootLevel.put(
5140
+ normalizePath(path2.join(this.getGeneratedFolder(), "_graphql.json")),
5141
+ graphQLSchema
5142
+ );
5143
+ await contentRootLevel.put(
5144
+ normalizePath(path2.join(this.getGeneratedFolder(), "_schema.json")),
5145
+ tinaSchema.schema
5146
+ );
5147
+ await contentRootLevel.put(
5148
+ normalizePath(path2.join(this.getGeneratedFolder(), "_lookup.json")),
5149
+ lookup
5150
+ );
5151
+ const result = await this._indexAllContent(nextLevel);
5152
+ if (this.config.version) {
5153
+ await this.updateDatabaseVersion(nextVersion);
5154
+ }
5155
+ return result;
5156
+ },
5157
+ async () => {
5158
+ if (this.config.version) {
5159
+ if (this.level) {
5160
+ await this.level.clear();
5161
+ }
5162
+ this.level = nextLevel;
5156
5163
  }
5157
- this.level = nextLevel;
5158
5164
  }
5159
- return result2;
5160
- });
5161
- return result;
5165
+ );
5162
5166
  };
5163
5167
  this.deleteContentByPaths = async (documentPaths) => {
5164
5168
  await this.initLevel();
@@ -5396,11 +5400,14 @@ This will be an error in the future. See https://tina.io/docs/errors/file-in-mut
5396
5400
  this.tinaSchema = null;
5397
5401
  this._lookup = null;
5398
5402
  }
5399
- async indexStatusCallbackWrapper(fn) {
5403
+ async indexStatusCallbackWrapper(fn, post) {
5400
5404
  await this.indexStatusCallback({ status: "inprogress" });
5401
5405
  try {
5402
5406
  const result = await fn();
5403
5407
  await this.indexStatusCallback({ status: "complete" });
5408
+ if (post) {
5409
+ await post();
5410
+ }
5404
5411
  return result;
5405
5412
  } catch (error) {
5406
5413
  await this.indexStatusCallback({ status: "failed", error });
package/dist/index.js CHANGED
@@ -2542,7 +2542,7 @@ var validateField = async (field) => {
2542
2542
  // package.json
2543
2543
  var package_default = {
2544
2544
  name: "@tinacms/graphql",
2545
- version: "1.4.4",
2545
+ version: "1.4.5",
2546
2546
  main: "dist/index.js",
2547
2547
  module: "dist/index.es.js",
2548
2548
  typings: "dist/index.d.ts",
@@ -5174,49 +5174,53 @@ var Database = class {
5174
5174
  throw new Error("No bridge configured");
5175
5175
  }
5176
5176
  await this.initLevel();
5177
- const result = await this.indexStatusCallbackWrapper(async () => {
5178
- const lookup = lookupFromLockFile || JSON.parse(
5179
- await this.bridge.get(
5180
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_lookup.json"))
5181
- )
5182
- );
5183
- let nextLevel;
5184
- let nextVersion;
5185
- if (!this.config.version) {
5186
- await this.level.clear();
5187
- nextLevel = this.level;
5188
- } else {
5189
- const version = await this.getDatabaseVersion();
5190
- nextVersion = version ? `${parseInt(version) + 1}` : "0";
5191
- nextLevel = this.rootLevel.sublevel(nextVersion, SUBLEVEL_OPTIONS);
5192
- }
5193
- const contentRootLevel = nextLevel.sublevel(
5194
- CONTENT_ROOT_PREFIX,
5195
- SUBLEVEL_OPTIONS
5196
- );
5197
- await contentRootLevel.put(
5198
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_graphql.json")),
5199
- graphQLSchema
5200
- );
5201
- await contentRootLevel.put(
5202
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_schema.json")),
5203
- tinaSchema.schema
5204
- );
5205
- await contentRootLevel.put(
5206
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_lookup.json")),
5207
- lookup
5208
- );
5209
- const result2 = await this._indexAllContent(nextLevel);
5210
- if (this.config.version) {
5211
- await this.updateDatabaseVersion(nextVersion);
5212
- if (this.level) {
5177
+ let nextLevel;
5178
+ return await this.indexStatusCallbackWrapper(
5179
+ async () => {
5180
+ const lookup = lookupFromLockFile || JSON.parse(
5181
+ await this.bridge.get(
5182
+ (0, import_schema_tools3.normalizePath)(
5183
+ import_path2.default.join(this.getGeneratedFolder(), "_lookup.json")
5184
+ )
5185
+ )
5186
+ );
5187
+ let nextVersion;
5188
+ if (!this.config.version) {
5213
5189
  await this.level.clear();
5190
+ nextLevel = this.level;
5191
+ } else {
5192
+ const version = await this.getDatabaseVersion();
5193
+ nextVersion = version ? `${parseInt(version) + 1}` : "0";
5194
+ nextLevel = this.rootLevel.sublevel(nextVersion, SUBLEVEL_OPTIONS);
5195
+ }
5196
+ const contentRootLevel = nextLevel.sublevel(CONTENT_ROOT_PREFIX, SUBLEVEL_OPTIONS);
5197
+ await contentRootLevel.put(
5198
+ (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_graphql.json")),
5199
+ graphQLSchema
5200
+ );
5201
+ await contentRootLevel.put(
5202
+ (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_schema.json")),
5203
+ tinaSchema.schema
5204
+ );
5205
+ await contentRootLevel.put(
5206
+ (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_lookup.json")),
5207
+ lookup
5208
+ );
5209
+ const result = await this._indexAllContent(nextLevel);
5210
+ if (this.config.version) {
5211
+ await this.updateDatabaseVersion(nextVersion);
5212
+ }
5213
+ return result;
5214
+ },
5215
+ async () => {
5216
+ if (this.config.version) {
5217
+ if (this.level) {
5218
+ await this.level.clear();
5219
+ }
5220
+ this.level = nextLevel;
5214
5221
  }
5215
- this.level = nextLevel;
5216
5222
  }
5217
- return result2;
5218
- });
5219
- return result;
5223
+ );
5220
5224
  };
5221
5225
  this.deleteContentByPaths = async (documentPaths) => {
5222
5226
  await this.initLevel();
@@ -5454,11 +5458,14 @@ This will be an error in the future. See https://tina.io/docs/errors/file-in-mut
5454
5458
  this.tinaSchema = null;
5455
5459
  this._lookup = null;
5456
5460
  }
5457
- async indexStatusCallbackWrapper(fn) {
5461
+ async indexStatusCallbackWrapper(fn, post) {
5458
5462
  await this.indexStatusCallback({ status: "inprogress" });
5459
5463
  try {
5460
5464
  const result = await fn();
5461
5465
  await this.indexStatusCallback({ status: "complete" });
5466
+ if (post) {
5467
+ await post();
5468
+ }
5462
5469
  return result;
5463
5470
  } catch (error) {
5464
5471
  await this.indexStatusCallback({ status: "failed", error });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "typings": "dist/index.d.ts",