@baeta/plugin-pagination 0.0.3 → 0.0.5
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 +18 -0
- package/dist/index.cjs +27 -17
- package/dist/index.js +28 -18
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @baeta/plugin-pagination
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @baeta/generator-sdk@0.0.7
|
|
9
|
+
|
|
10
|
+
## 0.0.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#47](https://github.com/andreisergiu98/baeta/pull/47) [`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
15
|
+
|
|
16
|
+
- [#43](https://github.com/andreisergiu98/baeta/pull/43) [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - bump dependencies
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9), [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2)]:
|
|
19
|
+
- @baeta/generator-sdk@0.0.6
|
|
20
|
+
|
|
3
21
|
## 0.0.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
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) {
|
|
@@ -19,12 +24,13 @@ 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}();
|
|
28
34
|
`;
|
|
29
35
|
}
|
|
30
36
|
function printConnectionTypes(name, typeOptions, options) {
|
|
@@ -46,7 +52,7 @@ function printConnectionTypes(name, typeOptions, options) {
|
|
|
46
52
|
]);
|
|
47
53
|
return [connection, edge];
|
|
48
54
|
}
|
|
49
|
-
function createConnectionModuleDir(modulesDir, moduleName
|
|
55
|
+
function createConnectionModuleDir(modulesDir, moduleName) {
|
|
50
56
|
return _path.join.call(void 0, modulesDir, moduleName);
|
|
51
57
|
}
|
|
52
58
|
function createGqlFilename(moduleDir) {
|
|
@@ -56,13 +62,14 @@ function createExportFilename(moduleDir) {
|
|
|
56
62
|
return `${moduleDir}/index.ts`;
|
|
57
63
|
}
|
|
58
64
|
function paginationPlugin(options) {
|
|
65
|
+
const { moduleName = "baeta-pagination" } = options;
|
|
59
66
|
return _generatorsdk.createPluginV1.call(void 0, {
|
|
60
67
|
name: "pagination",
|
|
61
68
|
actionName: "pagination connections",
|
|
62
69
|
watch: (generatorOptions) => {
|
|
63
70
|
return {
|
|
64
71
|
include: [],
|
|
65
|
-
ignore: [createConnectionModuleDir(generatorOptions.modulesDir,
|
|
72
|
+
ignore: [createConnectionModuleDir(generatorOptions.modulesDir, moduleName)]
|
|
66
73
|
};
|
|
67
74
|
},
|
|
68
75
|
generate: async (ctx, next) => {
|
|
@@ -72,12 +79,14 @@ function paginationPlugin(options) {
|
|
|
72
79
|
if (typeOptions === false) {
|
|
73
80
|
continue;
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
const connectionTypes = printConnectionTypes(
|
|
83
|
+
name,
|
|
84
|
+
typeOptions === true ? {} : typeOptions,
|
|
85
|
+
options
|
|
86
|
+
);
|
|
87
|
+
types.push(...connectionTypes);
|
|
76
88
|
}
|
|
77
|
-
const moduleDir = createConnectionModuleDir(
|
|
78
|
-
ctx.generatorOptions.modulesDir,
|
|
79
|
-
options.moduleName
|
|
80
|
-
);
|
|
89
|
+
const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
|
|
81
90
|
const definitionFile = new (0, _generatorsdk.File)(
|
|
82
91
|
createGqlFilename(moduleDir),
|
|
83
92
|
printTypes(types),
|
|
@@ -85,14 +94,15 @@ function paginationPlugin(options) {
|
|
|
85
94
|
);
|
|
86
95
|
await definitionFile.write();
|
|
87
96
|
ctx.fileManager.add(definitionFile);
|
|
88
|
-
if (options.createExport
|
|
89
|
-
|
|
90
|
-
createExportFilename(moduleDir),
|
|
91
|
-
printExport(ctx.generatorOptions.moduleDefinitionName),
|
|
92
|
-
"pagination"
|
|
93
|
-
);
|
|
94
|
-
ctx.fileManager.add(exportFile);
|
|
97
|
+
if (options.createExport === false) {
|
|
98
|
+
return next();
|
|
95
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);
|
|
96
106
|
return next();
|
|
97
107
|
}
|
|
98
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");
|
|
@@ -19,12 +24,13 @@ 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}();
|
|
28
34
|
`;
|
|
29
35
|
}
|
|
30
36
|
function printConnectionTypes(name, typeOptions, options) {
|
|
@@ -46,7 +52,7 @@ function printConnectionTypes(name, typeOptions, options) {
|
|
|
46
52
|
]);
|
|
47
53
|
return [connection, edge];
|
|
48
54
|
}
|
|
49
|
-
function createConnectionModuleDir(modulesDir, moduleName
|
|
55
|
+
function createConnectionModuleDir(modulesDir, moduleName) {
|
|
50
56
|
return join(modulesDir, moduleName);
|
|
51
57
|
}
|
|
52
58
|
function createGqlFilename(moduleDir) {
|
|
@@ -56,13 +62,14 @@ function createExportFilename(moduleDir) {
|
|
|
56
62
|
return `${moduleDir}/index.ts`;
|
|
57
63
|
}
|
|
58
64
|
function paginationPlugin(options) {
|
|
65
|
+
const { moduleName = "baeta-pagination" } = options;
|
|
59
66
|
return createPluginV1({
|
|
60
67
|
name: "pagination",
|
|
61
68
|
actionName: "pagination connections",
|
|
62
69
|
watch: (generatorOptions) => {
|
|
63
70
|
return {
|
|
64
71
|
include: [],
|
|
65
|
-
ignore: [createConnectionModuleDir(generatorOptions.modulesDir,
|
|
72
|
+
ignore: [createConnectionModuleDir(generatorOptions.modulesDir, moduleName)]
|
|
66
73
|
};
|
|
67
74
|
},
|
|
68
75
|
generate: async (ctx, next) => {
|
|
@@ -72,12 +79,14 @@ function paginationPlugin(options) {
|
|
|
72
79
|
if (typeOptions === false) {
|
|
73
80
|
continue;
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
const connectionTypes = printConnectionTypes(
|
|
83
|
+
name,
|
|
84
|
+
typeOptions === true ? {} : typeOptions,
|
|
85
|
+
options
|
|
86
|
+
);
|
|
87
|
+
types.push(...connectionTypes);
|
|
76
88
|
}
|
|
77
|
-
const moduleDir = createConnectionModuleDir(
|
|
78
|
-
ctx.generatorOptions.modulesDir,
|
|
79
|
-
options.moduleName
|
|
80
|
-
);
|
|
89
|
+
const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
|
|
81
90
|
const definitionFile = new File(
|
|
82
91
|
createGqlFilename(moduleDir),
|
|
83
92
|
printTypes(types),
|
|
@@ -85,14 +94,15 @@ function paginationPlugin(options) {
|
|
|
85
94
|
);
|
|
86
95
|
await definitionFile.write();
|
|
87
96
|
ctx.fileManager.add(definitionFile);
|
|
88
|
-
if (options.createExport
|
|
89
|
-
|
|
90
|
-
createExportFilename(moduleDir),
|
|
91
|
-
printExport(ctx.generatorOptions.moduleDefinitionName),
|
|
92
|
-
"pagination"
|
|
93
|
-
);
|
|
94
|
-
ctx.fileManager.add(exportFile);
|
|
97
|
+
if (options.createExport === false) {
|
|
98
|
+
return next();
|
|
95
99
|
}
|
|
100
|
+
const exportFile = new File(
|
|
101
|
+
createExportFilename(moduleDir),
|
|
102
|
+
printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),
|
|
103
|
+
"pagination"
|
|
104
|
+
);
|
|
105
|
+
ctx.fileManager.add(exportFile);
|
|
96
106
|
return next();
|
|
97
107
|
}
|
|
98
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.5",
|
|
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.7"
|
|
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"
|