@feathersjs/cli 5.0.0-pre.29 → 5.0.0-pre.31
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 +30 -37
- package/bin/feathers +3 -6
- package/lib/app/index.js +33 -10
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +88 -51
- package/lib/app/templates/app.test.tpl.js +1 -1
- package/lib/app/templates/app.test.tpl.js.map +1 -1
- package/lib/app/templates/app.test.tpl.ts +1 -2
- package/lib/app/templates/app.tpl.js +7 -7
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +7 -9
- package/lib/app/templates/channels.tpl.js +1 -1
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +1 -2
- package/lib/app/templates/{configuration.tpl.d.ts → client.test.tpl.d.ts} +0 -0
- package/lib/app/templates/client.test.tpl.js +27 -0
- package/lib/app/templates/client.test.tpl.js.map +1 -0
- package/lib/app/templates/client.test.tpl.ts +26 -0
- package/lib/app/templates/client.tpl.js +3 -3
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +3 -4
- package/lib/app/templates/declarations.tpl.js +3 -3
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +5 -4
- package/lib/app/templates/index.html.tpl.js +12 -52
- package/lib/app/templates/index.html.tpl.js.map +1 -1
- package/lib/app/templates/index.html.tpl.ts +12 -53
- package/lib/app/templates/index.tpl.js +1 -1
- package/lib/app/templates/index.tpl.js.map +1 -1
- package/lib/app/templates/index.tpl.ts +1 -2
- package/lib/app/templates/logger.tpl.js +9 -3
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +10 -4
- package/lib/app/templates/package.json.tpl.js +4 -3
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -3
- package/lib/app/templates/readme.md.tpl.js +11 -7
- package/lib/app/templates/readme.md.tpl.js.map +1 -1
- package/lib/app/templates/readme.md.tpl.ts +15 -8
- package/lib/app/templates/schemas.tpl.d.ts +2 -0
- package/lib/app/templates/schemas.tpl.js +75 -0
- package/lib/app/templates/schemas.tpl.js.map +1 -0
- package/lib/app/templates/schemas.tpl.ts +89 -0
- package/lib/app/templates/services.tpl.js +1 -1
- package/lib/app/templates/services.tpl.js.map +1 -1
- package/lib/app/templates/services.tpl.ts +1 -2
- package/lib/authentication/index.d.ts +5 -3
- package/lib/authentication/index.js +12 -3
- package/lib/authentication/index.js.map +1 -1
- package/lib/authentication/index.ts +23 -5
- package/lib/authentication/templates/authentication.tpl.js +1 -1
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +3 -2
- package/lib/authentication/templates/{test.tpl.d.ts → client.test.tpl.d.ts} +0 -0
- package/lib/authentication/templates/client.test.tpl.js +66 -0
- package/lib/authentication/templates/client.test.tpl.js.map +1 -0
- package/lib/authentication/templates/client.test.tpl.ts +80 -0
- package/lib/{service/templates/schema.tpl.d.ts → authentication/templates/client.tpl.d.ts} +1 -1
- package/lib/authentication/templates/client.tpl.js +14 -0
- package/lib/authentication/templates/client.tpl.js.map +1 -0
- package/lib/authentication/templates/client.tpl.ts +19 -0
- package/lib/authentication/templates/config.tpl.js +1 -1
- package/lib/authentication/templates/config.tpl.js.map +1 -1
- package/lib/authentication/templates/config.tpl.ts +1 -1
- package/lib/authentication/templates/declarations.tpl.js +3 -3
- package/lib/authentication/templates/declarations.tpl.js.map +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +9 -4
- package/lib/authentication/templates/knex.tpl.js +4 -4
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +5 -5
- package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/authentication/templates/schema.json.tpl.js +92 -0
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.json.tpl.ts +108 -0
- package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.js +77 -0
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
- package/lib/cli.d.ts +6 -0
- package/lib/cli.js +75 -0
- package/lib/cli.js.map +1 -0
- package/lib/cli.ts +68 -0
- package/lib/commons.d.ts +14 -1
- package/lib/commons.js +24 -4
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +29 -1
- package/lib/connection/index.d.ts +5 -3
- package/lib/connection/index.js +5 -3
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +19 -5
- package/lib/connection/templates/knex.tpl.js +2 -12
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -20
- package/lib/connection/templates/mongodb.tpl.js +1 -3
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +1 -12
- package/lib/hook/index.d.ts +1 -1
- package/lib/hook/index.js +3 -0
- package/lib/hook/index.js.map +1 -1
- package/lib/hook/index.ts +3 -1
- package/lib/hook/templates/hook.tpl.js +2 -3
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +5 -3
- package/lib/index.d.ts +2 -16
- package/lib/index.js +16 -24
- package/lib/index.js.map +1 -1
- package/lib/index.ts +2 -28
- package/lib/service/index.d.ts +10 -60
- package/lib/service/index.js +41 -4
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +61 -7
- package/lib/service/templates/client.tpl.js +21 -18
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +52 -24
- package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.json.tpl.js +75 -0
- package/lib/service/templates/schema.json.tpl.js.map +1 -0
- package/lib/service/templates/schema.json.tpl.ts +87 -0
- package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.typebox.tpl.js +55 -0
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/service/templates/schema.typebox.tpl.ts +67 -0
- package/lib/service/templates/service.tpl.d.ts +1 -0
- package/lib/service/templates/service.tpl.js +67 -15
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +98 -19
- package/lib/service/templates/test.tpl.js +1 -1
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +1 -2
- package/lib/service/type/custom.tpl.d.ts +1 -2
- package/lib/service/type/custom.tpl.js +32 -25
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +44 -35
- package/lib/service/type/knex.tpl.d.ts +1 -3
- package/lib/service/type/knex.tpl.js +37 -25
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +54 -31
- package/lib/service/type/mongodb.tpl.d.ts +1 -2
- package/lib/service/type/mongodb.tpl.js +32 -20
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +49 -29
- package/package.json +24 -23
- package/lib/app/templates/configuration.tpl.js +0 -45
- package/lib/app/templates/configuration.tpl.js.map +0 -1
- package/lib/app/templates/configuration.tpl.ts +0 -50
- package/lib/authentication/templates/test.tpl.js +0 -43
- package/lib/authentication/templates/test.tpl.js.map +0 -1
- package/lib/authentication/templates/test.tpl.ts +0 -50
- package/lib/authentication/templates/user.resolver.tpl.js +0 -98
- package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
- package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
- package/lib/authentication/templates/user.schema.tpl.js +0 -79
- package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
- package/lib/authentication/templates/user.schema.tpl.ts +0 -87
- package/lib/service/templates/class.tpl.js +0 -63
- package/lib/service/templates/class.tpl.js.map +0 -1
- package/lib/service/templates/class.tpl.ts +0 -79
- package/lib/service/templates/resolver.tpl.js +0 -73
- package/lib/service/templates/resolver.tpl.js.map +0 -1
- package/lib/service/templates/resolver.tpl.ts +0 -78
- package/lib/service/templates/schema.tpl.js +0 -75
- package/lib/service/templates/schema.tpl.js.map +0 -1
- package/lib/service/templates/schema.tpl.ts +0 -80
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { generator, toFile, when } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { ServiceGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({
|
|
6
|
+
camelName,
|
|
7
|
+
upperName,
|
|
8
|
+
relative,
|
|
9
|
+
type
|
|
10
|
+
}: ServiceGeneratorContext) => /* ts */ `import { resolve, getDataValidator, getValidator, querySyntax } from '@feathersjs/schema'
|
|
11
|
+
import type { FromSchema } from '@feathersjs/schema'
|
|
12
|
+
|
|
13
|
+
import type { HookContext } from '${relative}/declarations'
|
|
14
|
+
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
15
|
+
|
|
16
|
+
// Main data model schema
|
|
17
|
+
export const ${camelName}Schema = {
|
|
18
|
+
$id: '${upperName}',
|
|
19
|
+
type: 'object',
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
|
|
22
|
+
properties: {
|
|
23
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
24
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
25
|
+
},
|
|
26
|
+
text: {
|
|
27
|
+
type: 'string'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} as const
|
|
31
|
+
export type ${upperName} = FromSchema<typeof ${camelName}Schema>
|
|
32
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
33
|
+
properties: {}
|
|
34
|
+
})
|
|
35
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
36
|
+
properties: {}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// Schema for creating new data
|
|
40
|
+
export const ${camelName}DataSchema = {
|
|
41
|
+
$id: '${upperName}Data',
|
|
42
|
+
type: 'object',
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
required: [ 'text' ],
|
|
45
|
+
properties: {
|
|
46
|
+
text: {
|
|
47
|
+
type: 'string'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} as const
|
|
51
|
+
export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
|
|
52
|
+
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
53
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
54
|
+
properties: {}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// Schema for allowed query properties
|
|
58
|
+
export const ${camelName}QuerySchema = {
|
|
59
|
+
$id: '${upperName}Query',
|
|
60
|
+
type: 'object',
|
|
61
|
+
additionalProperties: false,
|
|
62
|
+
properties: {
|
|
63
|
+
...querySyntax(${camelName}Schema.properties)
|
|
64
|
+
}
|
|
65
|
+
} as const
|
|
66
|
+
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
67
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
68
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
69
|
+
properties: {}
|
|
70
|
+
})
|
|
71
|
+
`
|
|
72
|
+
|
|
73
|
+
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
74
|
+
generator(ctx).then(
|
|
75
|
+
when<ServiceGeneratorContext>(
|
|
76
|
+
({ schema }) => schema === 'json',
|
|
77
|
+
renderSource(
|
|
78
|
+
template,
|
|
79
|
+
toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
|
|
80
|
+
lib,
|
|
81
|
+
'services',
|
|
82
|
+
...folder,
|
|
83
|
+
`${fileName}.schema`
|
|
84
|
+
])
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
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, type }) => /* ts */ `import { resolve } from '@feathersjs/schema'
|
|
7
|
+
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
8
|
+
import type { Static } from '@feathersjs/typebox'
|
|
9
|
+
|
|
10
|
+
import type { HookContext } from '${relative}/declarations'
|
|
11
|
+
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
12
|
+
|
|
13
|
+
// Main data model schema
|
|
14
|
+
export const ${camelName}Schema = Type.Object({
|
|
15
|
+
${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
|
|
16
|
+
text: Type.String()
|
|
17
|
+
}, { $id: '${upperName}', additionalProperties: false })
|
|
18
|
+
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
19
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
20
|
+
properties: {}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
24
|
+
properties: {}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Schema for creating new entries
|
|
28
|
+
export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, ['text'], {
|
|
29
|
+
$id: '${upperName}Data', additionalProperties: false
|
|
30
|
+
})
|
|
31
|
+
export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
|
|
32
|
+
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
33
|
+
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
|
|
34
|
+
properties: {}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// Schema for allowed query properties
|
|
38
|
+
export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, [
|
|
39
|
+
'${type === 'mongodb' ? '_id' : 'id'}', 'text'
|
|
40
|
+
], { additionalProperties: false })
|
|
41
|
+
export const ${camelName}QuerySchema = querySyntax(${camelName}QueryProperties)
|
|
42
|
+
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
43
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
44
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
45
|
+
properties: {}
|
|
46
|
+
})
|
|
47
|
+
`;
|
|
48
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'typebox', (0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
49
|
+
lib,
|
|
50
|
+
'services',
|
|
51
|
+
...folder,
|
|
52
|
+
`${fileName}.schema`
|
|
53
|
+
]))));
|
|
54
|
+
exports.generate = generate;
|
|
55
|
+
//# sourceMappingURL=schema.typebox.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACoB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;oCAIJ,QAAQ;iDACK,QAAQ;;;eAG1C,SAAS;MAClB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,mBAAmB;;eAEtD,SAAS;cACV,SAAS,oBAAoB,SAAS;eACrC,SAAS,sBAAsB,SAAS;;;;eAIxC,SAAS,8BAA8B,SAAS;;;;;eAKhD,SAAS,0BAA0B,SAAS;UACjD,SAAS;;cAEL,SAAS,wBAAwB,SAAS;eACzC,SAAS,oCAAoC,SAAS;eACtD,SAAS,0BAA0B,SAAS;;;;;eAK5C,SAAS,+BAA+B,SAAS;KAC3D,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;eAEvB,SAAS,6BAA6B,SAAS;cAChD,SAAS,yBAAyB,SAAS;eAC1C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;;;CAG3D,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,EACpC,IAAA,sBAAY,EACV,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,CACF,CAAA;AAdU,QAAA,QAAQ,YAclB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { generator, toFile, when } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { ServiceGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({
|
|
6
|
+
camelName,
|
|
7
|
+
upperName,
|
|
8
|
+
relative,
|
|
9
|
+
type
|
|
10
|
+
}: ServiceGeneratorContext) => /* ts */ `import { resolve } from '@feathersjs/schema'
|
|
11
|
+
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
12
|
+
import type { Static } from '@feathersjs/typebox'
|
|
13
|
+
|
|
14
|
+
import type { HookContext } from '${relative}/declarations'
|
|
15
|
+
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
16
|
+
|
|
17
|
+
// Main data model schema
|
|
18
|
+
export const ${camelName}Schema = Type.Object({
|
|
19
|
+
${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'},
|
|
20
|
+
text: Type.String()
|
|
21
|
+
}, { $id: '${upperName}', additionalProperties: false })
|
|
22
|
+
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
23
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
24
|
+
properties: {}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
28
|
+
properties: {}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// Schema for creating new entries
|
|
32
|
+
export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, ['text'], {
|
|
33
|
+
$id: '${upperName}Data', additionalProperties: false
|
|
34
|
+
})
|
|
35
|
+
export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
|
|
36
|
+
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
37
|
+
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
|
|
38
|
+
properties: {}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
// Schema for allowed query properties
|
|
42
|
+
export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, [
|
|
43
|
+
'${type === 'mongodb' ? '_id' : 'id'}', 'text'
|
|
44
|
+
], { additionalProperties: false })
|
|
45
|
+
export const ${camelName}QuerySchema = querySyntax(${camelName}QueryProperties)
|
|
46
|
+
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
47
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
48
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
49
|
+
properties: {}
|
|
50
|
+
})
|
|
51
|
+
`
|
|
52
|
+
|
|
53
|
+
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
54
|
+
generator(ctx).then(
|
|
55
|
+
when<ServiceGeneratorContext>(
|
|
56
|
+
({ schema }) => schema === 'typebox',
|
|
57
|
+
renderSource(
|
|
58
|
+
template,
|
|
59
|
+
toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
|
|
60
|
+
lib,
|
|
61
|
+
'services',
|
|
62
|
+
...folder,
|
|
63
|
+
`${fileName}.schema`
|
|
64
|
+
])
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
)
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ServiceGeneratorContext } from '../index';
|
|
2
|
+
export declare const template: ({ camelName, authentication, isEntityService, path, className, relative, schema, fileName }: ServiceGeneratorContext) => string;
|
|
2
3
|
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -1,26 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = void 0;
|
|
3
|
+
exports.generate = exports.template = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({
|
|
6
|
+
const template = ({ camelName, authentication, isEntityService, path, className, relative, schema, fileName }) => /* ts */ `
|
|
7
|
+
${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
8
|
+
${schema
|
|
9
|
+
? `
|
|
10
|
+
import { hooks as schemaHooks } from '@feathersjs/schema'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
${camelName}DataValidator,
|
|
14
|
+
${camelName}QueryValidator,
|
|
15
|
+
${camelName}Resolver,
|
|
16
|
+
${camelName}DataResolver,
|
|
17
|
+
${camelName}QueryResolver,
|
|
18
|
+
${camelName}ExternalResolver
|
|
19
|
+
} from './${fileName}.schema'
|
|
20
|
+
`
|
|
21
|
+
: ''}
|
|
7
22
|
|
|
8
|
-
import
|
|
23
|
+
import type { Application } from '${relative}/declarations'
|
|
24
|
+
import { ${className}, getOptions } from './${fileName}.class'
|
|
9
25
|
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
const options = { // Service options will go here
|
|
13
|
-
}
|
|
26
|
+
export * from './${fileName}.class'
|
|
27
|
+
${schema ? `export * from './${fileName}.schema'` : ''}
|
|
14
28
|
|
|
29
|
+
// A configure function that registers the service and its hooks via \`app.configure\`
|
|
30
|
+
export const ${camelName} = (app: Application) => {
|
|
15
31
|
// Register our service on the Feathers application
|
|
16
|
-
app.use('${path}', new ${className}(
|
|
32
|
+
app.use('${path}', new ${className}(getOptions(app)), {
|
|
17
33
|
// A list of all methods this service exposes externally
|
|
18
34
|
methods: ['find', 'get', 'create', 'update', 'patch', 'remove'],
|
|
19
35
|
// You can add additional custom events to be sent to clients here
|
|
20
36
|
events: []
|
|
21
37
|
})
|
|
22
38
|
// Initialize hooks
|
|
23
|
-
app.service('${path}').hooks(
|
|
39
|
+
app.service('${path}').hooks({
|
|
40
|
+
around: {
|
|
41
|
+
all: [${authentication
|
|
42
|
+
? `
|
|
43
|
+
authenticate('jwt'),`
|
|
44
|
+
: ''}
|
|
45
|
+
]${isEntityService
|
|
46
|
+
? `,
|
|
47
|
+
find: [ authenticate('jwt') ],
|
|
48
|
+
get: [ authenticate('jwt') ],
|
|
49
|
+
create: [],
|
|
50
|
+
update: [ authenticate('jwt') ],
|
|
51
|
+
patch: [ authenticate('jwt') ],
|
|
52
|
+
remove: [ authenticate('jwt') ]`
|
|
53
|
+
: ''}
|
|
54
|
+
},
|
|
55
|
+
before: {
|
|
56
|
+
all: [${schema
|
|
57
|
+
? `
|
|
58
|
+
schemaHooks.validateQuery(${camelName}QueryValidator),
|
|
59
|
+
schemaHooks.validateData(${camelName}DataValidator),
|
|
60
|
+
schemaHooks.resolveQuery(${camelName}QueryResolver),
|
|
61
|
+
schemaHooks.resolveData(${camelName}DataResolver)
|
|
62
|
+
`
|
|
63
|
+
: ''}]
|
|
64
|
+
},
|
|
65
|
+
after: {
|
|
66
|
+
all: [${schema
|
|
67
|
+
? `
|
|
68
|
+
schemaHooks.resolveResult(${camelName}Resolver),
|
|
69
|
+
schemaHooks.resolveExternal(${camelName}ExternalResolver)
|
|
70
|
+
`
|
|
71
|
+
: ''}]
|
|
72
|
+
},
|
|
73
|
+
error: {
|
|
74
|
+
all: []
|
|
75
|
+
}
|
|
76
|
+
})
|
|
24
77
|
}
|
|
25
78
|
|
|
26
79
|
// Add this service to the service type index
|
|
@@ -30,17 +83,16 @@ declare module '${relative}/declarations' {
|
|
|
30
83
|
}
|
|
31
84
|
}
|
|
32
85
|
`;
|
|
33
|
-
|
|
34
|
-
const configureTemplate = ({ camelName }) => ` app.configure(${camelName})`;
|
|
86
|
+
exports.template = template;
|
|
35
87
|
const toServiceIndex = (0, pinion_1.toFile)(({ lib }) => [lib, 'services', `index`]);
|
|
36
88
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
37
|
-
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib,
|
|
89
|
+
.then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, fileName, folder }) => [
|
|
38
90
|
lib,
|
|
39
91
|
'services',
|
|
40
92
|
...folder,
|
|
41
|
-
`${fileName}
|
|
93
|
+
`${fileName}`
|
|
42
94
|
])))
|
|
43
|
-
.then((0, commons_1.injectSource)(
|
|
44
|
-
.then((0, commons_1.injectSource)(
|
|
95
|
+
.then((0, commons_1.injectSource)(({ camelName, folder, fileName }) => `import { ${camelName} } from './${folder.join('/')}/${fileName}'`, (0, pinion_1.prepend)(), toServiceIndex))
|
|
96
|
+
.then((0, commons_1.injectSource)(({ camelName }) => ` app.configure(${camelName})`, (0, pinion_1.after)('export const services'), toServiceIndex));
|
|
45
97
|
exports.generate = generate;
|
|
46
98
|
//# 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,+CAAsE;AACtE,2CAA0D;
|
|
1
|
+
{"version":3,"file":"service.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/service.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AACtE,2CAA0D;AAGnD,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,cAAc,EACd,eAAe,EACf,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;EACtC,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;EAEpG,MAAM;IACJ,CAAC,CAAC;;;;IAIF,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC,EACN;;oCAEoC,QAAQ;WACjC,SAAS,0BAA0B,QAAQ;;mBAEnC,QAAQ;EACzB,MAAM,CAAC,CAAC,CAAC,oBAAoB,QAAQ,UAAU,CAAC,CAAC,CAAC,EAAE;;;eAGvC,SAAS;;aAEX,IAAI,UAAU,SAAS;;;;;;;iBAOnB,IAAI;;cAGb,cAAc;IACZ,CAAC,CAAC;6BACiB;IACnB,CAAC,CAAC,EACN;SAEE,eAAe;IACb,CAAC,CAAC;;;;;;sCAM0B;IAC5B,CAAC,CAAC,EACN;;;cAIE,MAAM;IACJ,CAAC,CAAC;oCACwB,SAAS;mCACV,SAAS;mCACT,SAAS;kCACV,SAAS;OACpC;IACG,CAAC,CAAC,EACN;;;cAIE,MAAM;IACJ,CAAC,CAAC;oCACwB,SAAS;sCACP,SAAS;OACxC;IACG,CAAC,CAAC,EACN;;;;;;;;;kBASY,QAAQ;;OAEnB,IAAI,MAAM,SAAS;;;CAGzB,CAAA;AAlGY,QAAA,QAAQ,YAkGpB;AAED,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,gBAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAA2B,EAAE,EAAE,CAAC;IAC7D,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,EAAE;CACd,CAAC,CACH,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAClC,YAAY,SAAS,cAAc,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,GAAG,EACpE,IAAA,gBAAO,GAAE,EACT,cAAc,CACf,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,mBAAmB,SAAS,GAAG,EAClD,IAAA,cAAK,EAAC,uBAAuB,CAAC,EAC9B,cAAc,CACf,CACF,CAAA;AA3BQ,QAAA,QAAQ,YA2BhB"}
|
|
@@ -1,26 +1,97 @@
|
|
|
1
|
-
import { generator,
|
|
1
|
+
import { generator, toFile, after, prepend } from '@feathershq/pinion'
|
|
2
2
|
import { injectSource, renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({
|
|
6
|
-
|
|
5
|
+
export const template = ({
|
|
6
|
+
camelName,
|
|
7
|
+
authentication,
|
|
8
|
+
isEntityService,
|
|
9
|
+
path,
|
|
10
|
+
className,
|
|
11
|
+
relative,
|
|
12
|
+
schema,
|
|
13
|
+
fileName
|
|
14
|
+
}: ServiceGeneratorContext) => /* ts */ `
|
|
15
|
+
${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
16
|
+
${
|
|
17
|
+
schema
|
|
18
|
+
? `
|
|
19
|
+
import { hooks as schemaHooks } from '@feathersjs/schema'
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
${camelName}DataValidator,
|
|
23
|
+
${camelName}QueryValidator,
|
|
24
|
+
${camelName}Resolver,
|
|
25
|
+
${camelName}DataResolver,
|
|
26
|
+
${camelName}QueryResolver,
|
|
27
|
+
${camelName}ExternalResolver
|
|
28
|
+
} from './${fileName}.schema'
|
|
29
|
+
`
|
|
30
|
+
: ''
|
|
31
|
+
}
|
|
7
32
|
|
|
8
|
-
import
|
|
33
|
+
import type { Application } from '${relative}/declarations'
|
|
34
|
+
import { ${className}, getOptions } from './${fileName}.class'
|
|
9
35
|
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
const options = { // Service options will go here
|
|
13
|
-
}
|
|
36
|
+
export * from './${fileName}.class'
|
|
37
|
+
${schema ? `export * from './${fileName}.schema'` : ''}
|
|
14
38
|
|
|
39
|
+
// A configure function that registers the service and its hooks via \`app.configure\`
|
|
40
|
+
export const ${camelName} = (app: Application) => {
|
|
15
41
|
// Register our service on the Feathers application
|
|
16
|
-
app.use('${path}', new ${className}(
|
|
42
|
+
app.use('${path}', new ${className}(getOptions(app)), {
|
|
17
43
|
// A list of all methods this service exposes externally
|
|
18
44
|
methods: ['find', 'get', 'create', 'update', 'patch', 'remove'],
|
|
19
45
|
// You can add additional custom events to be sent to clients here
|
|
20
46
|
events: []
|
|
21
47
|
})
|
|
22
48
|
// Initialize hooks
|
|
23
|
-
app.service('${path}').hooks(
|
|
49
|
+
app.service('${path}').hooks({
|
|
50
|
+
around: {
|
|
51
|
+
all: [${
|
|
52
|
+
authentication
|
|
53
|
+
? `
|
|
54
|
+
authenticate('jwt'),`
|
|
55
|
+
: ''
|
|
56
|
+
}
|
|
57
|
+
]${
|
|
58
|
+
isEntityService
|
|
59
|
+
? `,
|
|
60
|
+
find: [ authenticate('jwt') ],
|
|
61
|
+
get: [ authenticate('jwt') ],
|
|
62
|
+
create: [],
|
|
63
|
+
update: [ authenticate('jwt') ],
|
|
64
|
+
patch: [ authenticate('jwt') ],
|
|
65
|
+
remove: [ authenticate('jwt') ]`
|
|
66
|
+
: ''
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
before: {
|
|
70
|
+
all: [${
|
|
71
|
+
schema
|
|
72
|
+
? `
|
|
73
|
+
schemaHooks.validateQuery(${camelName}QueryValidator),
|
|
74
|
+
schemaHooks.validateData(${camelName}DataValidator),
|
|
75
|
+
schemaHooks.resolveQuery(${camelName}QueryResolver),
|
|
76
|
+
schemaHooks.resolveData(${camelName}DataResolver)
|
|
77
|
+
`
|
|
78
|
+
: ''
|
|
79
|
+
}]
|
|
80
|
+
},
|
|
81
|
+
after: {
|
|
82
|
+
all: [${
|
|
83
|
+
schema
|
|
84
|
+
? `
|
|
85
|
+
schemaHooks.resolveResult(${camelName}Resolver),
|
|
86
|
+
schemaHooks.resolveExternal(${camelName}ExternalResolver)
|
|
87
|
+
`
|
|
88
|
+
: ''
|
|
89
|
+
}]
|
|
90
|
+
},
|
|
91
|
+
error: {
|
|
92
|
+
all: []
|
|
93
|
+
}
|
|
94
|
+
})
|
|
24
95
|
}
|
|
25
96
|
|
|
26
97
|
// Add this service to the service type index
|
|
@@ -31,11 +102,6 @@ declare module '${relative}/declarations' {
|
|
|
31
102
|
}
|
|
32
103
|
`
|
|
33
104
|
|
|
34
|
-
const importTemplate = ({ camelName, folder, fileName }: ServiceGeneratorContext) =>
|
|
35
|
-
`import { ${camelName} } from './${folder.join('/')}/${fileName}.service'`
|
|
36
|
-
|
|
37
|
-
const configureTemplate = ({ camelName }: ServiceGeneratorContext) => ` app.configure(${camelName})`
|
|
38
|
-
|
|
39
105
|
const toServiceIndex = toFile(({ lib }: ServiceGeneratorContext) => [lib, 'services', `index`])
|
|
40
106
|
|
|
41
107
|
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
@@ -43,13 +109,26 @@ export const generate = (ctx: ServiceGeneratorContext) =>
|
|
|
43
109
|
.then(
|
|
44
110
|
renderSource(
|
|
45
111
|
template,
|
|
46
|
-
toFile
|
|
112
|
+
toFile(({ lib, fileName, folder }: ServiceGeneratorContext) => [
|
|
47
113
|
lib,
|
|
48
114
|
'services',
|
|
49
115
|
...folder,
|
|
50
|
-
`${fileName}
|
|
116
|
+
`${fileName}`
|
|
51
117
|
])
|
|
52
118
|
)
|
|
53
119
|
)
|
|
54
|
-
.then(
|
|
55
|
-
|
|
120
|
+
.then(
|
|
121
|
+
injectSource<ServiceGeneratorContext>(
|
|
122
|
+
({ camelName, folder, fileName }) =>
|
|
123
|
+
`import { ${camelName} } from './${folder.join('/')}/${fileName}'`,
|
|
124
|
+
prepend(),
|
|
125
|
+
toServiceIndex
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
.then(
|
|
129
|
+
injectSource<ServiceGeneratorContext>(
|
|
130
|
+
({ camelName }) => ` app.configure(${camelName})`,
|
|
131
|
+
after('export const services'),
|
|
132
|
+
toServiceIndex
|
|
133
|
+
)
|
|
134
|
+
)
|
|
@@ -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 = ({ relative, lib, path }) => `import assert from 'assert'
|
|
6
|
+
const template = ({ relative, lib, path }) => /* ts */ `import assert from 'assert'
|
|
7
7
|
import { app } from '../${relative}/${lib}/app'
|
|
8
8
|
|
|
9
9
|
describe('${path} service', () => {
|
|
@@ -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,EAA2B,EAAE,EAAE,
|
|
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,CAAC,QAAQ,CAAC;0BACtD,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,8 +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 = ({ relative, lib, path }: ServiceGeneratorContext) =>
|
|
6
|
-
`import assert from 'assert'
|
|
5
|
+
const template = ({ relative, lib, path }: ServiceGeneratorContext) => /* ts */ `import assert from 'assert'
|
|
7
6
|
import { app } from '../${relative}/${lib}/app'
|
|
8
7
|
|
|
9
8
|
describe('${path} service', () => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ServiceGeneratorContext } from '../index';
|
|
2
|
-
export declare const template: ({ className, upperName, relative }: ServiceGeneratorContext) => string;
|
|
3
|
-
export declare const importTemplate = "import type { Id, NullableId, Params } from '@feathersjs/feathers'";
|
|
2
|
+
export declare const template: ({ className, upperName, schema, fileName, relative }: ServiceGeneratorContext) => string;
|
|
4
3
|
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = exports.
|
|
3
|
+
exports.generate = exports.template = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ className, upperName, relative }) => `
|
|
7
|
-
|
|
6
|
+
const template = ({ className, upperName, schema, fileName, relative }) => `
|
|
7
|
+
import type { Id, NullableId, Params } from '@feathersjs/feathers'
|
|
8
|
+
|
|
9
|
+
import type { Application } from '${relative}/declarations'
|
|
10
|
+
${schema
|
|
11
|
+
? `import type {
|
|
12
|
+
${upperName},
|
|
13
|
+
${upperName}Data,
|
|
14
|
+
${upperName}Query
|
|
15
|
+
} from './${fileName}.schema'
|
|
16
|
+
`
|
|
17
|
+
: `
|
|
18
|
+
export type ${upperName} = any
|
|
19
|
+
export type ${upperName}Data = any
|
|
20
|
+
export type ${upperName}Query = any
|
|
21
|
+
`}
|
|
22
|
+
|
|
8
23
|
export interface ${className}Options {
|
|
9
24
|
app: Application
|
|
10
25
|
}
|
|
@@ -18,20 +33,20 @@ export class ${className} {
|
|
|
18
33
|
constructor (public options: ${className}Options) {
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
async find (_params?: ${upperName}Params): Promise<${upperName}
|
|
36
|
+
async find (_params?: ${upperName}Params): Promise<${upperName}[]> {
|
|
22
37
|
return []
|
|
23
38
|
}
|
|
24
39
|
|
|
25
|
-
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}
|
|
40
|
+
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
26
41
|
return {
|
|
27
42
|
id: 0,
|
|
28
43
|
text: \`A new message with ID: \${id}!\`
|
|
29
44
|
}
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}
|
|
33
|
-
async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}
|
|
34
|
-
async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}
|
|
47
|
+
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}>
|
|
48
|
+
async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}[]>
|
|
49
|
+
async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}|${upperName}[]> {
|
|
35
50
|
if (Array.isArray(data)) {
|
|
36
51
|
return Promise.all(data.map(current => this.create(current, params)));
|
|
37
52
|
}
|
|
@@ -42,46 +57,38 @@ export class ${className} {
|
|
|
42
57
|
}
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}
|
|
60
|
+
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
46
61
|
return {
|
|
47
62
|
id: 0,
|
|
48
63
|
...data
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
|
|
52
|
-
async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}
|
|
67
|
+
async patch (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
53
68
|
return {
|
|
54
69
|
id: 0,
|
|
55
70
|
...data
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
73
|
|
|
59
|
-
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}
|
|
74
|
+
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
60
75
|
return {
|
|
61
76
|
id: 0,
|
|
62
77
|
text: 'removed'
|
|
63
78
|
}
|
|
64
79
|
}
|
|
65
80
|
}
|
|
81
|
+
|
|
82
|
+
export const getOptions = (app: Application) => {
|
|
83
|
+
return { app }
|
|
84
|
+
}
|
|
66
85
|
`;
|
|
67
86
|
exports.template = template;
|
|
68
|
-
|
|
69
|
-
const optionTemplate = ({}) => ` app`;
|
|
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 }) => [
|
|
87
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
77
88
|
lib,
|
|
78
89
|
'services',
|
|
79
90
|
...folder,
|
|
80
91
|
`${fileName}.class`
|
|
81
|
-
]);
|
|
82
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
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));
|
|
92
|
+
])));
|
|
86
93
|
exports.generate = generate;
|
|
87
94
|
//# 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,+CAAsD;AACtD,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC;;;oCAGvE,QAAQ;EAE1C,MAAM;IACJ,CAAC,CAAC;IACF,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC;cACQ,SAAS;cACT,SAAS;cACT,SAAS;CAEvB;;mBAEmB,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,IAAI,SAAS;;;;;;;;;;;wCAWjF,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;uCAOnE,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;4CAO7D,SAAS,oBAAoB,SAAS;;;;;;;;;;;CAWjF,CAAA;AAjFY,QAAA,QAAQ,YAiFpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,gBAAQ,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"}
|