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

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 (152) hide show
  1. package/CHANGELOG.md +25 -39
  2. package/bin/feathers +3 -6
  3. package/lib/app/index.js +33 -10
  4. package/lib/app/index.js.map +1 -1
  5. package/lib/app/index.ts +81 -53
  6. package/lib/app/templates/app.test.tpl.js +1 -1
  7. package/lib/app/templates/app.test.tpl.js.map +1 -1
  8. package/lib/app/templates/app.test.tpl.ts +1 -2
  9. package/lib/app/templates/app.tpl.js +7 -7
  10. package/lib/app/templates/app.tpl.js.map +1 -1
  11. package/lib/app/templates/app.tpl.ts +7 -9
  12. package/lib/app/templates/channels.tpl.js +1 -1
  13. package/lib/app/templates/channels.tpl.js.map +1 -1
  14. package/lib/app/templates/channels.tpl.ts +1 -2
  15. package/lib/app/templates/client.tpl.js +2 -2
  16. package/lib/app/templates/client.tpl.js.map +1 -1
  17. package/lib/app/templates/client.tpl.ts +2 -3
  18. package/lib/app/templates/declarations.tpl.js +3 -3
  19. package/lib/app/templates/declarations.tpl.js.map +1 -1
  20. package/lib/app/templates/declarations.tpl.ts +5 -4
  21. package/lib/app/templates/index.html.tpl.js +12 -52
  22. package/lib/app/templates/index.html.tpl.js.map +1 -1
  23. package/lib/app/templates/index.html.tpl.ts +12 -53
  24. package/lib/app/templates/index.tpl.js +1 -1
  25. package/lib/app/templates/index.tpl.js.map +1 -1
  26. package/lib/app/templates/index.tpl.ts +1 -2
  27. package/lib/app/templates/logger.tpl.js +1 -1
  28. package/lib/app/templates/logger.tpl.js.map +1 -1
  29. package/lib/app/templates/logger.tpl.ts +2 -2
  30. package/lib/app/templates/package.json.tpl.js +4 -3
  31. package/lib/app/templates/package.json.tpl.js.map +1 -1
  32. package/lib/app/templates/package.json.tpl.ts +5 -3
  33. package/lib/app/templates/readme.md.tpl.js +11 -7
  34. package/lib/app/templates/readme.md.tpl.js.map +1 -1
  35. package/lib/app/templates/readme.md.tpl.ts +15 -8
  36. package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
  37. package/lib/app/templates/schemas.tpl.js +76 -0
  38. package/lib/app/templates/schemas.tpl.js.map +1 -0
  39. package/lib/app/templates/schemas.tpl.ts +90 -0
  40. package/lib/app/templates/services.tpl.js +1 -1
  41. package/lib/app/templates/services.tpl.js.map +1 -1
  42. package/lib/app/templates/services.tpl.ts +1 -2
  43. package/lib/authentication/index.d.ts +4 -3
  44. package/lib/authentication/index.js +12 -3
  45. package/lib/authentication/index.js.map +1 -1
  46. package/lib/authentication/index.ts +23 -5
  47. package/lib/authentication/templates/authentication.tpl.js +1 -1
  48. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  49. package/lib/authentication/templates/authentication.tpl.ts +3 -2
  50. package/lib/authentication/templates/config.tpl.js +1 -1
  51. package/lib/authentication/templates/config.tpl.js.map +1 -1
  52. package/lib/authentication/templates/config.tpl.ts +1 -1
  53. package/lib/authentication/templates/declarations.tpl.js +3 -3
  54. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  55. package/lib/authentication/templates/declarations.tpl.ts +9 -4
  56. package/lib/authentication/templates/knex.tpl.js +2 -2
  57. package/lib/authentication/templates/knex.tpl.js.map +1 -1
  58. package/lib/authentication/templates/knex.tpl.ts +2 -2
  59. package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  60. package/lib/authentication/templates/schema.json.tpl.js +92 -0
  61. package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
  62. package/lib/authentication/templates/schema.json.tpl.ts +108 -0
  63. package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
  64. package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
  65. package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
  66. package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
  67. package/lib/authentication/templates/test.tpl.js +2 -2
  68. package/lib/authentication/templates/test.tpl.js.map +1 -1
  69. package/lib/authentication/templates/test.tpl.ts +6 -3
  70. package/lib/cli.d.ts +6 -0
  71. package/lib/cli.js +75 -0
  72. package/lib/cli.js.map +1 -0
  73. package/lib/cli.ts +68 -0
  74. package/lib/commons.d.ts +14 -1
  75. package/lib/commons.js +24 -4
  76. package/lib/commons.js.map +1 -1
  77. package/lib/commons.ts +29 -1
  78. package/lib/connection/index.d.ts +5 -3
  79. package/lib/connection/index.js +5 -3
  80. package/lib/connection/index.js.map +1 -1
  81. package/lib/connection/index.ts +19 -5
  82. package/lib/connection/templates/knex.tpl.js +2 -12
  83. package/lib/connection/templates/knex.tpl.js.map +1 -1
  84. package/lib/connection/templates/knex.tpl.ts +6 -20
  85. package/lib/connection/templates/mongodb.tpl.js +1 -3
  86. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  87. package/lib/connection/templates/mongodb.tpl.ts +1 -12
  88. package/lib/hook/index.d.ts +1 -1
  89. package/lib/hook/index.js +3 -0
  90. package/lib/hook/index.js.map +1 -1
  91. package/lib/hook/index.ts +3 -1
  92. package/lib/hook/templates/hook.tpl.js +2 -3
  93. package/lib/hook/templates/hook.tpl.js.map +1 -1
  94. package/lib/hook/templates/hook.tpl.ts +5 -3
  95. package/lib/index.d.ts +2 -16
  96. package/lib/index.js +16 -24
  97. package/lib/index.js.map +1 -1
  98. package/lib/index.ts +2 -28
  99. package/lib/service/index.d.ts +10 -2
  100. package/lib/service/index.js +79 -41
  101. package/lib/service/index.js.map +1 -1
  102. package/lib/service/index.ts +54 -6
  103. package/lib/service/templates/client.tpl.js +19 -11
  104. package/lib/service/templates/client.tpl.js.map +1 -1
  105. package/lib/service/templates/client.tpl.ts +34 -17
  106. package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  107. package/lib/service/templates/schema.json.tpl.js +73 -0
  108. package/lib/service/templates/schema.json.tpl.js.map +1 -0
  109. package/lib/service/templates/schema.json.tpl.ts +85 -0
  110. package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
  111. package/lib/service/templates/schema.typebox.tpl.js +58 -0
  112. package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
  113. package/lib/service/templates/schema.typebox.tpl.ts +70 -0
  114. package/lib/service/templates/service.tpl.d.ts +1 -0
  115. package/lib/service/templates/service.tpl.js +67 -15
  116. package/lib/service/templates/service.tpl.js.map +1 -1
  117. package/lib/service/templates/service.tpl.ts +98 -19
  118. package/lib/service/templates/test.tpl.js +1 -1
  119. package/lib/service/templates/test.tpl.js.map +1 -1
  120. package/lib/service/templates/test.tpl.ts +1 -2
  121. package/lib/service/type/custom.tpl.d.ts +1 -2
  122. package/lib/service/type/custom.tpl.js +32 -25
  123. package/lib/service/type/custom.tpl.js.map +1 -1
  124. package/lib/service/type/custom.tpl.ts +44 -35
  125. package/lib/service/type/knex.tpl.d.ts +1 -3
  126. package/lib/service/type/knex.tpl.js +33 -23
  127. package/lib/service/type/knex.tpl.js.map +1 -1
  128. package/lib/service/type/knex.tpl.ts +51 -29
  129. package/lib/service/type/mongodb.tpl.d.ts +1 -2
  130. package/lib/service/type/mongodb.tpl.js +30 -20
  131. package/lib/service/type/mongodb.tpl.js.map +1 -1
  132. package/lib/service/type/mongodb.tpl.ts +47 -29
  133. package/package.json +22 -23
  134. package/lib/app/templates/configuration.tpl.js +0 -45
  135. package/lib/app/templates/configuration.tpl.js.map +0 -1
  136. package/lib/app/templates/configuration.tpl.ts +0 -50
  137. package/lib/authentication/templates/user.resolver.tpl.js +0 -98
  138. package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
  139. package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
  140. package/lib/authentication/templates/user.schema.tpl.js +0 -79
  141. package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
  142. package/lib/authentication/templates/user.schema.tpl.ts +0 -87
  143. package/lib/service/templates/class.tpl.js +0 -63
  144. package/lib/service/templates/class.tpl.js.map +0 -1
  145. package/lib/service/templates/class.tpl.ts +0 -79
  146. package/lib/service/templates/resolver.tpl.js +0 -73
  147. package/lib/service/templates/resolver.tpl.js.map +0 -1
  148. package/lib/service/templates/resolver.tpl.ts +0 -78
  149. package/lib/service/templates/schema.tpl.d.ts +0 -2
  150. package/lib/service/templates/schema.tpl.js +0 -75
  151. package/lib/service/templates/schema.tpl.js.map +0 -1
  152. package/lib/service/templates/schema.tpl.ts +0 -80
@@ -1,35 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = exports.classCode = exports.importTemplate = void 0;
3
+ exports.generate = exports.template = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- exports.importTemplate = `import { MongoDBService } from \'@feathersjs/mongodb\'
7
- import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'`;
8
- const classCode = ({ className, upperName }) => `export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
6
+ const template = ({ className, upperName, kebabName, schema, fileName, relative }) => /* ts */ `import { MongoDBService } from \'@feathersjs/mongodb\'
7
+ import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'
8
+
9
+ import type { Application } from '${relative}/declarations'
10
+ ${schema
11
+ ? `import type {
12
+ ${upperName},
13
+ ${upperName}Data,
14
+ ${upperName}Query
15
+ } from './${fileName}.schema'
16
+ `
17
+ : `
18
+ export type ${upperName} = any
19
+ export type ${upperName}Data = any
20
+ export type ${upperName}Query = any
21
+ `}
22
+
23
+ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
9
24
  }
10
25
 
11
26
  // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
12
- export class ${className} extends MongoDBService<${upperName}Result, ${upperName}Data, ${upperName}Params> {
27
+ export class ${className} extends MongoDBService<${upperName}, ${upperName}Data, ${upperName}Params> {
28
+ }
29
+
30
+ export const getOptions = (app: Application) => {
31
+ return {
32
+ paginate: app.get('paginate'),
33
+ Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))
34
+ }
13
35
  }
14
36
  `;
15
- exports.classCode = classCode;
16
- const optionTemplate = ({ kebabName }) => ` paginate: app.get('paginate'),
17
- Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))`;
18
- const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
19
- lib,
20
- 'services',
21
- ...folder,
22
- `${fileName}.service`
23
- ]);
24
- const toClassFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
37
+ exports.template = template;
38
+ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
25
39
  lib,
26
40
  'services',
27
41
  ...folder,
28
42
  `${fileName}.class`
29
- ]);
30
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
31
- .then((0, commons_1.injectSource)(exports.classCode, (0, pinion_1.append)(), toClassFile))
32
- .then((0, commons_1.injectSource)(exports.importTemplate, (0, pinion_1.prepend)(), toClassFile))
33
- .then((0, commons_1.injectSource)(optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile, false));
43
+ ])));
34
44
  exports.generate = generate;
35
45
  //# sourceMappingURL=mongodb.tpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/service/type/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,2CAA4C;AAG/B,QAAA,cAAc,GAAG;kEACoC,CAAA;AAE3D,MAAM,SAAS,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC7E,oBAAoB,SAAS,uCAAuC,SAAS;;;;eAIhE,SAAS,2BAA2B,SAAS,WAAW,SAAS,SAAS,SAAS;;CAEjG,CAAA;AAPY,QAAA,SAAS,aAOrB;AAED,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAChE;gE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AS;cACT,SAAS;CAEvB;;mBAEmB,SAAS,uCAAuC,SAAS;;;;eAI7D,SAAS,2BAA2B,SAAS,KAAK,SAAS,SAAS,SAAS;;;;;;gEAM5B,SAAS;;;CAGxE,CAAA;AAvCY,QAAA,QAAQ,YAuCpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -1,39 +1,57 @@
1
- import { generator, toFile, after, prepend, append } from '@feathershq/pinion'
2
- import { injectSource } from '../../commons'
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
3
  import { ServiceGeneratorContext } from '../index'
4
4
 
5
- export const importTemplate = `import { MongoDBService } from \'@feathersjs/mongodb\'
6
- import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'`
5
+ export const template = ({
6
+ className,
7
+ upperName,
8
+ kebabName,
9
+ schema,
10
+ fileName,
11
+ relative
12
+ }: ServiceGeneratorContext) => /* ts */ `import { MongoDBService } from \'@feathersjs/mongodb\'
13
+ import type { MongoDBAdapterParams } from \'@feathersjs/mongodb\'
7
14
 
8
- export const classCode = ({ className, upperName }: ServiceGeneratorContext) =>
9
- `export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
15
+ import type { Application } from '${relative}/declarations'
16
+ ${
17
+ schema
18
+ ? `import type {
19
+ ${upperName},
20
+ ${upperName}Data,
21
+ ${upperName}Query
22
+ } from './${fileName}.schema'
23
+ `
24
+ : `
25
+ export type ${upperName} = any
26
+ export type ${upperName}Data = any
27
+ export type ${upperName}Query = any
28
+ `
10
29
  }
11
30
 
12
- // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
13
- export class ${className} extends MongoDBService<${upperName}Result, ${upperName}Data, ${upperName}Params> {
31
+ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
14
32
  }
15
- `
16
-
17
- const optionTemplate = ({ kebabName }: ServiceGeneratorContext) =>
18
- ` paginate: app.get('paginate'),
19
- Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))`
20
33
 
21
- const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
22
- lib,
23
- 'services',
24
- ...folder,
25
- `${fileName}.service`
26
- ])
34
+ // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
35
+ export class ${className} extends MongoDBService<${upperName}, ${upperName}Data, ${upperName}Params> {
36
+ }
27
37
 
28
- const toClassFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
29
- lib,
30
- 'services',
31
- ...folder,
32
- `${fileName}.class`
33
- ])
38
+ export const getOptions = (app: Application) => {
39
+ return {
40
+ paginate: app.get('paginate'),
41
+ Model: app.get('mongodbClient').then(db => db.collection('${kebabName}'))
42
+ }
43
+ }
44
+ `
34
45
 
35
46
  export const generate = (ctx: ServiceGeneratorContext) =>
36
- generator(ctx)
37
- .then(injectSource(classCode, append(), toClassFile))
38
- .then(injectSource(importTemplate, prepend(), toClassFile))
39
- .then(injectSource(optionTemplate, after('const options ='), toServiceFile, false))
47
+ generator(ctx).then(
48
+ renderSource(
49
+ template,
50
+ toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
51
+ lib,
52
+ 'services',
53
+ ...folder,
54
+ `${fileName}.class`
55
+ ])
56
+ )
57
+ )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@feathersjs/cli",
3
3
  "description": "The command line interface for creating Feathers applications",
4
- "version": "5.0.0-pre.29",
4
+ "version": "5.0.0-pre.30",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "main": "lib/",
7
7
  "bin": {
@@ -47,41 +47,40 @@
47
47
  "mocha": "mocha --timeout 60000 --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
48
48
  "test": "npm run compile && npm run mocha"
49
49
  },
50
- "directories": {
51
- "lib": "lib/cli"
52
- },
53
50
  "publishConfig": {
54
51
  "access": "public"
55
52
  },
56
53
  "dependencies": {
57
54
  "@feathershq/pinion": "^0.3.5",
58
55
  "chalk": "^4.0.1",
56
+ "commander": "^9.4.1",
59
57
  "lodash": "^4.17.21",
60
58
  "prettier": "^2.7.1"
61
59
  },
62
60
  "devDependencies": {
63
- "@feathersjs/authentication": "^5.0.0-pre.29",
64
- "@feathersjs/authentication-local": "^5.0.0-pre.29",
65
- "@feathersjs/authentication-oauth": "^5.0.0-pre.29",
66
- "@feathersjs/configuration": "^5.0.0-pre.29",
67
- "@feathersjs/errors": "^5.0.0-pre.29",
68
- "@feathersjs/express": "^5.0.0-pre.29",
69
- "@feathersjs/feathers": "^5.0.0-pre.29",
70
- "@feathersjs/knex": "^5.0.0-pre.29",
71
- "@feathersjs/koa": "^5.0.0-pre.29",
72
- "@feathersjs/mongodb": "^5.0.0-pre.29",
73
- "@feathersjs/schema": "^5.0.0-pre.29",
74
- "@feathersjs/socketio": "^5.0.0-pre.29",
75
- "@feathersjs/transport-commons": "^5.0.0-pre.29",
76
- "@types/mocha": "^9.1.1",
77
- "@types/node": "^18.7.17",
78
- "@types/prettier": "^2.7.0",
61
+ "@feathersjs/authentication": "^5.0.0-pre.30",
62
+ "@feathersjs/authentication-local": "^5.0.0-pre.30",
63
+ "@feathersjs/authentication-oauth": "^5.0.0-pre.30",
64
+ "@feathersjs/configuration": "^5.0.0-pre.30",
65
+ "@feathersjs/errors": "^5.0.0-pre.30",
66
+ "@feathersjs/express": "^5.0.0-pre.30",
67
+ "@feathersjs/feathers": "^5.0.0-pre.30",
68
+ "@feathersjs/knex": "^5.0.0-pre.30",
69
+ "@feathersjs/koa": "^5.0.0-pre.30",
70
+ "@feathersjs/mongodb": "^5.0.0-pre.30",
71
+ "@feathersjs/schema": "^5.0.0-pre.30",
72
+ "@feathersjs/socketio": "^5.0.0-pre.30",
73
+ "@feathersjs/transport-commons": "^5.0.0-pre.30",
74
+ "@feathersjs/typebox": "^5.0.0-pre.30",
75
+ "@types/mocha": "^10.0.0",
76
+ "@types/node": "^18.8.2",
77
+ "@types/prettier": "^2.7.1",
79
78
  "axios": "^0.27.2",
80
79
  "mocha": "^10.0.0",
81
80
  "shx": "^0.3.4",
82
81
  "ts-node": "^10.9.1",
83
- "type-fest": "^2.19.0",
84
- "typescript": "^4.8.3"
82
+ "type-fest": "^3.0.0",
83
+ "typescript": "^4.8.4"
85
84
  },
86
- "gitHead": "4314dc89a41a8bbaabf00b47697bf7887861d17d"
85
+ "gitHead": "b535c91197f4b997520e0a0e608793eeba791931"
87
86
  }
@@ -1,45 +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 = ({}) => `import { schema, Ajv } from '@feathersjs/schema'
7
- import type { Infer } from '@feathersjs/schema'
8
- import { authenticationSettingsSchema } from '@feathersjs/authentication'
9
-
10
- export const configurationSchema = schema(
11
- {
12
- $id: 'ApplicationConfiguration',
13
- type: 'object',
14
- additionalProperties: false,
15
- required: [ 'host', 'port', 'public', 'paginate' ],
16
- properties: {
17
- host: { type: 'string' },
18
- port: { type: 'number' },
19
- public: { type: 'string' },
20
- authentication: authenticationSettingsSchema,
21
- origins: {
22
- type: 'array',
23
- items: {
24
- type: 'string'
25
- }
26
- },
27
- paginate: {
28
- type: 'object',
29
- additionalProperties: false,
30
- required: [ 'default', 'max' ],
31
- properties: {
32
- default: { type: 'number' },
33
- max: { type: 'number' }
34
- }
35
- }
36
- }
37
- } as const,
38
- new Ajv()
39
- )
40
-
41
- export type ConfigurationSchema = Infer<typeof configurationSchema>
42
- `;
43
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'configuration')));
44
- exports.generate = generate;
45
- //# sourceMappingURL=configuration.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/configuration.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,CAC/D,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
@@ -1,50 +0,0 @@
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { renderSource } from '../../commons'
3
- import { AppGeneratorContext } from '../index'
4
-
5
- const template = ({}: AppGeneratorContext) =>
6
- `import { schema, Ajv } from '@feathersjs/schema'
7
- import type { Infer } from '@feathersjs/schema'
8
- import { authenticationSettingsSchema } from '@feathersjs/authentication'
9
-
10
- export const configurationSchema = schema(
11
- {
12
- $id: 'ApplicationConfiguration',
13
- type: 'object',
14
- additionalProperties: false,
15
- required: [ 'host', 'port', 'public', 'paginate' ],
16
- properties: {
17
- host: { type: 'string' },
18
- port: { type: 'number' },
19
- public: { type: 'string' },
20
- authentication: authenticationSettingsSchema,
21
- origins: {
22
- type: 'array',
23
- items: {
24
- type: 'string'
25
- }
26
- },
27
- paginate: {
28
- type: 'object',
29
- additionalProperties: false,
30
- required: [ 'default', 'max' ],
31
- properties: {
32
- default: { type: 'number' },
33
- max: { type: 'number' }
34
- }
35
- }
36
- }
37
- } as const,
38
- new Ajv()
39
- )
40
-
41
- export type ConfigurationSchema = Infer<typeof configurationSchema>
42
- `
43
-
44
- export const generate = (ctx: AppGeneratorContext) =>
45
- generator(ctx).then(
46
- renderSource(
47
- template,
48
- toFile<AppGeneratorContext>(({ lib }) => lib, 'configuration')
49
- )
50
- )
@@ -1,98 +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, authStrategies, type, fileName }) => `import { resolve } from '@feathersjs/schema'
7
- ${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
8
- import type { HookContext } from '${relative}/declarations'
9
- import type {
10
- ${upperName}Data,
11
- ${upperName}Patch,
12
- ${upperName}Result,
13
- ${upperName}Query,
14
- } from './${fileName}.schema'
15
- import {
16
- ${camelName}DataSchema,
17
- ${camelName}PatchSchema,
18
- ${camelName}ResultSchema,
19
- ${camelName}QuerySchema
20
- } from './${fileName}.schema'
21
-
22
-
23
- // Resolver for the basic data model (e.g. creating new entries)
24
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
25
- schema: ${camelName}DataSchema,
26
- validate: 'before',
27
- properties: {
28
- ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
29
- }
30
- })
31
-
32
-
33
- // Resolver for making partial updates
34
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
35
- schema: ${camelName}PatchSchema,
36
- validate: 'before',
37
- properties: {
38
- ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
39
- }
40
- })
41
-
42
-
43
- // Resolver for the data that is being returned
44
- export const ${camelName}ResultResolver = resolve<${upperName}Result, HookContext>({
45
- schema: ${camelName}ResultSchema,
46
- validate: false,
47
- properties: {}
48
- })
49
-
50
-
51
- // Resolver for the "safe" version that external clients are allowed to see
52
- export const ${camelName}DispatchResolver = resolve<${upperName}Result, HookContext>({
53
- schema: ${camelName}ResultSchema,
54
- validate: false,
55
- properties: {
56
- // The password should never be visible externally
57
- password: async () => undefined
58
- }
59
- })
60
-
61
-
62
- // Resolver for allowed query properties
63
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
64
- schema: ${camelName}QuerySchema,
65
- validate: 'before',
66
- properties: {
67
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
68
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
69
- if (context.params.user) {
70
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
71
- }
72
-
73
- return value
74
- }
75
- }
76
- })
77
-
78
-
79
- // Export all resolvers in a format that can be used with the resolveAll hook
80
- export const ${camelName}Resolvers = {
81
- result: ${camelName}ResultResolver,
82
- dispatch: ${camelName}DispatchResolver,
83
- data: {
84
- create: ${camelName}DataResolver,
85
- update: ${camelName}DataResolver,
86
- patch: ${camelName}PatchResolver
87
- },
88
- query: ${camelName}QueryResolver
89
- }
90
- `;
91
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
92
- lib,
93
- 'services',
94
- ...folder,
95
- `${fileName}.resolver`
96
- ]), { force: true }));
97
- exports.generate = generate;
98
- //# sourceMappingURL=user.resolver.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.resolver.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/user.resolver.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CACnC;EACA,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iEAAiE,C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
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext } from '../index'
4
-
5
- const template = ({
6
- camelName,
7
- upperName,
8
- relative,
9
- authStrategies,
10
- type,
11
- fileName
12
- }: AuthenticationGeneratorContext) =>
13
- `import { resolve } from '@feathersjs/schema'
14
- ${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
15
- import type { HookContext } from '${relative}/declarations'
16
- import type {
17
- ${upperName}Data,
18
- ${upperName}Patch,
19
- ${upperName}Result,
20
- ${upperName}Query,
21
- } from './${fileName}.schema'
22
- import {
23
- ${camelName}DataSchema,
24
- ${camelName}PatchSchema,
25
- ${camelName}ResultSchema,
26
- ${camelName}QuerySchema
27
- } from './${fileName}.schema'
28
-
29
-
30
- // Resolver for the basic data model (e.g. creating new entries)
31
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
32
- schema: ${camelName}DataSchema,
33
- validate: 'before',
34
- properties: {
35
- ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
36
- }
37
- })
38
-
39
-
40
- // Resolver for making partial updates
41
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
42
- schema: ${camelName}PatchSchema,
43
- validate: 'before',
44
- properties: {
45
- ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
46
- }
47
- })
48
-
49
-
50
- // Resolver for the data that is being returned
51
- export const ${camelName}ResultResolver = resolve<${upperName}Result, HookContext>({
52
- schema: ${camelName}ResultSchema,
53
- validate: false,
54
- properties: {}
55
- })
56
-
57
-
58
- // Resolver for the "safe" version that external clients are allowed to see
59
- export const ${camelName}DispatchResolver = resolve<${upperName}Result, HookContext>({
60
- schema: ${camelName}ResultSchema,
61
- validate: false,
62
- properties: {
63
- // The password should never be visible externally
64
- password: async () => undefined
65
- }
66
- })
67
-
68
-
69
- // Resolver for allowed query properties
70
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
71
- schema: ${camelName}QuerySchema,
72
- validate: 'before',
73
- properties: {
74
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
75
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
76
- if (context.params.user) {
77
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
78
- }
79
-
80
- return value
81
- }
82
- }
83
- })
84
-
85
-
86
- // Export all resolvers in a format that can be used with the resolveAll hook
87
- export const ${camelName}Resolvers = {
88
- result: ${camelName}ResultResolver,
89
- dispatch: ${camelName}DispatchResolver,
90
- data: {
91
- create: ${camelName}DataResolver,
92
- update: ${camelName}DataResolver,
93
- patch: ${camelName}PatchResolver
94
- },
95
- query: ${camelName}QueryResolver
96
- }
97
- `
98
-
99
- export const generate = (ctx: AuthenticationGeneratorContext) =>
100
- generator(ctx).then(
101
- renderSource(
102
- template,
103
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
104
- lib,
105
- 'services',
106
- ...folder,
107
- `${fileName}.resolver`
108
- ]),
109
- { force: true }
110
- )
111
- )
@@ -1,79 +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, authStrategies, type }) => `import { schema, querySyntax } from '@feathersjs/schema'
7
- import type { Infer } from '@feathersjs/schema'
8
-
9
- // Schema for the basic data model (e.g. creating new entries)
10
- export const ${camelName}DataSchema = schema({
11
- $id: '${upperName}Data',
12
- type: 'object',
13
- additionalProperties: false,
14
- required: [ ${authStrategies.includes('local') ? "'email'" : ''} ],
15
- properties: {
16
- ${authStrategies
17
- .map((name) => name === 'local'
18
- ? ` email: { type: 'string' },
19
- password: { type: 'string' }`
20
- : ` ${name}Id: { type: 'string' }`)
21
- .join(',\n')}
22
- }
23
- } as const)
24
-
25
- export type ${upperName}Data = Infer<typeof ${camelName}DataSchema>
26
-
27
-
28
- // Schema for making partial updates
29
- export const ${camelName}PatchSchema = schema({
30
- $id: '${upperName}Patch',
31
- type: 'object',
32
- additionalProperties: false,
33
- required: [],
34
- properties: {
35
- ...${camelName}DataSchema.properties
36
- }
37
- } as const)
38
-
39
- export type ${upperName}Patch = Infer<typeof ${camelName}PatchSchema>
40
-
41
- // Schema for the data that is being returned
42
- export const ${camelName}ResultSchema = schema({
43
- $id: '${upperName}Result',
44
- type: 'object',
45
- additionalProperties: false,
46
- required: [ '${type === 'mongodb' ? '_id' : 'id'}' ],
47
- properties: {
48
- ...${camelName}DataSchema.properties,
49
- ${type === 'mongodb' ? '_id' : 'id'}: {
50
- type: '${type === 'mongodb' ? 'string' : 'number'}'
51
- }
52
- }
53
- } as const)
54
-
55
- export type ${upperName}Result = Infer<typeof ${camelName}ResultSchema>
56
-
57
- // Queries shouldn't allow doing anything with the password
58
- const { password, ...${camelName}QueryProperties } = ${camelName}ResultSchema.properties
59
-
60
- // Schema for allowed query properties
61
- export const ${camelName}QuerySchema = schema({
62
- $id: '${upperName}Query',
63
- type: 'object',
64
- additionalProperties: false,
65
- properties: {
66
- ...querySyntax(${camelName}QueryProperties)
67
- }
68
- } as const)
69
-
70
- export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
71
- `;
72
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
73
- lib,
74
- 'services',
75
- ...folder,
76
- `${fileName}.schema`
77
- ]), { force: true }));
78
- exports.generate = generate;
79
- //# sourceMappingURL=user.schema.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.schema.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/user.schema.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAkC,EAAE,EAAE,CAClG;;;;e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