@feathersjs/cli 5.0.0-pre.29 → 5.0.0-pre.31

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +30 -37
  2. package/bin/feathers +3 -6
  3. package/lib/app/index.js +33 -10
  4. package/lib/app/index.js.map +1 -1
  5. package/lib/app/index.ts +88 -51
  6. package/lib/app/templates/app.test.tpl.js +1 -1
  7. package/lib/app/templates/app.test.tpl.js.map +1 -1
  8. package/lib/app/templates/app.test.tpl.ts +1 -2
  9. package/lib/app/templates/app.tpl.js +7 -7
  10. package/lib/app/templates/app.tpl.js.map +1 -1
  11. package/lib/app/templates/app.tpl.ts +7 -9
  12. package/lib/app/templates/channels.tpl.js +1 -1
  13. package/lib/app/templates/channels.tpl.js.map +1 -1
  14. package/lib/app/templates/channels.tpl.ts +1 -2
  15. package/lib/app/templates/{configuration.tpl.d.ts → client.test.tpl.d.ts} +0 -0
  16. package/lib/app/templates/client.test.tpl.js +27 -0
  17. package/lib/app/templates/client.test.tpl.js.map +1 -0
  18. package/lib/app/templates/client.test.tpl.ts +26 -0
  19. package/lib/app/templates/client.tpl.js +3 -3
  20. package/lib/app/templates/client.tpl.js.map +1 -1
  21. package/lib/app/templates/client.tpl.ts +3 -4
  22. package/lib/app/templates/declarations.tpl.js +3 -3
  23. package/lib/app/templates/declarations.tpl.js.map +1 -1
  24. package/lib/app/templates/declarations.tpl.ts +5 -4
  25. package/lib/app/templates/index.html.tpl.js +12 -52
  26. package/lib/app/templates/index.html.tpl.js.map +1 -1
  27. package/lib/app/templates/index.html.tpl.ts +12 -53
  28. package/lib/app/templates/index.tpl.js +1 -1
  29. package/lib/app/templates/index.tpl.js.map +1 -1
  30. package/lib/app/templates/index.tpl.ts +1 -2
  31. package/lib/app/templates/logger.tpl.js +9 -3
  32. package/lib/app/templates/logger.tpl.js.map +1 -1
  33. package/lib/app/templates/logger.tpl.ts +10 -4
  34. package/lib/app/templates/package.json.tpl.js +4 -3
  35. package/lib/app/templates/package.json.tpl.js.map +1 -1
  36. package/lib/app/templates/package.json.tpl.ts +5 -3
  37. package/lib/app/templates/readme.md.tpl.js +11 -7
  38. package/lib/app/templates/readme.md.tpl.js.map +1 -1
  39. package/lib/app/templates/readme.md.tpl.ts +15 -8
  40. package/lib/app/templates/schemas.tpl.d.ts +2 -0
  41. package/lib/app/templates/schemas.tpl.js +75 -0
  42. package/lib/app/templates/schemas.tpl.js.map +1 -0
  43. package/lib/app/templates/schemas.tpl.ts +89 -0
  44. package/lib/app/templates/services.tpl.js +1 -1
  45. package/lib/app/templates/services.tpl.js.map +1 -1
  46. package/lib/app/templates/services.tpl.ts +1 -2
  47. package/lib/authentication/index.d.ts +5 -3
  48. package/lib/authentication/index.js +12 -3
  49. package/lib/authentication/index.js.map +1 -1
  50. package/lib/authentication/index.ts +23 -5
  51. package/lib/authentication/templates/authentication.tpl.js +1 -1
  52. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  53. package/lib/authentication/templates/authentication.tpl.ts +3 -2
  54. package/lib/authentication/templates/{test.tpl.d.ts → client.test.tpl.d.ts} +0 -0
  55. package/lib/authentication/templates/client.test.tpl.js +66 -0
  56. package/lib/authentication/templates/client.test.tpl.js.map +1 -0
  57. package/lib/authentication/templates/client.test.tpl.ts +80 -0
  58. package/lib/{service/templates/schema.tpl.d.ts → authentication/templates/client.tpl.d.ts} +1 -1
  59. package/lib/authentication/templates/client.tpl.js +14 -0
  60. package/lib/authentication/templates/client.tpl.js.map +1 -0
  61. package/lib/authentication/templates/client.tpl.ts +19 -0
  62. package/lib/authentication/templates/config.tpl.js +1 -1
  63. package/lib/authentication/templates/config.tpl.js.map +1 -1
  64. package/lib/authentication/templates/config.tpl.ts +1 -1
  65. package/lib/authentication/templates/declarations.tpl.js +3 -3
  66. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  67. package/lib/authentication/templates/declarations.tpl.ts +9 -4
  68. package/lib/authentication/templates/knex.tpl.js +4 -4
  69. package/lib/authentication/templates/knex.tpl.js.map +1 -1
  70. package/lib/authentication/templates/knex.tpl.ts +5 -5
  71. package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  72. package/lib/authentication/templates/schema.json.tpl.js +92 -0
  73. package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
  74. package/lib/authentication/templates/schema.json.tpl.ts +108 -0
  75. package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
  76. package/lib/authentication/templates/schema.typebox.tpl.js +77 -0
  77. package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
  78. package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
  79. package/lib/cli.d.ts +6 -0
  80. package/lib/cli.js +75 -0
  81. package/lib/cli.js.map +1 -0
  82. package/lib/cli.ts +68 -0
  83. package/lib/commons.d.ts +14 -1
  84. package/lib/commons.js +24 -4
  85. package/lib/commons.js.map +1 -1
  86. package/lib/commons.ts +29 -1
  87. package/lib/connection/index.d.ts +5 -3
  88. package/lib/connection/index.js +5 -3
  89. package/lib/connection/index.js.map +1 -1
  90. package/lib/connection/index.ts +19 -5
  91. package/lib/connection/templates/knex.tpl.js +2 -12
  92. package/lib/connection/templates/knex.tpl.js.map +1 -1
  93. package/lib/connection/templates/knex.tpl.ts +6 -20
  94. package/lib/connection/templates/mongodb.tpl.js +1 -3
  95. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  96. package/lib/connection/templates/mongodb.tpl.ts +1 -12
  97. package/lib/hook/index.d.ts +1 -1
  98. package/lib/hook/index.js +3 -0
  99. package/lib/hook/index.js.map +1 -1
  100. package/lib/hook/index.ts +3 -1
  101. package/lib/hook/templates/hook.tpl.js +2 -3
  102. package/lib/hook/templates/hook.tpl.js.map +1 -1
  103. package/lib/hook/templates/hook.tpl.ts +5 -3
  104. package/lib/index.d.ts +2 -16
  105. package/lib/index.js +16 -24
  106. package/lib/index.js.map +1 -1
  107. package/lib/index.ts +2 -28
  108. package/lib/service/index.d.ts +10 -60
  109. package/lib/service/index.js +41 -4
  110. package/lib/service/index.js.map +1 -1
  111. package/lib/service/index.ts +61 -7
  112. package/lib/service/templates/client.tpl.js +21 -18
  113. package/lib/service/templates/client.tpl.js.map +1 -1
  114. package/lib/service/templates/client.tpl.ts +52 -24
  115. package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  116. package/lib/service/templates/schema.json.tpl.js +75 -0
  117. package/lib/service/templates/schema.json.tpl.js.map +1 -0
  118. package/lib/service/templates/schema.json.tpl.ts +87 -0
  119. package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
  120. package/lib/service/templates/schema.typebox.tpl.js +55 -0
  121. package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
  122. package/lib/service/templates/schema.typebox.tpl.ts +67 -0
  123. package/lib/service/templates/service.tpl.d.ts +1 -0
  124. package/lib/service/templates/service.tpl.js +67 -15
  125. package/lib/service/templates/service.tpl.js.map +1 -1
  126. package/lib/service/templates/service.tpl.ts +98 -19
  127. package/lib/service/templates/test.tpl.js +1 -1
  128. package/lib/service/templates/test.tpl.js.map +1 -1
  129. package/lib/service/templates/test.tpl.ts +1 -2
  130. package/lib/service/type/custom.tpl.d.ts +1 -2
  131. package/lib/service/type/custom.tpl.js +32 -25
  132. package/lib/service/type/custom.tpl.js.map +1 -1
  133. package/lib/service/type/custom.tpl.ts +44 -35
  134. package/lib/service/type/knex.tpl.d.ts +1 -3
  135. package/lib/service/type/knex.tpl.js +37 -25
  136. package/lib/service/type/knex.tpl.js.map +1 -1
  137. package/lib/service/type/knex.tpl.ts +54 -31
  138. package/lib/service/type/mongodb.tpl.d.ts +1 -2
  139. package/lib/service/type/mongodb.tpl.js +32 -20
  140. package/lib/service/type/mongodb.tpl.js.map +1 -1
  141. package/lib/service/type/mongodb.tpl.ts +49 -29
  142. package/package.json +24 -23
  143. package/lib/app/templates/configuration.tpl.js +0 -45
  144. package/lib/app/templates/configuration.tpl.js.map +0 -1
  145. package/lib/app/templates/configuration.tpl.ts +0 -50
  146. package/lib/authentication/templates/test.tpl.js +0 -43
  147. package/lib/authentication/templates/test.tpl.js.map +0 -1
  148. package/lib/authentication/templates/test.tpl.ts +0 -50
  149. package/lib/authentication/templates/user.resolver.tpl.js +0 -98
  150. package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
  151. package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
  152. package/lib/authentication/templates/user.schema.tpl.js +0 -79
  153. package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
  154. package/lib/authentication/templates/user.schema.tpl.ts +0 -87
  155. package/lib/service/templates/class.tpl.js +0 -63
  156. package/lib/service/templates/class.tpl.js.map +0 -1
  157. package/lib/service/templates/class.tpl.ts +0 -79
  158. package/lib/service/templates/resolver.tpl.js +0 -73
  159. package/lib/service/templates/resolver.tpl.js.map +0 -1
  160. package/lib/service/templates/resolver.tpl.ts +0 -78
  161. package/lib/service/templates/schema.tpl.js +0 -75
  162. package/lib/service/templates/schema.tpl.js.map +0 -1
  163. package/lib/service/templates/schema.tpl.ts +0 -80
@@ -1,10 +1,26 @@
1
- import { generator, toFile, after, prepend, append } from '@feathershq/pinion'
2
- import { injectSource } from '../../commons'
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
3
  import { ServiceGeneratorContext } from '../index'
4
4
 
5
- export const template = ({ className, upperName, relative }: ServiceGeneratorContext) =>
6
- `import type { Application } from '${relative}/declarations'
7
-
5
+ export const template = ({ className, upperName, schema, fileName, relative }: ServiceGeneratorContext) => `
6
+ import type { Id, NullableId, Params } from '@feathersjs/feathers'
7
+
8
+ import type { Application } from '${relative}/declarations'
9
+ ${
10
+ schema
11
+ ? `import type {
12
+ ${upperName},
13
+ ${upperName}Data,
14
+ ${upperName}Query
15
+ } from './${fileName}.schema'
16
+ `
17
+ : `
18
+ export type ${upperName} = any
19
+ export type ${upperName}Data = any
20
+ export type ${upperName}Query = any
21
+ `
22
+ }
23
+
8
24
  export interface ${className}Options {
9
25
  app: Application
10
26
  }
@@ -18,20 +34,20 @@ export class ${className} {
18
34
  constructor (public options: ${className}Options) {
19
35
  }
20
36
 
21
- async find (_params?: ${upperName}Params): Promise<${upperName}Result[]> {
37
+ async find (_params?: ${upperName}Params): Promise<${upperName}[]> {
22
38
  return []
23
39
  }
24
40
 
25
- async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}Result> {
41
+ async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}> {
26
42
  return {
27
43
  id: 0,
28
44
  text: \`A new message with ID: \${id}!\`
29
45
  }
30
46
  }
31
47
 
32
- async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}Result>
33
- async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}Result[]>
34
- async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}Result|${upperName}Result[]> {
48
+ async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}>
49
+ async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}[]>
50
+ async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}|${upperName}[]> {
35
51
  if (Array.isArray(data)) {
36
52
  return Promise.all(data.map(current => this.create(current, params)));
37
53
  }
@@ -42,49 +58,42 @@ export class ${className} {
42
58
  }
43
59
  }
44
60
 
45
- async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
61
+ async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
46
62
  return {
47
63
  id: 0,
48
64
  ...data
49
65
  }
50
66
  }
51
67
 
52
- async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
68
+ async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
53
69
  return {
54
70
  id: 0,
55
71
  ...data
56
72
  }
57
73
  }
58
74
 
59
- async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}Result> {
75
+ async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}> {
60
76
  return {
61
77
  id: 0,
62
78
  text: 'removed'
63
79
  }
64
80
  }
65
81
  }
66
- `
67
82
 
68
- export const importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'"
69
-
70
- const optionTemplate = ({}: ServiceGeneratorContext) => ` app`
71
-
72
- const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
73
- lib,
74
- 'services',
75
- ...folder,
76
- `${fileName}.service`
77
- ])
78
-
79
- const toClassFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
80
- lib,
81
- 'services',
82
- ...folder,
83
- `${fileName}.class`
84
- ])
83
+ export const getOptions = (app: Application) => {
84
+ return { app }
85
+ }
86
+ `
85
87
 
86
88
  export const generate = (ctx: ServiceGeneratorContext) =>
87
- generator(ctx)
88
- .then(injectSource(template, append(), toClassFile))
89
- .then(injectSource(importTemplate, prepend(), toClassFile))
90
- .then(injectSource(optionTemplate, after('const options ='), toServiceFile, false))
89
+ generator(ctx).then(
90
+ renderSource(
91
+ template,
92
+ toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
93
+ lib,
94
+ 'services',
95
+ ...folder,
96
+ `${fileName}.class`
97
+ ])
98
+ )
99
+ )
@@ -1,5 +1,3 @@
1
1
  import { ServiceGeneratorContext } from '../index';
2
- export declare const importTemplate = "import { KnexService } from '@feathersjs/knex'\nimport type { KnexAdapterParams } from '@feathersjs/knex'";
3
- export declare const classCode: ({ className, upperName }: ServiceGeneratorContext) => string;
4
- export declare const optionTemplate: ({ kebabName, feathers }: ServiceGeneratorContext) => string;
2
+ export declare const template: ({ className, upperName, feathers, schema, fileName, relative }: ServiceGeneratorContext) => string;
5
3
  export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -1,51 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = exports.optionTemplate = exports.classCode = exports.importTemplate = void 0;
3
+ exports.generate = exports.template = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const migrationTemplate = ({ kebabName }) => `import type { Knex } from 'knex'
6
+ const migrationTemplate = ({ kebabPath }) => /* ts */ `import type { Knex } from 'knex'
7
7
 
8
8
  export async function up(knex: Knex): Promise<void> {
9
- await knex.schema.createTable('${kebabName}', table => {
9
+ await knex.schema.createTable('${kebabPath}', table => {
10
10
  table.increments('id')
11
11
  table.string('text')
12
12
  })
13
13
  }
14
14
 
15
15
  export async function down(knex: Knex): Promise<void> {
16
- await knex.schema.dropTable('${kebabName}')
16
+ await knex.schema.dropTable('${kebabPath}')
17
17
  }
18
18
  `;
19
- exports.importTemplate = `import { KnexService } from \'@feathersjs/knex\'
20
- import type { KnexAdapterParams } from \'@feathersjs/knex\'`;
21
- const classCode = ({ className, upperName }) => `export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
19
+ const template = ({ className, upperName, feathers, schema, fileName, relative }) => /* ts */ `import type { Params } from '@feathersjs/feathers'
20
+ import { KnexService } from '@feathersjs/knex'
21
+ import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
22
+
23
+ import type { Application } from '${relative}/declarations'
24
+ ${schema
25
+ ? `import type {
26
+ ${upperName},
27
+ ${upperName}Data,
28
+ ${upperName}Query
29
+ } from './${fileName}.schema'
30
+ `
31
+ : `
32
+ export type ${upperName} = any
33
+ export type ${upperName}Data = any
34
+ export type ${upperName}Query = any
35
+ `}
36
+
37
+ export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
22
38
  }
23
39
 
24
40
  // By default calls the standard Knex adapter service methods but can be customized with your own functionality.
25
- export class ${className} extends KnexService<${upperName}Result, ${upperName}Data, ${upperName}Params> {
41
+ export class ${className}<ServiceParams extends Params = ${upperName}Params>
42
+ extends KnexService<${upperName}, ${upperName}Data, ServiceParams> {
26
43
  }
27
- `;
28
- exports.classCode = classCode;
29
- const optionTemplate = ({ kebabName, feathers }) => ` paginate: app.get('paginate'),
44
+
45
+ export const getOptions = (app: Application): KnexAdapterOptions => {
46
+ return {
47
+ paginate: app.get('paginate'),
30
48
  Model: app.get('${feathers.database}Client'),
31
- name: '${kebabName}'`;
32
- exports.optionTemplate = optionTemplate;
33
- const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
34
- lib,
35
- 'services',
36
- ...folder,
37
- `${fileName}.service`
38
- ]);
39
- const toClassFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
49
+ name: '${fileName}'
50
+ }
51
+ }
52
+ `;
53
+ exports.template = template;
54
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
55
+ .then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
40
56
  lib,
41
57
  'services',
42
58
  ...folder,
43
59
  `${fileName}.class`
44
- ]);
45
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
46
- .then((0, commons_1.injectSource)(exports.classCode, (0, pinion_1.append)(), toClassFile))
47
- .then((0, commons_1.injectSource)(exports.importTemplate, (0, pinion_1.prepend)(), toClassFile))
48
- .then((0, commons_1.injectSource)(exports.optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile, false))
60
+ ])))
49
61
  .then((0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)('migrations', ({ kebabName }) => {
50
62
  // Probably not great but it works to align with the Knex migration file format
51
63
  const migrationDate = new Date().toISOString().replace(/\D/g, '').substring(0, 14);
@@ -1 +1 @@
1
- {"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,2CAA0D;AAG1D,MAAM,iBAAiB,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAAC;;;m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Y,EACV,gBAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CACH,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAA0B,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC9D,+EAA+E;IAC/E,MAAM,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAElF,OAAO,GAAG,aAAa,IAAI,SAAS,EAAE,CAAA;AACxC,CAAC,CAAC,CACH,CACF,CAAA;AAvBQ,QAAA,QAAQ,YAuBhB"}
@@ -1,57 +1,80 @@
1
- import { generator, toFile, after, prepend, append } from '@feathershq/pinion'
2
- import { injectSource, renderSource } from '../../commons'
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
3
  import { ServiceGeneratorContext } from '../index'
4
4
 
5
- const migrationTemplate = ({ kebabName }: ServiceGeneratorContext) => `import type { Knex } from 'knex'
5
+ const migrationTemplate = ({
6
+ kebabPath
7
+ }: ServiceGeneratorContext) => /* ts */ `import type { Knex } from 'knex'
6
8
 
7
9
  export async function up(knex: Knex): Promise<void> {
8
- await knex.schema.createTable('${kebabName}', table => {
10
+ await knex.schema.createTable('${kebabPath}', table => {
9
11
  table.increments('id')
10
12
  table.string('text')
11
13
  })
12
14
  }
13
15
 
14
16
  export async function down(knex: Knex): Promise<void> {
15
- await knex.schema.dropTable('${kebabName}')
17
+ await knex.schema.dropTable('${kebabPath}')
16
18
  }
17
19
  `
18
20
 
19
- export const importTemplate = `import { KnexService } from \'@feathersjs/knex\'
20
- import type { KnexAdapterParams } from \'@feathersjs/knex\'`
21
+ export const template = ({
22
+ className,
23
+ upperName,
24
+ feathers,
25
+ schema,
26
+ fileName,
27
+ relative
28
+ }: ServiceGeneratorContext) => /* ts */ `import type { Params } from '@feathersjs/feathers'
29
+ import { KnexService } from '@feathersjs/knex'
30
+ import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
21
31
 
22
- export const classCode = ({ className, upperName }: ServiceGeneratorContext) =>
23
- `export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
32
+ import type { Application } from '${relative}/declarations'
33
+ ${
34
+ schema
35
+ ? `import type {
36
+ ${upperName},
37
+ ${upperName}Data,
38
+ ${upperName}Query
39
+ } from './${fileName}.schema'
40
+ `
41
+ : `
42
+ export type ${upperName} = any
43
+ export type ${upperName}Data = any
44
+ export type ${upperName}Query = any
45
+ `
46
+ }
47
+
48
+ export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
24
49
  }
25
50
 
26
51
  // By default calls the standard Knex adapter service methods but can be customized with your own functionality.
27
- export class ${className} extends KnexService<${upperName}Result, ${upperName}Data, ${upperName}Params> {
52
+ export class ${className}<ServiceParams extends Params = ${upperName}Params>
53
+ extends KnexService<${upperName}, ${upperName}Data, ServiceParams> {
28
54
  }
29
- `
30
55
 
31
- export const optionTemplate = ({ kebabName, feathers }: ServiceGeneratorContext) =>
32
- ` paginate: app.get('paginate'),
56
+ export const getOptions = (app: Application): KnexAdapterOptions => {
57
+ return {
58
+ paginate: app.get('paginate'),
33
59
  Model: app.get('${feathers.database}Client'),
34
- name: '${kebabName}'`
35
-
36
- const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
37
- lib,
38
- 'services',
39
- ...folder,
40
- `${fileName}.service`
41
- ])
42
-
43
- const toClassFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
44
- lib,
45
- 'services',
46
- ...folder,
47
- `${fileName}.class`
48
- ])
60
+ name: '${fileName}'
61
+ }
62
+ }
63
+ `
49
64
 
50
65
  export const generate = (ctx: ServiceGeneratorContext) =>
51
66
  generator(ctx)
52
- .then(injectSource(classCode, append(), toClassFile))
53
- .then(injectSource(importTemplate, prepend(), toClassFile))
54
- .then(injectSource(optionTemplate, after('const options ='), toServiceFile, false))
67
+ .then(
68
+ renderSource(
69
+ template,
70
+ toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
71
+ lib,
72
+ 'services',
73
+ ...folder,
74
+ `${fileName}.class`
75
+ ])
76
+ )
77
+ )
55
78
  .then(
56
79
  renderSource(
57
80
  migrationTemplate,
@@ -1,4 +1,3 @@
1
1
  import { ServiceGeneratorContext } from '../index';
2
- export declare const importTemplate = "import { MongoDBService } from '@feathersjs/mongodb'\nimport type { MongoDBAdapterParams } from '@feathersjs/mongodb'";
3
- export declare const classCode: ({ className, upperName }: ServiceGeneratorContext) => string;
2
+ export declare const template: ({ className, upperName, schema, fileName, kebabPath, relative }: ServiceGeneratorContext) => string;
4
3
  export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -1,35 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = exports.classCode = exports.importTemplate = void 0;
3
+ exports.generate = exports.template = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- exports.importTemplate = `import { MongoDBService } from \'@feathersjs/mongodb\'
7
- import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'`;
8
- const classCode = ({ className, upperName }) => `export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
6
+ const template = ({ className, upperName, schema, fileName, kebabPath, relative }) => /* ts */ `import type { Params } from '@feathersjs/feathers'
7
+ import { MongoDBService } from \'@feathersjs/mongodb\'
8
+ import type { MongoDBAdapterParams, MongoDBAdapterOptions } from \'@feathersjs/mongodb\'
9
+
10
+ import type { Application } from '${relative}/declarations'
11
+ ${schema
12
+ ? `import type {
13
+ ${upperName},
14
+ ${upperName}Data,
15
+ ${upperName}Query
16
+ } from './${fileName}.schema'
17
+ `
18
+ : `
19
+ export type ${upperName} = any
20
+ export type ${upperName}Data = any
21
+ export type ${upperName}Query = any
22
+ `}
23
+
24
+ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
9
25
  }
10
26
 
11
27
  // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
12
- export class ${className} extends MongoDBService<${upperName}Result, ${upperName}Data, ${upperName}Params> {
28
+ export class ${className}<ServiceParams extends Params = ${upperName}Params>
29
+ extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams> {
30
+ }
31
+
32
+ export const getOptions = (app: Application): MongoDBAdapterOptions => {
33
+ return {
34
+ paginate: app.get('paginate'),
35
+ Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}'))
36
+ }
13
37
  }
14
38
  `;
15
- exports.classCode = classCode;
16
- const optionTemplate = ({ kebabName }) => ` paginate: app.get('paginate'),
17
- Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))`;
18
- const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
19
- lib,
20
- 'services',
21
- ...folder,
22
- `${fileName}.service`
23
- ]);
24
- const toClassFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
39
+ exports.template = template;
40
+ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
25
41
  lib,
26
42
  'services',
27
43
  ...folder,
28
44
  `${fileName}.class`
29
- ]);
30
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
31
- .then((0, commons_1.injectSource)(exports.classCode, (0, pinion_1.append)(), toClassFile))
32
- .then((0, commons_1.injectSource)(exports.importTemplate, (0, pinion_1.prepend)(), toClassFile))
33
- .then((0, commons_1.injectSource)(optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile, false));
45
+ ])));
34
46
  exports.generate = generate;
35
47
  //# sourceMappingURL=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,aAAa,EAAE,KAAK,CAAC,CAAC,CAAA;AAJ1E,QAAA,QAAQ,YAIkE"}
1
+ {"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/service/type/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;oCAIJ,QAAQ;EAE1C,MAAM;IACJ,CAAC,CAAC;IACF,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC;cACQ,SAAS;cACT,SAAS;cACT,SAAS;CAEvB;;mBAEmB,SAAS,uCAAuC,SAAS;;;;eAI7D,SAAS,mCAAmC,SAAS;2BACzC,SAAS,KAAK,SAAS;;;;;;gEAMc,SAAS;;;CAGxE,CAAA;AAzCY,QAAA,QAAQ,YAyCpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -1,39 +1,59 @@
1
- import { generator, toFile, after, prepend, append } from '@feathershq/pinion'
2
- import { injectSource } from '../../commons'
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
3
  import { ServiceGeneratorContext } from '../index'
4
4
 
5
- export const importTemplate = `import { MongoDBService } from \'@feathersjs/mongodb\'
6
- import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'`
5
+ export const template = ({
6
+ className,
7
+ upperName,
8
+ schema,
9
+ fileName,
10
+ kebabPath,
11
+ relative
12
+ }: ServiceGeneratorContext) => /* ts */ `import type { Params } from '@feathersjs/feathers'
13
+ import { MongoDBService } from \'@feathersjs/mongodb\'
14
+ import type { MongoDBAdapterParams, MongoDBAdapterOptions } from \'@feathersjs/mongodb\'
7
15
 
8
- export const classCode = ({ className, upperName }: ServiceGeneratorContext) =>
9
- `export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
16
+ import type { Application } from '${relative}/declarations'
17
+ ${
18
+ schema
19
+ ? `import type {
20
+ ${upperName},
21
+ ${upperName}Data,
22
+ ${upperName}Query
23
+ } from './${fileName}.schema'
24
+ `
25
+ : `
26
+ export type ${upperName} = any
27
+ export type ${upperName}Data = any
28
+ export type ${upperName}Query = any
29
+ `
10
30
  }
11
31
 
12
- // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
13
- export class ${className} extends MongoDBService<${upperName}Result, ${upperName}Data, ${upperName}Params> {
32
+ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
14
33
  }
15
- `
16
-
17
- const optionTemplate = ({ kebabName }: ServiceGeneratorContext) =>
18
- ` paginate: app.get('paginate'),
19
- Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))`
20
34
 
21
- const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
22
- lib,
23
- 'services',
24
- ...folder,
25
- `${fileName}.service`
26
- ])
35
+ // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
36
+ export class ${className}<ServiceParams extends Params = ${upperName}Params>
37
+ extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams> {
38
+ }
27
39
 
28
- const toClassFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
29
- lib,
30
- 'services',
31
- ...folder,
32
- `${fileName}.class`
33
- ])
40
+ export const getOptions = (app: Application): MongoDBAdapterOptions => {
41
+ return {
42
+ paginate: app.get('paginate'),
43
+ Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}'))
44
+ }
45
+ }
46
+ `
34
47
 
35
48
  export const generate = (ctx: ServiceGeneratorContext) =>
36
- generator(ctx)
37
- .then(injectSource(classCode, append(), toClassFile))
38
- .then(injectSource(importTemplate, prepend(), toClassFile))
39
- .then(injectSource(optionTemplate, after('const options ='), toServiceFile, false))
49
+ generator(ctx).then(
50
+ renderSource(
51
+ template,
52
+ toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
53
+ lib,
54
+ 'services',
55
+ ...folder,
56
+ `${fileName}.class`
57
+ ])
58
+ )
59
+ )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@feathersjs/cli",
3
3
  "description": "The command line interface for creating Feathers applications",
4
- "version": "5.0.0-pre.29",
4
+ "version": "5.0.0-pre.31",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "main": "lib/",
7
7
  "bin": {
@@ -47,41 +47,42 @@
47
47
  "mocha": "mocha --timeout 60000 --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
48
48
  "test": "npm run compile && npm run mocha"
49
49
  },
50
- "directories": {
51
- "lib": "lib/cli"
52
- },
53
50
  "publishConfig": {
54
51
  "access": "public"
55
52
  },
56
53
  "dependencies": {
57
54
  "@feathershq/pinion": "^0.3.5",
58
55
  "chalk": "^4.0.1",
56
+ "commander": "^9.4.1",
59
57
  "lodash": "^4.17.21",
60
58
  "prettier": "^2.7.1"
61
59
  },
62
60
  "devDependencies": {
63
- "@feathersjs/authentication": "^5.0.0-pre.29",
64
- "@feathersjs/authentication-local": "^5.0.0-pre.29",
65
- "@feathersjs/authentication-oauth": "^5.0.0-pre.29",
66
- "@feathersjs/configuration": "^5.0.0-pre.29",
67
- "@feathersjs/errors": "^5.0.0-pre.29",
68
- "@feathersjs/express": "^5.0.0-pre.29",
69
- "@feathersjs/feathers": "^5.0.0-pre.29",
70
- "@feathersjs/knex": "^5.0.0-pre.29",
71
- "@feathersjs/koa": "^5.0.0-pre.29",
72
- "@feathersjs/mongodb": "^5.0.0-pre.29",
73
- "@feathersjs/schema": "^5.0.0-pre.29",
74
- "@feathersjs/socketio": "^5.0.0-pre.29",
75
- "@feathersjs/transport-commons": "^5.0.0-pre.29",
76
- "@types/mocha": "^9.1.1",
77
- "@types/node": "^18.7.17",
78
- "@types/prettier": "^2.7.0",
61
+ "@feathersjs/authentication": "^5.0.0-pre.31",
62
+ "@feathersjs/authentication-client": "^5.0.0-pre.31",
63
+ "@feathersjs/authentication-local": "^5.0.0-pre.31",
64
+ "@feathersjs/authentication-oauth": "^5.0.0-pre.31",
65
+ "@feathersjs/configuration": "^5.0.0-pre.31",
66
+ "@feathersjs/errors": "^5.0.0-pre.31",
67
+ "@feathersjs/express": "^5.0.0-pre.31",
68
+ "@feathersjs/feathers": "^5.0.0-pre.31",
69
+ "@feathersjs/knex": "^5.0.0-pre.31",
70
+ "@feathersjs/koa": "^5.0.0-pre.31",
71
+ "@feathersjs/mongodb": "^5.0.0-pre.31",
72
+ "@feathersjs/rest-client": "^5.0.0-pre.31",
73
+ "@feathersjs/schema": "^5.0.0-pre.31",
74
+ "@feathersjs/socketio": "^5.0.0-pre.31",
75
+ "@feathersjs/transport-commons": "^5.0.0-pre.31",
76
+ "@feathersjs/typebox": "^5.0.0-pre.31",
77
+ "@types/mocha": "^10.0.0",
78
+ "@types/node": "^18.8.2",
79
+ "@types/prettier": "^2.7.1",
79
80
  "axios": "^0.27.2",
80
81
  "mocha": "^10.0.0",
81
82
  "shx": "^0.3.4",
82
83
  "ts-node": "^10.9.1",
83
- "type-fest": "^2.19.0",
84
- "typescript": "^4.8.3"
84
+ "type-fest": "^3.0.0",
85
+ "typescript": "^4.8.4"
85
86
  },
86
- "gitHead": "4314dc89a41a8bbaabf00b47697bf7887861d17d"
87
+ "gitHead": "4500dbeb8cea566678cf88b3313a88efd93a2ed9"
87
88
  }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const template = ({}) => `import { schema, Ajv } from '@feathersjs/schema'
7
- import type { Infer } from '@feathersjs/schema'
8
- import { authenticationSettingsSchema } from '@feathersjs/authentication'
9
-
10
- export const configurationSchema = schema(
11
- {
12
- $id: 'ApplicationConfiguration',
13
- type: 'object',
14
- additionalProperties: false,
15
- required: [ 'host', 'port', 'public', 'paginate' ],
16
- properties: {
17
- host: { type: 'string' },
18
- port: { type: 'number' },
19
- public: { type: 'string' },
20
- authentication: authenticationSettingsSchema,
21
- origins: {
22
- type: 'array',
23
- items: {
24
- type: 'string'
25
- }
26
- },
27
- paginate: {
28
- type: 'object',
29
- additionalProperties: false,
30
- required: [ 'default', 'max' ],
31
- properties: {
32
- default: { type: 'number' },
33
- max: { type: 'number' }
34
- }
35
- }
36
- }
37
- } as const,
38
- new Ajv()
39
- )
40
-
41
- export type ConfigurationSchema = Infer<typeof configurationSchema>
42
- `;
43
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'configuration')));
44
- exports.generate = generate;
45
- //# sourceMappingURL=configuration.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/configuration.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,CAC/D,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}