@tinacms/graphql 0.0.0-202241918385 → 0.0.0-20224201864

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 CHANGED
@@ -1,11 +1,12 @@
1
1
  # tina-graphql
2
2
 
3
- ## 0.0.0-202241918385
3
+ ## 0.0.0-20224201864
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
8
- - c80bcf27d: Fix issues with experimentalData on windows
8
+ - 3f46c6706: Fixed issue where generated SDK would not work with templates
9
+ - 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
9
10
 
10
11
  ## 0.60.2
11
12
 
@@ -47,7 +47,6 @@ export declare class Database {
47
47
  private _graphql;
48
48
  private _tinaSchema;
49
49
  constructor(config: CreateDatabase);
50
- private normalizePath;
51
50
  private collectionForPath;
52
51
  private partitionPathsByCollection;
53
52
  get: <T extends object>(filepath: string) => Promise<T>;
@@ -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.js CHANGED
@@ -10911,15 +10911,31 @@ var astBuilder = {
10911
10911
  selectionSet: {
10912
10912
  kind: "SelectionSet",
10913
10913
  selections: [
10914
- SysFieldDefinition,
10915
10914
  {
10916
- kind: "Field",
10917
- name: {
10918
- kind: "Name",
10919
- value: "id"
10915
+ kind: "InlineFragment",
10916
+ typeCondition: {
10917
+ kind: "NamedType",
10918
+ name: {
10919
+ kind: "Name",
10920
+ value: "Document"
10921
+ }
10920
10922
  },
10921
- arguments: [],
10922
- directives: []
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: "Field",
10999
- name: {
11000
- kind: "Name",
11001
- value: "id"
11014
+ kind: "InlineFragment",
11015
+ typeCondition: {
11016
+ kind: "NamedType",
11017
+ name: {
11018
+ kind: "Name",
11019
+ value: "Document"
11020
+ }
11002
11021
  },
11003
- arguments: [],
11004
- directives: []
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: {
@@ -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",
@@ -22672,7 +22705,6 @@ var Resolver = class {
22672
22705
  assertShape(args, (yup3) => yup3.object({ relativePath: yup3.string().required() }));
22673
22706
  const collection = await this.tinaSchema.getCollection(collectionLookup);
22674
22707
  const realPath = import_path3.default.join(collection == null ? void 0 : collection.path, args.relativePath);
22675
- console.log(collection == null ? void 0 : collection.path, args.relativePath, realPath);
22676
22708
  const alreadyExists = await this.database.documentExists(realPath);
22677
22709
  if (isMutation) {
22678
22710
  if (isCreation) {
@@ -23005,7 +23037,6 @@ var resolve = async ({
23005
23037
  const lookup = await database.getLookup(returnType);
23006
23038
  const isMutation = info.parentType.toString() === "Mutation";
23007
23039
  const value = source[info.fieldName];
23008
- console.log(returnType);
23009
23040
  if (returnType === "Collection") {
23010
23041
  if (value) {
23011
23042
  return value;
@@ -23043,18 +23074,15 @@ var resolve = async ({
23043
23074
  return value;
23044
23075
  }
23045
23076
  const isCreation = lookup[info.fieldName] === "create";
23046
- console.log("h", lookup.resolveType);
23047
23077
  switch (lookup.resolveType) {
23048
23078
  case "nodeDocument":
23049
23079
  assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23050
23080
  return resolver2.getDocument(args.id);
23051
23081
  case "multiCollectionDocument":
23052
23082
  if (typeof value === "string") {
23053
- console.log("a - calling getDocument");
23054
23083
  return resolver2.getDocument(value);
23055
23084
  }
23056
23085
  if (args && args.collection && info.fieldName === "addPendingDocument") {
23057
- console.log("b - calling resolveDocument");
23058
23086
  return resolver2.resolveDocument({
23059
23087
  args: __spreadProps(__spreadValues({}, args), { params: {} }),
23060
23088
  collection: args.collection,
@@ -23069,7 +23097,6 @@ var resolve = async ({
23069
23097
  "updateDocument",
23070
23098
  "deleteDocument"
23071
23099
  ].includes(info.fieldName)) {
23072
- console.log("c - calling resolveDocument", args);
23073
23100
  const result2 = await resolver2.resolveDocument({
23074
23101
  args,
23075
23102
  collection: args.collection,
@@ -23216,6 +23243,7 @@ var parseFile = (content3, format, yupSchema) => {
23216
23243
  throw new Error(`Must specify a valid format, got ${format}`);
23217
23244
  }
23218
23245
  };
23246
+ var normalizePath = (filepath) => filepath.replace(/\\/g, "/");
23219
23247
 
23220
23248
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/database/index.ts
23221
23249
  var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
@@ -23231,7 +23259,6 @@ var defaultStatusCallback = () => Promise.resolve();
23231
23259
  var Database = class {
23232
23260
  constructor(config) {
23233
23261
  this.config = config;
23234
- this.normalizePath = (filepath) => filepath.replace("\\", "/");
23235
23262
  this.collectionForPath = async (filepath) => {
23236
23263
  const tinaSchema = await this.getSchema();
23237
23264
  const collection = await tinaSchema.getCollectionByFullPath(filepath);
@@ -23243,7 +23270,7 @@ var Database = class {
23243
23270
  } else {
23244
23271
  const tinaSchema = await this.getSchema();
23245
23272
  const extension2 = import_path4.default.extname(filepath);
23246
- const contentObject = await this.store.get(this.normalizePath(filepath));
23273
+ const contentObject = await this.store.get(normalizePath(filepath));
23247
23274
  if (!contentObject) {
23248
23275
  throw new import_graphql4.GraphQLError(`Unable to find record ${filepath}`);
23249
23276
  }
@@ -23283,9 +23310,9 @@ var Database = class {
23283
23310
  collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
23284
23311
  }
23285
23312
  if (this.store.supportsSeeding()) {
23286
- await this.bridge.put(this.normalizePath(filepath), stringifiedFile);
23313
+ await this.bridge.put(normalizePath(filepath), stringifiedFile);
23287
23314
  }
23288
- await this.store.put(this.normalizePath(filepath), payload, {
23315
+ await this.store.put(normalizePath(filepath), payload, {
23289
23316
  keepTemplateKey,
23290
23317
  collection: collection == null ? void 0 : collection.name,
23291
23318
  indexDefinitions: collectionIndexDefinitions
@@ -23302,9 +23329,9 @@ var Database = class {
23302
23329
  }
23303
23330
  const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23304
23331
  if (this.store.supportsSeeding()) {
23305
- await this.bridge.put(this.normalizePath(filepath), stringifiedFile);
23332
+ await this.bridge.put(normalizePath(filepath), stringifiedFile);
23306
23333
  }
23307
- await this.store.put(this.normalizePath(filepath), payload, {
23334
+ await this.store.put(normalizePath(filepath), payload, {
23308
23335
  keepTemplateKey,
23309
23336
  collection,
23310
23337
  indexDefinitions: collectionIndexDefinitions
@@ -23369,23 +23396,23 @@ var Database = class {
23369
23396
  this.getLookup = async (returnType) => {
23370
23397
  const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
23371
23398
  if (!this._lookup) {
23372
- const _lookup = await this.store.get(this.normalizePath(lookupPath));
23399
+ const _lookup = await this.store.get(normalizePath(lookupPath));
23373
23400
  this._lookup = _lookup;
23374
23401
  }
23375
23402
  return this._lookup[returnType];
23376
23403
  };
23377
23404
  this.getGraphQLSchema = async () => {
23378
23405
  const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
23379
- return this.store.get(this.normalizePath(graphqlPath));
23406
+ return this.store.get(normalizePath(graphqlPath));
23380
23407
  };
23381
23408
  this.getGraphQLSchemaFromBridge = async () => {
23382
23409
  const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
23383
- const _graphql = await this.bridge.get(this.normalizePath(graphqlPath));
23410
+ const _graphql = await this.bridge.get(normalizePath(graphqlPath));
23384
23411
  return JSON.parse(_graphql);
23385
23412
  };
23386
23413
  this.getTinaSchema = async () => {
23387
23414
  const schemaPath = import_path4.default.join(GENERATED_FOLDER, `_schema.json`);
23388
- return this.store.get(this.normalizePath(schemaPath));
23415
+ return this.store.get(normalizePath(schemaPath));
23389
23416
  };
23390
23417
  this.getSchema = async () => {
23391
23418
  if (this.tinaSchema) {
@@ -23505,8 +23532,8 @@ var Database = class {
23505
23532
  tinaSchema
23506
23533
  }) => {
23507
23534
  if (this.bridge.supportsBuilding()) {
23508
- await this.bridge.putConfig(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`)), JSON.stringify(graphQLSchema));
23509
- await this.bridge.putConfig(this.normalizePath(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));
23510
23537
  }
23511
23538
  };
23512
23539
  this.indexContent = async ({
@@ -23514,12 +23541,12 @@ var Database = class {
23514
23541
  tinaSchema
23515
23542
  }) => {
23516
23543
  await this.indexStatusCallbackWrapper(async () => {
23517
- const lookup = JSON.parse(await this.bridge.get(this.normalizePath(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"))));
23518
23545
  if (this.store.supportsSeeding()) {
23519
23546
  await this.store.clear();
23520
- await this.store.seed(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, "_graphql.json")), graphQLSchema);
23521
- await this.store.seed(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, "_schema.json")), tinaSchema.schema);
23522
- await this.store.seed(this.normalizePath(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);
23523
23550
  await this._indexAllContent();
23524
23551
  } else {
23525
23552
  if (this.store.supportsIndexing()) {
@@ -23553,16 +23580,16 @@ var Database = class {
23553
23580
  const indexDefinitions = await this.getIndexDefinitions();
23554
23581
  collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
23555
23582
  }
23556
- await this.store.delete(this.normalizePath(filepath), {
23583
+ await this.store.delete(normalizePath(filepath), {
23557
23584
  collection: collection.name,
23558
23585
  indexDefinitions: collectionIndexDefinitions
23559
23586
  });
23560
- await this.bridge.delete(this.normalizePath(filepath));
23587
+ await this.bridge.delete(normalizePath(filepath));
23561
23588
  };
23562
23589
  this._indexAllContent = async () => {
23563
23590
  const tinaSchema = await this.getSchema();
23564
23591
  await sequential(tinaSchema.getCollections(), async (collection) => {
23565
- const documentPaths = await this.bridge.glob(this.normalizePath(collection.path));
23592
+ const documentPaths = await this.bridge.glob(normalizePath(collection.path));
23566
23593
  await _indexContent(this, documentPaths, collection);
23567
23594
  });
23568
23595
  };
@@ -23570,14 +23597,14 @@ var Database = class {
23570
23597
  const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
23571
23598
  let lookupMap;
23572
23599
  try {
23573
- lookupMap = JSON.parse(await this.bridge.get(this.normalizePath(lookupPath)));
23600
+ lookupMap = JSON.parse(await this.bridge.get(normalizePath(lookupPath)));
23574
23601
  } catch (e) {
23575
23602
  lookupMap = {};
23576
23603
  }
23577
23604
  const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
23578
23605
  [lookup.type]: lookup
23579
23606
  });
23580
- await this.bridge.putConfig(this.normalizePath(lookupPath), JSON.stringify(updatedLookup));
23607
+ await this.bridge.putConfig(normalizePath(lookupPath), JSON.stringify(updatedLookup));
23581
23608
  };
23582
23609
  this.bridge = config.bridge;
23583
23610
  this.store = config.store;
@@ -23633,11 +23660,10 @@ var _indexContent = async (database, documentPaths, collection) => {
23633
23660
  };
23634
23661
  }
23635
23662
  await sequential(documentPaths, async (filepath) => {
23636
- const dataString = await database.bridge.get(filepath);
23663
+ const dataString = await database.bridge.get(normalizePath(filepath));
23637
23664
  const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
23638
23665
  if (database.store.supportsSeeding()) {
23639
- console.log("seeding ", filepath);
23640
- await database.store.seed(filepath, data, seedOptions);
23666
+ await database.store.seed(normalizePath(filepath), data, seedOptions);
23641
23667
  }
23642
23668
  });
23643
23669
  };
@@ -23663,7 +23689,6 @@ var _deleteIndexContent = async (database, documentPaths, collection) => {
23663
23689
  var buildSchema = async (rootPath, database, flags) => {
23664
23690
  const tempConfig = import_path5.default.join(rootPath, ".tina", "__generated__", "config");
23665
23691
  const config = await import_fs_extra2.default.readFileSync(import_path5.default.join(tempConfig, "schema.json")).toString();
23666
- console.log("buildSchema - calling rmdir on " + tempConfig);
23667
23692
  await import_fs_extra2.default.rmdir(tempConfig, { recursive: true });
23668
23693
  await indexDB({ database, config: JSON.parse(config), flags });
23669
23694
  const gqlAst = await database.getGraphQLSchemaFromBridge();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.0.0-202241918385",
3
+ "version": "0.0.0-20224201864",
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",