@tinacms/graphql 0.0.0-20224417538 → 0.0.0-2022510161017
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 +39 -2
- 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 +142 -67
- package/dist/resolve.d.ts +3 -1
- package/dist/resolver/index.d.ts +22 -11
- package/dist/types.d.ts +7 -0
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,47 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-2022510161017
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 7194aa3a0: Experimental isomorphic git bridge implementation
|
|
8
|
+
- Updated dependencies [7194aa3a0]
|
|
9
|
+
- @tinacms/datalayer@0.0.0-2022510161017
|
|
10
|
+
|
|
11
|
+
## 0.60.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 57f09bdd7: Always use the query function when the dataLayer in enabled
|
|
16
|
+
|
|
17
|
+
## 0.60.4
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- d103b27ad: Fix issue where new collections would not be added when CLI restarts
|
|
22
|
+
|
|
23
|
+
## 0.60.3
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
|
|
28
|
+
- 3f46c6706: Fixed issue where generated SDK would not work with templates
|
|
29
|
+
- db9168578: Adds support for an `assetsHost` when resolving `image` fields with `useRelativeMedia`
|
|
30
|
+
- 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
|
|
31
|
+
|
|
32
|
+
## 0.60.2
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 08cdb672a: Adds `useRelativeMedia` support to local graphql client
|
|
37
|
+
- fdbfe9a16: Fixes issue where on windows documents could not be deleted localy
|
|
38
|
+
- 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
|
|
39
|
+
|
|
40
|
+
## 0.60.1
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- 3b11ff6ad: Add optional indexing status callback to Database
|
|
8
45
|
|
|
9
46
|
## 0.60.0
|
|
10
47
|
|
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.5";
|
|
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,16 @@ 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
|
+
}
|
|
12816
|
+
if (flags.indexOf("isomorphicGitBridge") === -1) {
|
|
12817
|
+
flags.push("isomorphicGitBridge");
|
|
12818
|
+
}
|
|
12771
12819
|
}
|
|
12772
12820
|
const tinaSchema = await createSchema({ schema: config, flags });
|
|
12773
12821
|
const builder = await createBuilder({
|
|
@@ -22452,15 +22500,11 @@ var createResolver2 = (args) => {
|
|
|
22452
22500
|
var Resolver = class {
|
|
22453
22501
|
constructor(init) {
|
|
22454
22502
|
this.init = init;
|
|
22455
|
-
this.resolveCollection = async (collectionName, hasDocuments) => {
|
|
22503
|
+
this.resolveCollection = async (args, collectionName, hasDocuments) => {
|
|
22456
22504
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22457
22505
|
const extraFields = {};
|
|
22458
|
-
let documents = {};
|
|
22459
|
-
if (hasDocuments) {
|
|
22460
|
-
documents = await this.getDocumentsForCollection(collectionName);
|
|
22461
|
-
}
|
|
22462
22506
|
return __spreadValues(__spreadValues({
|
|
22463
|
-
documents
|
|
22507
|
+
documents: { collection, hasDocuments }
|
|
22464
22508
|
}, collection), extraFields);
|
|
22465
22509
|
};
|
|
22466
22510
|
this.getDocument = async (fullPath) => {
|
|
@@ -22486,11 +22530,19 @@ var Resolver = class {
|
|
|
22486
22530
|
_template: rawData._template
|
|
22487
22531
|
};
|
|
22488
22532
|
await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
|
|
22533
|
+
const titleField = template.fields.find((x) => {
|
|
22534
|
+
if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
|
|
22535
|
+
return true;
|
|
22536
|
+
}
|
|
22537
|
+
});
|
|
22538
|
+
const titleFieldName = titleField == null ? void 0 : titleField.name;
|
|
22539
|
+
const title = data[titleFieldName || " "] || null;
|
|
22489
22540
|
return __spreadProps(__spreadValues({
|
|
22490
22541
|
__typename: collection.fields ? NAMER.documentTypeName(collection.namespace) : NAMER.documentTypeName(template.namespace),
|
|
22491
22542
|
id: fullPath
|
|
22492
22543
|
}, data), {
|
|
22493
22544
|
_sys: {
|
|
22545
|
+
title,
|
|
22494
22546
|
basename,
|
|
22495
22547
|
filename,
|
|
22496
22548
|
extension: extension2,
|
|
@@ -22702,10 +22754,6 @@ var Resolver = class {
|
|
|
22702
22754
|
})
|
|
22703
22755
|
};
|
|
22704
22756
|
};
|
|
22705
|
-
this.getDocumentsForCollection = async (collectionName) => {
|
|
22706
|
-
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22707
|
-
return this.database.store.glob(collection.path, this.getDocument);
|
|
22708
|
-
};
|
|
22709
22757
|
this.referenceResolver = async (filter, fieldDefinition) => {
|
|
22710
22758
|
const referencedCollection = this.tinaSchema.getCollection(fieldDefinition.collections[0]);
|
|
22711
22759
|
if (!referencedCollection) {
|
|
@@ -22730,9 +22778,11 @@ var Resolver = class {
|
|
|
22730
22778
|
collection,
|
|
22731
22779
|
hydrator
|
|
22732
22780
|
}) => {
|
|
22781
|
+
var _a, _b, _c, _d;
|
|
22733
22782
|
let edges;
|
|
22734
22783
|
let pageInfo;
|
|
22735
|
-
|
|
22784
|
+
const useDataLayer = Boolean((_d = (_c = (_b = (_a = this.tinaSchema) == null ? void 0 : _a.config) == null ? void 0 : _b.meta) == null ? void 0 : _c.flags) == null ? void 0 : _d.find((x) => x === "experimentalData"));
|
|
22785
|
+
if (useDataLayer) {
|
|
22736
22786
|
let conditions;
|
|
22737
22787
|
if (args.filter) {
|
|
22738
22788
|
if (collection.fields) {
|
|
@@ -22835,9 +22885,19 @@ var Resolver = class {
|
|
|
22835
22885
|
case "boolean":
|
|
22836
22886
|
case "number":
|
|
22837
22887
|
case "reference":
|
|
22838
|
-
case "image":
|
|
22839
22888
|
accumulator[field.name] = value;
|
|
22840
22889
|
break;
|
|
22890
|
+
case "image":
|
|
22891
|
+
if (this.config) {
|
|
22892
|
+
if (this.config.useRelativeMedia === true) {
|
|
22893
|
+
accumulator[field.name] = value;
|
|
22894
|
+
} else {
|
|
22895
|
+
accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
|
|
22896
|
+
}
|
|
22897
|
+
} else {
|
|
22898
|
+
accumulator[field.name] = value;
|
|
22899
|
+
}
|
|
22900
|
+
break;
|
|
22841
22901
|
case "rich-text":
|
|
22842
22902
|
const tree = parseMDX(value, field);
|
|
22843
22903
|
accumulator[field.name] = tree;
|
|
@@ -22903,6 +22963,7 @@ var Resolver = class {
|
|
|
22903
22963
|
}));
|
|
22904
22964
|
return args.params;
|
|
22905
22965
|
};
|
|
22966
|
+
this.config = init.config;
|
|
22906
22967
|
this.database = init.database;
|
|
22907
22968
|
this.tinaSchema = init.tinaSchema;
|
|
22908
22969
|
}
|
|
@@ -22939,17 +23000,22 @@ var resolveDateInput = (value) => {
|
|
|
22939
23000
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolve.ts
|
|
22940
23001
|
var import_relay_operation_optimizer = __toModule(require("@graphql-tools/relay-operation-optimizer"));
|
|
22941
23002
|
var resolve = async ({
|
|
23003
|
+
config,
|
|
22942
23004
|
query,
|
|
22943
23005
|
variables,
|
|
22944
23006
|
database,
|
|
22945
23007
|
silenceErrors
|
|
22946
23008
|
}) => {
|
|
23009
|
+
var _a;
|
|
22947
23010
|
try {
|
|
22948
23011
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
22949
23012
|
const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
|
|
22950
|
-
const
|
|
22951
|
-
const tinaSchema = await createSchema({
|
|
22952
|
-
|
|
23013
|
+
const tinaConfig = await database.getTinaSchema();
|
|
23014
|
+
const tinaSchema = await createSchema({
|
|
23015
|
+
schema: tinaConfig,
|
|
23016
|
+
flags: (_a = tinaConfig == null ? void 0 : tinaConfig.meta) == null ? void 0 : _a.flags
|
|
23017
|
+
});
|
|
23018
|
+
const resolver2 = await createResolver2({ config, database, tinaSchema });
|
|
22953
23019
|
const res = await (0, import_graphql3.graphql)({
|
|
22954
23020
|
schema: graphQLSchema,
|
|
22955
23021
|
source: query,
|
|
@@ -22981,19 +23047,19 @@ var resolve = async ({
|
|
|
22981
23047
|
if (info.fieldName === "collections") {
|
|
22982
23048
|
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
22983
23049
|
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
22984
|
-
var
|
|
22985
|
-
return ((
|
|
23050
|
+
var _a2;
|
|
23051
|
+
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
22986
23052
|
});
|
|
22987
23053
|
return tinaSchema.getCollections().map((collection) => {
|
|
22988
|
-
return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
|
|
23054
|
+
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
22989
23055
|
});
|
|
22990
23056
|
}
|
|
22991
23057
|
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
22992
23058
|
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
22993
|
-
var
|
|
22994
|
-
return ((
|
|
23059
|
+
var _a2;
|
|
23060
|
+
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
22995
23061
|
});
|
|
22996
|
-
return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
|
|
23062
|
+
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
22997
23063
|
}
|
|
22998
23064
|
if (info.fieldName === "getOptimizedQuery") {
|
|
22999
23065
|
try {
|
|
@@ -23054,6 +23120,11 @@ var resolve = async ({
|
|
|
23054
23120
|
return { node: document3 };
|
|
23055
23121
|
})
|
|
23056
23122
|
};
|
|
23123
|
+
} else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
|
|
23124
|
+
return resolver2.resolveCollectionConnection({
|
|
23125
|
+
args,
|
|
23126
|
+
collection: value.collection
|
|
23127
|
+
});
|
|
23057
23128
|
} else {
|
|
23058
23129
|
throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
|
|
23059
23130
|
}
|
|
@@ -23175,6 +23246,7 @@ var parseFile = (content3, format, yupSchema) => {
|
|
|
23175
23246
|
throw new Error(`Must specify a valid format, got ${format}`);
|
|
23176
23247
|
}
|
|
23177
23248
|
};
|
|
23249
|
+
var normalizePath = (filepath) => filepath.replace(/\\/g, "/");
|
|
23178
23250
|
|
|
23179
23251
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/database/index.ts
|
|
23180
23252
|
var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
|
|
@@ -23192,7 +23264,7 @@ var Database = class {
|
|
|
23192
23264
|
this.config = config;
|
|
23193
23265
|
this.collectionForPath = async (filepath) => {
|
|
23194
23266
|
const tinaSchema = await this.getSchema();
|
|
23195
|
-
const collection = tinaSchema.
|
|
23267
|
+
const collection = await tinaSchema.getCollectionByFullPath(filepath);
|
|
23196
23268
|
return collection;
|
|
23197
23269
|
};
|
|
23198
23270
|
this.get = async (filepath) => {
|
|
@@ -23201,7 +23273,7 @@ var Database = class {
|
|
|
23201
23273
|
} else {
|
|
23202
23274
|
const tinaSchema = await this.getSchema();
|
|
23203
23275
|
const extension2 = import_path4.default.extname(filepath);
|
|
23204
|
-
const contentObject = await this.store.get(filepath);
|
|
23276
|
+
const contentObject = await this.store.get(normalizePath(filepath));
|
|
23205
23277
|
if (!contentObject) {
|
|
23206
23278
|
throw new import_graphql4.GraphQLError(`Unable to find record ${filepath}`);
|
|
23207
23279
|
}
|
|
@@ -23241,9 +23313,9 @@ var Database = class {
|
|
|
23241
23313
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23242
23314
|
}
|
|
23243
23315
|
if (this.store.supportsSeeding()) {
|
|
23244
|
-
await this.bridge.put(filepath, stringifiedFile);
|
|
23316
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23245
23317
|
}
|
|
23246
|
-
await this.store.put(filepath, payload, {
|
|
23318
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23247
23319
|
keepTemplateKey,
|
|
23248
23320
|
collection: collection == null ? void 0 : collection.name,
|
|
23249
23321
|
indexDefinitions: collectionIndexDefinitions
|
|
@@ -23260,9 +23332,9 @@ var Database = class {
|
|
|
23260
23332
|
}
|
|
23261
23333
|
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23262
23334
|
if (this.store.supportsSeeding()) {
|
|
23263
|
-
await this.bridge.put(filepath, stringifiedFile);
|
|
23335
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23264
23336
|
}
|
|
23265
|
-
await this.store.put(filepath, payload, {
|
|
23337
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23266
23338
|
keepTemplateKey,
|
|
23267
23339
|
collection,
|
|
23268
23340
|
indexDefinitions: collectionIndexDefinitions
|
|
@@ -23327,23 +23399,23 @@ var Database = class {
|
|
|
23327
23399
|
this.getLookup = async (returnType) => {
|
|
23328
23400
|
const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
|
|
23329
23401
|
if (!this._lookup) {
|
|
23330
|
-
const _lookup = await this.store.get(lookupPath);
|
|
23402
|
+
const _lookup = await this.store.get(normalizePath(lookupPath));
|
|
23331
23403
|
this._lookup = _lookup;
|
|
23332
23404
|
}
|
|
23333
23405
|
return this._lookup[returnType];
|
|
23334
23406
|
};
|
|
23335
23407
|
this.getGraphQLSchema = async () => {
|
|
23336
23408
|
const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
|
|
23337
|
-
return this.store.get(graphqlPath);
|
|
23409
|
+
return this.store.get(normalizePath(graphqlPath));
|
|
23338
23410
|
};
|
|
23339
23411
|
this.getGraphQLSchemaFromBridge = async () => {
|
|
23340
23412
|
const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
|
|
23341
|
-
const _graphql = await this.bridge.get(graphqlPath);
|
|
23413
|
+
const _graphql = await this.bridge.get(normalizePath(graphqlPath));
|
|
23342
23414
|
return JSON.parse(_graphql);
|
|
23343
23415
|
};
|
|
23344
23416
|
this.getTinaSchema = async () => {
|
|
23345
23417
|
const schemaPath = import_path4.default.join(GENERATED_FOLDER, `_schema.json`);
|
|
23346
|
-
return this.store.get(schemaPath);
|
|
23418
|
+
return this.store.get(normalizePath(schemaPath));
|
|
23347
23419
|
};
|
|
23348
23420
|
this.getSchema = async () => {
|
|
23349
23421
|
if (this.tinaSchema) {
|
|
@@ -23463,8 +23535,8 @@ var Database = class {
|
|
|
23463
23535
|
tinaSchema
|
|
23464
23536
|
}) => {
|
|
23465
23537
|
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));
|
|
23538
|
+
await this.bridge.putConfig(normalizePath(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`)), JSON.stringify(graphQLSchema));
|
|
23539
|
+
await this.bridge.putConfig(normalizePath(import_path4.default.join(GENERATED_FOLDER, `_schema.json`)), JSON.stringify(tinaSchema.schema));
|
|
23468
23540
|
}
|
|
23469
23541
|
};
|
|
23470
23542
|
this.indexContent = async ({
|
|
@@ -23472,12 +23544,12 @@ var Database = class {
|
|
|
23472
23544
|
tinaSchema
|
|
23473
23545
|
}) => {
|
|
23474
23546
|
await this.indexStatusCallbackWrapper(async () => {
|
|
23475
|
-
const lookup = JSON.parse(await this.bridge.get(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")));
|
|
23547
|
+
const lookup = JSON.parse(await this.bridge.get(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_lookup.json"))));
|
|
23476
23548
|
if (this.store.supportsSeeding()) {
|
|
23477
23549
|
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);
|
|
23550
|
+
await this.store.seed(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_graphql.json")), graphQLSchema);
|
|
23551
|
+
await this.store.seed(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_schema.json")), tinaSchema.schema);
|
|
23552
|
+
await this.store.seed(normalizePath(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")), lookup);
|
|
23481
23553
|
await this._indexAllContent();
|
|
23482
23554
|
} else {
|
|
23483
23555
|
if (this.store.supportsIndexing()) {
|
|
@@ -23505,23 +23577,22 @@ var Database = class {
|
|
|
23505
23577
|
});
|
|
23506
23578
|
};
|
|
23507
23579
|
this.delete = async (filepath) => {
|
|
23508
|
-
const
|
|
23509
|
-
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23580
|
+
const collection = await this.collectionForPath(filepath);
|
|
23510
23581
|
let collectionIndexDefinitions;
|
|
23511
23582
|
if (collection) {
|
|
23512
23583
|
const indexDefinitions = await this.getIndexDefinitions();
|
|
23513
23584
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23514
23585
|
}
|
|
23515
|
-
await this.store.delete(filepath, {
|
|
23586
|
+
await this.store.delete(normalizePath(filepath), {
|
|
23516
23587
|
collection: collection.name,
|
|
23517
23588
|
indexDefinitions: collectionIndexDefinitions
|
|
23518
23589
|
});
|
|
23519
|
-
await this.bridge.delete(filepath);
|
|
23590
|
+
await this.bridge.delete(normalizePath(filepath));
|
|
23520
23591
|
};
|
|
23521
23592
|
this._indexAllContent = async () => {
|
|
23522
23593
|
const tinaSchema = await this.getSchema();
|
|
23523
23594
|
await sequential(tinaSchema.getCollections(), async (collection) => {
|
|
23524
|
-
const documentPaths = await this.bridge.glob(collection.path);
|
|
23595
|
+
const documentPaths = await this.bridge.glob(normalizePath(collection.path));
|
|
23525
23596
|
await _indexContent(this, documentPaths, collection);
|
|
23526
23597
|
});
|
|
23527
23598
|
};
|
|
@@ -23529,14 +23600,14 @@ var Database = class {
|
|
|
23529
23600
|
const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
|
|
23530
23601
|
let lookupMap;
|
|
23531
23602
|
try {
|
|
23532
|
-
lookupMap = JSON.parse(await this.bridge.get(lookupPath));
|
|
23603
|
+
lookupMap = JSON.parse(await this.bridge.get(normalizePath(lookupPath)));
|
|
23533
23604
|
} catch (e) {
|
|
23534
23605
|
lookupMap = {};
|
|
23535
23606
|
}
|
|
23536
23607
|
const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
|
|
23537
23608
|
[lookup.type]: lookup
|
|
23538
23609
|
});
|
|
23539
|
-
await this.bridge.putConfig(lookupPath, JSON.stringify(updatedLookup));
|
|
23610
|
+
await this.bridge.putConfig(normalizePath(lookupPath), JSON.stringify(updatedLookup));
|
|
23540
23611
|
};
|
|
23541
23612
|
this.bridge = config.bridge;
|
|
23542
23613
|
this.store = config.store;
|
|
@@ -23560,6 +23631,10 @@ var Database = class {
|
|
|
23560
23631
|
}
|
|
23561
23632
|
return { pathsByCollection, nonCollectionPaths, collections };
|
|
23562
23633
|
}
|
|
23634
|
+
clearCache() {
|
|
23635
|
+
this.tinaSchema = null;
|
|
23636
|
+
this._lookup = null;
|
|
23637
|
+
}
|
|
23563
23638
|
async indexStatusCallbackWrapper(fn) {
|
|
23564
23639
|
await this.indexStatusCallback({ status: "inprogress" });
|
|
23565
23640
|
try {
|
|
@@ -23592,10 +23667,10 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
23592
23667
|
};
|
|
23593
23668
|
}
|
|
23594
23669
|
await sequential(documentPaths, async (filepath) => {
|
|
23595
|
-
const dataString = await database.bridge.get(filepath);
|
|
23670
|
+
const dataString = await database.bridge.get(normalizePath(filepath));
|
|
23596
23671
|
const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
|
|
23597
23672
|
if (database.store.supportsSeeding()) {
|
|
23598
|
-
await database.store.seed(filepath, data, seedOptions);
|
|
23673
|
+
await database.store.seed(normalizePath(filepath), data, seedOptions);
|
|
23599
23674
|
}
|
|
23600
23675
|
});
|
|
23601
23676
|
};
|
|
@@ -23618,11 +23693,11 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
|
|
|
23618
23693
|
};
|
|
23619
23694
|
|
|
23620
23695
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
23621
|
-
var buildSchema = async (rootPath, database) => {
|
|
23696
|
+
var buildSchema = async (rootPath, database, flags) => {
|
|
23622
23697
|
const tempConfig = import_path5.default.join(rootPath, ".tina", "__generated__", "config");
|
|
23623
23698
|
const config = await import_fs_extra2.default.readFileSync(import_path5.default.join(tempConfig, "schema.json")).toString();
|
|
23624
23699
|
await import_fs_extra2.default.rmdir(tempConfig, { recursive: true });
|
|
23625
|
-
await indexDB({ database, config: JSON.parse(config) });
|
|
23700
|
+
await indexDB({ database, config: JSON.parse(config), flags });
|
|
23626
23701
|
const gqlAst = await database.getGraphQLSchemaFromBridge();
|
|
23627
23702
|
return (0, import_graphql5.buildASTSchema)(gqlAst);
|
|
23628
23703
|
};
|
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;
|
|
@@ -191,7 +203,6 @@ export declare class Resolver {
|
|
|
191
203
|
};
|
|
192
204
|
}[];
|
|
193
205
|
}>;
|
|
194
|
-
getDocumentsForCollection: (collectionName: string) => Promise<string[]>;
|
|
195
206
|
private referenceResolver;
|
|
196
207
|
private resolveFilterConditions;
|
|
197
208
|
resolveCollectionConnection: ({ args, collection, hydrator, }: {
|
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.0.0-
|
|
3
|
+
"version": "0.0.0-2022510161017",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -42,11 +42,12 @@
|
|
|
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",
|
|
49
|
-
"@tinacms/datalayer": "0.
|
|
50
|
+
"@tinacms/datalayer": "0.0.0-2022510161017",
|
|
50
51
|
"body-parser": "^1.19.0",
|
|
51
52
|
"cors": "^2.8.5",
|
|
52
53
|
"dataloader": "^2.0.0",
|
|
@@ -96,7 +97,8 @@
|
|
|
96
97
|
"directory": "packages/tina-graphql"
|
|
97
98
|
},
|
|
98
99
|
"devDependencies": {
|
|
99
|
-
"@tinacms/datalayer": "0.
|
|
100
|
+
"@tinacms/datalayer": "0.0.0-2022510161017",
|
|
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
|
}
|