@tinacms/graphql 1.4.6 → 1.4.8

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.js CHANGED
@@ -506,6 +506,7 @@ var astBuilder = {
506
506
  },
507
507
  MultiCollectionDocument: "DocumentNode",
508
508
  CollectionDocumentUnion: "DocumentUnion",
509
+ Folder: "Folder",
509
510
  String: "String",
510
511
  Reference: "Reference",
511
512
  Collection: "Collection",
@@ -1274,6 +1275,21 @@ var scalarDefinitions = [
1274
1275
  })
1275
1276
  ]
1276
1277
  }),
1278
+ astBuilder.ObjectTypeDefinition({
1279
+ name: astBuilder.TYPES.Folder,
1280
+ fields: [
1281
+ astBuilder.FieldDefinition({
1282
+ name: "name",
1283
+ required: true,
1284
+ type: astBuilder.TYPES.String
1285
+ }),
1286
+ astBuilder.FieldDefinition({
1287
+ name: "path",
1288
+ required: true,
1289
+ type: astBuilder.TYPES.String
1290
+ })
1291
+ ]
1292
+ }),
1277
1293
  astBuilder.ObjectTypeDefinition({
1278
1294
  name: "PageInfo",
1279
1295
  fields: [
@@ -1326,7 +1342,8 @@ var Builder = class {
1326
1342
  namespace: ["document"],
1327
1343
  nodeType: astBuilder.TYPES.MultiCollectionDocument,
1328
1344
  collections,
1329
- connectionNamespace: ["document"]
1345
+ connectionNamespace: ["document"],
1346
+ includeFolderFilter: true
1330
1347
  });
1331
1348
  const type = astBuilder.ObjectTypeDefinition({
1332
1349
  name: typeName,
@@ -1425,7 +1442,8 @@ var Builder = class {
1425
1442
  ];
1426
1443
  const type = await this._buildMultiCollectionDocumentDefinition({
1427
1444
  fieldName: astBuilder.TYPES.MultiCollectionDocument,
1428
- collections
1445
+ collections,
1446
+ includeFolderType: true
1429
1447
  });
1430
1448
  return astBuilder.FieldDefinition({
1431
1449
  name,
@@ -1856,7 +1874,8 @@ var Builder = class {
1856
1874
  };
1857
1875
  this._buildMultiCollectionDocumentDefinition = async ({
1858
1876
  fieldName,
1859
- collections
1877
+ collections,
1878
+ includeFolderType
1860
1879
  }) => {
1861
1880
  const types = [];
1862
1881
  collections.forEach((collection) => {
@@ -1866,14 +1885,14 @@ var Builder = class {
1866
1885
  }
1867
1886
  if (collection.templates) {
1868
1887
  collection.templates.forEach((template) => {
1869
- if (typeof template === "string") {
1870
- throw new Error("Global templates not yet supported");
1871
- }
1872
1888
  const typeName = NAMER.documentTypeName(template.namespace);
1873
1889
  types.push(typeName);
1874
1890
  });
1875
1891
  }
1876
1892
  });
1893
+ if (includeFolderType) {
1894
+ types.push(astBuilder.TYPES.Folder);
1895
+ }
1877
1896
  const type = astBuilder.UnionTypeDefinition({
1878
1897
  name: fieldName,
1879
1898
  types
@@ -1891,7 +1910,8 @@ var Builder = class {
1891
1910
  namespace,
1892
1911
  nodeType,
1893
1912
  collections,
1894
- connectionNamespace
1913
+ connectionNamespace,
1914
+ includeFolderFilter
1895
1915
  }) => {
1896
1916
  const connectionName = NAMER.referenceConnectionType(namespace);
1897
1917
  await this.database.addToLookupMap({
@@ -1904,7 +1924,8 @@ var Builder = class {
1904
1924
  namespace: connectionNamespace,
1905
1925
  connectionName,
1906
1926
  nodeType,
1907
- collections
1927
+ collections,
1928
+ includeFolderFilter
1908
1929
  });
1909
1930
  };
1910
1931
  this._buildFieldFilter = async (field) => {
@@ -2211,7 +2232,8 @@ var Builder = class {
2211
2232
  connectionName,
2212
2233
  nodeType,
2213
2234
  collection,
2214
- collections
2235
+ collections,
2236
+ includeFolderFilter
2215
2237
  }) => {
2216
2238
  const extra = [
2217
2239
  await this._connectionFilterBuilder({
@@ -2221,6 +2243,14 @@ var Builder = class {
2221
2243
  collections
2222
2244
  })
2223
2245
  ];
2246
+ if (includeFolderFilter) {
2247
+ extra.push(
2248
+ astBuilder.InputValueDefinition({
2249
+ name: "folder",
2250
+ type: astBuilder.TYPES.String
2251
+ })
2252
+ );
2253
+ }
2224
2254
  return astBuilder.FieldDefinition({
2225
2255
  name: fieldName,
2226
2256
  required: true,
@@ -2487,7 +2517,12 @@ var validateCollection = async (collection) => {
2487
2517
  name: yup2.string().matches(/^[a-zA-Z0-9_]*$/, {
2488
2518
  message: (obj) => `Collection's "name" must match ${obj.regex} at ${messageName}`
2489
2519
  }).required(),
2490
- path: yup2.string().required().transform((value) => {
2520
+ path: yup2.string().test("is-required", "path is a required field", (value) => {
2521
+ if (value === "") {
2522
+ return true;
2523
+ }
2524
+ return yup2.string().required().isValidSync(value);
2525
+ }).transform((value) => {
2491
2526
  return value.replace(/^\/|\/$/g, "");
2492
2527
  })
2493
2528
  });
@@ -2542,7 +2577,7 @@ var validateField = async (field) => {
2542
2577
  // package.json
2543
2578
  var package_default = {
2544
2579
  name: "@tinacms/graphql",
2545
- version: "1.4.6",
2580
+ version: "1.4.8",
2546
2581
  main: "dist/index.js",
2547
2582
  module: "dist/index.es.js",
2548
2583
  typings: "dist/index.d.ts",
@@ -2594,6 +2629,7 @@ var package_default = {
2594
2629
  "graphql-type-json": "^0.3.2",
2595
2630
  "gray-matter": "^4.0.2",
2596
2631
  "isomorphic-git": "^1.21.0",
2632
+ "js-sha1": "^0.6.0",
2597
2633
  "js-yaml": "^3.14.1",
2598
2634
  "jsonpath-plus": "^6.0.1",
2599
2635
  leveldown: "^6.1.0",
@@ -2857,7 +2893,7 @@ var _buildSchema = async (builder, tinaSchema) => {
2857
2893
  var import_graphql4 = require("graphql");
2858
2894
 
2859
2895
  // src/resolver/index.ts
2860
- var import_path = __toESM(require("path"));
2896
+ var import_path2 = __toESM(require("path"));
2861
2897
  var import_isValid = __toESM(require("date-fns/isValid"));
2862
2898
 
2863
2899
  // src/mdx/index.ts
@@ -3088,9 +3124,9 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
3088
3124
  return value;
3089
3125
  }
3090
3126
  };
3091
- var cleanUpSlashes = (path4) => {
3092
- if (path4) {
3093
- return `/${path4.replace(/^\/+|\/+$/gm, "")}`;
3127
+ var cleanUpSlashes = (path5) => {
3128
+ if (path5) {
3129
+ return `/${path5.replace(/^\/+|\/+$/gm, "")}`;
3094
3130
  }
3095
3131
  return "";
3096
3132
  };
@@ -3107,6 +3143,7 @@ var import_graphql3 = require("graphql");
3107
3143
 
3108
3144
  // src/database/datalayer.ts
3109
3145
  var import_jsonpath_plus = require("jsonpath-plus");
3146
+ var import_js_sha1 = __toESM(require("js-sha1"));
3110
3147
 
3111
3148
  // src/database/level.ts
3112
3149
  var INDEX_KEY_FIELD_SEPARATOR = "";
@@ -3154,6 +3191,7 @@ var LevelProxy = class {
3154
3191
  };
3155
3192
 
3156
3193
  // src/database/datalayer.ts
3194
+ var import_path = __toESM(require("path"));
3157
3195
  var DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
3158
3196
  var DEFAULT_NUMERIC_LPAD = 4;
3159
3197
  var applyPadding = (input, pad) => {
@@ -3520,6 +3558,106 @@ var makeFilterSuffixes = (filterChain, index) => {
3520
3558
  return {};
3521
3559
  }
3522
3560
  };
3561
+ var FOLDER_ROOT = "~";
3562
+ var stripCollectionFromPath = (collectionPath, path5) => {
3563
+ const collectionPathParts = collectionPath.split("/");
3564
+ const pathParts = path5.split("/");
3565
+ const strippedPathParts = pathParts.slice(collectionPathParts.length);
3566
+ return strippedPathParts.join("/");
3567
+ };
3568
+ var FolderTreeBuilder = class {
3569
+ constructor() {
3570
+ this._tree = {
3571
+ [FOLDER_ROOT]: /* @__PURE__ */ new Set()
3572
+ };
3573
+ }
3574
+ get tree() {
3575
+ return this._tree;
3576
+ }
3577
+ update(documentPath, collectionPath) {
3578
+ let folderPath = import_path.default.dirname(documentPath);
3579
+ if (collectionPath) {
3580
+ folderPath = stripCollectionFromPath(collectionPath, folderPath);
3581
+ }
3582
+ const parent = [FOLDER_ROOT];
3583
+ folderPath.split("/").filter((part) => part.length).forEach((part) => {
3584
+ const current2 = parent.join("/");
3585
+ if (!this._tree[current2]) {
3586
+ this._tree[current2] = /* @__PURE__ */ new Set();
3587
+ }
3588
+ this._tree[current2].add(import_path.default.join(current2, part));
3589
+ parent.push(part);
3590
+ });
3591
+ const current = parent.join("/");
3592
+ if (!this._tree[current]) {
3593
+ this._tree[current] = /* @__PURE__ */ new Set();
3594
+ }
3595
+ return current === FOLDER_ROOT ? FOLDER_ROOT : import_js_sha1.default.hex(current);
3596
+ }
3597
+ };
3598
+ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opType, level, escapeStr = stringEscaper) => {
3599
+ const result = [];
3600
+ const data = {};
3601
+ const indexedValues = {};
3602
+ for (const [sort, indexDefinition] of Object.entries(indexDefinitions)) {
3603
+ for (const field of indexDefinition.fields) {
3604
+ data[field.name] = "";
3605
+ }
3606
+ indexedValues[sort] = makeKeyForField(indexDefinition, data, escapeStr);
3607
+ }
3608
+ const baseCharacter = "a".charCodeAt(0);
3609
+ for (const [folderName, folder] of Object.entries(folderTree)) {
3610
+ const parentFolderKey = folderName === FOLDER_ROOT ? FOLDER_ROOT : import_js_sha1.default.hex(folderName);
3611
+ const folderCollectionSublevel = level.sublevel(
3612
+ `${collection.name}_${parentFolderKey}`,
3613
+ SUBLEVEL_OPTIONS
3614
+ );
3615
+ let folderSortingIdx = 0;
3616
+ for (const path5 of Array.from(folder).sort()) {
3617
+ for (const [sort] of Object.entries(indexDefinitions)) {
3618
+ const indexSublevel = folderCollectionSublevel.sublevel(
3619
+ sort,
3620
+ SUBLEVEL_OPTIONS
3621
+ );
3622
+ const subFolderKey = import_js_sha1.default.hex(path5);
3623
+ if (sort === DEFAULT_COLLECTION_SORT_KEY) {
3624
+ result.push({
3625
+ type: opType,
3626
+ key: `${collection.path}/${subFolderKey}.${collection.format}`,
3627
+ sublevel: indexSublevel,
3628
+ value: {}
3629
+ });
3630
+ } else {
3631
+ const indexValue = `${String.fromCharCode(
3632
+ baseCharacter + folderSortingIdx
3633
+ )}${indexedValues[sort].substring(1)}`;
3634
+ result.push({
3635
+ type: opType,
3636
+ key: `${indexValue}${INDEX_KEY_FIELD_SEPARATOR}${collection.path}/${subFolderKey}.${collection.format}`,
3637
+ sublevel: indexSublevel,
3638
+ value: {}
3639
+ });
3640
+ }
3641
+ }
3642
+ folderSortingIdx++;
3643
+ }
3644
+ if (folderName !== FOLDER_ROOT) {
3645
+ result.push({
3646
+ type: "put",
3647
+ key: `${collection.path}/${parentFolderKey}.${collection.format}`,
3648
+ value: {
3649
+ __folderBasename: import_path.default.basename(folderName),
3650
+ __folderPath: folderName
3651
+ },
3652
+ sublevel: level.sublevel(
3653
+ CONTENT_ROOT_PREFIX,
3654
+ SUBLEVEL_OPTIONS
3655
+ )
3656
+ });
3657
+ }
3658
+ }
3659
+ return result;
3660
+ };
3523
3661
  var makeIndexOpsForDocument = (filepath, collection, indexDefinitions, data, opType, level, escapeStr = stringEscaper) => {
3524
3662
  const result = [];
3525
3663
  if (collection) {
@@ -3584,11 +3722,37 @@ var Resolver = class {
3584
3722
  ...extraFields
3585
3723
  };
3586
3724
  };
3725
+ this.getRaw = async (fullPath) => {
3726
+ if (typeof fullPath !== "string") {
3727
+ throw new Error(`fullPath must be of type string for getDocument request`);
3728
+ }
3729
+ return this.database.get(fullPath);
3730
+ };
3731
+ this.getDocumentOrDirectory = async (fullPath) => {
3732
+ if (typeof fullPath !== "string") {
3733
+ throw new Error(
3734
+ `fullPath must be of type string for getDocumentOrDirectory request`
3735
+ );
3736
+ }
3737
+ const rawData = await this.getRaw(fullPath);
3738
+ if (rawData["__folderBasename"]) {
3739
+ return {
3740
+ __typename: "Folder",
3741
+ name: rawData["__folderBasename"],
3742
+ path: rawData["__folderPath"]
3743
+ };
3744
+ } else {
3745
+ return this.transformDocumentIntoPayload(fullPath, rawData);
3746
+ }
3747
+ };
3587
3748
  this.getDocument = async (fullPath) => {
3588
3749
  if (typeof fullPath !== "string") {
3589
3750
  throw new Error(`fullPath must be of type string for getDocument request`);
3590
3751
  }
3591
- const rawData = await this.database.get(fullPath);
3752
+ const rawData = await this.getRaw(fullPath);
3753
+ return this.transformDocumentIntoPayload(fullPath, rawData);
3754
+ };
3755
+ this.transformDocumentIntoPayload = async (fullPath, rawData) => {
3592
3756
  const collection = this.tinaSchema.getCollection(rawData._collection);
3593
3757
  try {
3594
3758
  const template = await this.tinaSchema.getTemplateForData({
@@ -3599,7 +3763,7 @@ var Resolver = class {
3599
3763
  base: basename,
3600
3764
  ext: extension,
3601
3765
  name: filename
3602
- } = import_path.default.parse(fullPath);
3766
+ } = import_path2.default.parse(fullPath);
3603
3767
  const relativePath = fullPath.replace(/\\/g, "/").replace(collection.path, "").replace(/^\/|\/$/g, "");
3604
3768
  const breadcrumbs = relativePath.replace(extension, "").split("/");
3605
3769
  const data = {
@@ -3631,7 +3795,7 @@ var Resolver = class {
3631
3795
  id: fullPath,
3632
3796
  ...data,
3633
3797
  _sys: {
3634
- title,
3798
+ title: title || "",
3635
3799
  basename,
3636
3800
  filename,
3637
3801
  extension,
@@ -3842,7 +4006,7 @@ var Resolver = class {
3842
4006
  (yup3) => yup3.object({ relativePath: yup3.string().required() })
3843
4007
  );
3844
4008
  const collection = await this.tinaSchema.getCollection(collectionLookup);
3845
- const realPath = import_path.default.join(collection == null ? void 0 : collection.path, args.relativePath);
4009
+ const realPath = import_path2.default.join(collection == null ? void 0 : collection.path, args.relativePath);
3846
4010
  const alreadyExists = await this.database.documentExists(realPath);
3847
4011
  if (isMutation) {
3848
4012
  if (isCreation) {
@@ -3883,7 +4047,7 @@ var Resolver = class {
3883
4047
  (yup3) => yup3.object({ relativePath: yup3.string().required() })
3884
4048
  );
3885
4049
  const doc = await this.getDocument(realPath);
3886
- const newRealPath = import_path.default.join(
4050
+ const newRealPath = import_path2.default.join(
3887
4051
  collection == null ? void 0 : collection.path,
3888
4052
  args.params.relativePath
3889
4053
  );
@@ -3938,7 +4102,7 @@ var Resolver = class {
3938
4102
  first: -1
3939
4103
  },
3940
4104
  collection: referencedCollection,
3941
- hydrator: (path4) => path4
4105
+ hydrator: (path5) => path5
3942
4106
  }
3943
4107
  );
3944
4108
  const { edges } = resolvedCollectionConnection;
@@ -3986,11 +4150,12 @@ var Resolver = class {
3986
4150
  first: args.first,
3987
4151
  last: args.last,
3988
4152
  before: args.before,
3989
- after: args.after
4153
+ after: args.after,
4154
+ folder: args.folder
3990
4155
  };
3991
4156
  const result = await this.database.query(
3992
4157
  queryOptions,
3993
- hydrator ? hydrator : this.getDocument
4158
+ hydrator ? hydrator : this.getDocumentOrDirectory
3994
4159
  );
3995
4160
  const edges = result.edges;
3996
4161
  const pageInfo = result.pageInfo;
@@ -4223,7 +4388,7 @@ var resolveDateInput = (value) => {
4223
4388
  if (!(0, import_isValid.default)(date)) {
4224
4389
  throw "Invalid Date";
4225
4390
  }
4226
- return date.toISOString();
4391
+ return date;
4227
4392
  };
4228
4393
 
4229
4394
  // src/resolve.ts
@@ -4472,7 +4637,7 @@ var resolve = async ({
4472
4637
  };
4473
4638
 
4474
4639
  // src/database/index.ts
4475
- var import_path2 = __toESM(require("path"));
4640
+ var import_path3 = __toESM(require("path"));
4476
4641
  var import_graphql5 = require("graphql");
4477
4642
  var import_micromatch = __toESM(require("micromatch"));
4478
4643
 
@@ -4488,6 +4653,7 @@ var matterEngines = {
4488
4653
  }
4489
4654
  };
4490
4655
  var stringifyFile = (content, format, keepTemplateKey, markdownParseConfig) => {
4656
+ var _a, _b;
4491
4657
  const {
4492
4658
  _relativePath,
4493
4659
  _keepTemplateKey,
@@ -4511,9 +4677,9 @@ var stringifyFile = (content, format, keepTemplateKey, markdownParseConfig) => {
4511
4677
  ${$_body}`,
4512
4678
  strippedContent,
4513
4679
  {
4514
- language: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) || "yaml",
4680
+ language: (_a = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) != null ? _a : "yaml",
4515
4681
  engines: matterEngines,
4516
- delimiters: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) || "---"
4682
+ delimiters: (_b = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) != null ? _b : "---"
4517
4683
  }
4518
4684
  );
4519
4685
  return ok;
@@ -4529,13 +4695,14 @@ ${$_body}`,
4529
4695
  }
4530
4696
  };
4531
4697
  var parseFile = (content, format, yupSchema, markdownParseConfig) => {
4698
+ var _a, _b;
4532
4699
  switch (format) {
4533
4700
  case ".markdown":
4534
4701
  case ".mdx":
4535
4702
  case ".md":
4536
4703
  const contentJSON = (0, import_gray_matter.default)(content || "", {
4537
- language: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) || "yaml",
4538
- delimiters: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) || "---",
4704
+ language: (_a = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) != null ? _a : "yaml",
4705
+ delimiters: (_b = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) != null ? _b : "---",
4539
4706
  engines: matterEngines
4540
4707
  });
4541
4708
  const markdownData = {
@@ -4680,6 +4847,7 @@ var _applyNameOverrides = (fields, obj) => {
4680
4847
  };
4681
4848
 
4682
4849
  // src/database/index.ts
4850
+ var import_js_sha12 = __toESM(require("js-sha1"));
4683
4851
  var createDatabase = (config) => {
4684
4852
  return new Database({
4685
4853
  ...config,
@@ -4698,14 +4866,14 @@ var Database = class {
4698
4866
  const tinaSchema = await this.getSchema(this.level);
4699
4867
  return tinaSchema.getCollectionByFullPath(filepath);
4700
4868
  };
4701
- this.getGeneratedFolder = () => import_path2.default.join(this.tinaDirectory, "__generated__");
4869
+ this.getGeneratedFolder = () => import_path3.default.join(this.tinaDirectory, "__generated__");
4702
4870
  this.get = async (filepath) => {
4703
4871
  await this.initLevel();
4704
4872
  if (SYSTEM_FILES.includes(filepath)) {
4705
4873
  throw new Error(`Unexpected get for config file ${filepath}`);
4706
4874
  } else {
4707
4875
  const tinaSchema = await this.getSchema(this.level);
4708
- const extension = import_path2.default.extname(filepath);
4876
+ const extension = import_path3.default.extname(filepath);
4709
4877
  const contentObject = await this.level.sublevel(
4710
4878
  CONTENT_ROOT_PREFIX,
4711
4879
  SUBLEVEL_OPTIONS
@@ -4760,26 +4928,48 @@ var Database = class {
4760
4928
  await this.bridge.put(normalizedPath, stringifiedFile);
4761
4929
  }
4762
4930
  await this.onPut(normalizedPath, stringifiedFile);
4763
- const putOps = makeIndexOpsForDocument(
4764
- normalizedPath,
4765
- collection == null ? void 0 : collection.name,
4766
- collectionIndexDefinitions,
4767
- dataFields,
4768
- "put",
4769
- this.level
4770
- );
4931
+ const folderTreeBuilder = new FolderTreeBuilder();
4932
+ const folderKey = folderTreeBuilder.update(filepath, collection.path || "");
4933
+ const putOps = [
4934
+ ...makeIndexOpsForDocument(
4935
+ normalizedPath,
4936
+ collection == null ? void 0 : collection.name,
4937
+ collectionIndexDefinitions,
4938
+ dataFields,
4939
+ "put",
4940
+ this.level
4941
+ ),
4942
+ ...makeIndexOpsForDocument(
4943
+ normalizedPath,
4944
+ `${collection == null ? void 0 : collection.name}_${folderKey}`,
4945
+ collectionIndexDefinitions,
4946
+ dataFields,
4947
+ "put",
4948
+ this.level
4949
+ )
4950
+ ];
4771
4951
  const existingItem = await this.level.sublevel(
4772
4952
  CONTENT_ROOT_PREFIX,
4773
4953
  SUBLEVEL_OPTIONS
4774
4954
  ).get(normalizedPath);
4775
- const delOps = existingItem ? makeIndexOpsForDocument(
4776
- normalizedPath,
4777
- collection == null ? void 0 : collection.name,
4778
- collectionIndexDefinitions,
4779
- existingItem,
4780
- "del",
4781
- this.level
4782
- ) : [];
4955
+ const delOps = existingItem ? [
4956
+ ...makeIndexOpsForDocument(
4957
+ normalizedPath,
4958
+ collection == null ? void 0 : collection.name,
4959
+ collectionIndexDefinitions,
4960
+ existingItem,
4961
+ "del",
4962
+ this.level
4963
+ ),
4964
+ ...makeIndexOpsForDocument(
4965
+ normalizedPath,
4966
+ `${collection == null ? void 0 : collection.name}_${folderKey}`,
4967
+ collectionIndexDefinitions,
4968
+ existingItem,
4969
+ "del",
4970
+ this.level
4971
+ )
4972
+ ] : [];
4783
4973
  const ops = [
4784
4974
  ...delOps,
4785
4975
  ...putOps,
@@ -4830,26 +5020,51 @@ var Database = class {
4830
5020
  await this.bridge.put(normalizedPath, stringifiedFile);
4831
5021
  }
4832
5022
  await this.onPut(normalizedPath, stringifiedFile);
4833
- const putOps = makeIndexOpsForDocument(
4834
- normalizedPath,
4835
- collectionName,
4836
- collectionIndexDefinitions,
4837
- dataFields,
4838
- "put",
4839
- this.level
5023
+ const folderTreeBuilder = new FolderTreeBuilder();
5024
+ const folderKey = folderTreeBuilder.update(
5025
+ filepath,
5026
+ collection.path || ""
4840
5027
  );
5028
+ const putOps = [
5029
+ ...makeIndexOpsForDocument(
5030
+ normalizedPath,
5031
+ collectionName,
5032
+ collectionIndexDefinitions,
5033
+ dataFields,
5034
+ "put",
5035
+ this.level
5036
+ ),
5037
+ ...makeIndexOpsForDocument(
5038
+ normalizedPath,
5039
+ `${collection == null ? void 0 : collection.name}_${folderKey}`,
5040
+ collectionIndexDefinitions,
5041
+ dataFields,
5042
+ "put",
5043
+ this.level
5044
+ )
5045
+ ];
4841
5046
  const existingItem = await this.level.sublevel(
4842
5047
  CONTENT_ROOT_PREFIX,
4843
5048
  SUBLEVEL_OPTIONS
4844
5049
  ).get(normalizedPath);
4845
- const delOps = existingItem ? makeIndexOpsForDocument(
4846
- normalizedPath,
4847
- collectionName,
4848
- collectionIndexDefinitions,
4849
- existingItem,
4850
- "del",
4851
- this.level
4852
- ) : [];
5050
+ const delOps = existingItem ? [
5051
+ ...makeIndexOpsForDocument(
5052
+ normalizedPath,
5053
+ collectionName,
5054
+ collectionIndexDefinitions,
5055
+ existingItem,
5056
+ "del",
5057
+ this.level
5058
+ ),
5059
+ ...makeIndexOpsForDocument(
5060
+ normalizedPath,
5061
+ `${collection == null ? void 0 : collection.name}_${folderKey}`,
5062
+ collectionIndexDefinitions,
5063
+ existingItem,
5064
+ "del",
5065
+ this.level
5066
+ )
5067
+ ] : [];
4853
5068
  const ops = [
4854
5069
  ...delOps,
4855
5070
  ...putOps,
@@ -4907,7 +5122,7 @@ var Database = class {
4907
5122
  );
4908
5123
  const writeTemplateKey = templateDetails.info.type === "union";
4909
5124
  const aliasedData = applyNameOverrides(templateDetails.template, payload);
4910
- const extension = import_path2.default.extname(filepath);
5125
+ const extension = import_path3.default.extname(filepath);
4911
5126
  const stringifiedFile = stringifyFile(
4912
5127
  aliasedData,
4913
5128
  extension,
@@ -4933,7 +5148,7 @@ var Database = class {
4933
5148
  this.getLookup = async (returnType) => {
4934
5149
  await this.initLevel();
4935
5150
  const lookupPath = (0, import_schema_tools3.normalizePath)(
4936
- import_path2.default.join(this.getGeneratedFolder(), `_lookup.json`)
5151
+ import_path3.default.join(this.getGeneratedFolder(), `_lookup.json`)
4937
5152
  );
4938
5153
  if (!this._lookup) {
4939
5154
  const _lookup = await this.level.sublevel(
@@ -4947,7 +5162,7 @@ var Database = class {
4947
5162
  this.getGraphQLSchema = async () => {
4948
5163
  await this.initLevel();
4949
5164
  const graphqlPath = (0, import_schema_tools3.normalizePath)(
4950
- import_path2.default.join(this.getGeneratedFolder(), `_graphql.json`)
5165
+ import_path3.default.join(this.getGeneratedFolder(), `_graphql.json`)
4951
5166
  );
4952
5167
  return await this.level.sublevel(
4953
5168
  CONTENT_ROOT_PREFIX,
@@ -4959,7 +5174,7 @@ var Database = class {
4959
5174
  throw new Error(`No bridge configured`);
4960
5175
  }
4961
5176
  const graphqlPath = (0, import_schema_tools3.normalizePath)(
4962
- import_path2.default.join(this.getGeneratedFolder(), `_graphql.json`)
5177
+ import_path3.default.join(this.getGeneratedFolder(), `_graphql.json`)
4963
5178
  );
4964
5179
  const _graphql = await this.bridge.get(graphqlPath);
4965
5180
  return JSON.parse(_graphql);
@@ -4967,19 +5182,26 @@ var Database = class {
4967
5182
  this.getTinaSchema = async (level) => {
4968
5183
  await this.initLevel();
4969
5184
  const schemaPath = (0, import_schema_tools3.normalizePath)(
4970
- import_path2.default.join(this.getGeneratedFolder(), `_schema.json`)
5185
+ import_path3.default.join(this.getGeneratedFolder(), `_schema.json`)
4971
5186
  );
4972
5187
  return await (level || this.level).sublevel(
4973
5188
  CONTENT_ROOT_PREFIX,
4974
5189
  SUBLEVEL_OPTIONS
4975
5190
  ).get(schemaPath);
4976
5191
  };
4977
- this.getSchema = async (level) => {
5192
+ this.getSchema = async (level, existingSchema) => {
4978
5193
  if (this.tinaSchema) {
4979
5194
  return this.tinaSchema;
4980
5195
  }
4981
5196
  await this.initLevel();
4982
- const schema = await this.getTinaSchema(level || this.level);
5197
+ const schema = existingSchema || await this.getTinaSchema(level || this.level);
5198
+ if (!schema) {
5199
+ throw new Error(
5200
+ `Unable to get schema from level db: ${(0, import_schema_tools3.normalizePath)(
5201
+ import_path3.default.join(this.getGeneratedFolder(), `_schema.json`)
5202
+ )}`
5203
+ );
5204
+ }
4983
5205
  this.tinaSchema = await createSchema({ schema });
4984
5206
  return this.tinaSchema;
4985
5207
  };
@@ -5054,7 +5276,8 @@ var Database = class {
5054
5276
  before,
5055
5277
  sort = DEFAULT_COLLECTION_SORT_KEY,
5056
5278
  collection,
5057
- filterChain: rawFilterChain
5279
+ filterChain: rawFilterChain,
5280
+ folder
5058
5281
  } = queryOptions;
5059
5282
  let limit = 50;
5060
5283
  if (first) {
@@ -5082,12 +5305,15 @@ var Database = class {
5082
5305
  CONTENT_ROOT_PREFIX,
5083
5306
  SUBLEVEL_OPTIONS
5084
5307
  );
5085
- const sublevel = indexDefinition ? this.level.sublevel(collection, SUBLEVEL_OPTIONS).sublevel(sort, SUBLEVEL_OPTIONS) : rootLevel;
5308
+ const sublevel = indexDefinition ? this.level.sublevel(
5309
+ `${collection}${folder ? `_${folder === FOLDER_ROOT ? folder : import_js_sha12.default.hex(folder)}` : ""}`,
5310
+ SUBLEVEL_OPTIONS
5311
+ ).sublevel(sort, SUBLEVEL_OPTIONS) : rootLevel;
5086
5312
  if (!query.gt && !query.gte) {
5087
5313
  query.gte = (filterSuffixes == null ? void 0 : filterSuffixes.left) ? filterSuffixes.left : "";
5088
5314
  }
5089
5315
  if (!query.lt && !query.lte) {
5090
- query.lte = (filterSuffixes == null ? void 0 : filterSuffixes.right) ? `${filterSuffixes.right}\xFF` : "\xFF";
5316
+ query.lte = (filterSuffixes == null ? void 0 : filterSuffixes.right) ? `${filterSuffixes.right}\uFFFF` : "\uFFFF";
5091
5317
  }
5092
5318
  let edges = [];
5093
5319
  let startKey = "";
@@ -5156,11 +5382,11 @@ var Database = class {
5156
5382
  }) => {
5157
5383
  if (this.bridge && this.bridge.supportsBuilding()) {
5158
5384
  await this.bridge.putConfig(
5159
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), `_graphql.json`)),
5385
+ (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), `_graphql.json`)),
5160
5386
  JSON.stringify(graphQLSchema)
5161
5387
  );
5162
5388
  await this.bridge.putConfig(
5163
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), `_schema.json`)),
5389
+ (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), `_schema.json`)),
5164
5390
  JSON.stringify(tinaSchema.schema)
5165
5391
  );
5166
5392
  }
@@ -5180,7 +5406,7 @@ var Database = class {
5180
5406
  const lookup = lookupFromLockFile || JSON.parse(
5181
5407
  await this.bridge.get(
5182
5408
  (0, import_schema_tools3.normalizePath)(
5183
- import_path2.default.join(this.getGeneratedFolder(), "_lookup.json")
5409
+ import_path3.default.join(this.getGeneratedFolder(), "_lookup.json")
5184
5410
  )
5185
5411
  )
5186
5412
  );
@@ -5195,18 +5421,21 @@ var Database = class {
5195
5421
  }
5196
5422
  const contentRootLevel = nextLevel.sublevel(CONTENT_ROOT_PREFIX, SUBLEVEL_OPTIONS);
5197
5423
  await contentRootLevel.put(
5198
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_graphql.json")),
5424
+ (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), "_graphql.json")),
5199
5425
  graphQLSchema
5200
5426
  );
5201
5427
  await contentRootLevel.put(
5202
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_schema.json")),
5428
+ (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), "_schema.json")),
5203
5429
  tinaSchema.schema
5204
5430
  );
5205
5431
  await contentRootLevel.put(
5206
- (0, import_schema_tools3.normalizePath)(import_path2.default.join(this.getGeneratedFolder(), "_lookup.json")),
5432
+ (0, import_schema_tools3.normalizePath)(import_path3.default.join(this.getGeneratedFolder(), "_lookup.json")),
5207
5433
  lookup
5208
5434
  );
5209
- const result = await this._indexAllContent(nextLevel);
5435
+ const result = await this._indexAllContent(
5436
+ nextLevel,
5437
+ tinaSchema.schema
5438
+ );
5210
5439
  if (this.config.version) {
5211
5440
  await this.updateDatabaseVersion(nextVersion);
5212
5441
  }
@@ -5241,7 +5470,9 @@ var Database = class {
5241
5470
  collections[collection]
5242
5471
  );
5243
5472
  }
5244
- await _deleteIndexContent(this, nonCollectionPaths, enqueueOps, null);
5473
+ if (nonCollectionPaths.length) {
5474
+ await _deleteIndexContent(this, nonCollectionPaths, enqueueOps, null);
5475
+ }
5245
5476
  });
5246
5477
  while (operations.length) {
5247
5478
  await this.level.batch(operations.splice(0, 25));
@@ -5292,6 +5523,11 @@ var Database = class {
5292
5523
  );
5293
5524
  const item = await rootSublevel.get(itemKey);
5294
5525
  if (item) {
5526
+ const folderTreeBuilder = new FolderTreeBuilder();
5527
+ const folderKey = folderTreeBuilder.update(
5528
+ filepath,
5529
+ collection.path || ""
5530
+ );
5295
5531
  await this.level.batch([
5296
5532
  ...makeIndexOpsForDocument(
5297
5533
  filepath,
@@ -5301,6 +5537,14 @@ var Database = class {
5301
5537
  "del",
5302
5538
  this.level
5303
5539
  ),
5540
+ ...makeIndexOpsForDocument(
5541
+ filepath,
5542
+ `${collection.name}_${folderKey}`,
5543
+ collectionIndexDefinitions,
5544
+ item,
5545
+ "del",
5546
+ this.level
5547
+ ),
5304
5548
  {
5305
5549
  type: "del",
5306
5550
  key: itemKey,
@@ -5313,9 +5557,9 @@ var Database = class {
5313
5557
  }
5314
5558
  await this.onDelete((0, import_schema_tools3.normalizePath)(filepath));
5315
5559
  };
5316
- this._indexAllContent = async (level) => {
5560
+ this._indexAllContent = async (level, schema) => {
5317
5561
  const warnings = [];
5318
- const tinaSchema = await this.getSchema(level);
5562
+ const tinaSchema = await this.getSchema(level, schema);
5319
5563
  const operations = [];
5320
5564
  const enqueueOps = async (ops) => {
5321
5565
  operations.push(...ops);
@@ -5332,17 +5576,17 @@ var Database = class {
5332
5576
  const documentPaths = await this.bridge.glob(normalPath, format);
5333
5577
  const matches = this.tinaSchema.getMatches({ collection });
5334
5578
  const filteredPaths = matches.length > 0 ? (0, import_micromatch.default)(documentPaths, matches) : documentPaths;
5335
- filteredPaths.forEach((path4) => {
5336
- if (filesSeen.has(path4)) {
5337
- filesSeen.get(path4).push(collection.name);
5338
- duplicateFiles.add(path4);
5579
+ filteredPaths.forEach((path5) => {
5580
+ if (filesSeen.has(path5)) {
5581
+ filesSeen.get(path5).push(collection.name);
5582
+ duplicateFiles.add(path5);
5339
5583
  } else {
5340
- filesSeen.set(path4, [collection.name]);
5584
+ filesSeen.set(path5, [collection.name]);
5341
5585
  }
5342
5586
  });
5343
- duplicateFiles.forEach((path4) => {
5587
+ duplicateFiles.forEach((path5) => {
5344
5588
  warnings.push(
5345
- `"${path4}" Found in multiple collections: ${filesSeen.get(path4).map((collection2) => `"${collection2}"`).join(
5589
+ `"${path5}" Found in multiple collections: ${filesSeen.get(path5).map((collection2) => `"${collection2}"`).join(
5346
5590
  ", "
5347
5591
  )}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
5348
5592
  This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
@@ -5360,7 +5604,7 @@ This will be an error in the future. See https://tina.io/docs/errors/file-in-mut
5360
5604
  if (!this.bridge) {
5361
5605
  throw new Error("No bridge configured");
5362
5606
  }
5363
- const lookupPath = import_path2.default.join(this.getGeneratedFolder(), `_lookup.json`);
5607
+ const lookupPath = import_path3.default.join(this.getGeneratedFolder(), `_lookup.json`);
5364
5608
  let lookupMap;
5365
5609
  try {
5366
5610
  lookupMap = JSON.parse(await this.bridge.get((0, import_schema_tools3.normalizePath)(lookupPath)));
@@ -5478,24 +5722,27 @@ function hasOwnProperty(obj, prop) {
5478
5722
  }
5479
5723
  var _indexContent = async (database, level, documentPaths, enqueueOps, collection) => {
5480
5724
  let collectionIndexDefinitions;
5725
+ let collectionPath;
5481
5726
  if (collection) {
5482
5727
  const indexDefinitions = await database.getIndexDefinitions(level);
5483
5728
  collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
5484
5729
  if (!collectionIndexDefinitions) {
5485
5730
  throw new Error(`No indexDefinitions for collection ${collection.name}`);
5486
5731
  }
5732
+ collectionPath = collection.path;
5487
5733
  }
5488
5734
  const tinaSchema = await database.getSchema();
5489
5735
  let templateInfo = null;
5490
5736
  if (collection) {
5491
5737
  templateInfo = await tinaSchema.getTemplatesForCollectable(collection);
5492
5738
  }
5739
+ const folderTreeBuilder = new FolderTreeBuilder();
5493
5740
  await sequential(documentPaths, async (filepath) => {
5494
5741
  try {
5495
5742
  const dataString = await database.bridge.get((0, import_schema_tools3.normalizePath)(filepath));
5496
5743
  const data = parseFile(
5497
5744
  dataString,
5498
- import_path2.default.extname(filepath),
5745
+ import_path3.default.extname(filepath),
5499
5746
  (yup3) => yup3.object({}),
5500
5747
  {
5501
5748
  frontmatterDelimiters: collection == null ? void 0 : collection.frontmatterDelimiters,
@@ -5510,6 +5757,10 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
5510
5757
  return;
5511
5758
  }
5512
5759
  const normalizedPath = (0, import_schema_tools3.normalizePath)(filepath);
5760
+ const folderKey = folderTreeBuilder.update(
5761
+ normalizedPath,
5762
+ collectionPath || ""
5763
+ );
5513
5764
  const aliasedData = templateInfo ? replaceNameOverrides(template, data) : data;
5514
5765
  await enqueueOps([
5515
5766
  ...makeIndexOpsForDocument(
@@ -5520,6 +5771,14 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
5520
5771
  "put",
5521
5772
  level
5522
5773
  ),
5774
+ ...makeIndexOpsForDocument(
5775
+ normalizedPath,
5776
+ `${collection == null ? void 0 : collection.name}_${folderKey}`,
5777
+ collectionIndexDefinitions,
5778
+ aliasedData,
5779
+ "put",
5780
+ level
5781
+ ),
5523
5782
  {
5524
5783
  type: "put",
5525
5784
  key: normalizedPath,
@@ -5539,8 +5798,22 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
5539
5798
  });
5540
5799
  }
5541
5800
  });
5801
+ if (collection) {
5802
+ await enqueueOps(
5803
+ makeFolderOpsForCollection(
5804
+ folderTreeBuilder.tree,
5805
+ collection,
5806
+ collectionIndexDefinitions,
5807
+ "put",
5808
+ level
5809
+ )
5810
+ );
5811
+ }
5542
5812
  };
5543
- var _deleteIndexContent = async (database, documentPaths, enequeueOps, collection) => {
5813
+ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection) => {
5814
+ if (!documentPaths.length) {
5815
+ return;
5816
+ }
5544
5817
  let collectionIndexDefinitions;
5545
5818
  if (collection) {
5546
5819
  const indexDefinitions = await database.getIndexDefinitions(database.level);
@@ -5549,20 +5822,42 @@ var _deleteIndexContent = async (database, documentPaths, enequeueOps, collectio
5549
5822
  throw new Error(`No indexDefinitions for collection ${collection.name}`);
5550
5823
  }
5551
5824
  }
5825
+ const tinaSchema = await database.getSchema();
5826
+ let templateInfo = null;
5827
+ if (collection) {
5828
+ templateInfo = await tinaSchema.getTemplatesForCollectable(collection);
5829
+ }
5552
5830
  const rootLevel = database.level.sublevel(
5553
5831
  CONTENT_ROOT_PREFIX,
5554
5832
  SUBLEVEL_OPTIONS
5555
5833
  );
5834
+ const folderTreeBuilder = new FolderTreeBuilder();
5556
5835
  await sequential(documentPaths, async (filepath) => {
5557
5836
  const itemKey = (0, import_schema_tools3.normalizePath)(filepath);
5558
5837
  const item = await rootLevel.get(itemKey);
5559
5838
  if (item) {
5560
- await enequeueOps([
5839
+ const folderKey = folderTreeBuilder.update(
5840
+ itemKey,
5841
+ (collection == null ? void 0 : collection.path) || ""
5842
+ );
5843
+ const aliasedData = templateInfo ? replaceNameOverrides(
5844
+ getTemplateForFile(templateInfo, item),
5845
+ item
5846
+ ) : item;
5847
+ await enqueueOps([
5561
5848
  ...makeIndexOpsForDocument(
5562
5849
  itemKey,
5563
5850
  collection.name,
5564
5851
  collectionIndexDefinitions,
5565
- item,
5852
+ aliasedData,
5853
+ "del",
5854
+ database.level
5855
+ ),
5856
+ ...makeIndexOpsForDocument(
5857
+ itemKey,
5858
+ `${collection == null ? void 0 : collection.name}_${folderKey}`,
5859
+ collectionIndexDefinitions,
5860
+ aliasedData,
5566
5861
  "del",
5567
5862
  database.level
5568
5863
  ),
@@ -5570,6 +5865,17 @@ var _deleteIndexContent = async (database, documentPaths, enequeueOps, collectio
5570
5865
  ]);
5571
5866
  }
5572
5867
  });
5868
+ if (collectionIndexDefinitions) {
5869
+ await enqueueOps(
5870
+ makeFolderOpsForCollection(
5871
+ folderTreeBuilder.tree,
5872
+ collection,
5873
+ collectionIndexDefinitions,
5874
+ "del",
5875
+ database.level
5876
+ )
5877
+ );
5878
+ }
5573
5879
  };
5574
5880
  var getTemplateForFile = (templateInfo, data) => {
5575
5881
  if (templateInfo.type === "object") {
@@ -5617,7 +5923,7 @@ var TinaLevelClient = class extends import_many_level.ManyLevelGuest {
5617
5923
  // src/database/bridge/filesystem.ts
5618
5924
  var import_fs_extra = __toESM(require("fs-extra"));
5619
5925
  var import_fast_glob = __toESM(require("fast-glob"));
5620
- var import_path3 = __toESM(require("path"));
5926
+ var import_path4 = __toESM(require("path"));
5621
5927
  var import_normalize_path = __toESM(require("normalize-path"));
5622
5928
  var FilesystemBridge = class {
5623
5929
  constructor(rootPath, outputPath) {
@@ -5625,9 +5931,9 @@ var FilesystemBridge = class {
5625
5931
  this.outputPath = outputPath || rootPath;
5626
5932
  }
5627
5933
  async glob(pattern, extension) {
5628
- const basePath = import_path3.default.join(this.outputPath, ...pattern.split("/"));
5934
+ const basePath = import_path4.default.join(this.outputPath, ...pattern.split("/"));
5629
5935
  const items = await (0, import_fast_glob.default)(
5630
- import_path3.default.join(basePath, "**", `/*${extension}`).replace(/\\/g, "/"),
5936
+ import_path4.default.join(basePath, "**", `/*${extension}`).replace(/\\/g, "/"),
5631
5937
  {
5632
5938
  dot: true
5633
5939
  }
@@ -5641,10 +5947,10 @@ var FilesystemBridge = class {
5641
5947
  return true;
5642
5948
  }
5643
5949
  async delete(filepath) {
5644
- await import_fs_extra.default.remove(import_path3.default.join(this.outputPath, filepath));
5950
+ await import_fs_extra.default.remove(import_path4.default.join(this.outputPath, filepath));
5645
5951
  }
5646
5952
  async get(filepath) {
5647
- return import_fs_extra.default.readFileSync(import_path3.default.join(this.outputPath, filepath)).toString();
5953
+ return import_fs_extra.default.readFileSync(import_path4.default.join(this.outputPath, filepath)).toString();
5648
5954
  }
5649
5955
  async putConfig(filepath, data) {
5650
5956
  if (this.rootPath !== this.outputPath) {
@@ -5656,7 +5962,7 @@ var FilesystemBridge = class {
5656
5962
  }
5657
5963
  async put(filepath, data, basePathOverride) {
5658
5964
  const basePath = basePathOverride || this.outputPath;
5659
- await import_fs_extra.default.outputFileSync(import_path3.default.join(basePath, filepath), data);
5965
+ await import_fs_extra.default.outputFileSync(import_path4.default.join(basePath, filepath), data);
5660
5966
  }
5661
5967
  };
5662
5968
  var AuditFileSystemBridge = class extends FilesystemBridge {
@@ -5678,7 +5984,7 @@ var import_fs_extra2 = __toESM(require("fs-extra"));
5678
5984
  var import_glob_parent = __toESM(require("glob-parent"));
5679
5985
  var import_normalize_path2 = __toESM(require("normalize-path"));
5680
5986
  var import_graphql6 = require("graphql");
5681
- var import_path4 = require("path");
5987
+ var import_path5 = require("path");
5682
5988
  var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
5683
5989
  var toUint8Array = (buf) => {
5684
5990
  const ab = new ArrayBuffer(buf.length);
@@ -5737,7 +6043,7 @@ var IsomorphicBridge = class {
5737
6043
  async listEntries({
5738
6044
  pattern,
5739
6045
  entry,
5740
- path: path4,
6046
+ path: path5,
5741
6047
  results
5742
6048
  }) {
5743
6049
  const treeResult = await import_isomorphic_git.default.readTree({
@@ -5747,7 +6053,7 @@ var IsomorphicBridge = class {
5747
6053
  });
5748
6054
  const children = [];
5749
6055
  for (const childEntry of treeResult.tree) {
5750
- const childPath = path4 ? `${path4}/${childEntry.path}` : childEntry.path;
6056
+ const childPath = path5 ? `${path5}/${childEntry.path}` : childEntry.path;
5751
6057
  if (childEntry.type === "tree") {
5752
6058
  children.push(childEntry);
5753
6059
  } else {
@@ -5757,7 +6063,7 @@ var IsomorphicBridge = class {
5757
6063
  }
5758
6064
  }
5759
6065
  for (const childEntry of children) {
5760
- const childPath = path4 ? `${path4}/${childEntry.path}` : childEntry.path;
6066
+ const childPath = path5 ? `${path5}/${childEntry.path}` : childEntry.path;
5761
6067
  await this.listEntries({
5762
6068
  pattern,
5763
6069
  entry: childEntry,
@@ -5766,17 +6072,17 @@ var IsomorphicBridge = class {
5766
6072
  });
5767
6073
  }
5768
6074
  }
5769
- async resolvePathEntries(path4, ref) {
5770
- let pathParts = path4.split("/");
6075
+ async resolvePathEntries(path5, ref) {
6076
+ let pathParts = path5.split("/");
5771
6077
  const result = await import_isomorphic_git.default.walk({
5772
6078
  ...this.isomorphicConfig,
5773
6079
  map: async (filepath, [head]) => {
5774
6080
  if (head._fullpath === ".") {
5775
6081
  return head;
5776
6082
  }
5777
- if (path4.startsWith(filepath)) {
5778
- if ((0, import_path4.dirname)(path4) === (0, import_path4.dirname)(filepath)) {
5779
- if (path4 === filepath) {
6083
+ if (path5.startsWith(filepath)) {
6084
+ if ((0, import_path5.dirname)(path5) === (0, import_path5.dirname)(filepath)) {
6085
+ if (path5 === filepath) {
5780
6086
  return head;
5781
6087
  }
5782
6088
  } else {
@@ -5796,7 +6102,7 @@ var IsomorphicBridge = class {
5796
6102
  }
5797
6103
  return { pathParts, pathEntries };
5798
6104
  }
5799
- async updateTreeHierarchy(existingOid, updatedOid, path4, type, pathEntries, pathParts) {
6105
+ async updateTreeHierarchy(existingOid, updatedOid, path5, type, pathEntries, pathParts) {
5800
6106
  const lastIdx = pathEntries.length - 1;
5801
6107
  const parentEntry = pathEntries[lastIdx];
5802
6108
  const parentPath = pathParts[lastIdx];
@@ -5811,7 +6117,7 @@ var IsomorphicBridge = class {
5811
6117
  cache: this.cache
5812
6118
  });
5813
6119
  tree = existingOid ? treeResult.tree.map((entry) => {
5814
- if (entry.path === path4) {
6120
+ if (entry.path === path5) {
5815
6121
  entry.oid = updatedOid;
5816
6122
  }
5817
6123
  return entry;
@@ -5820,7 +6126,7 @@ var IsomorphicBridge = class {
5820
6126
  {
5821
6127
  oid: updatedOid,
5822
6128
  type,
5823
- path: path4,
6129
+ path: path5,
5824
6130
  mode
5825
6131
  }
5826
6132
  ];
@@ -5829,7 +6135,7 @@ var IsomorphicBridge = class {
5829
6135
  {
5830
6136
  oid: updatedOid,
5831
6137
  type,
5832
- path: path4,
6138
+ path: path5,
5833
6139
  mode
5834
6140
  }
5835
6141
  ];
@@ -5930,7 +6236,7 @@ var IsomorphicBridge = class {
5930
6236
  path: parentPath,
5931
6237
  results
5932
6238
  });
5933
- return results.map((path4) => this.unqualifyPath(path4)).filter((path4) => path4.endsWith(extension));
6239
+ return results.map((path5) => this.unqualifyPath(path5)).filter((path5) => path5.endsWith(extension));
5934
6240
  }
5935
6241
  supportsBuilding() {
5936
6242
  return true;