@feathersjs/cli 5.0.0-pre.33 → 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 (175) hide show
  1. package/CHANGELOG.md +27 -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 +30 -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 -227
  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 -48
  13. package/lib/app/templates/app.test.tpl.js.map +0 -1
  14. package/lib/app/templates/app.test.tpl.ts +0 -47
  15. package/lib/app/templates/app.tpl.d.ts +0 -2
  16. package/lib/app/templates/app.tpl.js +0 -121
  17. package/lib/app/templates/app.tpl.js.map +0 -1
  18. package/lib/app/templates/app.tpl.ts +0 -136
  19. package/lib/app/templates/channels.tpl.d.ts +0 -2
  20. package/lib/app/templates/channels.tpl.js +0 -48
  21. package/lib/app/templates/channels.tpl.js.map +0 -1
  22. package/lib/app/templates/channels.tpl.ts +0 -54
  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 -37
  29. package/lib/app/templates/client.tpl.js.map +0 -1
  30. package/lib/app/templates/client.tpl.ts +0 -44
  31. package/lib/app/templates/config.tpl.d.ts +0 -2
  32. package/lib/app/templates/config.tpl.js +0 -30
  33. package/lib/app/templates/config.tpl.js.map +0 -1
  34. package/lib/app/templates/config.tpl.ts +0 -31
  35. package/lib/app/templates/declarations.tpl.d.ts +0 -2
  36. package/lib/app/templates/declarations.tpl.js +0 -27
  37. package/lib/app/templates/declarations.tpl.js.map +0 -1
  38. package/lib/app/templates/declarations.tpl.ts +0 -36
  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 -2
  48. package/lib/app/templates/logger.tpl.js +0 -39
  49. package/lib/app/templates/logger.tpl.js.map +0 -1
  50. package/lib/app/templates/logger.tpl.ts +0 -44
  51. package/lib/app/templates/package.json.tpl.d.ts +0 -2
  52. package/lib/app/templates/package.json.tpl.js +0 -55
  53. package/lib/app/templates/package.json.tpl.js.map +0 -1
  54. package/lib/app/templates/package.json.tpl.ts +0 -68
  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/schemas.tpl.d.ts +0 -2
  64. package/lib/app/templates/schemas.tpl.js +0 -75
  65. package/lib/app/templates/schemas.tpl.js.map +0 -1
  66. package/lib/app/templates/schemas.tpl.ts +0 -89
  67. package/lib/app/templates/services.tpl.d.ts +0 -2
  68. package/lib/app/templates/services.tpl.js +0 -14
  69. package/lib/app/templates/services.tpl.js.map +0 -1
  70. package/lib/app/templates/services.tpl.ts +0 -18
  71. package/lib/app/templates/tsconfig.json.tpl.d.ts +0 -2
  72. package/lib/app/templates/tsconfig.json.tpl.js +0 -22
  73. package/lib/app/templates/tsconfig.json.tpl.js.map +0 -1
  74. package/lib/app/templates/tsconfig.json.tpl.ts +0 -28
  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 -39
  81. package/lib/authentication/templates/authentication.tpl.js.map +0 -1
  82. package/lib/authentication/templates/authentication.tpl.ts +0 -50
  83. package/lib/authentication/templates/client.test.tpl.d.ts +0 -2
  84. package/lib/authentication/templates/client.test.tpl.js +0 -61
  85. package/lib/authentication/templates/client.test.tpl.js.map +0 -1
  86. package/lib/authentication/templates/client.test.tpl.ts +0 -73
  87. package/lib/authentication/templates/client.tpl.d.ts +0 -2
  88. package/lib/authentication/templates/client.tpl.js +0 -14
  89. package/lib/authentication/templates/client.tpl.js.map +0 -1
  90. package/lib/authentication/templates/client.tpl.ts +0 -19
  91. package/lib/authentication/templates/config.tpl.d.ts +0 -2
  92. package/lib/authentication/templates/config.tpl.js +0 -50
  93. package/lib/authentication/templates/config.tpl.js.map +0 -1
  94. package/lib/authentication/templates/config.tpl.ts +0 -57
  95. package/lib/authentication/templates/declarations.tpl.d.ts +0 -2
  96. package/lib/authentication/templates/declarations.tpl.js +0 -19
  97. package/lib/authentication/templates/declarations.tpl.js.map +0 -1
  98. package/lib/authentication/templates/declarations.tpl.ts +0 -34
  99. package/lib/authentication/templates/knex.tpl.d.ts +0 -2
  100. package/lib/authentication/templates/knex.tpl.js +0 -45
  101. package/lib/authentication/templates/knex.tpl.js.map +0 -1
  102. package/lib/authentication/templates/knex.tpl.ts +0 -62
  103. package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
  104. package/lib/authentication/templates/schema.json.tpl.js +0 -93
  105. package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
  106. package/lib/authentication/templates/schema.json.tpl.ts +0 -108
  107. package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
  108. package/lib/authentication/templates/schema.typebox.tpl.js +0 -78
  109. package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
  110. package/lib/authentication/templates/schema.typebox.tpl.ts +0 -94
  111. package/lib/cli.d.ts +0 -6
  112. package/lib/cli.js +0 -75
  113. package/lib/cli.js.map +0 -1
  114. package/lib/cli.ts +0 -68
  115. package/lib/commons.d.ts +0 -143
  116. package/lib/commons.js +0 -190
  117. package/lib/commons.js.map +0 -1
  118. package/lib/commons.ts +0 -276
  119. package/lib/connection/index.d.ts +0 -55
  120. package/lib/connection/index.js +0 -88
  121. package/lib/connection/index.js.map +0 -1
  122. package/lib/connection/index.ts +0 -123
  123. package/lib/connection/templates/knex.tpl.d.ts +0 -2
  124. package/lib/connection/templates/knex.tpl.js +0 -46
  125. package/lib/connection/templates/knex.tpl.js.map +0 -1
  126. package/lib/connection/templates/knex.tpl.ts +0 -63
  127. package/lib/connection/templates/mongodb.tpl.d.ts +0 -2
  128. package/lib/connection/templates/mongodb.tpl.js +0 -33
  129. package/lib/connection/templates/mongodb.tpl.js.map +0 -1
  130. package/lib/connection/templates/mongodb.tpl.ts +0 -38
  131. package/lib/hook/index.d.ts +0 -22
  132. package/lib/hook/index.js +0 -43
  133. package/lib/hook/index.js.map +0 -1
  134. package/lib/hook/index.ts +0 -47
  135. package/lib/hook/templates/hook.tpl.d.ts +0 -2
  136. package/lib/hook/templates/hook.tpl.js +0 -20
  137. package/lib/hook/templates/hook.tpl.js.map +0 -1
  138. package/lib/hook/templates/hook.tpl.ts +0 -31
  139. package/lib/index.ts +0 -2
  140. package/lib/service/index.d.ts +0 -64
  141. package/lib/service/index.js +0 -116
  142. package/lib/service/index.js.map +0 -1
  143. package/lib/service/index.ts +0 -191
  144. package/lib/service/templates/client.tpl.d.ts +0 -2
  145. package/lib/service/templates/client.tpl.js +0 -31
  146. package/lib/service/templates/client.tpl.js.map +0 -1
  147. package/lib/service/templates/client.tpl.ts +0 -57
  148. package/lib/service/templates/schema.json.tpl.d.ts +0 -2
  149. package/lib/service/templates/schema.json.tpl.js +0 -75
  150. package/lib/service/templates/schema.json.tpl.js.map +0 -1
  151. package/lib/service/templates/schema.json.tpl.ts +0 -87
  152. package/lib/service/templates/schema.typebox.tpl.d.ts +0 -2
  153. package/lib/service/templates/schema.typebox.tpl.js +0 -55
  154. package/lib/service/templates/schema.typebox.tpl.js.map +0 -1
  155. package/lib/service/templates/schema.typebox.tpl.ts +0 -67
  156. package/lib/service/templates/service.tpl.d.ts +0 -3
  157. package/lib/service/templates/service.tpl.js +0 -98
  158. package/lib/service/templates/service.tpl.js.map +0 -1
  159. package/lib/service/templates/service.tpl.ts +0 -134
  160. package/lib/service/templates/test.tpl.d.ts +0 -2
  161. package/lib/service/templates/test.tpl.js +0 -24
  162. package/lib/service/templates/test.tpl.js.map +0 -1
  163. package/lib/service/templates/test.tpl.ts +0 -28
  164. package/lib/service/type/custom.tpl.d.ts +0 -3
  165. package/lib/service/type/custom.tpl.js +0 -94
  166. package/lib/service/type/custom.tpl.js.map +0 -1
  167. package/lib/service/type/custom.tpl.ts +0 -99
  168. package/lib/service/type/knex.tpl.d.ts +0 -3
  169. package/lib/service/type/knex.tpl.js +0 -67
  170. package/lib/service/type/knex.tpl.js.map +0 -1
  171. package/lib/service/type/knex.tpl.ts +0 -88
  172. package/lib/service/type/mongodb.tpl.d.ts +0 -3
  173. package/lib/service/type/mongodb.tpl.js +0 -47
  174. package/lib/service/type/mongodb.tpl.js.map +0 -1
  175. package/lib/service/type/mongodb.tpl.ts +0 -59
@@ -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 declare 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,CA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AAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,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.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAC3E,2CAA4C;AAG5C,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACe,EAAE,EAAE,CAAC,QAAQ,CAAC;IACpC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;qBACQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ;;IAE7C,SAAS;IACT,SAAS;IACT,SAAS;;CAEZ,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAA2B,EAAE,EAAE,CAAC;QACxF,SAAS;OACV,SAAS,wBAAwB,SAAS,GAC/C,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,SAAS,SAAS,CAAC,CAAC,CAAC,EACtD,YAAY,SAAS,yBAAyB,CAAA;AAE9C,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC3E,MAAM,IAAI,MAAM,SAAS,eAAe,CAAA;AAE1C,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,IAAI,EACoB,EAAE,EAAE,CAAC,iBAAiB,IAAI,0BAA0B,IAAI;aACrE,SAAS;GACnB,CAAA;AAEH,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,oBAAoB,EAAE,IAAA,eAAM,EAAC,eAAe,CAAC,EAAE,YAAY,CAAC,CAAC;KAC/E,IAAI,CACH,IAAA,aAAI,EACF,CAAC,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,75 +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 }) => /* ts */ `import { resolve, getDataValidator, getValidator, querySyntax } from '@feathersjs/schema'
7
- import type { FromSchema } from '@feathersjs/schema'
8
-
9
- import type { HookContext } from '${relative}/declarations'
10
- import { dataValidator, queryValidator } from '${relative}/schemas/validators'
11
-
12
- // Main data model schema
13
- export const ${camelName}Schema = {
14
- $id: '${upperName}',
15
- type: 'object',
16
- additionalProperties: false,
17
- required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
18
- properties: {
19
- ${type === 'mongodb' ? '_id' : 'id'}: {
20
- type: '${type === 'mongodb' ? 'string' : 'number'}'
21
- },
22
- text: {
23
- type: 'string'
24
- }
25
- }
26
- } as const
27
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
28
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
29
- properties: {}
30
- })
31
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
32
- properties: {}
33
- })
34
-
35
- // Schema for creating new data
36
- export const ${camelName}DataSchema = {
37
- $id: '${upperName}Data',
38
- type: 'object',
39
- additionalProperties: false,
40
- required: [ 'text' ],
41
- properties: {
42
- text: {
43
- type: 'string'
44
- }
45
- }
46
- } as const
47
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
48
- export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
49
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
50
- properties: {}
51
- })
52
-
53
- // Schema for allowed query properties
54
- export const ${camelName}QuerySchema = {
55
- $id: '${upperName}Query',
56
- type: 'object',
57
- additionalProperties: false,
58
- properties: {
59
- ...querySyntax(${camelName}Schema.properties)
60
- }
61
- } as const
62
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
63
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
64
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
65
- properties: {}
66
- })
67
- `;
68
- 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 }) => [
69
- lib,
70
- 'services',
71
- ...folder,
72
- `${fileName}.schema`
73
- ]))));
74
- exports.generate = generate;
75
- //# 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,2CAA4C;AA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ion'
2
- import { renderSource } from '../../commons'
3
- import { ServiceGeneratorContext } from '../index'
4
-
5
- const template = ({
6
- camelName,
7
- upperName,
8
- relative,
9
- type
10
- }: ServiceGeneratorContext) => /* ts */ `import { resolve, getDataValidator, getValidator, querySyntax } from '@feathersjs/schema'
11
- import type { FromSchema } from '@feathersjs/schema'
12
-
13
- import type { HookContext } from '${relative}/declarations'
14
- import { dataValidator, queryValidator } from '${relative}/schemas/validators'
15
-
16
- // Main data model schema
17
- export const ${camelName}Schema = {
18
- $id: '${upperName}',
19
- type: 'object',
20
- additionalProperties: false,
21
- required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
22
- properties: {
23
- ${type === 'mongodb' ? '_id' : 'id'}: {
24
- type: '${type === 'mongodb' ? 'string' : 'number'}'
25
- },
26
- text: {
27
- type: 'string'
28
- }
29
- }
30
- } as const
31
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
32
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
33
- properties: {}
34
- })
35
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
36
- properties: {}
37
- })
38
-
39
- // Schema for creating new data
40
- export const ${camelName}DataSchema = {
41
- $id: '${upperName}Data',
42
- type: 'object',
43
- additionalProperties: false,
44
- required: [ 'text' ],
45
- properties: {
46
- text: {
47
- type: 'string'
48
- }
49
- }
50
- } as const
51
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
52
- export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
53
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
54
- properties: {}
55
- })
56
-
57
- // Schema for allowed query properties
58
- export const ${camelName}QuerySchema = {
59
- $id: '${upperName}Query',
60
- type: 'object',
61
- additionalProperties: false,
62
- properties: {
63
- ...querySyntax(${camelName}Schema.properties)
64
- }
65
- } as const
66
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
67
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
68
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
69
- properties: {}
70
- })
71
- `
72
-
73
- export const generate = (ctx: ServiceGeneratorContext) =>
74
- generator(ctx).then(
75
- when<ServiceGeneratorContext>(
76
- ({ schema }) => schema === 'json',
77
- renderSource(
78
- template,
79
- toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
80
- lib,
81
- 'services',
82
- ...folder,
83
- `${fileName}.schema`
84
- ])
85
- )
86
- )
87
- )
@@ -1,2 +0,0 @@
1
- import { ServiceGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;