@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,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'" : ''} ],
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"}
@@ -1,78 +0,0 @@
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { renderSource } from '../../commons'
3
- import { ServiceGeneratorContext } from '../index'
4
-
5
- const template = ({ camelName, upperName, relative, fileName }: ServiceGeneratorContext) =>
6
- `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
-
67
- export const generate = (ctx: ServiceGeneratorContext) =>
68
- generator(ctx).then(
69
- renderSource(
70
- template,
71
- toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
72
- lib,
73
- 'services',
74
- ...folder,
75
- `${fileName}.resolver`
76
- ])
77
- )
78
- )
@@ -1,2 +0,0 @@
1
- import { ServiceGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const template = ({ camelName, upperName, 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: [ 'text' ],
15
- properties: {
16
- text: {
17
- type: 'string'
18
- }
19
- }
20
- } as const)
21
-
22
- export type ${upperName}Data = Infer<typeof ${camelName}DataSchema>
23
-
24
-
25
- // Schema for making partial updates
26
- export const ${camelName}PatchSchema = schema({
27
- $id: '${upperName}Patch',
28
- type: 'object',
29
- additionalProperties: false,
30
- required: [],
31
- properties: {
32
- ...${camelName}DataSchema.properties
33
- }
34
- } as const)
35
-
36
- export type ${upperName}Patch = Infer<typeof ${camelName}PatchSchema>
37
-
38
-
39
- // Schema for the data that is being returned
40
- export const ${camelName}ResultSchema = schema({
41
- $id: '${upperName}Result',
42
- type: 'object',
43
- additionalProperties: false,
44
- required: [ ...${camelName}DataSchema.required, '${type === 'mongodb' ? '_id' : 'id'}' ],
45
- properties: {
46
- ...${camelName}DataSchema.properties,
47
- ${type === 'mongodb' ? '_id' : 'id'}: {
48
- type: '${type === 'mongodb' ? 'string' : 'number'}'
49
- }
50
- }
51
- } as const)
52
-
53
- export type ${upperName}Result = Infer<typeof ${camelName}ResultSchema>
54
-
55
-
56
- // Schema for allowed query properties
57
- export const ${camelName}QuerySchema = schema({
58
- $id: '${upperName}Query',
59
- type: 'object',
60
- additionalProperties: false,
61
- properties: {
62
- ...querySyntax(${camelName}ResultSchema.properties)
63
- }
64
- } as const)
65
-
66
- export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
67
- `;
68
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
69
- lib,
70
- 'services',
71
- ...folder,
72
- `${fileName}.schema`
73
- ])));
74
- exports.generate = generate;
75
- //# sourceMappingURL=schema.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAA2B,EAAE,EAAE,CAC3E;;;;eAIa,SAAS;UACd,SAAS;;;;;;;;;;;cAWL,SAAS,uBAAuB,SAAS;;;;eAIxC,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;;cAIJ,SAAS,wBAAwB,SAAS;;;;eAIzC,SAAS;UACd,SAAS;;;mBAGA,SAAS,yBAAyB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;SAE7E,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;;;;eAI1C,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;;cAIhB,SAAS,wBAAwB,SAAS;CACvD,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,SAAS;CACrB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
@@ -1,80 +0,0 @@
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { renderSource } from '../../commons'
3
- import { ServiceGeneratorContext } from '../index'
4
-
5
- const template = ({ camelName, upperName, type }: ServiceGeneratorContext) =>
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: [ 'text' ],
15
- properties: {
16
- text: {
17
- type: 'string'
18
- }
19
- }
20
- } as const)
21
-
22
- export type ${upperName}Data = Infer<typeof ${camelName}DataSchema>
23
-
24
-
25
- // Schema for making partial updates
26
- export const ${camelName}PatchSchema = schema({
27
- $id: '${upperName}Patch',
28
- type: 'object',
29
- additionalProperties: false,
30
- required: [],
31
- properties: {
32
- ...${camelName}DataSchema.properties
33
- }
34
- } as const)
35
-
36
- export type ${upperName}Patch = Infer<typeof ${camelName}PatchSchema>
37
-
38
-
39
- // Schema for the data that is being returned
40
- export const ${camelName}ResultSchema = schema({
41
- $id: '${upperName}Result',
42
- type: 'object',
43
- additionalProperties: false,
44
- required: [ ...${camelName}DataSchema.required, '${type === 'mongodb' ? '_id' : 'id'}' ],
45
- properties: {
46
- ...${camelName}DataSchema.properties,
47
- ${type === 'mongodb' ? '_id' : 'id'}: {
48
- type: '${type === 'mongodb' ? 'string' : 'number'}'
49
- }
50
- }
51
- } as const)
52
-
53
- export type ${upperName}Result = Infer<typeof ${camelName}ResultSchema>
54
-
55
-
56
- // Schema for allowed query properties
57
- export const ${camelName}QuerySchema = schema({
58
- $id: '${upperName}Query',
59
- type: 'object',
60
- additionalProperties: false,
61
- properties: {
62
- ...querySyntax(${camelName}ResultSchema.properties)
63
- }
64
- } as const)
65
-
66
- export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
67
- `
68
-
69
- export const generate = (ctx: ServiceGeneratorContext) =>
70
- generator(ctx).then(
71
- renderSource(
72
- template,
73
- toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
74
- lib,
75
- 'services',
76
- ...folder,
77
- `${fileName}.schema`
78
- ])
79
- )
80
- )