@feathersjs/cli 5.0.0-pre.28 → 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 (155) hide show
  1. package/CHANGELOG.md +28 -28
  2. package/bin/feathers +3 -6
  3. package/lib/app/index.js +34 -11
  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 +24 -12
  10. package/lib/app/templates/app.tpl.js.map +1 -1
  11. package/lib/app/templates/app.tpl.ts +28 -14
  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 +3 -3
  16. package/lib/app/templates/client.tpl.js.map +1 -1
  17. package/lib/app/templates/client.tpl.ts +3 -4
  18. package/lib/app/templates/config.tpl.js +10 -1
  19. package/lib/app/templates/config.tpl.js.map +1 -1
  20. package/lib/app/templates/config.tpl.ts +10 -0
  21. package/lib/app/templates/declarations.tpl.js +3 -3
  22. package/lib/app/templates/declarations.tpl.js.map +1 -1
  23. package/lib/app/templates/declarations.tpl.ts +5 -4
  24. package/lib/app/templates/index.html.tpl.js +12 -52
  25. package/lib/app/templates/index.html.tpl.js.map +1 -1
  26. package/lib/app/templates/index.html.tpl.ts +12 -53
  27. package/lib/app/templates/index.tpl.js +1 -1
  28. package/lib/app/templates/index.tpl.js.map +1 -1
  29. package/lib/app/templates/index.tpl.ts +1 -2
  30. package/lib/app/templates/logger.tpl.js +1 -1
  31. package/lib/app/templates/logger.tpl.js.map +1 -1
  32. package/lib/app/templates/logger.tpl.ts +2 -2
  33. package/lib/app/templates/package.json.tpl.js +4 -3
  34. package/lib/app/templates/package.json.tpl.js.map +1 -1
  35. package/lib/app/templates/package.json.tpl.ts +5 -3
  36. package/lib/app/templates/readme.md.tpl.js +11 -7
  37. package/lib/app/templates/readme.md.tpl.js.map +1 -1
  38. package/lib/app/templates/readme.md.tpl.ts +15 -8
  39. package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
  40. package/lib/app/templates/schemas.tpl.js +76 -0
  41. package/lib/app/templates/schemas.tpl.js.map +1 -0
  42. package/lib/app/templates/schemas.tpl.ts +90 -0
  43. package/lib/app/templates/services.tpl.js +1 -1
  44. package/lib/app/templates/services.tpl.js.map +1 -1
  45. package/lib/app/templates/services.tpl.ts +1 -2
  46. package/lib/authentication/index.d.ts +4 -3
  47. package/lib/authentication/index.js +12 -3
  48. package/lib/authentication/index.js.map +1 -1
  49. package/lib/authentication/index.ts +23 -5
  50. package/lib/authentication/templates/authentication.tpl.js +4 -6
  51. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  52. package/lib/authentication/templates/authentication.tpl.ts +6 -9
  53. package/lib/authentication/templates/config.tpl.js +10 -6
  54. package/lib/authentication/templates/config.tpl.js.map +1 -1
  55. package/lib/authentication/templates/config.tpl.ts +40 -34
  56. package/lib/authentication/templates/declarations.tpl.js +3 -3
  57. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  58. package/lib/authentication/templates/declarations.tpl.ts +9 -4
  59. package/lib/authentication/templates/knex.tpl.js +5 -4
  60. package/lib/authentication/templates/knex.tpl.js.map +1 -1
  61. package/lib/authentication/templates/knex.tpl.ts +5 -4
  62. package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  63. package/lib/authentication/templates/schema.json.tpl.js +92 -0
  64. package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
  65. package/lib/authentication/templates/schema.json.tpl.ts +108 -0
  66. package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
  67. package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
  68. package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
  69. package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
  70. package/lib/authentication/templates/test.tpl.js +2 -2
  71. package/lib/authentication/templates/test.tpl.js.map +1 -1
  72. package/lib/authentication/templates/test.tpl.ts +6 -3
  73. package/lib/cli.d.ts +6 -0
  74. package/lib/cli.js +75 -0
  75. package/lib/cli.js.map +1 -0
  76. package/lib/cli.ts +68 -0
  77. package/lib/commons.d.ts +14 -1
  78. package/lib/commons.js +24 -4
  79. package/lib/commons.js.map +1 -1
  80. package/lib/commons.ts +29 -1
  81. package/lib/connection/index.d.ts +5 -3
  82. package/lib/connection/index.js +5 -3
  83. package/lib/connection/index.js.map +1 -1
  84. package/lib/connection/index.ts +19 -5
  85. package/lib/connection/templates/knex.tpl.js +2 -12
  86. package/lib/connection/templates/knex.tpl.js.map +1 -1
  87. package/lib/connection/templates/knex.tpl.ts +6 -20
  88. package/lib/connection/templates/mongodb.tpl.js +1 -3
  89. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  90. package/lib/connection/templates/mongodb.tpl.ts +1 -12
  91. package/lib/hook/index.d.ts +1 -1
  92. package/lib/hook/index.js +3 -0
  93. package/lib/hook/index.js.map +1 -1
  94. package/lib/hook/index.ts +3 -1
  95. package/lib/hook/templates/hook.tpl.js +2 -3
  96. package/lib/hook/templates/hook.tpl.js.map +1 -1
  97. package/lib/hook/templates/hook.tpl.ts +5 -3
  98. package/lib/index.d.ts +2 -16
  99. package/lib/index.js +16 -24
  100. package/lib/index.js.map +1 -1
  101. package/lib/index.ts +2 -28
  102. package/lib/service/index.d.ts +10 -2
  103. package/lib/service/index.js +79 -41
  104. package/lib/service/index.js.map +1 -1
  105. package/lib/service/index.ts +54 -6
  106. package/lib/service/templates/client.tpl.js +26 -6
  107. package/lib/service/templates/client.tpl.js.map +1 -1
  108. package/lib/service/templates/client.tpl.ts +41 -12
  109. package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  110. package/lib/service/templates/schema.json.tpl.js +73 -0
  111. package/lib/service/templates/schema.json.tpl.js.map +1 -0
  112. package/lib/service/templates/schema.json.tpl.ts +85 -0
  113. package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
  114. package/lib/service/templates/schema.typebox.tpl.js +58 -0
  115. package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
  116. package/lib/service/templates/schema.typebox.tpl.ts +70 -0
  117. package/lib/service/templates/service.tpl.d.ts +1 -0
  118. package/lib/service/templates/service.tpl.js +67 -15
  119. package/lib/service/templates/service.tpl.js.map +1 -1
  120. package/lib/service/templates/service.tpl.ts +98 -19
  121. package/lib/service/templates/test.tpl.js +1 -1
  122. package/lib/service/templates/test.tpl.js.map +1 -1
  123. package/lib/service/templates/test.tpl.ts +1 -2
  124. package/lib/service/type/custom.tpl.d.ts +1 -2
  125. package/lib/service/type/custom.tpl.js +32 -25
  126. package/lib/service/type/custom.tpl.js.map +1 -1
  127. package/lib/service/type/custom.tpl.ts +44 -35
  128. package/lib/service/type/knex.tpl.d.ts +1 -3
  129. package/lib/service/type/knex.tpl.js +33 -23
  130. package/lib/service/type/knex.tpl.js.map +1 -1
  131. package/lib/service/type/knex.tpl.ts +51 -29
  132. package/lib/service/type/mongodb.tpl.d.ts +1 -2
  133. package/lib/service/type/mongodb.tpl.js +30 -20
  134. package/lib/service/type/mongodb.tpl.js.map +1 -1
  135. package/lib/service/type/mongodb.tpl.ts +47 -29
  136. package/package.json +23 -24
  137. package/lib/app/templates/configuration.tpl.js +0 -39
  138. package/lib/app/templates/configuration.tpl.js.map +0 -1
  139. package/lib/app/templates/configuration.tpl.ts +0 -44
  140. package/lib/authentication/templates/user.resolver.tpl.js +0 -98
  141. package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
  142. package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
  143. package/lib/authentication/templates/user.schema.tpl.js +0 -79
  144. package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
  145. package/lib/authentication/templates/user.schema.tpl.ts +0 -87
  146. package/lib/service/templates/class.tpl.js +0 -63
  147. package/lib/service/templates/class.tpl.js.map +0 -1
  148. package/lib/service/templates/class.tpl.ts +0 -79
  149. package/lib/service/templates/resolver.tpl.js +0 -73
  150. package/lib/service/templates/resolver.tpl.js.map +0 -1
  151. package/lib/service/templates/resolver.tpl.ts +0 -78
  152. package/lib/service/templates/schema.tpl.d.ts +0 -2
  153. package/lib/service/templates/schema.tpl.js +0 -75
  154. package/lib/service/templates/schema.tpl.js.map +0 -1
  155. package/lib/service/templates/schema.tpl.ts +0 -80
@@ -1,44 +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
- paginate: {
22
- type: 'object',
23
- additionalProperties: false,
24
- required: [ 'default', 'max' ],
25
- properties: {
26
- default: { type: 'number' },
27
- max: { type: 'number' }
28
- }
29
- }
30
- }
31
- } as const,
32
- new Ajv()
33
- )
34
-
35
- export type ConfigurationSchema = Infer<typeof configurationSchema>
36
- `
37
-
38
- export const generate = (ctx: AppGeneratorContext) =>
39
- generator(ctx).then(
40
- renderSource(
41
- template,
42
- toFile<AppGeneratorContext>(({ lib }) => lib, 'configuration')
43
- )
44
- )
@@ -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,CAAC,CAAC,CAAC,EAAE;oCACvE,QAAQ;;IAExC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;;IAEhB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;;;;eAIL,SAAS,0BAA0B,SAAS;YAC/C,SAAS;;;MAGf,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,EAAE;;;;;;eAM9E,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;MAGf,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,EAAE;;;;;;eAM9E,SAAS,4BAA4B,SAAS;YACjD,SAAS;;;;;;;eAON,SAAS,8BAA8B,SAAS;YACnD,SAAS;;;;;;;;;;eAUN,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;MAIf,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;qCAEF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;;;;;eAUvD,SAAS;YACZ,SAAS;cACP,SAAS;;cAET,SAAS;cACT,SAAS;aACV,SAAS;;WAEX,SAAS;;CAEnB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,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,WAAW;CACvB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAA;AAZU,QAAA,QAAQ,YAYlB"}
@@ -1,111 +0,0 @@
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', 'password'" : ''} ],
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;;;;eAIa,SAAS;UACd,SAAS;;;gBAGH,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;;MAEvE,cAAc;KACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;iCACqB;IACvB,CAAC,CAAC,OAAO,IAAI,wBAAwB,CACxC;KACA,IAAI,CAAC,KAAK,CAAC;;;;cAIJ,SAAS,uBAAuB,SAAS;;;;eAIxC,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;;cAIJ,SAAS,wBAAwB,SAAS;;;eAGzC,SAAS;UACd,SAAS;;;iBAGF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;SAEzC,SAAS;MACZ,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;eACxB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;;;;;cAKzC,SAAS,yBAAyB,SAAS;;;uBAGlC,SAAS,uBAAuB,SAAS;;;eAGjD,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;;cAIhB,SAAS,wBAAwB,SAAS;CACvD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,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,CAAA;AAZU,QAAA,QAAQ,YAYlB"}
@@ -1,87 +0,0 @@
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { renderSource } from '../../commons'
3
- import { AuthenticationGeneratorContext } from '../index'
4
-
5
- const template = ({ camelName, upperName, authStrategies, type }: AuthenticationGeneratorContext) =>
6
- `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', 'password'" : ''} ],
15
- properties: {
16
- ${authStrategies
17
- .map((name) =>
18
- name === 'local'
19
- ? ` email: { type: 'string' },
20
- password: { type: 'string' }`
21
- : ` ${name}Id: { type: 'string' }`
22
- )
23
- .join(',\n')}
24
- }
25
- } as const)
26
-
27
- export type ${upperName}Data = Infer<typeof ${camelName}DataSchema>
28
-
29
-
30
- // Schema for making partial updates
31
- export const ${camelName}PatchSchema = schema({
32
- $id: '${upperName}Patch',
33
- type: 'object',
34
- additionalProperties: false,
35
- required: [],
36
- properties: {
37
- ...${camelName}DataSchema.properties
38
- }
39
- } as const)
40
-
41
- export type ${upperName}Patch = Infer<typeof ${camelName}PatchSchema>
42
-
43
- // Schema for the data that is being returned
44
- export const ${camelName}ResultSchema = schema({
45
- $id: '${upperName}Result',
46
- type: 'object',
47
- additionalProperties: false,
48
- required: [ '${type === 'mongodb' ? '_id' : 'id'}' ],
49
- properties: {
50
- ...${camelName}DataSchema.properties,
51
- ${type === 'mongodb' ? '_id' : 'id'}: {
52
- type: '${type === 'mongodb' ? 'string' : 'number'}'
53
- }
54
- }
55
- } as const)
56
-
57
- export type ${upperName}Result = Infer<typeof ${camelName}ResultSchema>
58
-
59
- // Queries shouldn't allow doing anything with the password
60
- const { password, ...${camelName}QueryProperties } = ${camelName}ResultSchema.properties
61
-
62
- // Schema for allowed query properties
63
- export const ${camelName}QuerySchema = schema({
64
- $id: '${upperName}Query',
65
- type: 'object',
66
- additionalProperties: false,
67
- properties: {
68
- ...querySyntax(${camelName}QueryProperties)
69
- }
70
- } as const)
71
-
72
- export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
73
- `
74
-
75
- export const generate = (ctx: AuthenticationGeneratorContext) =>
76
- generator(ctx).then(
77
- renderSource(
78
- template,
79
- toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
80
- lib,
81
- 'services',
82
- ...folder,
83
- `${fileName}.schema`
84
- ]),
85
- { force: true }
86
- )
87
- )
@@ -1,63 +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, fileName, isEntityService, authentication }) => `import { resolveAll } from '@feathersjs/schema'
7
- ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
8
- import type {
9
- ${upperName}Data,
10
- ${upperName}Result,
11
- ${upperName}Query,
12
- } from './${fileName}.schema'
13
- import { ${camelName}Resolvers } from './${fileName}.resolver'
14
-
15
- export const ${camelName}Hooks = {
16
- around: {
17
- all: [${authentication
18
- ? `
19
- authenticate('jwt'),`
20
- : ''} ${!isEntityService
21
- ? `
22
- resolveAll(${camelName}Resolvers)`
23
- : ''}
24
- ]${isEntityService
25
- ? `,
26
- get: [
27
- authenticate('jwt'),
28
- resolveAll(${camelName}Resolvers)
29
- ],
30
- find: [
31
- authenticate('jwt'),
32
- resolveAll(${camelName}Resolvers)
33
- ],
34
- create: [
35
- resolveAll(${camelName}Resolvers)
36
- ],
37
- patch: [
38
- authenticate('jwt'),
39
- resolveAll(${camelName}Resolvers)
40
- ],
41
- update: [
42
- authenticate('jwt'),
43
- resolveAll(${camelName}Resolvers)
44
- ],
45
- remove: [
46
- authenticate('jwt'),
47
- resolveAll(${camelName}Resolvers)
48
- ]`
49
- : ''}
50
- },
51
- before: {},
52
- after: {},
53
- error: {}
54
- }
55
- `;
56
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
57
- lib,
58
- 'services',
59
- ...folder,
60
- `${fileName}.class`
61
- ])));
62
- exports.generate = generate;
63
- //# sourceMappingURL=class.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"class.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/class.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,eAAe,EACf,cAAc,EACU,EAAE,EAAE,CAC5B;EACA,eAAe,IAAI,cAAc,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;;IAElG,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;WACT,SAAS,uBAAuB,QAAQ;;eAEpC,SAAS;;YAGlB,cAAc;IACZ,CAAC,CAAC;2BACiB;IACnB,CAAC,CAAC,EACN,IACA,CAAC,eAAe;IACd,CAAC,CAAC;mBACW,SAAS,YAAY;IAClC,CAAC,CAAC,EACN;OAEI,eAAe;IACb,CAAC,CAAC;;;mBAGS,SAAS;;;;mBAIT,SAAS;;;mBAGT,SAAS;;;;mBAIT,SAAS;;;;mBAIT,SAAS;;;;mBAIT,SAAS;MACtB;IACE,CAAC,CAAC,EACN;;;;;;CAMH,CAAA;AACM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,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,79 +0,0 @@
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { renderSource } from '../../commons'
3
- import { ServiceGeneratorContext } from '../index'
4
-
5
- const template = ({
6
- camelName,
7
- upperName,
8
- fileName,
9
- isEntityService,
10
- authentication
11
- }: ServiceGeneratorContext) =>
12
- `import { resolveAll } from '@feathersjs/schema'
13
- ${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
14
- import type {
15
- ${upperName}Data,
16
- ${upperName}Result,
17
- ${upperName}Query,
18
- } from './${fileName}.schema'
19
- import { ${camelName}Resolvers } from './${fileName}.resolver'
20
-
21
- export const ${camelName}Hooks = {
22
- around: {
23
- all: [${
24
- authentication
25
- ? `
26
- authenticate('jwt'),`
27
- : ''
28
- } ${
29
- !isEntityService
30
- ? `
31
- resolveAll(${camelName}Resolvers)`
32
- : ''
33
- }
34
- ]${
35
- isEntityService
36
- ? `,
37
- get: [
38
- authenticate('jwt'),
39
- resolveAll(${camelName}Resolvers)
40
- ],
41
- find: [
42
- authenticate('jwt'),
43
- resolveAll(${camelName}Resolvers)
44
- ],
45
- create: [
46
- resolveAll(${camelName}Resolvers)
47
- ],
48
- patch: [
49
- authenticate('jwt'),
50
- resolveAll(${camelName}Resolvers)
51
- ],
52
- update: [
53
- authenticate('jwt'),
54
- resolveAll(${camelName}Resolvers)
55
- ],
56
- remove: [
57
- authenticate('jwt'),
58
- resolveAll(${camelName}Resolvers)
59
- ]`
60
- : ''
61
- }
62
- },
63
- before: {},
64
- after: {},
65
- error: {}
66
- }
67
- `
68
- export const generate = (ctx: ServiceGeneratorContext) =>
69
- generator(ctx).then(
70
- renderSource(
71
- template,
72
- toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
73
- lib,
74
- 'services',
75
- ...folder,
76
- `${fileName}.class`
77
- ])
78
- )
79
- )
@@ -1,73 +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, fileName }) => `import { resolve } from '@feathersjs/schema'
7
- import type { HookContext } from '${relative}/declarations'
8
-
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
- })
29
-
30
-
31
- // Resolver for making partial updates
32
- export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
33
- schema: ${camelName}PatchSchema,
34
- validate: 'before',
35
- properties: {}
36
- })
37
-
38
-
39
- // Resolver for the data that is being returned
40
- export const ${camelName}ResultResolver = resolve<${upperName}Result, HookContext>({
41
- schema: ${camelName}ResultSchema,
42
- validate: false,
43
- properties: {}
44
- })
45
-
46
-
47
- // Resolver for query properties
48
- export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
49
- schema: ${camelName}QuerySchema,
50
- validate: 'before',
51
- properties: {}
52
- })
53
-
54
-
55
- // Export all resolvers in a format that can be used with the resolveAll hook
56
- export const ${camelName}Resolvers = {
57
- result: ${camelName}ResultResolver,
58
- data: {
59
- create: ${camelName}DataResolver,
60
- update: ${camelName}DataResolver,
61
- patch: ${camelName}PatchResolver
62
- },
63
- query: ${camelName}QueryResolver
64
- }
65
- `;
66
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
67
- lib,
68
- 'services',
69
- ...folder,
70
- `${fileName}.resolver`
71
- ])));
72
- exports.generate = generate;
73
- //# sourceMappingURL=resolver.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/resolver.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAA2B,EAAE,EAAE,CACzF;oCACkC,QAAQ;;;IAGxC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;;IAEhB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;;;;eAIL,SAAS,0BAA0B,SAAS;YAC/C,SAAS;;;;;;;eAON,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS,4BAA4B,SAAS;YACjD,SAAS;;;;;;;eAON,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS;YACZ,SAAS;;cAEP,SAAS;cACT,SAAS;aACV,SAAS;;WAEX,SAAS;;CAEnB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,WAAW;CACvB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}