@baeta/plugin-pagination 0.1.1 → 0.1.3
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 +22 -0
- package/package.json +21 -9
- package/dist/index.cjs +0 -109
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @baeta/plugin-pagination
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#180](https://github.com/andreisergiu98/baeta/pull/180) [`483c709`](https://github.com/andreisergiu98/baeta/commit/483c70932f815fd114732c00b74f9488d7924c72) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Raise minimum required NodeJS version to 22.12.0. Drop CommonJS builds in favor of the require_esm feature from NodeJS 22.12.0 onwards.
|
|
8
|
+
|
|
9
|
+
- [`de6e89c`](https://github.com/andreisergiu98/baeta/commit/de6e89c1b592e280967c73a4137d24ee56ef1857) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - raise es target to 2024
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`483c709`](https://github.com/andreisergiu98/baeta/commit/483c70932f815fd114732c00b74f9488d7924c72), [`de6e89c`](https://github.com/andreisergiu98/baeta/commit/de6e89c1b592e280967c73a4137d24ee56ef1857)]:
|
|
12
|
+
- @baeta/generator-sdk@0.1.3
|
|
13
|
+
- @baeta/util-path@0.1.3
|
|
14
|
+
|
|
15
|
+
## 0.1.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#170](https://github.com/andreisergiu98/baeta/pull/170) [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`e3fb6f8`](https://github.com/andreisergiu98/baeta/commit/e3fb6f877b4b20e248ad79cbaa3655cabe973f6b), [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321)]:
|
|
22
|
+
- @baeta/generator-sdk@0.1.2
|
|
23
|
+
- @baeta/util-path@0.1.2
|
|
24
|
+
|
|
3
25
|
## 0.1.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/plugin-pagination",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"baeta",
|
|
6
6
|
"graphql",
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"require": "./dist/index.cjs"
|
|
31
|
+
"default": "./dist/index.js"
|
|
33
32
|
}
|
|
34
33
|
},
|
|
35
34
|
"types": "dist/index.d.ts",
|
|
@@ -44,24 +43,30 @@
|
|
|
44
43
|
"types": "tsc --noEmit"
|
|
45
44
|
},
|
|
46
45
|
"dependencies": {
|
|
47
|
-
"@baeta/generator-sdk": "^0.1.
|
|
48
|
-
"@baeta/util-path": "^0.1.
|
|
46
|
+
"@baeta/generator-sdk": "^0.1.3",
|
|
47
|
+
"@baeta/util-path": "^0.1.3"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@baeta/builder": "^0.0.0",
|
|
52
51
|
"@baeta/tsconfig": "^0.0.0",
|
|
53
|
-
"@types/node": "^22.
|
|
52
|
+
"@types/node": "^22.10.1",
|
|
54
53
|
"graphql": "^16.9.0",
|
|
55
|
-
"typescript": "^5.
|
|
54
|
+
"typescript": "^5.7.2"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
57
|
"graphql": "^16.6.0"
|
|
59
58
|
},
|
|
60
59
|
"engines": {
|
|
61
|
-
"node": ">=22.
|
|
60
|
+
"node": ">=22.12.0"
|
|
62
61
|
},
|
|
63
62
|
"publishConfig": {
|
|
64
|
-
"access": "public"
|
|
63
|
+
"access": "public",
|
|
64
|
+
"exports": {
|
|
65
|
+
".": {
|
|
66
|
+
"types": "./dist/index.d.ts",
|
|
67
|
+
"default": "./dist/index.js"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
65
70
|
},
|
|
66
71
|
"ava": {
|
|
67
72
|
"extensions": {
|
|
@@ -71,5 +76,12 @@
|
|
|
71
76
|
"--no-warnings",
|
|
72
77
|
"--experimental-transform-types"
|
|
73
78
|
]
|
|
79
|
+
},
|
|
80
|
+
"typedocOptions": {
|
|
81
|
+
"entryPoints": [
|
|
82
|
+
"./index.ts"
|
|
83
|
+
],
|
|
84
|
+
"readme": "none",
|
|
85
|
+
"tsconfig": "./tsconfig.json"
|
|
74
86
|
}
|
|
75
87
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
|
-
var _generatorsdk = require('@baeta/generator-sdk');
|
|
3
|
-
var _utilpath = require('@baeta/util-path');
|
|
4
|
-
function printFields(fields) {
|
|
5
|
-
return fields.map((field) => ` ${field}`).join("\n");
|
|
6
|
-
}
|
|
7
|
-
function printType(name, fields) {
|
|
8
|
-
return `type ${name} {
|
|
9
|
-
${printFields(fields)}
|
|
10
|
-
}`;
|
|
11
|
-
}
|
|
12
|
-
function printTypes(types) {
|
|
13
|
-
return `${types.join("\n\n")}
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
function printPageInfo(addFields = []) {
|
|
17
|
-
return printType("PageInfo", [
|
|
18
|
-
...addFields,
|
|
19
|
-
"hasPreviousPage: Boolean!",
|
|
20
|
-
"hasNextPage: Boolean!"
|
|
21
|
-
]);
|
|
22
|
-
}
|
|
23
|
-
function printExport(moduleDefinitionName, moduleName, importExt = "") {
|
|
24
|
-
const parsed = _utilpath.parse.call(void 0, moduleDefinitionName);
|
|
25
|
-
const method = _generatorsdk.getModuleGetName.call(void 0, moduleName);
|
|
26
|
-
const importName = parsed.ext === ".ts" ? parsed.name : moduleDefinitionName;
|
|
27
|
-
return `import { ${method} } from "./${importName}${importExt}";
|
|
28
|
-
|
|
29
|
-
export const ${_generatorsdk.getModuleVariableName.call(void 0, moduleName)} = ${method}();
|
|
30
|
-
`;
|
|
31
|
-
}
|
|
32
|
-
function printConnectionTypes(name, typeOptions, options) {
|
|
33
|
-
const {
|
|
34
|
-
cursorType = "String!",
|
|
35
|
-
nodeType = name,
|
|
36
|
-
connectionFields = [],
|
|
37
|
-
edgeFields = []
|
|
38
|
-
} = typeOptions;
|
|
39
|
-
const connection = printType(`${name}Connection`, [
|
|
40
|
-
...connectionFields,
|
|
41
|
-
"pageInfo: PageInfo!",
|
|
42
|
-
`edges: [${name}Edge]`
|
|
43
|
-
]);
|
|
44
|
-
const edge = printType(`${name}Edge`, [
|
|
45
|
-
...edgeFields,
|
|
46
|
-
`cursor: ${cursorType}`,
|
|
47
|
-
`node: ${nodeType}${options.nullableNode === false ? "!" : ""}`
|
|
48
|
-
]);
|
|
49
|
-
return [connection, edge];
|
|
50
|
-
}
|
|
51
|
-
function createConnectionModuleDir(modulesDir, moduleName) {
|
|
52
|
-
return _utilpath.join.call(void 0, modulesDir, moduleName);
|
|
53
|
-
}
|
|
54
|
-
function createGqlFilename(moduleDir) {
|
|
55
|
-
return `${moduleDir}/connections.gql`;
|
|
56
|
-
}
|
|
57
|
-
function createExportFilename(moduleDir) {
|
|
58
|
-
return `${moduleDir}/index.ts`;
|
|
59
|
-
}
|
|
60
|
-
function paginationPlugin(options) {
|
|
61
|
-
const { moduleName = "baeta-pagination" } = options;
|
|
62
|
-
return _generatorsdk.createPluginV1.call(void 0, {
|
|
63
|
-
name: "pagination",
|
|
64
|
-
actionName: "pagination connections",
|
|
65
|
-
watch: (generatorOptions, watcher) => {
|
|
66
|
-
watcher.ignore(`${createConnectionModuleDir(generatorOptions.modulesDir, moduleName)}/**`);
|
|
67
|
-
},
|
|
68
|
-
generate: async (ctx, next) => {
|
|
69
|
-
const types = [printPageInfo(options.pageInfoFields)];
|
|
70
|
-
for (const name in options.types) {
|
|
71
|
-
const typeOptions = options.types[name];
|
|
72
|
-
if (typeOptions === false) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const connectionTypes = printConnectionTypes(
|
|
76
|
-
name,
|
|
77
|
-
typeOptions === true ? {} : typeOptions,
|
|
78
|
-
options
|
|
79
|
-
);
|
|
80
|
-
types.push(...connectionTypes);
|
|
81
|
-
}
|
|
82
|
-
const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
|
|
83
|
-
const definitionFile = ctx.fileManager.createAndAdd(
|
|
84
|
-
createGqlFilename(moduleDir),
|
|
85
|
-
printTypes(types),
|
|
86
|
-
"pagination"
|
|
87
|
-
);
|
|
88
|
-
await definitionFile.write();
|
|
89
|
-
ctx.fileManager.add(definitionFile);
|
|
90
|
-
if (options.createExport === false) {
|
|
91
|
-
return next();
|
|
92
|
-
}
|
|
93
|
-
ctx.fileManager.createAndAdd(
|
|
94
|
-
createExportFilename(moduleDir),
|
|
95
|
-
printExport(
|
|
96
|
-
ctx.generatorOptions.moduleDefinitionName,
|
|
97
|
-
moduleName,
|
|
98
|
-
ctx.generatorOptions.importExtension
|
|
99
|
-
),
|
|
100
|
-
"pagination"
|
|
101
|
-
);
|
|
102
|
-
return next();
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
exports.paginationPlugin = paginationPlugin;
|
|
109
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/baeta/ba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,QAAA;AACD,MAAA;AAEY,MAAA;AACb,IAAA;AACA,EAAA;AACF;ADrC0C;AACA;AACA","file":"/home/runner/work/baeta/baeta/packages/plugin-pagination/dist/index.cjs","sourcesContent":[null,"import { createPluginV1, getModuleGetName, getModuleVariableName } from '@baeta/generator-sdk';\nimport { join, parse } from '@baeta/util-path';\n\ninterface TypeOptions {\n\tnodeType?: string;\n\tcursorType?: string;\n\tedgeFields?: string[];\n\tconnectionFields?: string[];\n}\n\ninterface PaginationOptions {\n\ttypes: Record<string, boolean | TypeOptions>;\n\tnullableNode?: boolean;\n\tpageInfoFields?: string[];\n\tmoduleName?: string;\n\tcreateExport?: boolean;\n}\n\nfunction printFields(fields: string[]) {\n\treturn fields.map((field) => ` ${field}`).join('\\n');\n}\n\nfunction printType(name: string, fields: string[]) {\n\treturn `type ${name} {\n${printFields(fields)}\n}`;\n}\n\nfunction printTypes(types: string[]) {\n\treturn `${types.join('\\n\\n')}\\n`;\n}\n\nfunction printPageInfo(addFields: string[] = []) {\n\treturn printType('PageInfo', [\n\t\t...addFields,\n\t\t'hasPreviousPage: Boolean!',\n\t\t'hasNextPage: Boolean!',\n\t]);\n}\n\nfunction printExport(moduleDefinitionName: string, moduleName: string, importExt = '') {\n\tconst parsed = parse(moduleDefinitionName);\n\tconst method = getModuleGetName(moduleName);\n\tconst importName = parsed.ext === '.ts' ? parsed.name : moduleDefinitionName;\n\n\treturn `import { ${method} } from \"./${importName}${importExt}\";\n\nexport const ${getModuleVariableName(moduleName)} = ${method}();\n`;\n}\n\nfunction printConnectionTypes(name: string, typeOptions: TypeOptions, options: PaginationOptions) {\n\tconst {\n\t\tcursorType = 'String!',\n\t\tnodeType = name,\n\t\tconnectionFields = [],\n\t\tedgeFields = [],\n\t} = typeOptions;\n\n\tconst connection = printType(`${name}Connection`, [\n\t\t...connectionFields,\n\t\t'pageInfo: PageInfo!',\n\t\t`edges: [${name}Edge]`,\n\t]);\n\n\tconst edge = printType(`${name}Edge`, [\n\t\t...edgeFields,\n\t\t`cursor: ${cursorType}`,\n\t\t`node: ${nodeType}${options.nullableNode === false ? '!' : ''}`,\n\t]);\n\n\treturn [connection, edge];\n}\n\nfunction createConnectionModuleDir(modulesDir: string, moduleName: string) {\n\treturn join(modulesDir, moduleName);\n}\n\nfunction createGqlFilename(moduleDir: string) {\n\treturn `${moduleDir}/connections.gql`;\n}\n\nfunction createExportFilename(moduleDir: string) {\n\treturn `${moduleDir}/index.ts`;\n}\n\nexport function paginationPlugin(options: PaginationOptions) {\n\tconst { moduleName = 'baeta-pagination' } = options;\n\n\treturn createPluginV1({\n\t\tname: 'pagination',\n\t\tactionName: 'pagination connections',\n\t\twatch: (generatorOptions, watcher) => {\n\t\t\twatcher.ignore(`${createConnectionModuleDir(generatorOptions.modulesDir, moduleName)}/**`);\n\t\t},\n\t\tgenerate: async (ctx, next) => {\n\t\t\tconst types: string[] = [printPageInfo(options.pageInfoFields)];\n\n\t\t\tfor (const name in options.types) {\n\t\t\t\tconst typeOptions = options.types[name];\n\n\t\t\t\tif (typeOptions === false) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst connectionTypes = printConnectionTypes(\n\t\t\t\t\tname,\n\t\t\t\t\ttypeOptions === true ? {} : typeOptions,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\n\t\t\t\ttypes.push(...connectionTypes);\n\t\t\t}\n\n\t\t\tconst moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);\n\n\t\t\tconst definitionFile = ctx.fileManager.createAndAdd(\n\t\t\t\tcreateGqlFilename(moduleDir),\n\t\t\t\tprintTypes(types),\n\t\t\t\t'pagination',\n\t\t\t);\n\t\t\tawait definitionFile.write();\n\n\t\t\tctx.fileManager.add(definitionFile);\n\n\t\t\tif (options.createExport === false) {\n\t\t\t\treturn next();\n\t\t\t}\n\n\t\t\tctx.fileManager.createAndAdd(\n\t\t\t\tcreateExportFilename(moduleDir),\n\t\t\t\tprintExport(\n\t\t\t\t\tctx.generatorOptions.moduleDefinitionName,\n\t\t\t\t\tmoduleName,\n\t\t\t\t\tctx.generatorOptions.importExtension,\n\t\t\t\t),\n\t\t\t\t'pagination',\n\t\t\t);\n\n\t\t\treturn next();\n\t\t},\n\t});\n}\n"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as _baeta_generator_sdk from '@baeta/generator-sdk';
|
|
2
|
-
|
|
3
|
-
interface TypeOptions {
|
|
4
|
-
nodeType?: string;
|
|
5
|
-
cursorType?: string;
|
|
6
|
-
edgeFields?: string[];
|
|
7
|
-
connectionFields?: string[];
|
|
8
|
-
}
|
|
9
|
-
interface PaginationOptions {
|
|
10
|
-
types: Record<string, boolean | TypeOptions>;
|
|
11
|
-
nullableNode?: boolean;
|
|
12
|
-
pageInfoFields?: string[];
|
|
13
|
-
moduleName?: string;
|
|
14
|
-
createExport?: boolean;
|
|
15
|
-
}
|
|
16
|
-
declare function paginationPlugin(options: PaginationOptions): _baeta_generator_sdk.GeneratorPluginV1<unknown>;
|
|
17
|
-
|
|
18
|
-
export { paginationPlugin };
|