@graphql-mesh/cache-file 1.0.0-alpha-20220804093904-8e2e41f7f → 1.0.0-alpha-20230420181317-a95037648

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.
@@ -1,15 +1,13 @@
1
- 'use strict';
2
-
3
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
-
5
- const crossHelpers = require('@graphql-mesh/cross-helpers');
6
- const DataLoader = _interopDefault(require('dataloader'));
7
- const utils = require('@graphql-mesh/utils');
8
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const dataloader_1 = tslib_1.__importDefault(require("dataloader"));
5
+ const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
6
+ const utils_1 = require("@graphql-mesh/utils");
9
7
  class FileCache {
10
8
  constructor({ path, importFn }) {
11
- this.absolutePath = crossHelpers.path.isAbsolute(path) ? path : crossHelpers.path.join(process.cwd(), path);
12
- this.json$ = utils.pathExists(this.absolutePath).then(async (isExists) => {
9
+ this.absolutePath = cross_helpers_1.path.isAbsolute(path) ? path : cross_helpers_1.path.join(process.cwd(), path);
10
+ this.json$ = (0, utils_1.pathExists)(this.absolutePath).then(async (isExists) => {
13
11
  if (isExists) {
14
12
  const existingData = await importFn(this.absolutePath);
15
13
  return {
@@ -18,9 +16,9 @@ class FileCache {
18
16
  }
19
17
  return {};
20
18
  });
21
- this.writeDataLoader = new DataLoader(async (keys) => {
19
+ this.writeDataLoader = new dataloader_1.default(async (keys) => {
22
20
  const json = await this.json$;
23
- await utils.writeJSON(this.absolutePath, json);
21
+ await (0, utils_1.writeJSON)(this.absolutePath, json);
24
22
  return keys;
25
23
  });
26
24
  }
@@ -43,5 +41,4 @@ class FileCache {
43
41
  await this.writeDataLoader.load(name);
44
42
  }
45
43
  }
46
-
47
- module.exports = FileCache;
44
+ exports.default = FileCache;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,10 +1,9 @@
1
- import { path } from '@graphql-mesh/cross-helpers';
2
1
  import DataLoader from 'dataloader';
2
+ import { path as pathModule } from '@graphql-mesh/cross-helpers';
3
3
  import { pathExists, writeJSON } from '@graphql-mesh/utils';
4
-
5
- class FileCache {
6
- constructor({ path: path$1, importFn }) {
7
- this.absolutePath = path.isAbsolute(path$1) ? path$1 : path.join(process.cwd(), path$1);
4
+ export default class FileCache {
5
+ constructor({ path, importFn }) {
6
+ this.absolutePath = pathModule.isAbsolute(path) ? path : pathModule.join(process.cwd(), path);
8
7
  this.json$ = pathExists(this.absolutePath).then(async (isExists) => {
9
8
  if (isExists) {
10
9
  const existingData = await importFn(this.absolutePath);
@@ -39,5 +38,3 @@ class FileCache {
39
38
  await this.writeDataLoader.load(name);
40
39
  }
41
40
  }
42
-
43
- export default FileCache;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@graphql-mesh/cache-file",
3
- "version": "1.0.0-alpha-20220804093904-8e2e41f7f",
3
+ "version": "1.0.0-alpha-20230420181317-a95037648",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/types": "0.79.0-alpha-20220804093904-8e2e41f7f",
7
- "@graphql-mesh/utils": "1.0.0-alpha-20220804093904-8e2e41f7f",
8
- "graphql": "*"
6
+ "@graphql-mesh/cross-helpers": "^0.3.4",
7
+ "@graphql-mesh/types": "1.0.0-alpha-20230420181317-a95037648",
8
+ "@graphql-mesh/utils": "1.0.0-alpha-20230420181317-a95037648",
9
+ "graphql": "*",
10
+ "tslib": "^2.4.0"
9
11
  },
10
12
  "dependencies": {
11
- "@graphql-mesh/cross-helpers": "0.2.0",
12
- "dataloader": "2.1.0",
13
- "tslib": "^2.4.0"
13
+ "dataloader": "2.2.2"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -18,21 +18,28 @@
18
18
  "directory": "packages/cache/file"
19
19
  },
20
20
  "license": "MIT",
21
- "main": "index.js",
22
- "module": "index.mjs",
23
- "typings": "index.d.ts",
21
+ "main": "cjs/index.js",
22
+ "module": "esm/index.js",
23
+ "typings": "typings/index.d.ts",
24
24
  "typescript": {
25
- "definition": "index.d.ts"
25
+ "definition": "typings/index.d.ts"
26
26
  },
27
+ "type": "module",
27
28
  "exports": {
28
29
  ".": {
29
- "require": "./index.js",
30
- "import": "./index.mjs"
31
- },
32
- "./*": {
33
- "require": "./*.js",
34
- "import": "./*.mjs"
30
+ "require": {
31
+ "types": "./typings/index.d.cts",
32
+ "default": "./cjs/index.js"
33
+ },
34
+ "import": {
35
+ "types": "./typings/index.d.ts",
36
+ "default": "./esm/index.js"
37
+ },
38
+ "default": {
39
+ "types": "./typings/index.d.ts",
40
+ "default": "./esm/index.js"
41
+ }
35
42
  },
36
43
  "./package.json": "./package.json"
37
44
  }
38
- }
45
+ }
@@ -0,0 +1,15 @@
1
+ import DataLoader from 'dataloader';
2
+ import { ImportFn, KeyValueCache } from '@graphql-mesh/types';
3
+ export default class FileCache<V = any> implements KeyValueCache<V> {
4
+ json$: Promise<Record<string, V>>;
5
+ absolutePath: string;
6
+ writeDataLoader: DataLoader<string, string>;
7
+ constructor({ path, importFn }: {
8
+ path: string;
9
+ importFn: ImportFn;
10
+ });
11
+ getKeysByPrefix(prefix: string): Promise<string[]>;
12
+ get(name: string): Promise<V>;
13
+ set(name: string, value: V): Promise<void>;
14
+ delete(name: string): Promise<void>;
15
+ }
@@ -1,5 +1,5 @@
1
- import { ImportFn, KeyValueCache } from '@graphql-mesh/types';
2
1
  import DataLoader from 'dataloader';
2
+ import { ImportFn, KeyValueCache } from '@graphql-mesh/types';
3
3
  export default class FileCache<V = any> implements KeyValueCache<V> {
4
4
  json$: Promise<Record<string, V>>;
5
5
  absolutePath: string;