@okam/directus-node 0.2.1 → 0.4.0

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,3 +1,23 @@
1
+ ## 0.3.0 (2024-09-11)
2
+
3
+
4
+ ### 🚀 Features
5
+
6
+ - Add console log for redirects and rewrites count ([2ae2d19](https://github.com/OKAMca/stack/commit/2ae2d19))
7
+
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - add console.warn with error in catch block ([865cd5e](https://github.com/OKAMca/stack/commit/865cd5e))
12
+
13
+ - return true on error when fetching redirects ([54c34c6](https://github.com/OKAMca/stack/commit/54c34c6))
14
+
15
+
16
+ ### ❤️ Thank You
17
+
18
+ - David Paquet Pitts
19
+ - David Paquet Pitts (aider)
20
+
1
21
  ## 0.2.1 (2024-09-06)
2
22
 
3
23
 
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@okam/directus-node",
3
3
  "main": "./src/index.js",
4
- "version": "0.2.1",
4
+ "version": "0.4.0",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
7
- "registry": "https://registry.npmjs.org"
7
+ "access": "public"
8
8
  },
9
9
  "repository": {
10
10
  "url": "https://github.com/OKAMca/stack.git"
11
11
  },
12
+ "dependencies": {
13
+ "@graphql-codegen/cli": "^5.0.3",
14
+ "@okam/logger": "1.1.0",
15
+ "tslib": "^2.8.1"
16
+ },
12
17
  "type": "commonjs"
13
18
  }
package/src/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './lib/redirection';
2
2
  export { default as graphqlCodegenConfig } from './lib/codegen';
3
+ export { logger as DirectusNodeLogger } from './logger';
package/src/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.graphqlCodegenConfig = void 0;
3
+ exports.DirectusNodeLogger = exports.graphqlCodegenConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("./lib/redirection"), exports);
6
6
  var codegen_1 = require("./lib/codegen");
7
- Object.defineProperty(exports, "graphqlCodegenConfig", { enumerable: true, get: function () { return codegen_1.default; } });
7
+ Object.defineProperty(exports, "graphqlCodegenConfig", { enumerable: true, get: function () { return tslib_1.__importDefault(codegen_1).default; } });
8
+ var logger_1 = require("./logger");
9
+ Object.defineProperty(exports, "DirectusNodeLogger", { enumerable: true, get: function () { return logger_1.logger; } });
8
10
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/directus/directus-node/src/index.ts"],"names":[],"mappings":";;;;AAAA,4DAAiC;AACjC,yCAA+D;AAAtD,+GAAA,OAAO,OAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/directus/directus-node/src/index.ts"],"names":[],"mappings":";;;;AAAA,4DAAiC;AACjC,yCAA+D;AAAtD,wIAAA,OAAO,OAAwB;AACxC,mCAAuD;AAA9C,4GAAA,MAAM,OAAsB"}
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchRedirects = exports.getDefaultConfig = exports.redirectDefaultLimit = void 0;
3
+ exports.redirectDefaultLimit = void 0;
4
+ exports.getDefaultConfig = getDefaultConfig;
5
+ exports.fetchRedirects = fetchRedirects;
4
6
  const tslib_1 = require("tslib");
5
7
  const promises_1 = require("node:fs/promises");
8
+ const logger_1 = require("../logger");
6
9
  exports.redirectDefaultLimit = 2000;
7
10
  /**
8
11
  * Get Fetch Redirects Configuration
@@ -17,9 +20,9 @@ function getDefaultConfig() {
17
20
  limit: exports.redirectDefaultLimit,
18
21
  };
19
22
  }
20
- exports.getDefaultConfig = getDefaultConfig;
21
23
  function fetchRedirects(config) {
22
24
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ var _a, _b;
23
26
  const { graphqlEndpoint, graphqlApiKey, redirectsFilename, rewritesFilename, limit } = config;
24
27
  if (!graphqlEndpoint || !graphqlApiKey) {
25
28
  throw new Error('Missing graphql configuration: NEXT_PUBLIC_GRAPHQL_URL or NEXT_API_TOKEN_ADMIN');
@@ -64,13 +67,13 @@ function fetchRedirects(config) {
64
67
  yield (0, promises_1.writeFile)(redirectsFilename, writeDataRedirects);
65
68
  const writeDataRewrites = JSON.stringify(data.rewrites || []);
66
69
  yield (0, promises_1.writeFile)(rewritesFilename, writeDataRewrites);
70
+ (0, logger_1.log)(`Redirects count: ${((_a = data.redirects) === null || _a === void 0 ? void 0 : _a.length) || 0}, Rewrites count: ${((_b = data.rewrites) === null || _b === void 0 ? void 0 : _b.length) || 0}`);
67
71
  }
68
72
  catch (e) {
69
- // console.error('GraphQL Error', (e as Error).message)
70
- // return false
73
+ (0, logger_1.log)(`Error fetching redirects: ${e.message}`, 'error');
74
+ return true; // still want build to pass
71
75
  }
72
76
  return true;
73
77
  });
74
78
  }
75
- exports.fetchRedirects = fetchRedirects;
76
79
  //# sourceMappingURL=redirection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"redirection.js","sourceRoot":"","sources":["../../../../../../libs/directus/directus-node/src/lib/redirection.ts"],"names":[],"mappings":";;;;AAAA,+CAA4C;AAU/B,QAAA,oBAAoB,GAAG,IAAI,CAAA;AAExC;;;GAGG;AACH,SAAgB,gBAAgB;IAC9B,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,EAAE;QAC7D,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,EAAE;QACxD,iBAAiB,EAAE,2BAA2B;QAC9C,gBAAgB,EAAE,0BAA0B;QAC5C,KAAK,EAAE,4BAAoB;KAC5B,CAAA;AACH,CAAC;AARD,4CAQC;AAED,SAAsB,cAAc,CAAC,MAA6B;;QAChE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB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e;QACjB,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AA1DD,wCA0DC"}
1
+ {"version":3,"file":"redirection.js","sourceRoot":"","sources":["../../../../../../libs/directus/directus-node/src/lib/redirection.ts"],"names":[],"mappings":";;;AAkBA,4CAQC;AAED,wCA4DC;;AAxFD,+CAA4C;AAE5C,sCAA+B;AAUlB,QAAA,oBAAoB,GAAG,IAAI,CAAA;AAExC;;;GAGG;AACH,SAAgB,gBAAgB;IAC9B,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,EAAE;QAC7D,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,EAAE;QACxD,iBAAiB,EAAE,2BAA2B;QAC9C,gBAAgB,EAAE,0BAA0B;QAC5C,KAAK,EAAE,4BAAoB;KAC5B,CAAA;AACH,CAAC;AAED,SAAsB,cAAc,CAAC,MAA6B;;;QAChE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;QAE7F,IAAI,CAAC,eAAe,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;QACnG,CAAC;QAED,IAAI,CAAC,iBAAiB,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QAED,MAAM,KAAK,GAAG;;;;;;;;;;;;;EAad,CAAA;QAEA,MAAM,WAAW,GAAG;YAClB,KAAK;YACL,uBAAuB;YACvB,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,4BAAoB;aAC7C;SACF,CAAA;QAED,IAAI,CAAC;YACH,2DAA2D;YAC3D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE;gBAC5C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,gEAAgE;oBAChE,cAAc,EAAE,kBAAkB;oBAClC,aAAa,EAAE,UAAU,aAAa,EAAE;iBACzC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;aAClC,CAAC,CAAA;YACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAEtC,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAA;YAC/D,MAAM,IAAA,oBAAS,EAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAA;YAEtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAA;YAC7D,MAAM,IAAA,oBAAS,EAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAA;YAEpD,IAAA,YAAG,EAAC,oBAAoB,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,MAAM,KAAI,CAAC,qBAAqB,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,KAAI,CAAC,EAAE,CAAC,CAAA;QACvG,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAA,YAAG,EAAC,6BAA8B,CAAW,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;YACjE,OAAO,IAAI,CAAA,CAAC,2BAA2B;QACzC,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const logger: import("@okam/logger").Logger;
2
+ export declare const log: (message: string, severity?: import("@okam/logger").LogSeverity, context?: Record<string, unknown>) => void;
package/src/logger.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = exports.logger = void 0;
4
+ const logger_1 = require("@okam/logger");
5
+ exports.logger = (0, logger_1.createLogger)('[DirectusNode]');
6
+ exports.log = exports.logger.log;
7
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../libs/directus/directus-node/src/logger.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAE9B,QAAA,MAAM,GAAG,IAAA,qBAAY,EAAC,gBAAgB,CAAC,CAAA;AAErC,WAAG,GAAK,cAAM,KAAA"}