@feathersjs/cli 4.6.2 → 5.0.0-pre.24

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 +10 -917
  2. package/LICENSE +1 -1
  3. package/README.md +9 -34
  4. package/bin/feathers +9 -0
  5. package/lib/app/index.d.ts +29 -0
  6. package/lib/app/index.js +123 -0
  7. package/lib/app/index.js.map +1 -0
  8. package/lib/app/index.ts +198 -0
  9. package/lib/app/static/.gitignore +121 -0
  10. package/lib/app/templates/app.test.tpl.d.ts +2 -0
  11. package/lib/app/templates/app.test.tpl.js +48 -0
  12. package/lib/app/templates/app.test.tpl.js.map +1 -0
  13. package/lib/app/templates/app.test.tpl.ts +48 -0
  14. package/lib/app/templates/app.tpl.d.ts +2 -0
  15. package/lib/app/templates/app.tpl.js +110 -0
  16. package/lib/app/templates/app.tpl.js.map +1 -0
  17. package/lib/app/templates/app.tpl.ts +119 -0
  18. package/lib/app/templates/channels.tpl.d.ts +2 -0
  19. package/lib/app/templates/channels.tpl.js +76 -0
  20. package/lib/app/templates/channels.tpl.js.map +1 -0
  21. package/lib/app/templates/channels.tpl.ts +81 -0
  22. package/lib/app/templates/client.tpl.d.ts +2 -0
  23. package/lib/app/templates/client.tpl.js +22 -0
  24. package/lib/app/templates/client.tpl.js.map +1 -0
  25. package/lib/app/templates/client.tpl.ts +27 -0
  26. package/lib/app/templates/config.tpl.d.ts +2 -0
  27. package/lib/app/templates/config.tpl.js +21 -0
  28. package/lib/app/templates/config.tpl.js.map +1 -0
  29. package/lib/app/templates/config.tpl.ts +21 -0
  30. package/lib/app/templates/configuration.tpl.d.ts +2 -0
  31. package/lib/app/templates/configuration.tpl.js +36 -0
  32. package/lib/app/templates/configuration.tpl.js.map +1 -0
  33. package/lib/app/templates/configuration.tpl.ts +41 -0
  34. package/lib/app/templates/declarations.tpl.d.ts +2 -0
  35. package/lib/app/templates/declarations.tpl.js +23 -0
  36. package/lib/app/templates/declarations.tpl.js.map +1 -0
  37. package/lib/app/templates/declarations.tpl.ts +31 -0
  38. package/lib/app/templates/index.html.tpl.d.ts +2 -0
  39. package/lib/app/templates/index.html.tpl.js +85 -0
  40. package/lib/app/templates/index.html.tpl.js.map +1 -0
  41. package/lib/app/templates/index.html.tpl.ts +85 -0
  42. package/lib/app/templates/index.tpl.d.ts +2 -0
  43. package/lib/app/templates/index.tpl.js +18 -0
  44. package/lib/app/templates/index.tpl.js.map +1 -0
  45. package/lib/app/templates/index.tpl.ts +23 -0
  46. package/lib/app/templates/logger.tpl.d.ts +2 -0
  47. package/lib/app/templates/logger.tpl.js +33 -0
  48. package/lib/app/templates/logger.tpl.js.map +1 -0
  49. package/lib/app/templates/logger.tpl.ts +38 -0
  50. package/lib/app/templates/package.json.tpl.d.ts +2 -0
  51. package/lib/app/templates/package.json.tpl.js +53 -0
  52. package/lib/app/templates/package.json.tpl.js.map +1 -0
  53. package/lib/app/templates/package.json.tpl.ts +65 -0
  54. package/lib/app/templates/readme.md.tpl.d.ts +2 -0
  55. package/lib/app/templates/readme.md.tpl.js +50 -0
  56. package/lib/app/templates/readme.md.tpl.js.map +1 -0
  57. package/lib/app/templates/readme.md.tpl.ts +50 -0
  58. package/lib/app/templates/services.tpl.d.ts +2 -0
  59. package/lib/app/templates/services.tpl.js +14 -0
  60. package/lib/app/templates/services.tpl.js.map +1 -0
  61. package/lib/app/templates/services.tpl.ts +19 -0
  62. package/lib/app/templates/tsconfig.json.tpl.d.ts +2 -0
  63. package/lib/app/templates/tsconfig.json.tpl.js +20 -0
  64. package/lib/app/templates/tsconfig.json.tpl.js.map +1 -0
  65. package/lib/app/templates/tsconfig.json.tpl.ts +26 -0
  66. package/lib/authentication/index.d.ts +71 -0
  67. package/lib/authentication/index.js +94 -0
  68. package/lib/authentication/index.js.map +1 -0
  69. package/lib/authentication/index.ts +103 -0
  70. package/lib/authentication/templates/authentication.tpl.d.ts +2 -0
  71. package/lib/authentication/templates/authentication.tpl.js +40 -0
  72. package/lib/authentication/templates/authentication.tpl.js.map +1 -0
  73. package/lib/authentication/templates/authentication.tpl.ts +53 -0
  74. package/lib/authentication/templates/config.tpl.d.ts +2 -0
  75. package/lib/authentication/templates/config.tpl.js +46 -0
  76. package/lib/authentication/templates/config.tpl.js.map +1 -0
  77. package/lib/authentication/templates/config.tpl.ts +51 -0
  78. package/lib/authentication/templates/declarations.tpl.d.ts +2 -0
  79. package/lib/authentication/templates/declarations.tpl.js +19 -0
  80. package/lib/authentication/templates/declarations.tpl.js.map +1 -0
  81. package/lib/authentication/templates/declarations.tpl.ts +29 -0
  82. package/lib/authentication/templates/knex.tpl.d.ts +2 -0
  83. package/lib/authentication/templates/knex.tpl.js +41 -0
  84. package/lib/authentication/templates/knex.tpl.js.map +1 -0
  85. package/lib/authentication/templates/knex.tpl.ts +59 -0
  86. package/lib/authentication/templates/test.tpl.d.ts +2 -0
  87. package/lib/authentication/templates/test.tpl.js +43 -0
  88. package/lib/authentication/templates/test.tpl.js.map +1 -0
  89. package/lib/authentication/templates/test.tpl.ts +50 -0
  90. package/lib/authentication/templates/user.resolver.tpl.d.ts +2 -0
  91. package/lib/authentication/templates/user.resolver.tpl.js +96 -0
  92. package/lib/authentication/templates/user.resolver.tpl.js.map +1 -0
  93. package/lib/authentication/templates/user.resolver.tpl.ts +109 -0
  94. package/lib/authentication/templates/user.schema.tpl.d.ts +2 -0
  95. package/lib/authentication/templates/user.schema.tpl.js +85 -0
  96. package/lib/authentication/templates/user.schema.tpl.js.map +1 -0
  97. package/lib/authentication/templates/user.schema.tpl.ts +93 -0
  98. package/lib/commons.d.ts +120 -0
  99. package/lib/commons.js +137 -0
  100. package/lib/commons.js.map +1 -0
  101. package/lib/commons.ts +187 -0
  102. package/lib/connection/index.d.ts +53 -0
  103. package/lib/connection/index.js +86 -0
  104. package/lib/connection/index.js.map +1 -0
  105. package/lib/connection/index.ts +109 -0
  106. package/lib/connection/templates/knex.tpl.d.ts +2 -0
  107. package/lib/connection/templates/knex.tpl.js +59 -0
  108. package/lib/connection/templates/knex.tpl.js.map +1 -0
  109. package/lib/connection/templates/knex.tpl.ts +79 -0
  110. package/lib/connection/templates/mongodb.tpl.d.ts +2 -0
  111. package/lib/connection/templates/mongodb.tpl.js +39 -0
  112. package/lib/connection/templates/mongodb.tpl.js.map +1 -0
  113. package/lib/connection/templates/mongodb.tpl.ts +51 -0
  114. package/lib/hook/index.d.ts +22 -0
  115. package/lib/hook/index.js +40 -0
  116. package/lib/hook/index.js.map +1 -0
  117. package/lib/hook/index.ts +45 -0
  118. package/lib/hook/templates/hook.tpl.d.ts +2 -0
  119. package/lib/hook/templates/hook.tpl.js +21 -0
  120. package/lib/hook/templates/hook.tpl.js.map +1 -0
  121. package/lib/hook/templates/hook.tpl.ts +28 -0
  122. package/lib/index.d.ts +16 -0
  123. package/lib/index.js +24 -62
  124. package/lib/index.js.map +1 -0
  125. package/lib/index.ts +27 -0
  126. package/lib/service/index.d.ts +130 -0
  127. package/lib/service/index.js +84 -0
  128. package/lib/service/index.js.map +1 -0
  129. package/lib/service/index.ts +150 -0
  130. package/lib/service/templates/client.tpl.d.ts +2 -0
  131. package/lib/service/templates/client.tpl.js +16 -0
  132. package/lib/service/templates/client.tpl.js.map +1 -0
  133. package/lib/service/templates/client.tpl.ts +27 -0
  134. package/lib/service/templates/resolver.tpl.d.ts +2 -0
  135. package/lib/service/templates/resolver.tpl.js +73 -0
  136. package/lib/service/templates/resolver.tpl.js.map +1 -0
  137. package/lib/service/templates/resolver.tpl.ts +78 -0
  138. package/lib/service/templates/schema.tpl.d.ts +2 -0
  139. package/lib/service/templates/schema.tpl.js +75 -0
  140. package/lib/service/templates/schema.tpl.js.map +1 -0
  141. package/lib/service/templates/schema.tpl.ts +80 -0
  142. package/lib/service/templates/service.tpl.d.ts +2 -0
  143. package/lib/service/templates/service.tpl.js +92 -0
  144. package/lib/service/templates/service.tpl.js.map +1 -0
  145. package/lib/service/templates/service.tpl.ts +117 -0
  146. package/lib/service/templates/test.tpl.d.ts +2 -0
  147. package/lib/service/templates/test.tpl.js +24 -0
  148. package/lib/service/templates/test.tpl.js.map +1 -0
  149. package/lib/service/templates/test.tpl.ts +29 -0
  150. package/lib/service/type/custom.tpl.d.ts +4 -0
  151. package/lib/service/type/custom.tpl.js +79 -0
  152. package/lib/service/type/custom.tpl.js.map +1 -0
  153. package/lib/service/type/custom.tpl.ts +81 -0
  154. package/lib/service/type/knex.tpl.d.ts +5 -0
  155. package/lib/service/type/knex.tpl.js +50 -0
  156. package/lib/service/type/knex.tpl.js.map +1 -0
  157. package/lib/service/type/knex.tpl.ts +62 -0
  158. package/lib/service/type/mongodb.tpl.d.ts +4 -0
  159. package/lib/service/type/mongodb.tpl.js +29 -0
  160. package/lib/service/type/mongodb.tpl.js.map +1 -0
  161. package/lib/service/type/mongodb.tpl.ts +34 -0
  162. package/package.json +56 -36
  163. package/bin/feathers.js +0 -5
@@ -0,0 +1,92 @@
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 = ({ relative, path, className, schemaPath, resolverPath, camelName, upperName, isEntityService, authentication }) => `import { resolveAll } from '@feathersjs/schema'
7
+ ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
8
+ import type { Application } from '${relative}/declarations'
9
+ import type {
10
+ ${upperName}Data,
11
+ ${upperName}Result,
12
+ ${upperName}Query,
13
+ } from '${relative}/${schemaPath}'
14
+ import { ${camelName}Resolvers } from '${relative}/${resolverPath}'
15
+
16
+ export const hooks = {
17
+ around: {
18
+ all: [${authentication
19
+ ? `
20
+ authenticate('jwt'),`
21
+ : ''} ${!isEntityService
22
+ ? `
23
+ resolveAll(${camelName}Resolvers)`
24
+ : ''}
25
+ ]${isEntityService
26
+ ? `,
27
+ get: [
28
+ authenticate('jwt'),
29
+ resolveAll(${camelName}Resolvers)
30
+ ],
31
+ find: [
32
+ authenticate('jwt'),
33
+ resolveAll(${camelName}Resolvers)
34
+ ],
35
+ create: [
36
+ resolveAll(${camelName}Resolvers)
37
+ ],
38
+ patch: [
39
+ authenticate('jwt'),
40
+ resolveAll(${camelName}Resolvers)
41
+ ],
42
+ update: [
43
+ authenticate('jwt'),
44
+ resolveAll(${camelName}Resolvers)
45
+ ],
46
+ remove: [
47
+ authenticate('jwt'),
48
+ resolveAll(${camelName}Resolvers)
49
+ ]`
50
+ : ''}
51
+ },
52
+ before: {},
53
+ after: {},
54
+ error: {}
55
+ }
56
+
57
+ // A configure function that registers the service and its hooks via \`app.configure\`
58
+ export function ${camelName} (app: Application) {
59
+ const options = { // Service options will go here
60
+ }
61
+
62
+ // Register our service on the Feathers application
63
+ app.use('${path}', new ${className}(options), {
64
+ // A list of all methods this service exposes externally
65
+ methods: ['find', 'get', 'create', 'update', 'patch', 'remove'],
66
+ // You can add additional custom events to be sent to clients here
67
+ events: []
68
+ })
69
+ // Initialize hooks
70
+ app.service('${path}').hooks(hooks)
71
+ }
72
+
73
+ // Add this service to the service type index
74
+ declare module '${relative}/declarations' {
75
+ interface ServiceTypes {
76
+ '${path}': ${className}
77
+ }
78
+ }
79
+ `;
80
+ const importTemplate = ({ camelName, path }) => `import { ${camelName} } from './${path}'`;
81
+ const configureTemplate = ({ camelName }) => ` app.configure(${camelName})`;
82
+ const toServiceIndex = (0, pinion_1.toFile)(({ lib, language }) => [
83
+ lib,
84
+ 'services',
85
+ `index.${language}`
86
+ ]);
87
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
88
+ .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [lib, 'services', ...folder, fileName])))
89
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(importTemplate), (0, pinion_1.prepend)(), toServiceIndex))
90
+ .then((0, pinion_1.inject)(configureTemplate, (0, pinion_1.after)('export const services'), toServiceIndex));
91
+ exports.generate = generate;
92
+ //# sourceMappingURL=service.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/service.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,2CAAuD;AAGvD,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,eAAe,EACf,cAAc,EACU,EAAE,EAAE,CAC5B;EACA,eAAe,IAAI,cAAc,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;oCAClE,QAAQ;;IAExC,SAAS;IACT,SAAS;IACT,SAAS;UACH,QAAQ,IAAI,UAAU;WACrB,SAAS,qBAAqB,QAAQ,IAAI,YAAY;;;;YAK3D,cAAc;IACZ,CAAC,CAAC;2BACiB;IACnB,CAAC,CAAC,EACN,IACA,CAAC,eAAe;IACd,CAAC,CAAC;mBACW,SAAS,YAAY;IAClC,CAAC,CAAC,EACN;OAEI,eAAe;IACb,CAAC,CAAC;;;mBAGS,SAAS;;;;mBAIT,SAAS;;;mBAGT,SAAS;;;;mBAIT,SAAS;;;;mBAIT,SAAS;;;;mBAIT,SAAS;MACtB;IACE,CAAC,CAAC,EACN;;;;;;;;kBAQc,SAAS;;;;;aAKd,IAAI,UAAU,SAAS;;;;;;;iBAOnB,IAAI;;;;kBAIH,QAAQ;;OAEnB,IAAI,MAAM,SAAS;;;CAGzB,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAA2B,EAAE,EAAE,CACtE,YAAY,SAAS,cAAc,IAAI,GAAG,CAAA;AAE5C,MAAM,iBAAiB,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAAC,mBAAmB,SAAS,GAAG,CAAA;AAErG,MAAM,cAAc,GAAG,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAC5E,GAAG;IACH,UAAU;IACV,SAAS,QAAQ,EAAE;CACpB,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CACvG,CACF;KACA,IAAI,CAAC,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,cAAc,CAAC,EAAE,IAAA,gBAAO,GAAE,EAAE,cAAc,CAAC,CAAC;KAClE,IAAI,CAAC,IAAA,eAAM,EAAC,iBAAiB,EAAE,IAAA,cAAK,EAAC,uBAAuB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;AATvE,QAAA,QAAQ,YAS+D"}
@@ -0,0 +1,117 @@
1
+ import { generator, inject, prepend, toFile, after } from '@feathershq/pinion'
2
+ import { getSource, renderSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../index'
4
+
5
+ const template = ({
6
+ relative,
7
+ path,
8
+ className,
9
+ schemaPath,
10
+ resolverPath,
11
+ camelName,
12
+ upperName,
13
+ isEntityService,
14
+ authentication
15
+ }: ServiceGeneratorContext) =>
16
+ `import { resolveAll } from '@feathersjs/schema'
17
+ ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
18
+ import type { Application } from '${relative}/declarations'
19
+ import type {
20
+ ${upperName}Data,
21
+ ${upperName}Result,
22
+ ${upperName}Query,
23
+ } from '${relative}/${schemaPath}'
24
+ import { ${camelName}Resolvers } from '${relative}/${resolverPath}'
25
+
26
+ export const hooks = {
27
+ around: {
28
+ all: [${
29
+ authentication
30
+ ? `
31
+ authenticate('jwt'),`
32
+ : ''
33
+ } ${
34
+ !isEntityService
35
+ ? `
36
+ resolveAll(${camelName}Resolvers)`
37
+ : ''
38
+ }
39
+ ]${
40
+ isEntityService
41
+ ? `,
42
+ get: [
43
+ authenticate('jwt'),
44
+ resolveAll(${camelName}Resolvers)
45
+ ],
46
+ find: [
47
+ authenticate('jwt'),
48
+ resolveAll(${camelName}Resolvers)
49
+ ],
50
+ create: [
51
+ resolveAll(${camelName}Resolvers)
52
+ ],
53
+ patch: [
54
+ authenticate('jwt'),
55
+ resolveAll(${camelName}Resolvers)
56
+ ],
57
+ update: [
58
+ authenticate('jwt'),
59
+ resolveAll(${camelName}Resolvers)
60
+ ],
61
+ remove: [
62
+ authenticate('jwt'),
63
+ resolveAll(${camelName}Resolvers)
64
+ ]`
65
+ : ''
66
+ }
67
+ },
68
+ before: {},
69
+ after: {},
70
+ error: {}
71
+ }
72
+
73
+ // A configure function that registers the service and its hooks via \`app.configure\`
74
+ export function ${camelName} (app: Application) {
75
+ const options = { // Service options will go here
76
+ }
77
+
78
+ // Register our service on the Feathers application
79
+ app.use('${path}', new ${className}(options), {
80
+ // A list of all methods this service exposes externally
81
+ methods: ['find', 'get', 'create', 'update', 'patch', 'remove'],
82
+ // You can add additional custom events to be sent to clients here
83
+ events: []
84
+ })
85
+ // Initialize hooks
86
+ app.service('${path}').hooks(hooks)
87
+ }
88
+
89
+ // Add this service to the service type index
90
+ declare module '${relative}/declarations' {
91
+ interface ServiceTypes {
92
+ '${path}': ${className}
93
+ }
94
+ }
95
+ `
96
+
97
+ const importTemplate = ({ camelName, path }: ServiceGeneratorContext) =>
98
+ `import { ${camelName} } from './${path}'`
99
+
100
+ const configureTemplate = ({ camelName }: ServiceGeneratorContext) => ` app.configure(${camelName})`
101
+
102
+ const toServiceIndex = toFile(({ lib, language }: ServiceGeneratorContext) => [
103
+ lib,
104
+ 'services',
105
+ `index.${language}`
106
+ ])
107
+
108
+ export const generate = (ctx: ServiceGeneratorContext) =>
109
+ generator(ctx)
110
+ .then(
111
+ renderSource(
112
+ template,
113
+ toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [lib, 'services', ...folder, fileName])
114
+ )
115
+ )
116
+ .then(inject(getSource(importTemplate), prepend(), toServiceIndex))
117
+ .then(inject(configureTemplate, after('export const services'), toServiceIndex))
@@ -0,0 +1,2 @@
1
+ import { ServiceGeneratorContext } from '../index';
2
+ export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -0,0 +1,24 @@
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 = ({ relative, lib, path, name }) => `import assert from 'assert'
7
+ import { app } from '../${relative}/${lib}/app'
8
+
9
+ describe('${name} service', () => {
10
+ it('registered the service', () => {
11
+ const service = app.service('${path}')
12
+
13
+ assert.ok(service, 'Registered the service')
14
+ })
15
+ })
16
+ `;
17
+ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test, folder, kebabName }) => [
18
+ test,
19
+ 'services',
20
+ ...folder,
21
+ `${kebabName}.test`
22
+ ])));
23
+ exports.generate = generate;
24
+ //# sourceMappingURL=test.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAA2B,EAAE,EAAE,CAC1E;0BACwB,QAAQ,IAAI,GAAG;;YAE7B,IAAI;;mCAEmB,IAAI;;;;;CAKtC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC/D,IAAI;IACJ,UAAU;IACV,GAAG,MAAM;IACT,GAAG,SAAS,OAAO;CACpB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -0,0 +1,29 @@
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../index'
4
+
5
+ const template = ({ relative, lib, path, name }: ServiceGeneratorContext) =>
6
+ `import assert from 'assert'
7
+ import { app } from '../${relative}/${lib}/app'
8
+
9
+ describe('${name} service', () => {
10
+ it('registered the service', () => {
11
+ const service = app.service('${path}')
12
+
13
+ assert.ok(service, 'Registered the service')
14
+ })
15
+ })
16
+ `
17
+
18
+ export const generate = (ctx: ServiceGeneratorContext) =>
19
+ generator(ctx).then(
20
+ renderSource(
21
+ template,
22
+ toFile<ServiceGeneratorContext>(({ test, folder, kebabName }) => [
23
+ test,
24
+ 'services',
25
+ ...folder,
26
+ `${kebabName}.test`
27
+ ])
28
+ )
29
+ )
@@ -0,0 +1,4 @@
1
+ import { ServiceGeneratorContext } from '../index';
2
+ export declare const template: ({ className, upperName }: ServiceGeneratorContext) => string;
3
+ export declare const importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'";
4
+ export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = exports.importTemplate = exports.template = void 0;
4
+ const pinion_1 = require("@feathershq/pinion");
5
+ const commons_1 = require("../../commons");
6
+ const template = ({ className, upperName }) => `export interface ${className}Options {
7
+ app: Application
8
+ }
9
+
10
+ export interface ${upperName}Params extends Params<${upperName}Query> {
11
+
12
+ }
13
+
14
+ // This is a skeleton for a custom service class. Remove or add the methods you need here
15
+ export class ${className} {
16
+ constructor (public options: ${className}Options) {
17
+ }
18
+
19
+ async find (_params?: ${upperName}Params): Promise<${upperName}Result[]> {
20
+ return []
21
+ }
22
+
23
+ async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}Result> {
24
+ return {
25
+ id: \`\${id}\`,
26
+ text: \`A new message with ID: \${id}!\`
27
+ };
28
+ }
29
+
30
+ async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}Result>
31
+ async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}Result[]>
32
+ async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}Result|${upperName}Result[]> {
33
+ if (Array.isArray(data)) {
34
+ return Promise.all(data.map(current => this.create(current, params)));
35
+ }
36
+
37
+ return {
38
+ id: 'created',
39
+ ...data
40
+ };
41
+ }
42
+
43
+ async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
44
+ return {
45
+ id: \`\${id}\`,
46
+ ...data
47
+ };
48
+ }
49
+
50
+ async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
51
+ return {
52
+ id: \`\${id}\`,
53
+ ...data
54
+ };
55
+ }
56
+
57
+ async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}Result> {
58
+ return {
59
+ id: \`\${id}\`,
60
+ text: 'removed'
61
+ };
62
+ }
63
+ }
64
+ `;
65
+ exports.template = template;
66
+ exports.importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'";
67
+ const optionTemplate = ({}) => ` app`;
68
+ const toServiceFile = (0, pinion_1.toFile)(({ lib, language, folder, fileName }) => [
69
+ lib,
70
+ 'services',
71
+ ...folder,
72
+ `${fileName}.${language}`
73
+ ]);
74
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
75
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(exports.template), (0, pinion_1.before)('export const hooks ='), toServiceFile))
76
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(exports.importTemplate), (0, pinion_1.prepend)(), toServiceFile))
77
+ .then((0, pinion_1.inject)(optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile));
78
+ exports.generate = generate;
79
+ //# sourceMappingURL=custom.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.tpl.js","sourceRoot":"","sources":["../../../src/service/type/custom.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsF;AACtF,2CAAyC;AAGlC,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC5E,oBAAoB,SAAS;;;;mBAIZ,SAAS,yBAAyB,SAAS;;;;;eAK/C,SAAS;iCACS,SAAS;;;0BAGhB,SAAS,oBAAoB,SAAS;;;;iCAI/B,SAAS,oBAAoB,SAAS;;;;;;;wBAO/C,SAAS,kBAAkB,SAAS,oBAAoB,SAAS;wBACjE,SAAS,oBAAoB,SAAS,oBAAoB,SAAS;wBACnE,SAAS,QAAQ,SAAS,oBAAoB,SAAS,oBAAoB,SAAS,UAAU,SAAS;;;;;;;;;;;wCAWvF,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;uCAOnE,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;4CAO7D,SAAS,oBAAoB,SAAS;;;;;;;CAOjF,CAAA;AA3DY,QAAA,QAAQ,YA2DpB;AAEY,QAAA,cAAc,GAAG,oEAAoE,CAAA;AAElG,MAAM,cAAc,GAAG,CAAC,EAA2B,EAAE,EAAE,CAAC,SAAS,CAAA;AAEjE,MAAM,aAAa,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7F,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,IAAI,QAAQ,EAAE;CAC1B,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,gBAAQ,CAAC,EAAE,IAAA,eAAM,EAA0B,sBAAsB,CAAC,EAAE,aAAa,CAAC,CAAC;KACzG,IAAI,CAAC,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,sBAAc,CAAC,EAAE,IAAA,gBAAO,GAAE,EAAE,aAAa,CAAC,CAAC;KACjE,IAAI,CAAC,IAAA,eAAM,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC,CAAC,CAAA;AAJ7D,QAAA,QAAQ,YAIqD"}
@@ -0,0 +1,81 @@
1
+ import { generator, inject, toFile, after, before, prepend } from '@feathershq/pinion'
2
+ import { getSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../index'
4
+
5
+ export const template = ({ className, upperName }: ServiceGeneratorContext) =>
6
+ `export interface ${className}Options {
7
+ app: Application
8
+ }
9
+
10
+ export interface ${upperName}Params extends Params<${upperName}Query> {
11
+
12
+ }
13
+
14
+ // This is a skeleton for a custom service class. Remove or add the methods you need here
15
+ export class ${className} {
16
+ constructor (public options: ${className}Options) {
17
+ }
18
+
19
+ async find (_params?: ${upperName}Params): Promise<${upperName}Result[]> {
20
+ return []
21
+ }
22
+
23
+ async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}Result> {
24
+ return {
25
+ id: \`\${id}\`,
26
+ text: \`A new message with ID: \${id}!\`
27
+ };
28
+ }
29
+
30
+ async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}Result>
31
+ async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}Result[]>
32
+ async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}Result|${upperName}Result[]> {
33
+ if (Array.isArray(data)) {
34
+ return Promise.all(data.map(current => this.create(current, params)));
35
+ }
36
+
37
+ return {
38
+ id: 'created',
39
+ ...data
40
+ };
41
+ }
42
+
43
+ async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
44
+ return {
45
+ id: \`\${id}\`,
46
+ ...data
47
+ };
48
+ }
49
+
50
+ async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
51
+ return {
52
+ id: \`\${id}\`,
53
+ ...data
54
+ };
55
+ }
56
+
57
+ async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}Result> {
58
+ return {
59
+ id: \`\${id}\`,
60
+ text: 'removed'
61
+ };
62
+ }
63
+ }
64
+ `
65
+
66
+ export const importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'"
67
+
68
+ const optionTemplate = ({}: ServiceGeneratorContext) => ` app`
69
+
70
+ const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, language, folder, fileName }) => [
71
+ lib,
72
+ 'services',
73
+ ...folder,
74
+ `${fileName}.${language}`
75
+ ])
76
+
77
+ export const generate = (ctx: ServiceGeneratorContext) =>
78
+ generator(ctx)
79
+ .then(inject(getSource(template), before<ServiceGeneratorContext>('export const hooks ='), toServiceFile))
80
+ .then(inject(getSource(importTemplate), prepend(), toServiceFile))
81
+ .then(inject(optionTemplate, after('const options ='), toServiceFile))
@@ -0,0 +1,5 @@
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;
5
+ export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = exports.optionTemplate = exports.classCode = exports.importTemplate = void 0;
4
+ const pinion_1 = require("@feathershq/pinion");
5
+ const commons_1 = require("../../commons");
6
+ const migrationTemplate = ({ kebabName }) => `import type { Knex } from 'knex'
7
+
8
+ export async function up(knex: Knex): Promise<void> {
9
+ await knex.schema.createTable('${kebabName}', table => {
10
+ table.increments('id')
11
+ table.string('text')
12
+ })
13
+ }
14
+
15
+ export async function down(knex: Knex): Promise<void> {
16
+ await knex.schema.dropTable('${kebabName}')
17
+ }
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> {
22
+ }
23
+
24
+ // 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> {
26
+ }
27
+ `;
28
+ exports.classCode = classCode;
29
+ const optionTemplate = ({ kebabName, feathers }) => ` paginate: app.get('paginate'),
30
+ Model: app.get('${feathers.database}Client'),
31
+ name: '${kebabName}'`;
32
+ exports.optionTemplate = optionTemplate;
33
+ const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName, language }) => [
34
+ lib,
35
+ 'services',
36
+ ...folder,
37
+ `${fileName}.${language}`
38
+ ]);
39
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
40
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(exports.classCode), (0, pinion_1.before)('export const hooks ='), toServiceFile))
41
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(exports.importTemplate), (0, pinion_1.prepend)(), toServiceFile))
42
+ .then((0, pinion_1.inject)(exports.optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile))
43
+ .then((0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)('migrations', ({ kebabName }) => {
44
+ const now = new Date();
45
+ const migrationDate = `${now.getUTCFullYear()}${now.getUTCMonth()}${now.getUTCDay()}` +
46
+ `${now.getUTCHours()}${now.getUTCMinutes()}${now.getUTCSeconds()}`;
47
+ return `${migrationDate}_${kebabName}`;
48
+ })));
49
+ exports.generate = generate;
50
+ //# sourceMappingURL=knex.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsF;AACtF,2CAAuD;AAGvD,MAAM,iBAAiB,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAAC;;;mCAGnC,SAAS;;;;;;;iCAOX,SAAS;;CAEzC,CAAA;AAEY,QAAA,cAAc,GAAG;4DAC8B,CAAA;AAErD,MAAM,SAAS,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC7E,oBAAoB,SAAS,oCAAoC,SAAS;;;;eAI7D,SAAS,wBAAwB,SAAS,WAAW,SAAS,SAAS,SAAS;;CAE9F,CAAA;AAPY,QAAA,SAAS,aAOrB;AAEM,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAA2B,EAAE,EAAE,CACjF;sBACoB,QAAQ,CAAC,QAAQ;aAC1B,SAAS,GAAG,CAAA;AAHZ,QAAA,cAAc,kBAGF;AAEzB,MAAM,aAAa,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7F,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,IAAI,QAAQ,EAAE;CAC1B,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,iBAAS,CAAC,EAAE,IAAA,eAAM,EAA0B,sBAAsB,CAAC,EAAE,aAAa,CAAC,CACrG;KACA,IAAI,CAAC,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,sBAAc,CAAC,EAAE,IAAA,gBAAO,GAAE,EAAE,aAAa,CAAC,CAAC;KACjE,IAAI,CAAC,IAAA,eAAM,EAAC,sBAAc,EAAE,IAAA,cAAK,EAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC,CAAC;KACrE,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAA0B,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC9D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,MAAM,aAAa,GACjB,GAAG,GAAG,CAAC,cAAc,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,EAAE,EAAE;QAC/D,GAAG,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,GAAG,CAAC,aAAa,EAAE,EAAE,CAAA;IAEpE,OAAO,GAAG,aAAa,IAAI,SAAS,EAAE,CAAA;AACxC,CAAC,CAAC,CACH,CACF,CAAA;AAnBQ,QAAA,QAAQ,YAmBhB"}
@@ -0,0 +1,62 @@
1
+ import { generator, inject, toFile, before, after, prepend } from '@feathershq/pinion'
2
+ import { getSource, renderSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../index'
4
+
5
+ const migrationTemplate = ({ kebabName }: ServiceGeneratorContext) => `import type { Knex } from 'knex'
6
+
7
+ export async function up(knex: Knex): Promise<void> {
8
+ await knex.schema.createTable('${kebabName}', table => {
9
+ table.increments('id')
10
+ table.string('text')
11
+ })
12
+ }
13
+
14
+ export async function down(knex: Knex): Promise<void> {
15
+ await knex.schema.dropTable('${kebabName}')
16
+ }
17
+ `
18
+
19
+ export const importTemplate = `import { KnexService } from \'@feathersjs/knex\'
20
+ import type { KnexAdapterParams } from \'@feathersjs/knex\'`
21
+
22
+ export const classCode = ({ className, upperName }: ServiceGeneratorContext) =>
23
+ `export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
24
+ }
25
+
26
+ // 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> {
28
+ }
29
+ `
30
+
31
+ export const optionTemplate = ({ kebabName, feathers }: ServiceGeneratorContext) =>
32
+ ` paginate: app.get('paginate'),
33
+ Model: app.get('${feathers.database}Client'),
34
+ name: '${kebabName}'`
35
+
36
+ const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName, language }) => [
37
+ lib,
38
+ 'services',
39
+ ...folder,
40
+ `${fileName}.${language}`
41
+ ])
42
+
43
+ export const generate = (ctx: ServiceGeneratorContext) =>
44
+ generator(ctx)
45
+ .then(
46
+ inject(getSource(classCode), before<ServiceGeneratorContext>('export const hooks ='), toServiceFile)
47
+ )
48
+ .then(inject(getSource(importTemplate), prepend(), toServiceFile))
49
+ .then(inject(optionTemplate, after('const options ='), toServiceFile))
50
+ .then(
51
+ renderSource(
52
+ migrationTemplate,
53
+ toFile<ServiceGeneratorContext>('migrations', ({ kebabName }) => {
54
+ const now = new Date()
55
+ const migrationDate =
56
+ `${now.getUTCFullYear()}${now.getUTCMonth()}${now.getUTCDay()}` +
57
+ `${now.getUTCHours()}${now.getUTCMinutes()}${now.getUTCSeconds()}`
58
+
59
+ return `${migrationDate}_${kebabName}`
60
+ })
61
+ )
62
+ )
@@ -0,0 +1,4 @@
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;
4
+ export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = exports.classCode = exports.importTemplate = void 0;
4
+ const pinion_1 = require("@feathershq/pinion");
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> {
9
+ }
10
+
11
+ // 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> {
13
+ }
14
+ `;
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, language }) => [
19
+ lib,
20
+ 'services',
21
+ ...folder,
22
+ `${fileName}.${language}`
23
+ ]);
24
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
25
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(exports.classCode), (0, pinion_1.before)('export const hooks ='), toServiceFile))
26
+ .then((0, pinion_1.inject)((0, commons_1.getSource)(exports.importTemplate), (0, pinion_1.prepend)(), toServiceFile))
27
+ .then((0, pinion_1.inject)(optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile));
28
+ exports.generate = generate;
29
+ //# sourceMappingURL=mongodb.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/service/type/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsF;AACtF,2CAAyC;AAG5B,QAAA,cAAc,GAAG;kEACoC,CAAA;AAE3D,MAAM,SAAS,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC7E,oBAAoB,SAAS,uCAAuC,SAAS;;;;eAIhE,SAAS,2BAA2B,SAAS,WAAW,SAAS,SAAS,SAAS;;CAEjG,CAAA;AAPY,QAAA,SAAS,aAOrB;AAED,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAChE;gEAC8D,SAAS,KAAK,CAAA;AAE9E,MAAM,aAAa,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7F,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,IAAI,QAAQ,EAAE;CAC1B,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,iBAAS,CAAC,EAAE,IAAA,eAAM,EAA0B,sBAAsB,CAAC,EAAE,aAAa,CAAC,CACrG;KACA,IAAI,CAAC,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,sBAAc,CAAC,EAAE,IAAA,gBAAO,GAAE,EAAE,aAAa,CAAC,CAAC;KACjE,IAAI,CAAC,IAAA,eAAM,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC,CAAC,CAAA;AAN7D,QAAA,QAAQ,YAMqD"}
@@ -0,0 +1,34 @@
1
+ import { generator, inject, toFile, before, after, prepend } from '@feathershq/pinion'
2
+ import { getSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../index'
4
+
5
+ export const importTemplate = `import { MongoDBService } from \'@feathersjs/mongodb\'
6
+ import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'`
7
+
8
+ export const classCode = ({ className, upperName }: ServiceGeneratorContext) =>
9
+ `export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
10
+ }
11
+
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> {
14
+ }
15
+ `
16
+
17
+ const optionTemplate = ({ kebabName }: ServiceGeneratorContext) =>
18
+ ` paginate: app.get('paginate'),
19
+ Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))`
20
+
21
+ const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName, language }) => [
22
+ lib,
23
+ 'services',
24
+ ...folder,
25
+ `${fileName}.${language}`
26
+ ])
27
+
28
+ export const generate = (ctx: ServiceGeneratorContext) =>
29
+ generator(ctx)
30
+ .then(
31
+ inject(getSource(classCode), before<ServiceGeneratorContext>('export const hooks ='), toServiceFile)
32
+ )
33
+ .then(inject(getSource(importTemplate), prepend(), toServiceFile))
34
+ .then(inject(optionTemplate, after('const options ='), toServiceFile))