dymo-api 1.0.74 → 1.0.75

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.
@@ -91,14 +91,16 @@ class DymoAPI {
91
91
  * does not exist or is outdated.
92
92
  */
93
93
  readTokensFromFile() {
94
- if (!fs_1.default.existsSync("../data/cache.json"))
94
+ if (!fs_1.default.existsSync("./node_modules/dymo-api/data/cache.json"))
95
+ fs_1.default.mkdirSync("./node_modules/dymo-api/data/cache.json", { recursive: true });
96
+ if (!fs_1.default.existsSync("./node_modules/dymo-api/data/cache.json"))
95
97
  return null;
96
- const parsedData = JSON.parse(fs_1.default.readFileSync("../data/cache.json", "utf-8"));
98
+ const parsedData = JSON.parse(fs_1.default.readFileSync("./node_modules/dymo-api/data/cache.json", "utf-8"));
97
99
  const lastInitialized = new Date(parsedData.lastInitialized);
98
100
  const now = new Date();
99
101
  const diffInDays = (now.getTime() - lastInitialized.getTime()) / (1000 * 3600 * 24);
100
102
  if (diffInDays > 5) {
101
- fs_1.default.unlinkSync("../data/cache.json");
103
+ fs_1.default.unlinkSync("./node_modules/dymo-api/data/cache.json");
102
104
  return null;
103
105
  }
104
106
  return parsedData.tokens;
@@ -112,7 +114,7 @@ class DymoAPI {
112
114
  * @param {TokensResponse} tokens - The authentication tokens to be written to the file.
113
115
  */
114
116
  writeTokensToFile(tokens) {
115
- fs_1.default.writeFileSync("../data/cache.json", JSON.stringify({
117
+ fs_1.default.writeFileSync("./node_modules/dymo-api/data/cache.json", JSON.stringify({
116
118
  tokens,
117
119
  lastInitialized: new Date().toISOString()
118
120
  }, null, 2));
@@ -53,14 +53,16 @@ class DymoAPI {
53
53
  * does not exist or is outdated.
54
54
  */
55
55
  readTokensFromFile() {
56
- if (!fs.existsSync("../data/cache.json"))
56
+ if (!fs.existsSync("./node_modules/dymo-api/data/cache.json"))
57
+ fs.mkdirSync("./node_modules/dymo-api/data/cache.json", { recursive: true });
58
+ if (!fs.existsSync("./node_modules/dymo-api/data/cache.json"))
57
59
  return null;
58
- const parsedData = JSON.parse(fs.readFileSync("../data/cache.json", "utf-8"));
60
+ const parsedData = JSON.parse(fs.readFileSync("./node_modules/dymo-api/data/cache.json", "utf-8"));
59
61
  const lastInitialized = new Date(parsedData.lastInitialized);
60
62
  const now = new Date();
61
63
  const diffInDays = (now.getTime() - lastInitialized.getTime()) / (1000 * 3600 * 24);
62
64
  if (diffInDays > 5) {
63
- fs.unlinkSync("../data/cache.json");
65
+ fs.unlinkSync("./node_modules/dymo-api/data/cache.json");
64
66
  return null;
65
67
  }
66
68
  return parsedData.tokens;
@@ -74,7 +76,7 @@ class DymoAPI {
74
76
  * @param {TokensResponse} tokens - The authentication tokens to be written to the file.
75
77
  */
76
78
  writeTokensToFile(tokens) {
77
- fs.writeFileSync("../data/cache.json", JSON.stringify({
79
+ fs.writeFileSync("./node_modules/dymo-api/data/cache.json", JSON.stringify({
78
80
  tokens,
79
81
  lastInitialized: new Date().toISOString()
80
82
  }, null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.74",
3
+ "version": "1.0.75",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/cjs/dymo-api.js",
6
6
  "module": "dist/esm/dymo-api.js",