@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,62 +0,0 @@
1
- import { generator, when, toFile } from '@feathershq/pinion'
2
- import { getDatabaseAdapter, renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext } from '../index'
4
-
5
- const migrationTemplate = ({
6
- kebabPath,
7
- authStrategies
8
- }: AuthenticationGeneratorContext) => /* ts */ `import type { Knex } from 'knex'
9
-
10
- export async function up(knex: Knex): Promise<void> {
11
- await knex.schema.alterTable('${kebabPath}', function (table) {
12
- table.dropColumn('text')${authStrategies
13
- .map((name) =>
14
- name === 'local'
15
- ? `
16
- table.string('email').unique()
17
- table.string('password')`
18
- : `
19
- table.string('${name}Id')`
20
- )
21
- .join('\n')}
22
- })
23
- }
24
-
25
- export async function down(knex: Knex): Promise<void> {
26
- await knex.schema.alterTable('${kebabPath}', function (table) {
27
- table.string('text')${authStrategies
28
- .map((name) =>
29
- name === 'local'
30
- ? `
31
- table.dropColumn('email')
32
- table.dropColumn('password')`
33
- : `
34
- table.dropColumn('${name}Id')
35
- `
36
- )
37
- .join('\n')}
38
- })
39
- }
40
- `
41
-
42
- export const generate = (ctx: AuthenticationGeneratorContext) =>
43
- generator(ctx).then(
44
- when(
45
- (ctx) => getDatabaseAdapter(ctx.feathers?.database) === 'knex',
46
- renderSource(
47
- migrationTemplate,
48
- toFile(
49
- toFile<AuthenticationGeneratorContext>('migrations', () => {
50
- // Probably not great but it works to align with the Knex migration file format
51
- // We add a few seconds so that the migrations run in the correct order
52
- const migrationDate = new Date(Date.now() + 10000)
53
- .toISOString()
54
- .replace(/\D/g, '')
55
- .substring(0, 14)
56
-
57
- return `${migrationDate}_authentication`
58
- })
59
- )
60
- )
61
- )
62
- )
@@ -1,2 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,103 +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 index_1 = require("../index");
7
- const template = ({ cwd, lib, camelName, upperName, authStrategies, type, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
8
- import { resolve, querySyntax, getValidator } from '@feathersjs/schema'
9
- import type { FromSchema } from '@feathersjs/schema'
10
- ${(0, index_1.localTemplate)(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
11
-
12
- import type { HookContext } from '${relative}/declarations'
13
- import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
14
- }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'}'${(0, index_1.localTemplate)(authStrategies, ", 'email'")} ],
22
- properties: {
23
- ${type === 'mongodb' ? '_id' : 'id'}: {
24
- type: '${type === 'mongodb' ? 'string' : 'number'}'
25
- },
26
- ${authStrategies
27
- .map((name) => name === 'local'
28
- ? ` email: { type: 'string' },
29
- password: { type: 'string' }`
30
- : ` ${name}Id: { type: 'string' }`)
31
- .join(',\n')}
32
- }
33
- } as const
34
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
35
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
36
-
37
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
38
- ${(0, index_1.localTemplate)(authStrategies, `// The password should never be visible externally
39
- password: async () => undefined`)}
40
- })
41
-
42
- // Schema for creating new users
43
- export const ${camelName}DataSchema = {
44
- $id: '${upperName}Data',
45
- type: 'object',
46
- additionalProperties: false,
47
- required: [ ],
48
- properties: {
49
- ...${camelName}Schema.properties
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
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
56
- })
57
-
58
- // Schema for updating existing users
59
- export const ${camelName}DataSchema = {
60
- $id: '${upperName}Patch',
61
- type: 'object',
62
- additionalProperties: false,
63
- required: [],
64
- properties: {
65
- ...${camelName}Schema.properties
66
- }
67
- } as const
68
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
69
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
70
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
71
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
72
- })
73
-
74
- // Schema for allowed query properties
75
- export const ${camelName}QuerySchema = {
76
- $id: '${upperName}Query',
77
- type: 'object',
78
- additionalProperties: false,
79
- properties: {
80
- ...querySyntax(${camelName}Schema.properties)
81
- }
82
- } as const
83
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
84
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
85
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
86
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
87
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
88
- if (context.params.user) {
89
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
90
- }
91
-
92
- return value
93
- }
94
- })
95
- `;
96
- 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 }) => [
97
- lib,
98
- 'services',
99
- ...folder,
100
- `${fileName}.schema`
101
- ]), { force: true })));
102
- exports.generate = generate;
103
- //# sourceMappingURL=schema.json.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AACxD,oCAAwE;AAExE,MAAM,QAAQ,GAAG,CAAC,EAChB,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;EAG7C,IAAA,qBAAa,EAAC,cAAc,EAAE,iEAAiE,CAAC;;oCAE9D,QAAQ;iDACK,QAAQ,IACvD,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AI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;mCAEF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;CAMnE,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,EACjC,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC;IACpE,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CACF,CAAA;AAfU,QAAA,QAAQ,YAelB"}
@@ -1,124 +0,0 @@
1
- import { generator, toFile, when } from '@feathershq/pinion'
2
- import { fileExists, renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext, localTemplate } from '../index'
4
-
5
- const template = ({
6
- cwd,
7
- lib,
8
- camelName,
9
- upperName,
10
- authStrategies,
11
- type,
12
- relative
13
- }: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
14
- import { resolve, querySyntax, getValidator } from '@feathersjs/schema'
15
- import type { FromSchema } from '@feathersjs/schema'
16
- ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
17
-
18
- import type { HookContext } from '${relative}/declarations'
19
- import { dataValidator, queryValidator } from '${relative}/${
20
- fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
21
- }validators'
22
-
23
- // Main data model schema
24
- export const ${camelName}Schema = {
25
- $id: '${upperName}',
26
- type: 'object',
27
- additionalProperties: false,
28
- required: [ '${type === 'mongodb' ? '_id' : 'id'}'${localTemplate(authStrategies, ", 'email'")} ],
29
- properties: {
30
- ${type === 'mongodb' ? '_id' : 'id'}: {
31
- type: '${type === 'mongodb' ? 'string' : 'number'}'
32
- },
33
- ${authStrategies
34
- .map((name) =>
35
- name === 'local'
36
- ? ` email: { type: 'string' },
37
- password: { type: 'string' }`
38
- : ` ${name}Id: { type: 'string' }`
39
- )
40
- .join(',\n')}
41
- }
42
- } as const
43
- export type ${upperName} = FromSchema<typeof ${camelName}Schema>
44
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
45
-
46
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
47
- ${localTemplate(
48
- authStrategies,
49
- `// The password should never be visible externally
50
- password: async () => undefined`
51
- )}
52
- })
53
-
54
- // Schema for creating new users
55
- export const ${camelName}DataSchema = {
56
- $id: '${upperName}Data',
57
- type: 'object',
58
- additionalProperties: false,
59
- required: [ ],
60
- properties: {
61
- ...${camelName}Schema.properties
62
- }
63
- } as const
64
- export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
65
- export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
66
- export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
67
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
68
- })
69
-
70
- // Schema for updating existing users
71
- export const ${camelName}DataSchema = {
72
- $id: '${upperName}Patch',
73
- type: 'object',
74
- additionalProperties: false,
75
- required: [],
76
- properties: {
77
- ...${camelName}Schema.properties
78
- }
79
- } as const
80
- export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
81
- export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
82
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
83
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
84
- })
85
-
86
- // Schema for allowed query properties
87
- export const ${camelName}QuerySchema = {
88
- $id: '${upperName}Query',
89
- type: 'object',
90
- additionalProperties: false,
91
- properties: {
92
- ...querySyntax(${camelName}Schema.properties)
93
- }
94
- } as const
95
- export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
96
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
97
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
98
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
99
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
100
- if (context.params.user) {
101
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
102
- }
103
-
104
- return value
105
- }
106
- })
107
- `
108
-
109
- export const generate = (ctx: AuthenticationGeneratorContext) =>
110
- generator(ctx).then(
111
- when<AuthenticationGeneratorContext>(
112
- ({ schema }) => schema === 'json',
113
- renderSource(
114
- template,
115
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
116
- lib,
117
- 'services',
118
- ...folder,
119
- `${fileName}.schema`
120
- ]),
121
- { force: true }
122
- )
123
- )
124
- )
@@ -1,3 +0,0 @@
1
- import { AuthenticationGeneratorContext } from '../index';
2
- export declare const template: ({ cwd, lib, camelName, upperName, authStrategies, type, relative }: AuthenticationGeneratorContext) => string;
3
- export declare const generate: (ctx: AuthenticationGeneratorContext) => Promise<AuthenticationGeneratorContext>;
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = exports.template = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const index_1 = require("../index");
7
- const template = ({ cwd, lib, camelName, upperName, authStrategies, type, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
8
- import { resolve } from '@feathersjs/schema'
9
- import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
10
- import type { Static } from '@feathersjs/typebox'
11
- ${(0, index_1.localTemplate)(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
12
-
13
- import type { HookContext } from '${relative}/declarations'
14
- import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
15
- }validators'
16
-
17
- // Main data model schema
18
- export const ${camelName}Schema = Type.Object({
19
- ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
20
- ${authStrategies
21
- .map((name) => name === 'local'
22
- ? ` email: Type.String(),
23
- password: Type.Optional(Type.String())`
24
- : ` ${name}Id: Type.Optional(Type.String())`)
25
- .join(',\n')}
26
- },{ $id: '${upperName}', additionalProperties: false })
27
- export type ${upperName} = Static<typeof ${camelName}Schema>
28
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
29
-
30
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
31
- ${(0, index_1.localTemplate)(authStrategies, `// The password should never be visible externally
32
- password: async () => undefined`)}
33
- })
34
-
35
- // Schema for creating new users
36
- export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
37
- ${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
38
- ],
39
- { $id: '${upperName}Data', additionalProperties: false }
40
- )
41
- export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
42
- export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
43
- export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
44
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
45
- })
46
-
47
- // Schema for updating existing users
48
- export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
49
- $id: '${upperName}Patch'
50
- })
51
- export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
52
- export const ${camelName}PatchValidator = getDataValidator(${camelName}PatchSchema, dataValidator)
53
- export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({
54
- ${(0, index_1.localTemplate)(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
55
- })
56
-
57
- // Schema for allowed query properties
58
- export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${type === 'mongodb' ? '_id' : 'id'}', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
59
- ])
60
- export const ${camelName}QuerySchema = Type.Intersect([
61
- querySyntax(${camelName}QueryProperties),
62
- // Add additional query properties here
63
- Type.Object({}, { additionalProperties: false })
64
- ], { additionalProperties: false })
65
- export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
66
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
67
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
68
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
69
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
70
- if (context.params.user) {
71
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
72
- }
73
-
74
- return value
75
- }
76
- })
77
- `;
78
- exports.template = template;
79
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'typebox', (0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
80
- lib,
81
- 'services',
82
- ...folder,
83
- `${fileName}.schema`
84
- ]), { force: true })));
85
- exports.generate = generate;
86
- //# sourceMappingURL=schema.typebox.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AACxD,oCAAwE;AAEjE,MAAM,QAAQ,GAAG,CAAC,EACvB,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;EAI7C,IAAA,qBAAa,EAAC,cAAc,EAAE,iEAAiE,CAAC;;oCAE9D,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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;eAE9E,SAAS;gBACR,SAAS;;;;cAIX,SAAS,yBAAyB,SAAS;eAC1C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;;IAExD,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;mCAEF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;CAMnE,CAAA;AAtFY,QAAA,QAAQ,YAsFpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,EACpC,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC;IACpE,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CACF,CAAA;AAfU,QAAA,QAAQ,YAelB"}
@@ -1,108 +0,0 @@
1
- import { generator, toFile, when } from '@feathershq/pinion'
2
- import { fileExists, renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext, localTemplate } from '../index'
4
-
5
- export const template = ({
6
- cwd,
7
- lib,
8
- camelName,
9
- upperName,
10
- authStrategies,
11
- type,
12
- relative
13
- }: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
14
- import { resolve } from '@feathersjs/schema'
15
- import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
16
- import type { Static } from '@feathersjs/typebox'
17
- ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)}
18
-
19
- import type { HookContext } from '${relative}/declarations'
20
- import { dataValidator, queryValidator } from '${relative}/${
21
- fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
22
- }validators'
23
-
24
- // Main data model schema
25
- export const ${camelName}Schema = Type.Object({
26
- ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
27
- ${authStrategies
28
- .map((name) =>
29
- name === 'local'
30
- ? ` email: Type.String(),
31
- password: Type.Optional(Type.String())`
32
- : ` ${name}Id: Type.Optional(Type.String())`
33
- )
34
- .join(',\n')}
35
- },{ $id: '${upperName}', additionalProperties: false })
36
- export type ${upperName} = Static<typeof ${camelName}Schema>
37
- export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
38
-
39
- export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
40
- ${localTemplate(
41
- authStrategies,
42
- `// The password should never be visible externally
43
- password: async () => undefined`
44
- )}
45
- })
46
-
47
- // Schema for creating new users
48
- export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [
49
- ${authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ')}
50
- ],
51
- { $id: '${upperName}Data', additionalProperties: false }
52
- )
53
- export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
54
- export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
55
- export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
56
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
57
- })
58
-
59
- // Schema for updating existing users
60
- export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
61
- $id: '${upperName}Patch'
62
- })
63
- export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
64
- export const ${camelName}PatchValidator = getDataValidator(${camelName}PatchSchema, dataValidator)
65
- export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({
66
- ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)}
67
- })
68
-
69
- // Schema for allowed query properties
70
- export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, ['${
71
- type === 'mongodb' ? '_id' : 'id'
72
- }', ${authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ')}
73
- ])
74
- export const ${camelName}QuerySchema = Type.Intersect([
75
- querySyntax(${camelName}QueryProperties),
76
- // Add additional query properties here
77
- Type.Object({}, { additionalProperties: false })
78
- ], { additionalProperties: false })
79
- export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
80
- export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
81
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
82
- // If there is a user (e.g. with authentication), they are only allowed to see their own data
83
- ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
84
- if (context.params.user) {
85
- return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
86
- }
87
-
88
- return value
89
- }
90
- })
91
- `
92
-
93
- export const generate = (ctx: AuthenticationGeneratorContext) =>
94
- generator(ctx).then(
95
- when<AuthenticationGeneratorContext>(
96
- ({ schema }) => schema === 'typebox',
97
- renderSource(
98
- template,
99
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
100
- lib,
101
- 'services',
102
- ...folder,
103
- `${fileName}.schema`
104
- ]),
105
- { force: true }
106
- )
107
- )
108
- )
package/lib/cli.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import chalk from 'chalk';
2
- import { Command } from 'commander';
3
- export * from 'commander';
4
- export { chalk };
5
- export declare const commandRunner: (name: string) => (options: any) => Promise<void>;
6
- export declare const program: Command;
package/lib/cli.js DELETED
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.program = exports.commandRunner = exports.chalk = void 0;
21
- const chalk_1 = __importDefault(require("chalk"));
22
- exports.chalk = chalk_1.default;
23
- const commander_1 = require("commander");
24
- const pinion_1 = require("@feathershq/pinion");
25
- const commons_1 = require("./commons");
26
- __exportStar(require("commander"), exports);
27
- const commandRunner = (name) => async (options) => {
28
- const ctx = (0, pinion_1.getContext)({
29
- ...options
30
- });
31
- await (0, pinion_1.generator)(ctx)
32
- .then((0, pinion_1.runGenerator)(__dirname, name, 'index'))
33
- .catch((error) => {
34
- const { logger } = ctx.pinion;
35
- logger.error(`Error: ${chalk_1.default.white(error.message)}`);
36
- });
37
- };
38
- exports.commandRunner = commandRunner;
39
- exports.program = new commander_1.Command();
40
- exports.program
41
- .name('feathers')
42
- .description('The Feathers command line interface 🕊️')
43
- .version(commons_1.version)
44
- .showHelpAfterError();
45
- const generate = exports.program.command('generate').alias('g');
46
- generate
47
- .command('app')
48
- .description('Generate a new application')
49
- .option('--name <name>', 'The name of the application')
50
- .action((0, exports.commandRunner)('app'));
51
- generate
52
- .command('service')
53
- .description('Generate a new service')
54
- .option('--name <name>', 'The service name')
55
- .option('--path <path>', 'The path to register the service on')
56
- .option('--type <type>', 'The service type (knex, mongodb, custom)')
57
- .action((0, exports.commandRunner)('service'));
58
- generate
59
- .command('hook')
60
- .description('Generate a hook')
61
- .option('--name <name>', 'The name of the hook')
62
- .option('--type <type>', 'The hook type (around or regular)')
63
- .action((0, exports.commandRunner)('hook'));
64
- generate
65
- .command('connection')
66
- .description('Add a new database connection')
67
- .action((0, exports.commandRunner)('connection'));
68
- generate
69
- .command('authentication')
70
- .description('Add authentication to the application')
71
- .action((0, exports.commandRunner)('authentication'));
72
- generate.description(`Run a generator. Currently available: \n ${generate.commands
73
- .map((cmd) => `${chalk_1.default.blue(cmd.name())}: ${cmd.description()} `)
74
- .join('\n ')}`);
75
- //# sourceMappingURL=cli.js.map
package/lib/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AAMhB,gBANF,eAAK,CAME;AALd,yCAAmC;AACnC,+CAAwE;AACxE,uCAAwD;AAExD,4CAAyB;AAGlB,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,EAAE,OAAY,EAAE,EAAE;IACpE,MAAM,GAAG,GAAG,IAAA,mBAAU,EAAsB;QAC1C,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,MAAM,IAAA,kBAAS,EAAC,GAAG,CAAC;SACjB,IAAI,CAAC,IAAA,qBAAY,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;SAC5C,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAA;QAE7B,MAAM,CAAC,KAAK,CAAC,UAAU,eAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAZY,QAAA,aAAa,iBAYzB;AAEY,QAAA,OAAO,GAAG,IAAI,mBAAO,EA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AClB,6CAA6C,QAAQ,CAAC,QAAQ;KAC3D,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC;KAChE,IAAI,CAAC,MAAM,CAAC,EAAE,CAClB,CAAA"}
package/lib/cli.ts DELETED
@@ -1,68 +0,0 @@
1
- import chalk from 'chalk'
2
- import { Command } from 'commander'
3
- import { generator, runGenerator, getContext } from '@feathershq/pinion'
4
- import { FeathersBaseContext, version } from './commons'
5
-
6
- export * from 'commander'
7
- export { chalk }
8
-
9
- export const commandRunner = (name: string) => async (options: any) => {
10
- const ctx = getContext<FeathersBaseContext>({
11
- ...options
12
- })
13
-
14
- await generator(ctx)
15
- .then(runGenerator(__dirname, name, 'index'))
16
- .catch((error) => {
17
- const { logger } = ctx.pinion
18
-
19
- logger.error(`Error: ${chalk.white(error.message)}`)
20
- })
21
- }
22
-
23
- export const program = new Command()
24
-
25
- program
26
- .name('feathers')
27
- .description('The Feathers command line interface 🕊️')
28
- .version(version)
29
- .showHelpAfterError()
30
-
31
- const generate = program.command('generate').alias('g')
32
-
33
- generate
34
- .command('app')
35
- .description('Generate a new application')
36
- .option('--name <name>', 'The name of the application')
37
- .action(commandRunner('app'))
38
-
39
- generate
40
- .command('service')
41
- .description('Generate a new service')
42
- .option('--name <name>', 'The service name')
43
- .option('--path <path>', 'The path to register the service on')
44
- .option('--type <type>', 'The service type (knex, mongodb, custom)')
45
- .action(commandRunner('service'))
46
-
47
- generate
48
- .command('hook')
49
- .description('Generate a hook')
50
- .option('--name <name>', 'The name of the hook')
51
- .option('--type <type>', 'The hook type (around or regular)')
52
- .action(commandRunner('hook'))
53
-
54
- generate
55
- .command('connection')
56
- .description('Add a new database connection')
57
- .action(commandRunner('connection'))
58
-
59
- generate
60
- .command('authentication')
61
- .description('Add authentication to the application')
62
- .action(commandRunner('authentication'))
63
-
64
- generate.description(
65
- `Run a generator. Currently available: \n ${generate.commands
66
- .map((cmd) => `${chalk.blue(cmd.name())}: ${cmd.description()} `)
67
- .join('\n ')}`
68
- )