@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
@@ -0,0 +1,75 @@
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 validatorTemplate = /* ts */ `import { Ajv, addFormats } from '@feathersjs/schema'
7
+ import type { FormatsPluginOptions } from '@feathersjs/schema'
8
+
9
+ const formats: FormatsPluginOptions = [
10
+ 'date-time',
11
+ 'time',
12
+ 'date',
13
+ 'email',
14
+ 'hostname',
15
+ 'ipv4',
16
+ 'ipv6',
17
+ 'uri',
18
+ 'uri-reference',
19
+ 'uuid',
20
+ 'uri-template',
21
+ 'json-pointer',
22
+ 'relative-json-pointer',
23
+ 'regex'
24
+ ]
25
+
26
+ export const dataValidator = addFormats(new Ajv({}), formats)
27
+
28
+ export const queryValidator = addFormats(new Ajv({
29
+ coerceTypes: true
30
+ }), formats)
31
+ `;
32
+ const configurationJsonTemplate = ({}) => /* ts */ `import { defaultAppSettings, getValidator } from '@feathersjs/schema'
33
+ import type { FromSchema } from '@feathersjs/schema'
34
+
35
+ import { dataValidator } from './validators'
36
+
37
+ export const configurationSchema = {
38
+ type: 'object',
39
+ additionalProperties: false,
40
+ required: [ 'host', 'port', 'public' ],
41
+ properties: {
42
+ ...defaultAppSettings,
43
+ host: { type: 'string' },
44
+ port: { type: 'number' },
45
+ public: { type: 'string' }
46
+ }
47
+ } as const
48
+
49
+ export const configurationValidator = getValidator(configurationSchema, dataValidator)
50
+
51
+ export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
52
+ `;
53
+ const configurationTypeboxTemplate = ({}) => /* ts */ `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'
54
+ import type { Static } from '@feathersjs/typebox'
55
+
56
+ import { dataValidator } from './validators'
57
+
58
+ export const configurationSchema = Type.Intersect([
59
+ defaultAppConfiguration,
60
+ Type.Object({
61
+ host: Type.String(),
62
+ port: Type.Number(),
63
+ public: Type.String()
64
+ })
65
+ ])
66
+
67
+ export type ApplicationConfiguration = Static<typeof configurationSchema>
68
+
69
+ export const configurationValidator = getValidator(configurationSchema, dataValidator)
70
+ `;
71
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
72
+ .then((0, commons_1.renderSource)(async (ctx) => ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx), (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'configuration')))
73
+ .then((0, commons_1.renderSource)(validatorTemplate, (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'validators')));
74
+ exports.generate = generate;
75
+ //# sourceMappingURL=schemas.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/schemas.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlC,CAAA;AAED,MAAM,yBAAyB,GAC7B,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAA;AAED,MAAM,4BAA4B,GAChC,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;CAiBvC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,KAAK,EAAE,GAAG,EAAE,EAAE,CACZ,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,EAC/F,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,CAAC,CAC1E,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,CACvE,CACF,CAAA;AAdQ,QAAA,QAAQ,YAchB"}
@@ -0,0 +1,89 @@
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
+ import { AppGeneratorContext } from '../index'
4
+
5
+ const validatorTemplate = /* ts */ `import { Ajv, addFormats } from '@feathersjs/schema'
6
+ import type { FormatsPluginOptions } from '@feathersjs/schema'
7
+
8
+ const formats: FormatsPluginOptions = [
9
+ 'date-time',
10
+ 'time',
11
+ 'date',
12
+ 'email',
13
+ 'hostname',
14
+ 'ipv4',
15
+ 'ipv6',
16
+ 'uri',
17
+ 'uri-reference',
18
+ 'uuid',
19
+ 'uri-template',
20
+ 'json-pointer',
21
+ 'relative-json-pointer',
22
+ 'regex'
23
+ ]
24
+
25
+ export const dataValidator = addFormats(new Ajv({}), formats)
26
+
27
+ export const queryValidator = addFormats(new Ajv({
28
+ coerceTypes: true
29
+ }), formats)
30
+ `
31
+
32
+ const configurationJsonTemplate =
33
+ ({}: AppGeneratorContext) => /* ts */ `import { defaultAppSettings, getValidator } from '@feathersjs/schema'
34
+ import type { FromSchema } from '@feathersjs/schema'
35
+
36
+ import { dataValidator } from './validators'
37
+
38
+ export const configurationSchema = {
39
+ type: 'object',
40
+ additionalProperties: false,
41
+ required: [ 'host', 'port', 'public' ],
42
+ properties: {
43
+ ...defaultAppSettings,
44
+ host: { type: 'string' },
45
+ port: { type: 'number' },
46
+ public: { type: 'string' }
47
+ }
48
+ } as const
49
+
50
+ export const configurationValidator = getValidator(configurationSchema, dataValidator)
51
+
52
+ export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
53
+ `
54
+
55
+ const configurationTypeboxTemplate =
56
+ ({}: AppGeneratorContext) => /* ts */ `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'
57
+ import type { Static } from '@feathersjs/typebox'
58
+
59
+ import { dataValidator } from './validators'
60
+
61
+ export const configurationSchema = Type.Intersect([
62
+ defaultAppConfiguration,
63
+ Type.Object({
64
+ host: Type.String(),
65
+ port: Type.Number(),
66
+ public: Type.String()
67
+ })
68
+ ])
69
+
70
+ export type ApplicationConfiguration = Static<typeof configurationSchema>
71
+
72
+ export const configurationValidator = getValidator(configurationSchema, dataValidator)
73
+ `
74
+
75
+ export const generate = (ctx: AppGeneratorContext) =>
76
+ generator(ctx)
77
+ .then(
78
+ renderSource(
79
+ async (ctx) =>
80
+ ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx),
81
+ toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'configuration')
82
+ )
83
+ )
84
+ .then(
85
+ renderSource(
86
+ validatorTemplate,
87
+ toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'validators')
88
+ )
89
+ )
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({}) => `import type { Application } from '../declarations'
6
+ const template = ({}) => /* ts */ `import type { Application } from '../declarations'
7
7
 
8
8
  export const services = (app: Application) => {
9
9
  // All services will be registered here
@@ -1 +1 @@
1
- {"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAC3C;;;;;CAKD,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,UAAU,EAAE,OAAO,CAAC,CACnE,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
1
+ {"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;CAKtD,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,UAAU,EAAE,OAAO,CAAC,CACnE,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
@@ -2,8 +2,7 @@ import { generator, toFile } from '@feathershq/pinion'
2
2
  import { renderSource } from '../../commons'
3
3
  import { AppGeneratorContext } from '../index'
4
4
 
5
- const template = ({}: AppGeneratorContext) =>
6
- `import type { Application } from '../declarations'
5
+ const template = ({}: AppGeneratorContext) => /* ts */ `import type { Application } from '../declarations'
7
6
 
8
7
  export const services = (app: Application) => {
9
8
  // All services will be registered here
@@ -6,7 +6,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
6
6
  authStrategies: string[];
7
7
  dependencies: string[];
8
8
  }
9
- export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>;
9
+ export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>;
10
10
  export declare const prompts: (ctx: AuthenticationGeneratorArguments) => ({
11
11
  type: string;
12
12
  name: string;
@@ -50,15 +50,17 @@ export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promis
50
50
  className: string;
51
51
  kebabName: string;
52
52
  fileName: string;
53
+ kebabPath: string;
53
54
  relative: string;
54
- type: "custom" | "mongodb" | "knex";
55
+ type: "mongodb" | "knex" | "custom";
56
+ schema: false | "typebox" | "json";
55
57
  authentication: boolean;
56
58
  isEntityService?: boolean;
57
59
  feathers: import("../commons").FeathersAppInfo;
58
60
  pkg: import("../commons").AppPackageJson;
59
61
  lib: string;
60
62
  test: string;
61
- language: "js" | "ts";
63
+ language: "ts" | "js";
62
64
  dependencyVersions?: import("../commons").DependencyVersions;
63
65
  cwd: string;
64
66
  _?: (string | number)[];
@@ -48,6 +48,13 @@ const prompts = (ctx) => [
48
48
  type: 'input',
49
49
  when: !ctx.service,
50
50
  message: 'What is your authentication service name?',
51
+ default: 'user'
52
+ },
53
+ {
54
+ name: 'path',
55
+ type: 'input',
56
+ when: !ctx.path,
57
+ message: 'What path should the service be registered on?',
51
58
  default: 'users'
52
59
  },
53
60
  {
@@ -61,14 +68,16 @@ const prompts = (ctx) => [
61
68
  ];
62
69
  exports.prompts = prompts;
63
70
  const generate = (ctx) => (0, pinion_1.generator)(ctx)
71
+ .then((0, commons_1.initializeBaseContext)())
72
+ .then((0, commons_1.checkPreconditions)())
64
73
  .then((0, pinion_1.prompt)(exports.prompts))
65
74
  .then(async (ctx) => {
75
+ var _a;
66
76
  const serviceContext = await (0, index_1.generate)({
67
77
  ...ctx,
68
78
  name: ctx.service,
69
- path: ctx.service,
70
79
  isEntityService: true,
71
- type: (0, commons_1.getDatabaseAdapter)(ctx.feathers.database)
80
+ type: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database)
72
81
  });
73
82
  return {
74
83
  ...ctx,
@@ -88,7 +97,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
88
97
  dependencies: [...ctx.dependencies, ...dependencies]
89
98
  };
90
99
  }
91
- return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions))(ctx);
100
+ return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
92
101
  });
93
102
  exports.generate = generate;
94
103
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+CAA8E;AAC9E,wCAAiF;AACjF,4CAAwF;AAYjF,MAAM,OAAO,GAAG,CAAC,GAAqC,EAAE,EAAE,CAAC;IAChE;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,CAAC,GAAG,CAAC,cAAc;QACzB,OAAO,EAAE,kDAAkD;QAC3D,MAAM,EAAE,eAAK,CAAC,IAAI,CAAC,wDAAwD,CA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B,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE,IAAA,4BAAkB,EAAC,MAAA,GAAG,CAAC,QAAQ,0CAAE,QAAQ,CAAC;KACjD,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,GAAG;QACN,GAAG,cAAc;KAClB,CAAA;AACH,CAAC,CAAC;KACD,IAAI,CAAC,IAAA,sBAAa,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KAC3C,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,MAAM,YAAY,GAAa,EAAE,CAAA;IAEjC,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;IAErD,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACxC,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;KACtD;IAED,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,OAAO;YACL,GAAG,GAAG;YACN,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC;SACrD,CAAA;KACF;IAED,OAAO,IAAA,gBAAO,EACZ,IAAA,qBAAW,EAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjD,KAAK,EACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACtB,CAAC,GAAG,CAAC,CAAA;AACR,CAAC,CAAC,CAAA;AAxCO,QAAA,QAAQ,YAwCf"}
@@ -1,6 +1,12 @@
1
1
  import chalk from 'chalk'
2
2
  import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
3
- import { addVersions, FeathersBaseContext, getDatabaseAdapter } from '../commons'
3
+ import {
4
+ addVersions,
5
+ checkPreconditions,
6
+ FeathersBaseContext,
7
+ getDatabaseAdapter,
8
+ initializeBaseContext
9
+ } from '../commons'
4
10
  import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
5
11
 
6
12
  export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
@@ -11,7 +17,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
11
17
  }
12
18
 
13
19
  export type AuthenticationGeneratorArguments = FeathersBaseContext &
14
- Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>
20
+ Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>
15
21
 
16
22
  export const prompts = (ctx: AuthenticationGeneratorArguments) => [
17
23
  {
@@ -53,6 +59,13 @@ export const prompts = (ctx: AuthenticationGeneratorArguments) => [
53
59
  type: 'input',
54
60
  when: !ctx.service,
55
61
  message: 'What is your authentication service name?',
62
+ default: 'user'
63
+ },
64
+ {
65
+ name: 'path',
66
+ type: 'input',
67
+ when: !ctx.path,
68
+ message: 'What path should the service be registered on?',
56
69
  default: 'users'
57
70
  },
58
71
  {
@@ -67,14 +80,15 @@ export const prompts = (ctx: AuthenticationGeneratorArguments) => [
67
80
 
68
81
  export const generate = (ctx: AuthenticationGeneratorArguments) =>
69
82
  generator(ctx)
83
+ .then(initializeBaseContext())
84
+ .then(checkPreconditions())
70
85
  .then(prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(prompts))
71
86
  .then(async (ctx) => {
72
87
  const serviceContext = await serviceGenerator({
73
88
  ...ctx,
74
89
  name: ctx.service,
75
- path: ctx.service,
76
90
  isEntityService: true,
77
- type: getDatabaseAdapter(ctx.feathers.database)
91
+ type: getDatabaseAdapter(ctx.feathers?.database)
78
92
  })
79
93
 
80
94
  return {
@@ -99,5 +113,9 @@ export const generate = (ctx: AuthenticationGeneratorArguments) =>
99
113
  }
100
114
  }
101
115
 
102
- return install<AuthenticationGeneratorContext>(addVersions(dependencies, ctx.dependencyVersions))(ctx)
116
+ return install<AuthenticationGeneratorContext>(
117
+ addVersions(dependencies, ctx.dependencyVersions),
118
+ false,
119
+ ctx.feathers.packager
120
+ )(ctx)
103
121
  })
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({ authStrategies }) => `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
6
+ const template = ({ authStrategies }) => /* ts */ `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
7
7
  import { LocalStrategy } from '@feathersjs/authentication-local'
8
8
  import { OAuthStrategy } from '@feathersjs/authentication-oauth'
9
9
  import { oauth } from '@feathersjs/authentication-oauth'
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAG1D,MAAM,QAAQ,GAAG,CAAC,EAAE,cAAc,EAAkC,EAAE,EAAE,CACtE;;;;;;;;;;;;;;;;IAgBE,cAAc;KACb,GAAG,CACF,CAAC,QAAQ,EAAE,EAAE,CACX,8BAA8B,QAAQ,MACpC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBACjD,GAAG,CACN;KACA,IAAI,CAAC,IAAI,CAAC;;;;;CAKd,CAAA;AAED,MAAM,cAAc,GAAG,mDAAmD,CAAA;AAC1E,MAAM,iBAAiB,GAAG,+BAA+B,CAAA;AACzD,MAAM,SAAS,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAE5E,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM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C,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
@@ -2,8 +2,9 @@ import { generator, before, toFile } from '@feathershq/pinion'
2
2
  import { injectSource, renderSource } from '../../commons'
3
3
  import { AuthenticationGeneratorContext } from '../index'
4
4
 
5
- const template = ({ authStrategies }: AuthenticationGeneratorContext) =>
6
- `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
5
+ const template = ({
6
+ authStrategies
7
+ }: AuthenticationGeneratorContext) => /* ts */ `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
7
8
  import { LocalStrategy } from '@feathersjs/authentication-local'
8
9
  import { OAuthStrategy } from '@feathersjs/authentication-oauth'
9
10
  import { oauth } from '@feathersjs/authentication-oauth'
@@ -0,0 +1,66 @@
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 = ({ authStrategies, upperName, type, lib }) => /* ts */ `import assert from 'assert'
7
+ import axios from 'axios'
8
+
9
+ import rest from '@feathersjs/rest-client'
10
+ ${authStrategies.includes('local')
11
+ ? `import authenticationClient from '@feathersjs/authentication-client'`
12
+ : ''}
13
+ import { app } from '../${lib}/app'
14
+ import { createClient } from '../${lib}/client'
15
+ ${authStrategies.includes('local') ? `import type { ${upperName}Data } from '../${lib}/client'` : ''}
16
+
17
+ const port = app.get('port')
18
+ const appUrl = \`http://\${app.get('host')}:\${port}\`
19
+
20
+ describe('application client tests', () => {
21
+ const client = createClient(rest(appUrl).axios(axios))
22
+
23
+ client.configure(authenticationClient())
24
+
25
+ before(async () => {
26
+ await app.listen(port)
27
+ })
28
+
29
+ after(async () => {
30
+ await app.teardown()
31
+ })
32
+
33
+ it('initialized the client', () => {
34
+ assert.ok(client)
35
+ })
36
+
37
+ ${authStrategies.includes('local')
38
+ ? `
39
+ it('creates and authenticates a user with email and password', async () => {
40
+ const userData: ${upperName}Data = {
41
+ email: 'someone@example.com',
42
+ password: 'supersecret'
43
+ }
44
+
45
+ await client.service('users').create(userData)
46
+
47
+ const { user, accessToken } = await client.authenticate({
48
+ strategy: 'local',
49
+ ...userData
50
+ })
51
+
52
+ assert.ok(accessToken, 'Created access token for user')
53
+ assert.ok(user, 'Includes user in authentication data')
54
+ assert.strictEqual(user.password, undefined, 'Password is hidden to clients')
55
+
56
+ await client.logout()
57
+
58
+ // Remove the test user on the server
59
+ await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'})
60
+ })`
61
+ : ''}
62
+ })
63
+ `;
64
+ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test }) => test, 'client.test'), { force: true }));
65
+ exports.generate = generate;
66
+ //# sourceMappingURL=client.test.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACd,SAAS,EACT,IAAI,EACJ,GAAG,EAC4B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;EAK7C,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC,sEAAsE;IACxE,CAAC,CAAC,EACN;0BAC0B,GAAG;mCACM,GAAG;EACpC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,SAAS,mBAAmB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;IAuBhG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC;;sBAEc,SAAS;;;;;;;;;;;;;;;;;;;6CAmBc,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;KACzE;IACC,CAAC,CAAC,EACN;;CAED,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,EACzE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAA;AAPU,QAAA,QAAQ,YAOlB"}
@@ -0,0 +1,80 @@
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
+ import { AuthenticationGeneratorContext } from '../index'
4
+
5
+ const template = ({
6
+ authStrategies,
7
+ upperName,
8
+ type,
9
+ lib
10
+ }: AuthenticationGeneratorContext) => /* ts */ `import assert from 'assert'
11
+ import axios from 'axios'
12
+
13
+ import rest from '@feathersjs/rest-client'
14
+ ${
15
+ authStrategies.includes('local')
16
+ ? `import authenticationClient from '@feathersjs/authentication-client'`
17
+ : ''
18
+ }
19
+ import { app } from '../${lib}/app'
20
+ import { createClient } from '../${lib}/client'
21
+ ${authStrategies.includes('local') ? `import type { ${upperName}Data } from '../${lib}/client'` : ''}
22
+
23
+ const port = app.get('port')
24
+ const appUrl = \`http://\${app.get('host')}:\${port}\`
25
+
26
+ describe('application client tests', () => {
27
+ const client = createClient(rest(appUrl).axios(axios))
28
+
29
+ client.configure(authenticationClient())
30
+
31
+ before(async () => {
32
+ await app.listen(port)
33
+ })
34
+
35
+ after(async () => {
36
+ await app.teardown()
37
+ })
38
+
39
+ it('initialized the client', () => {
40
+ assert.ok(client)
41
+ })
42
+
43
+ ${
44
+ authStrategies.includes('local')
45
+ ? `
46
+ it('creates and authenticates a user with email and password', async () => {
47
+ const userData: ${upperName}Data = {
48
+ email: 'someone@example.com',
49
+ password: 'supersecret'
50
+ }
51
+
52
+ await client.service('users').create(userData)
53
+
54
+ const { user, accessToken } = await client.authenticate({
55
+ strategy: 'local',
56
+ ...userData
57
+ })
58
+
59
+ assert.ok(accessToken, 'Created access token for user')
60
+ assert.ok(user, 'Includes user in authentication data')
61
+ assert.strictEqual(user.password, undefined, 'Password is hidden to clients')
62
+
63
+ await client.logout()
64
+
65
+ // Remove the test user on the server
66
+ await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'})
67
+ })`
68
+ : ''
69
+ }
70
+ })
71
+ `
72
+
73
+ export const generate = (ctx: AuthenticationGeneratorContext) =>
74
+ generator(ctx).then(
75
+ renderSource(
76
+ template,
77
+ toFile<AuthenticationGeneratorContext>(({ test }) => test, 'client.test'),
78
+ { force: true }
79
+ )
80
+ )
@@ -1,2 +1,2 @@
1
- import { ServiceGeneratorContext } from '../index';
1
+ import { ServiceGeneratorContext } from '../../service';
2
2
  export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -0,0 +1,14 @@
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 importTemplate = /* ts */ `import type { AuthenticationService } from '@feathersjs/authentication'
7
+ `;
8
+ const declarationTemplate = ` authentication: Pick<AuthenticationService, 'create' | 'remove'>`;
9
+ const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client']);
10
+ const generate = async (ctx) => (0, pinion_1.generator)(ctx)
11
+ .then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile))
12
+ .then((0, pinion_1.when)(({ language }) => language === 'ts', (0, commons_1.injectSource)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
13
+ exports.generate = generate;
14
+ //# sourceMappingURL=client.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAmE;AACnE,2CAA4C;AAG5C,MAAM,cAAc,GAAG,QAAQ,CAAC;CAC/B,CAAA;AACD,MAAM,mBAAmB,GAAG,oEAAoE,CAAA;AAEhG,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE3E,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA4B,EAAE,EAAE,CAC7D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,CAAC;KACtF,IAAI,CACH,IAAA,aAAI,EACF,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,EACnC,IAAA,sBAAY,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CACxF,CACF,CAAA;AARQ,QAAA,QAAQ,YAQhB"}
@@ -0,0 +1,19 @@
1
+ import { generator, toFile, after, when } from '@feathershq/pinion'
2
+ import { injectSource } from '../../commons'
3
+ import { ServiceGeneratorContext } from '../../service'
4
+
5
+ const importTemplate = /* ts */ `import type { AuthenticationService } from '@feathersjs/authentication'
6
+ `
7
+ const declarationTemplate = ` authentication: Pick<AuthenticationService, 'create' | 'remove'>`
8
+
9
+ const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client'])
10
+
11
+ export const generate = async (ctx: ServiceGeneratorContext) =>
12
+ generator(ctx)
13
+ .then(injectSource(importTemplate, after("from '@feathersjs/feathers'"), toClientFile))
14
+ .then(
15
+ when(
16
+ ({ language }) => language === 'ts',
17
+ injectSource(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
18
+ )
19
+ )
@@ -10,7 +10,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
10
10
  .then((0, pinion_1.mergeJSON)(({ authStrategies }) => {
11
11
  const authentication = {
12
12
  entity: ctx.entity,
13
- service: ctx.service,
13
+ service: ctx.path,
14
14
  secret: crypto_1.default.randomBytes(24).toString('base64'),
15
15
  authStrategies: ['jwt'],
16
16
  jwtOptions: {
@@ -1 +1 @@
1
- {"version":3,"file":"config.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/config.tpl.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,+CAAiE;AAG1D,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,kBAAS,EAAiC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;IAC/D,MAAM,cAAc,GAAQ;QAC1B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,MAAM,EAAE,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjD,cAAc,EAAE,CAAC,KAAK,CAAC;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,GAAG,EAAE,QAAQ;aACd;YACD,QAAQ,EAAE,wBAAwB;YAClC,SAAS,EAAE,OAAO;YAClB,SAAS,EAAE,IAAI;SAChB;KACF,CAAA;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACpC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3C,cAAc,CAAC,KAAK,GAAG;YACrB,aAAa,EAAE,OAAO;YACtB,aAAa,EAAE,UAAU;SAC1B,CAAA;KACF;IAED,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,CAAA;IAEzE,IAAI,eAAe,CAAC,MAAM,EAAE;QAC1B,cAAc,C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AC,OAAO,CAAC,EAAE;QACpC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3C,cAAc,CAAC,KAAK,GAAG;YACrB,aAAa,EAAE,OAAO;YACtB,aAAa,EAAE,UAAU;SAC1B,CAAA;KACF;IAED,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,CAAA;IAEzE,IAAI,eAAe,CAAC,MAAM,EAAE;QAC1B,cAAc,CAAC,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC5D,KAAK,CAAC,IAAI,CAAC,GAAG;gBACZ,GAAG,EAAE,aAAa;gBAClB,MAAM,EAAE,iBAAiB;aAC1B,CAAA;YAED,OAAO,KAAK,CAAA;QACd,CAAC,EAAE,EAAS,CAAC,CAAA;KACd;IAED,OAAO,EAAE,cAAc,EAAE,CAAA;AAC3B,CAAC,EAAE,IAAA,eAAM,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CACrC;KACA,IAAI,CACH,IAAA,kBAAS,EACP;IACE,cAAc,EAAE;QACd,MAAM,EAAE,iBAAiB;KAC1B;CACF,EACD,IAAA,eAAM,EAAC,QAAQ,EAAE,mCAAmC,CAAC,CACtD,CACF,CAAA;AApDQ,QAAA,QAAQ,YAoDhB"}
@@ -8,7 +8,7 @@ export const generate = (ctx: AuthenticationGeneratorContext) =>
8
8
  mergeJSON<AuthenticationGeneratorContext>(({ authStrategies }) => {
9
9
  const authentication: any = {
10
10
  entity: ctx.entity,
11
- service: ctx.service,
11
+ service: ctx.path,
12
12
  secret: crypto.randomBytes(24).toString('base64'),
13
13
  authStrategies: ['jwt'],
14
14
  jwtOptions: {
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
- const importTemplate = ({ upperName, folder, fileName }) => `import { ${upperName}Result } from './services/${folder.join('/')}/${fileName}.schema'
5
+ const importTemplate = ({ upperName, folder, fileName }) => /* ts */ `import { ${upperName} } from './services/${folder.join('/')}/${fileName}'
6
6
  `;
7
- const paramsTemplate = ({ entity, upperName }) => `// Add the ${entity} as an optional property to all params
7
+ const paramsTemplate = ({ entity, upperName }) => /* ts */ `// Add the ${entity} as an optional property to all params
8
8
  declare module '@feathersjs/feathers' {
9
9
  interface Params {
10
- ${entity}?: ${upperName}Result
10
+ ${entity}?: ${upperName}
11
11
  }
12
12
  }
13
13
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"declarations.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/declarations.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAoF;AAGpF,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CACzF,YAAY,SAAS,6BAA6B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ;CAC/E,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,EACtB,MAAM,EACN,SAAS,EACsB,EAAE,EAAE,CAAC,cAAc,MAAM;;;MAGpD,MAAM,MAAM,SAAS;;;CAG1B,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAA;AAE9F,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,eAAM,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,iBAAiB,CAAC,CAC7E,CACF;KACA,IAAI,CAAC,IAAA,aAAI,E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