@feathersjs/cli 5.0.0-pre.34 → 5.0.0-pre.35

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 (171) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/index.d.ts +6 -2
  3. package/lib/index.js +59 -2
  4. package/lib/index.js.map +1 -1
  5. package/package.json +28 -30
  6. package/lib/app/index.d.ts +0 -29
  7. package/lib/app/index.js +0 -146
  8. package/lib/app/index.js.map +0 -1
  9. package/lib/app/index.ts +0 -228
  10. package/lib/app/static/.gitignore +0 -121
  11. package/lib/app/templates/app.test.tpl.d.ts +0 -2
  12. package/lib/app/templates/app.test.tpl.js +0 -49
  13. package/lib/app/templates/app.test.tpl.js.map +0 -1
  14. package/lib/app/templates/app.test.tpl.ts +0 -50
  15. package/lib/app/templates/app.tpl.d.ts +0 -2
  16. package/lib/app/templates/app.tpl.js +0 -123
  17. package/lib/app/templates/app.tpl.js.map +0 -1
  18. package/lib/app/templates/app.tpl.ts +0 -138
  19. package/lib/app/templates/channels.tpl.d.ts +0 -2
  20. package/lib/app/templates/channels.tpl.js +0 -49
  21. package/lib/app/templates/channels.tpl.js.map +0 -1
  22. package/lib/app/templates/channels.tpl.ts +0 -55
  23. package/lib/app/templates/client.test.tpl.d.ts +0 -2
  24. package/lib/app/templates/client.test.tpl.js +0 -27
  25. package/lib/app/templates/client.test.tpl.js.map +0 -1
  26. package/lib/app/templates/client.test.tpl.ts +0 -26
  27. package/lib/app/templates/client.tpl.d.ts +0 -2
  28. package/lib/app/templates/client.tpl.js +0 -38
  29. package/lib/app/templates/client.tpl.js.map +0 -1
  30. package/lib/app/templates/client.tpl.ts +0 -45
  31. package/lib/app/templates/configuration.tpl.d.ts +0 -2
  32. package/lib/app/templates/configuration.tpl.js +0 -71
  33. package/lib/app/templates/configuration.tpl.js.map +0 -1
  34. package/lib/app/templates/configuration.tpl.ts +0 -82
  35. package/lib/app/templates/declarations.tpl.d.ts +0 -2
  36. package/lib/app/templates/declarations.tpl.js +0 -28
  37. package/lib/app/templates/declarations.tpl.js.map +0 -1
  38. package/lib/app/templates/declarations.tpl.ts +0 -37
  39. package/lib/app/templates/index.html.tpl.d.ts +0 -2
  40. package/lib/app/templates/index.html.tpl.js +0 -45
  41. package/lib/app/templates/index.html.tpl.js.map +0 -1
  42. package/lib/app/templates/index.html.tpl.ts +0 -44
  43. package/lib/app/templates/index.tpl.d.ts +0 -2
  44. package/lib/app/templates/index.tpl.js +0 -18
  45. package/lib/app/templates/index.tpl.js.map +0 -1
  46. package/lib/app/templates/index.tpl.ts +0 -22
  47. package/lib/app/templates/logger.tpl.d.ts +0 -3
  48. package/lib/app/templates/logger.tpl.js +0 -45
  49. package/lib/app/templates/logger.tpl.js.map +0 -1
  50. package/lib/app/templates/logger.tpl.ts +0 -56
  51. package/lib/app/templates/package.json.tpl.d.ts +0 -2
  52. package/lib/app/templates/package.json.tpl.js +0 -58
  53. package/lib/app/templates/package.json.tpl.js.map +0 -1
  54. package/lib/app/templates/package.json.tpl.ts +0 -71
  55. package/lib/app/templates/prettierrc.tpl.d.ts +0 -2
  56. package/lib/app/templates/prettierrc.tpl.js +0 -11
  57. package/lib/app/templates/prettierrc.tpl.js.map +0 -1
  58. package/lib/app/templates/prettierrc.tpl.ts +0 -14
  59. package/lib/app/templates/readme.md.tpl.d.ts +0 -2
  60. package/lib/app/templates/readme.md.tpl.js +0 -54
  61. package/lib/app/templates/readme.md.tpl.js.map +0 -1
  62. package/lib/app/templates/readme.md.tpl.ts +0 -57
  63. package/lib/app/templates/services.tpl.d.ts +0 -2
  64. package/lib/app/templates/services.tpl.js +0 -15
  65. package/lib/app/templates/services.tpl.js.map +0 -1
  66. package/lib/app/templates/services.tpl.ts +0 -20
  67. package/lib/app/templates/tsconfig.json.tpl.d.ts +0 -2
  68. package/lib/app/templates/tsconfig.json.tpl.js +0 -22
  69. package/lib/app/templates/tsconfig.json.tpl.js.map +0 -1
  70. package/lib/app/templates/tsconfig.json.tpl.ts +0 -28
  71. package/lib/app/templates/validators.tpl.d.ts +0 -2
  72. package/lib/app/templates/validators.tpl.js +0 -36
  73. package/lib/app/templates/validators.tpl.js.map +0 -1
  74. package/lib/app/templates/validators.tpl.ts +0 -40
  75. package/lib/authentication/index.d.ts +0 -73
  76. package/lib/authentication/index.js +0 -107
  77. package/lib/authentication/index.js.map +0 -1
  78. package/lib/authentication/index.ts +0 -126
  79. package/lib/authentication/templates/authentication.tpl.d.ts +0 -2
  80. package/lib/authentication/templates/authentication.tpl.js +0 -40
  81. package/lib/authentication/templates/authentication.tpl.js.map +0 -1
  82. package/lib/authentication/templates/authentication.tpl.ts +0 -51
  83. package/lib/authentication/templates/client.test.tpl.d.ts +0 -2
  84. package/lib/authentication/templates/client.test.tpl.js +0 -62
  85. package/lib/authentication/templates/client.test.tpl.js.map +0 -1
  86. package/lib/authentication/templates/client.test.tpl.ts +0 -74
  87. package/lib/authentication/templates/config.tpl.d.ts +0 -2
  88. package/lib/authentication/templates/config.tpl.js +0 -50
  89. package/lib/authentication/templates/config.tpl.js.map +0 -1
  90. package/lib/authentication/templates/config.tpl.ts +0 -57
  91. package/lib/authentication/templates/declarations.tpl.d.ts +0 -2
  92. package/lib/authentication/templates/declarations.tpl.js +0 -19
  93. package/lib/authentication/templates/declarations.tpl.js.map +0 -1
  94. package/lib/authentication/templates/declarations.tpl.ts +0 -34
  95. package/lib/authentication/templates/knex.tpl.d.ts +0 -2
  96. package/lib/authentication/templates/knex.tpl.js +0 -45
  97. package/lib/authentication/templates/knex.tpl.js.map +0 -1
  98. package/lib/authentication/templates/knex.tpl.ts +0 -62
  99. package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
  100. package/lib/authentication/templates/schema.json.tpl.js +0 -103
  101. package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
  102. package/lib/authentication/templates/schema.json.tpl.ts +0 -124
  103. package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
  104. package/lib/authentication/templates/schema.typebox.tpl.js +0 -86
  105. package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
  106. package/lib/authentication/templates/schema.typebox.tpl.ts +0 -108
  107. package/lib/cli.d.ts +0 -6
  108. package/lib/cli.js +0 -75
  109. package/lib/cli.js.map +0 -1
  110. package/lib/cli.ts +0 -68
  111. package/lib/commons.d.ts +0 -150
  112. package/lib/commons.js +0 -198
  113. package/lib/commons.js.map +0 -1
  114. package/lib/commons.ts +0 -284
  115. package/lib/connection/index.d.ts +0 -55
  116. package/lib/connection/index.js +0 -88
  117. package/lib/connection/index.js.map +0 -1
  118. package/lib/connection/index.ts +0 -123
  119. package/lib/connection/templates/knex.tpl.d.ts +0 -2
  120. package/lib/connection/templates/knex.tpl.js +0 -48
  121. package/lib/connection/templates/knex.tpl.js.map +0 -1
  122. package/lib/connection/templates/knex.tpl.ts +0 -67
  123. package/lib/connection/templates/mongodb.tpl.d.ts +0 -2
  124. package/lib/connection/templates/mongodb.tpl.js +0 -34
  125. package/lib/connection/templates/mongodb.tpl.js.map +0 -1
  126. package/lib/connection/templates/mongodb.tpl.ts +0 -40
  127. package/lib/hook/index.d.ts +0 -22
  128. package/lib/hook/index.js +0 -43
  129. package/lib/hook/index.js.map +0 -1
  130. package/lib/hook/index.ts +0 -47
  131. package/lib/hook/templates/hook.tpl.d.ts +0 -2
  132. package/lib/hook/templates/hook.tpl.js +0 -22
  133. package/lib/hook/templates/hook.tpl.js.map +0 -1
  134. package/lib/hook/templates/hook.tpl.ts +0 -33
  135. package/lib/index.ts +0 -2
  136. package/lib/service/index.d.ts +0 -64
  137. package/lib/service/index.js +0 -116
  138. package/lib/service/index.js.map +0 -1
  139. package/lib/service/index.ts +0 -191
  140. package/lib/service/templates/client.tpl.d.ts +0 -2
  141. package/lib/service/templates/client.tpl.js +0 -31
  142. package/lib/service/templates/client.tpl.js.map +0 -1
  143. package/lib/service/templates/client.tpl.ts +0 -57
  144. package/lib/service/templates/schema.json.tpl.d.ts +0 -2
  145. package/lib/service/templates/schema.json.tpl.js +0 -83
  146. package/lib/service/templates/schema.json.tpl.js.map +0 -1
  147. package/lib/service/templates/schema.json.tpl.ts +0 -98
  148. package/lib/service/templates/schema.typebox.tpl.d.ts +0 -2
  149. package/lib/service/templates/schema.typebox.tpl.js +0 -61
  150. package/lib/service/templates/schema.typebox.tpl.js.map +0 -1
  151. package/lib/service/templates/schema.typebox.tpl.ts +0 -76
  152. package/lib/service/templates/service.tpl.d.ts +0 -3
  153. package/lib/service/templates/service.tpl.js +0 -112
  154. package/lib/service/templates/service.tpl.js.map +0 -1
  155. package/lib/service/templates/service.tpl.ts +0 -152
  156. package/lib/service/templates/test.tpl.d.ts +0 -2
  157. package/lib/service/templates/test.tpl.js +0 -25
  158. package/lib/service/templates/test.tpl.js.map +0 -1
  159. package/lib/service/templates/test.tpl.ts +0 -33
  160. package/lib/service/type/custom.tpl.d.ts +0 -3
  161. package/lib/service/type/custom.tpl.js +0 -98
  162. package/lib/service/type/custom.tpl.js.map +0 -1
  163. package/lib/service/type/custom.tpl.ts +0 -109
  164. package/lib/service/type/knex.tpl.d.ts +0 -3
  165. package/lib/service/type/knex.tpl.js +0 -71
  166. package/lib/service/type/knex.tpl.js.map +0 -1
  167. package/lib/service/type/knex.tpl.ts +0 -92
  168. package/lib/service/type/mongodb.tpl.d.ts +0 -3
  169. package/lib/service/type/mongodb.tpl.js +0 -50
  170. package/lib/service/type/mongodb.tpl.js.map +0 -1
  171. package/lib/service/type/mongodb.tpl.ts +0 -62
@@ -1,64 +0,0 @@
1
- import { FeathersBaseContext } from '../commons';
2
- export interface ServiceGeneratorContext extends FeathersBaseContext {
3
- /**
4
- * The chosen service name
5
- */
6
- name: string;
7
- /**
8
- * The path the service is registered on
9
- */
10
- path: string;
11
- /**
12
- * The list of subfolders this service is in
13
- */
14
- folder: string[];
15
- /**
16
- * The `camelCase` service name starting with a lowercase letter
17
- */
18
- camelName: string;
19
- /**
20
- * The `CamelCase` service name starting with an uppercase letter
21
- */
22
- upperName: string;
23
- /**
24
- * The service class name combined as `CamelCaseService`
25
- */
26
- className: string;
27
- /**
28
- * A kebab-cased (filename friendly) version of the service name
29
- */
30
- kebabName: string;
31
- /**
32
- * The actual filename (the last element of the path)
33
- */
34
- fileName: string;
35
- /**
36
- * The kebab-cased name of the path. Will be used for e.g. database names
37
- */
38
- kebabPath: string;
39
- /**
40
- * Indicates how many file paths we should go up to import other things (e.g. `../../`)
41
- */
42
- relative: string;
43
- /**
44
- * The chosen service type
45
- */
46
- type: 'knex' | 'mongodb' | 'custom';
47
- /**
48
- * Which schema definition format to use
49
- */
50
- schema: 'typebox' | 'json' | false;
51
- /**
52
- * Wether this service uses authentication
53
- */
54
- authentication: boolean;
55
- /**
56
- * Set to true if this service is for an authentication entity
57
- */
58
- isEntityService?: boolean;
59
- }
60
- /**
61
- * Parameters the generator is called with
62
- */
63
- export type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>>;
64
- export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<ServiceGeneratorContext>;
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generate = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const pinion_1 = require("@feathershq/pinion");
9
- const commons_1 = require("../commons");
10
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
11
- .then((0, commons_1.initializeBaseContext)())
12
- .then((0, commons_1.checkPreconditions)())
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';
22
- }
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';
35
- }
36
- return true;
37
- }
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
- ]))
88
- .then(async (ctx) => {
89
- const { name, path, type } = ctx;
90
- const kebabName = lodash_1.default.kebabCase(name);
91
- const camelName = lodash_1.default.camelCase(name);
92
- const upperName = lodash_1.default.upperFirst(camelName);
93
- const className = `${upperName}Service`;
94
- const folder = path.split('/').filter((el) => el !== '');
95
- const relative = ['', ...folder].map(() => '..').join('/');
96
- const fileName = lodash_1.default.last(folder);
97
- const kebabPath = lodash_1.default.kebabCase(path);
98
- return {
99
- name,
100
- type,
101
- path,
102
- folder,
103
- fileName,
104
- upperName,
105
- className,
106
- kebabName,
107
- camelName,
108
- kebabPath,
109
- relative,
110
- ...ctx
111
- };
112
- })
113
- .then((0, pinion_1.runGenerators)(__dirname, 'templates'))
114
- .then((0, pinion_1.runGenerator)(__dirname, 'type', ({ type }) => `${type}.tpl`));
115
- exports.generate = generate;
116
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAKmB;AAqEZ,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAE,EAAE,CACzD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAAI,CAAC,IAAA,4BAAkB,GAAE,CAAC;KAC1B,IAAI,CACH,IAAA,eAAM,EACJ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC3E;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,IAAI;QACX,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,gBAAgB,EAAE;gBACxC,OAAO,sBAAsB,CAAA;aAC9B;YAED,OAAO,IAAI,CAAA;QACb,CAAC;KACF;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,IAAI;QACX,OAAO,EAAE,iDAAiD;QAC1D,OAAO,EAAE,CAAC,OAAkC,EAAE,EAAE,CAAC,GAAG,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC/E,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,gBAAgB,EAAE;gBACxC,OAAO,sBAAsB,CAAA;aAC9B;YAED,OAAO,IAAI,CAAA;QACb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SAAS,GAAG,gBAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,SAAS,GAAG,GAAG,SAAS,SAAS,CAAA;IAEvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACxD,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1D,MAAM,QAAQ,GAAG,gBAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAEnC,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,QAAQ;QACR,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,QAAQ;QACR,GAAG,GAAG;KACP,CAAA;AACH,CAAC,CAAC;KACD,IAAI,CAAC,IAAA,sBAAa,EAA0B,SAAS,EAAE,WAAW,CAAC,CAAC;KACpE,IAAI,CAAC,IAAA,qBAAY,EAA0B,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAA;AAjHnF,QAAA,QAAQ,YAiH2E"}
@@ -1,191 +0,0 @@
1
- import _ from 'lodash'
2
- import { generator, runGenerator, runGenerators, prompt } from '@feathershq/pinion'
3
-
4
- import {
5
- checkPreconditions,
6
- FeathersBaseContext,
7
- getDatabaseAdapter,
8
- initializeBaseContext
9
- } from '../commons'
10
-
11
- export interface ServiceGeneratorContext extends FeathersBaseContext {
12
- /**
13
- * The chosen service name
14
- */
15
- name: string
16
- /**
17
- * The path the service is registered on
18
- */
19
- path: string
20
- /**
21
- * The list of subfolders this service is in
22
- */
23
- folder: string[]
24
- /**
25
- * The `camelCase` service name starting with a lowercase letter
26
- */
27
- camelName: string
28
- /**
29
- * The `CamelCase` service name starting with an uppercase letter
30
- */
31
- upperName: string
32
- /**
33
- * The service class name combined as `CamelCaseService`
34
- */
35
- className: string
36
- /**
37
- * A kebab-cased (filename friendly) version of the service name
38
- */
39
- kebabName: string
40
- /**
41
- * The actual filename (the last element of the path)
42
- */
43
- fileName: string
44
- /**
45
- * The kebab-cased name of the path. Will be used for e.g. database names
46
- */
47
- kebabPath: string
48
- /**
49
- * Indicates how many file paths we should go up to import other things (e.g. `../../`)
50
- */
51
- relative: string
52
- /**
53
- * The chosen service type
54
- */
55
- type: 'knex' | 'mongodb' | 'custom'
56
- /**
57
- * Which schema definition format to use
58
- */
59
- schema: 'typebox' | 'json' | false
60
- /**
61
- * Wether this service uses authentication
62
- */
63
- authentication: boolean
64
- /**
65
- * Set to true if this service is for an authentication entity
66
- */
67
- isEntityService?: boolean
68
- }
69
-
70
- /**
71
- * Parameters the generator is called with
72
- */
73
- export type ServiceGeneratorArguments = FeathersBaseContext &
74
- Partial<
75
- Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>
76
- >
77
-
78
- export const generate = (ctx: ServiceGeneratorArguments) =>
79
- generator(ctx)
80
- .then(initializeBaseContext())
81
- .then(checkPreconditions())
82
- .then(
83
- prompt<ServiceGeneratorArguments, ServiceGeneratorContext>(
84
- ({ name, path, type, schema, authentication, isEntityService, feathers }) => [
85
- {
86
- name: 'name',
87
- type: 'input',
88
- when: !name,
89
- message: 'What is the name of your service?',
90
- validate: (input) => {
91
- if (!input || input === 'authentication') {
92
- return 'Invalid service name'
93
- }
94
-
95
- return true
96
- }
97
- },
98
- {
99
- name: 'path',
100
- type: 'input',
101
- when: !path,
102
- message: 'Which path should the service be registered on?',
103
- default: (answers: ServiceGeneratorArguments) => `${_.kebabCase(answers.name)}`,
104
- validate: (input) => {
105
- if (!input || input === 'authentication') {
106
- return 'Invalid service path'
107
- }
108
-
109
- return true
110
- }
111
- },
112
- {
113
- name: 'authentication',
114
- type: 'confirm',
115
- when: authentication === undefined && !isEntityService,
116
- message: 'Does this service require authentication?'
117
- },
118
- {
119
- name: 'type',
120
- type: 'list',
121
- when: !type,
122
- message: 'What kind of service is it?',
123
- default: getDatabaseAdapter(feathers?.database),
124
- choices: [
125
- {
126
- value: 'knex',
127
- name: 'SQL'
128
- },
129
- {
130
- value: 'mongodb',
131
- name: 'MongoDB'
132
- },
133
- {
134
- value: 'custom',
135
- name: 'A custom service'
136
- }
137
- ]
138
- },
139
- {
140
- name: 'schema',
141
- type: 'list',
142
- when: schema === undefined,
143
- message: 'Which schema definition format do you want to use?',
144
- default: feathers?.schema,
145
- choices: [
146
- {
147
- value: 'typebox',
148
- name: 'TypeBox'
149
- },
150
- {
151
- value: 'json',
152
- name: 'JSON schema'
153
- },
154
- {
155
- value: false,
156
- name: 'No schema'
157
- }
158
- ]
159
- }
160
- ]
161
- )
162
- )
163
- .then(async (ctx): Promise<ServiceGeneratorContext> => {
164
- const { name, path, type } = ctx
165
- const kebabName = _.kebabCase(name)
166
- const camelName = _.camelCase(name)
167
- const upperName = _.upperFirst(camelName)
168
- const className = `${upperName}Service`
169
-
170
- const folder = path.split('/').filter((el) => el !== '')
171
- const relative = ['', ...folder].map(() => '..').join('/')
172
- const fileName = _.last(folder)
173
- const kebabPath = _.kebabCase(path)
174
-
175
- return {
176
- name,
177
- type,
178
- path,
179
- folder,
180
- fileName,
181
- upperName,
182
- className,
183
- kebabName,
184
- camelName,
185
- kebabPath,
186
- relative,
187
- ...ctx
188
- }
189
- })
190
- .then(runGenerators<ServiceGeneratorContext>(__dirname, 'templates'))
191
- .then(runGenerator<ServiceGeneratorContext>(__dirname, 'type', ({ type }) => `${type}.tpl`))
@@ -1,2 +0,0 @@
1
- import { ServiceGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const importTemplate = ({ upperName, folder, fileName, className }) => /* ts */ `import type {
7
- ${upperName},
8
- ${upperName}Data,
9
- ${upperName}Query,
10
- ${className}
11
- } from './services/${folder.join('/')}/${fileName}'
12
- export type {
13
- ${upperName},
14
- ${upperName}Data,
15
- ${upperName}Query
16
- }
17
- `;
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']);
26
- const generate = async (ctx) => (0, pinion_1.generator)(ctx)
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)));
30
- exports.generate = generate;
31
- //# sourceMappingURL=client.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.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AC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,sBAAY,EAAC,eAAe,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,CAClF,CACF;KACA,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,EAChF,IAAA,sBAAY,EAAC,eAAe,EAAE,IAAA,eAAM,EAAC,iCAAiC,CAAC,EAAE,YAAY,CAAC,EACtF,IAAA,sBAAY,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CACxF,CACF,CAAA;AAhBQ,QAAA,QAAQ,YAgBhB"}
@@ -1,57 +0,0 @@
1
- import { generator, toFile, when, after, before } from '@feathershq/pinion'
2
- import { injectSource } from '../../commons'
3
- import { ServiceGeneratorContext } from '../index'
4
-
5
- const importTemplate = ({
6
- upperName,
7
- folder,
8
- fileName,
9
- className
10
- }: ServiceGeneratorContext) => /* ts */ `import type {
11
- ${upperName},
12
- ${upperName}Data,
13
- ${upperName}Query,
14
- ${className}
15
- } from './services/${folder.join('/')}/${fileName}'
16
- export type {
17
- ${upperName},
18
- ${upperName}Data,
19
- ${upperName}Query
20
- }
21
- `
22
-
23
- const methodsTemplate = ({ camelName, upperName, className, type }: ServiceGeneratorContext) => `
24
- const ${camelName}ServiceMethods = ['find', 'get', 'create', 'update', 'patch', 'remove'] as const
25
- type ${upperName}ClientService = Pick<${className}${
26
- type !== 'custom' ? `<Params<${upperName}Query>>` : ''
27
- }, typeof ${camelName}ServiceMethods[number]>`
28
-
29
- const declarationTemplate = ({ path, upperName }: ServiceGeneratorContext) =>
30
- ` '${path}': ${upperName}ClientService`
31
-
32
- const registrationTemplate = ({
33
- camelName,
34
- path
35
- }: ServiceGeneratorContext) => ` client.use('${path}', connection.service('${path}'), {
36
- methods: ${camelName}ServiceMethods
37
- })`
38
-
39
- const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client'])
40
-
41
- export const generate = async (ctx: ServiceGeneratorContext) =>
42
- generator(ctx)
43
- .then(injectSource(registrationTemplate, before('return client'), toClientFile))
44
- .then(
45
- when(
46
- (ctx) => ctx.language === 'js',
47
- injectSource(methodsTemplate, after('import authenticationClient'), toClientFile)
48
- )
49
- )
50
- .then(
51
- when(
52
- (ctx) => ctx.language === 'ts',
53
- injectSource(importTemplate, after('import authenticationClient'), toClientFile),
54
- injectSource(methodsTemplate, before('\nexport interface ServiceTypes'), toClientFile),
55
- injectSource(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
56
- )
57
- )
@@ -1,2 +0,0 @@
1
- import { ServiceGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const template = ({ camelName, upperName, relative, type, cwd, lib }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
7
- import { resolve, getValidator, querySyntax } from '@feathersjs/schema'
8
- import type { FromSchema } from '@feathersjs/schema'
9
-
10
- import type { HookContext } from '${relative}/declarations'
11
- import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
12
- }validators'
13
-
14
- // Main data model schema
15
- export const ${camelName}Schema = {
16
- $id: '${upperName}',
17
- type: 'object',
18
- additionalProperties: false,
19
- required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
20
- properties: {
21
- ${type === 'mongodb' ? '_id' : 'id'}: {
22
- type: '${type === 'mongodb' ? 'string' : 'number'}'
23
- },
24
- text: {
25
- type: 'string'
26
- }
27
- }
28
- } as const
29
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
30
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
31
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({})
32
-
33
- // Schema for creating new data
34
- export const ${camelName}DataSchema = {
35
- $id: '${upperName}Data',
36
- type: 'object',
37
- additionalProperties: false,
38
- required: [ 'text' ],
39
- properties: {
40
- text: {
41
- type: 'string'
42
- }
43
- }
44
- } as const
45
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
46
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
47
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({})
48
-
49
- // Schema for updating existing data
50
- export const ${camelName}PatchSchema = {
51
- $id: '${upperName}Patch',
52
- type: 'object',
53
- additionalProperties: false,
54
- required: [],
55
- properties: {
56
- ...${camelName}Schema.properties
57
- }
58
- } as const
59
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
60
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
61
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({})
62
-
63
- // Schema for allowed query properties
64
- export const ${camelName}QuerySchema = {
65
- $id: '${upperName}Query',
66
- type: 'object',
67
- additionalProperties: false,
68
- properties: {
69
- ...querySyntax(${camelName}Schema.properties)
70
- }
71
- } as const
72
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
73
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
74
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({})
75
- `;
76
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'json', (0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
77
- lib,
78
- 'services',
79
- ...folder,
80
- `${fileName}.schema`
81
- ]))));
82
- exports.generate = generate;
83
- //# sourceMappingURL=schema.json.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AAGxD,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,GAAG,EACqB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;oCAIJ,QAAQ;iDACK,QAAQ,IACvD,IAAA,oBAAU,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,6CAA6C;AACjG;;;eAGe,SAAS;UACd,SAAS;;;iBAGF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;MAE5C,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;eACxB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;;;;;;;cAOzC,SAAS,wBAAwB,SAAS;eACzC,SAAS,sBAAsB,SAAS;eACxC,SAAS,8BAA8B,SAAS;;;eAGhD,SAAS;UACd,SAAS;;;;;;;;;;cAUL,SAAS,4BAA4B,SAAS;eAC7C,SAAS,gCAAgC,SAAS;eAClD,SAAS,0BAA0B,SAAS;;;eAG5C,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;cAGJ,SAAS,6BAA6B,SAAS;eAC9C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;;;eAG7C,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;cAGhB,SAAS,6BAA6B,SAAS;eAC9C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;CAC3D,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,EACjC,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,CACH,CACF,CACF,CAAA;AAdU,QAAA,QAAQ,YAclB"}
@@ -1,98 +0,0 @@
1
- import { generator, toFile, when } from '@feathershq/pinion'
2
- import { fileExists, renderSource } from '../../commons'
3
- import { ServiceGeneratorContext } from '../index'
4
-
5
- const template = ({
6
- camelName,
7
- upperName,
8
- relative,
9
- type,
10
- cwd,
11
- lib
12
- }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
13
- import { resolve, getValidator, querySyntax } from '@feathersjs/schema'
14
- import type { FromSchema } from '@feathersjs/schema'
15
-
16
- import type { HookContext } from '${relative}/declarations'
17
- import { dataValidator, queryValidator } from '${relative}/${
18
- fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
19
- }validators'
20
-
21
- // Main data model schema
22
- export const ${camelName}Schema = {
23
- $id: '${upperName}',
24
- type: 'object',
25
- additionalProperties: false,
26
- required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
27
- properties: {
28
- ${type === 'mongodb' ? '_id' : 'id'}: {
29
- type: '${type === 'mongodb' ? 'string' : 'number'}'
30
- },
31
- text: {
32
- type: 'string'
33
- }
34
- }
35
- } as const
36
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
37
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
38
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({})
39
-
40
- // Schema for creating new data
41
- export const ${camelName}DataSchema = {
42
- $id: '${upperName}Data',
43
- type: 'object',
44
- additionalProperties: false,
45
- required: [ 'text' ],
46
- properties: {
47
- text: {
48
- type: 'string'
49
- }
50
- }
51
- } as const
52
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
53
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
54
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({})
55
-
56
- // Schema for updating existing data
57
- export const ${camelName}PatchSchema = {
58
- $id: '${upperName}Patch',
59
- type: 'object',
60
- additionalProperties: false,
61
- required: [],
62
- properties: {
63
- ...${camelName}Schema.properties
64
- }
65
- } as const
66
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
67
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
68
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({})
69
-
70
- // Schema for allowed query properties
71
- export const ${camelName}QuerySchema = {
72
- $id: '${upperName}Query',
73
- type: 'object',
74
- additionalProperties: false,
75
- properties: {
76
- ...querySyntax(${camelName}Schema.properties)
77
- }
78
- } as const
79
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
80
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
81
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({})
82
- `
83
-
84
- export const generate = (ctx: ServiceGeneratorContext) =>
85
- generator(ctx).then(
86
- when<ServiceGeneratorContext>(
87
- ({ schema }) => schema === 'json',
88
- renderSource(
89
- template,
90
- toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
91
- lib,
92
- 'services',
93
- ...folder,
94
- `${fileName}.schema`
95
- ])
96
- )
97
- )
98
- )
@@ -1,2 +0,0 @@
1
- import { ServiceGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;