@tinacms/graphql 1.4.39 → 1.5.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/dist/index.mjs CHANGED
@@ -1,9 +1,6 @@
1
1
  // src/build.ts
2
- import _3 from "lodash";
3
2
  import { print } from "graphql";
4
-
5
- // src/ast-builder/index.ts
6
- import _ from "lodash";
3
+ import uniqBy2 from "lodash.uniqby";
7
4
 
8
5
  // src/util.ts
9
6
  import * as yup from "yup";
@@ -46,8 +43,20 @@ var btoa = (string2) => {
46
43
  var lastItem = (arr) => {
47
44
  return arr[arr.length - 1];
48
45
  };
46
+ var get = (obj, path7, defaultValue = void 0) => {
47
+ const travel = (regexp) => String.prototype.split.call(path7, regexp).filter(Boolean).reduce(
48
+ (res, key) => res !== null && res !== void 0 ? res[key] : res,
49
+ obj
50
+ );
51
+ const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
52
+ return result === void 0 || result === obj ? defaultValue : result;
53
+ };
54
+ var flattenDeep = (arr) => arr.flatMap(
55
+ (subArray, index) => Array.isArray(subArray) ? flattenDeep(subArray) : subArray
56
+ );
49
57
 
50
58
  // src/ast-builder/index.ts
59
+ import uniqBy from "lodash.uniqby";
51
60
  var SysFieldDefinition = {
52
61
  kind: "Field",
53
62
  name: {
@@ -933,7 +942,7 @@ var astBuilder = {
933
942
  };
934
943
  },
935
944
  toGraphQLAst: (ast) => {
936
- const definitions = _.uniqBy(
945
+ const definitions = uniqBy(
937
946
  [
938
947
  ...extractInlineTypes(ast.query),
939
948
  ...extractInlineTypes(ast.globalTemplates),
@@ -954,25 +963,24 @@ var capitalize = (s) => {
954
963
  };
955
964
  var extractInlineTypes = (item) => {
956
965
  if (Array.isArray(item)) {
957
- const accumulator = item.map((i) => {
966
+ const accumulator2 = item.map((i) => {
958
967
  return extractInlineTypes(i);
959
968
  });
960
- return _.flattenDeep(accumulator);
961
- } else {
962
- const accumulator = [item];
963
- for (const node of walk(item)) {
964
- if (node.kind === "UnionTypeDefinition") {
965
- node.types = _.uniqBy(node.types, (type) => type.name.value);
966
- }
967
- if (node.kind === "NamedType") {
968
- if (typeof node.name.value !== "string") {
969
- accumulator.push(node.name.value);
970
- node.name.value = node.name.value.name.value;
971
- }
969
+ return flattenDeep(accumulator2);
970
+ }
971
+ const accumulator = [item];
972
+ for (const node of walk(item)) {
973
+ if (node.kind === "UnionTypeDefinition") {
974
+ node.types = uniqBy(node.types, (type) => type.name.value);
975
+ }
976
+ if (node.kind === "NamedType") {
977
+ if (typeof node.name.value !== "string") {
978
+ accumulator.push(node.name.value);
979
+ node.name.value = node.name.value.name.value;
972
980
  }
973
981
  }
974
- return accumulator;
975
982
  }
983
+ return accumulator;
976
984
  };
977
985
  function* walk(maybeNode, visited = /* @__PURE__ */ new WeakSet()) {
978
986
  if (typeof maybeNode === "string") {
@@ -2653,7 +2661,7 @@ var filterSelections = (arr) => {
2653
2661
  import { TinaSchema } from "@tinacms/schema-tools";
2654
2662
 
2655
2663
  // src/schema/validate.ts
2656
- import _2 from "lodash";
2664
+ import deepClone from "lodash.clonedeep";
2657
2665
  import * as yup2 from "yup";
2658
2666
  import {
2659
2667
  validateTinaCloudSchemaConfig
@@ -2671,7 +2679,7 @@ var FIELD_TYPES = [
2671
2679
  ];
2672
2680
  var validateSchema = async (schema) => {
2673
2681
  const schema2 = addNamespaceToSchema(
2674
- _2.cloneDeep(schema)
2682
+ deepClone(schema)
2675
2683
  );
2676
2684
  const collections = await sequential(
2677
2685
  schema2.collections,
@@ -2776,7 +2784,7 @@ var validateCollection = async (collection) => {
2776
2784
  }
2777
2785
  if (validCollection.fields) {
2778
2786
  if (typeof validCollection.fields === "string") {
2779
- throw new Error(`Global templates are not yet supported`);
2787
+ throw new Error("Global templates are not yet supported");
2780
2788
  }
2781
2789
  fields = await sequential(validCollection.fields, async (field) => {
2782
2790
  return validateField(field);
@@ -2807,7 +2815,7 @@ var validateField = async (field) => {
2807
2815
  // package.json
2808
2816
  var package_default = {
2809
2817
  name: "@tinacms/graphql",
2810
- version: "1.4.39",
2818
+ version: "1.5.0",
2811
2819
  main: "dist/index.js",
2812
2820
  module: "dist/index.mjs",
2813
2821
  typings: "dist/index.d.ts",
@@ -2841,24 +2849,26 @@ var package_default = {
2841
2849
  "@iarna/toml": "^2.2.5",
2842
2850
  "@tinacms/mdx": "workspace:*",
2843
2851
  "@tinacms/schema-tools": "workspace:*",
2844
- "abstract-level": "^1.0.3",
2845
- "date-fns": "^2.21.1",
2846
- "fast-glob": "^3.2.5",
2847
- "fs-extra": "^9.0.1",
2852
+ "abstract-level": "^1.0.4",
2853
+ "date-fns": "^2.30.0",
2854
+ "fast-glob": "^3.3.2",
2855
+ "fs-extra": "^9.1.0",
2848
2856
  "glob-parent": "^6.0.2",
2849
2857
  graphql: "15.8.0",
2850
- "gray-matter": "^4.0.2",
2851
- "isomorphic-git": "^1.21.0",
2858
+ "gray-matter": "^4.0.3",
2859
+ "isomorphic-git": "^1.27.1",
2852
2860
  "js-sha1": "^0.6.0",
2853
2861
  "js-yaml": "^3.14.1",
2854
2862
  "jsonpath-plus": "^6.0.1",
2855
- lodash: "^4.17.20",
2863
+ "lodash.clonedeep": "^4.5.0",
2864
+ "lodash.set": "^4.3.2",
2865
+ "lodash.uniqby": "^4.7.0",
2856
2866
  "many-level": "^2.0.0",
2857
2867
  micromatch: "4.0.5",
2858
2868
  "normalize-path": "^3.0.0",
2859
- "readable-stream": "^4.3.0",
2869
+ "readable-stream": "^4.5.2",
2860
2870
  scmp: "^2.1.0",
2861
- yup: "^0.32.9"
2871
+ yup: "^0.32.11"
2862
2872
  },
2863
2873
  publishConfig: {
2864
2874
  registry: "https://registry.npmjs.org"
@@ -2870,29 +2880,28 @@ var package_default = {
2870
2880
  devDependencies: {
2871
2881
  "@tinacms/schema-tools": "workspace:*",
2872
2882
  "@tinacms/scripts": "workspace:*",
2873
- "@types/cors": "^2.8.7",
2883
+ "@types/cors": "^2.8.17",
2874
2884
  "@types/estree": "^0.0.50",
2875
- "@types/express": "^4.17.8",
2876
- "@types/fs-extra": "^9.0.2",
2877
- "@types/jest": "^26.0.4",
2878
- "@types/js-yaml": "^3.12.5",
2879
- "@types/lodash": "^4.14.161",
2880
- "@types/lodash.camelcase": "^4.3.6",
2881
- "@types/lodash.upperfirst": "^4.3.6",
2882
- "@types/lru-cache": "^5.1.0",
2883
- "@types/mdast": "^3.0.10",
2884
- "@types/micromatch": "^4.0.2",
2885
- "@types/node": "^14.17.34",
2886
- "@types/normalize-path": "^3.0.0",
2887
- "@types/ws": "^7.2.6",
2888
- "@types/yup": "^0.29.7",
2889
- jest: "^29.5.0",
2890
- "jest-diff": "^29.5.0",
2885
+ "@types/express": "^4.17.21",
2886
+ "@types/fs-extra": "^9.0.13",
2887
+ "@types/jest": "^26.0.24",
2888
+ "@types/js-yaml": "^3.12.10",
2889
+ "@types/lodash.camelcase": "^4.3.9",
2890
+ "@types/lodash.upperfirst": "^4.3.9",
2891
+ "@types/lru-cache": "^5.1.1",
2892
+ "@types/mdast": "^3.0.15",
2893
+ "@types/micromatch": "^4.0.9",
2894
+ "@types/node": "^14.18.63",
2895
+ "@types/normalize-path": "^3.0.2",
2896
+ "@types/ws": "^7.4.7",
2897
+ "@types/yup": "^0.29.14",
2898
+ jest: "^29.7.0",
2899
+ "jest-diff": "^29.7.0",
2891
2900
  "jest-file-snapshot": "^0.5.0",
2892
- "jest-matcher-utils": "^29.5.0",
2901
+ "jest-matcher-utils": "^29.7.0",
2893
2902
  "memory-level": "^1.0.0",
2894
2903
  nodemon: "2.0.19",
2895
- typescript: "4.6.4"
2904
+ typescript: "^5.5.4"
2896
2905
  }
2897
2906
  };
2898
2907
 
@@ -2962,7 +2971,7 @@ var _buildFragments = async (builder, tinaSchema) => {
2962
2971
  });
2963
2972
  const fragDoc = {
2964
2973
  kind: "Document",
2965
- definitions: _3.uniqBy(
2974
+ definitions: uniqBy2(
2966
2975
  extractInlineTypes(fragmentDefinitionsFields),
2967
2976
  (node) => node.name.value
2968
2977
  )
@@ -2993,7 +3002,7 @@ var _buildQueries = async (builder, tinaSchema) => {
2993
3002
  });
2994
3003
  const queryDoc = {
2995
3004
  kind: "Document",
2996
- definitions: _3.uniqBy(
3005
+ definitions: uniqBy2(
2997
3006
  extractInlineTypes(operationsDefinitions),
2998
3007
  (node) => node.name.value
2999
3008
  )
@@ -3081,7 +3090,7 @@ var _buildSchema = async (builder, tinaSchema) => {
3081
3090
  );
3082
3091
  return {
3083
3092
  kind: "Document",
3084
- definitions: _3.uniqBy(
3093
+ definitions: uniqBy2(
3085
3094
  extractInlineTypes(definitions),
3086
3095
  (node) => node.name.value
3087
3096
  )
@@ -5176,7 +5185,7 @@ var resolveDateInput = (value) => {
5176
5185
  };
5177
5186
 
5178
5187
  // src/resolve.ts
5179
- import _4 from "lodash";
5188
+ import set from "lodash.set";
5180
5189
 
5181
5190
  // src/error.ts
5182
5191
  import { GraphQLError as GraphQLError3 } from "graphql";
@@ -5202,7 +5211,7 @@ var resolve = async ({
5202
5211
  const verboseValue = verbose ?? true;
5203
5212
  const graphQLSchemaAst = await database.getGraphQLSchema();
5204
5213
  if (!graphQLSchemaAst) {
5205
- throw new GraphQLError4(`GraphQL schema not found`);
5214
+ throw new GraphQLError4("GraphQL schema not found");
5206
5215
  }
5207
5216
  const graphQLSchema = buildASTSchema(graphQLSchemaAst);
5208
5217
  const tinaConfig = await database.getTinaSchema();
@@ -5230,9 +5239,8 @@ var resolve = async ({
5230
5239
  const lookup = await database.getLookup(namedType);
5231
5240
  if (lookup.resolveType === "unionData") {
5232
5241
  return lookup.typeMap[source._template];
5233
- } else {
5234
- throw new Error(`Unable to find lookup key for ${namedType}`);
5235
5242
  }
5243
+ throw new Error(`Unable to find lookup key for ${namedType}`);
5236
5244
  },
5237
5245
  fieldResolver: async (source = {}, _args = {}, _context, info) => {
5238
5246
  try {
@@ -5289,7 +5297,7 @@ var resolve = async ({
5289
5297
  const sub = args.sub || ctxUser?.sub;
5290
5298
  const collection = tinaSchema.getCollections().find((c) => c.isAuthCollection);
5291
5299
  if (!collection) {
5292
- throw new Error(`Auth collection not found`);
5300
+ throw new Error("Auth collection not found");
5293
5301
  }
5294
5302
  const userFields = mapUserFields(collection, ["_rawData"]);
5295
5303
  if (!userFields.length) {
@@ -5305,7 +5313,7 @@ var resolve = async ({
5305
5313
  const userField = userFields[0];
5306
5314
  const realPath = `${collection.path}/index.json`;
5307
5315
  const userDoc = await resolver.getDocument(realPath);
5308
- const users = _4.get(userDoc, userField.path);
5316
+ const users = get(userDoc, userField.path);
5309
5317
  if (!users) {
5310
5318
  throw new Error("No users found");
5311
5319
  }
@@ -5318,7 +5326,7 @@ var resolve = async ({
5318
5326
  return null;
5319
5327
  }
5320
5328
  if (info.fieldName === "authenticate") {
5321
- const saltedHash = _4.get(user, [passwordFieldName || "", "value"]);
5329
+ const saltedHash = get(user, [passwordFieldName || "", "value"]);
5322
5330
  if (!saltedHash) {
5323
5331
  throw new Error("No password field found on user field");
5324
5332
  }
@@ -5328,12 +5336,10 @@ var resolve = async ({
5328
5336
  });
5329
5337
  if (matches) {
5330
5338
  return user;
5331
- } else {
5332
- return null;
5333
5339
  }
5334
- } else {
5335
- return user;
5340
+ return null;
5336
5341
  }
5342
+ return user;
5337
5343
  }
5338
5344
  if (info.fieldName === "updatePassword") {
5339
5345
  if (!ctxUser?.sub) {
@@ -5344,7 +5350,7 @@ var resolve = async ({
5344
5350
  }
5345
5351
  const collection = tinaSchema.getCollections().find((c) => c.isAuthCollection);
5346
5352
  if (!collection) {
5347
- throw new Error(`Auth collection not found`);
5353
+ throw new Error("Auth collection not found");
5348
5354
  }
5349
5355
  const userFields = mapUserFields(collection, ["_rawData"]);
5350
5356
  if (!userFields.length) {
@@ -5360,7 +5366,7 @@ var resolve = async ({
5360
5366
  const userField = userFields[0];
5361
5367
  const realPath = `${collection.path}/index.json`;
5362
5368
  const userDoc = await resolver.getDocument(realPath);
5363
- const users = _4.get(userDoc, userField.path);
5369
+ const users = get(userDoc, userField.path);
5364
5370
  if (!users) {
5365
5371
  throw new Error("No users found");
5366
5372
  }
@@ -5374,21 +5380,20 @@ var resolve = async ({
5374
5380
  passwordChangeRequired: false
5375
5381
  };
5376
5382
  const params = {};
5377
- _4.set(
5383
+ set(
5378
5384
  params,
5379
5385
  userField.path.slice(1),
5380
5386
  users.map((u) => {
5381
5387
  if (user[idFieldName] === u[idFieldName]) {
5382
5388
  return user;
5383
- } else {
5384
- return {
5385
- ...u,
5386
- [passwordFieldName]: {
5387
- ...u[passwordFieldName],
5388
- value: ""
5389
- }
5390
- };
5391
5389
  }
5390
+ return {
5391
+ ...u,
5392
+ [passwordFieldName]: {
5393
+ ...u[passwordFieldName],
5394
+ value: ""
5395
+ }
5396
+ };
5392
5397
  })
5393
5398
  );
5394
5399
  await resolver.updateResolveDocument({
@@ -5415,7 +5420,7 @@ var resolve = async ({
5415
5420
  if (typeof value === "string" && value !== "") {
5416
5421
  return resolver.getDocument(value);
5417
5422
  }
5418
- if (args && args.collection && info.fieldName === "addPendingDocument") {
5423
+ if (args?.collection && info.fieldName === "addPendingDocument") {
5419
5424
  return resolver.resolveDocument({
5420
5425
  args: { ...args, params: {} },
5421
5426
  collection: args.collection,
@@ -5431,7 +5436,7 @@ var resolve = async ({
5431
5436
  "deleteDocument",
5432
5437
  "createFolder"
5433
5438
  ].includes(info.fieldName)) {
5434
- const result2 = await resolver.resolveDocument({
5439
+ const result = await resolver.resolveDocument({
5435
5440
  args,
5436
5441
  collection: args.collection,
5437
5442
  isMutation,
@@ -5442,7 +5447,7 @@ var resolve = async ({
5442
5447
  isAddPendingDocument: false,
5443
5448
  isCollectionSpecific: false
5444
5449
  });
5445
- return result2;
5450
+ return result;
5446
5451
  }
5447
5452
  return value;
5448
5453
  case "multiCollectionDocumentList":
@@ -5453,7 +5458,8 @@ var resolve = async ({
5453
5458
  return { node: document };
5454
5459
  })
5455
5460
  };
5456
- } else if (info.fieldName === "documents" && value?.collection && value?.hasDocuments) {
5461
+ }
5462
+ if (info.fieldName === "documents" && value?.collection && value?.hasDocuments) {
5457
5463
  let filter = args.filter;
5458
5464
  if (typeof args?.filter !== "undefined" && args?.filter !== null && typeof value?.collection?.name === "string" && Object.keys(args.filter).includes(value?.collection?.name) && typeof args.filter[value?.collection?.name] !== "undefined") {
5459
5465
  filter = args.filter[value.collection.name];
@@ -5465,12 +5471,11 @@ var resolve = async ({
5465
5471
  },
5466
5472
  collection: value.collection
5467
5473
  });
5468
- } else {
5469
- throw new Error(
5470
- `Expected an array for result of ${info.fieldName} at ${info.path}`
5471
- );
5472
5474
  }
5473
- case "collectionDocument":
5475
+ throw new Error(
5476
+ `Expected an array for result of ${info.fieldName} at ${info.path}`
5477
+ );
5478
+ case "collectionDocument": {
5474
5479
  if (value) {
5475
5480
  return value;
5476
5481
  }
@@ -5483,6 +5488,7 @@ var resolve = async ({
5483
5488
  isCollectionSpecific: true
5484
5489
  });
5485
5490
  return result;
5491
+ }
5486
5492
  case "collectionDocumentList":
5487
5493
  return resolver.resolveCollectionConnection({
5488
5494
  args,
@@ -5491,7 +5497,7 @@ var resolve = async ({
5491
5497
  case "unionData":
5492
5498
  if (!value) {
5493
5499
  if (args.relativePath) {
5494
- const result2 = await resolver.resolveDocument({
5500
+ const result = await resolver.resolveDocument({
5495
5501
  args,
5496
5502
  collection: lookup.collection,
5497
5503
  isMutation,
@@ -5499,13 +5505,13 @@ var resolve = async ({
5499
5505
  isAddPendingDocument: false,
5500
5506
  isCollectionSpecific: true
5501
5507
  });
5502
- return result2;
5508
+ return result;
5503
5509
  }
5504
5510
  }
5505
5511
  return value;
5506
5512
  default:
5507
5513
  console.error(lookup);
5508
- throw new Error(`Unexpected resolve type`);
5514
+ throw new Error("Unexpected resolve type");
5509
5515
  }
5510
5516
  } catch (e) {
5511
5517
  handleFetchErrorError(e, verboseValue);
@@ -5536,9 +5542,8 @@ var resolve = async ({
5536
5542
  return {
5537
5543
  errors: [e]
5538
5544
  };
5539
- } else {
5540
- throw e;
5541
5545
  }
5546
+ throw e;
5542
5547
  }
5543
5548
  };
5544
5549
 
@@ -5568,7 +5573,7 @@ import path4 from "path";
5568
5573
  import { GraphQLError as GraphQLError5 } from "graphql";
5569
5574
  import micromatch2 from "micromatch";
5570
5575
  import sha2 from "js-sha1";
5571
- import _5 from "lodash";
5576
+ import set2 from "lodash.set";
5572
5577
  var createLocalDatabase = (config) => {
5573
5578
  const level = new TinaLevelClient(config?.port);
5574
5579
  level.openConnection();
@@ -5723,46 +5728,50 @@ var Database = class {
5723
5728
  }
5724
5729
  const folderTreeBuilder = new FolderTreeBuilder();
5725
5730
  const folderKey = folderTreeBuilder.update(filepath, collection.path || "");
5726
- const putOps = [
5727
- ...makeIndexOpsForDocument(
5728
- normalizedPath,
5729
- collection?.name,
5730
- collectionIndexDefinitions,
5731
- dataFields,
5732
- "put",
5733
- level
5734
- ),
5735
- ...makeIndexOpsForDocument(
5736
- normalizedPath,
5737
- `${collection?.name}_${folderKey}`,
5738
- collectionIndexDefinitions,
5739
- dataFields,
5740
- "put",
5741
- level
5742
- )
5743
- ];
5744
- const existingItem = await level.sublevel(
5745
- CONTENT_ROOT_PREFIX,
5746
- SUBLEVEL_OPTIONS
5747
- ).get(normalizedPath);
5748
- const delOps = existingItem ? [
5749
- ...makeIndexOpsForDocument(
5750
- normalizedPath,
5751
- collection?.name,
5752
- collectionIndexDefinitions,
5753
- existingItem,
5754
- "del",
5755
- level
5756
- ),
5757
- ...makeIndexOpsForDocument(
5758
- normalizedPath,
5759
- `${collection?.name}_${folderKey}`,
5760
- collectionIndexDefinitions,
5761
- existingItem,
5762
- "del",
5763
- level
5764
- )
5765
- ] : [];
5731
+ let putOps = [];
5732
+ let delOps = [];
5733
+ if (!isGitKeep(normalizedPath, collection)) {
5734
+ putOps = [
5735
+ ...makeIndexOpsForDocument(
5736
+ normalizedPath,
5737
+ collection?.name,
5738
+ collectionIndexDefinitions,
5739
+ dataFields,
5740
+ "put",
5741
+ level
5742
+ ),
5743
+ ...makeIndexOpsForDocument(
5744
+ normalizedPath,
5745
+ `${collection?.name}_${folderKey}`,
5746
+ collectionIndexDefinitions,
5747
+ dataFields,
5748
+ "put",
5749
+ level
5750
+ )
5751
+ ];
5752
+ const existingItem = await level.sublevel(
5753
+ CONTENT_ROOT_PREFIX,
5754
+ SUBLEVEL_OPTIONS
5755
+ ).get(normalizedPath);
5756
+ delOps = existingItem ? [
5757
+ ...makeIndexOpsForDocument(
5758
+ normalizedPath,
5759
+ collection?.name,
5760
+ collectionIndexDefinitions,
5761
+ existingItem,
5762
+ "del",
5763
+ level
5764
+ ),
5765
+ ...makeIndexOpsForDocument(
5766
+ normalizedPath,
5767
+ `${collection?.name}_${folderKey}`,
5768
+ collectionIndexDefinitions,
5769
+ existingItem,
5770
+ "del",
5771
+ level
5772
+ )
5773
+ ] : [];
5774
+ }
5766
5775
  const ops = [
5767
5776
  ...delOps,
5768
5777
  ...putOps,
@@ -5834,46 +5843,50 @@ var Database = class {
5834
5843
  collection.path || ""
5835
5844
  );
5836
5845
  const level = collection?.isDetached ? this.appLevel.sublevel(collection?.name, SUBLEVEL_OPTIONS) : this.contentLevel;
5837
- const putOps = [
5838
- ...makeIndexOpsForDocument(
5839
- normalizedPath,
5840
- collectionName,
5841
- collectionIndexDefinitions,
5842
- dataFields,
5843
- "put",
5844
- level
5845
- ),
5846
- ...makeIndexOpsForDocument(
5847
- normalizedPath,
5848
- `${collection?.name}_${folderKey}`,
5849
- collectionIndexDefinitions,
5850
- dataFields,
5851
- "put",
5852
- level
5853
- )
5854
- ];
5855
- const existingItem = await level.sublevel(
5856
- CONTENT_ROOT_PREFIX,
5857
- SUBLEVEL_OPTIONS
5858
- ).get(normalizedPath);
5859
- const delOps = existingItem ? [
5860
- ...makeIndexOpsForDocument(
5861
- normalizedPath,
5862
- collectionName,
5863
- collectionIndexDefinitions,
5864
- existingItem,
5865
- "del",
5866
- level
5867
- ),
5868
- ...makeIndexOpsForDocument(
5869
- normalizedPath,
5870
- `${collection?.name}_${folderKey}`,
5871
- collectionIndexDefinitions,
5872
- existingItem,
5873
- "del",
5874
- level
5875
- )
5876
- ] : [];
5846
+ let putOps = [];
5847
+ let delOps = [];
5848
+ if (!isGitKeep(normalizedPath, collection)) {
5849
+ putOps = [
5850
+ ...makeIndexOpsForDocument(
5851
+ normalizedPath,
5852
+ collectionName,
5853
+ collectionIndexDefinitions,
5854
+ dataFields,
5855
+ "put",
5856
+ level
5857
+ ),
5858
+ ...makeIndexOpsForDocument(
5859
+ normalizedPath,
5860
+ `${collection?.name}_${folderKey}`,
5861
+ collectionIndexDefinitions,
5862
+ dataFields,
5863
+ "put",
5864
+ level
5865
+ )
5866
+ ];
5867
+ const existingItem = await level.sublevel(
5868
+ CONTENT_ROOT_PREFIX,
5869
+ SUBLEVEL_OPTIONS
5870
+ ).get(normalizedPath);
5871
+ delOps = existingItem ? [
5872
+ ...makeIndexOpsForDocument(
5873
+ normalizedPath,
5874
+ collectionName,
5875
+ collectionIndexDefinitions,
5876
+ existingItem,
5877
+ "del",
5878
+ level
5879
+ ),
5880
+ ...makeIndexOpsForDocument(
5881
+ normalizedPath,
5882
+ `${collection?.name}_${folderKey}`,
5883
+ collectionIndexDefinitions,
5884
+ existingItem,
5885
+ "del",
5886
+ level
5887
+ )
5888
+ ] : [];
5889
+ }
5877
5890
  const ops = [
5878
5891
  ...delOps,
5879
5892
  ...putOps,
@@ -6194,9 +6207,8 @@ var Database = class {
6194
6207
  collection: collection.name,
6195
6208
  stack: error.stack
6196
6209
  });
6197
- } else {
6198
- throw error;
6199
6210
  }
6211
+ throw error;
6200
6212
  }
6201
6213
  }),
6202
6214
  pageInfo: {
@@ -6546,9 +6558,9 @@ var Database = class {
6546
6558
  };
6547
6559
  var hashPasswordVisitor = async (node, path7) => {
6548
6560
  const passwordValuePath = [...path7, "value"];
6549
- const plaintextPassword = _5.get(node, passwordValuePath);
6561
+ const plaintextPassword = get(node, passwordValuePath);
6550
6562
  if (plaintextPassword) {
6551
- _5.set(
6563
+ set2(
6552
6564
  node,
6553
6565
  passwordValuePath,
6554
6566
  await generatePasswordHash({ password: plaintextPassword })
@@ -6573,6 +6585,7 @@ var hashPasswordValues = async (data, passwordFields) => Promise.all(
6573
6585
  async (passwordField) => visitNodes(data, passwordField, hashPasswordVisitor)
6574
6586
  )
6575
6587
  );
6588
+ var isGitKeep = (filepath, collection) => filepath.endsWith(`.gitkeep.${collection?.format || "md"}`);
6576
6589
  var _indexContent = async (database, level, documentPaths, enqueueOps, collection, passwordFields) => {
6577
6590
  let collectionIndexDefinitions;
6578
6591
  let collectionPath;
@@ -6609,33 +6622,35 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
6609
6622
  normalizedPath,
6610
6623
  collectionPath || ""
6611
6624
  );
6612
- await enqueueOps([
6613
- ...makeIndexOpsForDocument(
6614
- normalizedPath,
6615
- collection?.name,
6616
- collectionIndexDefinitions,
6617
- aliasedData,
6618
- "put",
6619
- level
6620
- ),
6621
- ...makeIndexOpsForDocument(
6622
- normalizedPath,
6623
- `${collection?.name}_${folderKey}`,
6624
- collectionIndexDefinitions,
6625
- aliasedData,
6626
- "put",
6627
- level
6628
- ),
6629
- {
6630
- type: "put",
6631
- key: normalizedPath,
6632
- value: aliasedData,
6633
- sublevel: level.sublevel(
6634
- CONTENT_ROOT_PREFIX,
6635
- SUBLEVEL_OPTIONS
6636
- )
6637
- }
6638
- ]);
6625
+ if (!isGitKeep(filepath, collection)) {
6626
+ await enqueueOps([
6627
+ ...makeIndexOpsForDocument(
6628
+ normalizedPath,
6629
+ collection?.name,
6630
+ collectionIndexDefinitions,
6631
+ aliasedData,
6632
+ "put",
6633
+ level
6634
+ ),
6635
+ ...makeIndexOpsForDocument(
6636
+ normalizedPath,
6637
+ `${collection?.name}_${folderKey}`,
6638
+ collectionIndexDefinitions,
6639
+ aliasedData,
6640
+ "put",
6641
+ level
6642
+ ),
6643
+ {
6644
+ type: "put",
6645
+ key: normalizedPath,
6646
+ value: aliasedData,
6647
+ sublevel: level.sublevel(
6648
+ CONTENT_ROOT_PREFIX,
6649
+ SUBLEVEL_OPTIONS
6650
+ )
6651
+ }
6652
+ ]);
6653
+ }
6639
6654
  } catch (error) {
6640
6655
  throw new TinaFetchError(`Unable to seed ${filepath}`, {
6641
6656
  originalError: error,
@@ -7294,3 +7309,5 @@ export {
7294
7309
  transformDocument,
7295
7310
  transformDocumentIntoPayload
7296
7311
  };
7312
+ //! Replaces _.flattenDeep()
7313
+ //! Replaces _.get()