@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
|
@@ -2,7 +2,7 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({ camelName, upperName, relative,
|
|
5
|
+
const template = ({ camelName, upperName, relative, fileName }: ServiceGeneratorContext) =>
|
|
6
6
|
`import { resolve } from '@feathersjs/schema'
|
|
7
7
|
import type { HookContext } from '${relative}/declarations'
|
|
8
8
|
|
|
@@ -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)
|
|
@@ -70,7 +70,7 @@ export const generate = (ctx: ServiceGeneratorContext) =>
|
|
|
70
70
|
template,
|
|
71
71
|
toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
|
|
72
72
|
lib,
|
|
73
|
-
'
|
|
73
|
+
'services',
|
|
74
74
|
...folder,
|
|
75
75
|
`${fileName}.resolver`
|
|
76
76
|
])
|
|
@@ -45,7 +45,7 @@ export const ${camelName}ResultSchema = schema({
|
|
|
45
45
|
properties: {
|
|
46
46
|
...${camelName}DataSchema.properties,
|
|
47
47
|
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
48
|
-
type: 'string'
|
|
48
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
} as const)
|
|
@@ -67,7 +67,7 @@ export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
|
|
|
67
67
|
`;
|
|
68
68
|
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
69
69
|
lib,
|
|
70
|
-
'
|
|
70
|
+
'services',
|
|
71
71
|
...folder,
|
|
72
72
|
`${fileName}.schema`
|
|
73
73
|
])));
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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"}
|
|
@@ -45,7 +45,7 @@ export const ${camelName}ResultSchema = schema({
|
|
|
45
45
|
properties: {
|
|
46
46
|
...${camelName}DataSchema.properties,
|
|
47
47
|
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
48
|
-
type: 'string'
|
|
48
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
} as const)
|
|
@@ -72,7 +72,7 @@ export const generate = (ctx: ServiceGeneratorContext) =>
|
|
|
72
72
|
template,
|
|
73
73
|
toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
|
|
74
74
|
lib,
|
|
75
|
-
'
|
|
75
|
+
'services',
|
|
76
76
|
...folder,
|
|
77
77
|
`${fileName}.schema`
|
|
78
78
|
])
|
|
@@ -3,56 +3,9 @@ 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 = ({ relative, path, className,
|
|
7
|
-
${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
8
|
-
import type { Application } from '${relative}/declarations'
|
|
9
|
-
import type {
|
|
10
|
-
${upperName}Data,
|
|
11
|
-
${upperName}Result,
|
|
12
|
-
${upperName}Query,
|
|
13
|
-
} from '${relative}/${schemaPath}'
|
|
14
|
-
import { ${camelName}Resolvers } from '${relative}/${resolverPath}'
|
|
6
|
+
const template = ({ relative, path, className, camelName, fileName }) => `import type { Application } from '${relative}/declarations'
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
around: {
|
|
18
|
-
all: [${authentication
|
|
19
|
-
? `
|
|
20
|
-
authenticate('jwt'),`
|
|
21
|
-
: ''} ${!isEntityService
|
|
22
|
-
? `
|
|
23
|
-
resolveAll(${camelName}Resolvers)`
|
|
24
|
-
: ''}
|
|
25
|
-
]${isEntityService
|
|
26
|
-
? `,
|
|
27
|
-
get: [
|
|
28
|
-
authenticate('jwt'),
|
|
29
|
-
resolveAll(${camelName}Resolvers)
|
|
30
|
-
],
|
|
31
|
-
find: [
|
|
32
|
-
authenticate('jwt'),
|
|
33
|
-
resolveAll(${camelName}Resolvers)
|
|
34
|
-
],
|
|
35
|
-
create: [
|
|
36
|
-
resolveAll(${camelName}Resolvers)
|
|
37
|
-
],
|
|
38
|
-
patch: [
|
|
39
|
-
authenticate('jwt'),
|
|
40
|
-
resolveAll(${camelName}Resolvers)
|
|
41
|
-
],
|
|
42
|
-
update: [
|
|
43
|
-
authenticate('jwt'),
|
|
44
|
-
resolveAll(${camelName}Resolvers)
|
|
45
|
-
],
|
|
46
|
-
remove: [
|
|
47
|
-
authenticate('jwt'),
|
|
48
|
-
resolveAll(${camelName}Resolvers)
|
|
49
|
-
]`
|
|
50
|
-
: ''}
|
|
51
|
-
},
|
|
52
|
-
before: {},
|
|
53
|
-
after: {},
|
|
54
|
-
error: {}
|
|
55
|
-
}
|
|
8
|
+
import { ${className}, ${camelName}Hooks } from './${fileName}.class'
|
|
56
9
|
|
|
57
10
|
// A configure function that registers the service and its hooks via \`app.configure\`
|
|
58
11
|
export function ${camelName} (app: Application) {
|
|
@@ -67,7 +20,7 @@ export function ${camelName} (app: Application) {
|
|
|
67
20
|
events: []
|
|
68
21
|
})
|
|
69
22
|
// Initialize hooks
|
|
70
|
-
app.service('${path}').hooks(
|
|
23
|
+
app.service('${path}').hooks(${camelName}Hooks)
|
|
71
24
|
}
|
|
72
25
|
|
|
73
26
|
// Add this service to the service type index
|
|
@@ -77,16 +30,17 @@ declare module '${relative}/declarations' {
|
|
|
77
30
|
}
|
|
78
31
|
}
|
|
79
32
|
`;
|
|
80
|
-
const importTemplate = ({ camelName,
|
|
33
|
+
const importTemplate = ({ camelName, folder, fileName }) => `import { ${camelName} } from './${folder.join('/')}/${fileName}.service'`;
|
|
81
34
|
const configureTemplate = ({ camelName }) => ` app.configure(${camelName})`;
|
|
82
|
-
const toServiceIndex = (0, pinion_1.toFile)(({ lib
|
|
35
|
+
const toServiceIndex = (0, pinion_1.toFile)(({ lib }) => [lib, 'services', `index`]);
|
|
36
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
37
|
+
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
83
38
|
lib,
|
|
84
39
|
'services',
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.then((0, commons_1.
|
|
89
|
-
.then((0,
|
|
90
|
-
.then((0, pinion_1.inject)(configureTemplate, (0, pinion_1.after)('export const services'), toServiceIndex));
|
|
40
|
+
...folder,
|
|
41
|
+
`${fileName}.service`
|
|
42
|
+
])))
|
|
43
|
+
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.prepend)(), toServiceIndex))
|
|
44
|
+
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.after)('export const services'), toServiceIndex));
|
|
91
45
|
exports.generate = generate;
|
|
92
46
|
//# sourceMappingURL=service.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/service.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"service.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/service.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AACtE,2CAA0D;AAG1D,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAC/F,qCAAqC,QAAQ;;WAEpC,SAAS,KAAK,SAAS,mBAAmB,QAAQ;;;kBAG3C,SAAS;;;;;aAKd,IAAI,UAAU,SAAS;;;;;;;iBAOnB,IAAI,YAAY,SAAS;;;;kBAIxB,QAAQ;;OAEnB,IAAI,MAAM,SAAS;;;CAGzB,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAClF,YAAY,SAAS,cAAc,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,WAAW,CAAA;AAE5E,MAAM,iBAAiB,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAAC,mBAAmB,SAAS,GAAG,CAAA;AAErG,MAAM,cAAc,GAAG,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAA2B,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;AAExF,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,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,UAAU;CACtB,CAAC,CACH,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,gBAAO,GAAE,EAAE,cAAc,CAAC,CAAC;KAC7D,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,cAAK,EAAC,uBAAuB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;AAd7E,QAAA,QAAQ,YAcqE"}
|
|
@@ -1,74 +1,11 @@
|
|
|
1
|
-
import { generator,
|
|
2
|
-
import {
|
|
1
|
+
import { generator, prepend, toFile, after } from '@feathershq/pinion'
|
|
2
|
+
import { injectSource, renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({
|
|
6
|
-
relative
|
|
7
|
-
path,
|
|
8
|
-
className,
|
|
9
|
-
schemaPath,
|
|
10
|
-
resolverPath,
|
|
11
|
-
camelName,
|
|
12
|
-
upperName,
|
|
13
|
-
isEntityService,
|
|
14
|
-
authentication
|
|
15
|
-
}: ServiceGeneratorContext) =>
|
|
16
|
-
`import { resolveAll } from '@feathersjs/schema'
|
|
17
|
-
${isEntityService || authentication ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
18
|
-
import type { Application } from '${relative}/declarations'
|
|
19
|
-
import type {
|
|
20
|
-
${upperName}Data,
|
|
21
|
-
${upperName}Result,
|
|
22
|
-
${upperName}Query,
|
|
23
|
-
} from '${relative}/${schemaPath}'
|
|
24
|
-
import { ${camelName}Resolvers } from '${relative}/${resolverPath}'
|
|
5
|
+
const template = ({ relative, path, className, camelName, fileName }: ServiceGeneratorContext) =>
|
|
6
|
+
`import type { Application } from '${relative}/declarations'
|
|
25
7
|
|
|
26
|
-
|
|
27
|
-
around: {
|
|
28
|
-
all: [${
|
|
29
|
-
authentication
|
|
30
|
-
? `
|
|
31
|
-
authenticate('jwt'),`
|
|
32
|
-
: ''
|
|
33
|
-
} ${
|
|
34
|
-
!isEntityService
|
|
35
|
-
? `
|
|
36
|
-
resolveAll(${camelName}Resolvers)`
|
|
37
|
-
: ''
|
|
38
|
-
}
|
|
39
|
-
]${
|
|
40
|
-
isEntityService
|
|
41
|
-
? `,
|
|
42
|
-
get: [
|
|
43
|
-
authenticate('jwt'),
|
|
44
|
-
resolveAll(${camelName}Resolvers)
|
|
45
|
-
],
|
|
46
|
-
find: [
|
|
47
|
-
authenticate('jwt'),
|
|
48
|
-
resolveAll(${camelName}Resolvers)
|
|
49
|
-
],
|
|
50
|
-
create: [
|
|
51
|
-
resolveAll(${camelName}Resolvers)
|
|
52
|
-
],
|
|
53
|
-
patch: [
|
|
54
|
-
authenticate('jwt'),
|
|
55
|
-
resolveAll(${camelName}Resolvers)
|
|
56
|
-
],
|
|
57
|
-
update: [
|
|
58
|
-
authenticate('jwt'),
|
|
59
|
-
resolveAll(${camelName}Resolvers)
|
|
60
|
-
],
|
|
61
|
-
remove: [
|
|
62
|
-
authenticate('jwt'),
|
|
63
|
-
resolveAll(${camelName}Resolvers)
|
|
64
|
-
]`
|
|
65
|
-
: ''
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
before: {},
|
|
69
|
-
after: {},
|
|
70
|
-
error: {}
|
|
71
|
-
}
|
|
8
|
+
import { ${className}, ${camelName}Hooks } from './${fileName}.class'
|
|
72
9
|
|
|
73
10
|
// A configure function that registers the service and its hooks via \`app.configure\`
|
|
74
11
|
export function ${camelName} (app: Application) {
|
|
@@ -83,7 +20,7 @@ export function ${camelName} (app: Application) {
|
|
|
83
20
|
events: []
|
|
84
21
|
})
|
|
85
22
|
// Initialize hooks
|
|
86
|
-
app.service('${path}').hooks(
|
|
23
|
+
app.service('${path}').hooks(${camelName}Hooks)
|
|
87
24
|
}
|
|
88
25
|
|
|
89
26
|
// Add this service to the service type index
|
|
@@ -94,24 +31,25 @@ declare module '${relative}/declarations' {
|
|
|
94
31
|
}
|
|
95
32
|
`
|
|
96
33
|
|
|
97
|
-
const importTemplate = ({ camelName,
|
|
98
|
-
`import { ${camelName} } from './${
|
|
34
|
+
const importTemplate = ({ camelName, folder, fileName }: ServiceGeneratorContext) =>
|
|
35
|
+
`import { ${camelName} } from './${folder.join('/')}/${fileName}.service'`
|
|
99
36
|
|
|
100
37
|
const configureTemplate = ({ camelName }: ServiceGeneratorContext) => ` app.configure(${camelName})`
|
|
101
38
|
|
|
102
|
-
const toServiceIndex = toFile(({ lib
|
|
103
|
-
lib,
|
|
104
|
-
'services',
|
|
105
|
-
`index.${language}`
|
|
106
|
-
])
|
|
39
|
+
const toServiceIndex = toFile(({ lib }: ServiceGeneratorContext) => [lib, 'services', `index`])
|
|
107
40
|
|
|
108
41
|
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
109
42
|
generator(ctx)
|
|
110
43
|
.then(
|
|
111
44
|
renderSource(
|
|
112
45
|
template,
|
|
113
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
46
|
+
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
47
|
+
lib,
|
|
48
|
+
'services',
|
|
49
|
+
...folder,
|
|
50
|
+
`${fileName}.service`
|
|
51
|
+
])
|
|
114
52
|
)
|
|
115
53
|
)
|
|
116
|
-
.then(
|
|
117
|
-
.then(
|
|
54
|
+
.then(injectSource(importTemplate, prepend(), toServiceIndex))
|
|
55
|
+
.then(injectSource(configureTemplate, after('export const services'), toServiceIndex))
|
|
@@ -3,10 +3,10 @@ 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 = ({ relative, lib, path
|
|
6
|
+
const template = ({ relative, lib, path }) => `import assert from 'assert'
|
|
7
7
|
import { app } from '../${relative}/${lib}/app'
|
|
8
8
|
|
|
9
|
-
describe('${
|
|
9
|
+
describe('${path} service', () => {
|
|
10
10
|
it('registered the service', () => {
|
|
11
11
|
const service = app.service('${path}')
|
|
12
12
|
|
|
@@ -14,11 +14,11 @@ describe('${name} service', () => {
|
|
|
14
14
|
})
|
|
15
15
|
})
|
|
16
16
|
`;
|
|
17
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test, folder,
|
|
17
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test, folder, fileName }) => [
|
|
18
18
|
test,
|
|
19
19
|
'services',
|
|
20
20
|
...folder,
|
|
21
|
-
`${
|
|
21
|
+
`${fileName}.test`
|
|
22
22
|
])));
|
|
23
23
|
exports.generate = generate;
|
|
24
24
|
//# sourceMappingURL=test.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAA2B,EAAE,EAAE,CACpE;0BACwB,QAAQ,IAAI,GAAG;;YAE7B,IAAI;;mCAEmB,IAAI;;;;;CAKtC,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,EAA0B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC9D,IAAI;IACJ,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,OAAO;CACnB,CAAC,CACH,CACF,CAAA;AAXU,QAAA,QAAQ,YAWlB"}
|
|
@@ -2,11 +2,11 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({ relative, lib, path
|
|
5
|
+
const template = ({ relative, lib, path }: ServiceGeneratorContext) =>
|
|
6
6
|
`import assert from 'assert'
|
|
7
7
|
import { app } from '../${relative}/${lib}/app'
|
|
8
8
|
|
|
9
|
-
describe('${
|
|
9
|
+
describe('${path} service', () => {
|
|
10
10
|
it('registered the service', () => {
|
|
11
11
|
const service = app.service('${path}')
|
|
12
12
|
|
|
@@ -19,11 +19,11 @@ export const generate = (ctx: ServiceGeneratorContext) =>
|
|
|
19
19
|
generator(ctx).then(
|
|
20
20
|
renderSource(
|
|
21
21
|
template,
|
|
22
|
-
toFile<ServiceGeneratorContext>(({ test, folder,
|
|
22
|
+
toFile<ServiceGeneratorContext>(({ test, folder, fileName }) => [
|
|
23
23
|
test,
|
|
24
24
|
'services',
|
|
25
25
|
...folder,
|
|
26
|
-
`${
|
|
26
|
+
`${fileName}.test`
|
|
27
27
|
])
|
|
28
28
|
)
|
|
29
29
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ServiceGeneratorContext } from '../index';
|
|
2
|
-
export declare const template: ({ className, upperName }: ServiceGeneratorContext) => string;
|
|
2
|
+
export declare const template: ({ className, upperName, relative }: ServiceGeneratorContext) => string;
|
|
3
3
|
export declare const importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'";
|
|
4
4
|
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = exports.importTemplate = exports.template = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ className, upperName }) => `
|
|
6
|
+
const template = ({ className, upperName, relative }) => `import type { Application } from '${relative}/declarations'
|
|
7
|
+
|
|
8
|
+
export interface ${className}Options {
|
|
7
9
|
app: Application
|
|
8
10
|
}
|
|
9
11
|
|
|
@@ -22,9 +24,9 @@ export class ${className} {
|
|
|
22
24
|
|
|
23
25
|
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
24
26
|
return {
|
|
25
|
-
id:
|
|
27
|
+
id: 0,
|
|
26
28
|
text: \`A new message with ID: \${id}!\`
|
|
27
|
-
}
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}Result>
|
|
@@ -35,45 +37,51 @@ export class ${className} {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
return {
|
|
38
|
-
id:
|
|
40
|
+
id: 0,
|
|
39
41
|
...data
|
|
40
|
-
}
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
44
46
|
return {
|
|
45
|
-
id:
|
|
47
|
+
id: 0,
|
|
46
48
|
...data
|
|
47
|
-
}
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
51
53
|
return {
|
|
52
|
-
id:
|
|
54
|
+
id: 0,
|
|
53
55
|
...data
|
|
54
|
-
}
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
58
60
|
return {
|
|
59
|
-
id:
|
|
61
|
+
id: 0,
|
|
60
62
|
text: 'removed'
|
|
61
|
-
}
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
`;
|
|
65
67
|
exports.template = template;
|
|
66
68
|
exports.importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'";
|
|
67
69
|
const optionTemplate = ({}) => ` app`;
|
|
68
|
-
const toServiceFile = (0, pinion_1.toFile)(({ lib,
|
|
70
|
+
const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
71
|
+
lib,
|
|
72
|
+
'services',
|
|
73
|
+
...folder,
|
|
74
|
+
`${fileName}.service`
|
|
75
|
+
]);
|
|
76
|
+
const toClassFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
69
77
|
lib,
|
|
70
78
|
'services',
|
|
71
79
|
...folder,
|
|
72
|
-
`${fileName}
|
|
80
|
+
`${fileName}.class`
|
|
73
81
|
]);
|
|
74
82
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
75
|
-
.then((0,
|
|
76
|
-
.then((0,
|
|
77
|
-
.then((0,
|
|
83
|
+
.then((0, commons_1.injectSource)(exports.template, (0, pinion_1.append)(), toClassFile))
|
|
84
|
+
.then((0, commons_1.injectSource)(exports.importTemplate, (0, pinion_1.prepend)(), toClassFile))
|
|
85
|
+
.then((0, commons_1.injectSource)(optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile, false));
|
|
78
86
|
exports.generate = generate;
|
|
79
87
|
//# sourceMappingURL=custom.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.tpl.js","sourceRoot":"","sources":["../../../src/service/type/custom.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"custom.tpl.js","sourceRoot":"","sources":["../../../src/service/type/custom.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAA2B,EAAE,EAAE,CACtF,qCAAqC,QAAQ;;mBAE5B,SAAS;;;;mBAIT,SAAS,yBAAyB,SAAS;;;;;eAK/C,SAAS;iCACS,SAAS;;;0BAGhB,SAAS,oBAAoB,SAAS;;;;iCAI/B,SAAS,oBAAoB,SAAS;;;;;;;wBAO/C,SAAS,kBAAkB,SAAS,oBAAoB,SAAS;wBACjE,SAAS,oBAAoB,SAAS,oBAAoB,SAAS;wBACnE,SAAS,QAAQ,SAAS,oBAAoB,SAAS,oBAAoB,SAAS,UAAU,SAAS;;;;;;;;;;;wCAWvF,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;uCAOnE,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;4CAO7D,SAAS,oBAAoB,SAAS;;;;;;;CAOjF,CAAA;AA7DY,QAAA,QAAQ,YA6DpB;AAEY,QAAA,cAAc,GAAG,oEAAoE,CAAA;AAElG,MAAM,cAAc,GAAG,CAAC,EAA2B,EAAE,EAAE,CAAC,SAAS,CAAA;AAEjE,MAAM,aAAa,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACnF,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,UAAU;CACtB,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACjF,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,sBAAY,EAAC,gBAAQ,EAAE,IAAA,eAAM,GAAE,EAAE,WAAW,CAAC,CAAC;KACnD,IAAI,CAAC,IAAA,sBAAY,EAAC,sBAAc,EAAE,IAAA,gBAAO,GAAE,EAAE,WAAW,CAAC,CAAC;KAC1D,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,iBAAiB,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC,CAAA;AAJ1E,QAAA,QAAQ,YAIkE"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { generator,
|
|
2
|
-
import {
|
|
1
|
+
import { generator, toFile, after, prepend, append } from '@feathershq/pinion'
|
|
2
|
+
import { injectSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
export const template = ({ className, upperName }: ServiceGeneratorContext) =>
|
|
6
|
-
`
|
|
5
|
+
export const template = ({ className, upperName, relative }: ServiceGeneratorContext) =>
|
|
6
|
+
`import type { Application } from '${relative}/declarations'
|
|
7
|
+
|
|
8
|
+
export interface ${className}Options {
|
|
7
9
|
app: Application
|
|
8
10
|
}
|
|
9
11
|
|
|
@@ -22,9 +24,9 @@ export class ${className} {
|
|
|
22
24
|
|
|
23
25
|
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
24
26
|
return {
|
|
25
|
-
id:
|
|
27
|
+
id: 0,
|
|
26
28
|
text: \`A new message with ID: \${id}!\`
|
|
27
|
-
}
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}Result>
|
|
@@ -35,30 +37,30 @@ export class ${className} {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
return {
|
|
38
|
-
id:
|
|
40
|
+
id: 0,
|
|
39
41
|
...data
|
|
40
|
-
}
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
44
46
|
return {
|
|
45
|
-
id:
|
|
47
|
+
id: 0,
|
|
46
48
|
...data
|
|
47
|
-
}
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
51
53
|
return {
|
|
52
|
-
id:
|
|
54
|
+
id: 0,
|
|
53
55
|
...data
|
|
54
|
-
}
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}Result> {
|
|
58
60
|
return {
|
|
59
|
-
id:
|
|
61
|
+
id: 0,
|
|
60
62
|
text: 'removed'
|
|
61
|
-
}
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
`
|
|
@@ -67,15 +69,22 @@ export const importTemplate = "import type { Id, NullableId, Params } from '@fea
|
|
|
67
69
|
|
|
68
70
|
const optionTemplate = ({}: ServiceGeneratorContext) => ` app`
|
|
69
71
|
|
|
70
|
-
const toServiceFile = toFile<ServiceGeneratorContext>(({ lib,
|
|
72
|
+
const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
73
|
+
lib,
|
|
74
|
+
'services',
|
|
75
|
+
...folder,
|
|
76
|
+
`${fileName}.service`
|
|
77
|
+
])
|
|
78
|
+
|
|
79
|
+
const toClassFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
71
80
|
lib,
|
|
72
81
|
'services',
|
|
73
82
|
...folder,
|
|
74
|
-
`${fileName}
|
|
83
|
+
`${fileName}.class`
|
|
75
84
|
])
|
|
76
85
|
|
|
77
86
|
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
78
87
|
generator(ctx)
|
|
79
|
-
.then(
|
|
80
|
-
.then(
|
|
81
|
-
.then(
|
|
88
|
+
.then(injectSource(template, append(), toClassFile))
|
|
89
|
+
.then(injectSource(importTemplate, prepend(), toClassFile))
|
|
90
|
+
.then(injectSource(optionTemplate, after('const options ='), toServiceFile, false))
|
|
@@ -30,16 +30,22 @@ const optionTemplate = ({ kebabName, feathers }) => ` paginate: app.get('pagi
|
|
|
30
30
|
Model: app.get('${feathers.database}Client'),
|
|
31
31
|
name: '${kebabName}'`;
|
|
32
32
|
exports.optionTemplate = optionTemplate;
|
|
33
|
-
const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName
|
|
33
|
+
const toServiceFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
34
34
|
lib,
|
|
35
35
|
'services',
|
|
36
36
|
...folder,
|
|
37
|
-
`${fileName}
|
|
37
|
+
`${fileName}.service`
|
|
38
|
+
]);
|
|
39
|
+
const toClassFile = (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
40
|
+
lib,
|
|
41
|
+
'services',
|
|
42
|
+
...folder,
|
|
43
|
+
`${fileName}.class`
|
|
38
44
|
]);
|
|
39
45
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
40
|
-
.then((0,
|
|
41
|
-
.then((0,
|
|
42
|
-
.then((0,
|
|
46
|
+
.then((0, commons_1.injectSource)(exports.classCode, (0, pinion_1.append)(), toClassFile))
|
|
47
|
+
.then((0, commons_1.injectSource)(exports.importTemplate, (0, pinion_1.prepend)(), toClassFile))
|
|
48
|
+
.then((0, commons_1.injectSource)(exports.optionTemplate, (0, pinion_1.after)('const options ='), toServiceFile, false))
|
|
43
49
|
.then((0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)('migrations', ({ kebabName }) => {
|
|
44
50
|
// Probably not great but it works to align with the Knex migration file format
|
|
45
51
|
const migrationDate = new Date().toISOString().replace(/\D/g, '').substring(0, 14);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,2CAA0D;AAG1D,MAAM,iBAAiB,GAAG,CAAC,EAAE,SAAS,EAA2B,EAAE,EAAE,CAAC;;;mCAGnC,SAAS;;;;;;;iCAOX,SAAS;;CAEzC,CAAA;AAEY,QAAA,cAAc,GAAG;4DAC8B,CAAA;AAErD,MAAM,SAAS,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC7E,oBAAoB,SAAS,oCAAoC,SAAS;;;;eAI7D,SAAS,wBAAwB,SAAS,WAAW,SAAS,SAAS,SAAS;;CAE9F,CAAA;AAPY,QAAA,SAAS,aAOrB;AAEM,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAA2B,EAAE,EAAE,CACjF;sBACoB,QAAQ,CAAC,QAAQ;aAC1B,SAAS,GAAG,CAAA;AAHZ,QAAA,cAAc,kBAGF;AAEzB,MAAM,aAAa,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACnF,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,UAAU;CACtB,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACjF,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,QAAQ;CACpB,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAS,EAAE,IAAA,eAAM,GAAE,EAAE,WAAW,CAAC,CAAC;KACpD,IAAI,CAAC,IAAA,sBAAY,EAAC,sBAAc,EAAE,IAAA,gBAAO,GAAE,EAAE,WAAW,CAAC,CAAC;KAC1D,IAAI,CAAC,IAAA,sBAAY,EAAC,sBAAc,EAAE,IAAA,cAAK,EAAC,iBAAiB,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;KAClF,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAA0B,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC9D,+EAA+E;IAC/E,MAAM,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAElF,OAAO,GAAG,aAAa,IAAI,SAAS,EAAE,CAAA;AACxC,CAAC,CAAC,CACH,CACF,CAAA;AAfQ,QAAA,QAAQ,YAehB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { generator,
|
|
2
|
-
import {
|
|
1
|
+
import { generator, toFile, after, prepend, append } from '@feathershq/pinion'
|
|
2
|
+
import { injectSource, renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
const migrationTemplate = ({ kebabName }: ServiceGeneratorContext) => `import type { Knex } from 'knex'
|
|
@@ -33,20 +33,25 @@ export const optionTemplate = ({ kebabName, feathers }: ServiceGeneratorContext)
|
|
|
33
33
|
Model: app.get('${feathers.database}Client'),
|
|
34
34
|
name: '${kebabName}'`
|
|
35
35
|
|
|
36
|
-
const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName
|
|
36
|
+
const toServiceFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
37
37
|
lib,
|
|
38
38
|
'services',
|
|
39
39
|
...folder,
|
|
40
|
-
`${fileName}
|
|
40
|
+
`${fileName}.service`
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
const toClassFile = toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
44
|
+
lib,
|
|
45
|
+
'services',
|
|
46
|
+
...folder,
|
|
47
|
+
`${fileName}.class`
|
|
41
48
|
])
|
|
42
49
|
|
|
43
50
|
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
44
51
|
generator(ctx)
|
|
45
|
-
.then(
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
.then(inject(getSource(importTemplate), prepend(), toServiceFile))
|
|
49
|
-
.then(inject(optionTemplate, after('const options ='), toServiceFile))
|
|
52
|
+
.then(injectSource(classCode, append(), toClassFile))
|
|
53
|
+
.then(injectSource(importTemplate, prepend(), toClassFile))
|
|
54
|
+
.then(injectSource(optionTemplate, after('const options ='), toServiceFile, false))
|
|
50
55
|
.then(
|
|
51
56
|
renderSource(
|
|
52
57
|
migrationTemplate,
|