@tinacms/graphql 0.0.0-db8aa8e-20250228034006 → 0.0.0-df15996-20250420014759
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/builder/index.d.ts +2 -2
- package/dist/index.d.ts +1 -32
- package/dist/index.js +116 -19
- package/dist/index.mjs +116 -19
- package/dist/resolver/index.d.ts +4 -1
- package/dist/resolver/media-utils.d.ts +3 -3
- package/package.json +5 -5
package/dist/builder/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
*/
|
|
4
4
|
import { LookupMapType } from '../database';
|
|
5
|
-
import type {
|
|
5
|
+
import type { FieldDefinitionNode, InlineFragmentNode, ObjectTypeDefinitionNode } from 'graphql';
|
|
6
6
|
import type { Collection, Template } from '@tinacms/schema-tools';
|
|
7
7
|
import { TinaSchema } from '@tinacms/schema-tools';
|
|
8
8
|
export declare const createBuilder: ({ tinaSchema, }: {
|
|
@@ -177,7 +177,7 @@ export declare class Builder {
|
|
|
177
177
|
* ```
|
|
178
178
|
*
|
|
179
179
|
* @public
|
|
180
|
-
* @param collection a
|
|
180
|
+
* @param collection a TinaCloud collection
|
|
181
181
|
*/
|
|
182
182
|
collectionFragment: (collection: Collection<true>) => Promise<import("graphql").FragmentDefinitionNode>;
|
|
183
183
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { buildDotTinaFiles } from './build';
|
|
3
|
-
export { resolve } from './resolve';
|
|
4
|
-
export { transformDocumentIntoPayload } from './resolver';
|
|
5
|
-
export * from './resolver/error';
|
|
6
|
-
export { TinaLevelClient } from './level/tinaLevel';
|
|
7
|
-
export type { Level } from './database/level';
|
|
8
|
-
export type { QueryOptions, OnDeleteCallback, OnPutCallback, DatabaseArgs, GitProvider, CreateDatabase, } from './database';
|
|
9
|
-
export { Database, createDatabaseInternal, createDatabase, createLocalDatabase, } from './database';
|
|
10
|
-
import type { Config } from '@tinacms/schema-tools';
|
|
11
|
-
export { getChangedFiles, getSha, shaExists } from './git';
|
|
12
|
-
export * from './auth/utils';
|
|
13
|
-
export { sequential, assertShape } from './util';
|
|
14
|
-
export { loadAndParseWithAliases, stringifyFile, parseFile, scanAllContent, scanContentByPaths, transformDocument, } from './database/util';
|
|
15
|
-
export { createSchema } from './schema/createSchema';
|
|
16
|
-
export { buildDotTinaFiles };
|
|
17
|
-
export type DummyType = unknown;
|
|
18
|
-
export declare const buildSchema: (config: Config, flags?: string[]) => Promise<{
|
|
19
|
-
graphQLSchema: {
|
|
20
|
-
kind: "Document";
|
|
21
|
-
definitions: any;
|
|
22
|
-
};
|
|
23
|
-
tinaSchema: import("@tinacms/schema-tools").TinaSchema;
|
|
24
|
-
lookup: Record<string, import("./database").LookupMapType>;
|
|
25
|
-
fragDoc: string;
|
|
26
|
-
queryDoc: string;
|
|
27
|
-
}>;
|
|
28
|
-
export type TinaSchema = Schema;
|
|
29
|
-
export type { TinaTemplate, Schema, Collection };
|
|
30
|
-
export { FilesystemBridge, AuditFileSystemBridge, } from './database/bridge/filesystem';
|
|
31
|
-
export { IsomorphicBridge } from './database/bridge/isomorphic';
|
|
32
|
-
export type { Bridge } from './database/bridge';
|
|
1
|
+
export * from "../src/index"
|
package/dist/index.js
CHANGED
|
@@ -1914,7 +1914,7 @@ var Builder = class {
|
|
|
1914
1914
|
* ```
|
|
1915
1915
|
*
|
|
1916
1916
|
* @public
|
|
1917
|
-
* @param collection a
|
|
1917
|
+
* @param collection a TinaCloud collection
|
|
1918
1918
|
*/
|
|
1919
1919
|
this.collectionFragment = async (collection) => {
|
|
1920
1920
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -3090,7 +3090,7 @@ var validateField = async (field) => {
|
|
|
3090
3090
|
// package.json
|
|
3091
3091
|
var package_default = {
|
|
3092
3092
|
name: "@tinacms/graphql",
|
|
3093
|
-
version: "1.5.
|
|
3093
|
+
version: "1.5.16",
|
|
3094
3094
|
main: "dist/index.js",
|
|
3095
3095
|
module: "dist/index.mjs",
|
|
3096
3096
|
typings: "dist/index.d.ts",
|
|
@@ -3332,7 +3332,9 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
3332
3332
|
await builder.buildCreateCollectionFolderMutation()
|
|
3333
3333
|
);
|
|
3334
3334
|
await sequential(collections, async (collection) => {
|
|
3335
|
-
queryTypeDefinitionFields.push(
|
|
3335
|
+
queryTypeDefinitionFields.push(
|
|
3336
|
+
await builder.collectionDocument(collection)
|
|
3337
|
+
);
|
|
3336
3338
|
if (collection.isAuthCollection) {
|
|
3337
3339
|
queryTypeDefinitionFields.push(
|
|
3338
3340
|
await builder.authenticationCollectionDocument(collection)
|
|
@@ -3648,7 +3650,9 @@ var LevelProxyHandler = {
|
|
|
3648
3650
|
throw new Error(`The property, ${property.toString()}, doesn't exist`);
|
|
3649
3651
|
}
|
|
3650
3652
|
if (typeof target[property] !== "function") {
|
|
3651
|
-
throw new Error(
|
|
3653
|
+
throw new Error(
|
|
3654
|
+
`The property, ${property.toString()}, is not a function`
|
|
3655
|
+
);
|
|
3652
3656
|
}
|
|
3653
3657
|
if (property === "get") {
|
|
3654
3658
|
return async (...args) => {
|
|
@@ -4626,8 +4630,14 @@ var makeRefOpsForDocument = (filepath, collection, references, data, opType, lev
|
|
|
4626
4630
|
const references2 = {};
|
|
4627
4631
|
for (const path7 of referencePaths) {
|
|
4628
4632
|
const ref = (0, import_jsonpath_plus.JSONPath)({ path: path7, json: data });
|
|
4633
|
+
if (!ref) {
|
|
4634
|
+
continue;
|
|
4635
|
+
}
|
|
4629
4636
|
if (Array.isArray(ref)) {
|
|
4630
4637
|
for (const r of ref) {
|
|
4638
|
+
if (!r) {
|
|
4639
|
+
continue;
|
|
4640
|
+
}
|
|
4631
4641
|
if (references2[r]) {
|
|
4632
4642
|
references2[r].push(path7);
|
|
4633
4643
|
} else {
|
|
@@ -4878,25 +4888,32 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
|
|
|
4878
4888
|
}
|
|
4879
4889
|
};
|
|
4880
4890
|
var updateObjectWithJsonPath = (obj, path7, oldValue, newValue) => {
|
|
4891
|
+
let updated = false;
|
|
4881
4892
|
if (!path7.includes(".") && !path7.includes("[")) {
|
|
4882
4893
|
if (path7 in obj && obj[path7] === oldValue) {
|
|
4883
4894
|
obj[path7] = newValue;
|
|
4895
|
+
updated = true;
|
|
4884
4896
|
}
|
|
4885
|
-
return obj;
|
|
4897
|
+
return { object: obj, updated };
|
|
4886
4898
|
}
|
|
4887
4899
|
const parentPath = path7.replace(/\.[^.\[\]]+$/, "");
|
|
4888
4900
|
const keyToUpdate = path7.match(/[^.\[\]]+$/)[0];
|
|
4889
|
-
const parents = (0, import_jsonpath_plus2.JSONPath)({
|
|
4901
|
+
const parents = (0, import_jsonpath_plus2.JSONPath)({
|
|
4902
|
+
path: parentPath,
|
|
4903
|
+
json: obj,
|
|
4904
|
+
resultType: "value"
|
|
4905
|
+
});
|
|
4890
4906
|
if (parents.length > 0) {
|
|
4891
4907
|
parents.forEach((parent) => {
|
|
4892
4908
|
if (parent && typeof parent === "object" && keyToUpdate in parent) {
|
|
4893
4909
|
if (parent[keyToUpdate] === oldValue) {
|
|
4894
4910
|
parent[keyToUpdate] = newValue;
|
|
4911
|
+
updated = true;
|
|
4895
4912
|
}
|
|
4896
4913
|
}
|
|
4897
4914
|
});
|
|
4898
4915
|
}
|
|
4899
|
-
return obj;
|
|
4916
|
+
return { object: obj, updated };
|
|
4900
4917
|
};
|
|
4901
4918
|
var Resolver = class {
|
|
4902
4919
|
constructor(init) {
|
|
@@ -4913,7 +4930,9 @@ var Resolver = class {
|
|
|
4913
4930
|
};
|
|
4914
4931
|
this.getRaw = async (fullPath) => {
|
|
4915
4932
|
if (typeof fullPath !== "string") {
|
|
4916
|
-
throw new Error(
|
|
4933
|
+
throw new Error(
|
|
4934
|
+
`fullPath must be of type string for getDocument request`
|
|
4935
|
+
);
|
|
4917
4936
|
}
|
|
4918
4937
|
return this.database.get(fullPath);
|
|
4919
4938
|
};
|
|
@@ -4942,7 +4961,9 @@ var Resolver = class {
|
|
|
4942
4961
|
};
|
|
4943
4962
|
this.getDocument = async (fullPath, opts = {}) => {
|
|
4944
4963
|
if (typeof fullPath !== "string") {
|
|
4945
|
-
throw new Error(
|
|
4964
|
+
throw new Error(
|
|
4965
|
+
`fullPath must be of type string for getDocument request`
|
|
4966
|
+
);
|
|
4946
4967
|
}
|
|
4947
4968
|
const rawData = await this.getRaw(fullPath);
|
|
4948
4969
|
const hasReferences = (opts == null ? void 0 : opts.checkReferences) ? await this.hasReferences(fullPath, opts.collection) : void 0;
|
|
@@ -4957,7 +4978,9 @@ var Resolver = class {
|
|
|
4957
4978
|
};
|
|
4958
4979
|
this.deleteDocument = async (fullPath) => {
|
|
4959
4980
|
if (typeof fullPath !== "string") {
|
|
4960
|
-
throw new Error(
|
|
4981
|
+
throw new Error(
|
|
4982
|
+
`fullPath must be of type string for getDocument request`
|
|
4983
|
+
);
|
|
4961
4984
|
}
|
|
4962
4985
|
await this.database.delete(fullPath);
|
|
4963
4986
|
};
|
|
@@ -5161,7 +5184,11 @@ var Resolver = class {
|
|
|
5161
5184
|
collection,
|
|
5162
5185
|
doc == null ? void 0 : doc._rawData
|
|
5163
5186
|
);
|
|
5164
|
-
await this.database.put(
|
|
5187
|
+
await this.database.put(
|
|
5188
|
+
realPath,
|
|
5189
|
+
{ ...oldDoc, ...params },
|
|
5190
|
+
collection.name
|
|
5191
|
+
);
|
|
5165
5192
|
return this.getDocument(realPath);
|
|
5166
5193
|
};
|
|
5167
5194
|
/**
|
|
@@ -5280,10 +5307,30 @@ var Resolver = class {
|
|
|
5280
5307
|
docsWithRefs
|
|
5281
5308
|
)) {
|
|
5282
5309
|
let refDoc = await this.getRaw(pathToDocWithRef);
|
|
5310
|
+
let hasUpdate = false;
|
|
5283
5311
|
for (const path7 of referencePaths) {
|
|
5284
|
-
|
|
5312
|
+
const { object: object2, updated } = updateObjectWithJsonPath(
|
|
5313
|
+
refDoc,
|
|
5314
|
+
path7,
|
|
5315
|
+
realPath,
|
|
5316
|
+
null
|
|
5317
|
+
);
|
|
5318
|
+
refDoc = object2;
|
|
5319
|
+
hasUpdate = updated || hasUpdate;
|
|
5320
|
+
}
|
|
5321
|
+
if (hasUpdate) {
|
|
5322
|
+
const collectionWithRef = this.tinaSchema.getCollectionByFullPath(pathToDocWithRef);
|
|
5323
|
+
if (!collectionWithRef) {
|
|
5324
|
+
throw new Error(
|
|
5325
|
+
`Unable to find collection for ${pathToDocWithRef}`
|
|
5326
|
+
);
|
|
5327
|
+
}
|
|
5328
|
+
await this.database.put(
|
|
5329
|
+
pathToDocWithRef,
|
|
5330
|
+
refDoc,
|
|
5331
|
+
collectionWithRef.name
|
|
5332
|
+
);
|
|
5285
5333
|
}
|
|
5286
|
-
await this.database.put(pathToDocWithRef, refDoc, collection2);
|
|
5287
5334
|
}
|
|
5288
5335
|
}
|
|
5289
5336
|
}
|
|
@@ -5314,21 +5361,38 @@ var Resolver = class {
|
|
|
5314
5361
|
docsWithRefs
|
|
5315
5362
|
)) {
|
|
5316
5363
|
let docWithRef = await this.getRaw(pathToDocWithRef);
|
|
5364
|
+
let hasUpdate = false;
|
|
5317
5365
|
for (const path7 of referencePaths) {
|
|
5318
|
-
|
|
5366
|
+
const { object: object2, updated } = updateObjectWithJsonPath(
|
|
5319
5367
|
docWithRef,
|
|
5320
5368
|
path7,
|
|
5321
5369
|
realPath,
|
|
5322
5370
|
newRealPath
|
|
5323
5371
|
);
|
|
5372
|
+
docWithRef = object2;
|
|
5373
|
+
hasUpdate = updated || hasUpdate;
|
|
5374
|
+
}
|
|
5375
|
+
if (hasUpdate) {
|
|
5376
|
+
const collectionWithRef = this.tinaSchema.getCollectionByFullPath(pathToDocWithRef);
|
|
5377
|
+
if (!collectionWithRef) {
|
|
5378
|
+
throw new Error(
|
|
5379
|
+
`Unable to find collection for ${pathToDocWithRef}`
|
|
5380
|
+
);
|
|
5381
|
+
}
|
|
5382
|
+
await this.database.put(
|
|
5383
|
+
pathToDocWithRef,
|
|
5384
|
+
docWithRef,
|
|
5385
|
+
collectionWithRef.name
|
|
5386
|
+
);
|
|
5324
5387
|
}
|
|
5325
|
-
await this.database.put(pathToDocWithRef, docWithRef, collection2);
|
|
5326
5388
|
}
|
|
5327
5389
|
}
|
|
5328
5390
|
return this.getDocument(newRealPath);
|
|
5329
5391
|
}
|
|
5330
5392
|
if (alreadyExists === false) {
|
|
5331
|
-
throw new Error(
|
|
5393
|
+
throw new Error(
|
|
5394
|
+
`Unable to update document, ${realPath} does not exist`
|
|
5395
|
+
);
|
|
5332
5396
|
}
|
|
5333
5397
|
return this.updateResolveDocument({
|
|
5334
5398
|
collection,
|
|
@@ -6677,8 +6741,35 @@ var Database = class {
|
|
|
6677
6741
|
]
|
|
6678
6742
|
}
|
|
6679
6743
|
};
|
|
6680
|
-
|
|
6681
|
-
|
|
6744
|
+
let fields = [];
|
|
6745
|
+
if (collection.templates) {
|
|
6746
|
+
const templateFieldMap = {};
|
|
6747
|
+
const conflictedFields = /* @__PURE__ */ new Set();
|
|
6748
|
+
for (const template of collection.templates) {
|
|
6749
|
+
for (const field of template.fields) {
|
|
6750
|
+
if (!templateFieldMap[field.name]) {
|
|
6751
|
+
templateFieldMap[field.name] = field;
|
|
6752
|
+
} else {
|
|
6753
|
+
if (templateFieldMap[field.name].type !== field.type) {
|
|
6754
|
+
console.warn(
|
|
6755
|
+
`Field ${field.name} has conflicting types in templates - skipping index`
|
|
6756
|
+
);
|
|
6757
|
+
conflictedFields.add(field.name);
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
}
|
|
6761
|
+
}
|
|
6762
|
+
for (const conflictedField in conflictedFields) {
|
|
6763
|
+
delete templateFieldMap[conflictedField];
|
|
6764
|
+
}
|
|
6765
|
+
for (const field of Object.values(templateFieldMap)) {
|
|
6766
|
+
fields.push(field);
|
|
6767
|
+
}
|
|
6768
|
+
} else if (collection.fields) {
|
|
6769
|
+
fields = collection.fields;
|
|
6770
|
+
}
|
|
6771
|
+
if (fields) {
|
|
6772
|
+
for (const field of fields) {
|
|
6682
6773
|
if (field.indexed !== void 0 && field.indexed === false || field.type === "object") {
|
|
6683
6774
|
continue;
|
|
6684
6775
|
}
|
|
@@ -7107,7 +7198,13 @@ var Database = class {
|
|
|
7107
7198
|
);
|
|
7108
7199
|
}
|
|
7109
7200
|
} else {
|
|
7110
|
-
await _indexContent(
|
|
7201
|
+
await _indexContent(
|
|
7202
|
+
this,
|
|
7203
|
+
level,
|
|
7204
|
+
contentPaths,
|
|
7205
|
+
enqueueOps,
|
|
7206
|
+
collection
|
|
7207
|
+
);
|
|
7111
7208
|
}
|
|
7112
7209
|
}
|
|
7113
7210
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -1847,7 +1847,7 @@ var Builder = class {
|
|
|
1847
1847
|
* ```
|
|
1848
1848
|
*
|
|
1849
1849
|
* @public
|
|
1850
|
-
* @param collection a
|
|
1850
|
+
* @param collection a TinaCloud collection
|
|
1851
1851
|
*/
|
|
1852
1852
|
this.collectionFragment = async (collection) => {
|
|
1853
1853
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -3019,7 +3019,7 @@ var validateField = async (field) => {
|
|
|
3019
3019
|
// package.json
|
|
3020
3020
|
var package_default = {
|
|
3021
3021
|
name: "@tinacms/graphql",
|
|
3022
|
-
version: "1.5.
|
|
3022
|
+
version: "1.5.16",
|
|
3023
3023
|
main: "dist/index.js",
|
|
3024
3024
|
module: "dist/index.mjs",
|
|
3025
3025
|
typings: "dist/index.d.ts",
|
|
@@ -3260,7 +3260,9 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
3260
3260
|
await builder.buildCreateCollectionFolderMutation()
|
|
3261
3261
|
);
|
|
3262
3262
|
await sequential(collections, async (collection) => {
|
|
3263
|
-
queryTypeDefinitionFields.push(
|
|
3263
|
+
queryTypeDefinitionFields.push(
|
|
3264
|
+
await builder.collectionDocument(collection)
|
|
3265
|
+
);
|
|
3264
3266
|
if (collection.isAuthCollection) {
|
|
3265
3267
|
queryTypeDefinitionFields.push(
|
|
3266
3268
|
await builder.authenticationCollectionDocument(collection)
|
|
@@ -3575,7 +3577,9 @@ var LevelProxyHandler = {
|
|
|
3575
3577
|
throw new Error(`The property, ${property.toString()}, doesn't exist`);
|
|
3576
3578
|
}
|
|
3577
3579
|
if (typeof target[property] !== "function") {
|
|
3578
|
-
throw new Error(
|
|
3580
|
+
throw new Error(
|
|
3581
|
+
`The property, ${property.toString()}, is not a function`
|
|
3582
|
+
);
|
|
3579
3583
|
}
|
|
3580
3584
|
if (property === "get") {
|
|
3581
3585
|
return async (...args) => {
|
|
@@ -4551,8 +4555,14 @@ var makeRefOpsForDocument = (filepath, collection, references, data, opType, lev
|
|
|
4551
4555
|
const references2 = {};
|
|
4552
4556
|
for (const path7 of referencePaths) {
|
|
4553
4557
|
const ref = JSONPath({ path: path7, json: data });
|
|
4558
|
+
if (!ref) {
|
|
4559
|
+
continue;
|
|
4560
|
+
}
|
|
4554
4561
|
if (Array.isArray(ref)) {
|
|
4555
4562
|
for (const r of ref) {
|
|
4563
|
+
if (!r) {
|
|
4564
|
+
continue;
|
|
4565
|
+
}
|
|
4556
4566
|
if (references2[r]) {
|
|
4557
4567
|
references2[r].push(path7);
|
|
4558
4568
|
} else {
|
|
@@ -4802,25 +4812,32 @@ var transformDocumentIntoPayload = async (fullPath, rawData, tinaSchema, config,
|
|
|
4802
4812
|
}
|
|
4803
4813
|
};
|
|
4804
4814
|
var updateObjectWithJsonPath = (obj, path7, oldValue, newValue) => {
|
|
4815
|
+
let updated = false;
|
|
4805
4816
|
if (!path7.includes(".") && !path7.includes("[")) {
|
|
4806
4817
|
if (path7 in obj && obj[path7] === oldValue) {
|
|
4807
4818
|
obj[path7] = newValue;
|
|
4819
|
+
updated = true;
|
|
4808
4820
|
}
|
|
4809
|
-
return obj;
|
|
4821
|
+
return { object: obj, updated };
|
|
4810
4822
|
}
|
|
4811
4823
|
const parentPath = path7.replace(/\.[^.\[\]]+$/, "");
|
|
4812
4824
|
const keyToUpdate = path7.match(/[^.\[\]]+$/)[0];
|
|
4813
|
-
const parents = JSONPath2({
|
|
4825
|
+
const parents = JSONPath2({
|
|
4826
|
+
path: parentPath,
|
|
4827
|
+
json: obj,
|
|
4828
|
+
resultType: "value"
|
|
4829
|
+
});
|
|
4814
4830
|
if (parents.length > 0) {
|
|
4815
4831
|
parents.forEach((parent) => {
|
|
4816
4832
|
if (parent && typeof parent === "object" && keyToUpdate in parent) {
|
|
4817
4833
|
if (parent[keyToUpdate] === oldValue) {
|
|
4818
4834
|
parent[keyToUpdate] = newValue;
|
|
4835
|
+
updated = true;
|
|
4819
4836
|
}
|
|
4820
4837
|
}
|
|
4821
4838
|
});
|
|
4822
4839
|
}
|
|
4823
|
-
return obj;
|
|
4840
|
+
return { object: obj, updated };
|
|
4824
4841
|
};
|
|
4825
4842
|
var Resolver = class {
|
|
4826
4843
|
constructor(init) {
|
|
@@ -4837,7 +4854,9 @@ var Resolver = class {
|
|
|
4837
4854
|
};
|
|
4838
4855
|
this.getRaw = async (fullPath) => {
|
|
4839
4856
|
if (typeof fullPath !== "string") {
|
|
4840
|
-
throw new Error(
|
|
4857
|
+
throw new Error(
|
|
4858
|
+
`fullPath must be of type string for getDocument request`
|
|
4859
|
+
);
|
|
4841
4860
|
}
|
|
4842
4861
|
return this.database.get(fullPath);
|
|
4843
4862
|
};
|
|
@@ -4866,7 +4885,9 @@ var Resolver = class {
|
|
|
4866
4885
|
};
|
|
4867
4886
|
this.getDocument = async (fullPath, opts = {}) => {
|
|
4868
4887
|
if (typeof fullPath !== "string") {
|
|
4869
|
-
throw new Error(
|
|
4888
|
+
throw new Error(
|
|
4889
|
+
`fullPath must be of type string for getDocument request`
|
|
4890
|
+
);
|
|
4870
4891
|
}
|
|
4871
4892
|
const rawData = await this.getRaw(fullPath);
|
|
4872
4893
|
const hasReferences = opts?.checkReferences ? await this.hasReferences(fullPath, opts.collection) : void 0;
|
|
@@ -4881,7 +4902,9 @@ var Resolver = class {
|
|
|
4881
4902
|
};
|
|
4882
4903
|
this.deleteDocument = async (fullPath) => {
|
|
4883
4904
|
if (typeof fullPath !== "string") {
|
|
4884
|
-
throw new Error(
|
|
4905
|
+
throw new Error(
|
|
4906
|
+
`fullPath must be of type string for getDocument request`
|
|
4907
|
+
);
|
|
4885
4908
|
}
|
|
4886
4909
|
await this.database.delete(fullPath);
|
|
4887
4910
|
};
|
|
@@ -5085,7 +5108,11 @@ var Resolver = class {
|
|
|
5085
5108
|
collection,
|
|
5086
5109
|
doc?._rawData
|
|
5087
5110
|
);
|
|
5088
|
-
await this.database.put(
|
|
5111
|
+
await this.database.put(
|
|
5112
|
+
realPath,
|
|
5113
|
+
{ ...oldDoc, ...params },
|
|
5114
|
+
collection.name
|
|
5115
|
+
);
|
|
5089
5116
|
return this.getDocument(realPath);
|
|
5090
5117
|
};
|
|
5091
5118
|
/**
|
|
@@ -5203,10 +5230,30 @@ var Resolver = class {
|
|
|
5203
5230
|
docsWithRefs
|
|
5204
5231
|
)) {
|
|
5205
5232
|
let refDoc = await this.getRaw(pathToDocWithRef);
|
|
5233
|
+
let hasUpdate = false;
|
|
5206
5234
|
for (const path7 of referencePaths) {
|
|
5207
|
-
|
|
5235
|
+
const { object: object2, updated } = updateObjectWithJsonPath(
|
|
5236
|
+
refDoc,
|
|
5237
|
+
path7,
|
|
5238
|
+
realPath,
|
|
5239
|
+
null
|
|
5240
|
+
);
|
|
5241
|
+
refDoc = object2;
|
|
5242
|
+
hasUpdate = updated || hasUpdate;
|
|
5243
|
+
}
|
|
5244
|
+
if (hasUpdate) {
|
|
5245
|
+
const collectionWithRef = this.tinaSchema.getCollectionByFullPath(pathToDocWithRef);
|
|
5246
|
+
if (!collectionWithRef) {
|
|
5247
|
+
throw new Error(
|
|
5248
|
+
`Unable to find collection for ${pathToDocWithRef}`
|
|
5249
|
+
);
|
|
5250
|
+
}
|
|
5251
|
+
await this.database.put(
|
|
5252
|
+
pathToDocWithRef,
|
|
5253
|
+
refDoc,
|
|
5254
|
+
collectionWithRef.name
|
|
5255
|
+
);
|
|
5208
5256
|
}
|
|
5209
|
-
await this.database.put(pathToDocWithRef, refDoc, collection2);
|
|
5210
5257
|
}
|
|
5211
5258
|
}
|
|
5212
5259
|
}
|
|
@@ -5237,21 +5284,38 @@ var Resolver = class {
|
|
|
5237
5284
|
docsWithRefs
|
|
5238
5285
|
)) {
|
|
5239
5286
|
let docWithRef = await this.getRaw(pathToDocWithRef);
|
|
5287
|
+
let hasUpdate = false;
|
|
5240
5288
|
for (const path7 of referencePaths) {
|
|
5241
|
-
|
|
5289
|
+
const { object: object2, updated } = updateObjectWithJsonPath(
|
|
5242
5290
|
docWithRef,
|
|
5243
5291
|
path7,
|
|
5244
5292
|
realPath,
|
|
5245
5293
|
newRealPath
|
|
5246
5294
|
);
|
|
5295
|
+
docWithRef = object2;
|
|
5296
|
+
hasUpdate = updated || hasUpdate;
|
|
5297
|
+
}
|
|
5298
|
+
if (hasUpdate) {
|
|
5299
|
+
const collectionWithRef = this.tinaSchema.getCollectionByFullPath(pathToDocWithRef);
|
|
5300
|
+
if (!collectionWithRef) {
|
|
5301
|
+
throw new Error(
|
|
5302
|
+
`Unable to find collection for ${pathToDocWithRef}`
|
|
5303
|
+
);
|
|
5304
|
+
}
|
|
5305
|
+
await this.database.put(
|
|
5306
|
+
pathToDocWithRef,
|
|
5307
|
+
docWithRef,
|
|
5308
|
+
collectionWithRef.name
|
|
5309
|
+
);
|
|
5247
5310
|
}
|
|
5248
|
-
await this.database.put(pathToDocWithRef, docWithRef, collection2);
|
|
5249
5311
|
}
|
|
5250
5312
|
}
|
|
5251
5313
|
return this.getDocument(newRealPath);
|
|
5252
5314
|
}
|
|
5253
5315
|
if (alreadyExists === false) {
|
|
5254
|
-
throw new Error(
|
|
5316
|
+
throw new Error(
|
|
5317
|
+
`Unable to update document, ${realPath} does not exist`
|
|
5318
|
+
);
|
|
5255
5319
|
}
|
|
5256
5320
|
return this.updateResolveDocument({
|
|
5257
5321
|
collection,
|
|
@@ -6593,8 +6657,35 @@ var Database = class {
|
|
|
6593
6657
|
]
|
|
6594
6658
|
}
|
|
6595
6659
|
};
|
|
6596
|
-
|
|
6597
|
-
|
|
6660
|
+
let fields = [];
|
|
6661
|
+
if (collection.templates) {
|
|
6662
|
+
const templateFieldMap = {};
|
|
6663
|
+
const conflictedFields = /* @__PURE__ */ new Set();
|
|
6664
|
+
for (const template of collection.templates) {
|
|
6665
|
+
for (const field of template.fields) {
|
|
6666
|
+
if (!templateFieldMap[field.name]) {
|
|
6667
|
+
templateFieldMap[field.name] = field;
|
|
6668
|
+
} else {
|
|
6669
|
+
if (templateFieldMap[field.name].type !== field.type) {
|
|
6670
|
+
console.warn(
|
|
6671
|
+
`Field ${field.name} has conflicting types in templates - skipping index`
|
|
6672
|
+
);
|
|
6673
|
+
conflictedFields.add(field.name);
|
|
6674
|
+
}
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
for (const conflictedField in conflictedFields) {
|
|
6679
|
+
delete templateFieldMap[conflictedField];
|
|
6680
|
+
}
|
|
6681
|
+
for (const field of Object.values(templateFieldMap)) {
|
|
6682
|
+
fields.push(field);
|
|
6683
|
+
}
|
|
6684
|
+
} else if (collection.fields) {
|
|
6685
|
+
fields = collection.fields;
|
|
6686
|
+
}
|
|
6687
|
+
if (fields) {
|
|
6688
|
+
for (const field of fields) {
|
|
6598
6689
|
if (field.indexed !== void 0 && field.indexed === false || field.type === "object") {
|
|
6599
6690
|
continue;
|
|
6600
6691
|
}
|
|
@@ -7021,7 +7112,13 @@ var Database = class {
|
|
|
7021
7112
|
);
|
|
7022
7113
|
}
|
|
7023
7114
|
} else {
|
|
7024
|
-
await _indexContent(
|
|
7115
|
+
await _indexContent(
|
|
7116
|
+
this,
|
|
7117
|
+
level,
|
|
7118
|
+
contentPaths,
|
|
7119
|
+
enqueueOps,
|
|
7120
|
+
collection
|
|
7121
|
+
);
|
|
7025
7122
|
}
|
|
7026
7123
|
}
|
|
7027
7124
|
);
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -47,7 +47,10 @@ export declare const transformDocumentIntoPayload: (fullPath: string, rawData: {
|
|
|
47
47
|
* @param newValue - The new value to set at the specified path.
|
|
48
48
|
* @returns the updated object.
|
|
49
49
|
*/
|
|
50
|
-
export declare const updateObjectWithJsonPath: (obj: any, path: string, oldValue: any, newValue: any) =>
|
|
50
|
+
export declare const updateObjectWithJsonPath: (obj: any, path: string, oldValue: any, newValue: any) => {
|
|
51
|
+
object: any;
|
|
52
|
+
updated: boolean;
|
|
53
|
+
};
|
|
51
54
|
/**
|
|
52
55
|
* The resolver provides functions for all possible types of lookup
|
|
53
56
|
* values and retrieves them from the database
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
|
|
3
3
|
*/
|
|
4
|
-
import type { GraphQLConfig } from '../types';
|
|
5
4
|
import type { Schema } from '@tinacms/schema-tools';
|
|
5
|
+
import type { GraphQLConfig } from '../types';
|
|
6
6
|
/**
|
|
7
|
-
* Strips away the
|
|
7
|
+
* Strips away the TinaCloud Asset URL from an `image` value
|
|
8
8
|
*
|
|
9
9
|
* @param {string | string[]} value
|
|
10
10
|
* @param {GraphQLConfig} config
|
|
@@ -12,7 +12,7 @@ import type { Schema } from '@tinacms/schema-tools';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const resolveMediaCloudToRelative: (value: string | string[], config: GraphQLConfig, schema: Schema<true>) => string | string[];
|
|
14
14
|
/**
|
|
15
|
-
* Adds
|
|
15
|
+
* Adds TinaCloud Asset URL to an `image` value
|
|
16
16
|
*
|
|
17
17
|
* @param {string | string[]} value
|
|
18
18
|
* @param {GraphQLConfig} config
|
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-df15996-20250420014759",
|
|
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.7.0",
|
|
45
45
|
"scmp": "^2.1.0",
|
|
46
46
|
"yup": "^0.32.11",
|
|
47
|
-
"@tinacms/mdx": "0.0.0-
|
|
48
|
-
"@tinacms/schema-tools": "0.0.0-
|
|
47
|
+
"@tinacms/mdx": "0.0.0-df15996-20250420014759",
|
|
48
|
+
"@tinacms/schema-tools": "0.0.0-df15996-20250420014759"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"registry": "https://registry.npmjs.org"
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"vite": "^4.5.9",
|
|
77
77
|
"vitest": "^0.32.4",
|
|
78
78
|
"zod": "^3.24.2",
|
|
79
|
-
"@tinacms/
|
|
80
|
-
"@tinacms/
|
|
79
|
+
"@tinacms/scripts": "1.3.4",
|
|
80
|
+
"@tinacms/schema-tools": "0.0.0-df15996-20250420014759"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"types": "pnpm tsc",
|