@feathersjs/cli 5.0.0-pre.30 → 5.0.0-pre.32

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 (76) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/lib/app/index.js +5 -5
  3. package/lib/app/index.js.map +1 -1
  4. package/lib/app/index.ts +13 -12
  5. package/lib/app/templates/app.tpl.js +7 -8
  6. package/lib/app/templates/app.tpl.js.map +1 -1
  7. package/lib/app/templates/app.tpl.ts +11 -8
  8. package/lib/app/templates/channels.tpl.js +4 -30
  9. package/lib/app/templates/channels.tpl.js.map +1 -1
  10. package/lib/app/templates/channels.tpl.ts +6 -30
  11. package/lib/app/templates/client.test.tpl.d.ts +2 -0
  12. package/lib/app/templates/client.test.tpl.js +27 -0
  13. package/lib/app/templates/client.test.tpl.js.map +1 -0
  14. package/lib/app/templates/client.test.tpl.ts +26 -0
  15. package/lib/app/templates/client.tpl.js +17 -3
  16. package/lib/app/templates/client.tpl.js.map +1 -1
  17. package/lib/app/templates/client.tpl.ts +20 -3
  18. package/lib/app/templates/declarations.tpl.js +3 -0
  19. package/lib/app/templates/declarations.tpl.js.map +1 -1
  20. package/lib/app/templates/declarations.tpl.ts +3 -0
  21. package/lib/app/templates/logger.tpl.js +8 -2
  22. package/lib/app/templates/logger.tpl.js.map +1 -1
  23. package/lib/app/templates/logger.tpl.ts +8 -2
  24. package/lib/app/templates/schemas.tpl.js +4 -5
  25. package/lib/app/templates/schemas.tpl.js.map +1 -1
  26. package/lib/app/templates/schemas.tpl.ts +4 -5
  27. package/lib/authentication/index.d.ts +3 -0
  28. package/lib/authentication/index.js +5 -1
  29. package/lib/authentication/index.js.map +1 -1
  30. package/lib/authentication/index.ts +5 -0
  31. package/lib/authentication/templates/authentication.tpl.js +5 -4
  32. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  33. package/lib/authentication/templates/authentication.tpl.ts +5 -5
  34. package/lib/authentication/templates/{test.tpl.d.ts → client.test.tpl.d.ts} +0 -0
  35. package/lib/authentication/templates/client.test.tpl.js +61 -0
  36. package/lib/authentication/templates/client.test.tpl.js.map +1 -0
  37. package/lib/authentication/templates/client.test.tpl.ts +73 -0
  38. package/lib/authentication/templates/client.tpl.d.ts +2 -0
  39. package/lib/authentication/templates/client.tpl.js +14 -0
  40. package/lib/authentication/templates/client.tpl.js.map +1 -0
  41. package/lib/authentication/templates/client.tpl.ts +19 -0
  42. package/lib/authentication/templates/declarations.tpl.js +1 -1
  43. package/lib/authentication/templates/declarations.tpl.ts +1 -1
  44. package/lib/authentication/templates/knex.tpl.js +3 -3
  45. package/lib/authentication/templates/knex.tpl.ts +3 -3
  46. package/lib/authentication/templates/schema.json.tpl.js +26 -25
  47. package/lib/authentication/templates/schema.json.tpl.js.map +1 -1
  48. package/lib/authentication/templates/schema.json.tpl.ts +26 -26
  49. package/lib/authentication/templates/schema.typebox.tpl.js +26 -27
  50. package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -1
  51. package/lib/authentication/templates/schema.typebox.tpl.ts +28 -28
  52. package/lib/service/index.d.ts +5 -63
  53. package/lib/service/index.js +74 -75
  54. package/lib/service/index.js.map +1 -1
  55. package/lib/service/index.ts +10 -4
  56. package/lib/service/templates/client.tpl.js +15 -20
  57. package/lib/service/templates/client.tpl.js.map +1 -1
  58. package/lib/service/templates/client.tpl.ts +29 -25
  59. package/lib/service/templates/schema.json.tpl.js +24 -22
  60. package/lib/service/templates/schema.json.tpl.js.map +1 -1
  61. package/lib/service/templates/schema.json.tpl.ts +24 -22
  62. package/lib/service/templates/schema.typebox.tpl.js +22 -25
  63. package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
  64. package/lib/service/templates/schema.typebox.tpl.ts +22 -25
  65. package/lib/service/type/knex.tpl.d.ts +1 -1
  66. package/lib/service/type/knex.tpl.js +10 -8
  67. package/lib/service/type/knex.tpl.js.map +1 -1
  68. package/lib/service/type/knex.tpl.ts +10 -9
  69. package/lib/service/type/mongodb.tpl.d.ts +1 -1
  70. package/lib/service/type/mongodb.tpl.js +7 -5
  71. package/lib/service/type/mongodb.tpl.js.map +1 -1
  72. package/lib/service/type/mongodb.tpl.ts +8 -6
  73. package/package.json +18 -16
  74. package/lib/authentication/templates/test.tpl.js +0 -43
  75. package/lib/authentication/templates/test.tpl.js.map +0 -1
  76. package/lib/authentication/templates/test.tpl.ts +0 -53
@@ -3,38 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = exports.template = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({ camelName, upperName, authStrategies, type, relative }) => /* ts */ `import { jsonSchema, resolve } from '@feathersjs/schema'
7
- import { Type, querySyntax } from '@feathersjs/typebox'
6
+ const index_1 = require("../index");
7
+ const template = ({ camelName, upperName, authStrategies, type, relative }) => /* ts */ `import { resolve } from '@feathersjs/schema'
8
+ import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
8
9
  import type { Static } from '@feathersjs/typebox'
9
- ${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
10
+ ${(0, index_1.localTemplate)(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
10
11
 
11
12
  import type { HookContext } from '${relative}/declarations'
12
13
  import { dataValidator, queryValidator } from '${relative}/schemas/validators'
13
14
 
14
- // Schema for the basic data model (e.g. creating new entries)
15
- export const ${camelName}DataSchema = Type.Object({
15
+ // Main data model schema
16
+ export const ${camelName}Schema = Type.Object({
17
+ ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
16
18
  ${authStrategies
17
19
  .map((name) => name === 'local'
18
20
  ? ` email: Type.String(),
19
- password: Type.String()`
21
+ password: Type.Optional(Type.String())`
20
22
  : ` ${name}Id: Type.Optional(Type.String())`)
21
23
  .join(',\n')}
22
- }, { $id: '${upperName}Data', additionalProperties: false })
23
- export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
24
- export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
25
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
26
- properties: {
27
- ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
28
- }
29
- })
30
-
31
- // Schema for the data that is being returned
32
- export const ${camelName}Schema = Type.Intersect([
33
- ${camelName}DataSchema,
34
- Type.Object({
35
- ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'}
36
- })
37
- ], { $id: '${upperName}' })
24
+ },{ $id: '${upperName}', additionalProperties: false })
38
25
  export type ${upperName} = Static<typeof ${camelName}Schema>
39
26
  export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
40
27
  properties: {}
@@ -47,14 +34,26 @@ export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
47
34
  }
48
35
  })
49
36
 
37
+ // Schema for the basic data model (e.g. creating new entries)
38
+ export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
39
+ ${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
40
+ ],
41
+ { $id: '${upperName}Data', additionalProperties: false }
42
+ )
43
+ export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
44
+ export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
45
+ export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
46
+ properties: {
47
+ ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
48
+ }
49
+ })
50
+
50
51
  // Schema for allowed query properties
51
- export const ${camelName}QuerySchema = Type.Intersect([
52
- querySyntax(${camelName}Schema),
53
- // Add additional query properties here
54
- Type.Object({})
52
+ export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${type === 'mongodb' ? '_id' : 'id'}', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
55
53
  ])
54
+ export const ${camelName}QuerySchema = querySyntax(${camelName}QueryProperties)
56
55
  export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
57
- export const ${camelName}QueryValidator = jsonSchema.getValidator(${camelName}QuerySchema, queryValidator)
56
+ export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
58
57
  export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
59
58
  properties: {
60
59
  // If there is a user (e.g. with authentication), they are only allowed to see their own data
@@ -1 +1 @@
1
- {"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;EAG7C,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iEAAiE,CAAC,CAAC,CAAC,EAAE;;oCAEvE,QAAQ;iDACK,QAAQ;;;eAG1C,SAAS;IACpB,cAAc;KACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;0BACgB;IAClB,CAAC,CAAC,OAAO,IAAI,kCAAkC,CAClD;KACA,IAAI,CAAC,KAAK,CAAC;aACH,SAAS;cACR,SAAS,wBAAwB,SAAS;eACzC,SAAS,+CAA+C,SAAS;eACjE,SAAS,0BAA0B,SAAS;;MAErD,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,EAAE;;;;;eAK9E,SAAS;IACpB,SAAS;;MAEP,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,mBAAmB;;aAExD,SAAS;cACR,SAAS,oBAAoB,SAAS;eACrC,SAAS,sBAAsB,SAAS;;;;eAIxC,SAAS,8BAA8B,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Y,QAAA,QAAQ,YAwEpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,EACpC,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC;IACpE,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CACF,CAAA;AAfU,QAAA,QAAQ,YAelB"}
@@ -1,6 +1,6 @@
1
1
  import { generator, toFile, when } from '@feathershq/pinion'
2
2
  import { renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext } from '../index'
3
+ import { AuthenticationGeneratorContext, localTemplate } from '../index'
4
4
 
5
5
  export const template = ({
6
6
  camelName,
@@ -8,40 +8,26 @@ export const template = ({
8
8
  authStrategies,
9
9
  type,
10
10
  relative
11
- }: AuthenticationGeneratorContext) => /* ts */ `import { jsonSchema, resolve } from '@feathersjs/schema'
12
- import { Type, querySyntax } from '@feathersjs/typebox'
11
+ }: AuthenticationGeneratorContext) => /* ts */ `import { resolve } from '@feathersjs/schema'
12
+ import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
13
13
  import type { Static } from '@feathersjs/typebox'
14
- ${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
14
+ ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
15
15
 
16
16
  import type { HookContext } from '${relative}/declarations'
17
17
  import { dataValidator, queryValidator } from '${relative}/schemas/validators'
18
18
 
19
- // Schema for the basic data model (e.g. creating new entries)
20
- export const ${camelName}DataSchema = Type.Object({
19
+ // Main data model schema
20
+ export const ${camelName}Schema = Type.Object({
21
+ ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
21
22
  ${authStrategies
22
23
  .map((name) =>
23
24
  name === 'local'
24
25
  ? ` email: Type.String(),
25
- password: Type.String()`
26
+ password: Type.Optional(Type.String())`
26
27
  : ` ${name}Id: Type.Optional(Type.String())`
27
28
  )
28
29
  .join(',\n')}
29
- }, { $id: '${upperName}Data', additionalProperties: false })
30
- export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
31
- export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
32
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
33
- properties: {
34
- ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
35
- }
36
- })
37
-
38
- // Schema for the data that is being returned
39
- export const ${camelName}Schema = Type.Intersect([
40
- ${camelName}DataSchema,
41
- Type.Object({
42
- ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'}
43
- })
44
- ], { $id: '${upperName}' })
30
+ },{ $id: '${upperName}', additionalProperties: false })
45
31
  export type ${upperName} = Static<typeof ${camelName}Schema>
46
32
  export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
47
33
  properties: {}
@@ -54,14 +40,28 @@ export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
54
40
  }
55
41
  })
56
42
 
43
+ // Schema for the basic data model (e.g. creating new entries)
44
+ export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
45
+ ${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
46
+ ],
47
+ { $id: '${upperName}Data', additionalProperties: false }
48
+ )
49
+ export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
50
+ export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
51
+ export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
52
+ properties: {
53
+ ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
54
+ }
55
+ })
56
+
57
57
  // Schema for allowed query properties
58
- export const ${camelName}QuerySchema = Type.Intersect([
59
- querySyntax(${camelName}Schema),
60
- // Add additional query properties here
61
- Type.Object({})
58
+ export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${
59
+ type === 'mongodb' ? '_id' : 'id'
60
+ }', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
62
61
  ])
62
+ export const ${camelName}QuerySchema = querySyntax(${camelName}QueryProperties)
63
63
  export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
64
- export const ${camelName}QueryValidator = jsonSchema.getValidator(${camelName}QuerySchema, queryValidator)
64
+ export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
65
65
  export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
66
66
  properties: {
67
67
  // If there is a user (e.g. with authentication), they are only allowed to see their own data
@@ -32,6 +32,10 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
32
32
  * The actual filename (the last element of the path)
33
33
  */
34
34
  fileName: string;
35
+ /**
36
+ * The kebab-cased name of the path. Will be used for e.g. database names
37
+ */
38
+ kebabPath: string;
35
39
  /**
36
40
  * Indicates how many file paths we should go up to import other things (e.g. `../../`)
37
41
  */
@@ -57,66 +61,4 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
57
61
  * Parameters the generator is called with
58
62
  */
59
63
  export declare type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>>;
60
- export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
61
- /**
62
- * The chosen service name
63
- */
64
- name: string;
65
- /**
66
- * The path the service is registered on
67
- */
68
- path: string;
69
- /**
70
- * The list of subfolders this service is in
71
- */
72
- folder: string[];
73
- /**
74
- * The `camelCase` service name starting with a lowercase letter
75
- */
76
- camelName: string;
77
- /**
78
- * The `CamelCase` service name starting with an uppercase letter
79
- */
80
- upperName: string;
81
- /**
82
- * The service class name combined as `CamelCaseService`
83
- */
84
- className: string;
85
- /**
86
- * A kebab-cased (filename friendly) version of the service name
87
- */
88
- kebabName: string;
89
- /**
90
- * The actual filename (the last element of the path)
91
- */
92
- fileName: string;
93
- /**
94
- * Indicates how many file paths we should go up to import other things (e.g. `../../`)
95
- */
96
- relative: string;
97
- /**
98
- * The chosen service type
99
- */
100
- type: 'knex' | 'mongodb' | 'custom';
101
- /**
102
- * Which schema definition format to use
103
- */
104
- schema: 'typebox' | 'json' | false;
105
- /**
106
- * Wether this service uses authentication
107
- */
108
- authentication: boolean;
109
- /**
110
- * Set to true if this service is for an authentication entity
111
- */
112
- isEntityService?: boolean;
113
- feathers: import("../commons").FeathersAppInfo;
114
- pkg: import("../commons").AppPackageJson;
115
- lib: string;
116
- test: string;
117
- language: "ts" | "js";
118
- dependencyVersions?: import("../commons").DependencyVersions;
119
- cwd: string;
120
- _?: (string | number)[];
121
- pinion: import("@feathershq/pinion").Configuration;
122
- }>;
64
+ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<ServiceGeneratorContext>;
@@ -10,84 +10,81 @@ const commons_1 = require("../commons");
10
10
  const generate = (ctx) => (0, pinion_1.generator)(ctx)
11
11
  .then((0, commons_1.initializeBaseContext)())
12
12
  .then((0, commons_1.checkPreconditions)())
13
- .then((0, pinion_1.prompt)(({ name, path, type, schema, authentication, isEntityService }) => {
14
- var _a, _b;
15
- return [
16
- {
17
- name: 'name',
18
- type: 'input',
19
- when: !name,
20
- message: 'What is the name of your service?',
21
- validate: (input) => {
22
- if (!input || input === 'authentication') {
23
- return 'Invalid service name';
24
- }
25
- return true;
13
+ .then((0, pinion_1.prompt)(({ name, path, type, schema, authentication, isEntityService, feathers }) => [
14
+ {
15
+ name: 'name',
16
+ type: 'input',
17
+ when: !name,
18
+ message: 'What is the name of your service?',
19
+ validate: (input) => {
20
+ if (!input || input === 'authentication') {
21
+ return 'Invalid service name';
26
22
  }
27
- },
28
- {
29
- name: 'path',
30
- type: 'input',
31
- when: !path,
32
- message: 'Which path should the service be registered on?',
33
- default: (answers) => `${lodash_1.default.kebabCase(answers.name)}`,
34
- validate: (input) => {
35
- if (!input || input === 'authentication') {
36
- return 'Invalid service path';
37
- }
38
- return true;
23
+ return true;
24
+ }
25
+ },
26
+ {
27
+ name: 'path',
28
+ type: 'input',
29
+ when: !path,
30
+ message: 'Which path should the service be registered on?',
31
+ default: (answers) => `${lodash_1.default.kebabCase(answers.name)}`,
32
+ validate: (input) => {
33
+ if (!input || input === 'authentication') {
34
+ return 'Invalid service path';
39
35
  }
40
- },
41
- {
42
- name: 'authentication',
43
- type: 'confirm',
44
- when: authentication === undefined && !isEntityService,
45
- message: 'Does this service require authentication?'
46
- },
47
- {
48
- name: 'type',
49
- type: 'list',
50
- when: !type,
51
- message: 'What kind of service is it?',
52
- default: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database),
53
- choices: [
54
- {
55
- value: 'knex',
56
- name: 'SQL'
57
- },
58
- {
59
- value: 'mongodb',
60
- name: 'MongoDB'
61
- },
62
- {
63
- value: 'custom',
64
- name: 'A custom service'
65
- }
66
- ]
67
- },
68
- {
69
- name: 'schema',
70
- type: 'list',
71
- when: schema === undefined,
72
- message: 'Which schema definition format do you want to use?',
73
- default: ((_b = ctx.feathers) === null || _b === void 0 ? void 0 : _b.schema) || 'json',
74
- choices: [
75
- {
76
- value: 'typebox',
77
- name: 'TypeBox'
78
- },
79
- {
80
- value: 'json',
81
- name: 'JSON schema'
82
- },
83
- {
84
- value: false,
85
- name: 'No schema'
86
- }
87
- ]
36
+ return true;
88
37
  }
89
- ];
90
- }))
38
+ },
39
+ {
40
+ name: 'authentication',
41
+ type: 'confirm',
42
+ when: authentication === undefined && !isEntityService,
43
+ message: 'Does this service require authentication?'
44
+ },
45
+ {
46
+ name: 'type',
47
+ type: 'list',
48
+ when: !type,
49
+ message: 'What kind of service is it?',
50
+ default: (0, commons_1.getDatabaseAdapter)(feathers === null || feathers === void 0 ? void 0 : feathers.database),
51
+ choices: [
52
+ {
53
+ value: 'knex',
54
+ name: 'SQL'
55
+ },
56
+ {
57
+ value: 'mongodb',
58
+ name: 'MongoDB'
59
+ },
60
+ {
61
+ value: 'custom',
62
+ name: 'A custom service'
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ name: 'schema',
68
+ type: 'list',
69
+ when: schema === undefined,
70
+ message: 'Which schema definition format do you want to use?',
71
+ default: feathers === null || feathers === void 0 ? void 0 : feathers.schema,
72
+ choices: [
73
+ {
74
+ value: 'typebox',
75
+ name: 'TypeBox'
76
+ },
77
+ {
78
+ value: 'json',
79
+ name: 'JSON schema'
80
+ },
81
+ {
82
+ value: false,
83
+ name: 'No schema'
84
+ }
85
+ ]
86
+ }
87
+ ]))
91
88
  .then(async (ctx) => {
92
89
  const { name, path, type } = ctx;
93
90
  const kebabName = lodash_1.default.kebabCase(name);
@@ -97,6 +94,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
97
94
  const folder = path.split('/').filter((el) => el !== '');
98
95
  const relative = ['', ...folder].map(() => '..').join('/');
99
96
  const fileName = lodash_1.default.last(folder);
97
+ const kebabPath = lodash_1.default.kebabCase(path);
100
98
  return {
101
99
  name,
102
100
  type,
@@ -107,6 +105,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
107
105
  className,
108
106
  kebabName,
109
107
  camelName,
108
+ kebabPath,
110
109
  relative,
111
110
  ...ctx
112
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAKmB;AAiEZ,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAE,EAAE,CACzD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAA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AAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAA;AAjHnF,QAAA,QAAQ,YAiH2E"}
@@ -41,6 +41,10 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
41
41
  * The actual filename (the last element of the path)
42
42
  */
43
43
  fileName: string
44
+ /**
45
+ * The kebab-cased name of the path. Will be used for e.g. database names
46
+ */
47
+ kebabPath: string
44
48
  /**
45
49
  * Indicates how many file paths we should go up to import other things (e.g. `../../`)
46
50
  */
@@ -77,7 +81,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
77
81
  .then(checkPreconditions())
78
82
  .then(
79
83
  prompt<ServiceGeneratorArguments, ServiceGeneratorContext>(
80
- ({ name, path, type, schema, authentication, isEntityService }) => [
84
+ ({ name, path, type, schema, authentication, isEntityService, feathers }) => [
81
85
  {
82
86
  name: 'name',
83
87
  type: 'input',
@@ -116,7 +120,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
116
120
  type: 'list',
117
121
  when: !type,
118
122
  message: 'What kind of service is it?',
119
- default: getDatabaseAdapter(ctx.feathers?.database),
123
+ default: getDatabaseAdapter(feathers?.database),
120
124
  choices: [
121
125
  {
122
126
  value: 'knex',
@@ -137,7 +141,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
137
141
  type: 'list',
138
142
  when: schema === undefined,
139
143
  message: 'Which schema definition format do you want to use?',
140
- default: ctx.feathers?.schema || 'json',
144
+ default: feathers?.schema,
141
145
  choices: [
142
146
  {
143
147
  value: 'typebox',
@@ -156,7 +160,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
156
160
  ]
157
161
  )
158
162
  )
159
- .then(async (ctx) => {
163
+ .then(async (ctx): Promise<ServiceGeneratorContext> => {
160
164
  const { name, path, type } = ctx
161
165
  const kebabName = _.kebabCase(name)
162
166
  const camelName = _.camelCase(name)
@@ -166,6 +170,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
166
170
  const folder = path.split('/').filter((el) => el !== '')
167
171
  const relative = ['', ...folder].map(() => '..').join('/')
168
172
  const fileName = _.last(folder)
173
+ const kebabPath = _.kebabCase(path)
169
174
 
170
175
  return {
171
176
  name,
@@ -177,6 +182,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
177
182
  className,
178
183
  kebabName,
179
184
  camelName,
185
+ kebabPath,
180
186
  relative,
181
187
  ...ctx
182
188
  }
@@ -3,34 +3,29 @@ 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 schemaImports = ({ upperName, folder, fileName }) => /* ts */ `import type {
6
+ const importTemplate = ({ upperName, folder, fileName, className }) => /* ts */ `import type {
7
7
  ${upperName},
8
8
  ${upperName}Data,
9
9
  ${upperName}Query,
10
+ ${className}
10
11
  } from './services/${folder.join('/')}/${fileName}'
11
-
12
12
  export type {
13
13
  ${upperName},
14
14
  ${upperName}Data,
15
- ${upperName}Query,
16
- }`;
17
- const declarationTemplate = ({ path, upperName }) => ` '${path}': ClientService<
18
- ${upperName},
19
- ${upperName}Data,
20
- Partial<${upperName}Data>,
21
- Paginated<${upperName}>,
22
- Params<${upperName}Query>
23
- > & {
24
- // Add custom methods here
25
- }`;
26
- const registrationTemplate = ({ path }) => ` client.use('${path}', connection.service('${path}'), {
27
- // List all standard and custom methods
28
- methods: ['find', 'get', 'create', 'update', 'patch', 'remove']
29
- })
15
+ ${upperName}Query
16
+ }
30
17
  `;
31
- const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client.ts']);
18
+ const methodsTemplate = ({ camelName, upperName, className, type }) => `
19
+ const ${camelName}ServiceMethods = ['find', 'get', 'create', 'update', 'patch', 'remove'] as const
20
+ type ${upperName}ClientService = Pick<${className}${type !== 'custom' ? `<Params<${upperName}Query>>` : ''}, typeof ${camelName}ServiceMethods[number]>`;
21
+ const declarationTemplate = ({ path, upperName }) => ` '${path}': ${upperName}ClientService`;
22
+ const registrationTemplate = ({ camelName, path }) => ` client.use('${path}', connection.service('${path}'), {
23
+ methods: ${camelName}ServiceMethods
24
+ })`;
25
+ const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client']);
32
26
  const generate = async (ctx) => (0, pinion_1.generator)(ctx)
33
- .then((0, commons_1.injectSource)(registrationTemplate, (0, pinion_1.before)('return client'), (0, pinion_1.toFile)(({ lib }) => [lib, 'client'])))
34
- .then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(schemaImports, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile), (0, pinion_1.inject)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
27
+ .then((0, commons_1.injectSource)(registrationTemplate, (0, pinion_1.before)('return client'), toClientFile))
28
+ .then((0, pinion_1.when)((ctx) => ctx.language === 'js', (0, commons_1.injectSource)(methodsTemplate, (0, pinion_1.after)('import authenticationClient'), toClientFile)))
29
+ .then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, commons_1.injectSource)(importTemplate, (0, pinion_1.after)('import authenticationClient'), toClientFile), (0, commons_1.injectSource)(methodsTemplate, (0, pinion_1.before)('\nexport interface ServiceTypes'), toClientFile), (0, commons_1.injectSource)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
35
30
  exports.generate = generate;
36
31
  //# sourceMappingURL=client.tpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAmF;AACnF,2CAA4C;AAG5C,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC,QAAQ,CAAC;IACzF,SAAS;IACT,SAAS;IACT,SAAS;qBACQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ;;;IAG7C,SAAS;IACT,S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