@okam/directus-node 0.0.1 → 0.1.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 ADDED
@@ -0,0 +1,23 @@
1
+ ## 0.1.1 (2024-07-09)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - **publish:** add building packages step to workflow ([c9ce442](https://github.com/OKAMca/stack/commit/c9ce442))
7
+
8
+
9
+ ### ❤️ Thank You
10
+
11
+ - Jérôme Trottier
12
+
13
+ ## 0.1.0 (2024-06-28)
14
+
15
+
16
+ ### 🚀 Features
17
+
18
+ - add gql query ([#73](https://github.com/OKAMca/stack/pull/73))
19
+
20
+
21
+ ### ❤️ Thank You
22
+
23
+ - Marie-Maxime Tanguay @marie-maxime
package/README.md CHANGED
@@ -21,14 +21,28 @@ Run `nx test directus-node` to execute the unit tests via [Jest](https://jestjs.
21
21
  * npx env-cmd -f ../../.env.local node fetch-redirect.js
22
22
  */
23
23
  const { fetchRedirects, getDefaultConfig } = require('@okam/directus-node')
24
+
24
25
  fetchRedirects(getDefaultConfig())
25
26
  ```
26
27
 
27
- 2. In project.json targets.build, add "dependsOn": ["fetch-redirect"]
28
+ 2. In project.json,
29
+ 1. In targets.build, add `"dependsOn": ["fetch-redirect"],`
30
+ 2. In targets:
31
+ ```
32
+ "fetch-redirect": {
33
+ "executor": "nx:run-commands",
34
+ "options": {
35
+ "cwd": "{projectRoot}",
36
+ "command": "node fetch-redirect"
37
+ }
38
+ },
39
+ ```
40
+ 3. Don't forget to change the cwd path
28
41
 
29
- 3. Create directory redirection
30
42
 
31
- 4. Create file redirection/index.js
43
+ 3. Create directory redirect
44
+
45
+ 4. Create file redirect/index.js
32
46
  ```
33
47
  const redirects = require('./redirects.json')
34
48
  const rewrites = require('./rewrites.json')
@@ -46,7 +60,38 @@ NEXT_PUBLIC_GRAPHQL_URL=
46
60
  NEXT_API_TOKEN_ADMIN=
47
61
  ```
48
62
 
49
- 6. Generate redirects.json and rewrites.json using fetch-redirect (or build project with nx)
63
+ 6. Generate redirect/redirects.json and redirect/rewrites.json using fetch-redirect (or build project with nx)
50
64
  ```
51
65
  npx env-cmd -f ../../.env.local node fetch-redirect.js
52
66
  ```
67
+
68
+ 7. Update nextConfig in next.config.js with
69
+ ```
70
+ const { rewrites, redirects } = require('./redirect/index')
71
+ ```
72
+ ```
73
+ const nextConfig = {
74
+ ...
75
+ async redirects() {
76
+ const rest = await redirects()
77
+ return [
78
+ ...i18nReRouter({locale: false, permanent: true}, 'redirect'),
79
+ ...rest,
80
+ ]
81
+ return rest
82
+ },
83
+ async rewrites() {
84
+ const fallback = await rewrites()
85
+ return {
86
+ beforeFiles: [
87
+ ...i18nReRouter({locale: false}, 'rewrite'),
88
+ ],
89
+ afterFiles: [
90
+ ...i18nRewriter({...i18nConfigWithoutLocaleDetector, localeDetector: false}),
91
+ ],
92
+ fallback,
93
+ }
94
+ },
95
+ ...
96
+ }
97
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@okam/directus-node",
3
- "main": "./src/index.js",
4
- "version": "0.0.1",
3
+ "main": "./index.js",
4
+ "version": "0.1.1",
5
5
  "types": "./index.d.ts",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org"
@@ -10,4 +10,4 @@
10
10
  "url": "https://github.com/OKAMca/stack.git"
11
11
  },
12
12
  "type": "commonjs"
13
- }
13
+ }
package/src/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './lib/redirection';
2
+ export { default as graphqlCodegenConfig } from './lib/codegen';
package/src/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.graphqlCodegenConfig = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  tslib_1.__exportStar(require("./lib/redirection"), exports);
6
+ var codegen_1 = require("./lib/codegen");
7
+ Object.defineProperty(exports, "graphqlCodegenConfig", { enumerable: true, get: function () { return codegen_1.default; } });
5
8
  //# 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"}
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"}
@@ -0,0 +1,2 @@
1
+ declare const graphqlCodegenConfig: (schemaUrl: string, generatePath: string, headers: Record<string, string>) => import("@graphql-codegen/plugin-helpers").Types.Config;
2
+ export default graphqlCodegenConfig;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const graphqlCodegenConfig = (schemaUrl, generatePath, headers) => {
4
+ const config = {
5
+ overwrite: true,
6
+ schema: [
7
+ {
8
+ [schemaUrl]: {
9
+ headers,
10
+ },
11
+ },
12
+ ],
13
+ documents: [`${__dirname}/apps/demo/**/*.graphql`],
14
+ ignoreNoDocuments: true, // for better experience with the watcher
15
+ generates: {
16
+ [generatePath]: {
17
+ preset: 'client',
18
+ },
19
+ },
20
+ };
21
+ return config;
22
+ };
23
+ exports.default = graphqlCodegenConfig;
24
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../../../../libs/directus/directus-node/src/lib/codegen.ts"],"names":[],"mappings":";;AAEA,MAAM,oBAAoB,GAAG,CAAC,SAAiB,EAAE,YAAoB,EAAE,OAA+B,EAAE,EAAE;IACxG,MAAM,MAAM,GAAkB;QAC5B,SAAS,EAAE,IAAI;QACf,MAAM,EAAE;YACN;gBACE,CAAC,SAAS,CAAC,EAAE;oBACX,OAAO;iBACR;aACF;SACF;QACD,SAAS,EAAE,CAAC,GAAG,SAAS,yBAAyB,CAAC;QAClD,iBAAiB,EAAE,IAAI,EAAE,yCAAyC;QAClE,SAAS,EAAE;YACT,CAAC,YAAY,CAAC,EAAE;gBACd,MAAM,EAAE,QAAQ;aACjB;SACF;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,kBAAe,oBAAoB,CAAA"}