@okam/directus-node 0.2.0 → 0.2.1
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 +17 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/lib/redirection.d.ts +2 -0
- package/src/lib/redirection.js +10 -6
- package/src/lib/redirection.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 0.2.1 (2024-09-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🩹 Fixes
|
|
5
|
+
|
|
6
|
+
- **directus-node:** adding limit = 200 for graphql redirects queries ([#192](https://github.com/OKAMca/stack/pull/192))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
12
|
+
- mykimd @mykimd
|
|
13
|
+
- Pierre-Olivier Clerson @poclerson
|
|
14
|
+
- poclerson
|
|
15
|
+
- Yan Morin
|
|
16
|
+
- yanmorinokamca @yanmorinokamca
|
|
17
|
+
|
|
1
18
|
## 0.2.0 (2024-07-25)
|
|
2
19
|
|
|
3
20
|
|
package/README.md
CHANGED
|
@@ -22,6 +22,12 @@ Run `nx test directus-node` to execute the unit tests via [Jest](https://jestjs.
|
|
|
22
22
|
*/
|
|
23
23
|
const { fetchRedirects, getDefaultConfig } = require('@okam/directus-node')
|
|
24
24
|
|
|
25
|
+
// getDefaultConfig() will return an object with
|
|
26
|
+
// graphqlEndpoint: use environment variable NEXT_PUBLIC_GRAPHQL_URL
|
|
27
|
+
// graphqlApiKey: use environment variable NEXT_API_TOKEN_ADMIN
|
|
28
|
+
// redirectsFilename
|
|
29
|
+
// rewritesFilename
|
|
30
|
+
// limit: 2000 (number of redirect or rewrite rules fetched by graphql)
|
|
25
31
|
fetchRedirects(getDefaultConfig())
|
|
26
32
|
```
|
|
27
33
|
|
package/package.json
CHANGED
package/src/lib/redirection.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ interface TFetchRedirectsConfig {
|
|
|
3
3
|
graphqlApiKey: string;
|
|
4
4
|
redirectsFilename: string;
|
|
5
5
|
rewritesFilename: string;
|
|
6
|
+
limit: number | undefined;
|
|
6
7
|
}
|
|
8
|
+
export declare const redirectDefaultLimit = 2000;
|
|
7
9
|
/**
|
|
8
10
|
* Get Fetch Redirects Configuration
|
|
9
11
|
* @returns {object}
|
package/src/lib/redirection.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchRedirects = exports.getDefaultConfig = void 0;
|
|
3
|
+
exports.fetchRedirects = exports.getDefaultConfig = exports.redirectDefaultLimit = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const promises_1 = require("node:fs/promises");
|
|
6
|
+
exports.redirectDefaultLimit = 2000;
|
|
6
7
|
/**
|
|
7
8
|
* Get Fetch Redirects Configuration
|
|
8
9
|
* @returns {object}
|
|
@@ -13,26 +14,27 @@ function getDefaultConfig() {
|
|
|
13
14
|
graphqlApiKey: process.env['NEXT_API_TOKEN_ADMIN'] || '',
|
|
14
15
|
redirectsFilename: './redirect/redirects.json',
|
|
15
16
|
rewritesFilename: './redirect/rewrites.json',
|
|
17
|
+
limit: exports.redirectDefaultLimit,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
exports.getDefaultConfig = getDefaultConfig;
|
|
19
21
|
function fetchRedirects(config) {
|
|
20
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const { graphqlEndpoint, graphqlApiKey, redirectsFilename, rewritesFilename } = config;
|
|
23
|
+
const { graphqlEndpoint, graphqlApiKey, redirectsFilename, rewritesFilename, limit } = config;
|
|
22
24
|
if (!graphqlEndpoint || !graphqlApiKey) {
|
|
23
25
|
throw new Error('Missing graphql configuration: NEXT_PUBLIC_GRAPHQL_URL or NEXT_API_TOKEN_ADMIN');
|
|
24
26
|
}
|
|
25
27
|
if (!redirectsFilename || !rewritesFilename) {
|
|
26
28
|
throw new Error('Missing filename');
|
|
27
29
|
}
|
|
28
|
-
const query = `query fetchRedirects {
|
|
29
|
-
redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:false}}, sort: "sort") {
|
|
30
|
+
const query = `query fetchRedirects($limit: Int = 2000) {
|
|
31
|
+
redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:false}}, sort: "sort", limit: $limit) {
|
|
30
32
|
source
|
|
31
33
|
destination
|
|
32
34
|
permanent
|
|
33
35
|
locale
|
|
34
36
|
}
|
|
35
|
-
rewrites: redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:true}}, sort: "sort") {
|
|
37
|
+
rewrites: redirects(filter: {status:{_eq:"published"},isrewrite:{_eq:true}}, sort: "sort", limit: $limit) {
|
|
36
38
|
source
|
|
37
39
|
destination
|
|
38
40
|
permanent
|
|
@@ -42,7 +44,9 @@ function fetchRedirects(config) {
|
|
|
42
44
|
const graphqlBody = {
|
|
43
45
|
query,
|
|
44
46
|
// "operationName": "",
|
|
45
|
-
variables: {
|
|
47
|
+
variables: {
|
|
48
|
+
limit: Number(limit) || exports.redirectDefaultLimit,
|
|
49
|
+
},
|
|
46
50
|
};
|
|
47
51
|
try {
|
|
48
52
|
// console.info(`Fetching redirects on ${graphqlEndpoint}`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirection.js","sourceRoot":"","sources":["../../../../../../libs/directus/directus-node/src/lib/redirection.ts"],"names":[],"mappings":";;;;AAAA,+CAA4C;
|
|
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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