@baeta/plugin-pagination 0.0.2 → 0.0.4
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 +19 -0
- package/dist/index.cjs +44 -18
- package/dist/index.js +44 -18
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @baeta/plugin-pagination
|
|
2
2
|
|
|
3
|
+
## 0.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#47](https://github.com/andreisergiu98/baeta/pull/47) [`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
8
|
+
|
|
9
|
+
- [#43](https://github.com/andreisergiu98/baeta/pull/43) [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - bump dependencies
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9), [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2)]:
|
|
12
|
+
- @baeta/generator-sdk@0.0.6
|
|
13
|
+
|
|
14
|
+
## 0.0.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`8569eca`](https://github.com/andreisergiu98/baeta/commit/8569ecaf263e24f8d17f62ea00a0cd374dd27941) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add final new line
|
|
19
|
+
|
|
20
|
+
- [#31](https://github.com/andreisergiu98/baeta/pull/31) [`f122a1e`](https://github.com/andreisergiu98/baeta/commit/f122a1e2970d915ce3c24931d4309db26665c739) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - ignore generated sdl
|
|
21
|
+
|
|
3
22
|
## 0.0.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
2
7
|
var _generatorsdk = require('@baeta/generator-sdk');
|
|
3
8
|
var _path = require('path');
|
|
4
9
|
function printFields(fields) {
|
|
@@ -10,7 +15,7 @@ ${printFields(fields)}
|
|
|
10
15
|
}`;
|
|
11
16
|
}
|
|
12
17
|
function printTypes(types) {
|
|
13
|
-
return types.join("\n\n");
|
|
18
|
+
return types.join("\n\n") + "\n";
|
|
14
19
|
}
|
|
15
20
|
function printPageInfo(addFields = []) {
|
|
16
21
|
return printType("PageInfo", [
|
|
@@ -19,12 +24,14 @@ function printPageInfo(addFields = []) {
|
|
|
19
24
|
"hasNextPage: Boolean!"
|
|
20
25
|
]);
|
|
21
26
|
}
|
|
22
|
-
function printExport(moduleDefinitionName) {
|
|
27
|
+
function printExport(moduleDefinitionName, moduleName) {
|
|
23
28
|
const parsed = _path.parse.call(void 0, moduleDefinitionName);
|
|
29
|
+
const method = _generatorsdk.getModuleGetName.call(void 0, moduleName);
|
|
24
30
|
const importName = parsed.ext === ".ts" ? parsed.name : moduleDefinitionName;
|
|
25
|
-
return `import {
|
|
31
|
+
return `import { ${method} } from "./${importName}";
|
|
26
32
|
|
|
27
|
-
export const
|
|
33
|
+
export const ${_generatorsdk.getModuleVariableName.call(void 0, moduleName)} = ${method}();
|
|
34
|
+
`;
|
|
28
35
|
}
|
|
29
36
|
function printConnectionTypes(name, typeOptions, options) {
|
|
30
37
|
const {
|
|
@@ -45,10 +52,26 @@ function printConnectionTypes(name, typeOptions, options) {
|
|
|
45
52
|
]);
|
|
46
53
|
return [connection, edge];
|
|
47
54
|
}
|
|
55
|
+
function createConnectionModuleDir(modulesDir, moduleName) {
|
|
56
|
+
return _path.join.call(void 0, modulesDir, moduleName);
|
|
57
|
+
}
|
|
58
|
+
function createGqlFilename(moduleDir) {
|
|
59
|
+
return `${moduleDir}/connections.gql`;
|
|
60
|
+
}
|
|
61
|
+
function createExportFilename(moduleDir) {
|
|
62
|
+
return `${moduleDir}/index.ts`;
|
|
63
|
+
}
|
|
48
64
|
function paginationPlugin(options) {
|
|
65
|
+
const { moduleName = "baeta-pagination" } = options;
|
|
49
66
|
return _generatorsdk.createPluginV1.call(void 0, {
|
|
50
67
|
name: "pagination",
|
|
51
68
|
actionName: "pagination connections",
|
|
69
|
+
watch: (generatorOptions) => {
|
|
70
|
+
return {
|
|
71
|
+
include: [],
|
|
72
|
+
ignore: [createConnectionModuleDir(generatorOptions.modulesDir, moduleName)]
|
|
73
|
+
};
|
|
74
|
+
},
|
|
52
75
|
generate: async (ctx, next) => {
|
|
53
76
|
const types = [printPageInfo(options.pageInfoFields)];
|
|
54
77
|
for (const name in options.types) {
|
|
@@ -56,27 +79,30 @@ function paginationPlugin(options) {
|
|
|
56
79
|
if (typeOptions === false) {
|
|
57
80
|
continue;
|
|
58
81
|
}
|
|
59
|
-
|
|
82
|
+
const connectionTypes = printConnectionTypes(
|
|
83
|
+
name,
|
|
84
|
+
typeOptions === true ? {} : typeOptions,
|
|
85
|
+
options
|
|
86
|
+
);
|
|
87
|
+
types.push(...connectionTypes);
|
|
60
88
|
}
|
|
61
|
-
const
|
|
62
|
-
ctx.generatorOptions.modulesDir,
|
|
63
|
-
_nullishCoalesce(options.moduleName, () => ( "connections"))
|
|
64
|
-
);
|
|
89
|
+
const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
|
|
65
90
|
const definitionFile = new (0, _generatorsdk.File)(
|
|
66
|
-
|
|
91
|
+
createGqlFilename(moduleDir),
|
|
67
92
|
printTypes(types),
|
|
68
93
|
"pagination"
|
|
69
94
|
);
|
|
70
95
|
await definitionFile.write();
|
|
71
96
|
ctx.fileManager.add(definitionFile);
|
|
72
|
-
if (options.createExport
|
|
73
|
-
|
|
74
|
-
`${connectionModuleDir}/index.ts`,
|
|
75
|
-
printExport(ctx.generatorOptions.moduleDefinitionName),
|
|
76
|
-
"pagination"
|
|
77
|
-
);
|
|
78
|
-
ctx.fileManager.add(exportFile);
|
|
97
|
+
if (options.createExport === false) {
|
|
98
|
+
return next();
|
|
79
99
|
}
|
|
100
|
+
const exportFile = new (0, _generatorsdk.File)(
|
|
101
|
+
createExportFilename(moduleDir),
|
|
102
|
+
printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),
|
|
103
|
+
"pagination"
|
|
104
|
+
);
|
|
105
|
+
ctx.fileManager.add(exportFile);
|
|
80
106
|
return next();
|
|
81
107
|
}
|
|
82
108
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createPluginV1,
|
|
4
|
+
File,
|
|
5
|
+
getModuleGetName,
|
|
6
|
+
getModuleVariableName
|
|
7
|
+
} from "@baeta/generator-sdk";
|
|
3
8
|
import { join, parse } from "path";
|
|
4
9
|
function printFields(fields) {
|
|
5
10
|
return fields.map((field) => ` ${field}`).join("\n");
|
|
@@ -10,7 +15,7 @@ ${printFields(fields)}
|
|
|
10
15
|
}`;
|
|
11
16
|
}
|
|
12
17
|
function printTypes(types) {
|
|
13
|
-
return types.join("\n\n");
|
|
18
|
+
return types.join("\n\n") + "\n";
|
|
14
19
|
}
|
|
15
20
|
function printPageInfo(addFields = []) {
|
|
16
21
|
return printType("PageInfo", [
|
|
@@ -19,12 +24,14 @@ function printPageInfo(addFields = []) {
|
|
|
19
24
|
"hasNextPage: Boolean!"
|
|
20
25
|
]);
|
|
21
26
|
}
|
|
22
|
-
function printExport(moduleDefinitionName) {
|
|
27
|
+
function printExport(moduleDefinitionName, moduleName) {
|
|
23
28
|
const parsed = parse(moduleDefinitionName);
|
|
29
|
+
const method = getModuleGetName(moduleName);
|
|
24
30
|
const importName = parsed.ext === ".ts" ? parsed.name : moduleDefinitionName;
|
|
25
|
-
return `import {
|
|
31
|
+
return `import { ${method} } from "./${importName}";
|
|
26
32
|
|
|
27
|
-
export const
|
|
33
|
+
export const ${getModuleVariableName(moduleName)} = ${method}();
|
|
34
|
+
`;
|
|
28
35
|
}
|
|
29
36
|
function printConnectionTypes(name, typeOptions, options) {
|
|
30
37
|
const {
|
|
@@ -45,10 +52,26 @@ function printConnectionTypes(name, typeOptions, options) {
|
|
|
45
52
|
]);
|
|
46
53
|
return [connection, edge];
|
|
47
54
|
}
|
|
55
|
+
function createConnectionModuleDir(modulesDir, moduleName) {
|
|
56
|
+
return join(modulesDir, moduleName);
|
|
57
|
+
}
|
|
58
|
+
function createGqlFilename(moduleDir) {
|
|
59
|
+
return `${moduleDir}/connections.gql`;
|
|
60
|
+
}
|
|
61
|
+
function createExportFilename(moduleDir) {
|
|
62
|
+
return `${moduleDir}/index.ts`;
|
|
63
|
+
}
|
|
48
64
|
function paginationPlugin(options) {
|
|
65
|
+
const { moduleName = "baeta-pagination" } = options;
|
|
49
66
|
return createPluginV1({
|
|
50
67
|
name: "pagination",
|
|
51
68
|
actionName: "pagination connections",
|
|
69
|
+
watch: (generatorOptions) => {
|
|
70
|
+
return {
|
|
71
|
+
include: [],
|
|
72
|
+
ignore: [createConnectionModuleDir(generatorOptions.modulesDir, moduleName)]
|
|
73
|
+
};
|
|
74
|
+
},
|
|
52
75
|
generate: async (ctx, next) => {
|
|
53
76
|
const types = [printPageInfo(options.pageInfoFields)];
|
|
54
77
|
for (const name in options.types) {
|
|
@@ -56,27 +79,30 @@ function paginationPlugin(options) {
|
|
|
56
79
|
if (typeOptions === false) {
|
|
57
80
|
continue;
|
|
58
81
|
}
|
|
59
|
-
|
|
82
|
+
const connectionTypes = printConnectionTypes(
|
|
83
|
+
name,
|
|
84
|
+
typeOptions === true ? {} : typeOptions,
|
|
85
|
+
options
|
|
86
|
+
);
|
|
87
|
+
types.push(...connectionTypes);
|
|
60
88
|
}
|
|
61
|
-
const
|
|
62
|
-
ctx.generatorOptions.modulesDir,
|
|
63
|
-
options.moduleName ?? "connections"
|
|
64
|
-
);
|
|
89
|
+
const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
|
|
65
90
|
const definitionFile = new File(
|
|
66
|
-
|
|
91
|
+
createGqlFilename(moduleDir),
|
|
67
92
|
printTypes(types),
|
|
68
93
|
"pagination"
|
|
69
94
|
);
|
|
70
95
|
await definitionFile.write();
|
|
71
96
|
ctx.fileManager.add(definitionFile);
|
|
72
|
-
if (options.createExport
|
|
73
|
-
|
|
74
|
-
`${connectionModuleDir}/index.ts`,
|
|
75
|
-
printExport(ctx.generatorOptions.moduleDefinitionName),
|
|
76
|
-
"pagination"
|
|
77
|
-
);
|
|
78
|
-
ctx.fileManager.add(exportFile);
|
|
97
|
+
if (options.createExport === false) {
|
|
98
|
+
return next();
|
|
79
99
|
}
|
|
100
|
+
const exportFile = new File(
|
|
101
|
+
createExportFilename(moduleDir),
|
|
102
|
+
printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),
|
|
103
|
+
"pagination"
|
|
104
|
+
);
|
|
105
|
+
ctx.fileManager.add(exportFile);
|
|
80
106
|
return next();
|
|
81
107
|
}
|
|
82
108
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/plugin-pagination",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"homepage": "https://github.com/andreisergiu98/baeta#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/andreisergiu98/baeta/issues"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/andreisergiu98/baeta.git",
|
|
11
|
-
"directory": "
|
|
11
|
+
"directory": "packages/plugin-pagination"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Andrei Pampu <pampu.andrei@pm.me>",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"types": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@baeta/generator-sdk": "^0.0.
|
|
27
|
+
"@baeta/generator-sdk": "^0.0.6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@baeta/
|
|
30
|
+
"@baeta/builder": "^0.0.0",
|
|
31
31
|
"@baeta/tsconfig": "^0.0.0",
|
|
32
|
-
"@types/node": "^18.11
|
|
32
|
+
"@types/node": "^18.15.11",
|
|
33
33
|
"graphql": "^16.6.0",
|
|
34
|
-
"typescript": "^4.9.
|
|
34
|
+
"typescript": "^4.9.5"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"graphql": "^16.6.0"
|