@tinacms/graphql 1.4.18 → 1.4.20

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.
@@ -50,6 +50,8 @@ export declare class Database {
50
50
  private updateDatabaseVersion;
51
51
  private getDatabaseVersion;
52
52
  private initLevel;
53
+ getMetadata: (key: string) => Promise<any>;
54
+ setMetadata: (key: string, value: string) => Promise<void>;
53
55
  get: <T extends object>(filepath: string) => Promise<T>;
54
56
  addPendingDocument: (filepath: string, data: {
55
57
  [key: string]: unknown;
@@ -0,0 +1,18 @@
1
+ import { CallbackFsClient, PromiseFsClient } from 'isomorphic-git';
2
+ export declare const getSha: ({ fs, dir, }: {
3
+ fs: CallbackFsClient | PromiseFsClient;
4
+ dir: string;
5
+ }) => Promise<string>;
6
+ export declare const getChangedFiles: ({ fs, dir, from, to, pathFilter, }: {
7
+ fs: CallbackFsClient | PromiseFsClient;
8
+ dir: string;
9
+ from: string;
10
+ to: string;
11
+ pathFilter: Record<string, {
12
+ matches?: string[];
13
+ }>;
14
+ }) => Promise<{
15
+ added: any[];
16
+ modified: any[];
17
+ deleted: any[];
18
+ }>;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { createDatabase } from './database';
7
7
  export { TinaLevelClient } from './level/tinaLevel';
8
8
  export type { QueryOptions, Database, OnDeleteCallback, OnPutCallback, CreateDatabase, } from './database';
9
9
  import type { Config } from '@tinacms/schema-tools';
10
+ export { getChangedFiles, getSha } from './git';
10
11
  export { sequential, assertShape } from './util';
11
12
  export { loadAndParseWithAliases, stringifyFile, parseFile, scanAllContent, scanContentByPaths, transformDocument, } from './database/util';
12
13
  export { createSchema } from './schema/createSchema';
package/dist/index.es.js CHANGED
@@ -2526,7 +2526,7 @@ var validateField = async (field) => {
2526
2526
  // package.json
2527
2527
  var package_default = {
2528
2528
  name: "@tinacms/graphql",
2529
- version: "1.4.18",
2529
+ version: "1.4.20",
2530
2530
  main: "dist/index.js",
2531
2531
  module: "dist/index.es.js",
2532
2532
  typings: "dist/index.d.ts",
@@ -2557,7 +2557,6 @@ var package_default = {
2557
2557
  "test-watch": "jest --watch"
2558
2558
  },
2559
2559
  dependencies: {
2560
- "@graphql-tools/relay-operation-optimizer": "^6.4.1",
2561
2560
  "@iarna/toml": "^2.2.5",
2562
2561
  "@tinacms/mdx": "workspace:*",
2563
2562
  "@tinacms/schema-tools": "workspace:*",
@@ -2567,47 +2566,21 @@ var package_default = {
2567
2566
  dataloader: "^2.0.0",
2568
2567
  "date-fns": "^2.21.1",
2569
2568
  "encoding-down": "^7.1.0",
2570
- esbuild: "^0.15.5",
2571
- "esbuild-jest": "^0.5.0",
2572
2569
  "estree-walker": "^3.0.0",
2573
2570
  "fast-glob": "^3.2.5",
2574
- flat: "^5.0.2",
2575
2571
  "fs-extra": "^9.0.1",
2576
2572
  "glob-parent": "^6.0.2",
2577
2573
  graphql: "15.8.0",
2578
- "graphql-type-json": "^0.3.2",
2579
2574
  "gray-matter": "^4.0.2",
2580
2575
  "isomorphic-git": "^1.21.0",
2581
2576
  "js-sha1": "^0.6.0",
2582
2577
  "js-yaml": "^3.14.1",
2583
2578
  "jsonpath-plus": "^6.0.1",
2584
- leveldown: "^6.1.0",
2585
2579
  lodash: "^4.17.20",
2586
2580
  "many-level": "^2.0.0",
2587
- mdast: "^3.0.0",
2588
- "mdast-util-from-markdown": "^1.0.0",
2589
- "mdast-util-mdx": "^1.1.0",
2590
- "mdast-util-mdx-expression": "^1.1.0",
2591
- "mdast-util-to-markdown": "^1.2.1",
2592
- "micromark-extension-mdxjs": "^1.0.0",
2593
2581
  micromatch: "4.0.5",
2594
2582
  "normalize-path": "^3.0.0",
2595
- prettier: "^2.2.1",
2596
2583
  "readable-stream": "^4.3.0",
2597
- "rehype-format": "^3.1.0",
2598
- "rehype-stringify": "^8.0.0",
2599
- remark: "^13.0.0",
2600
- "remark-frontmatter": "^3.0.0",
2601
- "remark-mdx": "next",
2602
- "remark-parse": "^10.0.0",
2603
- "remark-rehype": "^8.0.0",
2604
- "remark-slate": "^1.8.0",
2605
- "remark-stringify": "^8.1.1",
2606
- unified: "^10.1.0",
2607
- "unist-util-remove-position": "^3.0.0",
2608
- "unist-util-visit": "^4.0.0",
2609
- vfile: "^4.2.0",
2610
- ws: "^7.3.1",
2611
2584
  yup: "^0.32.9"
2612
2585
  },
2613
2586
  publishConfig: {
@@ -2636,10 +2609,10 @@ var package_default = {
2636
2609
  "@types/normalize-path": "^3.0.0",
2637
2610
  "@types/ws": "^7.2.6",
2638
2611
  "@types/yup": "^0.29.7",
2639
- jest: "27.0.6",
2640
- "jest-diff": "27.0.6",
2612
+ jest: "^29.5.0",
2613
+ "jest-diff": "^29.5.0",
2641
2614
  "jest-file-snapshot": "^0.5.0",
2642
- "jest-matcher-utils": "27.0.6",
2615
+ "jest-matcher-utils": "^29.5.0",
2643
2616
  "memory-level": "^1.0.0",
2644
2617
  nodemon: "2.0.19",
2645
2618
  typescript: "4.3.5"
@@ -2825,14 +2798,7 @@ var _buildSchema = async (builder, tinaSchema) => {
2825
2798
  };
2826
2799
 
2827
2800
  // src/resolve.ts
2828
- import {
2829
- graphql,
2830
- buildASTSchema,
2831
- getNamedType,
2832
- print as print2,
2833
- GraphQLError as GraphQLError3,
2834
- parse
2835
- } from "graphql";
2801
+ import { graphql, buildASTSchema, getNamedType, GraphQLError as GraphQLError3 } from "graphql";
2836
2802
 
2837
2803
  // src/resolver/index.ts
2838
2804
  import path3 from "path";
@@ -3067,9 +3033,9 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
3067
3033
  return value;
3068
3034
  }
3069
3035
  };
3070
- var cleanUpSlashes = (path6) => {
3071
- if (path6) {
3072
- return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
3036
+ var cleanUpSlashes = (path7) => {
3037
+ if (path7) {
3038
+ return `/${path7.replace(/^\/+|\/+$/gm, "")}`;
3073
3039
  }
3074
3040
  return "";
3075
3041
  };
@@ -3353,17 +3319,17 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
3353
3319
  const documentPaths = await bridge.glob(normalPath, format);
3354
3320
  const matches = tinaSchema.getMatches({ collection });
3355
3321
  const filteredPaths = matches.length > 0 ? micromatch(documentPaths, matches) : documentPaths;
3356
- filteredPaths.forEach((path6) => {
3357
- if (filesSeen.has(path6)) {
3358
- filesSeen.get(path6).push(collection.name);
3359
- duplicateFiles.add(path6);
3322
+ filteredPaths.forEach((path7) => {
3323
+ if (filesSeen.has(path7)) {
3324
+ filesSeen.get(path7).push(collection.name);
3325
+ duplicateFiles.add(path7);
3360
3326
  } else {
3361
- filesSeen.set(path6, [collection.name]);
3327
+ filesSeen.set(path7, [collection.name]);
3362
3328
  }
3363
3329
  });
3364
- duplicateFiles.forEach((path6) => {
3330
+ duplicateFiles.forEach((path7) => {
3365
3331
  warnings.push(
3366
- `"${path6}" Found in multiple collections: ${filesSeen.get(path6).map((collection2) => `"${collection2}"`).join(
3332
+ `"${path7}" Found in multiple collections: ${filesSeen.get(path7).map((collection2) => `"${collection2}"`).join(
3367
3333
  ", "
3368
3334
  )}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
3369
3335
  This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
@@ -3923,9 +3889,9 @@ var makeFilterSuffixes = (filterChain, index) => {
3923
3889
  }
3924
3890
  };
3925
3891
  var FOLDER_ROOT = "~";
3926
- var stripCollectionFromPath = (collectionPath, path6) => {
3892
+ var stripCollectionFromPath = (collectionPath, path7) => {
3927
3893
  const collectionPathParts = collectionPath.split("/");
3928
- const pathParts = path6.split("/");
3894
+ const pathParts = path7.split("/");
3929
3895
  const strippedPathParts = pathParts.slice(collectionPathParts.length);
3930
3896
  return strippedPathParts.join("/");
3931
3897
  };
@@ -3980,13 +3946,13 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
3980
3946
  SUBLEVEL_OPTIONS
3981
3947
  );
3982
3948
  let folderSortingIdx = 0;
3983
- for (const path6 of Array.from(folder).sort()) {
3949
+ for (const path7 of Array.from(folder).sort()) {
3984
3950
  for (const [sort] of Object.entries(indexDefinitions)) {
3985
3951
  const indexSublevel = folderCollectionSublevel.sublevel(
3986
3952
  sort,
3987
3953
  SUBLEVEL_OPTIONS
3988
3954
  );
3989
- const subFolderKey = sha.hex(path6);
3955
+ const subFolderKey = sha.hex(path7);
3990
3956
  if (sort === DEFAULT_COLLECTION_SORT_KEY) {
3991
3957
  result.push({
3992
3958
  type: opType,
@@ -4604,7 +4570,7 @@ var Resolver = class {
4604
4570
  first: -1
4605
4571
  },
4606
4572
  collection: referencedCollection,
4607
- hydrator: (path6) => path6
4573
+ hydrator: (path7) => path7
4608
4574
  }
4609
4575
  );
4610
4576
  const { edges } = resolvedCollectionConnection;
@@ -4792,7 +4758,6 @@ var resolveDateInput = (value) => {
4792
4758
  };
4793
4759
 
4794
4760
  // src/resolve.ts
4795
- import { optimizeDocuments } from "@graphql-tools/relay-operation-optimizer";
4796
4761
  var resolve = async ({
4797
4762
  config,
4798
4763
  query,
@@ -4882,16 +4847,7 @@ var resolve = async ({
4882
4847
  }
4883
4848
  if (info.fieldName === "getOptimizedQuery") {
4884
4849
  try {
4885
- const [optimizedQuery] = optimizeDocuments(
4886
- info.schema,
4887
- [parse(args.queryString)],
4888
- {
4889
- assumeValid: true,
4890
- includeFragments: false,
4891
- noLocation: true
4892
- }
4893
- );
4894
- return print2(optimizedQuery);
4850
+ return args.queryString;
4895
4851
  } catch (e) {
4896
4852
  throw new Error(
4897
4853
  `Invalid query provided, Error message: ${e.message}`
@@ -5062,6 +5018,17 @@ var Database = class {
5062
5018
  }
5063
5019
  };
5064
5020
  this.getGeneratedFolder = () => path4.join(this.tinaDirectory, "__generated__");
5021
+ this.getMetadata = async (key) => {
5022
+ await this.initLevel();
5023
+ const metadataLevel = this.rootLevel.sublevel("_metadata", SUBLEVEL_OPTIONS);
5024
+ const metadata = await metadataLevel.get(`metadata_${key}`);
5025
+ return metadata?.value;
5026
+ };
5027
+ this.setMetadata = async (key, value) => {
5028
+ await this.initLevel();
5029
+ const metadataLevel = this.rootLevel.sublevel("_metadata", SUBLEVEL_OPTIONS);
5030
+ return metadataLevel.put(`metadata_${key}`, { value });
5031
+ };
5065
5032
  this.get = async (filepath) => {
5066
5033
  await this.initLevel();
5067
5034
  if (SYSTEM_FILES.includes(filepath)) {
@@ -5509,7 +5476,7 @@ var Database = class {
5509
5476
  if (!matcher || indexDefinition && matcher.length !== indexDefinition.fields.length + 2) {
5510
5477
  continue;
5511
5478
  }
5512
- let filepath = matcher.groups["_filepath_"];
5479
+ const filepath = matcher.groups["_filepath_"];
5513
5480
  let itemRecord;
5514
5481
  if (filterSuffixes) {
5515
5482
  itemRecord = matcher.groups;
@@ -6030,10 +5997,93 @@ var TinaLevelClient = class extends ManyLevelGuest {
6030
5997
  }
6031
5998
  };
6032
5999
 
6033
- // src/database/bridge/filesystem.ts
6000
+ // src/git/index.ts
6001
+ import git from "isomorphic-git";
6034
6002
  import fs from "fs-extra";
6035
- import fg from "fast-glob";
6036
6003
  import path5 from "path";
6004
+ import micromatch3 from "micromatch";
6005
+ var findGitRoot = async (dir) => {
6006
+ if (await fs.pathExists(path5.join(dir, ".git"))) {
6007
+ return dir;
6008
+ }
6009
+ const parentDir = path5.dirname(dir);
6010
+ if (parentDir === dir) {
6011
+ throw new Error("Could not find .git directory");
6012
+ }
6013
+ return findGitRoot(parentDir);
6014
+ };
6015
+ var getSha = async ({
6016
+ fs: fs4,
6017
+ dir
6018
+ }) => {
6019
+ dir = await findGitRoot(dir);
6020
+ return git.resolveRef({
6021
+ fs: fs4,
6022
+ dir,
6023
+ ref: "HEAD"
6024
+ });
6025
+ };
6026
+ var getChangedFiles = async ({
6027
+ fs: fs4,
6028
+ dir,
6029
+ from,
6030
+ to,
6031
+ pathFilter
6032
+ }) => {
6033
+ const results = {
6034
+ added: [],
6035
+ modified: [],
6036
+ deleted: []
6037
+ };
6038
+ const rootDir = await findGitRoot(dir);
6039
+ let pathPrefix = "";
6040
+ if (rootDir !== dir) {
6041
+ pathPrefix = normalizePath(dir.substring(rootDir.length + 1));
6042
+ }
6043
+ await git.walk({
6044
+ fs: fs4,
6045
+ dir: rootDir,
6046
+ trees: [git.TREE({ ref: from }), git.TREE({ ref: to })],
6047
+ map: async function(filename, [A, B]) {
6048
+ const relativePath = normalizePath(filename).substring(pathPrefix.length);
6049
+ let matches = false;
6050
+ for (const [key, matcher] of Object.entries(pathFilter)) {
6051
+ if (relativePath.startsWith(key)) {
6052
+ if (!matcher.matches) {
6053
+ matches = true;
6054
+ } else {
6055
+ if (micromatch3.isMatch(relativePath, matcher.matches)) {
6056
+ matches = true;
6057
+ break;
6058
+ }
6059
+ }
6060
+ }
6061
+ }
6062
+ if (await B?.type() === "tree") {
6063
+ return;
6064
+ }
6065
+ if (matches) {
6066
+ let oidA = await A?.oid();
6067
+ let oidB = await B?.oid();
6068
+ if (oidA !== oidB) {
6069
+ if (oidA === void 0) {
6070
+ results.added.push(relativePath);
6071
+ } else if (oidB === void 0) {
6072
+ results.deleted.push(relativePath);
6073
+ } else {
6074
+ results.modified.push(relativePath);
6075
+ }
6076
+ }
6077
+ }
6078
+ }
6079
+ });
6080
+ return results;
6081
+ };
6082
+
6083
+ // src/database/bridge/filesystem.ts
6084
+ import fs2 from "fs-extra";
6085
+ import fg from "fast-glob";
6086
+ import path6 from "path";
6037
6087
  import normalize from "normalize-path";
6038
6088
  var FilesystemBridge = class {
6039
6089
  constructor(rootPath, outputPath) {
@@ -6041,9 +6091,9 @@ var FilesystemBridge = class {
6041
6091
  this.outputPath = outputPath || rootPath;
6042
6092
  }
6043
6093
  async glob(pattern, extension) {
6044
- const basePath = path5.join(this.outputPath, ...pattern.split("/"));
6094
+ const basePath = path6.join(this.outputPath, ...pattern.split("/"));
6045
6095
  const items = await fg(
6046
- path5.join(basePath, "**", `/*.${extension}`).replace(/\\/g, "/"),
6096
+ path6.join(basePath, "**", `/*.${extension}`).replace(/\\/g, "/"),
6047
6097
  {
6048
6098
  dot: true,
6049
6099
  ignore: ["**/node_modules/**"]
@@ -6055,14 +6105,14 @@ var FilesystemBridge = class {
6055
6105
  });
6056
6106
  }
6057
6107
  async delete(filepath) {
6058
- await fs.remove(path5.join(this.outputPath, filepath));
6108
+ await fs2.remove(path6.join(this.outputPath, filepath));
6059
6109
  }
6060
6110
  async get(filepath) {
6061
- return fs.readFileSync(path5.join(this.outputPath, filepath)).toString();
6111
+ return fs2.readFileSync(path6.join(this.outputPath, filepath)).toString();
6062
6112
  }
6063
6113
  async put(filepath, data, basePathOverride) {
6064
6114
  const basePath = basePathOverride || this.outputPath;
6065
- await fs.outputFileSync(path5.join(basePath, filepath), data);
6115
+ await fs2.outputFileSync(path6.join(basePath, filepath), data);
6066
6116
  }
6067
6117
  };
6068
6118
  var AuditFileSystemBridge = class extends FilesystemBridge {
@@ -6082,8 +6132,8 @@ var AuditFileSystemBridge = class extends FilesystemBridge {
6082
6132
  };
6083
6133
 
6084
6134
  // src/database/bridge/isomorphic.ts
6085
- import git from "isomorphic-git";
6086
- import fs2 from "fs-extra";
6135
+ import git2 from "isomorphic-git";
6136
+ import fs3 from "fs-extra";
6087
6137
  import globParent from "glob-parent";
6088
6138
  import normalize2 from "normalize-path";
6089
6139
  import { GraphQLError as GraphQLError5 } from "graphql";
@@ -6102,7 +6152,7 @@ var IsomorphicBridge = class {
6102
6152
  gitRoot,
6103
6153
  author,
6104
6154
  committer,
6105
- fsModule = fs2,
6155
+ fsModule = fs3,
6106
6156
  commitMessage = "Update from GraphQL client",
6107
6157
  ref,
6108
6158
  onPut,
@@ -6146,17 +6196,17 @@ var IsomorphicBridge = class {
6146
6196
  async listEntries({
6147
6197
  pattern,
6148
6198
  entry,
6149
- path: path6,
6199
+ path: path7,
6150
6200
  results
6151
6201
  }) {
6152
- const treeResult = await git.readTree({
6202
+ const treeResult = await git2.readTree({
6153
6203
  ...this.isomorphicConfig,
6154
6204
  oid: entry.oid,
6155
6205
  cache: this.cache
6156
6206
  });
6157
6207
  const children = [];
6158
6208
  for (const childEntry of treeResult.tree) {
6159
- const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
6209
+ const childPath = path7 ? `${path7}/${childEntry.path}` : childEntry.path;
6160
6210
  if (childEntry.type === "tree") {
6161
6211
  children.push(childEntry);
6162
6212
  } else {
@@ -6166,7 +6216,7 @@ var IsomorphicBridge = class {
6166
6216
  }
6167
6217
  }
6168
6218
  for (const childEntry of children) {
6169
- const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
6219
+ const childPath = path7 ? `${path7}/${childEntry.path}` : childEntry.path;
6170
6220
  await this.listEntries({
6171
6221
  pattern,
6172
6222
  entry: childEntry,
@@ -6175,17 +6225,17 @@ var IsomorphicBridge = class {
6175
6225
  });
6176
6226
  }
6177
6227
  }
6178
- async resolvePathEntries(path6, ref) {
6179
- let pathParts = path6.split("/");
6180
- const result = await git.walk({
6228
+ async resolvePathEntries(path7, ref) {
6229
+ let pathParts = path7.split("/");
6230
+ const result = await git2.walk({
6181
6231
  ...this.isomorphicConfig,
6182
6232
  map: async (filepath, [head]) => {
6183
6233
  if (head._fullpath === ".") {
6184
6234
  return head;
6185
6235
  }
6186
- if (path6.startsWith(filepath)) {
6187
- if (dirname(path6) === dirname(filepath)) {
6188
- if (path6 === filepath) {
6236
+ if (path7.startsWith(filepath)) {
6237
+ if (dirname(path7) === dirname(filepath)) {
6238
+ if (path7 === filepath) {
6189
6239
  return head;
6190
6240
  }
6191
6241
  } else {
@@ -6194,7 +6244,7 @@ var IsomorphicBridge = class {
6194
6244
  }
6195
6245
  },
6196
6246
  cache: this.cache,
6197
- trees: [git.TREE({ ref })]
6247
+ trees: [git2.TREE({ ref })]
6198
6248
  });
6199
6249
  const pathEntries = flat(result);
6200
6250
  if (pathParts.indexOf(".") === -1) {
@@ -6205,7 +6255,7 @@ var IsomorphicBridge = class {
6205
6255
  }
6206
6256
  return { pathParts, pathEntries };
6207
6257
  }
6208
- async updateTreeHierarchy(existingOid, updatedOid, path6, type, pathEntries, pathParts) {
6258
+ async updateTreeHierarchy(existingOid, updatedOid, path7, type, pathEntries, pathParts) {
6209
6259
  const lastIdx = pathEntries.length - 1;
6210
6260
  const parentEntry = pathEntries[lastIdx];
6211
6261
  const parentPath = pathParts[lastIdx];
@@ -6214,13 +6264,13 @@ var IsomorphicBridge = class {
6214
6264
  const mode = type === "blob" ? "100644" : "040000";
6215
6265
  if (parentEntry) {
6216
6266
  parentOid = await parentEntry.oid();
6217
- const treeResult = await git.readTree({
6267
+ const treeResult = await git2.readTree({
6218
6268
  ...this.isomorphicConfig,
6219
6269
  oid: parentOid,
6220
6270
  cache: this.cache
6221
6271
  });
6222
6272
  tree = existingOid ? treeResult.tree.map((entry) => {
6223
- if (entry.path === path6) {
6273
+ if (entry.path === path7) {
6224
6274
  entry.oid = updatedOid;
6225
6275
  }
6226
6276
  return entry;
@@ -6229,7 +6279,7 @@ var IsomorphicBridge = class {
6229
6279
  {
6230
6280
  oid: updatedOid,
6231
6281
  type,
6232
- path: path6,
6282
+ path: path7,
6233
6283
  mode
6234
6284
  }
6235
6285
  ];
@@ -6238,12 +6288,12 @@ var IsomorphicBridge = class {
6238
6288
  {
6239
6289
  oid: updatedOid,
6240
6290
  type,
6241
- path: path6,
6291
+ path: path7,
6242
6292
  mode
6243
6293
  }
6244
6294
  ];
6245
6295
  }
6246
- const updatedParentOid = await git.writeTree({
6296
+ const updatedParentOid = await git2.writeTree({
6247
6297
  ...this.isomorphicConfig,
6248
6298
  tree
6249
6299
  });
@@ -6261,12 +6311,12 @@ var IsomorphicBridge = class {
6261
6311
  }
6262
6312
  }
6263
6313
  async commitTree(treeSha, ref) {
6264
- const commitSha = await git.writeCommit({
6314
+ const commitSha = await git2.writeCommit({
6265
6315
  ...this.isomorphicConfig,
6266
6316
  commit: {
6267
6317
  tree: treeSha,
6268
6318
  parent: [
6269
- await git.resolveRef({
6319
+ await git2.resolveRef({
6270
6320
  ...this.isomorphicConfig,
6271
6321
  ref
6272
6322
  })
@@ -6276,7 +6326,7 @@ var IsomorphicBridge = class {
6276
6326
  committer: this.getCommitter()
6277
6327
  }
6278
6328
  });
6279
- await git.writeRef({
6329
+ await git2.writeRef({
6280
6330
  ...this.isomorphicConfig,
6281
6331
  ref,
6282
6332
  value: commitSha,
@@ -6287,7 +6337,7 @@ var IsomorphicBridge = class {
6287
6337
  if (this.ref) {
6288
6338
  return this.ref;
6289
6339
  }
6290
- const ref = await git.currentBranch({
6340
+ const ref = await git2.currentBranch({
6291
6341
  ...this.isomorphicConfig,
6292
6342
  fullname: true
6293
6343
  });
@@ -6318,7 +6368,7 @@ var IsomorphicBridge = class {
6318
6368
  let treeEntry;
6319
6369
  let parentPath;
6320
6370
  if (parentEntry) {
6321
- const treeResult = await git.readTree({
6371
+ const treeResult = await git2.readTree({
6322
6372
  ...this.isomorphicConfig,
6323
6373
  oid: await parentEntry.oid(),
6324
6374
  cache: this.cache
@@ -6339,7 +6389,7 @@ var IsomorphicBridge = class {
6339
6389
  path: parentPath,
6340
6390
  results
6341
6391
  });
6342
- return results.map((path6) => this.unqualifyPath(path6)).filter((path6) => path6.endsWith(extension));
6392
+ return results.map((path7) => this.unqualifyPath(path7)).filter((path7) => path7.endsWith(extension));
6343
6393
  }
6344
6394
  async delete(filepath) {
6345
6395
  const ref = await this.getRef();
@@ -6356,7 +6406,7 @@ var IsomorphicBridge = class {
6356
6406
  oidToRemove = oidToRemove || await leafEntry.oid();
6357
6407
  const parentEntry = pathEntries[ptr - 1];
6358
6408
  const existingOid = await parentEntry.oid();
6359
- const treeResult = await git.readTree({
6409
+ const treeResult = await git2.readTree({
6360
6410
  ...this.isomorphicConfig,
6361
6411
  oid: existingOid,
6362
6412
  cache: this.cache
@@ -6368,7 +6418,7 @@ var IsomorphicBridge = class {
6368
6418
  ptr -= 1;
6369
6419
  continue;
6370
6420
  }
6371
- const updatedTreeOid = await git.writeTree({
6421
+ const updatedTreeOid = await git2.writeTree({
6372
6422
  ...this.isomorphicConfig,
6373
6423
  tree: updatedTree
6374
6424
  });
@@ -6395,7 +6445,7 @@ var IsomorphicBridge = class {
6395
6445
  }
6396
6446
  }
6397
6447
  if (oidToRemove) {
6398
- await git.updateIndex({
6448
+ await git2.updateIndex({
6399
6449
  ...this.isomorphicConfig,
6400
6450
  filepath: this.qualifyPath(filepath),
6401
6451
  force: true,
@@ -6414,11 +6464,11 @@ var IsomorphicBridge = class {
6414
6464
  }
6415
6465
  async get(filepath) {
6416
6466
  const ref = await this.getRef();
6417
- const oid = await git.resolveRef({
6467
+ const oid = await git2.resolveRef({
6418
6468
  ...this.isomorphicConfig,
6419
6469
  ref
6420
6470
  });
6421
- const { blob } = await git.readBlob({
6471
+ const { blob } = await git2.readBlob({
6422
6472
  ...this.isomorphicConfig,
6423
6473
  oid,
6424
6474
  filepath: this.qualifyPath(filepath),
@@ -6438,13 +6488,13 @@ var IsomorphicBridge = class {
6438
6488
  const nodePath = pathParts[pathParts.length - 1];
6439
6489
  if (leafEntry) {
6440
6490
  existingOid = await leafEntry.oid();
6441
- const hash = await git.hashBlob({ object: blobUpdate });
6491
+ const hash = await git2.hashBlob({ object: blobUpdate });
6442
6492
  if (hash.oid === existingOid) {
6443
6493
  await this.onPut(filepath, data);
6444
6494
  return;
6445
6495
  }
6446
6496
  }
6447
- const updatedOid = await git.writeBlob({
6497
+ const updatedOid = await git2.writeBlob({
6448
6498
  ...this.isomorphicConfig,
6449
6499
  blob: blobUpdate
6450
6500
  });
@@ -6457,7 +6507,7 @@ var IsomorphicBridge = class {
6457
6507
  pathParts.slice(0, pathParts.length - 1)
6458
6508
  );
6459
6509
  await this.commitTree(updatedRootSha, ref);
6460
- await git.updateIndex({
6510
+ await git2.updateIndex({
6461
6511
  ...this.isomorphicConfig,
6462
6512
  filepath: this.qualifyPath(filepath),
6463
6513
  add: true,
@@ -6489,6 +6539,8 @@ export {
6489
6539
  buildSchema,
6490
6540
  createDatabase,
6491
6541
  createSchema,
6542
+ getChangedFiles,
6543
+ getSha,
6492
6544
  handleFetchErrorError,
6493
6545
  loadAndParseWithAliases,
6494
6546
  parseFile,
package/dist/index.js CHANGED
@@ -38,6 +38,8 @@ __export(src_exports, {
38
38
  buildSchema: () => buildSchema,
39
39
  createDatabase: () => createDatabase,
40
40
  createSchema: () => createSchema,
41
+ getChangedFiles: () => getChangedFiles,
42
+ getSha: () => getSha,
41
43
  handleFetchErrorError: () => handleFetchErrorError,
42
44
  loadAndParseWithAliases: () => loadAndParseWithAliases,
43
45
  parseFile: () => parseFile,
@@ -2583,7 +2585,7 @@ var validateField = async (field) => {
2583
2585
  // package.json
2584
2586
  var package_default = {
2585
2587
  name: "@tinacms/graphql",
2586
- version: "1.4.18",
2588
+ version: "1.4.20",
2587
2589
  main: "dist/index.js",
2588
2590
  module: "dist/index.es.js",
2589
2591
  typings: "dist/index.d.ts",
@@ -2614,7 +2616,6 @@ var package_default = {
2614
2616
  "test-watch": "jest --watch"
2615
2617
  },
2616
2618
  dependencies: {
2617
- "@graphql-tools/relay-operation-optimizer": "^6.4.1",
2618
2619
  "@iarna/toml": "^2.2.5",
2619
2620
  "@tinacms/mdx": "workspace:*",
2620
2621
  "@tinacms/schema-tools": "workspace:*",
@@ -2624,47 +2625,21 @@ var package_default = {
2624
2625
  dataloader: "^2.0.0",
2625
2626
  "date-fns": "^2.21.1",
2626
2627
  "encoding-down": "^7.1.0",
2627
- esbuild: "^0.15.5",
2628
- "esbuild-jest": "^0.5.0",
2629
2628
  "estree-walker": "^3.0.0",
2630
2629
  "fast-glob": "^3.2.5",
2631
- flat: "^5.0.2",
2632
2630
  "fs-extra": "^9.0.1",
2633
2631
  "glob-parent": "^6.0.2",
2634
2632
  graphql: "15.8.0",
2635
- "graphql-type-json": "^0.3.2",
2636
2633
  "gray-matter": "^4.0.2",
2637
2634
  "isomorphic-git": "^1.21.0",
2638
2635
  "js-sha1": "^0.6.0",
2639
2636
  "js-yaml": "^3.14.1",
2640
2637
  "jsonpath-plus": "^6.0.1",
2641
- leveldown: "^6.1.0",
2642
2638
  lodash: "^4.17.20",
2643
2639
  "many-level": "^2.0.0",
2644
- mdast: "^3.0.0",
2645
- "mdast-util-from-markdown": "^1.0.0",
2646
- "mdast-util-mdx": "^1.1.0",
2647
- "mdast-util-mdx-expression": "^1.1.0",
2648
- "mdast-util-to-markdown": "^1.2.1",
2649
- "micromark-extension-mdxjs": "^1.0.0",
2650
2640
  micromatch: "4.0.5",
2651
2641
  "normalize-path": "^3.0.0",
2652
- prettier: "^2.2.1",
2653
2642
  "readable-stream": "^4.3.0",
2654
- "rehype-format": "^3.1.0",
2655
- "rehype-stringify": "^8.0.0",
2656
- remark: "^13.0.0",
2657
- "remark-frontmatter": "^3.0.0",
2658
- "remark-mdx": "next",
2659
- "remark-parse": "^10.0.0",
2660
- "remark-rehype": "^8.0.0",
2661
- "remark-slate": "^1.8.0",
2662
- "remark-stringify": "^8.1.1",
2663
- unified: "^10.1.0",
2664
- "unist-util-remove-position": "^3.0.0",
2665
- "unist-util-visit": "^4.0.0",
2666
- vfile: "^4.2.0",
2667
- ws: "^7.3.1",
2668
2643
  yup: "^0.32.9"
2669
2644
  },
2670
2645
  publishConfig: {
@@ -2693,10 +2668,10 @@ var package_default = {
2693
2668
  "@types/normalize-path": "^3.0.0",
2694
2669
  "@types/ws": "^7.2.6",
2695
2670
  "@types/yup": "^0.29.7",
2696
- jest: "27.0.6",
2697
- "jest-diff": "27.0.6",
2671
+ jest: "^29.5.0",
2672
+ "jest-diff": "^29.5.0",
2698
2673
  "jest-file-snapshot": "^0.5.0",
2699
- "jest-matcher-utils": "27.0.6",
2674
+ "jest-matcher-utils": "^29.5.0",
2700
2675
  "memory-level": "^1.0.0",
2701
2676
  nodemon: "2.0.19",
2702
2677
  typescript: "4.3.5"
@@ -3118,9 +3093,9 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
3118
3093
  return value;
3119
3094
  }
3120
3095
  };
3121
- var cleanUpSlashes = (path6) => {
3122
- if (path6) {
3123
- return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
3096
+ var cleanUpSlashes = (path7) => {
3097
+ if (path7) {
3098
+ return `/${path7.replace(/^\/+|\/+$/gm, "")}`;
3124
3099
  }
3125
3100
  return "";
3126
3101
  };
@@ -3407,17 +3382,17 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
3407
3382
  const documentPaths = await bridge.glob(normalPath, format);
3408
3383
  const matches = tinaSchema.getMatches({ collection });
3409
3384
  const filteredPaths = matches.length > 0 ? (0, import_micromatch.default)(documentPaths, matches) : documentPaths;
3410
- filteredPaths.forEach((path6) => {
3411
- if (filesSeen.has(path6)) {
3412
- filesSeen.get(path6).push(collection.name);
3413
- duplicateFiles.add(path6);
3385
+ filteredPaths.forEach((path7) => {
3386
+ if (filesSeen.has(path7)) {
3387
+ filesSeen.get(path7).push(collection.name);
3388
+ duplicateFiles.add(path7);
3414
3389
  } else {
3415
- filesSeen.set(path6, [collection.name]);
3390
+ filesSeen.set(path7, [collection.name]);
3416
3391
  }
3417
3392
  });
3418
- duplicateFiles.forEach((path6) => {
3393
+ duplicateFiles.forEach((path7) => {
3419
3394
  warnings.push(
3420
- `"${path6}" Found in multiple collections: ${filesSeen.get(path6).map((collection2) => `"${collection2}"`).join(
3395
+ `"${path7}" Found in multiple collections: ${filesSeen.get(path7).map((collection2) => `"${collection2}"`).join(
3421
3396
  ", "
3422
3397
  )}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
3423
3398
  This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
@@ -3977,9 +3952,9 @@ var makeFilterSuffixes = (filterChain, index) => {
3977
3952
  }
3978
3953
  };
3979
3954
  var FOLDER_ROOT = "~";
3980
- var stripCollectionFromPath = (collectionPath, path6) => {
3955
+ var stripCollectionFromPath = (collectionPath, path7) => {
3981
3956
  const collectionPathParts = collectionPath.split("/");
3982
- const pathParts = path6.split("/");
3957
+ const pathParts = path7.split("/");
3983
3958
  const strippedPathParts = pathParts.slice(collectionPathParts.length);
3984
3959
  return strippedPathParts.join("/");
3985
3960
  };
@@ -4034,13 +4009,13 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
4034
4009
  SUBLEVEL_OPTIONS
4035
4010
  );
4036
4011
  let folderSortingIdx = 0;
4037
- for (const path6 of Array.from(folder).sort()) {
4012
+ for (const path7 of Array.from(folder).sort()) {
4038
4013
  for (const [sort] of Object.entries(indexDefinitions)) {
4039
4014
  const indexSublevel = folderCollectionSublevel.sublevel(
4040
4015
  sort,
4041
4016
  SUBLEVEL_OPTIONS
4042
4017
  );
4043
- const subFolderKey = import_js_sha1.default.hex(path6);
4018
+ const subFolderKey = import_js_sha1.default.hex(path7);
4044
4019
  if (sort === DEFAULT_COLLECTION_SORT_KEY) {
4045
4020
  result.push({
4046
4021
  type: opType,
@@ -4659,7 +4634,7 @@ var Resolver = class {
4659
4634
  first: -1
4660
4635
  },
4661
4636
  collection: referencedCollection,
4662
- hydrator: (path6) => path6
4637
+ hydrator: (path7) => path7
4663
4638
  }
4664
4639
  );
4665
4640
  const { edges } = resolvedCollectionConnection;
@@ -4847,7 +4822,6 @@ var resolveDateInput = (value) => {
4847
4822
  };
4848
4823
 
4849
4824
  // src/resolve.ts
4850
- var import_relay_operation_optimizer = require("@graphql-tools/relay-operation-optimizer");
4851
4825
  var resolve = async ({
4852
4826
  config,
4853
4827
  query,
@@ -4941,16 +4915,7 @@ var resolve = async ({
4941
4915
  }
4942
4916
  if (info.fieldName === "getOptimizedQuery") {
4943
4917
  try {
4944
- const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(
4945
- info.schema,
4946
- [(0, import_graphql4.parse)(args.queryString)],
4947
- {
4948
- assumeValid: true,
4949
- includeFragments: false,
4950
- noLocation: true
4951
- }
4952
- );
4953
- return (0, import_graphql4.print)(optimizedQuery);
4918
+ return args.queryString;
4954
4919
  } catch (e) {
4955
4920
  throw new Error(
4956
4921
  `Invalid query provided, Error message: ${e.message}`
@@ -5121,6 +5086,17 @@ var Database = class {
5121
5086
  }
5122
5087
  };
5123
5088
  this.getGeneratedFolder = () => import_path4.default.join(this.tinaDirectory, "__generated__");
5089
+ this.getMetadata = async (key) => {
5090
+ await this.initLevel();
5091
+ const metadataLevel = this.rootLevel.sublevel("_metadata", SUBLEVEL_OPTIONS);
5092
+ const metadata = await metadataLevel.get(`metadata_${key}`);
5093
+ return metadata == null ? void 0 : metadata.value;
5094
+ };
5095
+ this.setMetadata = async (key, value) => {
5096
+ await this.initLevel();
5097
+ const metadataLevel = this.rootLevel.sublevel("_metadata", SUBLEVEL_OPTIONS);
5098
+ return metadataLevel.put(`metadata_${key}`, { value });
5099
+ };
5124
5100
  this.get = async (filepath) => {
5125
5101
  await this.initLevel();
5126
5102
  if (SYSTEM_FILES.includes(filepath)) {
@@ -5570,7 +5546,7 @@ var Database = class {
5570
5546
  if (!matcher || indexDefinition && matcher.length !== indexDefinition.fields.length + 2) {
5571
5547
  continue;
5572
5548
  }
5573
- let filepath = matcher.groups["_filepath_"];
5549
+ const filepath = matcher.groups["_filepath_"];
5574
5550
  let itemRecord;
5575
5551
  if (filterSuffixes) {
5576
5552
  itemRecord = matcher.groups;
@@ -6091,10 +6067,93 @@ var TinaLevelClient = class extends import_many_level.ManyLevelGuest {
6091
6067
  }
6092
6068
  };
6093
6069
 
6094
- // src/database/bridge/filesystem.ts
6070
+ // src/git/index.ts
6071
+ var import_isomorphic_git = __toESM(require("isomorphic-git"));
6095
6072
  var import_fs_extra = __toESM(require("fs-extra"));
6096
- var import_fast_glob = __toESM(require("fast-glob"));
6097
6073
  var import_path5 = __toESM(require("path"));
6074
+ var import_micromatch3 = __toESM(require("micromatch"));
6075
+ var findGitRoot = async (dir) => {
6076
+ if (await import_fs_extra.default.pathExists(import_path5.default.join(dir, ".git"))) {
6077
+ return dir;
6078
+ }
6079
+ const parentDir = import_path5.default.dirname(dir);
6080
+ if (parentDir === dir) {
6081
+ throw new Error("Could not find .git directory");
6082
+ }
6083
+ return findGitRoot(parentDir);
6084
+ };
6085
+ var getSha = async ({
6086
+ fs: fs4,
6087
+ dir
6088
+ }) => {
6089
+ dir = await findGitRoot(dir);
6090
+ return import_isomorphic_git.default.resolveRef({
6091
+ fs: fs4,
6092
+ dir,
6093
+ ref: "HEAD"
6094
+ });
6095
+ };
6096
+ var getChangedFiles = async ({
6097
+ fs: fs4,
6098
+ dir,
6099
+ from,
6100
+ to,
6101
+ pathFilter
6102
+ }) => {
6103
+ const results = {
6104
+ added: [],
6105
+ modified: [],
6106
+ deleted: []
6107
+ };
6108
+ const rootDir = await findGitRoot(dir);
6109
+ let pathPrefix = "";
6110
+ if (rootDir !== dir) {
6111
+ pathPrefix = (0, import_schema_tools3.normalizePath)(dir.substring(rootDir.length + 1));
6112
+ }
6113
+ await import_isomorphic_git.default.walk({
6114
+ fs: fs4,
6115
+ dir: rootDir,
6116
+ trees: [import_isomorphic_git.default.TREE({ ref: from }), import_isomorphic_git.default.TREE({ ref: to })],
6117
+ map: async function(filename, [A, B]) {
6118
+ const relativePath = (0, import_schema_tools3.normalizePath)(filename).substring(pathPrefix.length);
6119
+ let matches = false;
6120
+ for (const [key, matcher] of Object.entries(pathFilter)) {
6121
+ if (relativePath.startsWith(key)) {
6122
+ if (!matcher.matches) {
6123
+ matches = true;
6124
+ } else {
6125
+ if (import_micromatch3.default.isMatch(relativePath, matcher.matches)) {
6126
+ matches = true;
6127
+ break;
6128
+ }
6129
+ }
6130
+ }
6131
+ }
6132
+ if (await (B == null ? void 0 : B.type()) === "tree") {
6133
+ return;
6134
+ }
6135
+ if (matches) {
6136
+ let oidA = await (A == null ? void 0 : A.oid());
6137
+ let oidB = await (B == null ? void 0 : B.oid());
6138
+ if (oidA !== oidB) {
6139
+ if (oidA === void 0) {
6140
+ results.added.push(relativePath);
6141
+ } else if (oidB === void 0) {
6142
+ results.deleted.push(relativePath);
6143
+ } else {
6144
+ results.modified.push(relativePath);
6145
+ }
6146
+ }
6147
+ }
6148
+ }
6149
+ });
6150
+ return results;
6151
+ };
6152
+
6153
+ // src/database/bridge/filesystem.ts
6154
+ var import_fs_extra2 = __toESM(require("fs-extra"));
6155
+ var import_fast_glob = __toESM(require("fast-glob"));
6156
+ var import_path6 = __toESM(require("path"));
6098
6157
  var import_normalize_path = __toESM(require("normalize-path"));
6099
6158
  var FilesystemBridge = class {
6100
6159
  constructor(rootPath, outputPath) {
@@ -6102,9 +6161,9 @@ var FilesystemBridge = class {
6102
6161
  this.outputPath = outputPath || rootPath;
6103
6162
  }
6104
6163
  async glob(pattern, extension) {
6105
- const basePath = import_path5.default.join(this.outputPath, ...pattern.split("/"));
6164
+ const basePath = import_path6.default.join(this.outputPath, ...pattern.split("/"));
6106
6165
  const items = await (0, import_fast_glob.default)(
6107
- import_path5.default.join(basePath, "**", `/*.${extension}`).replace(/\\/g, "/"),
6166
+ import_path6.default.join(basePath, "**", `/*.${extension}`).replace(/\\/g, "/"),
6108
6167
  {
6109
6168
  dot: true,
6110
6169
  ignore: ["**/node_modules/**"]
@@ -6116,14 +6175,14 @@ var FilesystemBridge = class {
6116
6175
  });
6117
6176
  }
6118
6177
  async delete(filepath) {
6119
- await import_fs_extra.default.remove(import_path5.default.join(this.outputPath, filepath));
6178
+ await import_fs_extra2.default.remove(import_path6.default.join(this.outputPath, filepath));
6120
6179
  }
6121
6180
  async get(filepath) {
6122
- return import_fs_extra.default.readFileSync(import_path5.default.join(this.outputPath, filepath)).toString();
6181
+ return import_fs_extra2.default.readFileSync(import_path6.default.join(this.outputPath, filepath)).toString();
6123
6182
  }
6124
6183
  async put(filepath, data, basePathOverride) {
6125
6184
  const basePath = basePathOverride || this.outputPath;
6126
- await import_fs_extra.default.outputFileSync(import_path5.default.join(basePath, filepath), data);
6185
+ await import_fs_extra2.default.outputFileSync(import_path6.default.join(basePath, filepath), data);
6127
6186
  }
6128
6187
  };
6129
6188
  var AuditFileSystemBridge = class extends FilesystemBridge {
@@ -6143,12 +6202,12 @@ var AuditFileSystemBridge = class extends FilesystemBridge {
6143
6202
  };
6144
6203
 
6145
6204
  // src/database/bridge/isomorphic.ts
6146
- var import_isomorphic_git = __toESM(require("isomorphic-git"));
6147
- var import_fs_extra2 = __toESM(require("fs-extra"));
6205
+ var import_isomorphic_git2 = __toESM(require("isomorphic-git"));
6206
+ var import_fs_extra3 = __toESM(require("fs-extra"));
6148
6207
  var import_glob_parent = __toESM(require("glob-parent"));
6149
6208
  var import_normalize_path2 = __toESM(require("normalize-path"));
6150
6209
  var import_graphql6 = require("graphql");
6151
- var import_path6 = require("path");
6210
+ var import_path7 = require("path");
6152
6211
  var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
6153
6212
  var toUint8Array = (buf) => {
6154
6213
  const ab = new ArrayBuffer(buf.length);
@@ -6163,7 +6222,7 @@ var IsomorphicBridge = class {
6163
6222
  gitRoot,
6164
6223
  author,
6165
6224
  committer,
6166
- fsModule = import_fs_extra2.default,
6225
+ fsModule = import_fs_extra3.default,
6167
6226
  commitMessage = "Update from GraphQL client",
6168
6227
  ref,
6169
6228
  onPut,
@@ -6207,17 +6266,17 @@ var IsomorphicBridge = class {
6207
6266
  async listEntries({
6208
6267
  pattern,
6209
6268
  entry,
6210
- path: path6,
6269
+ path: path7,
6211
6270
  results
6212
6271
  }) {
6213
- const treeResult = await import_isomorphic_git.default.readTree({
6272
+ const treeResult = await import_isomorphic_git2.default.readTree({
6214
6273
  ...this.isomorphicConfig,
6215
6274
  oid: entry.oid,
6216
6275
  cache: this.cache
6217
6276
  });
6218
6277
  const children = [];
6219
6278
  for (const childEntry of treeResult.tree) {
6220
- const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
6279
+ const childPath = path7 ? `${path7}/${childEntry.path}` : childEntry.path;
6221
6280
  if (childEntry.type === "tree") {
6222
6281
  children.push(childEntry);
6223
6282
  } else {
@@ -6227,7 +6286,7 @@ var IsomorphicBridge = class {
6227
6286
  }
6228
6287
  }
6229
6288
  for (const childEntry of children) {
6230
- const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
6289
+ const childPath = path7 ? `${path7}/${childEntry.path}` : childEntry.path;
6231
6290
  await this.listEntries({
6232
6291
  pattern,
6233
6292
  entry: childEntry,
@@ -6236,17 +6295,17 @@ var IsomorphicBridge = class {
6236
6295
  });
6237
6296
  }
6238
6297
  }
6239
- async resolvePathEntries(path6, ref) {
6240
- let pathParts = path6.split("/");
6241
- const result = await import_isomorphic_git.default.walk({
6298
+ async resolvePathEntries(path7, ref) {
6299
+ let pathParts = path7.split("/");
6300
+ const result = await import_isomorphic_git2.default.walk({
6242
6301
  ...this.isomorphicConfig,
6243
6302
  map: async (filepath, [head]) => {
6244
6303
  if (head._fullpath === ".") {
6245
6304
  return head;
6246
6305
  }
6247
- if (path6.startsWith(filepath)) {
6248
- if ((0, import_path6.dirname)(path6) === (0, import_path6.dirname)(filepath)) {
6249
- if (path6 === filepath) {
6306
+ if (path7.startsWith(filepath)) {
6307
+ if ((0, import_path7.dirname)(path7) === (0, import_path7.dirname)(filepath)) {
6308
+ if (path7 === filepath) {
6250
6309
  return head;
6251
6310
  }
6252
6311
  } else {
@@ -6255,7 +6314,7 @@ var IsomorphicBridge = class {
6255
6314
  }
6256
6315
  },
6257
6316
  cache: this.cache,
6258
- trees: [import_isomorphic_git.default.TREE({ ref })]
6317
+ trees: [import_isomorphic_git2.default.TREE({ ref })]
6259
6318
  });
6260
6319
  const pathEntries = flat(result);
6261
6320
  if (pathParts.indexOf(".") === -1) {
@@ -6266,7 +6325,7 @@ var IsomorphicBridge = class {
6266
6325
  }
6267
6326
  return { pathParts, pathEntries };
6268
6327
  }
6269
- async updateTreeHierarchy(existingOid, updatedOid, path6, type, pathEntries, pathParts) {
6328
+ async updateTreeHierarchy(existingOid, updatedOid, path7, type, pathEntries, pathParts) {
6270
6329
  const lastIdx = pathEntries.length - 1;
6271
6330
  const parentEntry = pathEntries[lastIdx];
6272
6331
  const parentPath = pathParts[lastIdx];
@@ -6275,13 +6334,13 @@ var IsomorphicBridge = class {
6275
6334
  const mode = type === "blob" ? "100644" : "040000";
6276
6335
  if (parentEntry) {
6277
6336
  parentOid = await parentEntry.oid();
6278
- const treeResult = await import_isomorphic_git.default.readTree({
6337
+ const treeResult = await import_isomorphic_git2.default.readTree({
6279
6338
  ...this.isomorphicConfig,
6280
6339
  oid: parentOid,
6281
6340
  cache: this.cache
6282
6341
  });
6283
6342
  tree = existingOid ? treeResult.tree.map((entry) => {
6284
- if (entry.path === path6) {
6343
+ if (entry.path === path7) {
6285
6344
  entry.oid = updatedOid;
6286
6345
  }
6287
6346
  return entry;
@@ -6290,7 +6349,7 @@ var IsomorphicBridge = class {
6290
6349
  {
6291
6350
  oid: updatedOid,
6292
6351
  type,
6293
- path: path6,
6352
+ path: path7,
6294
6353
  mode
6295
6354
  }
6296
6355
  ];
@@ -6299,12 +6358,12 @@ var IsomorphicBridge = class {
6299
6358
  {
6300
6359
  oid: updatedOid,
6301
6360
  type,
6302
- path: path6,
6361
+ path: path7,
6303
6362
  mode
6304
6363
  }
6305
6364
  ];
6306
6365
  }
6307
- const updatedParentOid = await import_isomorphic_git.default.writeTree({
6366
+ const updatedParentOid = await import_isomorphic_git2.default.writeTree({
6308
6367
  ...this.isomorphicConfig,
6309
6368
  tree
6310
6369
  });
@@ -6322,12 +6381,12 @@ var IsomorphicBridge = class {
6322
6381
  }
6323
6382
  }
6324
6383
  async commitTree(treeSha, ref) {
6325
- const commitSha = await import_isomorphic_git.default.writeCommit({
6384
+ const commitSha = await import_isomorphic_git2.default.writeCommit({
6326
6385
  ...this.isomorphicConfig,
6327
6386
  commit: {
6328
6387
  tree: treeSha,
6329
6388
  parent: [
6330
- await import_isomorphic_git.default.resolveRef({
6389
+ await import_isomorphic_git2.default.resolveRef({
6331
6390
  ...this.isomorphicConfig,
6332
6391
  ref
6333
6392
  })
@@ -6337,7 +6396,7 @@ var IsomorphicBridge = class {
6337
6396
  committer: this.getCommitter()
6338
6397
  }
6339
6398
  });
6340
- await import_isomorphic_git.default.writeRef({
6399
+ await import_isomorphic_git2.default.writeRef({
6341
6400
  ...this.isomorphicConfig,
6342
6401
  ref,
6343
6402
  value: commitSha,
@@ -6348,7 +6407,7 @@ var IsomorphicBridge = class {
6348
6407
  if (this.ref) {
6349
6408
  return this.ref;
6350
6409
  }
6351
- const ref = await import_isomorphic_git.default.currentBranch({
6410
+ const ref = await import_isomorphic_git2.default.currentBranch({
6352
6411
  ...this.isomorphicConfig,
6353
6412
  fullname: true
6354
6413
  });
@@ -6379,7 +6438,7 @@ var IsomorphicBridge = class {
6379
6438
  let treeEntry;
6380
6439
  let parentPath;
6381
6440
  if (parentEntry) {
6382
- const treeResult = await import_isomorphic_git.default.readTree({
6441
+ const treeResult = await import_isomorphic_git2.default.readTree({
6383
6442
  ...this.isomorphicConfig,
6384
6443
  oid: await parentEntry.oid(),
6385
6444
  cache: this.cache
@@ -6400,7 +6459,7 @@ var IsomorphicBridge = class {
6400
6459
  path: parentPath,
6401
6460
  results
6402
6461
  });
6403
- return results.map((path6) => this.unqualifyPath(path6)).filter((path6) => path6.endsWith(extension));
6462
+ return results.map((path7) => this.unqualifyPath(path7)).filter((path7) => path7.endsWith(extension));
6404
6463
  }
6405
6464
  async delete(filepath) {
6406
6465
  const ref = await this.getRef();
@@ -6417,7 +6476,7 @@ var IsomorphicBridge = class {
6417
6476
  oidToRemove = oidToRemove || await leafEntry.oid();
6418
6477
  const parentEntry = pathEntries[ptr - 1];
6419
6478
  const existingOid = await parentEntry.oid();
6420
- const treeResult = await import_isomorphic_git.default.readTree({
6479
+ const treeResult = await import_isomorphic_git2.default.readTree({
6421
6480
  ...this.isomorphicConfig,
6422
6481
  oid: existingOid,
6423
6482
  cache: this.cache
@@ -6429,7 +6488,7 @@ var IsomorphicBridge = class {
6429
6488
  ptr -= 1;
6430
6489
  continue;
6431
6490
  }
6432
- const updatedTreeOid = await import_isomorphic_git.default.writeTree({
6491
+ const updatedTreeOid = await import_isomorphic_git2.default.writeTree({
6433
6492
  ...this.isomorphicConfig,
6434
6493
  tree: updatedTree
6435
6494
  });
@@ -6456,7 +6515,7 @@ var IsomorphicBridge = class {
6456
6515
  }
6457
6516
  }
6458
6517
  if (oidToRemove) {
6459
- await import_isomorphic_git.default.updateIndex({
6518
+ await import_isomorphic_git2.default.updateIndex({
6460
6519
  ...this.isomorphicConfig,
6461
6520
  filepath: this.qualifyPath(filepath),
6462
6521
  force: true,
@@ -6475,11 +6534,11 @@ var IsomorphicBridge = class {
6475
6534
  }
6476
6535
  async get(filepath) {
6477
6536
  const ref = await this.getRef();
6478
- const oid = await import_isomorphic_git.default.resolveRef({
6537
+ const oid = await import_isomorphic_git2.default.resolveRef({
6479
6538
  ...this.isomorphicConfig,
6480
6539
  ref
6481
6540
  });
6482
- const { blob } = await import_isomorphic_git.default.readBlob({
6541
+ const { blob } = await import_isomorphic_git2.default.readBlob({
6483
6542
  ...this.isomorphicConfig,
6484
6543
  oid,
6485
6544
  filepath: this.qualifyPath(filepath),
@@ -6499,13 +6558,13 @@ var IsomorphicBridge = class {
6499
6558
  const nodePath = pathParts[pathParts.length - 1];
6500
6559
  if (leafEntry) {
6501
6560
  existingOid = await leafEntry.oid();
6502
- const hash = await import_isomorphic_git.default.hashBlob({ object: blobUpdate });
6561
+ const hash = await import_isomorphic_git2.default.hashBlob({ object: blobUpdate });
6503
6562
  if (hash.oid === existingOid) {
6504
6563
  await this.onPut(filepath, data);
6505
6564
  return;
6506
6565
  }
6507
6566
  }
6508
- const updatedOid = await import_isomorphic_git.default.writeBlob({
6567
+ const updatedOid = await import_isomorphic_git2.default.writeBlob({
6509
6568
  ...this.isomorphicConfig,
6510
6569
  blob: blobUpdate
6511
6570
  });
@@ -6518,7 +6577,7 @@ var IsomorphicBridge = class {
6518
6577
  pathParts.slice(0, pathParts.length - 1)
6519
6578
  );
6520
6579
  await this.commitTree(updatedRootSha, ref);
6521
- await import_isomorphic_git.default.updateIndex({
6580
+ await import_isomorphic_git2.default.updateIndex({
6522
6581
  ...this.isomorphicConfig,
6523
6582
  filepath: this.qualifyPath(filepath),
6524
6583
  add: true,
@@ -6551,6 +6610,8 @@ var buildSchema = async (config, flags) => {
6551
6610
  buildSchema,
6552
6611
  createDatabase,
6553
6612
  createSchema,
6613
+ getChangedFiles,
6614
+ getSha,
6554
6615
  handleFetchErrorError,
6555
6616
  loadAndParseWithAliases,
6556
6617
  parseFile,
package/dist/util.d.ts CHANGED
@@ -13,7 +13,7 @@ import * as yup from 'yup';
13
13
  * ```
14
14
  */
15
15
  export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
16
- export declare function assertShape<T extends unknown>(value: unknown, yupSchema: (args: typeof yup) => yup.AnySchema, errorMessage?: string): asserts value is T;
16
+ export declare function assertShape<T>(value: unknown, yupSchema: (args: typeof yup) => yup.AnySchema, errorMessage?: string): asserts value is T;
17
17
  export declare const atob: (b64Encoded: string) => string;
18
18
  export declare const btoa: (string: string) => string;
19
19
  export declare const lastItem: (arr: (number | string)[]) => string | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "typings": "dist/index.d.ts",
@@ -23,57 +23,30 @@
23
23
  ]
24
24
  },
25
25
  "dependencies": {
26
- "@graphql-tools/relay-operation-optimizer": "^6.4.1",
27
26
  "@iarna/toml": "^2.2.5",
28
- "@tinacms/mdx": "1.3.13",
29
- "@tinacms/schema-tools": "1.4.7",
27
+ "@tinacms/mdx": "1.3.14",
28
+ "@tinacms/schema-tools": "1.4.8",
30
29
  "abstract-level": "^1.0.3",
31
30
  "body-parser": "^1.19.0",
32
31
  "cors": "^2.8.5",
33
32
  "dataloader": "^2.0.0",
34
33
  "date-fns": "^2.21.1",
35
34
  "encoding-down": "^7.1.0",
36
- "esbuild": "^0.15.5",
37
- "esbuild-jest": "^0.5.0",
38
35
  "estree-walker": "^3.0.0",
39
36
  "fast-glob": "^3.2.5",
40
- "flat": "^5.0.2",
41
37
  "fs-extra": "^9.0.1",
42
38
  "glob-parent": "^6.0.2",
43
39
  "graphql": "15.8.0",
44
- "graphql-type-json": "^0.3.2",
45
40
  "gray-matter": "^4.0.2",
46
41
  "isomorphic-git": "^1.21.0",
47
42
  "js-sha1": "^0.6.0",
48
43
  "js-yaml": "^3.14.1",
49
44
  "jsonpath-plus": "^6.0.1",
50
- "leveldown": "^6.1.0",
51
45
  "lodash": "^4.17.20",
52
46
  "many-level": "^2.0.0",
53
- "mdast": "^3.0.0",
54
- "mdast-util-from-markdown": "^1.0.0",
55
- "mdast-util-mdx": "^1.1.0",
56
- "mdast-util-mdx-expression": "^1.1.0",
57
- "mdast-util-to-markdown": "^1.2.1",
58
- "micromark-extension-mdxjs": "^1.0.0",
59
47
  "micromatch": "4.0.5",
60
48
  "normalize-path": "^3.0.0",
61
- "prettier": "^2.2.1",
62
49
  "readable-stream": "^4.3.0",
63
- "rehype-format": "^3.1.0",
64
- "rehype-stringify": "^8.0.0",
65
- "remark": "^13.0.0",
66
- "remark-frontmatter": "^3.0.0",
67
- "remark-mdx": "next",
68
- "remark-parse": "^10.0.0",
69
- "remark-rehype": "^8.0.0",
70
- "remark-slate": "^1.8.0",
71
- "remark-stringify": "^8.1.1",
72
- "unified": "^10.1.0",
73
- "unist-util-remove-position": "^3.0.0",
74
- "unist-util-visit": "^4.0.0",
75
- "vfile": "^4.2.0",
76
- "ws": "^7.3.1",
77
50
  "yup": "^0.32.9"
78
51
  },
79
52
  "publishConfig": {
@@ -84,7 +57,7 @@
84
57
  "directory": "packages/tina-graphql"
85
58
  },
86
59
  "devDependencies": {
87
- "@tinacms/schema-tools": "1.4.7",
60
+ "@tinacms/schema-tools": "1.4.8",
88
61
  "@tinacms/scripts": "1.1.0",
89
62
  "@types/cors": "^2.8.7",
90
63
  "@types/estree": "^0.0.50",
@@ -102,10 +75,10 @@
102
75
  "@types/normalize-path": "^3.0.0",
103
76
  "@types/ws": "^7.2.6",
104
77
  "@types/yup": "^0.29.7",
105
- "jest": "27.0.6",
106
- "jest-diff": "27.0.6",
78
+ "jest": "^29.5.0",
79
+ "jest-diff": "^29.5.0",
107
80
  "jest-file-snapshot": "^0.5.0",
108
- "jest-matcher-utils": "27.0.6",
81
+ "jest-matcher-utils": "^29.5.0",
109
82
  "memory-level": "^1.0.0",
110
83
  "nodemon": "2.0.19",
111
84
  "typescript": "4.3.5"