@tinacms/graphql 0.60.2 → 0.60.3
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 +9 -0
- package/dist/build.d.ts +2 -1
- package/dist/database/util.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -43
- package/dist/types.d.ts +1 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
+
## 0.60.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
|
|
8
|
+
- 3f46c6706: Fixed issue where generated SDK would not work with templates
|
|
9
|
+
- db9168578: Adds support for an `assetsHost` when resolving `image` fields with `useRelativeMedia`
|
|
10
|
+
- 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
|
|
11
|
+
|
|
3
12
|
## 0.60.2
|
|
4
13
|
|
|
5
14
|
### 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/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: {
|
|
@@ -12448,7 +12480,7 @@ var validateField = async (field) => {
|
|
|
12448
12480
|
|
|
12449
12481
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12450
12482
|
var name = "@tinacms/graphql";
|
|
12451
|
-
var version = "0.60.
|
|
12483
|
+
var version = "0.60.3";
|
|
12452
12484
|
var main = "dist/index.js";
|
|
12453
12485
|
var typings = "dist/index.d.ts";
|
|
12454
12486
|
var files = [
|
|
@@ -12490,7 +12522,8 @@ var scripts = {
|
|
|
12490
12522
|
build: 'echo "Run `yarn build` from the root of the repository instead"',
|
|
12491
12523
|
docs: "yarn typedoc",
|
|
12492
12524
|
serve: "yarn nodemon dist/server.js",
|
|
12493
|
-
test: "jest"
|
|
12525
|
+
test: "jest",
|
|
12526
|
+
"test-watch": "jest --watch"
|
|
12494
12527
|
};
|
|
12495
12528
|
var dependencies = {
|
|
12496
12529
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
@@ -12773,11 +12806,13 @@ var import_path = __toModule(require("path"));
|
|
|
12773
12806
|
var indexDB = async ({
|
|
12774
12807
|
database,
|
|
12775
12808
|
config,
|
|
12809
|
+
flags = [],
|
|
12776
12810
|
buildSDK = true
|
|
12777
12811
|
}) => {
|
|
12778
|
-
const flags = [];
|
|
12779
12812
|
if (database.store.supportsIndexing()) {
|
|
12780
|
-
flags.
|
|
12813
|
+
if (flags.indexOf("experimentalData") === -1) {
|
|
12814
|
+
flags.push("experimentalData");
|
|
12815
|
+
}
|
|
12781
12816
|
}
|
|
12782
12817
|
const tinaSchema = await createSchema({ schema: config, flags });
|
|
12783
12818
|
const builder = await createBuilder({
|
|
@@ -22856,7 +22891,7 @@ var Resolver = class {
|
|
|
22856
22891
|
if (this.config.useRelativeMedia === true) {
|
|
22857
22892
|
accumulator[field.name] = value;
|
|
22858
22893
|
} else {
|
|
22859
|
-
accumulator[field.name] = `https
|
|
22894
|
+
accumulator[field.name] = `https://${this.config.assetsHost}/${this.config.clientId}/${value}`;
|
|
22860
22895
|
}
|
|
22861
22896
|
} else {
|
|
22862
22897
|
accumulator[field.name] = value;
|
|
@@ -23208,6 +23243,7 @@ var parseFile = (content3, format, yupSchema) => {
|
|
|
23208
23243
|
throw new Error(`Must specify a valid format, got ${format}`);
|
|
23209
23244
|
}
|
|
23210
23245
|
};
|
|
23246
|
+
var normalizePath = (filepath) => filepath.replace(/\\/g, "/");
|
|
23211
23247
|
|
|
23212
23248
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/database/index.ts
|
|
23213
23249
|
var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
|
|
@@ -23234,7 +23270,7 @@ var Database = class {
|
|
|
23234
23270
|
} else {
|
|
23235
23271
|
const tinaSchema = await this.getSchema();
|
|
23236
23272
|
const extension2 = import_path4.default.extname(filepath);
|
|
23237
|
-
const contentObject = await this.store.get(filepath);
|
|
23273
|
+
const contentObject = await this.store.get(normalizePath(filepath));
|
|
23238
23274
|
if (!contentObject) {
|
|
23239
23275
|
throw new import_graphql4.GraphQLError(`Unable to find record ${filepath}`);
|
|
23240
23276
|
}
|
|
@@ -23274,9 +23310,9 @@ var Database = class {
|
|
|
23274
23310
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23275
23311
|
}
|
|
23276
23312
|
if (this.store.supportsSeeding()) {
|
|
23277
|
-
await this.bridge.put(filepath, stringifiedFile);
|
|
23313
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23278
23314
|
}
|
|
23279
|
-
await this.store.put(filepath, payload, {
|
|
23315
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23280
23316
|
keepTemplateKey,
|
|
23281
23317
|
collection: collection == null ? void 0 : collection.name,
|
|
23282
23318
|
indexDefinitions: collectionIndexDefinitions
|
|
@@ -23293,9 +23329,9 @@ var Database = class {
|
|
|
23293
23329
|
}
|
|
23294
23330
|
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23295
23331
|
if (this.store.supportsSeeding()) {
|
|
23296
|
-
await this.bridge.put(filepath, stringifiedFile);
|
|
23332
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23297
23333
|
}
|
|
23298
|
-
await this.store.put(filepath, payload, {
|
|
23334
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23299
23335
|
keepTemplateKey,
|
|
23300
23336
|
collection,
|
|
23301
23337
|
indexDefinitions: collectionIndexDefinitions
|
|
@@ -23360,23 +23396,23 @@ var Database = class {
|
|
|
23360
23396
|
this.getLookup = async (returnType) => {
|
|
23361
23397
|
const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
|
|
23362
23398
|
if (!this._lookup) {
|
|
23363
|
-
const _lookup = await this.store.get(lookupPath);
|
|
23399
|
+
const _lookup = await this.store.get(normalizePath(lookupPath));
|
|
23364
23400
|
this._lookup = _lookup;
|
|
23365
23401
|
}
|
|
23366
23402
|
return this._lookup[returnType];
|
|
23367
23403
|
};
|
|
23368
23404
|
this.getGraphQLSchema = async () => {
|
|
23369
23405
|
const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
|
|
23370
|
-
return this.store.get(graphqlPath);
|
|
23406
|
+
return this.store.get(normalizePath(graphqlPath));
|
|
23371
23407
|
};
|
|
23372
23408
|
this.getGraphQLSchemaFromBridge = async () => {
|
|
23373
23409
|
const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
|
|
23374
|
-
const _graphql = await this.bridge.get(graphqlPath);
|
|
23410
|
+
const _graphql = await this.bridge.get(normalizePath(graphqlPath));
|
|
23375
23411
|
return JSON.parse(_graphql);
|
|
23376
23412
|
};
|
|
23377
23413
|
this.getTinaSchema = async () => {
|
|
23378
23414
|
const schemaPath = import_path4.default.join(GENERATED_FOLDER, `_schema.json`);
|
|
23379
|
-
return this.store.get(schemaPath);
|
|
23415
|
+
return this.store.get(normalizePath(schemaPath));
|
|
23380
23416
|
};
|
|
23381
23417
|
this.getSchema = async () => {
|
|
23382
23418
|
if (this.tinaSchema) {
|
|
@@ -23496,8 +23532,8 @@ var Database = class {
|
|
|
23496
23532
|
tinaSchema
|
|
23497
23533
|
}) => {
|
|
23498
23534
|
if (this.bridge.supportsBuilding()) {
|
|
23499
|
-
await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`), JSON.stringify(graphQLSchema));
|
|
23500
|
-
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));
|
|
23501
23537
|
}
|
|
23502
23538
|
};
|
|
23503
23539
|
this.indexContent = async ({
|
|
@@ -23505,12 +23541,12 @@ var Database = class {
|
|
|
23505
23541
|
tinaSchema
|
|
23506
23542
|
}) => {
|
|
23507
23543
|
await this.indexStatusCallbackWrapper(async () => {
|
|
23508
|
-
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"))));
|
|
23509
23545
|
if (this.store.supportsSeeding()) {
|
|
23510
23546
|
await this.store.clear();
|
|
23511
|
-
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_graphql.json"), graphQLSchema);
|
|
23512
|
-
await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_schema.json"), tinaSchema.schema);
|
|
23513
|
-
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);
|
|
23514
23550
|
await this._indexAllContent();
|
|
23515
23551
|
} else {
|
|
23516
23552
|
if (this.store.supportsIndexing()) {
|
|
@@ -23544,16 +23580,16 @@ var Database = class {
|
|
|
23544
23580
|
const indexDefinitions = await this.getIndexDefinitions();
|
|
23545
23581
|
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
|
|
23546
23582
|
}
|
|
23547
|
-
await this.store.delete(filepath, {
|
|
23583
|
+
await this.store.delete(normalizePath(filepath), {
|
|
23548
23584
|
collection: collection.name,
|
|
23549
23585
|
indexDefinitions: collectionIndexDefinitions
|
|
23550
23586
|
});
|
|
23551
|
-
await this.bridge.delete(filepath);
|
|
23587
|
+
await this.bridge.delete(normalizePath(filepath));
|
|
23552
23588
|
};
|
|
23553
23589
|
this._indexAllContent = async () => {
|
|
23554
23590
|
const tinaSchema = await this.getSchema();
|
|
23555
23591
|
await sequential(tinaSchema.getCollections(), async (collection) => {
|
|
23556
|
-
const documentPaths = await this.bridge.glob(collection.path);
|
|
23592
|
+
const documentPaths = await this.bridge.glob(normalizePath(collection.path));
|
|
23557
23593
|
await _indexContent(this, documentPaths, collection);
|
|
23558
23594
|
});
|
|
23559
23595
|
};
|
|
@@ -23561,14 +23597,14 @@ var Database = class {
|
|
|
23561
23597
|
const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
|
|
23562
23598
|
let lookupMap;
|
|
23563
23599
|
try {
|
|
23564
|
-
lookupMap = JSON.parse(await this.bridge.get(lookupPath));
|
|
23600
|
+
lookupMap = JSON.parse(await this.bridge.get(normalizePath(lookupPath)));
|
|
23565
23601
|
} catch (e) {
|
|
23566
23602
|
lookupMap = {};
|
|
23567
23603
|
}
|
|
23568
23604
|
const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
|
|
23569
23605
|
[lookup.type]: lookup
|
|
23570
23606
|
});
|
|
23571
|
-
await this.bridge.putConfig(lookupPath, JSON.stringify(updatedLookup));
|
|
23607
|
+
await this.bridge.putConfig(normalizePath(lookupPath), JSON.stringify(updatedLookup));
|
|
23572
23608
|
};
|
|
23573
23609
|
this.bridge = config.bridge;
|
|
23574
23610
|
this.store = config.store;
|
|
@@ -23624,10 +23660,10 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
23624
23660
|
};
|
|
23625
23661
|
}
|
|
23626
23662
|
await sequential(documentPaths, async (filepath) => {
|
|
23627
|
-
const dataString = await database.bridge.get(filepath);
|
|
23663
|
+
const dataString = await database.bridge.get(normalizePath(filepath));
|
|
23628
23664
|
const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
|
|
23629
23665
|
if (database.store.supportsSeeding()) {
|
|
23630
|
-
await database.store.seed(filepath, data, seedOptions);
|
|
23666
|
+
await database.store.seed(normalizePath(filepath), data, seedOptions);
|
|
23631
23667
|
}
|
|
23632
23668
|
});
|
|
23633
23669
|
};
|
|
@@ -23650,11 +23686,11 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
|
|
|
23650
23686
|
};
|
|
23651
23687
|
|
|
23652
23688
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
23653
|
-
var buildSchema = async (rootPath, database) => {
|
|
23689
|
+
var buildSchema = async (rootPath, database, flags) => {
|
|
23654
23690
|
const tempConfig = import_path5.default.join(rootPath, ".tina", "__generated__", "config");
|
|
23655
23691
|
const config = await import_fs_extra2.default.readFileSync(import_path5.default.join(tempConfig, "schema.json")).toString();
|
|
23656
23692
|
await import_fs_extra2.default.rmdir(tempConfig, { recursive: true });
|
|
23657
|
-
await indexDB({ database, config: JSON.parse(config) });
|
|
23693
|
+
await indexDB({ database, config: JSON.parse(config), flags });
|
|
23658
23694
|
const gqlAst = await database.getGraphQLSchemaFromBridge();
|
|
23659
23695
|
return (0, import_graphql5.buildASTSchema)(gqlAst);
|
|
23660
23696
|
};
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.3",
|
|
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",
|