@tinacms/graphql 0.0.0-20230627202513 → 0.0.0-20230627221909
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/database/index.d.ts +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +59 -157
- package/dist/{index.es.js → index.mjs} +58 -154
- package/package.json +9 -9
- package/dist/git/index.d.ts +0 -18
package/dist/database/index.d.ts
CHANGED
|
@@ -50,8 +50,6 @@ 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>;
|
|
55
53
|
get: <T extends object>(filepath: string) => Promise<T>;
|
|
56
54
|
addPendingDocument: (filepath: string, data: {
|
|
57
55
|
[key: string]: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ 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';
|
|
11
10
|
export { sequential, assertShape } from './util';
|
|
12
11
|
export { loadAndParseWithAliases, stringifyFile, parseFile, scanAllContent, scanContentByPaths, transformDocument, } from './database/util';
|
|
13
12
|
export { createSchema } from './schema/createSchema';
|
package/dist/index.js
CHANGED
|
@@ -38,8 +38,6 @@ __export(src_exports, {
|
|
|
38
38
|
buildSchema: () => buildSchema,
|
|
39
39
|
createDatabase: () => createDatabase,
|
|
40
40
|
createSchema: () => createSchema,
|
|
41
|
-
getChangedFiles: () => getChangedFiles,
|
|
42
|
-
getSha: () => getSha,
|
|
43
41
|
handleFetchErrorError: () => handleFetchErrorError,
|
|
44
42
|
loadAndParseWithAliases: () => loadAndParseWithAliases,
|
|
45
43
|
parseFile: () => parseFile,
|
|
@@ -2587,14 +2585,14 @@ var package_default = {
|
|
|
2587
2585
|
name: "@tinacms/graphql",
|
|
2588
2586
|
version: "1.4.18",
|
|
2589
2587
|
main: "dist/index.js",
|
|
2590
|
-
module: "dist/index.
|
|
2588
|
+
module: "dist/index.mjs",
|
|
2591
2589
|
typings: "dist/index.d.ts",
|
|
2592
2590
|
files: [
|
|
2593
2591
|
"package.json",
|
|
2594
2592
|
"dist"
|
|
2595
2593
|
],
|
|
2596
2594
|
exports: {
|
|
2597
|
-
import: "./dist/index.
|
|
2595
|
+
import: "./dist/index.mjs",
|
|
2598
2596
|
require: "./dist/index.js"
|
|
2599
2597
|
},
|
|
2600
2598
|
license: "SEE LICENSE IN LICENSE",
|
|
@@ -3093,9 +3091,9 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
|
|
|
3093
3091
|
return value;
|
|
3094
3092
|
}
|
|
3095
3093
|
};
|
|
3096
|
-
var cleanUpSlashes = (
|
|
3097
|
-
if (
|
|
3098
|
-
return `/${
|
|
3094
|
+
var cleanUpSlashes = (path6) => {
|
|
3095
|
+
if (path6) {
|
|
3096
|
+
return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
|
|
3099
3097
|
}
|
|
3100
3098
|
return "";
|
|
3101
3099
|
};
|
|
@@ -3382,17 +3380,17 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
|
3382
3380
|
const documentPaths = await bridge.glob(normalPath, format);
|
|
3383
3381
|
const matches = tinaSchema.getMatches({ collection });
|
|
3384
3382
|
const filteredPaths = matches.length > 0 ? (0, import_micromatch.default)(documentPaths, matches) : documentPaths;
|
|
3385
|
-
filteredPaths.forEach((
|
|
3386
|
-
if (filesSeen.has(
|
|
3387
|
-
filesSeen.get(
|
|
3388
|
-
duplicateFiles.add(
|
|
3383
|
+
filteredPaths.forEach((path6) => {
|
|
3384
|
+
if (filesSeen.has(path6)) {
|
|
3385
|
+
filesSeen.get(path6).push(collection.name);
|
|
3386
|
+
duplicateFiles.add(path6);
|
|
3389
3387
|
} else {
|
|
3390
|
-
filesSeen.set(
|
|
3388
|
+
filesSeen.set(path6, [collection.name]);
|
|
3391
3389
|
}
|
|
3392
3390
|
});
|
|
3393
|
-
duplicateFiles.forEach((
|
|
3391
|
+
duplicateFiles.forEach((path6) => {
|
|
3394
3392
|
warnings.push(
|
|
3395
|
-
`"${
|
|
3393
|
+
`"${path6}" Found in multiple collections: ${filesSeen.get(path6).map((collection2) => `"${collection2}"`).join(
|
|
3396
3394
|
", "
|
|
3397
3395
|
)}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
|
|
3398
3396
|
This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
|
|
@@ -3952,9 +3950,9 @@ var makeFilterSuffixes = (filterChain, index) => {
|
|
|
3952
3950
|
}
|
|
3953
3951
|
};
|
|
3954
3952
|
var FOLDER_ROOT = "~";
|
|
3955
|
-
var stripCollectionFromPath = (collectionPath,
|
|
3953
|
+
var stripCollectionFromPath = (collectionPath, path6) => {
|
|
3956
3954
|
const collectionPathParts = collectionPath.split("/");
|
|
3957
|
-
const pathParts =
|
|
3955
|
+
const pathParts = path6.split("/");
|
|
3958
3956
|
const strippedPathParts = pathParts.slice(collectionPathParts.length);
|
|
3959
3957
|
return strippedPathParts.join("/");
|
|
3960
3958
|
};
|
|
@@ -4009,13 +4007,13 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
|
|
|
4009
4007
|
SUBLEVEL_OPTIONS
|
|
4010
4008
|
);
|
|
4011
4009
|
let folderSortingIdx = 0;
|
|
4012
|
-
for (const
|
|
4010
|
+
for (const path6 of Array.from(folder).sort()) {
|
|
4013
4011
|
for (const [sort] of Object.entries(indexDefinitions)) {
|
|
4014
4012
|
const indexSublevel = folderCollectionSublevel.sublevel(
|
|
4015
4013
|
sort,
|
|
4016
4014
|
SUBLEVEL_OPTIONS
|
|
4017
4015
|
);
|
|
4018
|
-
const subFolderKey = import_js_sha1.default.hex(
|
|
4016
|
+
const subFolderKey = import_js_sha1.default.hex(path6);
|
|
4019
4017
|
if (sort === DEFAULT_COLLECTION_SORT_KEY) {
|
|
4020
4018
|
result.push({
|
|
4021
4019
|
type: opType,
|
|
@@ -4634,7 +4632,7 @@ var Resolver = class {
|
|
|
4634
4632
|
first: -1
|
|
4635
4633
|
},
|
|
4636
4634
|
collection: referencedCollection,
|
|
4637
|
-
hydrator: (
|
|
4635
|
+
hydrator: (path6) => path6
|
|
4638
4636
|
}
|
|
4639
4637
|
);
|
|
4640
4638
|
const { edges } = resolvedCollectionConnection;
|
|
@@ -5086,17 +5084,6 @@ var Database = class {
|
|
|
5086
5084
|
}
|
|
5087
5085
|
};
|
|
5088
5086
|
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
|
-
};
|
|
5100
5087
|
this.get = async (filepath) => {
|
|
5101
5088
|
await this.initLevel();
|
|
5102
5089
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
@@ -6067,93 +6054,10 @@ var TinaLevelClient = class extends import_many_level.ManyLevelGuest {
|
|
|
6067
6054
|
}
|
|
6068
6055
|
};
|
|
6069
6056
|
|
|
6070
|
-
// src/git/index.ts
|
|
6071
|
-
var import_isomorphic_git = __toESM(require("isomorphic-git"));
|
|
6072
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
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
6057
|
// src/database/bridge/filesystem.ts
|
|
6154
|
-
var
|
|
6058
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
6155
6059
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
6156
|
-
var
|
|
6060
|
+
var import_path5 = __toESM(require("path"));
|
|
6157
6061
|
var import_normalize_path = __toESM(require("normalize-path"));
|
|
6158
6062
|
var FilesystemBridge = class {
|
|
6159
6063
|
constructor(rootPath, outputPath) {
|
|
@@ -6161,9 +6065,9 @@ var FilesystemBridge = class {
|
|
|
6161
6065
|
this.outputPath = outputPath || rootPath;
|
|
6162
6066
|
}
|
|
6163
6067
|
async glob(pattern, extension) {
|
|
6164
|
-
const basePath =
|
|
6068
|
+
const basePath = import_path5.default.join(this.outputPath, ...pattern.split("/"));
|
|
6165
6069
|
const items = await (0, import_fast_glob.default)(
|
|
6166
|
-
|
|
6070
|
+
import_path5.default.join(basePath, "**", `/*.${extension}`).replace(/\\/g, "/"),
|
|
6167
6071
|
{
|
|
6168
6072
|
dot: true,
|
|
6169
6073
|
ignore: ["**/node_modules/**"]
|
|
@@ -6175,14 +6079,14 @@ var FilesystemBridge = class {
|
|
|
6175
6079
|
});
|
|
6176
6080
|
}
|
|
6177
6081
|
async delete(filepath) {
|
|
6178
|
-
await
|
|
6082
|
+
await import_fs_extra.default.remove(import_path5.default.join(this.outputPath, filepath));
|
|
6179
6083
|
}
|
|
6180
6084
|
async get(filepath) {
|
|
6181
|
-
return
|
|
6085
|
+
return import_fs_extra.default.readFileSync(import_path5.default.join(this.outputPath, filepath)).toString();
|
|
6182
6086
|
}
|
|
6183
6087
|
async put(filepath, data, basePathOverride) {
|
|
6184
6088
|
const basePath = basePathOverride || this.outputPath;
|
|
6185
|
-
await
|
|
6089
|
+
await import_fs_extra.default.outputFileSync(import_path5.default.join(basePath, filepath), data);
|
|
6186
6090
|
}
|
|
6187
6091
|
};
|
|
6188
6092
|
var AuditFileSystemBridge = class extends FilesystemBridge {
|
|
@@ -6202,12 +6106,12 @@ var AuditFileSystemBridge = class extends FilesystemBridge {
|
|
|
6202
6106
|
};
|
|
6203
6107
|
|
|
6204
6108
|
// src/database/bridge/isomorphic.ts
|
|
6205
|
-
var
|
|
6206
|
-
var
|
|
6109
|
+
var import_isomorphic_git = __toESM(require("isomorphic-git"));
|
|
6110
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
6207
6111
|
var import_glob_parent = __toESM(require("glob-parent"));
|
|
6208
6112
|
var import_normalize_path2 = __toESM(require("normalize-path"));
|
|
6209
6113
|
var import_graphql6 = require("graphql");
|
|
6210
|
-
var
|
|
6114
|
+
var import_path6 = require("path");
|
|
6211
6115
|
var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
|
|
6212
6116
|
var toUint8Array = (buf) => {
|
|
6213
6117
|
const ab = new ArrayBuffer(buf.length);
|
|
@@ -6222,7 +6126,7 @@ var IsomorphicBridge = class {
|
|
|
6222
6126
|
gitRoot,
|
|
6223
6127
|
author,
|
|
6224
6128
|
committer,
|
|
6225
|
-
fsModule =
|
|
6129
|
+
fsModule = import_fs_extra2.default,
|
|
6226
6130
|
commitMessage = "Update from GraphQL client",
|
|
6227
6131
|
ref,
|
|
6228
6132
|
onPut,
|
|
@@ -6266,17 +6170,17 @@ var IsomorphicBridge = class {
|
|
|
6266
6170
|
async listEntries({
|
|
6267
6171
|
pattern,
|
|
6268
6172
|
entry,
|
|
6269
|
-
path:
|
|
6173
|
+
path: path6,
|
|
6270
6174
|
results
|
|
6271
6175
|
}) {
|
|
6272
|
-
const treeResult = await
|
|
6176
|
+
const treeResult = await import_isomorphic_git.default.readTree({
|
|
6273
6177
|
...this.isomorphicConfig,
|
|
6274
6178
|
oid: entry.oid,
|
|
6275
6179
|
cache: this.cache
|
|
6276
6180
|
});
|
|
6277
6181
|
const children = [];
|
|
6278
6182
|
for (const childEntry of treeResult.tree) {
|
|
6279
|
-
const childPath =
|
|
6183
|
+
const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
|
|
6280
6184
|
if (childEntry.type === "tree") {
|
|
6281
6185
|
children.push(childEntry);
|
|
6282
6186
|
} else {
|
|
@@ -6286,7 +6190,7 @@ var IsomorphicBridge = class {
|
|
|
6286
6190
|
}
|
|
6287
6191
|
}
|
|
6288
6192
|
for (const childEntry of children) {
|
|
6289
|
-
const childPath =
|
|
6193
|
+
const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
|
|
6290
6194
|
await this.listEntries({
|
|
6291
6195
|
pattern,
|
|
6292
6196
|
entry: childEntry,
|
|
@@ -6295,17 +6199,17 @@ var IsomorphicBridge = class {
|
|
|
6295
6199
|
});
|
|
6296
6200
|
}
|
|
6297
6201
|
}
|
|
6298
|
-
async resolvePathEntries(
|
|
6299
|
-
let pathParts =
|
|
6300
|
-
const result = await
|
|
6202
|
+
async resolvePathEntries(path6, ref) {
|
|
6203
|
+
let pathParts = path6.split("/");
|
|
6204
|
+
const result = await import_isomorphic_git.default.walk({
|
|
6301
6205
|
...this.isomorphicConfig,
|
|
6302
6206
|
map: async (filepath, [head]) => {
|
|
6303
6207
|
if (head._fullpath === ".") {
|
|
6304
6208
|
return head;
|
|
6305
6209
|
}
|
|
6306
|
-
if (
|
|
6307
|
-
if ((0,
|
|
6308
|
-
if (
|
|
6210
|
+
if (path6.startsWith(filepath)) {
|
|
6211
|
+
if ((0, import_path6.dirname)(path6) === (0, import_path6.dirname)(filepath)) {
|
|
6212
|
+
if (path6 === filepath) {
|
|
6309
6213
|
return head;
|
|
6310
6214
|
}
|
|
6311
6215
|
} else {
|
|
@@ -6314,7 +6218,7 @@ var IsomorphicBridge = class {
|
|
|
6314
6218
|
}
|
|
6315
6219
|
},
|
|
6316
6220
|
cache: this.cache,
|
|
6317
|
-
trees: [
|
|
6221
|
+
trees: [import_isomorphic_git.default.TREE({ ref })]
|
|
6318
6222
|
});
|
|
6319
6223
|
const pathEntries = flat(result);
|
|
6320
6224
|
if (pathParts.indexOf(".") === -1) {
|
|
@@ -6325,7 +6229,7 @@ var IsomorphicBridge = class {
|
|
|
6325
6229
|
}
|
|
6326
6230
|
return { pathParts, pathEntries };
|
|
6327
6231
|
}
|
|
6328
|
-
async updateTreeHierarchy(existingOid, updatedOid,
|
|
6232
|
+
async updateTreeHierarchy(existingOid, updatedOid, path6, type, pathEntries, pathParts) {
|
|
6329
6233
|
const lastIdx = pathEntries.length - 1;
|
|
6330
6234
|
const parentEntry = pathEntries[lastIdx];
|
|
6331
6235
|
const parentPath = pathParts[lastIdx];
|
|
@@ -6334,13 +6238,13 @@ var IsomorphicBridge = class {
|
|
|
6334
6238
|
const mode = type === "blob" ? "100644" : "040000";
|
|
6335
6239
|
if (parentEntry) {
|
|
6336
6240
|
parentOid = await parentEntry.oid();
|
|
6337
|
-
const treeResult = await
|
|
6241
|
+
const treeResult = await import_isomorphic_git.default.readTree({
|
|
6338
6242
|
...this.isomorphicConfig,
|
|
6339
6243
|
oid: parentOid,
|
|
6340
6244
|
cache: this.cache
|
|
6341
6245
|
});
|
|
6342
6246
|
tree = existingOid ? treeResult.tree.map((entry) => {
|
|
6343
|
-
if (entry.path ===
|
|
6247
|
+
if (entry.path === path6) {
|
|
6344
6248
|
entry.oid = updatedOid;
|
|
6345
6249
|
}
|
|
6346
6250
|
return entry;
|
|
@@ -6349,7 +6253,7 @@ var IsomorphicBridge = class {
|
|
|
6349
6253
|
{
|
|
6350
6254
|
oid: updatedOid,
|
|
6351
6255
|
type,
|
|
6352
|
-
path:
|
|
6256
|
+
path: path6,
|
|
6353
6257
|
mode
|
|
6354
6258
|
}
|
|
6355
6259
|
];
|
|
@@ -6358,12 +6262,12 @@ var IsomorphicBridge = class {
|
|
|
6358
6262
|
{
|
|
6359
6263
|
oid: updatedOid,
|
|
6360
6264
|
type,
|
|
6361
|
-
path:
|
|
6265
|
+
path: path6,
|
|
6362
6266
|
mode
|
|
6363
6267
|
}
|
|
6364
6268
|
];
|
|
6365
6269
|
}
|
|
6366
|
-
const updatedParentOid = await
|
|
6270
|
+
const updatedParentOid = await import_isomorphic_git.default.writeTree({
|
|
6367
6271
|
...this.isomorphicConfig,
|
|
6368
6272
|
tree
|
|
6369
6273
|
});
|
|
@@ -6381,12 +6285,12 @@ var IsomorphicBridge = class {
|
|
|
6381
6285
|
}
|
|
6382
6286
|
}
|
|
6383
6287
|
async commitTree(treeSha, ref) {
|
|
6384
|
-
const commitSha = await
|
|
6288
|
+
const commitSha = await import_isomorphic_git.default.writeCommit({
|
|
6385
6289
|
...this.isomorphicConfig,
|
|
6386
6290
|
commit: {
|
|
6387
6291
|
tree: treeSha,
|
|
6388
6292
|
parent: [
|
|
6389
|
-
await
|
|
6293
|
+
await import_isomorphic_git.default.resolveRef({
|
|
6390
6294
|
...this.isomorphicConfig,
|
|
6391
6295
|
ref
|
|
6392
6296
|
})
|
|
@@ -6396,7 +6300,7 @@ var IsomorphicBridge = class {
|
|
|
6396
6300
|
committer: this.getCommitter()
|
|
6397
6301
|
}
|
|
6398
6302
|
});
|
|
6399
|
-
await
|
|
6303
|
+
await import_isomorphic_git.default.writeRef({
|
|
6400
6304
|
...this.isomorphicConfig,
|
|
6401
6305
|
ref,
|
|
6402
6306
|
value: commitSha,
|
|
@@ -6407,7 +6311,7 @@ var IsomorphicBridge = class {
|
|
|
6407
6311
|
if (this.ref) {
|
|
6408
6312
|
return this.ref;
|
|
6409
6313
|
}
|
|
6410
|
-
const ref = await
|
|
6314
|
+
const ref = await import_isomorphic_git.default.currentBranch({
|
|
6411
6315
|
...this.isomorphicConfig,
|
|
6412
6316
|
fullname: true
|
|
6413
6317
|
});
|
|
@@ -6438,7 +6342,7 @@ var IsomorphicBridge = class {
|
|
|
6438
6342
|
let treeEntry;
|
|
6439
6343
|
let parentPath;
|
|
6440
6344
|
if (parentEntry) {
|
|
6441
|
-
const treeResult = await
|
|
6345
|
+
const treeResult = await import_isomorphic_git.default.readTree({
|
|
6442
6346
|
...this.isomorphicConfig,
|
|
6443
6347
|
oid: await parentEntry.oid(),
|
|
6444
6348
|
cache: this.cache
|
|
@@ -6459,7 +6363,7 @@ var IsomorphicBridge = class {
|
|
|
6459
6363
|
path: parentPath,
|
|
6460
6364
|
results
|
|
6461
6365
|
});
|
|
6462
|
-
return results.map((
|
|
6366
|
+
return results.map((path6) => this.unqualifyPath(path6)).filter((path6) => path6.endsWith(extension));
|
|
6463
6367
|
}
|
|
6464
6368
|
async delete(filepath) {
|
|
6465
6369
|
const ref = await this.getRef();
|
|
@@ -6476,7 +6380,7 @@ var IsomorphicBridge = class {
|
|
|
6476
6380
|
oidToRemove = oidToRemove || await leafEntry.oid();
|
|
6477
6381
|
const parentEntry = pathEntries[ptr - 1];
|
|
6478
6382
|
const existingOid = await parentEntry.oid();
|
|
6479
|
-
const treeResult = await
|
|
6383
|
+
const treeResult = await import_isomorphic_git.default.readTree({
|
|
6480
6384
|
...this.isomorphicConfig,
|
|
6481
6385
|
oid: existingOid,
|
|
6482
6386
|
cache: this.cache
|
|
@@ -6488,7 +6392,7 @@ var IsomorphicBridge = class {
|
|
|
6488
6392
|
ptr -= 1;
|
|
6489
6393
|
continue;
|
|
6490
6394
|
}
|
|
6491
|
-
const updatedTreeOid = await
|
|
6395
|
+
const updatedTreeOid = await import_isomorphic_git.default.writeTree({
|
|
6492
6396
|
...this.isomorphicConfig,
|
|
6493
6397
|
tree: updatedTree
|
|
6494
6398
|
});
|
|
@@ -6515,7 +6419,7 @@ var IsomorphicBridge = class {
|
|
|
6515
6419
|
}
|
|
6516
6420
|
}
|
|
6517
6421
|
if (oidToRemove) {
|
|
6518
|
-
await
|
|
6422
|
+
await import_isomorphic_git.default.updateIndex({
|
|
6519
6423
|
...this.isomorphicConfig,
|
|
6520
6424
|
filepath: this.qualifyPath(filepath),
|
|
6521
6425
|
force: true,
|
|
@@ -6534,11 +6438,11 @@ var IsomorphicBridge = class {
|
|
|
6534
6438
|
}
|
|
6535
6439
|
async get(filepath) {
|
|
6536
6440
|
const ref = await this.getRef();
|
|
6537
|
-
const oid = await
|
|
6441
|
+
const oid = await import_isomorphic_git.default.resolveRef({
|
|
6538
6442
|
...this.isomorphicConfig,
|
|
6539
6443
|
ref
|
|
6540
6444
|
});
|
|
6541
|
-
const { blob } = await
|
|
6445
|
+
const { blob } = await import_isomorphic_git.default.readBlob({
|
|
6542
6446
|
...this.isomorphicConfig,
|
|
6543
6447
|
oid,
|
|
6544
6448
|
filepath: this.qualifyPath(filepath),
|
|
@@ -6558,13 +6462,13 @@ var IsomorphicBridge = class {
|
|
|
6558
6462
|
const nodePath = pathParts[pathParts.length - 1];
|
|
6559
6463
|
if (leafEntry) {
|
|
6560
6464
|
existingOid = await leafEntry.oid();
|
|
6561
|
-
const hash = await
|
|
6465
|
+
const hash = await import_isomorphic_git.default.hashBlob({ object: blobUpdate });
|
|
6562
6466
|
if (hash.oid === existingOid) {
|
|
6563
6467
|
await this.onPut(filepath, data);
|
|
6564
6468
|
return;
|
|
6565
6469
|
}
|
|
6566
6470
|
}
|
|
6567
|
-
const updatedOid = await
|
|
6471
|
+
const updatedOid = await import_isomorphic_git.default.writeBlob({
|
|
6568
6472
|
...this.isomorphicConfig,
|
|
6569
6473
|
blob: blobUpdate
|
|
6570
6474
|
});
|
|
@@ -6577,7 +6481,7 @@ var IsomorphicBridge = class {
|
|
|
6577
6481
|
pathParts.slice(0, pathParts.length - 1)
|
|
6578
6482
|
);
|
|
6579
6483
|
await this.commitTree(updatedRootSha, ref);
|
|
6580
|
-
await
|
|
6484
|
+
await import_isomorphic_git.default.updateIndex({
|
|
6581
6485
|
...this.isomorphicConfig,
|
|
6582
6486
|
filepath: this.qualifyPath(filepath),
|
|
6583
6487
|
add: true,
|
|
@@ -6610,8 +6514,6 @@ var buildSchema = async (config, flags) => {
|
|
|
6610
6514
|
buildSchema,
|
|
6611
6515
|
createDatabase,
|
|
6612
6516
|
createSchema,
|
|
6613
|
-
getChangedFiles,
|
|
6614
|
-
getSha,
|
|
6615
6517
|
handleFetchErrorError,
|
|
6616
6518
|
loadAndParseWithAliases,
|
|
6617
6519
|
parseFile,
|
|
@@ -2528,14 +2528,14 @@ var package_default = {
|
|
|
2528
2528
|
name: "@tinacms/graphql",
|
|
2529
2529
|
version: "1.4.18",
|
|
2530
2530
|
main: "dist/index.js",
|
|
2531
|
-
module: "dist/index.
|
|
2531
|
+
module: "dist/index.mjs",
|
|
2532
2532
|
typings: "dist/index.d.ts",
|
|
2533
2533
|
files: [
|
|
2534
2534
|
"package.json",
|
|
2535
2535
|
"dist"
|
|
2536
2536
|
],
|
|
2537
2537
|
exports: {
|
|
2538
|
-
import: "./dist/index.
|
|
2538
|
+
import: "./dist/index.mjs",
|
|
2539
2539
|
require: "./dist/index.js"
|
|
2540
2540
|
},
|
|
2541
2541
|
license: "SEE LICENSE IN LICENSE",
|
|
@@ -3033,9 +3033,9 @@ var resolveMediaRelativeToCloud = (value, config = { useRelativeMedia: true }, s
|
|
|
3033
3033
|
return value;
|
|
3034
3034
|
}
|
|
3035
3035
|
};
|
|
3036
|
-
var cleanUpSlashes = (
|
|
3037
|
-
if (
|
|
3038
|
-
return `/${
|
|
3036
|
+
var cleanUpSlashes = (path6) => {
|
|
3037
|
+
if (path6) {
|
|
3038
|
+
return `/${path6.replace(/^\/+|\/+$/gm, "")}`;
|
|
3039
3039
|
}
|
|
3040
3040
|
return "";
|
|
3041
3041
|
};
|
|
@@ -3319,17 +3319,17 @@ var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
|
3319
3319
|
const documentPaths = await bridge.glob(normalPath, format);
|
|
3320
3320
|
const matches = tinaSchema.getMatches({ collection });
|
|
3321
3321
|
const filteredPaths = matches.length > 0 ? micromatch(documentPaths, matches) : documentPaths;
|
|
3322
|
-
filteredPaths.forEach((
|
|
3323
|
-
if (filesSeen.has(
|
|
3324
|
-
filesSeen.get(
|
|
3325
|
-
duplicateFiles.add(
|
|
3322
|
+
filteredPaths.forEach((path6) => {
|
|
3323
|
+
if (filesSeen.has(path6)) {
|
|
3324
|
+
filesSeen.get(path6).push(collection.name);
|
|
3325
|
+
duplicateFiles.add(path6);
|
|
3326
3326
|
} else {
|
|
3327
|
-
filesSeen.set(
|
|
3327
|
+
filesSeen.set(path6, [collection.name]);
|
|
3328
3328
|
}
|
|
3329
3329
|
});
|
|
3330
|
-
duplicateFiles.forEach((
|
|
3330
|
+
duplicateFiles.forEach((path6) => {
|
|
3331
3331
|
warnings.push(
|
|
3332
|
-
`"${
|
|
3332
|
+
`"${path6}" Found in multiple collections: ${filesSeen.get(path6).map((collection2) => `"${collection2}"`).join(
|
|
3333
3333
|
", "
|
|
3334
3334
|
)}. This can cause unexpected behavior. We recommend updating the \`match\` property of those collections so that each file is in only one collection.
|
|
3335
3335
|
This will be an error in the future. See https://tina.io/docs/errors/file-in-mutpliple-collections/
|
|
@@ -3889,9 +3889,9 @@ var makeFilterSuffixes = (filterChain, index) => {
|
|
|
3889
3889
|
}
|
|
3890
3890
|
};
|
|
3891
3891
|
var FOLDER_ROOT = "~";
|
|
3892
|
-
var stripCollectionFromPath = (collectionPath,
|
|
3892
|
+
var stripCollectionFromPath = (collectionPath, path6) => {
|
|
3893
3893
|
const collectionPathParts = collectionPath.split("/");
|
|
3894
|
-
const pathParts =
|
|
3894
|
+
const pathParts = path6.split("/");
|
|
3895
3895
|
const strippedPathParts = pathParts.slice(collectionPathParts.length);
|
|
3896
3896
|
return strippedPathParts.join("/");
|
|
3897
3897
|
};
|
|
@@ -3946,13 +3946,13 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
|
|
|
3946
3946
|
SUBLEVEL_OPTIONS
|
|
3947
3947
|
);
|
|
3948
3948
|
let folderSortingIdx = 0;
|
|
3949
|
-
for (const
|
|
3949
|
+
for (const path6 of Array.from(folder).sort()) {
|
|
3950
3950
|
for (const [sort] of Object.entries(indexDefinitions)) {
|
|
3951
3951
|
const indexSublevel = folderCollectionSublevel.sublevel(
|
|
3952
3952
|
sort,
|
|
3953
3953
|
SUBLEVEL_OPTIONS
|
|
3954
3954
|
);
|
|
3955
|
-
const subFolderKey = sha.hex(
|
|
3955
|
+
const subFolderKey = sha.hex(path6);
|
|
3956
3956
|
if (sort === DEFAULT_COLLECTION_SORT_KEY) {
|
|
3957
3957
|
result.push({
|
|
3958
3958
|
type: opType,
|
|
@@ -4570,7 +4570,7 @@ var Resolver = class {
|
|
|
4570
4570
|
first: -1
|
|
4571
4571
|
},
|
|
4572
4572
|
collection: referencedCollection,
|
|
4573
|
-
hydrator: (
|
|
4573
|
+
hydrator: (path6) => path6
|
|
4574
4574
|
}
|
|
4575
4575
|
);
|
|
4576
4576
|
const { edges } = resolvedCollectionConnection;
|
|
@@ -5018,17 +5018,6 @@ var Database = class {
|
|
|
5018
5018
|
}
|
|
5019
5019
|
};
|
|
5020
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
|
-
};
|
|
5032
5021
|
this.get = async (filepath) => {
|
|
5033
5022
|
await this.initLevel();
|
|
5034
5023
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
@@ -5997,93 +5986,10 @@ var TinaLevelClient = class extends ManyLevelGuest {
|
|
|
5997
5986
|
}
|
|
5998
5987
|
};
|
|
5999
5988
|
|
|
6000
|
-
// src/git/index.ts
|
|
6001
|
-
import git from "isomorphic-git";
|
|
6002
|
-
import fs from "fs-extra";
|
|
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
5989
|
// src/database/bridge/filesystem.ts
|
|
6084
|
-
import
|
|
5990
|
+
import fs from "fs-extra";
|
|
6085
5991
|
import fg from "fast-glob";
|
|
6086
|
-
import
|
|
5992
|
+
import path5 from "path";
|
|
6087
5993
|
import normalize from "normalize-path";
|
|
6088
5994
|
var FilesystemBridge = class {
|
|
6089
5995
|
constructor(rootPath, outputPath) {
|
|
@@ -6091,9 +5997,9 @@ var FilesystemBridge = class {
|
|
|
6091
5997
|
this.outputPath = outputPath || rootPath;
|
|
6092
5998
|
}
|
|
6093
5999
|
async glob(pattern, extension) {
|
|
6094
|
-
const basePath =
|
|
6000
|
+
const basePath = path5.join(this.outputPath, ...pattern.split("/"));
|
|
6095
6001
|
const items = await fg(
|
|
6096
|
-
|
|
6002
|
+
path5.join(basePath, "**", `/*.${extension}`).replace(/\\/g, "/"),
|
|
6097
6003
|
{
|
|
6098
6004
|
dot: true,
|
|
6099
6005
|
ignore: ["**/node_modules/**"]
|
|
@@ -6105,14 +6011,14 @@ var FilesystemBridge = class {
|
|
|
6105
6011
|
});
|
|
6106
6012
|
}
|
|
6107
6013
|
async delete(filepath) {
|
|
6108
|
-
await
|
|
6014
|
+
await fs.remove(path5.join(this.outputPath, filepath));
|
|
6109
6015
|
}
|
|
6110
6016
|
async get(filepath) {
|
|
6111
|
-
return
|
|
6017
|
+
return fs.readFileSync(path5.join(this.outputPath, filepath)).toString();
|
|
6112
6018
|
}
|
|
6113
6019
|
async put(filepath, data, basePathOverride) {
|
|
6114
6020
|
const basePath = basePathOverride || this.outputPath;
|
|
6115
|
-
await
|
|
6021
|
+
await fs.outputFileSync(path5.join(basePath, filepath), data);
|
|
6116
6022
|
}
|
|
6117
6023
|
};
|
|
6118
6024
|
var AuditFileSystemBridge = class extends FilesystemBridge {
|
|
@@ -6132,8 +6038,8 @@ var AuditFileSystemBridge = class extends FilesystemBridge {
|
|
|
6132
6038
|
};
|
|
6133
6039
|
|
|
6134
6040
|
// src/database/bridge/isomorphic.ts
|
|
6135
|
-
import
|
|
6136
|
-
import
|
|
6041
|
+
import git from "isomorphic-git";
|
|
6042
|
+
import fs2 from "fs-extra";
|
|
6137
6043
|
import globParent from "glob-parent";
|
|
6138
6044
|
import normalize2 from "normalize-path";
|
|
6139
6045
|
import { GraphQLError as GraphQLError5 } from "graphql";
|
|
@@ -6152,7 +6058,7 @@ var IsomorphicBridge = class {
|
|
|
6152
6058
|
gitRoot,
|
|
6153
6059
|
author,
|
|
6154
6060
|
committer,
|
|
6155
|
-
fsModule =
|
|
6061
|
+
fsModule = fs2,
|
|
6156
6062
|
commitMessage = "Update from GraphQL client",
|
|
6157
6063
|
ref,
|
|
6158
6064
|
onPut,
|
|
@@ -6196,17 +6102,17 @@ var IsomorphicBridge = class {
|
|
|
6196
6102
|
async listEntries({
|
|
6197
6103
|
pattern,
|
|
6198
6104
|
entry,
|
|
6199
|
-
path:
|
|
6105
|
+
path: path6,
|
|
6200
6106
|
results
|
|
6201
6107
|
}) {
|
|
6202
|
-
const treeResult = await
|
|
6108
|
+
const treeResult = await git.readTree({
|
|
6203
6109
|
...this.isomorphicConfig,
|
|
6204
6110
|
oid: entry.oid,
|
|
6205
6111
|
cache: this.cache
|
|
6206
6112
|
});
|
|
6207
6113
|
const children = [];
|
|
6208
6114
|
for (const childEntry of treeResult.tree) {
|
|
6209
|
-
const childPath =
|
|
6115
|
+
const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
|
|
6210
6116
|
if (childEntry.type === "tree") {
|
|
6211
6117
|
children.push(childEntry);
|
|
6212
6118
|
} else {
|
|
@@ -6216,7 +6122,7 @@ var IsomorphicBridge = class {
|
|
|
6216
6122
|
}
|
|
6217
6123
|
}
|
|
6218
6124
|
for (const childEntry of children) {
|
|
6219
|
-
const childPath =
|
|
6125
|
+
const childPath = path6 ? `${path6}/${childEntry.path}` : childEntry.path;
|
|
6220
6126
|
await this.listEntries({
|
|
6221
6127
|
pattern,
|
|
6222
6128
|
entry: childEntry,
|
|
@@ -6225,17 +6131,17 @@ var IsomorphicBridge = class {
|
|
|
6225
6131
|
});
|
|
6226
6132
|
}
|
|
6227
6133
|
}
|
|
6228
|
-
async resolvePathEntries(
|
|
6229
|
-
let pathParts =
|
|
6230
|
-
const result = await
|
|
6134
|
+
async resolvePathEntries(path6, ref) {
|
|
6135
|
+
let pathParts = path6.split("/");
|
|
6136
|
+
const result = await git.walk({
|
|
6231
6137
|
...this.isomorphicConfig,
|
|
6232
6138
|
map: async (filepath, [head]) => {
|
|
6233
6139
|
if (head._fullpath === ".") {
|
|
6234
6140
|
return head;
|
|
6235
6141
|
}
|
|
6236
|
-
if (
|
|
6237
|
-
if (dirname(
|
|
6238
|
-
if (
|
|
6142
|
+
if (path6.startsWith(filepath)) {
|
|
6143
|
+
if (dirname(path6) === dirname(filepath)) {
|
|
6144
|
+
if (path6 === filepath) {
|
|
6239
6145
|
return head;
|
|
6240
6146
|
}
|
|
6241
6147
|
} else {
|
|
@@ -6244,7 +6150,7 @@ var IsomorphicBridge = class {
|
|
|
6244
6150
|
}
|
|
6245
6151
|
},
|
|
6246
6152
|
cache: this.cache,
|
|
6247
|
-
trees: [
|
|
6153
|
+
trees: [git.TREE({ ref })]
|
|
6248
6154
|
});
|
|
6249
6155
|
const pathEntries = flat(result);
|
|
6250
6156
|
if (pathParts.indexOf(".") === -1) {
|
|
@@ -6255,7 +6161,7 @@ var IsomorphicBridge = class {
|
|
|
6255
6161
|
}
|
|
6256
6162
|
return { pathParts, pathEntries };
|
|
6257
6163
|
}
|
|
6258
|
-
async updateTreeHierarchy(existingOid, updatedOid,
|
|
6164
|
+
async updateTreeHierarchy(existingOid, updatedOid, path6, type, pathEntries, pathParts) {
|
|
6259
6165
|
const lastIdx = pathEntries.length - 1;
|
|
6260
6166
|
const parentEntry = pathEntries[lastIdx];
|
|
6261
6167
|
const parentPath = pathParts[lastIdx];
|
|
@@ -6264,13 +6170,13 @@ var IsomorphicBridge = class {
|
|
|
6264
6170
|
const mode = type === "blob" ? "100644" : "040000";
|
|
6265
6171
|
if (parentEntry) {
|
|
6266
6172
|
parentOid = await parentEntry.oid();
|
|
6267
|
-
const treeResult = await
|
|
6173
|
+
const treeResult = await git.readTree({
|
|
6268
6174
|
...this.isomorphicConfig,
|
|
6269
6175
|
oid: parentOid,
|
|
6270
6176
|
cache: this.cache
|
|
6271
6177
|
});
|
|
6272
6178
|
tree = existingOid ? treeResult.tree.map((entry) => {
|
|
6273
|
-
if (entry.path ===
|
|
6179
|
+
if (entry.path === path6) {
|
|
6274
6180
|
entry.oid = updatedOid;
|
|
6275
6181
|
}
|
|
6276
6182
|
return entry;
|
|
@@ -6279,7 +6185,7 @@ var IsomorphicBridge = class {
|
|
|
6279
6185
|
{
|
|
6280
6186
|
oid: updatedOid,
|
|
6281
6187
|
type,
|
|
6282
|
-
path:
|
|
6188
|
+
path: path6,
|
|
6283
6189
|
mode
|
|
6284
6190
|
}
|
|
6285
6191
|
];
|
|
@@ -6288,12 +6194,12 @@ var IsomorphicBridge = class {
|
|
|
6288
6194
|
{
|
|
6289
6195
|
oid: updatedOid,
|
|
6290
6196
|
type,
|
|
6291
|
-
path:
|
|
6197
|
+
path: path6,
|
|
6292
6198
|
mode
|
|
6293
6199
|
}
|
|
6294
6200
|
];
|
|
6295
6201
|
}
|
|
6296
|
-
const updatedParentOid = await
|
|
6202
|
+
const updatedParentOid = await git.writeTree({
|
|
6297
6203
|
...this.isomorphicConfig,
|
|
6298
6204
|
tree
|
|
6299
6205
|
});
|
|
@@ -6311,12 +6217,12 @@ var IsomorphicBridge = class {
|
|
|
6311
6217
|
}
|
|
6312
6218
|
}
|
|
6313
6219
|
async commitTree(treeSha, ref) {
|
|
6314
|
-
const commitSha = await
|
|
6220
|
+
const commitSha = await git.writeCommit({
|
|
6315
6221
|
...this.isomorphicConfig,
|
|
6316
6222
|
commit: {
|
|
6317
6223
|
tree: treeSha,
|
|
6318
6224
|
parent: [
|
|
6319
|
-
await
|
|
6225
|
+
await git.resolveRef({
|
|
6320
6226
|
...this.isomorphicConfig,
|
|
6321
6227
|
ref
|
|
6322
6228
|
})
|
|
@@ -6326,7 +6232,7 @@ var IsomorphicBridge = class {
|
|
|
6326
6232
|
committer: this.getCommitter()
|
|
6327
6233
|
}
|
|
6328
6234
|
});
|
|
6329
|
-
await
|
|
6235
|
+
await git.writeRef({
|
|
6330
6236
|
...this.isomorphicConfig,
|
|
6331
6237
|
ref,
|
|
6332
6238
|
value: commitSha,
|
|
@@ -6337,7 +6243,7 @@ var IsomorphicBridge = class {
|
|
|
6337
6243
|
if (this.ref) {
|
|
6338
6244
|
return this.ref;
|
|
6339
6245
|
}
|
|
6340
|
-
const ref = await
|
|
6246
|
+
const ref = await git.currentBranch({
|
|
6341
6247
|
...this.isomorphicConfig,
|
|
6342
6248
|
fullname: true
|
|
6343
6249
|
});
|
|
@@ -6368,7 +6274,7 @@ var IsomorphicBridge = class {
|
|
|
6368
6274
|
let treeEntry;
|
|
6369
6275
|
let parentPath;
|
|
6370
6276
|
if (parentEntry) {
|
|
6371
|
-
const treeResult = await
|
|
6277
|
+
const treeResult = await git.readTree({
|
|
6372
6278
|
...this.isomorphicConfig,
|
|
6373
6279
|
oid: await parentEntry.oid(),
|
|
6374
6280
|
cache: this.cache
|
|
@@ -6389,7 +6295,7 @@ var IsomorphicBridge = class {
|
|
|
6389
6295
|
path: parentPath,
|
|
6390
6296
|
results
|
|
6391
6297
|
});
|
|
6392
|
-
return results.map((
|
|
6298
|
+
return results.map((path6) => this.unqualifyPath(path6)).filter((path6) => path6.endsWith(extension));
|
|
6393
6299
|
}
|
|
6394
6300
|
async delete(filepath) {
|
|
6395
6301
|
const ref = await this.getRef();
|
|
@@ -6406,7 +6312,7 @@ var IsomorphicBridge = class {
|
|
|
6406
6312
|
oidToRemove = oidToRemove || await leafEntry.oid();
|
|
6407
6313
|
const parentEntry = pathEntries[ptr - 1];
|
|
6408
6314
|
const existingOid = await parentEntry.oid();
|
|
6409
|
-
const treeResult = await
|
|
6315
|
+
const treeResult = await git.readTree({
|
|
6410
6316
|
...this.isomorphicConfig,
|
|
6411
6317
|
oid: existingOid,
|
|
6412
6318
|
cache: this.cache
|
|
@@ -6418,7 +6324,7 @@ var IsomorphicBridge = class {
|
|
|
6418
6324
|
ptr -= 1;
|
|
6419
6325
|
continue;
|
|
6420
6326
|
}
|
|
6421
|
-
const updatedTreeOid = await
|
|
6327
|
+
const updatedTreeOid = await git.writeTree({
|
|
6422
6328
|
...this.isomorphicConfig,
|
|
6423
6329
|
tree: updatedTree
|
|
6424
6330
|
});
|
|
@@ -6445,7 +6351,7 @@ var IsomorphicBridge = class {
|
|
|
6445
6351
|
}
|
|
6446
6352
|
}
|
|
6447
6353
|
if (oidToRemove) {
|
|
6448
|
-
await
|
|
6354
|
+
await git.updateIndex({
|
|
6449
6355
|
...this.isomorphicConfig,
|
|
6450
6356
|
filepath: this.qualifyPath(filepath),
|
|
6451
6357
|
force: true,
|
|
@@ -6464,11 +6370,11 @@ var IsomorphicBridge = class {
|
|
|
6464
6370
|
}
|
|
6465
6371
|
async get(filepath) {
|
|
6466
6372
|
const ref = await this.getRef();
|
|
6467
|
-
const oid = await
|
|
6373
|
+
const oid = await git.resolveRef({
|
|
6468
6374
|
...this.isomorphicConfig,
|
|
6469
6375
|
ref
|
|
6470
6376
|
});
|
|
6471
|
-
const { blob } = await
|
|
6377
|
+
const { blob } = await git.readBlob({
|
|
6472
6378
|
...this.isomorphicConfig,
|
|
6473
6379
|
oid,
|
|
6474
6380
|
filepath: this.qualifyPath(filepath),
|
|
@@ -6488,13 +6394,13 @@ var IsomorphicBridge = class {
|
|
|
6488
6394
|
const nodePath = pathParts[pathParts.length - 1];
|
|
6489
6395
|
if (leafEntry) {
|
|
6490
6396
|
existingOid = await leafEntry.oid();
|
|
6491
|
-
const hash = await
|
|
6397
|
+
const hash = await git.hashBlob({ object: blobUpdate });
|
|
6492
6398
|
if (hash.oid === existingOid) {
|
|
6493
6399
|
await this.onPut(filepath, data);
|
|
6494
6400
|
return;
|
|
6495
6401
|
}
|
|
6496
6402
|
}
|
|
6497
|
-
const updatedOid = await
|
|
6403
|
+
const updatedOid = await git.writeBlob({
|
|
6498
6404
|
...this.isomorphicConfig,
|
|
6499
6405
|
blob: blobUpdate
|
|
6500
6406
|
});
|
|
@@ -6507,7 +6413,7 @@ var IsomorphicBridge = class {
|
|
|
6507
6413
|
pathParts.slice(0, pathParts.length - 1)
|
|
6508
6414
|
);
|
|
6509
6415
|
await this.commitTree(updatedRootSha, ref);
|
|
6510
|
-
await
|
|
6416
|
+
await git.updateIndex({
|
|
6511
6417
|
...this.isomorphicConfig,
|
|
6512
6418
|
filepath: this.qualifyPath(filepath),
|
|
6513
6419
|
add: true,
|
|
@@ -6539,8 +6445,6 @@ export {
|
|
|
6539
6445
|
buildSchema,
|
|
6540
6446
|
createDatabase,
|
|
6541
6447
|
createSchema,
|
|
6542
|
-
getChangedFiles,
|
|
6543
|
-
getSha,
|
|
6544
6448
|
handleFetchErrorError,
|
|
6545
6449
|
loadAndParseWithAliases,
|
|
6546
6450
|
parseFile,
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20230627221909",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"module": "dist/index.
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"package.json",
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
|
-
"import": "./dist/index.
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
13
|
"require": "./dist/index.js"
|
|
14
14
|
},
|
|
15
15
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@iarna/toml": "^2.2.5",
|
|
27
|
-
"@tinacms/mdx": "1.3.13",
|
|
28
|
-
"@tinacms/schema-tools": "1.4.7",
|
|
29
27
|
"abstract-level": "^1.0.3",
|
|
30
28
|
"body-parser": "^1.19.0",
|
|
31
29
|
"cors": "^2.8.5",
|
|
@@ -47,7 +45,9 @@
|
|
|
47
45
|
"micromatch": "4.0.5",
|
|
48
46
|
"normalize-path": "^3.0.0",
|
|
49
47
|
"readable-stream": "^4.3.0",
|
|
50
|
-
"yup": "^0.32.9"
|
|
48
|
+
"yup": "^0.32.9",
|
|
49
|
+
"@tinacms/mdx": "0.0.0-20230627221909",
|
|
50
|
+
"@tinacms/schema-tools": "0.0.0-20230627221909"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"registry": "https://registry.npmjs.org"
|
|
@@ -57,8 +57,6 @@
|
|
|
57
57
|
"directory": "packages/tina-graphql"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@tinacms/schema-tools": "1.4.7",
|
|
61
|
-
"@tinacms/scripts": "1.1.0",
|
|
62
60
|
"@types/cors": "^2.8.7",
|
|
63
61
|
"@types/estree": "^0.0.50",
|
|
64
62
|
"@types/express": "^4.17.8",
|
|
@@ -81,7 +79,9 @@
|
|
|
81
79
|
"jest-matcher-utils": "^29.5.0",
|
|
82
80
|
"memory-level": "^1.0.0",
|
|
83
81
|
"nodemon": "2.0.19",
|
|
84
|
-
"typescript": "4.3.5"
|
|
82
|
+
"typescript": "4.3.5",
|
|
83
|
+
"@tinacms/schema-tools": "0.0.0-20230627221909",
|
|
84
|
+
"@tinacms/scripts": "0.0.0-20230627221909"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"types": "pnpm tsc",
|
package/dist/git/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}>;
|