@feathersjs/cli 5.0.0-pre.25 → 5.0.0-pre.28
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.
- package/CHANGELOG.md +39 -0
- package/lib/app/index.js +1 -1
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +1 -1
- package/lib/app/templates/app.tpl.js +2 -2
- package/lib/app/templates/app.tpl.ts +2 -2
- package/lib/app/templates/client.tpl.js +1 -1
- package/lib/app/templates/client.tpl.ts +1 -1
- package/lib/app/templates/configuration.tpl.js +23 -20
- package/lib/app/templates/configuration.tpl.js.map +1 -1
- package/lib/app/templates/configuration.tpl.ts +23 -20
- package/lib/app/templates/declarations.tpl.js +3 -2
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +3 -2
- package/lib/app/templates/package.json.tpl.js +5 -4
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -4
- package/lib/app/templates/prettierrc.tpl.d.ts +2 -0
- package/lib/app/templates/prettierrc.tpl.js +11 -0
- package/lib/app/templates/prettierrc.tpl.js.map +1 -0
- package/lib/app/templates/prettierrc.tpl.ts +14 -0
- package/lib/app/templates/tsconfig.json.tpl.js +1 -0
- package/lib/app/templates/tsconfig.json.tpl.js.map +1 -1
- package/lib/app/templates/tsconfig.json.tpl.ts +1 -0
- package/lib/authentication/index.d.ts +0 -2
- package/lib/authentication/templates/authentication.tpl.js +3 -3
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +5 -5
- package/lib/authentication/templates/declarations.tpl.js +1 -1
- package/lib/authentication/templates/declarations.tpl.js.map +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +2 -2
- package/lib/authentication/templates/knex.tpl.js +6 -5
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +16 -17
- package/lib/authentication/templates/test.tpl.js +2 -2
- package/lib/authentication/templates/test.tpl.js.map +1 -1
- package/lib/authentication/templates/test.tpl.ts +2 -2
- package/lib/authentication/templates/user.resolver.tpl.js +10 -8
- package/lib/authentication/templates/user.resolver.tpl.js.map +1 -1
- package/lib/authentication/templates/user.resolver.tpl.ts +10 -8
- package/lib/authentication/templates/user.schema.tpl.js +7 -13
- package/lib/authentication/templates/user.schema.tpl.js.map +1 -1
- package/lib/authentication/templates/user.schema.tpl.ts +7 -13
- package/lib/commons.d.ts +19 -9
- package/lib/commons.js +56 -23
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +87 -26
- package/lib/connection/templates/knex.tpl.js +13 -16
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +18 -20
- package/lib/connection/templates/mongodb.tpl.js +5 -9
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +10 -12
- package/lib/hook/templates/hook.tpl.js +2 -2
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +4 -3
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/index.ts +2 -1
- package/lib/service/index.d.ts +0 -16
- package/lib/service/index.js +3 -8
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +3 -16
- package/lib/service/templates/class.tpl.d.ts +2 -0
- package/lib/service/templates/class.tpl.js +63 -0
- package/lib/service/templates/class.tpl.js.map +1 -0
- package/lib/service/templates/class.tpl.ts +79 -0
- package/lib/service/templates/client.tpl.js +7 -7
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +13 -16
- package/lib/service/templates/resolver.tpl.js +4 -4
- package/lib/service/templates/resolver.tpl.js.map +1 -1
- package/lib/service/templates/resolver.tpl.ts +4 -4
- package/lib/service/templates/schema.tpl.js +2 -2
- package/lib/service/templates/schema.tpl.js.map +1 -1
- package/lib/service/templates/schema.tpl.ts +2 -2
- package/lib/service/templates/service.tpl.js +12 -58
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +17 -79
- package/lib/service/templates/test.tpl.js +4 -4
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +4 -4
- package/lib/service/type/custom.tpl.d.ts +1 -1
- package/lib/service/type/custom.tpl.js +24 -16
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +28 -19
- package/lib/service/type/knex.tpl.js +11 -5
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +14 -9
- package/lib/service/type/mongodb.tpl.js +11 -5
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +14 -9
- package/package.json +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAEzE,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAC5D;;;;;;MAMI,QAAQ;;;;eAIC,QAAQ;4BACK,QAAQ;;;aAGvB,QAAQ;;CAEpB,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAAC;yBACrD,GAAG;;;0BAGF,QAAQ;;EAEhC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,yBAAyB;CACxE,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAAC,GAAG,QAAQ;;;;;;GAMpF,CAAA;AACH,MAAM,c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A,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AA9B3E,QAAA,QAAQ,YA8BmE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { generator, toFile,
|
|
1
|
+
import { generator, toFile, before, mergeJSON } from '@feathershq/pinion'
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
|
-
import {
|
|
3
|
+
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
5
|
const template = ({ database }: ConnectionGeneratorContext) =>
|
|
6
6
|
`import knex from 'knex'
|
|
@@ -17,7 +17,7 @@ export const ${database} = (app: Application) => {
|
|
|
17
17
|
const config = app.get('${database}')
|
|
18
18
|
const db = knex(config!)
|
|
19
19
|
|
|
20
|
-
app.set('${database}Client', db)
|
|
20
|
+
app.set('${database}Client', db)
|
|
21
21
|
}
|
|
22
22
|
`
|
|
23
23
|
|
|
@@ -30,18 +30,19 @@ const config = app.get('${database}')
|
|
|
30
30
|
${language === 'js' ? 'export default config' : 'module.exports = config'}
|
|
31
31
|
`
|
|
32
32
|
|
|
33
|
-
const configurationTemplate = ({ database }: ConnectionGeneratorContext) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const configurationTemplate = ({ database }: ConnectionGeneratorContext) => `${database}: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
client: { type: 'string' },
|
|
37
|
+
connection: { type: 'string' }
|
|
38
|
+
}
|
|
39
|
+
},`
|
|
41
40
|
const importTemplate = ({ database }: ConnectionGeneratorContext) =>
|
|
42
41
|
`import { ${database} } from './${database}'`
|
|
43
42
|
const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})`
|
|
44
|
-
|
|
43
|
+
|
|
44
|
+
const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
|
|
45
|
+
const toConfig = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'configuration'])
|
|
45
46
|
|
|
46
47
|
export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
47
48
|
generator(ctx)
|
|
@@ -65,15 +66,12 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
|
65
66
|
)
|
|
66
67
|
)
|
|
67
68
|
.then(
|
|
68
|
-
|
|
69
|
+
injectSource(
|
|
69
70
|
configurationTemplate,
|
|
70
71
|
before('authentication: authenticationSettingsSchema'),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
'schemas',
|
|
74
|
-
`configuration.schema.${language}`
|
|
75
|
-
])
|
|
72
|
+
toConfig,
|
|
73
|
+
false
|
|
76
74
|
)
|
|
77
75
|
)
|
|
78
|
-
.then(
|
|
79
|
-
.then(
|
|
76
|
+
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
|
77
|
+
.then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
|
|
@@ -22,18 +22,14 @@ export const mongodb = (app: Application) => {
|
|
|
22
22
|
app.set('mongodbClient', mongoClient)
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
-
const configurationTemplate = ({ database }) => `
|
|
25
|
+
const configurationTemplate = ({ database }) => ` ${database}: { type: 'string' },`;
|
|
26
26
|
const importTemplate = "import { mongodb } from './mongodb'";
|
|
27
27
|
const configureTemplate = 'app.configure(mongodb)';
|
|
28
|
-
const toAppFile = (0, pinion_1.toFile)(({ lib
|
|
28
|
+
const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
|
|
29
29
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
30
30
|
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'mongodb')))
|
|
31
|
-
.then((0,
|
|
32
|
-
|
|
33
|
-
'
|
|
34
|
-
`configuration.schema.${language}`
|
|
35
|
-
])))
|
|
36
|
-
.then((0, pinion_1.inject)((0, commons_1.getSource)(importTemplate), (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
37
|
-
.then((0, pinion_1.inject)((0, commons_1.getSource)(configureTemplate), (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
31
|
+
.then((0, commons_1.injectSource)(configurationTemplate, (0, pinion_1.before)('authentication: authenticationSettingsSchema'), (0, pinion_1.toFile)(({ lib }) => [lib, 'configuration']), false))
|
|
32
|
+
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
33
|
+
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
38
34
|
exports.generate = generate;
|
|
39
35
|
//# sourceMappingURL=mongodb.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAE9D,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAA8B,EAAE,EAAE,CAClD;;;;;;;;;;;;;;;;;;CAkBD,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CACzE,MAAM,QAAQ,uBAAuB,CAAA;AACvC,MAAM,cAAc,GAAG,qCAAqC,CAAA;AAC5D,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAClD,MAAM,SAAS,GAAG,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAExE,MAAM,QAAQ,GAAG,CAAC,GAA+B,EAAE,EAAE,CAC1D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAChE,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,qBAAqB,EACrB,IAAA,eAAM,EAAC,8CAA8C,CAAC,EACtD,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EACvE,KAAK,CACN,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAjB3E,QAAA,QAAQ,YAiBmE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { generator, toFile,
|
|
1
|
+
import { generator, toFile, before } from '@feathershq/pinion'
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
|
-
import {
|
|
3
|
+
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
5
|
const template = ({}: ConnectionGeneratorContext) =>
|
|
6
6
|
`import { MongoClient } from 'mongodb'
|
|
@@ -22,11 +22,12 @@ export const mongodb = (app: Application) => {
|
|
|
22
22
|
app.set('mongodbClient', mongoClient)
|
|
23
23
|
}
|
|
24
24
|
`
|
|
25
|
+
|
|
25
26
|
const configurationTemplate = ({ database }: ConnectionGeneratorContext) =>
|
|
26
|
-
`
|
|
27
|
+
` ${database}: { type: 'string' },`
|
|
27
28
|
const importTemplate = "import { mongodb } from './mongodb'"
|
|
28
29
|
const configureTemplate = 'app.configure(mongodb)'
|
|
29
|
-
const toAppFile = toFile<ConnectionGeneratorContext>(({ lib
|
|
30
|
+
const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
|
|
30
31
|
|
|
31
32
|
export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
32
33
|
generator(ctx)
|
|
@@ -37,15 +38,12 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
|
37
38
|
)
|
|
38
39
|
)
|
|
39
40
|
.then(
|
|
40
|
-
|
|
41
|
+
injectSource(
|
|
41
42
|
configurationTemplate,
|
|
42
43
|
before('authentication: authenticationSettingsSchema'),
|
|
43
|
-
toFile<ConnectionGeneratorContext>(({ lib
|
|
44
|
-
|
|
45
|
-
'schemas',
|
|
46
|
-
`configuration.schema.${language}`
|
|
47
|
-
])
|
|
44
|
+
toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'configuration']),
|
|
45
|
+
false
|
|
48
46
|
)
|
|
49
47
|
)
|
|
50
|
-
.then(
|
|
51
|
-
.then(
|
|
48
|
+
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
|
49
|
+
.then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
|
|
@@ -4,14 +4,14 @@ exports.generate = void 0;
|
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
6
|
const aroundTemplate = ({ camelName, name }) => `
|
|
7
|
-
import { HookContext, NextFunction } from '../declarations'
|
|
7
|
+
import type { HookContext, NextFunction } from '../declarations'
|
|
8
8
|
|
|
9
9
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
10
10
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
11
11
|
await next()
|
|
12
12
|
}
|
|
13
13
|
`;
|
|
14
|
-
const regularTemplate = ({ camelName }) => `import { HookContext } from '../declarations'
|
|
14
|
+
const regularTemplate = ({ camelName, name }) => `import type { HookContext } from '../declarations'
|
|
15
15
|
|
|
16
16
|
export const ${camelName} = async (context: HookContext) => {
|
|
17
17
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAwB,EAAE,EAAE,CAAC;;;eAGvD,SAAS;+BACO,IAAI;;;CAGlC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,SAAS,
|
|
1
|
+
{"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAwB,EAAE,EAAE,CAAC;;;eAGvD,SAAS;+BACO,IAAI;;;CAGlC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC;;eAEb,SAAS;+BACO,IAAI;EACjC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAAyB,EAAE,EAAE,CACpD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAC7E,IAAA,eAAM,EAAuB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAChF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -3,7 +3,7 @@ import { HookGeneratorContext } from '../index'
|
|
|
3
3
|
import { renderSource } from '../../commons'
|
|
4
4
|
|
|
5
5
|
const aroundTemplate = ({ camelName, name }: HookGeneratorContext) => `
|
|
6
|
-
import { HookContext, NextFunction } from '../declarations'
|
|
6
|
+
import type { HookContext, NextFunction } from '../declarations'
|
|
7
7
|
|
|
8
8
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
9
9
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -12,8 +12,9 @@ export const ${camelName} = async (context: HookContext, next: NextFunction) =>
|
|
|
12
12
|
`
|
|
13
13
|
|
|
14
14
|
const regularTemplate = ({
|
|
15
|
-
camelName
|
|
16
|
-
|
|
15
|
+
camelName,
|
|
16
|
+
name
|
|
17
|
+
}: HookGeneratorContext) => `import type { HookContext } from '../declarations'
|
|
17
18
|
|
|
18
19
|
export const ${camelName} = async (context: HookContext) => {
|
|
19
20
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
package/lib/index.js
CHANGED
|
@@ -18,8 +18,9 @@ const command = (yargs) => yargs
|
|
|
18
18
|
.command('generate', 'Run a generator', (yarg) => yarg
|
|
19
19
|
.command('app', 'Generate a new app', exports.commandRunner)
|
|
20
20
|
.command('service', 'Generate a service', exports.commandRunner)
|
|
21
|
+
.command('hook', 'Generate a hook', exports.commandRunner)
|
|
21
22
|
.command('connection', 'Connect to a different database', exports.commandRunner)
|
|
22
|
-
.command('
|
|
23
|
+
.command('authentication', 'Set up authentication with a custom entity', exports.commandRunner))
|
|
23
24
|
.usage('Usage: $0 <command> [options]')
|
|
24
25
|
.help();
|
|
25
26
|
exports.command = command;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,uCAAsE;AAE/D,MAAM,aAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IACzC,MAAM,GAAG,GAAG,IAAA,mBAAU,EAAsB;QAC1C,GAAG,IAAI,CAAC,IAAI;KACb,CAAC,CAAA;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,IAAA,qBAAY,EAAC,SAAS,EAAE,CAAC,GAAwB,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAA;AAH3E,QAAA,QAAQ,YAGmE;AAEjF,MAAM,OAAO,GAAG,CAAC,KAAW,EAAE,EAAE,CACrC,KAAK;KACF,OAAO,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC/C,IAAI;KACD,OAAO,CAAC,KAAK,EAAE,oBAAoB,EAAE,qBAAa,CAAC;KACnD,OAAO,CAAC,SAAS,EAAE,oBAAoB,EAAE,qBAAa,CAAC;KACvD,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,qBAAa,CAAC;KACjD,OAAO,CAAC,YAAY,EAAE,iCAAiC,EAAE,qBAAa,CAAC;KACvE,OAAO,CAAC,gBAAgB,EAAE,4CAA4C,EAAE,qBAAa,CAAC,CAC1F;KACA,KAAK,CAAC,+BAA+B,CAAC;KACtC,IAAI,EAAE,CAAA;AAXE,QAAA,OAAO,WAWT"}
|
package/lib/index.ts
CHANGED
|
@@ -20,8 +20,9 @@ export const command = (yargs: Argv) =>
|
|
|
20
20
|
yarg
|
|
21
21
|
.command('app', 'Generate a new app', commandRunner)
|
|
22
22
|
.command('service', 'Generate a service', commandRunner)
|
|
23
|
-
.command('connection', 'Connect to a different database', commandRunner)
|
|
24
23
|
.command('hook', 'Generate a hook', commandRunner)
|
|
24
|
+
.command('connection', 'Connect to a different database', commandRunner)
|
|
25
|
+
.command('authentication', 'Set up authentication with a custom entity', commandRunner)
|
|
25
26
|
)
|
|
26
27
|
.usage('Usage: $0 <command> [options]')
|
|
27
28
|
.help()
|
package/lib/service/index.d.ts
CHANGED
|
@@ -48,14 +48,6 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
48
48
|
* Set to true if this service is for an authentication entity
|
|
49
49
|
*/
|
|
50
50
|
isEntityService?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* The name of the schema file
|
|
53
|
-
*/
|
|
54
|
-
schemaPath: string;
|
|
55
|
-
/**
|
|
56
|
-
* The name of the resolver file
|
|
57
|
-
*/
|
|
58
|
-
resolverPath: string;
|
|
59
51
|
}
|
|
60
52
|
/**
|
|
61
53
|
* Parameters the generator is called with
|
|
@@ -110,14 +102,6 @@ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
|
110
102
|
* Set to true if this service is for an authentication entity
|
|
111
103
|
*/
|
|
112
104
|
isEntityService?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* The name of the schema file
|
|
115
|
-
*/
|
|
116
|
-
schemaPath: string;
|
|
117
|
-
/**
|
|
118
|
-
* The name of the resolver file
|
|
119
|
-
*/
|
|
120
|
-
resolverPath: string;
|
|
121
105
|
feathers: import("../commons").FeathersAppInfo;
|
|
122
106
|
pkg: import("../commons").AppPackageJson;
|
|
123
107
|
lib: string;
|
package/lib/service/index.js
CHANGED
|
@@ -56,12 +56,9 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
56
56
|
const camelName = lodash_1.default.camelCase(name);
|
|
57
57
|
const upperName = lodash_1.default.upperFirst(camelName);
|
|
58
58
|
const className = `${upperName}Service`;
|
|
59
|
-
const
|
|
60
|
-
const relative =
|
|
61
|
-
const
|
|
62
|
-
const fileName = lodash_1.default.last(pathElements);
|
|
63
|
-
const schemaPath = ['schemas', ...folder, `${fileName}.schema`].join('/');
|
|
64
|
-
const resolverPath = ['resolvers', ...folder, `${fileName}.resolver`].join('/');
|
|
59
|
+
const folder = path.split('/').filter((el) => el !== '');
|
|
60
|
+
const relative = ['', ...folder].map(() => '..').join('/');
|
|
61
|
+
const fileName = lodash_1.default.last(folder);
|
|
65
62
|
return {
|
|
66
63
|
name,
|
|
67
64
|
type,
|
|
@@ -73,8 +70,6 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
73
70
|
kebabName,
|
|
74
71
|
camelName,
|
|
75
72
|
relative,
|
|
76
|
-
resolverPath,
|
|
77
|
-
schemaPath,
|
|
78
73
|
...ctx
|
|
79
74
|
};
|
|
80
75
|
})
|
package/lib/service/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAAoE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAAoE;AA2D7D,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAE,EAAE,CACzD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,eAAM,EACJ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IACzD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,IAAI;QACX,OAAO,EAAE,mCAAmC;KAC7C;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,IAAI;QACX,OAAO,EAAE,iDAAiD;QAC1D,OAAO,EAAE,CAAC,OAAkC,EAAE,EAAE,CAAC,GAAG,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;KAChF;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,cAAc,KAAK,SAAS,IAAI,CAAC,eAAe;QACtD,OAAO,EAAE,2CAA2C;KACrD;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,IAAI;QACX,OAAO,EAAE,6BAA6B;QACtC,OAAO,EAAE,IAAA,4BAAk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C;KACpE,IAAI,CAAC,IAAA,qBAAY,EAA0B,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAA;AA1EnF,QAAA,QAAQ,YA0E2E"}
|
package/lib/service/index.ts
CHANGED
|
@@ -52,14 +52,6 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
52
52
|
* Set to true if this service is for an authentication entity
|
|
53
53
|
*/
|
|
54
54
|
isEntityService?: boolean
|
|
55
|
-
/**
|
|
56
|
-
* The name of the schema file
|
|
57
|
-
*/
|
|
58
|
-
schemaPath: string
|
|
59
|
-
/**
|
|
60
|
-
* The name of the resolver file
|
|
61
|
-
*/
|
|
62
|
-
resolverPath: string
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
/**
|
|
@@ -123,12 +115,9 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
|
|
|
123
115
|
const upperName = _.upperFirst(camelName)
|
|
124
116
|
const className = `${upperName}Service`
|
|
125
117
|
|
|
126
|
-
const
|
|
127
|
-
const relative =
|
|
128
|
-
const
|
|
129
|
-
const fileName = _.last(pathElements)
|
|
130
|
-
const schemaPath = ['schemas', ...folder, `${fileName}.schema`].join('/')
|
|
131
|
-
const resolverPath = ['resolvers', ...folder, `${fileName}.resolver`].join('/')
|
|
118
|
+
const folder = path.split('/').filter((el) => el !== '')
|
|
119
|
+
const relative = ['', ...folder].map(() => '..').join('/')
|
|
120
|
+
const fileName = _.last(folder)
|
|
132
121
|
|
|
133
122
|
return {
|
|
134
123
|
name,
|
|
@@ -141,8 +130,6 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
|
|
|
141
130
|
kebabName,
|
|
142
131
|
camelName,
|
|
143
132
|
relative,
|
|
144
|
-
resolverPath,
|
|
145
|
-
schemaPath,
|
|
146
133
|
...ctx
|
|
147
134
|
}
|
|
148
135
|
})
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
)
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const schemaImports = ({ upperName,
|
|
5
|
+
const schemaImports = ({ upperName, folder, fileName }) => `import type {
|
|
6
6
|
${upperName}Data,
|
|
7
7
|
${upperName}Result,
|
|
8
8
|
${upperName}Query,
|
|
9
|
-
} from '
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
} from './services/${folder.join('/')}/${fileName}.schema'
|
|
10
|
+
|
|
11
|
+
export * from './services/${folder.join('/')}/${fileName}.schema'`;
|
|
12
|
+
const declarationTemplate = ({ path, upperName }) => ` '${path}': Service<${upperName}Result, ${upperName}Data, Params<${upperName}Query>>`;
|
|
13
|
+
const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client.ts']);
|
|
14
|
+
const generate = async (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(schemaImports, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile), (0, pinion_1.inject)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
|
|
15
15
|
exports.generate = generate;
|
|
16
16
|
//# sourceMappingURL=client.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAG3E,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAG3E,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;IAChF,SAAS;IACT,SAAS;IACT,SAAS;qBACQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ;;4BAErB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,UAAU,CAAA;AAElE,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC3E,MAAM,IAAI,cAAc,SAAS,WAAW,SAAS,gBAAgB,SAAS,SAAS,CAAA;AAEzF,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAA;AAE9E,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA4B,EAAE,EAAE,CAC7D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,eAAM,EAAC,aAAa,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,EACzE,IAAA,eAAM,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CAClF,CACF,CAAA;AAPU,QAAA,QAAQ,YAOlB"}
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import { generator, inject, toFile, when, after } from '@feathershq/pinion'
|
|
2
2
|
import { ServiceGeneratorContext } from '../index'
|
|
3
3
|
|
|
4
|
-
const schemaImports = ({ upperName,
|
|
4
|
+
const schemaImports = ({ upperName, folder, fileName }: ServiceGeneratorContext) => `import type {
|
|
5
5
|
${upperName}Data,
|
|
6
6
|
${upperName}Result,
|
|
7
7
|
${upperName}Query,
|
|
8
|
-
} from '
|
|
8
|
+
} from './services/${folder.join('/')}/${fileName}.schema'
|
|
9
|
+
|
|
10
|
+
export * from './services/${folder.join('/')}/${fileName}.schema'`
|
|
11
|
+
|
|
9
12
|
const declarationTemplate = ({ path, upperName }: ServiceGeneratorContext) =>
|
|
10
|
-
` '${path}': Service<${upperName}
|
|
13
|
+
` '${path}': Service<${upperName}Result, ${upperName}Data, Params<${upperName}Query>>`
|
|
11
14
|
|
|
12
|
-
const toClientFile = toFile<ServiceGeneratorContext>(({ lib
|
|
15
|
+
const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client.ts'])
|
|
13
16
|
|
|
14
17
|
export const generate = async (ctx: ServiceGeneratorContext) =>
|
|
15
|
-
generator(ctx)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
)
|
|
22
|
-
.then(
|
|
23
|
-
when(
|
|
24
|
-
(ctx) => ctx.language === 'ts',
|
|
25
|
-
inject(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
|
|
26
|
-
)
|
|
18
|
+
generator(ctx).then(
|
|
19
|
+
when(
|
|
20
|
+
(ctx) => ctx.language === 'ts',
|
|
21
|
+
inject(schemaImports, after("from '@feathersjs/feathers'"), toClientFile),
|
|
22
|
+
inject(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
|
|
27
23
|
)
|
|
24
|
+
)
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ camelName, upperName, relative,
|
|
6
|
+
const template = ({ camelName, upperName, relative, fileName }) => `import { resolve } from '@feathersjs/schema'
|
|
7
7
|
import type { HookContext } from '${relative}/declarations'
|
|
8
8
|
|
|
9
9
|
import type {
|
|
@@ -11,13 +11,13 @@ import type {
|
|
|
11
11
|
${upperName}Patch,
|
|
12
12
|
${upperName}Result,
|
|
13
13
|
${upperName}Query,
|
|
14
|
-
} from '
|
|
14
|
+
} from './${fileName}.schema'
|
|
15
15
|
import {
|
|
16
16
|
${camelName}DataSchema,
|
|
17
17
|
${camelName}PatchSchema,
|
|
18
18
|
${camelName}ResultSchema,
|
|
19
19
|
${camelName}QuerySchema
|
|
20
|
-
} from '
|
|
20
|
+
} from './${fileName}.schema'
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
// Resolver for the basic data model (e.g. creating new entries)
|
|
@@ -65,7 +65,7 @@ export const ${camelName}Resolvers = {
|
|
|
65
65
|
`;
|
|
66
66
|
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
67
67
|
lib,
|
|
68
|
-
'
|
|
68
|
+
'services',
|
|
69
69
|
...folder,
|
|
70
70
|
`${fileName}.resolver`
|
|
71
71
|
])));
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|