@tinacms/graphql 0.60.1 → 0.60.4
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/CHANGELOG.md +23 -0
- package/dist/build.d.ts +2 -1
- package/dist/database/index.d.ts +4 -2
- package/dist/database/util.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +130 -58
- package/dist/resolve.d.ts +3 -1
- package/dist/resolver/index.d.ts +22 -10
- package/dist/types.d.ts +7 -0
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
+
## 0.60.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d103b27ad: Fix issue where new collections would not be added when CLI restarts
|
|
8
|
+
|
|
9
|
+
## 0.60.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
|
|
14
|
+
- 3f46c6706: Fixed issue where generated SDK would not work with templates
|
|
15
|
+
- db9168578: Adds support for an `assetsHost` when resolving `image` fields with `useRelativeMedia`
|
|
16
|
+
- 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
|
|
17
|
+
|
|
18
|
+
## 0.60.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 08cdb672a: Adds `useRelativeMedia` support to local graphql client
|
|
23
|
+
- fdbfe9a16: Fixes issue where on windows documents could not be deleted localy
|
|
24
|
+
- 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
|
|
25
|
+
|
|
3
26
|
## 0.60.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/build.d.ts
CHANGED
|
@@ -12,8 +12,9 @@ limitations under the License.
|
|
|
12
12
|
*/
|
|
13
13
|
import type { TinaSchema } from './schema';
|
|
14
14
|
import { Database } from './database';
|
|
15
|
-
export declare const indexDB: ({ database, config, buildSDK, }: {
|
|
15
|
+
export declare const indexDB: ({ database, config, flags, buildSDK, }: {
|
|
16
16
|
database: Database;
|
|
17
17
|
config: TinaSchema['config'];
|
|
18
|
+
flags?: string[];
|
|
18
19
|
buildSDK?: boolean;
|
|
19
20
|
}) => Promise<void>;
|
package/dist/database/index.d.ts
CHANGED
|
@@ -44,8 +44,6 @@ export declare class Database {
|
|
|
44
44
|
private tinaSchema;
|
|
45
45
|
private collectionIndexDefinitions;
|
|
46
46
|
private _lookup;
|
|
47
|
-
private _graphql;
|
|
48
|
-
private _tinaSchema;
|
|
49
47
|
constructor(config: CreateDatabase);
|
|
50
48
|
private collectionForPath;
|
|
51
49
|
private partitionPathsByCollection;
|
|
@@ -65,6 +63,10 @@ export declare class Database {
|
|
|
65
63
|
};
|
|
66
64
|
keepTemplateKey: boolean;
|
|
67
65
|
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
|
|
68
|
+
*/
|
|
69
|
+
clearCache(): void;
|
|
68
70
|
flush: (filepath: string) => Promise<string>;
|
|
69
71
|
getLookup: (returnType: string) => Promise<LookupMapType>;
|
|
70
72
|
getGraphQLSchema: () => Promise<DocumentNode>;
|
package/dist/database/util.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ import * as yup from 'yup';
|
|
|
14
14
|
export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean) => string;
|
|
15
15
|
export declare const parseFile: <T extends object>(content: string, format: FormatType | string, yupSchema: (args: typeof yup) => yup.ObjectSchema<any>) => T;
|
|
16
16
|
export declare type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
|
|
17
|
+
export declare const normalizePath: (filepath: string) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type { Store } from '@tinacms/datalayer';
|
|
|
20
20
|
export type { Bridge } from './database/bridge';
|
|
21
21
|
export { sequential, assertShape } from './util';
|
|
22
22
|
export { stringifyFile, parseFile } from './database/util';
|
|
23
|
-
export declare const buildSchema: (rootPath: string, database: Database) => Promise<import("graphql").GraphQLSchema>;
|
|
23
|
+
export declare const buildSchema: (rootPath: string, database: Database, flags?: string[]) => Promise<import("graphql").GraphQLSchema>;
|
|
24
24
|
import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from './types';
|
|
25
25
|
export declare type TinaCloudSchema = TinaCloudSchemaBase<false>;
|
|
26
26
|
export declare type TinaSchema = TinaCloudSchema;
|
package/dist/index.js
CHANGED
|
@@ -10911,15 +10911,31 @@ var astBuilder = {
|
|
|
10911
10911
|
selectionSet: {
|
|
10912
10912
|
kind: "SelectionSet",
|
|
10913
10913
|
selections: [
|
|
10914
|
-
SysFieldDefinition,
|
|
10915
10914
|
{
|
|
10916
|
-
kind: "
|
|
10917
|
-
|
|
10918
|
-
kind: "
|
|
10919
|
-
|
|
10915
|
+
kind: "InlineFragment",
|
|
10916
|
+
typeCondition: {
|
|
10917
|
+
kind: "NamedType",
|
|
10918
|
+
name: {
|
|
10919
|
+
kind: "Name",
|
|
10920
|
+
value: "Document"
|
|
10921
|
+
}
|
|
10920
10922
|
},
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
+
directives: [],
|
|
10924
|
+
selectionSet: {
|
|
10925
|
+
kind: "SelectionSet",
|
|
10926
|
+
selections: [
|
|
10927
|
+
SysFieldDefinition,
|
|
10928
|
+
{
|
|
10929
|
+
kind: "Field",
|
|
10930
|
+
name: {
|
|
10931
|
+
kind: "Name",
|
|
10932
|
+
value: "id"
|
|
10933
|
+
},
|
|
10934
|
+
arguments: [],
|
|
10935
|
+
directives: []
|
|
10936
|
+
}
|
|
10937
|
+
]
|
|
10938
|
+
}
|
|
10923
10939
|
},
|
|
10924
10940
|
{
|
|
10925
10941
|
kind: "FragmentSpread",
|
|
@@ -10995,15 +11011,31 @@ var astBuilder = {
|
|
|
10995
11011
|
kind: "SelectionSet",
|
|
10996
11012
|
selections: [
|
|
10997
11013
|
{
|
|
10998
|
-
kind: "
|
|
10999
|
-
|
|
11000
|
-
kind: "
|
|
11001
|
-
|
|
11014
|
+
kind: "InlineFragment",
|
|
11015
|
+
typeCondition: {
|
|
11016
|
+
kind: "NamedType",
|
|
11017
|
+
name: {
|
|
11018
|
+
kind: "Name",
|
|
11019
|
+
value: "Document"
|
|
11020
|
+
}
|
|
11002
11021
|
},
|
|
11003
|
-
|
|
11004
|
-
|
|
11022
|
+
directives: [],
|
|
11023
|
+
selectionSet: {
|
|
11024
|
+
kind: "SelectionSet",
|
|
11025
|
+
selections: [
|
|
11026
|
+
SysFieldDefinition,
|
|
11027
|
+
{
|
|
11028
|
+
kind: "Field",
|
|
11029
|
+
name: {
|
|
11030
|
+
kind: "Name",
|
|
11031
|
+
value: "id"
|
|
11032
|
+
},
|
|
11033
|
+
arguments: [],
|
|
11034
|
+
directives: []
|
|
11035
|
+
}
|
|
11036
|
+
]
|
|
11037
|
+
}
|
|
11005
11038
|
},
|
|
11006
|
-
SysFieldDefinition,
|
|
11007
11039
|
{
|
|
11008
11040
|
kind: "FragmentSpread",
|
|
11009
11041
|
name: {
|
|
@@ -11264,6 +11296,11 @@ var scalarDefinitions = [
|
|
|
11264
11296
|
required: true,
|
|
11265
11297
|
type: astBuilder.TYPES.String
|
|
11266
11298
|
}),
|
|
11299
|
+
astBuilder.FieldDefinition({
|
|
11300
|
+
name: "title",
|
|
11301
|
+
required: false,
|
|
11302
|
+
type: astBuilder.TYPES.String
|
|
11303
|
+
}),
|
|
11267
11304
|
astBuilder.FieldDefinition({
|
|
11268
11305
|
name: "basename",
|
|
11269
11306
|
required: true,
|
|
@@ -12443,7 +12480,7 @@ var validateField = async (field) => {
|
|
|
12443
12480
|
|
|
12444
12481
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12445
12482
|
var name = "@tinacms/graphql";
|
|
12446
|
-
var version = "0.60.
|
|
12483
|
+
var version = "0.60.4";
|
|
12447
12484
|
var main = "dist/index.js";
|
|
12448
12485
|
var typings = "dist/index.d.ts";
|
|
12449
12486
|
var files = [
|
|
@@ -12485,7 +12522,8 @@ var scripts = {
|
|
|
12485
12522
|
build: 'echo "Run `yarn build` from the root of the repository instead"',
|
|
12486
12523
|
docs: "yarn typedoc",
|
|
12487
12524
|
serve: "yarn nodemon dist/server.js",
|
|
12488
|
-
test: "jest"
|
|
12525
|
+
test: "jest",
|
|
12526
|
+
"test-watch": "jest --watch"
|
|
12489
12527
|
};
|
|
12490
12528
|
var dependencies = {
|
|
12491
12529
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
@@ -12540,6 +12578,7 @@ var repository = {
|
|
|
12540
12578
|
};
|
|
12541
12579
|
var devDependencies = {
|
|
12542
12580
|
"@tinacms/datalayer": "workspace:*",
|
|
12581
|
+
"@tinacms/schema-tools": "workspace:*",
|
|
12543
12582
|
"@tinacms/scripts": "workspace:*",
|
|
12544
12583
|
"@types/cors": "^2.8.7",
|
|
12545
12584
|
"@types/estree": "^0.0.50",
|
|
@@ -12563,6 +12602,9 @@ var devDependencies = {
|
|
|
12563
12602
|
nodemon: "^2.0.4",
|
|
12564
12603
|
typescript: "^4.3.5"
|
|
12565
12604
|
};
|
|
12605
|
+
var peerDependencies = {
|
|
12606
|
+
"@tinacms/schema-tools": "*"
|
|
12607
|
+
};
|
|
12566
12608
|
var package_default = {
|
|
12567
12609
|
name,
|
|
12568
12610
|
version,
|
|
@@ -12575,7 +12617,8 @@ var package_default = {
|
|
|
12575
12617
|
dependencies,
|
|
12576
12618
|
publishConfig,
|
|
12577
12619
|
repository,
|
|
12578
|
-
devDependencies
|
|
12620
|
+
devDependencies,
|
|
12621
|
+
peerDependencies
|
|
12579
12622
|
};
|
|
12580
12623
|
|
|
12581
12624
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
|
|
@@ -12763,11 +12806,13 @@ var import_path = __toModule(require("path"));
|
|
|
12763
12806
|
var indexDB = async ({
|
|
12764
12807
|
database,
|
|
12765
12808
|
config,
|
|
12809
|
+
flags = [],
|
|
12766
12810
|
buildSDK = true
|
|
12767
12811
|
}) => {
|
|
12768
|
-
const flags = [];
|
|
12769
12812
|
if (database.store.supportsIndexing()) {
|
|
12770
|
-
flags.
|
|
12813
|
+
if (flags.indexOf("experimentalData") === -1) {
|
|
12814
|
+
flags.push("experimentalData");
|
|
12815
|
+
}
|
|
12771
12816
|
}
|
|
12772
12817
|
const tinaSchema = await createSchema({ schema: config, flags });
|
|
12773
12818
|
const builder = await createBuilder({
|
|
@@ -22452,15 +22497,11 @@ var createResolver2 = (args) => {
|
|
|
22452
22497
|
var Resolver = class {
|
|
22453
22498
|
constructor(init) {
|
|
22454
22499
|
this.init = init;
|
|
22455
|
-
this.resolveCollection = async (collectionName, hasDocuments) => {
|
|
22500
|
+
this.resolveCollection = async (args, collectionName, hasDocuments) => {
|
|
22456
22501
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22457
22502
|
const extraFields = {};
|
|
22458
|
-
let documents = {};
|
|
22459
|
-
if (hasDocuments) {
|
|
22460
|
-
documents = await this.getDocumentsForCollection(collectionName);
|
|
22461
|
-
}
|
|
22462
22503
|
return __spreadValues(__spreadValues({
|
|
22463
|
-
documents
|
|
22504
|
+
documents: { collection, hasDocuments }
|
|
22464
22505
|
}, collection), extraFields);
|
|
22465
22506
|
};
|
|
22466
22507
|
this.getDocument = async (fullPath) => {
|
|
@@ -22486,11 +22527,19 @@ var Resolver = class {
|
|
|
22486
22527
|
_template: rawData._template
|
|
22487
22528
|
};
|
|
22488
22529
|
await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
|
|
22530
|
+
const titleField = template.fields.find((x) => {
|
|
22531
|
+
if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
|
|
22532
|
+
return true;
|
|
22533
|
+
}
|
|
22534
|
+
});
|
|
22535
|
+
const titleFieldName = titleField == null ? void 0 : titleField.name;
|
|
22536
|
+
const title = data[titleFieldName || " "] || null;
|
|
22489
22537
|
return __spreadProps(__spreadValues({
|
|
22490
22538
|
__typename: collection.fields ? NAMER.documentTypeName(collection.namespace) : NAMER.documentTypeName(template.namespace),
|
|
22491
22539
|
id: fullPath
|
|
22492
22540
|
}, data), {
|
|
22493
22541
|
_sys: {
|
|
22542
|
+
title,
|
|
22494
22543
|
basename,
|
|
22495
22544
|
filename,
|
|
22496
22545
|
extension: extension2,
|
|
@@ -22835,9 +22884,19 @@ var Resolver = class {
|
|
|
22835
22884
|
case "boolean":
|
|
22836
22885
|
case "number":
|
|
22837
22886
|
case "reference":
|
|
22838
|
-
case "image":
|
|
22839
22887
|
accumulator[field.name] = value;
|
|
22840
22888
|
break;
|
|
22889
|
+
case "image":
|
|
22890
|
+
if (this.config) {
|
|
22891
|
+
if (this.config.useRelativeMedia === true) {
|
|
22892
|
+
accumulator[field.name] = value;
|
|
22893
|
+
} else {
|
|
22894
|
+
accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
|
|
22895
|
+
}
|
|
22896
|
+
} else {
|
|
22897
|
+
accumulator[field.name] = value;
|
|
22898
|
+
}
|
|
22899
|
+
break;
|
|
22841
22900
|
case "rich-text":
|
|
22842
22901
|
const tree = parseMDX(value, field);
|
|
22843
22902
|
accumulator[field.name] = tree;
|
|
@@ -22903,6 +22962,7 @@ var Resolver = class {
|
|
|
22903
22962
|
}));
|
|
22904
22963
|
return args.params;
|
|
22905
22964
|
};
|
|
22965
|
+
this.config = init.config;
|
|
22906
22966
|
this.database = init.database;
|
|
22907
22967
|
this.tinaSchema = init.tinaSchema;
|
|
22908
22968
|
}
|
|
@@ -22939,6 +22999,7 @@ var resolveDateInput = (value) => {
|
|
|
22939
22999
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolve.ts
|
|
22940
23000
|
var import_relay_operation_optimizer = __toModule(require("@graphql-tools/relay-operation-optimizer"));
|
|
22941
23001
|
var resolve = async ({
|
|
23002
|
+
config,
|
|
22942
23003
|
query,
|
|
22943
23004
|
variables,
|
|
22944
23005
|
database,
|
|
@@ -22947,9 +23008,11 @@ var resolve = async ({
|
|
|
22947
23008
|
try {
|
|
22948
23009
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
22949
23010
|
const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
|
|
22950
|
-
const
|
|
22951
|
-
const tinaSchema = await createSchema({
|
|
22952
|
-
|
|
23011
|
+
const tinaConfig = await database.getTinaSchema();
|
|
23012
|
+
const tinaSchema = await createSchema({
|
|
23013
|
+
schema: tinaConfig
|
|
23014
|
+
});
|
|
23015
|
+
const resolver2 = await createResolver2({ config, database, tinaSchema });
|
|
22953
23016
|
const res = await (0, import_graphql3.graphql)({
|
|
22954
23017
|
schema: graphQLSchema,
|
|
22955
23018
|
source: query,
|
|
@@ -22985,7 +23048,7 @@ var resolve = async ({
|
|
|
22985
23048
|
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22986
23049
|
});
|
|
22987
23050
|
return tinaSchema.getCollections().map((collection) => {
|
|
22988
|
-
return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
|
|
23051
|
+
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
22989
23052
|
});
|
|
22990
23053
|
}
|
|
22991
23054
|
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
@@ -22993,7 +23056,7 @@ var resolve = async ({
|
|
|
22993
23056
|
var _a;
|
|
22994
23057
|
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22995
23058
|
});
|
|
22996
|
-
return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
|
|
23059
|
+
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
22997
23060
|
}
|
|
22998
23061
|
if (info.fieldName === "getOptimizedQuery") {
|
|
22999
23062
|
try {
|
|
@@ -23054,6 +23117,11 @@ var resolve = async ({
|
|
|
23054
23117
|
return { node: document3 };
|
|
23055
23118
|
})
|
|
23056
23119
|
};
|
|
23120
|
+
} else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
|
|
23121
|
+
return resolver2.resolveCollectionConnection({
|
|
23122
|
+
args,
|
|
23123
|
+
collection: value.collection
|
|
23124
|
+
});
|
|
23057
23125
|
} else {
|
|
23058
23126
|
throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
|
|
23059
23127
|
}
|
|
@@ -23175,6 +23243,7 @@ var parseFile = (content3, format, yupSchema) => {
|
|
|
23175
23243
|
throw new Error(`Must specify a valid format, got ${format}`);
|
|
23176
23244
|
}
|
|
23177
23245
|
};
|
|
23246
|
+
var normalizePath = (filepath) => filepath.replace(/\\/g, "/");
|
|
23178
23247
|
|
|
23179
23248
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/database/index.ts
|
|
23180
23249
|
var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
|
|
@@ -23192,7 +23261,7 @@ var Database = class {
|
|
|
23192
23261
|
this.config = config;
|
|
23193
23262
|
this.collectionForPath = async (filepath) => {
|
|
23194
23263
|
const tinaSchema = await this.getSchema();
|
|
23195
|
-
const collection = tinaSchema.
|
|
23264
|
+
const collection = await tinaSchema.getCollectionByFullPath(filepath);
|
|
23196
23265
|
return collection;
|
|
23197
23266
|
};
|
|
23198
23267
|
this.get = async (filepath) => {
|
|
@@ -23201,7 +23270,7 @@ var Database = class {
|
|
|
23201
23270
|
} else {
|
|
23202
23271
|
const tinaSchema = await this.getSchema();
|
|
23203
23272
|
const extension2 = import_path4.default.extname(filepath);
|
|
23204
|
-
const contentObject = await this.store.get(filepath);
|
|
23273
|
+
const contentObject = await this.store.get(normalizePath(filepath));
|
|
23205
23274
|
if (!contentObject) {
|
|
23206
23275
|
throw new import_graphql4.GraphQLError(`Unable to find record ${filepath}`);
|
|
23207
23276
|
}
|
|
@@ -23241,9 +23310,9 @@ var Database = class {
|
|
|
23241
23310
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23242
23311
|
}
|
|
23243
23312
|
if (this.store.supportsSeeding()) {
|
|
23244
|
-
await this.bridge.put(filepath, stringifiedFile);
|
|
23313
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23245
23314
|
}
|
|
23246
|
-
await this.store.put(filepath, payload, {
|
|
23315
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23247
23316
|
keepTemplateKey,
|
|
23248
23317
|
collection: collection == null ? void 0 : collection.name,
|
|
23249
23318
|
indexDefinitions: collectionIndexDefinitions
|
|
@@ -23260,9 +23329,9 @@ var Database = class {
|
|
|
23260
23329
|
}
|
|
23261
23330
|
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23262
23331
|
if (this.store.supportsSeeding()) {
|
|
23263
|
-
await this.bridge.put(filepath, stringifiedFile);
|
|
23332
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23264
23333
|
}
|
|
23265
|
-
await this.store.put(filepath, payload, {
|
|
23334
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23266
23335
|
keepTemplateKey,
|
|
23267
23336
|
collection,
|
|
23268
23337
|
indexDefinitions: collectionIndexDefinitions
|
|
@@ -23327,23 +23396,23 @@ var Database = class {
|
|
|
23327
23396
|
this.getLookup = async (returnType) => {
|
|
23328
23397
|
const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
|
|
23329
23398
|
if (!this._lookup) {
|
|
23330
|
-
const _lookup = await this.store.get(lookupPath);
|
|
23399
|
+
const _lookup = await this.store.get(normalizePath(lookupPath));
|
|
23331
23400
|
this._lookup = _lookup;
|
|
23332
23401
|
}
|
|
23333
23402
|
return this._lookup[returnType];
|
|
23334
23403
|
};
|
|
23335
23404
|
this.getGraphQLSchema = async () => {
|
|
23336
23405
|
const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
|
|
23337
|
-
return this.store.get(graphqlPath);
|
|
23406
|
+
return this.store.get(normalizePath(graphqlPath));
|
|
23338
23407
|
};
|
|
23339
23408
|
this.getGraphQLSchemaFromBridge = async () => {
|
|
23340
23409
|
const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
|
|
23341
|
-
const _graphql = await this.bridge.get(graphqlPath);
|
|
23410
|
+
const _graphql = await this.bridge.get(normalizePath(graphqlPath));
|
|
23342
23411
|
return JSON.parse(_graphql);
|
|
23343
23412
|
};
|
|
23344
23413
|
this.getTinaSchema = async () => {
|
|
23345
23414
|
const schemaPath = import_path4.default.join(GENERATED_FOLDER, `_schema.json`);
|
|
23346
|
-
return this.store.get(schemaPath);
|
|
23415
|
+
return this.store.get(normalizePath(schemaPath));
|
|
23347
23416
|
};
|
|
23348
23417
|
this.getSchema = async () => {
|
|
23349
23418
|
if (this.tinaSchema) {
|
|
@@ -23463,8 +23532,8 @@ var Database = class {
|
|
|
23463
23532
|
tinaSchema
|
|
23464
23533
|
}) => {
|
|
23465
23534
|
if (this.bridge.supportsBuilding()) {
|
|
23466
|
-
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`), JSON.stringify(graphQLSchema));
|
|
23467
|
-
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_schema.json`), JSON.stringify(tinaSchema.schema));
|
|
23535
|
+
await this.bridge.putConfig(normalizePath(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`)), JSON.stringify(graphQLSchema));
|
|
23536
|
+
await this.bridge.putConfig(normalizePath(import_path4.default.join(GENERATED_FOLDER, `_schema.json`)), JSON.stringify(tinaSchema.schema));
|
|
23468
23537
|
}
|
|
23469
23538
|
};
|
|
23470
23539
|
this.indexContent = async ({
|
|
@@ -23472,12 +23541,12 @@ var Database = class {
|
|
|
23472
23541
|
tinaSchema
|
|
23473
23542
|
}) => {
|
|
23474
23543
|
await this.indexStatusCallbackWrapper(async () => {
|
|
23475
|
-
const lookup = JSON.parse(await this.bridge.get(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")));
|
|
23544
|
+
const lookup = JSON.parse(await this.bridge.get(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_lookup.json"))));
|
|
23476
23545
|
if (this.store.supportsSeeding()) {
|
|
23477
23546
|
await this.store.clear();
|
|
23478
|
-
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_graphql.json"), graphQLSchema);
|
|
23479
|
-
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_schema.json"), tinaSchema.schema);
|
|
23480
|
-
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_lookup.json"), lookup);
|
|
23547
|
+
await this.store.seed(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_graphql.json")), graphQLSchema);
|
|
23548
|
+
await this.store.seed(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_schema.json")), tinaSchema.schema);
|
|
23549
|
+
await this.store.seed(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")), lookup);
|
|
23481
23550
|
await this._indexAllContent();
|
|
23482
23551
|
} else {
|
|
23483
23552
|
if (this.store.supportsIndexing()) {
|
|
@@ -23505,23 +23574,22 @@ var Database = class {
|
|
|
23505
23574
|
});
|
|
23506
23575
|
};
|
|
23507
23576
|
this.delete = async (filepath) => {
|
|
23508
|
-
const
|
|
23509
|
-
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23577
|
+
const collection = await this.collectionForPath(filepath);
|
|
23510
23578
|
let collectionIndexDefinitions;
|
|
23511
23579
|
if (collection) {
|
|
23512
23580
|
const indexDefinitions = await this.getIndexDefinitions();
|
|
23513
23581
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23514
23582
|
}
|
|
23515
|
-
await this.store.delete(filepath, {
|
|
23583
|
+
await this.store.delete(normalizePath(filepath), {
|
|
23516
23584
|
collection: collection.name,
|
|
23517
23585
|
indexDefinitions: collectionIndexDefinitions
|
|
23518
23586
|
});
|
|
23519
|
-
await this.bridge.delete(filepath);
|
|
23587
|
+
await this.bridge.delete(normalizePath(filepath));
|
|
23520
23588
|
};
|
|
23521
23589
|
this._indexAllContent = async () => {
|
|
23522
23590
|
const tinaSchema = await this.getSchema();
|
|
23523
23591
|
await sequential(tinaSchema.getCollections(), async (collection) => {
|
|
23524
|
-
const documentPaths = await this.bridge.glob(collection.path);
|
|
23592
|
+
const documentPaths = await this.bridge.glob(normalizePath(collection.path));
|
|
23525
23593
|
await _indexContent(this, documentPaths, collection);
|
|
23526
23594
|
});
|
|
23527
23595
|
};
|
|
@@ -23529,14 +23597,14 @@ var Database = class {
|
|
|
23529
23597
|
const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
|
|
23530
23598
|
let lookupMap;
|
|
23531
23599
|
try {
|
|
23532
|
-
lookupMap = JSON.parse(await this.bridge.get(lookupPath));
|
|
23600
|
+
lookupMap = JSON.parse(await this.bridge.get(normalizePath(lookupPath)));
|
|
23533
23601
|
} catch (e) {
|
|
23534
23602
|
lookupMap = {};
|
|
23535
23603
|
}
|
|
23536
23604
|
const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
|
|
23537
23605
|
[lookup.type]: lookup
|
|
23538
23606
|
});
|
|
23539
|
-
await this.bridge.putConfig(lookupPath, JSON.stringify(updatedLookup));
|
|
23607
|
+
await this.bridge.putConfig(normalizePath(lookupPath), JSON.stringify(updatedLookup));
|
|
23540
23608
|
};
|
|
23541
23609
|
this.bridge = config.bridge;
|
|
23542
23610
|
this.store = config.store;
|
|
@@ -23560,6 +23628,10 @@ var Database = class {
|
|
|
23560
23628
|
}
|
|
23561
23629
|
return { pathsByCollection, nonCollectionPaths, collections };
|
|
23562
23630
|
}
|
|
23631
|
+
clearCache() {
|
|
23632
|
+
this.tinaSchema = null;
|
|
23633
|
+
this._lookup = null;
|
|
23634
|
+
}
|
|
23563
23635
|
async indexStatusCallbackWrapper(fn) {
|
|
23564
23636
|
await this.indexStatusCallback({ status: "inprogress" });
|
|
23565
23637
|
try {
|
|
@@ -23592,10 +23664,10 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
23592
23664
|
};
|
|
23593
23665
|
}
|
|
23594
23666
|
await sequential(documentPaths, async (filepath) => {
|
|
23595
|
-
const dataString = await database.bridge.get(filepath);
|
|
23667
|
+
const dataString = await database.bridge.get(normalizePath(filepath));
|
|
23596
23668
|
const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
|
|
23597
23669
|
if (database.store.supportsSeeding()) {
|
|
23598
|
-
await database.store.seed(filepath, data, seedOptions);
|
|
23670
|
+
await database.store.seed(normalizePath(filepath), data, seedOptions);
|
|
23599
23671
|
}
|
|
23600
23672
|
});
|
|
23601
23673
|
};
|
|
@@ -23618,11 +23690,11 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
|
|
|
23618
23690
|
};
|
|
23619
23691
|
|
|
23620
23692
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
23621
|
-
var buildSchema = async (rootPath, database) => {
|
|
23693
|
+
var buildSchema = async (rootPath, database, flags) => {
|
|
23622
23694
|
const tempConfig = import_path5.default.join(rootPath, ".tina", "__generated__", "config");
|
|
23623
23695
|
const config = await import_fs_extra2.default.readFileSync(import_path5.default.join(tempConfig, "schema.json")).toString();
|
|
23624
23696
|
await import_fs_extra2.default.rmdir(tempConfig, { recursive: true });
|
|
23625
|
-
await indexDB({ database, config: JSON.parse(config) });
|
|
23697
|
+
await indexDB({ database, config: JSON.parse(config), flags });
|
|
23626
23698
|
const gqlAst = await database.getGraphQLSchemaFromBridge();
|
|
23627
23699
|
return (0, import_graphql5.buildASTSchema)(gqlAst);
|
|
23628
23700
|
};
|
package/dist/resolve.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import type { Database } from './database';
|
|
14
|
-
|
|
14
|
+
import type { GraphQLConfig } from './types';
|
|
15
|
+
export declare const resolve: ({ config, query, variables, database, silenceErrors, }: {
|
|
16
|
+
config?: GraphQLConfig;
|
|
15
17
|
query: string;
|
|
16
18
|
variables: object;
|
|
17
19
|
database: Database;
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import { Database } from '../database';
|
|
14
|
-
import { TinaSchema } from '
|
|
15
|
-
import type {
|
|
16
|
-
import { TinaFieldInner } from '../types';
|
|
14
|
+
import type { Collectable, ReferenceTypeWithNamespace, TinaCloudCollection, TinaFieldInner, TinaSchema } from '@tinacms/schema-tools';
|
|
15
|
+
import type { GraphQLConfig } from '../types';
|
|
17
16
|
interface ResolverConfig {
|
|
17
|
+
config?: GraphQLConfig;
|
|
18
18
|
database: Database;
|
|
19
19
|
tinaSchema: TinaSchema;
|
|
20
20
|
}
|
|
@@ -25,11 +25,12 @@ export declare const createResolver: (args: ResolverConfig) => Resolver;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare class Resolver {
|
|
27
27
|
init: ResolverConfig;
|
|
28
|
+
config: GraphQLConfig;
|
|
28
29
|
database: Database;
|
|
29
30
|
tinaSchema: TinaSchema;
|
|
30
31
|
constructor(init: ResolverConfig);
|
|
31
|
-
resolveCollection: (collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
32
|
-
fields:
|
|
32
|
+
resolveCollection: (args: any, collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
33
|
+
fields: TinaFieldInner<true>[];
|
|
33
34
|
templates?: undefined;
|
|
34
35
|
references?: ReferenceTypeWithNamespace[];
|
|
35
36
|
namespace: string[];
|
|
@@ -38,14 +39,18 @@ export declare class Resolver {
|
|
|
38
39
|
path: string;
|
|
39
40
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
40
41
|
match?: string;
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
documents: {
|
|
43
|
+
collection: TinaCloudCollection<true>;
|
|
44
|
+
hasDocuments: boolean;
|
|
45
|
+
};
|
|
43
46
|
} | {
|
|
44
47
|
templates: (string | {
|
|
45
48
|
label: string;
|
|
46
49
|
name: string;
|
|
47
50
|
fields: TinaFieldInner<true>[];
|
|
48
|
-
ui?: object
|
|
51
|
+
ui?: object | (import("@tinacms/schema-tools").UIField<any, any> & {
|
|
52
|
+
previewSrc: string;
|
|
53
|
+
});
|
|
49
54
|
namespace: string[];
|
|
50
55
|
})[];
|
|
51
56
|
fields?: undefined;
|
|
@@ -56,11 +61,14 @@ export declare class Resolver {
|
|
|
56
61
|
path: string;
|
|
57
62
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
58
63
|
match?: string;
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
documents: {
|
|
65
|
+
collection: TinaCloudCollection<true>;
|
|
66
|
+
hasDocuments: boolean;
|
|
67
|
+
};
|
|
61
68
|
}>;
|
|
62
69
|
getDocument: (fullPath: unknown) => Promise<{
|
|
63
70
|
_sys: {
|
|
71
|
+
title: any;
|
|
64
72
|
basename: string;
|
|
65
73
|
filename: string;
|
|
66
74
|
extension: string;
|
|
@@ -92,6 +100,7 @@ export declare class Resolver {
|
|
|
92
100
|
isAddPendingDocument: boolean;
|
|
93
101
|
}) => Promise<{
|
|
94
102
|
_sys: {
|
|
103
|
+
title: any;
|
|
95
104
|
basename: string;
|
|
96
105
|
filename: string;
|
|
97
106
|
extension: string;
|
|
@@ -118,6 +127,7 @@ export declare class Resolver {
|
|
|
118
127
|
isCollectionSpecific: boolean;
|
|
119
128
|
}) => Promise<{
|
|
120
129
|
_sys: {
|
|
130
|
+
title: any;
|
|
121
131
|
basename: string;
|
|
122
132
|
filename: string;
|
|
123
133
|
extension: string;
|
|
@@ -146,6 +156,7 @@ export declare class Resolver {
|
|
|
146
156
|
isCollectionSpecific?: boolean;
|
|
147
157
|
}) => Promise<{
|
|
148
158
|
_sys: {
|
|
159
|
+
title: any;
|
|
149
160
|
basename: string;
|
|
150
161
|
filename: string;
|
|
151
162
|
extension: string;
|
|
@@ -171,6 +182,7 @@ export declare class Resolver {
|
|
|
171
182
|
edges: {
|
|
172
183
|
node: {
|
|
173
184
|
_sys: {
|
|
185
|
+
title: any;
|
|
174
186
|
basename: string;
|
|
175
187
|
filename: string;
|
|
176
188
|
extension: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -263,4 +263,11 @@ export declare type Templateable = {
|
|
|
263
263
|
fields: TinaFieldEnriched[];
|
|
264
264
|
ui?: object;
|
|
265
265
|
};
|
|
266
|
+
export declare type GraphQLConfig = {
|
|
267
|
+
useRelativeMedia: true;
|
|
268
|
+
} | {
|
|
269
|
+
useRelativeMedia: false;
|
|
270
|
+
clientId: string;
|
|
271
|
+
assetsHost: string;
|
|
272
|
+
};
|
|
266
273
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"build": "echo \"Run `yarn build` from the root of the repository instead\"",
|
|
43
43
|
"docs": "yarn typedoc",
|
|
44
44
|
"serve": "yarn nodemon dist/server.js",
|
|
45
|
-
"test": "jest"
|
|
45
|
+
"test": "jest",
|
|
46
|
+
"test-watch": "jest --watch"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
@@ -97,6 +98,7 @@
|
|
|
97
98
|
},
|
|
98
99
|
"devDependencies": {
|
|
99
100
|
"@tinacms/datalayer": "0.1.1",
|
|
101
|
+
"@tinacms/schema-tools": "0.0.4",
|
|
100
102
|
"@tinacms/scripts": "0.50.7",
|
|
101
103
|
"@types/cors": "^2.8.7",
|
|
102
104
|
"@types/estree": "^0.0.50",
|
|
@@ -119,5 +121,8 @@
|
|
|
119
121
|
"jest-matcher-utils": "27.0.6",
|
|
120
122
|
"nodemon": "^2.0.4",
|
|
121
123
|
"typescript": "^4.3.5"
|
|
124
|
+
},
|
|
125
|
+
"peerDependencies": {
|
|
126
|
+
"@tinacms/schema-tools": "*"
|
|
122
127
|
}
|
|
123
128
|
}
|