@baeta/plugin-pagination 0.0.4 → 0.0.6

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @baeta/plugin-pagination
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#66](https://github.com/andreisergiu98/baeta/pull/66) [`9a4a021`](https://github.com/andreisergiu98/baeta/commit/9a4a0214351b70295ce4f7eecaa8c49ab0e1325b) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - replace chokidar with @parcel/watcher
8
+
9
+ - Updated dependencies [[`9a4a021`](https://github.com/andreisergiu98/baeta/commit/9a4a0214351b70295ce4f7eecaa8c49ab0e1325b)]:
10
+ - @baeta/generator-sdk@0.0.8
11
+
12
+ ## 0.0.5
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies []:
17
+ - @baeta/generator-sdk@0.0.7
18
+
3
19
  ## 0.0.4
4
20
 
5
21
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -66,11 +66,8 @@ function paginationPlugin(options) {
66
66
  return _generatorsdk.createPluginV1.call(void 0, {
67
67
  name: "pagination",
68
68
  actionName: "pagination connections",
69
- watch: (generatorOptions) => {
70
- return {
71
- include: [],
72
- ignore: [createConnectionModuleDir(generatorOptions.modulesDir, moduleName)]
73
- };
69
+ watch: (generatorOptions, watcher) => {
70
+ watcher.ignore(`${createConnectionModuleDir(generatorOptions.modulesDir, moduleName)}/**`);
74
71
  },
75
72
  generate: async (ctx, next) => {
76
73
  const types = [printPageInfo(options.pageInfoFields)];
@@ -87,11 +84,7 @@ function paginationPlugin(options) {
87
84
  types.push(...connectionTypes);
88
85
  }
89
86
  const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
90
- const definitionFile = new (0, _generatorsdk.File)(
91
- createGqlFilename(moduleDir),
92
- printTypes(types),
93
- "pagination"
94
- );
87
+ const definitionFile = new (0, _generatorsdk.File)(createGqlFilename(moduleDir), printTypes(types), "schema");
95
88
  await definitionFile.write();
96
89
  ctx.fileManager.add(definitionFile);
97
90
  if (options.createExport === false) {
@@ -100,7 +93,7 @@ function paginationPlugin(options) {
100
93
  const exportFile = new (0, _generatorsdk.File)(
101
94
  createExportFilename(moduleDir),
102
95
  printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),
103
- "pagination"
96
+ "export"
104
97
  );
105
98
  ctx.fileManager.add(exportFile);
106
99
  return next();
@@ -110,3 +103,4 @@ function paginationPlugin(options) {
110
103
 
111
104
 
112
105
  exports.paginationPlugin = paginationPlugin;
106
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts"],"names":[],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,aAAa;AAiB5B,SAAS,YAAY,QAAkB;AACrC,SAAO,OAAO,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,KAAK,IAAI;AACtD;AAEA,SAAS,UAAU,MAAc,QAAkB;AACjD,SAAO,QAAQ;AAAA,EACf,YAAY,MAAM;AAAA;AAEpB;AAEA,SAAS,WAAW,OAAiB;AACnC,SAAO,MAAM,KAAK,MAAM,IAAI;AAC9B;AAEA,SAAS,cAAc,YAAsB,CAAC,GAAG;AAC/C,SAAO,UAAU,YAAY;AAAA,IAC3B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEA,SAAS,YAAY,sBAA8B,YAAoB;AACrE,QAAM,SAAS,MAAM,oBAAoB;AACzC,QAAM,SAAS,iBAAiB,UAAU;AAC1C,QAAM,aAAa,OAAO,QAAQ,QAAQ,OAAO,OAAO;AAExD,SAAO,YAAY,oBAAoB;AAAA;AAAA,eAE1B,sBAAsB,UAAU,OAAO;AAAA;AAEtD;AAEA,SAAS,qBAAqB,MAAc,aAA0B,SAA4B;AAChG,QAAM;AAA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AG,WAAW,KAAK,GAAG,QAAQ;AAEzF,YAAM,eAAe,MAAM;AAE3B,UAAI,YAAY,IAAI,cAAc;AAElC,UAAI,QAAQ,iBAAiB,OAAO;AAClC,eAAO,KAAK;AAAA,MACd;AAEA,YAAM,aAAa,IAAI;AAAA,QACrB,qBAAqB,SAAS;AAAA,QAC9B,YAAY,IAAI,iBAAiB,sBAAsB,UAAU;AAAA,QACjE;AAAA,MACF;AAEA,UAAI,YAAY,IAAI,UAAU;AAE9B,aAAO,KAAK;AAAA,IACd;AAAA,EACF,CAAC;AACH","sourcesContent":["import {\n createPluginV1,\n File,\n getModuleGetName,\n getModuleVariableName,\n} from '@baeta/generator-sdk';\nimport { join, parse } from 'path';\n\ninterface TypeOptions {\n nodeType?: string;\n cursorType?: string;\n edgeFields?: string[];\n connectionFields?: string[];\n}\n\ninterface PaginationOptions {\n types: Record<string, boolean | TypeOptions>;\n nullableNode?: boolean;\n pageInfoFields?: string[];\n moduleName?: string;\n createExport?: boolean;\n}\n\nfunction printFields(fields: string[]) {\n return fields.map((field) => ` ${field}`).join('\\n');\n}\n\nfunction printType(name: string, fields: string[]) {\n return `type ${name} {\n${printFields(fields)}\n}`;\n}\n\nfunction printTypes(types: string[]) {\n return types.join('\\n\\n') + '\\n';\n}\n\nfunction printPageInfo(addFields: string[] = []) {\n return printType('PageInfo', [\n ...addFields,\n 'hasPreviousPage: Boolean!',\n 'hasNextPage: Boolean!',\n ]);\n}\n\nfunction printExport(moduleDefinitionName: string, moduleName: string) {\n const parsed = parse(moduleDefinitionName);\n const method = getModuleGetName(moduleName);\n const importName = parsed.ext === '.ts' ? parsed.name : moduleDefinitionName;\n\n return `import { ${method} } from \"./${importName}\";\n\nexport const ${getModuleVariableName(moduleName)} = ${method}();\n`;\n}\n\nfunction printConnectionTypes(name: string, typeOptions: TypeOptions, options: PaginationOptions) {\n const {\n cursorType = 'String!',\n nodeType = name,\n connectionFields = [],\n edgeFields = [],\n } = typeOptions;\n\n const connection = printType(`${name}Connection`, [\n ...connectionFields,\n 'pageInfo: PageInfo!',\n `edges: [${name}Edge]`,\n ]);\n\n const edge = printType(`${name}Edge`, [\n ...edgeFields,\n `cursor: ${cursorType}`,\n `node: ${nodeType}${options.nullableNode === false ? '!' : ''}`,\n ]);\n\n return [connection, edge];\n}\n\nfunction createConnectionModuleDir(modulesDir: string, moduleName: string) {\n return join(modulesDir, moduleName);\n}\n\nfunction createGqlFilename(moduleDir: string) {\n return `${moduleDir}/connections.gql`;\n}\n\nfunction createExportFilename(moduleDir: string) {\n return `${moduleDir}/index.ts`;\n}\n\nexport function paginationPlugin(options: PaginationOptions) {\n const { moduleName = 'baeta-pagination' } = options;\n\n return createPluginV1({\n name: 'pagination',\n actionName: 'pagination connections',\n watch: (generatorOptions, watcher) => {\n watcher.ignore(`${createConnectionModuleDir(generatorOptions.modulesDir, moduleName)}/**`);\n },\n generate: async (ctx, next) => {\n const types: string[] = [printPageInfo(options.pageInfoFields)];\n\n for (const name in options.types) {\n const typeOptions = options.types[name];\n\n if (typeOptions === false) {\n continue;\n }\n\n const connectionTypes = printConnectionTypes(\n name,\n typeOptions === true ? {} : typeOptions,\n options\n );\n\n types.push(...connectionTypes);\n }\n\n const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);\n\n const definitionFile = new File(createGqlFilename(moduleDir), printTypes(types), 'schema');\n\n await definitionFile.write();\n\n ctx.fileManager.add(definitionFile);\n\n if (options.createExport === false) {\n return next();\n }\n\n const exportFile = new File(\n createExportFilename(moduleDir),\n printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),\n 'export'\n );\n\n ctx.fileManager.add(exportFile);\n\n return next();\n },\n });\n}\n"]}
package/dist/index.js CHANGED
@@ -66,11 +66,8 @@ function paginationPlugin(options) {
66
66
  return createPluginV1({
67
67
  name: "pagination",
68
68
  actionName: "pagination connections",
69
- watch: (generatorOptions) => {
70
- return {
71
- include: [],
72
- ignore: [createConnectionModuleDir(generatorOptions.modulesDir, moduleName)]
73
- };
69
+ watch: (generatorOptions, watcher) => {
70
+ watcher.ignore(`${createConnectionModuleDir(generatorOptions.modulesDir, moduleName)}/**`);
74
71
  },
75
72
  generate: async (ctx, next) => {
76
73
  const types = [printPageInfo(options.pageInfoFields)];
@@ -87,11 +84,7 @@ function paginationPlugin(options) {
87
84
  types.push(...connectionTypes);
88
85
  }
89
86
  const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);
90
- const definitionFile = new File(
91
- createGqlFilename(moduleDir),
92
- printTypes(types),
93
- "pagination"
94
- );
87
+ const definitionFile = new File(createGqlFilename(moduleDir), printTypes(types), "schema");
95
88
  await definitionFile.write();
96
89
  ctx.fileManager.add(definitionFile);
97
90
  if (options.createExport === false) {
@@ -100,7 +93,7 @@ function paginationPlugin(options) {
100
93
  const exportFile = new File(
101
94
  createExportFilename(moduleDir),
102
95
  printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),
103
- "pagination"
96
+ "export"
104
97
  );
105
98
  ctx.fileManager.add(exportFile);
106
99
  return next();
@@ -110,3 +103,4 @@ function paginationPlugin(options) {
110
103
  export {
111
104
  paginationPlugin
112
105
  };
106
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n createPluginV1,\n File,\n getModuleGetName,\n getModuleVariableName,\n} from '@baeta/generator-sdk';\nimport { join, parse } from 'path';\n\ninterface TypeOptions {\n nodeType?: string;\n cursorType?: string;\n edgeFields?: string[];\n connectionFields?: string[];\n}\n\ninterface PaginationOptions {\n types: Record<string, boolean | TypeOptions>;\n nullableNode?: boolean;\n pageInfoFields?: string[];\n moduleName?: string;\n createExport?: boolean;\n}\n\nfunction printFields(fields: string[]) {\n return fields.map((field) => ` ${field}`).join('\\n');\n}\n\nfunction printType(name: string, fields: string[]) {\n return `type ${name} {\n${printFields(fields)}\n}`;\n}\n\nfunction printTypes(types: string[]) {\n return types.join('\\n\\n') + '\\n';\n}\n\nfunction printPageInfo(addFields: string[] = []) {\n return printType('PageInfo', [\n ...addFields,\n 'hasPreviousPage: Boolean!',\n 'hasNextPage: Boolean!',\n ]);\n}\n\nfunction printExport(moduleDefinitionName: string, moduleName: string) {\n const parsed = parse(moduleDefinitionName);\n const method = getModuleGetName(moduleName);\n const importName = parsed.ext === '.ts' ? parsed.name : moduleDefinitionName;\n\n return `import { ${method} } from \"./${importName}\";\n\nexport const ${getModuleVariableName(moduleName)} = ${method}();\n`;\n}\n\nfunction printConnectionTypes(name: string, typeOptions: TypeOptions, options: PaginationOptions) {\n const {\n cursorType = 'String!',\n nodeType = name,\n connectionFields = [],\n edgeFields = [],\n } = typeOptions;\n\n const connection = printType(`${name}Connection`, [\n ...connectionFields,\n 'pageInfo: PageInfo!',\n `edges: [${name}Edge]`,\n ]);\n\n const edge = printType(`${name}Edge`, [\n ...edgeFields,\n `cursor: ${cursorType}`,\n `node: ${nodeType}${options.nullableNode === false ? '!' : ''}`,\n ]);\n\n return [connection, edge];\n}\n\nfunction createConnectionModuleDir(modulesDir: string, moduleName: string) {\n return join(modulesDir, moduleName);\n}\n\nfunction createGqlFilename(moduleDir: string) {\n return `${moduleDir}/connections.gql`;\n}\n\nfunction createExportFilename(moduleDir: string) {\n return `${moduleDir}/index.ts`;\n}\n\nexport function paginationPlugin(options: PaginationOptions) {\n const { moduleName = 'baeta-pagination' } = options;\n\n return createPluginV1({\n name: 'pagination',\n actionName: 'pagination connections',\n watch: (generatorOptions, watcher) => {\n watcher.ignore(`${createConnectionModuleDir(generatorOptions.modulesDir, moduleName)}/**`);\n },\n generate: async (ctx, next) => {\n const types: string[] = [printPageInfo(options.pageInfoFields)];\n\n for (const name in options.types) {\n const typeOptions = options.types[name];\n\n if (typeOptions === false) {\n continue;\n }\n\n const connectionTypes = printConnectionTypes(\n name,\n typeOptions === true ? {} : typeOptions,\n options\n );\n\n types.push(...connectionTypes);\n }\n\n const moduleDir = createConnectionModuleDir(ctx.generatorOptions.modulesDir, moduleName);\n\n const definitionFile = new File(createGqlFilename(moduleDir), printTypes(types), 'schema');\n\n await definitionFile.write();\n\n ctx.fileManager.add(definitionFile);\n\n if (options.createExport === false) {\n return next();\n }\n\n const exportFile = new File(\n createExportFilename(moduleDir),\n printExport(ctx.generatorOptions.moduleDefinitionName, moduleName),\n 'export'\n );\n\n ctx.fileManager.add(exportFile);\n\n return next();\n },\n });\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,aAAa;AAiB5B,SAAS,YAAY,QAAkB;AACrC,SAAO,OAAO,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,KAAK,IAAI;AACtD;AAEA,SAAS,UAAU,MAAc,QAAkB;AACjD,SAAO,QAAQ;AAAA,EACf,YAAY,MAAM;AAAA;AAEpB;AAEA,SAAS,WAAW,OAAiB;AACnC,SAAO,MAAM,KAAK,MAAM,IAAI;AAC9B;AAEA,SAAS,cAAc,YAAsB,CAAC,GAAG;AAC/C,SAAO,UAAU,YAAY;AAAA,IAC3B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEA,SAAS,YAAY,sBAA8B,YAAoB;AACrE,QAAM,SAAS,MAAM,oBAAoB;AACzC,QAAM,SAAS,iBAAiB,UAAU;AAC1C,QAAM,aAAa,OAAO,QAAQ,QAAQ,OAAO,OAAO;AAExD,SAAO,YAAY,oBAAoB;AAAA;AAAA,eAE1B,sBAAsB,UAAU,OAAO;AAAA;AAEtD;AAEA,SAAS,qBAAqB,MAAc,aAA0B,SAA4B;AAChG,QAAM;AAAA,IACJ,aAAa;AAAA,IACb,WAAW;AAAA,IACX,mBAAmB,CAAC;AAAA,IACpB,aAAa,CAAC;AAAA,EAChB,IAAI;AAEJ,QAAM,aAAa,UAAU,GAAG,kBAAkB;AAAA,IAChD,GAAG;AAAA,IACH;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AAED,QAAM,OAAO,UAAU,GAAG,YA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sBAAsB,UAAU;AAAA,QACjE;AAAA,MACF;AAEA,UAAI,YAAY,IAAI,UAAU;AAE9B,aAAO,KAAK;AAAA,IACd;AAAA,EACF,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baeta/plugin-pagination",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "homepage": "https://github.com/andreisergiu98/baeta#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/andreisergiu98/baeta/issues"
@@ -13,18 +13,27 @@
13
13
  "license": "MIT",
14
14
  "author": "Andrei Pampu <pampu.andrei@pm.me>",
15
15
  "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.cjs",
20
+ "types": "./dist/index.d.ts"
21
+ }
22
+ },
23
+ "types": "dist/index.d.ts",
16
24
  "files": [
17
25
  "dist",
18
26
  "package.json"
19
27
  ],
20
28
  "scripts": {
21
29
  "build": "tsup",
30
+ "dev": "tsup --watch",
22
31
  "prepack": "prep",
23
32
  "postpack": "prep --clean",
24
33
  "types": "tsc --noEmit"
25
34
  },
26
35
  "dependencies": {
27
- "@baeta/generator-sdk": "^0.0.6"
36
+ "@baeta/generator-sdk": "^0.0.8"
28
37
  },
29
38
  "devDependencies": {
30
39
  "@baeta/builder": "^0.0.0",
@@ -40,22 +49,6 @@
40
49
  "node": ">=18.0.0"
41
50
  },
42
51
  "publishConfig": {
43
- "access": "public",
44
- "exports": {
45
- ".": {
46
- "import": "./dist/index.js",
47
- "require": "./dist/index.cjs",
48
- "types": "./dist/index.d.ts"
49
- }
50
- },
51
- "types": "dist/index.d.ts"
52
- },
53
- "exports": {
54
- ".": {
55
- "import": "./dist/index.js",
56
- "require": "./dist/index.cjs",
57
- "types": "./dist/index.d.ts"
58
- }
59
- },
60
- "types": "dist/index.d.ts"
52
+ "access": "public"
53
+ }
61
54
  }