@tinacms/graphql 0.0.0-d7c745e-20250102002342 → 0.0.0-d9672bc-20250218033222
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/ast-builder/index.d.ts +0 -1
- package/dist/database/datalayer.d.ts +5 -1
- package/dist/database/index.d.ts +2 -0
- package/dist/index.js +308 -173
- package/dist/index.mjs +275 -144
- package/dist/resolver/index.d.ts +1 -1
- package/package.json +9 -10
package/dist/index.mjs
CHANGED
|
@@ -1029,41 +1029,6 @@ function* walk(maybeNode, visited = /* @__PURE__ */ new WeakSet()) {
|
|
|
1029
1029
|
yield maybeNode;
|
|
1030
1030
|
visited.add(maybeNode);
|
|
1031
1031
|
}
|
|
1032
|
-
function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
1033
|
-
if (typeof maybeNode === "string") {
|
|
1034
|
-
return maybeNode;
|
|
1035
|
-
}
|
|
1036
|
-
if (typeof maybeNode === "boolean") {
|
|
1037
|
-
return maybeNode;
|
|
1038
|
-
}
|
|
1039
|
-
const newNode = maybeNode;
|
|
1040
|
-
const keys = Object.keys(maybeNode);
|
|
1041
|
-
Object.values(maybeNode).map((m, index) => {
|
|
1042
|
-
const key = keys[index];
|
|
1043
|
-
if (Array.isArray(m)) {
|
|
1044
|
-
newNode[key] = m.map((element) => {
|
|
1045
|
-
if (!element) {
|
|
1046
|
-
return;
|
|
1047
|
-
}
|
|
1048
|
-
if (!element.hasOwnProperty("name")) {
|
|
1049
|
-
return element;
|
|
1050
|
-
}
|
|
1051
|
-
const value = element.name || element.value;
|
|
1052
|
-
return addNamespaceToSchema(element, [...namespace, value]);
|
|
1053
|
-
});
|
|
1054
|
-
} else {
|
|
1055
|
-
if (!m) {
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
if (!m.hasOwnProperty("name")) {
|
|
1059
|
-
newNode[key] = m;
|
|
1060
|
-
} else {
|
|
1061
|
-
newNode[key] = addNamespaceToSchema(m, [...namespace, m.name]);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1065
|
-
return { ...newNode, namespace };
|
|
1066
|
-
}
|
|
1067
1032
|
var generateNamespacedFieldName = (names, suffix = "") => {
|
|
1068
1033
|
return (suffix ? [...names, suffix] : names).map(capitalize).join("");
|
|
1069
1034
|
};
|
|
@@ -2898,6 +2863,7 @@ var filterSelections = (arr) => {
|
|
|
2898
2863
|
import { TinaSchema } from "@tinacms/schema-tools";
|
|
2899
2864
|
|
|
2900
2865
|
// src/schema/validate.ts
|
|
2866
|
+
import { addNamespaceToSchema } from "@tinacms/schema-tools";
|
|
2901
2867
|
import deepClone from "lodash.clonedeep";
|
|
2902
2868
|
import * as yup2 from "yup";
|
|
2903
2869
|
import {
|
|
@@ -3053,7 +3019,7 @@ var validateField = async (field) => {
|
|
|
3053
3019
|
// package.json
|
|
3054
3020
|
var package_default = {
|
|
3055
3021
|
name: "@tinacms/graphql",
|
|
3056
|
-
version: "1.5.
|
|
3022
|
+
version: "1.5.12",
|
|
3057
3023
|
main: "dist/index.js",
|
|
3058
3024
|
module: "dist/index.mjs",
|
|
3059
3025
|
typings: "dist/index.d.ts",
|
|
@@ -3080,8 +3046,8 @@ var package_default = {
|
|
|
3080
3046
|
build: "tinacms-scripts build",
|
|
3081
3047
|
docs: "pnpm typedoc",
|
|
3082
3048
|
serve: "pnpm nodemon dist/server.js",
|
|
3083
|
-
test: "
|
|
3084
|
-
"test-watch": "
|
|
3049
|
+
test: "vitest run",
|
|
3050
|
+
"test-watch": "vitest"
|
|
3085
3051
|
},
|
|
3086
3052
|
dependencies: {
|
|
3087
3053
|
"@iarna/toml": "^2.2.5",
|
|
@@ -3122,7 +3088,6 @@ var package_default = {
|
|
|
3122
3088
|
"@types/estree": "^0.0.50",
|
|
3123
3089
|
"@types/express": "^4.17.21",
|
|
3124
3090
|
"@types/fs-extra": "^9.0.13",
|
|
3125
|
-
"@types/jest": "^26.0.24",
|
|
3126
3091
|
"@types/js-yaml": "^3.12.10",
|
|
3127
3092
|
"@types/lodash.camelcase": "^4.3.9",
|
|
3128
3093
|
"@types/lodash.upperfirst": "^4.3.9",
|
|
@@ -3133,13 +3098,13 @@ var package_default = {
|
|
|
3133
3098
|
"@types/normalize-path": "^3.0.2",
|
|
3134
3099
|
"@types/ws": "^7.4.7",
|
|
3135
3100
|
"@types/yup": "^0.29.14",
|
|
3136
|
-
jest: "^29.7.0",
|
|
3137
|
-
"jest-diff": "^29.7.0",
|
|
3138
3101
|
"jest-file-snapshot": "^0.5.0",
|
|
3139
|
-
"jest-matcher-utils": "^29.7.0",
|
|
3140
3102
|
"memory-level": "^1.0.0",
|
|
3141
3103
|
nodemon: "3.1.4",
|
|
3142
|
-
typescript: "^5.6.3"
|
|
3104
|
+
typescript: "^5.6.3",
|
|
3105
|
+
vite: "^4.3.9",
|
|
3106
|
+
vitest: "^0.32.2",
|
|
3107
|
+
zod: "^3.23.8"
|
|
3143
3108
|
}
|
|
3144
3109
|
};
|
|
3145
3110
|
|
|
@@ -3995,6 +3960,9 @@ var loadAndParseWithAliases = async (bridge, filepath, collection, templateInfo)
|
|
|
3995
3960
|
|
|
3996
3961
|
// src/database/datalayer.ts
|
|
3997
3962
|
var DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
|
|
3963
|
+
var REFS_COLLECTIONS_SORT_KEY = "__refs__";
|
|
3964
|
+
var REFS_REFERENCE_FIELD = "__tina_ref__";
|
|
3965
|
+
var REFS_PATH_FIELD = "__tina_ref_path__";
|
|
3998
3966
|
var DEFAULT_NUMERIC_LPAD = 4;
|
|
3999
3967
|
var applyPadding = (input, pad) => {
|
|
4000
3968
|
if (pad) {
|
|
@@ -4568,6 +4536,41 @@ var makeIndexOpsForDocument = (filepath, collection, indexDefinitions, data, opT
|
|
|
4568
4536
|
}
|
|
4569
4537
|
return result;
|
|
4570
4538
|
};
|
|
4539
|
+
var makeRefOpsForDocument = (filepath, collection, references, data, opType, level) => {
|
|
4540
|
+
const result = [];
|
|
4541
|
+
if (collection) {
|
|
4542
|
+
for (const [c, referencePaths] of Object.entries(references || {})) {
|
|
4543
|
+
if (!referencePaths.length) {
|
|
4544
|
+
continue;
|
|
4545
|
+
}
|
|
4546
|
+
const collectionSublevel = level.sublevel(c, SUBLEVEL_OPTIONS);
|
|
4547
|
+
const refSublevel = collectionSublevel.sublevel(
|
|
4548
|
+
REFS_COLLECTIONS_SORT_KEY,
|
|
4549
|
+
SUBLEVEL_OPTIONS
|
|
4550
|
+
);
|
|
4551
|
+
const references2 = {};
|
|
4552
|
+
for (const path7 of referencePaths) {
|
|
4553
|
+
const ref = JSONPath({ path: path7, json: data });
|
|
4554
|
+
if (references2[ref]) {
|
|
4555
|
+
references2[ref].push(path7);
|
|
4556
|
+
} else {
|
|
4557
|
+
references2[ref] = [path7];
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
for (const ref of Object.keys(references2)) {
|
|
4561
|
+
for (const path7 of references2[ref]) {
|
|
4562
|
+
result.push({
|
|
4563
|
+
type: opType,
|
|
4564
|
+
key: `${ref}${INDEX_KEY_FIELD_SEPARATOR}${path7}${INDEX_KEY_FIELD_SEPARATOR}${filepath}`,
|
|
4565
|
+
sublevel: refSublevel,
|
|
4566
|
+
value: opType === "put" ? {} : void 0
|
|
4567
|
+
});
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
return result;
|
|
4573
|
+
};
|
|
4571
4574
|
var makeStringEscaper = (regex, replacement) => {
|
|
4572
4575
|
return (input) => {
|
|
4573
4576
|
if (Array.isArray(input)) {
|
|
@@ -5183,17 +5186,15 @@ var Resolver = class {
|
|
|
5183
5186
|
await this.deleteDocument(realPath);
|
|
5184
5187
|
if (await this.hasReferences(realPath, collection)) {
|
|
5185
5188
|
const collRefs = await this.findReferences(realPath, collection);
|
|
5186
|
-
for (const [collection2,
|
|
5187
|
-
for (const [
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
null
|
|
5194
|
-
);
|
|
5189
|
+
for (const [collection2, docsWithRefs] of Object.entries(collRefs)) {
|
|
5190
|
+
for (const [pathToDocWithRef, referencePaths] of Object.entries(
|
|
5191
|
+
docsWithRefs
|
|
5192
|
+
)) {
|
|
5193
|
+
let refDoc = await this.getRaw(pathToDocWithRef);
|
|
5194
|
+
for (const path7 of referencePaths) {
|
|
5195
|
+
refDoc = updateObjectWithJsonPath(refDoc, path7, null);
|
|
5195
5196
|
}
|
|
5196
|
-
await this.database.put(
|
|
5197
|
+
await this.database.put(pathToDocWithRef, refDoc, collection2);
|
|
5197
5198
|
}
|
|
5198
5199
|
}
|
|
5199
5200
|
}
|
|
@@ -5216,17 +5217,19 @@ var Resolver = class {
|
|
|
5216
5217
|
await this.database.put(newRealPath, doc._rawData, collection.name);
|
|
5217
5218
|
await this.deleteDocument(realPath);
|
|
5218
5219
|
const collRefs = await this.findReferences(realPath, collection);
|
|
5219
|
-
for (const [collection2,
|
|
5220
|
-
for (const [
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5220
|
+
for (const [collection2, docsWithRefs] of Object.entries(collRefs)) {
|
|
5221
|
+
for (const [pathToDocWithRef, referencePaths] of Object.entries(
|
|
5222
|
+
docsWithRefs
|
|
5223
|
+
)) {
|
|
5224
|
+
let docWithRef = await this.getRaw(pathToDocWithRef);
|
|
5225
|
+
for (const path7 of referencePaths) {
|
|
5226
|
+
docWithRef = updateObjectWithJsonPath(
|
|
5227
|
+
docWithRef,
|
|
5228
|
+
path7,
|
|
5226
5229
|
newRealPath
|
|
5227
5230
|
);
|
|
5228
5231
|
}
|
|
5229
|
-
await this.database.put(
|
|
5232
|
+
await this.database.put(pathToDocWithRef, docWithRef, collection2);
|
|
5230
5233
|
}
|
|
5231
5234
|
}
|
|
5232
5235
|
return this.getDocument(newRealPath);
|
|
@@ -5358,35 +5361,30 @@ var Resolver = class {
|
|
|
5358
5361
|
*/
|
|
5359
5362
|
this.hasReferences = async (id, c) => {
|
|
5360
5363
|
let count = 0;
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
(refId) => {
|
|
5382
|
-
count++;
|
|
5383
|
-
return refId;
|
|
5384
|
-
}
|
|
5385
|
-
);
|
|
5386
|
-
if (count) {
|
|
5387
|
-
return true;
|
|
5388
|
-
}
|
|
5364
|
+
await this.database.query(
|
|
5365
|
+
{
|
|
5366
|
+
collection: c.name,
|
|
5367
|
+
filterChain: makeFilterChain({
|
|
5368
|
+
conditions: [
|
|
5369
|
+
{
|
|
5370
|
+
filterPath: REFS_REFERENCE_FIELD,
|
|
5371
|
+
filterExpression: {
|
|
5372
|
+
_type: "string",
|
|
5373
|
+
_list: false,
|
|
5374
|
+
eq: id
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
]
|
|
5378
|
+
}),
|
|
5379
|
+
sort: REFS_COLLECTIONS_SORT_KEY
|
|
5380
|
+
},
|
|
5381
|
+
(refId) => {
|
|
5382
|
+
count++;
|
|
5383
|
+
return refId;
|
|
5389
5384
|
}
|
|
5385
|
+
);
|
|
5386
|
+
if (count) {
|
|
5387
|
+
return true;
|
|
5390
5388
|
}
|
|
5391
5389
|
return false;
|
|
5392
5390
|
};
|
|
@@ -5394,46 +5392,41 @@ var Resolver = class {
|
|
|
5394
5392
|
* Finds references to a document
|
|
5395
5393
|
* @param id the id of the document to find references to
|
|
5396
5394
|
* @param c the collection to find references in
|
|
5397
|
-
* @returns
|
|
5395
|
+
* @returns a map of references to the document
|
|
5398
5396
|
*/
|
|
5399
5397
|
this.findReferences = async (id, c) => {
|
|
5400
5398
|
const references = {};
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
_list: false,
|
|
5414
|
-
eq: id
|
|
5415
|
-
}
|
|
5416
|
-
}
|
|
5417
|
-
]
|
|
5418
|
-
}),
|
|
5419
|
-
sort: ref.field.name
|
|
5420
|
-
},
|
|
5421
|
-
(refId) => {
|
|
5422
|
-
if (!references[collection]) {
|
|
5423
|
-
references[collection] = {};
|
|
5424
|
-
}
|
|
5425
|
-
if (!references[collection][refId]) {
|
|
5426
|
-
references[collection][refId] = [];
|
|
5399
|
+
await this.database.query(
|
|
5400
|
+
{
|
|
5401
|
+
collection: c.name,
|
|
5402
|
+
filterChain: makeFilterChain({
|
|
5403
|
+
conditions: [
|
|
5404
|
+
{
|
|
5405
|
+
filterPath: REFS_REFERENCE_FIELD,
|
|
5406
|
+
filterExpression: {
|
|
5407
|
+
_type: "string",
|
|
5408
|
+
_list: false,
|
|
5409
|
+
eq: id
|
|
5410
|
+
}
|
|
5427
5411
|
}
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5412
|
+
]
|
|
5413
|
+
}),
|
|
5414
|
+
sort: REFS_COLLECTIONS_SORT_KEY
|
|
5415
|
+
},
|
|
5416
|
+
(refId, rawItem) => {
|
|
5417
|
+
if (!references[c.name]) {
|
|
5418
|
+
references[c.name] = {};
|
|
5419
|
+
}
|
|
5420
|
+
if (!references[c.name][refId]) {
|
|
5421
|
+
references[c.name][refId] = [];
|
|
5422
|
+
}
|
|
5423
|
+
const referencePath = rawItem?.[REFS_PATH_FIELD];
|
|
5424
|
+
if (referencePath) {
|
|
5425
|
+
references[c.name][refId].push(referencePath);
|
|
5426
|
+
}
|
|
5427
|
+
return refId;
|
|
5435
5428
|
}
|
|
5436
|
-
|
|
5429
|
+
);
|
|
5437
5430
|
return references;
|
|
5438
5431
|
};
|
|
5439
5432
|
this.buildFieldMutations = async (fieldParams, template, existingData) => {
|
|
@@ -6177,6 +6170,7 @@ var Database = class {
|
|
|
6177
6170
|
);
|
|
6178
6171
|
const indexDefinitions = await this.getIndexDefinitions(this.contentLevel);
|
|
6179
6172
|
const collectionIndexDefinitions = indexDefinitions?.[collection.name];
|
|
6173
|
+
const collectionReferences = (await this.getCollectionReferences())?.[collection.name];
|
|
6180
6174
|
const normalizedPath = normalizePath(filepath);
|
|
6181
6175
|
if (!collection?.isDetached) {
|
|
6182
6176
|
if (this.bridge) {
|
|
@@ -6205,6 +6199,14 @@ var Database = class {
|
|
|
6205
6199
|
let delOps = [];
|
|
6206
6200
|
if (!isGitKeep(normalizedPath, collection)) {
|
|
6207
6201
|
putOps = [
|
|
6202
|
+
...makeRefOpsForDocument(
|
|
6203
|
+
normalizedPath,
|
|
6204
|
+
collection?.name,
|
|
6205
|
+
collectionReferences,
|
|
6206
|
+
dataFields,
|
|
6207
|
+
"put",
|
|
6208
|
+
level
|
|
6209
|
+
),
|
|
6208
6210
|
...makeIndexOpsForDocument(
|
|
6209
6211
|
normalizedPath,
|
|
6210
6212
|
collection?.name,
|
|
@@ -6228,6 +6230,14 @@ var Database = class {
|
|
|
6228
6230
|
SUBLEVEL_OPTIONS
|
|
6229
6231
|
).get(normalizedPath);
|
|
6230
6232
|
delOps = existingItem ? [
|
|
6233
|
+
...makeRefOpsForDocument(
|
|
6234
|
+
normalizedPath,
|
|
6235
|
+
collection?.name,
|
|
6236
|
+
collectionReferences,
|
|
6237
|
+
existingItem,
|
|
6238
|
+
"del",
|
|
6239
|
+
level
|
|
6240
|
+
),
|
|
6231
6241
|
...makeIndexOpsForDocument(
|
|
6232
6242
|
normalizedPath,
|
|
6233
6243
|
collection?.name,
|
|
@@ -6275,6 +6285,7 @@ var Database = class {
|
|
|
6275
6285
|
);
|
|
6276
6286
|
collectionIndexDefinitions = indexDefinitions?.[collectionName];
|
|
6277
6287
|
}
|
|
6288
|
+
const collectionReferences = (await this.getCollectionReferences())?.[collectionName];
|
|
6278
6289
|
const normalizedPath = normalizePath(filepath);
|
|
6279
6290
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
6280
6291
|
const collection = await this.collectionForPath(filepath);
|
|
@@ -6322,6 +6333,14 @@ var Database = class {
|
|
|
6322
6333
|
let delOps = [];
|
|
6323
6334
|
if (!isGitKeep(normalizedPath, collection)) {
|
|
6324
6335
|
putOps = [
|
|
6336
|
+
...makeRefOpsForDocument(
|
|
6337
|
+
normalizedPath,
|
|
6338
|
+
collectionName,
|
|
6339
|
+
collectionReferences,
|
|
6340
|
+
dataFields,
|
|
6341
|
+
"put",
|
|
6342
|
+
level
|
|
6343
|
+
),
|
|
6325
6344
|
...makeIndexOpsForDocument(
|
|
6326
6345
|
normalizedPath,
|
|
6327
6346
|
collectionName,
|
|
@@ -6345,6 +6364,14 @@ var Database = class {
|
|
|
6345
6364
|
SUBLEVEL_OPTIONS
|
|
6346
6365
|
).get(normalizedPath);
|
|
6347
6366
|
delOps = existingItem ? [
|
|
6367
|
+
...makeRefOpsForDocument(
|
|
6368
|
+
normalizedPath,
|
|
6369
|
+
collectionName,
|
|
6370
|
+
collectionReferences,
|
|
6371
|
+
existingItem,
|
|
6372
|
+
"del",
|
|
6373
|
+
level
|
|
6374
|
+
),
|
|
6348
6375
|
...makeIndexOpsForDocument(
|
|
6349
6376
|
normalizedPath,
|
|
6350
6377
|
collectionName,
|
|
@@ -6507,6 +6534,22 @@ var Database = class {
|
|
|
6507
6534
|
this.tinaSchema = await createSchema({ schema });
|
|
6508
6535
|
return this.tinaSchema;
|
|
6509
6536
|
};
|
|
6537
|
+
this.getCollectionReferences = async (level) => {
|
|
6538
|
+
if (this.collectionReferences) {
|
|
6539
|
+
return this.collectionReferences;
|
|
6540
|
+
}
|
|
6541
|
+
const result = {};
|
|
6542
|
+
const schema = await this.getSchema(level || this.contentLevel);
|
|
6543
|
+
const collections = schema.getCollections();
|
|
6544
|
+
for (const collection of collections) {
|
|
6545
|
+
const collectionReferences = this.tinaSchema.findReferencesFromCollection(
|
|
6546
|
+
collection.name
|
|
6547
|
+
);
|
|
6548
|
+
result[collection.name] = collectionReferences;
|
|
6549
|
+
}
|
|
6550
|
+
this.collectionReferences = result;
|
|
6551
|
+
return result;
|
|
6552
|
+
};
|
|
6510
6553
|
this.getIndexDefinitions = async (level) => {
|
|
6511
6554
|
if (!this.collectionIndexDefinitions) {
|
|
6512
6555
|
await new Promise(async (resolve2, reject) => {
|
|
@@ -6516,8 +6559,23 @@ var Database = class {
|
|
|
6516
6559
|
const collections = schema.getCollections();
|
|
6517
6560
|
for (const collection of collections) {
|
|
6518
6561
|
const indexDefinitions = {
|
|
6519
|
-
[DEFAULT_COLLECTION_SORT_KEY]: { fields: [] }
|
|
6562
|
+
[DEFAULT_COLLECTION_SORT_KEY]: { fields: [] },
|
|
6520
6563
|
// provide a default sort key which is the file sort
|
|
6564
|
+
// pseudo-index for the collection's references
|
|
6565
|
+
[REFS_COLLECTIONS_SORT_KEY]: {
|
|
6566
|
+
fields: [
|
|
6567
|
+
{
|
|
6568
|
+
name: REFS_REFERENCE_FIELD,
|
|
6569
|
+
type: "string",
|
|
6570
|
+
list: false
|
|
6571
|
+
},
|
|
6572
|
+
{
|
|
6573
|
+
name: REFS_PATH_FIELD,
|
|
6574
|
+
type: "string",
|
|
6575
|
+
list: false
|
|
6576
|
+
}
|
|
6577
|
+
]
|
|
6578
|
+
}
|
|
6521
6579
|
};
|
|
6522
6580
|
if (collection.fields) {
|
|
6523
6581
|
for (const field of collection.fields) {
|
|
@@ -6668,29 +6726,36 @@ var Database = class {
|
|
|
6668
6726
|
}
|
|
6669
6727
|
startKey = startKey || key || "";
|
|
6670
6728
|
endKey = key || "";
|
|
6671
|
-
edges = [...edges, { cursor: key, path: filepath }];
|
|
6729
|
+
edges = [...edges, { cursor: key, path: filepath, value: itemRecord }];
|
|
6672
6730
|
}
|
|
6673
6731
|
return {
|
|
6674
|
-
edges: await sequential(
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6732
|
+
edges: await sequential(
|
|
6733
|
+
edges,
|
|
6734
|
+
async ({
|
|
6735
|
+
cursor,
|
|
6736
|
+
path: path7,
|
|
6737
|
+
value
|
|
6738
|
+
}) => {
|
|
6739
|
+
try {
|
|
6740
|
+
const node = await hydrator(path7, value);
|
|
6741
|
+
return {
|
|
6742
|
+
node,
|
|
6743
|
+
cursor: btoa(cursor)
|
|
6744
|
+
};
|
|
6745
|
+
} catch (error) {
|
|
6746
|
+
console.log(error);
|
|
6747
|
+
if (error instanceof Error && (!path7.includes(".tina/__generated__/_graphql.json") || !path7.includes("tina/__generated__/_graphql.json"))) {
|
|
6748
|
+
throw new TinaQueryError({
|
|
6749
|
+
originalError: error,
|
|
6750
|
+
file: path7,
|
|
6751
|
+
collection: collection.name,
|
|
6752
|
+
stack: error.stack
|
|
6753
|
+
});
|
|
6754
|
+
}
|
|
6755
|
+
throw error;
|
|
6690
6756
|
}
|
|
6691
|
-
throw error;
|
|
6692
6757
|
}
|
|
6693
|
-
|
|
6758
|
+
),
|
|
6694
6759
|
pageInfo: {
|
|
6695
6760
|
hasPreviousPage,
|
|
6696
6761
|
hasNextPage,
|
|
@@ -6836,6 +6901,7 @@ var Database = class {
|
|
|
6836
6901
|
throw new Error(`No collection found for path: ${filepath}`);
|
|
6837
6902
|
}
|
|
6838
6903
|
const indexDefinitions = await this.getIndexDefinitions(this.contentLevel);
|
|
6904
|
+
const collectionReferences = (await this.getCollectionReferences())?.[collection.name];
|
|
6839
6905
|
const collectionIndexDefinitions = indexDefinitions?.[collection.name];
|
|
6840
6906
|
let level = this.contentLevel;
|
|
6841
6907
|
if (collection?.isDetached) {
|
|
@@ -6854,6 +6920,14 @@ var Database = class {
|
|
|
6854
6920
|
collection.path || ""
|
|
6855
6921
|
);
|
|
6856
6922
|
await this.contentLevel.batch([
|
|
6923
|
+
...makeRefOpsForDocument(
|
|
6924
|
+
normalizedPath,
|
|
6925
|
+
collection.name,
|
|
6926
|
+
collectionReferences,
|
|
6927
|
+
item,
|
|
6928
|
+
"del",
|
|
6929
|
+
level
|
|
6930
|
+
),
|
|
6857
6931
|
...makeIndexOpsForDocument(
|
|
6858
6932
|
normalizedPath,
|
|
6859
6933
|
collection.name,
|
|
@@ -7081,6 +7155,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
7081
7155
|
}
|
|
7082
7156
|
collectionPath = collection.path;
|
|
7083
7157
|
}
|
|
7158
|
+
const collectionReferences = (await database.getCollectionReferences())?.[collection?.name];
|
|
7084
7159
|
const tinaSchema = await database.getSchema();
|
|
7085
7160
|
let templateInfo = null;
|
|
7086
7161
|
if (collection) {
|
|
@@ -7102,12 +7177,59 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
7102
7177
|
await hashPasswordValues(aliasedData, passwordFields);
|
|
7103
7178
|
}
|
|
7104
7179
|
const normalizedPath = normalizePath(filepath);
|
|
7180
|
+
const rootSublevel = level.sublevel(
|
|
7181
|
+
CONTENT_ROOT_PREFIX,
|
|
7182
|
+
SUBLEVEL_OPTIONS
|
|
7183
|
+
);
|
|
7105
7184
|
const folderKey = folderTreeBuilder.update(
|
|
7106
7185
|
normalizedPath,
|
|
7107
7186
|
collectionPath || ""
|
|
7108
7187
|
);
|
|
7188
|
+
const item = await rootSublevel.get(normalizedPath);
|
|
7189
|
+
if (item) {
|
|
7190
|
+
await database.contentLevel.batch([
|
|
7191
|
+
...makeRefOpsForDocument(
|
|
7192
|
+
normalizedPath,
|
|
7193
|
+
collection?.name,
|
|
7194
|
+
collectionReferences,
|
|
7195
|
+
item,
|
|
7196
|
+
"del",
|
|
7197
|
+
level
|
|
7198
|
+
),
|
|
7199
|
+
...makeIndexOpsForDocument(
|
|
7200
|
+
normalizedPath,
|
|
7201
|
+
collection.name,
|
|
7202
|
+
collectionIndexDefinitions,
|
|
7203
|
+
item,
|
|
7204
|
+
"del",
|
|
7205
|
+
level
|
|
7206
|
+
),
|
|
7207
|
+
// folder indices
|
|
7208
|
+
...makeIndexOpsForDocument(
|
|
7209
|
+
normalizedPath,
|
|
7210
|
+
`${collection.name}_${folderKey}`,
|
|
7211
|
+
collectionIndexDefinitions,
|
|
7212
|
+
item,
|
|
7213
|
+
"del",
|
|
7214
|
+
level
|
|
7215
|
+
),
|
|
7216
|
+
{
|
|
7217
|
+
type: "del",
|
|
7218
|
+
key: normalizedPath,
|
|
7219
|
+
sublevel: rootSublevel
|
|
7220
|
+
}
|
|
7221
|
+
]);
|
|
7222
|
+
}
|
|
7109
7223
|
if (!isGitKeep(filepath, collection)) {
|
|
7110
7224
|
await enqueueOps([
|
|
7225
|
+
...makeRefOpsForDocument(
|
|
7226
|
+
normalizedPath,
|
|
7227
|
+
collection?.name,
|
|
7228
|
+
collectionReferences,
|
|
7229
|
+
aliasedData,
|
|
7230
|
+
"put",
|
|
7231
|
+
level
|
|
7232
|
+
),
|
|
7111
7233
|
...makeIndexOpsForDocument(
|
|
7112
7234
|
normalizedPath,
|
|
7113
7235
|
collection?.name,
|
|
@@ -7171,6 +7293,7 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
|
|
|
7171
7293
|
throw new Error(`No indexDefinitions for collection ${collection.name}`);
|
|
7172
7294
|
}
|
|
7173
7295
|
}
|
|
7296
|
+
const collectionReferences = (await database.getCollectionReferences())?.[collection?.name];
|
|
7174
7297
|
const tinaSchema = await database.getSchema();
|
|
7175
7298
|
let templateInfo = null;
|
|
7176
7299
|
if (collection) {
|
|
@@ -7194,6 +7317,14 @@ var _deleteIndexContent = async (database, documentPaths, enqueueOps, collection
|
|
|
7194
7317
|
item
|
|
7195
7318
|
) : item;
|
|
7196
7319
|
await enqueueOps([
|
|
7320
|
+
...makeRefOpsForDocument(
|
|
7321
|
+
itemKey,
|
|
7322
|
+
collection?.name,
|
|
7323
|
+
collectionReferences,
|
|
7324
|
+
aliasedData,
|
|
7325
|
+
"del",
|
|
7326
|
+
database.contentLevel
|
|
7327
|
+
),
|
|
7197
7328
|
...makeIndexOpsForDocument(
|
|
7198
7329
|
itemKey,
|
|
7199
7330
|
collection.name,
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -346,7 +346,7 @@ export declare class Resolver {
|
|
|
346
346
|
* Finds references to a document
|
|
347
347
|
* @param id the id of the document to find references to
|
|
348
348
|
* @param c the collection to find references in
|
|
349
|
-
* @returns
|
|
349
|
+
* @returns a map of references to the document
|
|
350
350
|
*/
|
|
351
351
|
private findReferences;
|
|
352
352
|
private buildFieldMutations;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-d9672bc-20250218033222",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"readable-stream": "^4.5.2",
|
|
45
45
|
"scmp": "^2.1.0",
|
|
46
46
|
"yup": "^0.32.11",
|
|
47
|
-
"@tinacms/mdx": "0.0.0-
|
|
48
|
-
"@tinacms/schema-tools": "
|
|
47
|
+
"@tinacms/mdx": "0.0.0-d9672bc-20250218033222",
|
|
48
|
+
"@tinacms/schema-tools": "0.0.0-d9672bc-20250218033222"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"registry": "https://registry.npmjs.org"
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"@types/estree": "^0.0.50",
|
|
60
60
|
"@types/express": "^4.17.21",
|
|
61
61
|
"@types/fs-extra": "^9.0.13",
|
|
62
|
-
"@types/jest": "^26.0.24",
|
|
63
62
|
"@types/js-yaml": "^3.12.10",
|
|
64
63
|
"@types/lodash.camelcase": "^4.3.9",
|
|
65
64
|
"@types/lodash.upperfirst": "^4.3.9",
|
|
@@ -70,14 +69,14 @@
|
|
|
70
69
|
"@types/normalize-path": "^3.0.2",
|
|
71
70
|
"@types/ws": "^7.4.7",
|
|
72
71
|
"@types/yup": "^0.29.14",
|
|
73
|
-
"jest": "^29.7.0",
|
|
74
|
-
"jest-diff": "^29.7.0",
|
|
75
72
|
"jest-file-snapshot": "^0.5.0",
|
|
76
|
-
"jest-matcher-utils": "^29.7.0",
|
|
77
73
|
"memory-level": "^1.0.0",
|
|
78
74
|
"nodemon": "3.1.4",
|
|
79
75
|
"typescript": "^5.6.3",
|
|
80
|
-
"
|
|
76
|
+
"vite": "^4.3.9",
|
|
77
|
+
"vitest": "^0.32.2",
|
|
78
|
+
"zod": "^3.23.8",
|
|
79
|
+
"@tinacms/schema-tools": "0.0.0-d9672bc-20250218033222",
|
|
81
80
|
"@tinacms/scripts": "1.3.1"
|
|
82
81
|
},
|
|
83
82
|
"scripts": {
|
|
@@ -85,7 +84,7 @@
|
|
|
85
84
|
"build": "tinacms-scripts build",
|
|
86
85
|
"docs": "pnpm typedoc",
|
|
87
86
|
"serve": "pnpm nodemon dist/server.js",
|
|
88
|
-
"test": "
|
|
89
|
-
"test-watch": "
|
|
87
|
+
"test": "vitest run",
|
|
88
|
+
"test-watch": "vitest"
|
|
90
89
|
}
|
|
91
90
|
}
|