@feathersjs/cli 5.0.0-pre.32 → 5.0.0-pre.34
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 +26 -0
- package/LICENSE +1 -2
- package/README.md +3 -7
- package/lib/app/index.d.ts +2 -2
- package/lib/app/index.js +1 -1
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +1 -0
- package/lib/app/templates/app.test.tpl.js +2 -1
- package/lib/app/templates/app.test.tpl.js.map +1 -1
- package/lib/app/templates/app.test.tpl.ts +4 -1
- package/lib/app/templates/app.tpl.js +12 -10
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +12 -10
- package/lib/app/templates/channels.tpl.js +2 -1
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +2 -1
- package/lib/app/templates/client.tpl.js +2 -1
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +2 -1
- package/lib/app/templates/{config.tpl.d.ts → configuration.tpl.d.ts} +0 -0
- package/lib/app/templates/{schemas.tpl.js → configuration.tpl.js} +25 -29
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/{schemas.tpl.ts → configuration.tpl.ts} +25 -32
- 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/logger.tpl.d.ts +1 -0
- package/lib/app/templates/logger.tpl.js +13 -7
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +22 -10
- package/lib/app/templates/package.json.tpl.js +5 -2
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -2
- package/lib/app/templates/services.tpl.js +2 -1
- package/lib/app/templates/services.tpl.js.map +1 -1
- package/lib/app/templates/services.tpl.ts +3 -1
- package/lib/app/templates/{schemas.tpl.d.ts → validators.tpl.d.ts} +0 -0
- package/lib/app/templates/validators.tpl.js +36 -0
- package/lib/app/templates/validators.tpl.js.map +1 -0
- package/lib/app/templates/validators.tpl.ts +40 -0
- package/lib/authentication/index.d.ts +1 -1
- package/lib/authentication/templates/authentication.tpl.js +2 -1
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +2 -1
- package/lib/authentication/templates/client.test.tpl.js +2 -1
- package/lib/authentication/templates/client.test.tpl.js.map +1 -1
- package/lib/authentication/templates/client.test.tpl.ts +2 -1
- package/lib/authentication/templates/knex.tpl.js +2 -2
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +2 -2
- package/lib/authentication/templates/schema.json.tpl.js +30 -20
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.json.tpl.ts +37 -21
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +1 -1
- package/lib/authentication/templates/schema.typebox.tpl.js +30 -22
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +37 -23
- package/lib/commons.d.ts +11 -4
- package/lib/commons.js +9 -1
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +8 -0
- package/lib/connection/index.d.ts +1 -1
- package/lib/connection/index.js +2 -2
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +2 -2
- package/lib/connection/templates/knex.tpl.js +4 -2
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -2
- package/lib/connection/templates/mongodb.tpl.js +3 -2
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +4 -2
- package/lib/hook/templates/hook.tpl.js +4 -2
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +4 -2
- package/lib/service/index.d.ts +1 -1
- package/lib/service/templates/schema.json.tpl.js +23 -15
- package/lib/service/templates/schema.json.tpl.js.map +1 -1
- package/lib/service/templates/schema.json.tpl.ts +28 -17
- package/lib/service/templates/schema.typebox.tpl.js +21 -15
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/service/templates/schema.typebox.tpl.ts +26 -17
- package/lib/service/templates/service.tpl.js +33 -19
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +38 -20
- package/lib/service/templates/test.tpl.js +2 -1
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +6 -1
- package/lib/service/type/custom.tpl.js +8 -4
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +14 -4
- package/lib/service/type/knex.tpl.js +7 -3
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +7 -3
- package/lib/service/type/mongodb.tpl.js +5 -2
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +5 -2
- package/package.json +27 -25
- package/lib/app/templates/config.tpl.js +0 -30
- package/lib/app/templates/config.tpl.js.map +0 -1
- package/lib/app/templates/config.tpl.ts +0 -31
- package/lib/app/templates/schemas.tpl.js.map +0 -1
- package/lib/authentication/templates/client.tpl.d.ts +0 -2
- package/lib/authentication/templates/client.tpl.js +0 -14
- package/lib/authentication/templates/client.tpl.js.map +0 -1
- package/lib/authentication/templates/client.tpl.ts +0 -19
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { generator, toFile, when } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
2
|
+
import { fileExists, renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
const template = ({
|
|
6
6
|
camelName,
|
|
7
7
|
upperName,
|
|
8
8
|
relative,
|
|
9
|
-
type
|
|
10
|
-
|
|
9
|
+
type,
|
|
10
|
+
cwd,
|
|
11
|
+
lib
|
|
12
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
|
|
13
|
+
import { resolve, getValidator, querySyntax } from '@feathersjs/schema'
|
|
11
14
|
import type { FromSchema } from '@feathersjs/schema'
|
|
12
15
|
|
|
13
16
|
import type { HookContext } from '${relative}/declarations'
|
|
14
|
-
import { dataValidator, queryValidator } from '${relative}
|
|
17
|
+
import { dataValidator, queryValidator } from '${relative}/${
|
|
18
|
+
fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
|
|
19
|
+
}validators'
|
|
15
20
|
|
|
16
21
|
// Main data model schema
|
|
17
22
|
export const ${camelName}Schema = {
|
|
@@ -29,12 +34,8 @@ export const ${camelName}Schema = {
|
|
|
29
34
|
}
|
|
30
35
|
} as const
|
|
31
36
|
export type ${upperName} = FromSchema<typeof ${camelName}Schema>
|
|
32
|
-
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
36
|
-
properties: {}
|
|
37
|
-
})
|
|
37
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
|
|
38
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({})
|
|
38
39
|
|
|
39
40
|
// Schema for creating new data
|
|
40
41
|
export const ${camelName}DataSchema = {
|
|
@@ -49,10 +50,22 @@ export const ${camelName}DataSchema = {
|
|
|
49
50
|
}
|
|
50
51
|
} as const
|
|
51
52
|
export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
|
|
52
|
-
export const ${camelName}DataValidator =
|
|
53
|
-
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator)
|
|
54
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({})
|
|
55
|
+
|
|
56
|
+
// Schema for updating existing data
|
|
57
|
+
export const ${camelName}PatchSchema = {
|
|
58
|
+
$id: '${upperName}Patch',
|
|
59
|
+
type: 'object',
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
required: [],
|
|
62
|
+
properties: {
|
|
63
|
+
...${camelName}Schema.properties
|
|
64
|
+
}
|
|
65
|
+
} as const
|
|
66
|
+
export type ${upperName}Patch = FromSchema<typeof ${camelName}PatchSchema>
|
|
67
|
+
export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator)
|
|
68
|
+
export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({})
|
|
56
69
|
|
|
57
70
|
// Schema for allowed query properties
|
|
58
71
|
export const ${camelName}QuerySchema = {
|
|
@@ -65,9 +78,7 @@ export const ${camelName}QuerySchema = {
|
|
|
65
78
|
} as const
|
|
66
79
|
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
67
80
|
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
68
|
-
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
69
|
-
properties: {}
|
|
70
|
-
})
|
|
81
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({})
|
|
71
82
|
`
|
|
72
83
|
|
|
73
84
|
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
@@ -3,12 +3,14 @@ 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, type }) => /* ts */
|
|
6
|
+
const template = ({ camelName, upperName, relative, type, cwd, lib }) => /* ts */ `// // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
|
|
7
|
+
import { resolve } from '@feathersjs/schema'
|
|
7
8
|
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
8
9
|
import type { Static } from '@feathersjs/typebox'
|
|
9
10
|
|
|
10
11
|
import type { HookContext } from '${relative}/declarations'
|
|
11
|
-
import { dataValidator, queryValidator } from '${relative}
|
|
12
|
+
import { dataValidator, queryValidator } from '${relative}/${(0, commons_1.fileExists)(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
|
|
13
|
+
}validators'
|
|
12
14
|
|
|
13
15
|
// Main data model schema
|
|
14
16
|
export const ${camelName}Schema = Type.Object({
|
|
@@ -16,34 +18,38 @@ export const ${camelName}Schema = Type.Object({
|
|
|
16
18
|
text: Type.String()
|
|
17
19
|
}, { $id: '${upperName}', additionalProperties: false })
|
|
18
20
|
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
19
|
-
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
20
|
-
properties: {}
|
|
21
|
-
})
|
|
21
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
|
|
22
22
|
|
|
23
|
-
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
24
|
-
properties: {}
|
|
25
|
-
})
|
|
23
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({})
|
|
26
24
|
|
|
27
25
|
// Schema for creating new entries
|
|
28
26
|
export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, ['text'], {
|
|
29
|
-
$id: '${upperName}Data'
|
|
27
|
+
$id: '${upperName}Data'
|
|
30
28
|
})
|
|
31
29
|
export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
|
|
32
30
|
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
33
|
-
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
|
|
34
|
-
|
|
31
|
+
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({})
|
|
32
|
+
|
|
33
|
+
// Schema for updating existing entries
|
|
34
|
+
export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
|
|
35
|
+
$id: '${upperName}Patch'
|
|
35
36
|
})
|
|
37
|
+
export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
|
|
38
|
+
export const ${camelName}PatchValidator = getDataValidator(${camelName}PatchSchema, dataValidator)
|
|
39
|
+
export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({})
|
|
36
40
|
|
|
37
41
|
// Schema for allowed query properties
|
|
38
42
|
export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, [
|
|
39
43
|
'${type === 'mongodb' ? '_id' : 'id'}', 'text'
|
|
44
|
+
])
|
|
45
|
+
export const ${camelName}QuerySchema = Type.Intersect([
|
|
46
|
+
querySyntax(${camelName}QueryProperties),
|
|
47
|
+
// Add additional query properties here
|
|
48
|
+
Type.Object({}, { additionalProperties: false })
|
|
40
49
|
], { additionalProperties: false })
|
|
41
|
-
export const ${camelName}QuerySchema = querySyntax(${camelName}QueryProperties)
|
|
42
50
|
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
43
51
|
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
44
|
-
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
45
|
-
properties: {}
|
|
46
|
-
})
|
|
52
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({})
|
|
47
53
|
`;
|
|
48
54
|
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
55
|
lib,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AAGxD,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,GAAG,EACqB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;oCAKJ,QAAQ;iDACK,QAAQ,IACvD,IAAA,oBAAU,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,6CAA6C;AACjG;;;eAGe,SAAS;MAClB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,mBAAmB;;eAEtD,SAAS;cACV,SAAS,oBAAoB,SAAS;eACrC,SAAS,sBAAsB,SAAS;;eAExC,SAAS,8BAA8B,SAAS;;;eAGhD,SAAS,0BAA0B,SAAS;UACjD,SAAS;;cAEL,SAAS,wBAAwB,SAAS;eACzC,SAAS,oCAAoC,SAAS;eACtD,SAAS,0BAA0B,SAAS;;;eAG5C,SAAS,8BAA8B,SAAS;UACrD,SAAS;;cAEL,SAAS,yBAAyB,SAAS;eAC1C,SAAS,qCAAqC,SAAS;eACvD,SAAS,2BAA2B,SAAS;;;eAG7C,SAAS,+BAA+B,SAAS;KAC3D,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;eAEvB,SAAS;gBACR,SAAS;;;;cAIX,SAAS,yBAAyB,SAAS;eAC1C,SAAS,iCAAiC,SAAS;eACnD,SAAS,2BAA2B,SAAS;CAC3D,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"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { generator, toFile, when } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
2
|
+
import { fileExists, renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
const template = ({
|
|
6
6
|
camelName,
|
|
7
7
|
upperName,
|
|
8
8
|
relative,
|
|
9
|
-
type
|
|
10
|
-
|
|
9
|
+
type,
|
|
10
|
+
cwd,
|
|
11
|
+
lib
|
|
12
|
+
}: ServiceGeneratorContext) => /* ts */ `// // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
|
|
13
|
+
import { resolve } from '@feathersjs/schema'
|
|
11
14
|
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
12
15
|
import type { Static } from '@feathersjs/typebox'
|
|
13
16
|
|
|
14
17
|
import type { HookContext } from '${relative}/declarations'
|
|
15
|
-
import { dataValidator, queryValidator } from '${relative}
|
|
18
|
+
import { dataValidator, queryValidator } from '${relative}/${
|
|
19
|
+
fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility
|
|
20
|
+
}validators'
|
|
16
21
|
|
|
17
22
|
// Main data model schema
|
|
18
23
|
export const ${camelName}Schema = Type.Object({
|
|
@@ -20,34 +25,38 @@ export const ${camelName}Schema = Type.Object({
|
|
|
20
25
|
text: Type.String()
|
|
21
26
|
}, { $id: '${upperName}', additionalProperties: false })
|
|
22
27
|
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
23
|
-
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
24
|
-
properties: {}
|
|
25
|
-
})
|
|
28
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({})
|
|
26
29
|
|
|
27
|
-
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
28
|
-
properties: {}
|
|
29
|
-
})
|
|
30
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({})
|
|
30
31
|
|
|
31
32
|
// Schema for creating new entries
|
|
32
33
|
export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, ['text'], {
|
|
33
|
-
$id: '${upperName}Data'
|
|
34
|
+
$id: '${upperName}Data'
|
|
34
35
|
})
|
|
35
36
|
export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
|
|
36
37
|
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
37
|
-
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({
|
|
38
|
-
|
|
38
|
+
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({})
|
|
39
|
+
|
|
40
|
+
// Schema for updating existing entries
|
|
41
|
+
export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
|
|
42
|
+
$id: '${upperName}Patch'
|
|
39
43
|
})
|
|
44
|
+
export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
|
|
45
|
+
export const ${camelName}PatchValidator = getDataValidator(${camelName}PatchSchema, dataValidator)
|
|
46
|
+
export const ${camelName}PatchResolver = resolve<${upperName}, HookContext>({})
|
|
40
47
|
|
|
41
48
|
// Schema for allowed query properties
|
|
42
49
|
export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, [
|
|
43
50
|
'${type === 'mongodb' ? '_id' : 'id'}', 'text'
|
|
51
|
+
])
|
|
52
|
+
export const ${camelName}QuerySchema = Type.Intersect([
|
|
53
|
+
querySyntax(${camelName}QueryProperties),
|
|
54
|
+
// Add additional query properties here
|
|
55
|
+
Type.Object({}, { additionalProperties: false })
|
|
44
56
|
], { additionalProperties: false })
|
|
45
|
-
export const ${camelName}QuerySchema = querySyntax(${camelName}QueryProperties)
|
|
46
57
|
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
47
58
|
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
48
|
-
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
49
|
-
properties: {}
|
|
50
|
-
})
|
|
59
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({})
|
|
51
60
|
`
|
|
52
61
|
|
|
53
62
|
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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 = ({ camelName, authentication, isEntityService, path, className, relative, schema, fileName }) => /* ts */
|
|
6
|
+
const template = ({ camelName, authentication, isEntityService, path, className, relative, schema, fileName }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html
|
|
7
7
|
${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
8
8
|
${schema
|
|
9
9
|
? `
|
|
@@ -11,11 +11,13 @@ import { hooks as schemaHooks } from '@feathersjs/schema'
|
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
${camelName}DataValidator,
|
|
14
|
+
${camelName}PatchValidator,
|
|
14
15
|
${camelName}QueryValidator,
|
|
15
16
|
${camelName}Resolver,
|
|
17
|
+
${camelName}ExternalResolver,
|
|
16
18
|
${camelName}DataResolver,
|
|
17
|
-
${camelName}
|
|
18
|
-
${camelName}
|
|
19
|
+
${camelName}PatchResolver,
|
|
20
|
+
${camelName}QueryResolver
|
|
19
21
|
} from './${fileName}.schema'
|
|
20
22
|
`
|
|
21
23
|
: ''}
|
|
@@ -31,7 +33,7 @@ export const ${camelName} = (app: Application) => {
|
|
|
31
33
|
// Register our service on the Feathers application
|
|
32
34
|
app.use('${path}', new ${className}(getOptions(app)), {
|
|
33
35
|
// A list of all methods this service exposes externally
|
|
34
|
-
methods: ['find', 'get', 'create', '
|
|
36
|
+
methods: ['find', 'get', 'create', 'patch', 'remove'],
|
|
35
37
|
// You can add additional custom events to be sent to clients here
|
|
36
38
|
events: []
|
|
37
39
|
})
|
|
@@ -41,34 +43,46 @@ export const ${camelName} = (app: Application) => {
|
|
|
41
43
|
all: [${authentication
|
|
42
44
|
? `
|
|
43
45
|
authenticate('jwt'),`
|
|
46
|
+
: ''} ${schema
|
|
47
|
+
? `
|
|
48
|
+
schemaHooks.resolveExternal(${camelName}ExternalResolver),
|
|
49
|
+
schemaHooks.resolveResult(${camelName}Resolver),`
|
|
44
50
|
: ''}
|
|
45
|
-
]
|
|
46
|
-
?
|
|
47
|
-
find: [
|
|
48
|
-
get: [
|
|
51
|
+
],${isEntityService
|
|
52
|
+
? `
|
|
53
|
+
find: [authenticate('jwt')],
|
|
54
|
+
get: [authenticate('jwt')],
|
|
49
55
|
create: [],
|
|
50
|
-
update: [
|
|
51
|
-
patch: [
|
|
52
|
-
remove: [
|
|
56
|
+
update: [authenticate('jwt')],
|
|
57
|
+
patch: [authenticate('jwt')],
|
|
58
|
+
remove: [authenticate('jwt')]`
|
|
53
59
|
: ''}
|
|
54
60
|
},
|
|
55
61
|
before: {
|
|
56
62
|
all: [${schema
|
|
57
63
|
? `
|
|
58
64
|
schemaHooks.validateQuery(${camelName}QueryValidator),
|
|
65
|
+
schemaHooks.resolveQuery(${camelName}QueryResolver)
|
|
66
|
+
`
|
|
67
|
+
: ''}],
|
|
68
|
+
find: [],
|
|
69
|
+
get: [],
|
|
70
|
+
create: [${schema
|
|
71
|
+
? `
|
|
59
72
|
schemaHooks.validateData(${camelName}DataValidator),
|
|
60
|
-
schemaHooks.resolveQuery(${camelName}QueryResolver),
|
|
61
73
|
schemaHooks.resolveData(${camelName}DataResolver)
|
|
62
74
|
`
|
|
63
|
-
: ''}]
|
|
64
|
-
|
|
65
|
-
after: {
|
|
66
|
-
all: [${schema
|
|
75
|
+
: ''}],
|
|
76
|
+
patch: [${schema
|
|
67
77
|
? `
|
|
68
|
-
schemaHooks.
|
|
69
|
-
schemaHooks.
|
|
78
|
+
schemaHooks.validateData(${camelName}PatchValidator),
|
|
79
|
+
schemaHooks.resolveData(${camelName}PatchResolver)
|
|
70
80
|
`
|
|
71
|
-
: ''}]
|
|
81
|
+
: ''}],
|
|
82
|
+
remove: []
|
|
83
|
+
},
|
|
84
|
+
after: {
|
|
85
|
+
all: []
|
|
72
86
|
},
|
|
73
87
|
error: {
|
|
74
88
|
all: []
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;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,IACJ,MAAM;IACJ,CAAC,CAAC;sCACgC,SAAS;oCACX,SAAS,YAAY;IACrD,CAAC,CAAC,EACN;UAEQ,eAAe;IACb,CAAC,CAAC;;;;;;oCAMwB;IAC1B,CAAC,CAAC,EACN;;;cAIE,MAAM;IACJ,CAAC,CAAC;oCACwB,SAAS;mCACV,SAAS;OACrC;IACG,CAAC,CAAC,EACN;;;iBAIE,MAAM;IACJ,CAAC,CAAC;mCACuB,SAAS;kCACV,SAAS;OACpC;IACG,CAAC,CAAC,EACN;gBAEE,MAAM;IACJ,CAAC,CAAC;mCACuB,SAAS;kCACV,SAAS;OACpC;IACG,CAAC,CAAC,EACN;;;;;;;;;;;;;kBAaY,QAAQ;;OAEnB,IAAI,MAAM,SAAS;;;CAGzB,CAAA;AApHY,QAAA,QAAQ,YAoHpB;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"}
|
|
@@ -11,7 +11,7 @@ export const template = ({
|
|
|
11
11
|
relative,
|
|
12
12
|
schema,
|
|
13
13
|
fileName
|
|
14
|
-
}: ServiceGeneratorContext) => /* ts */
|
|
14
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html
|
|
15
15
|
${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''}
|
|
16
16
|
${
|
|
17
17
|
schema
|
|
@@ -20,11 +20,13 @@ import { hooks as schemaHooks } from '@feathersjs/schema'
|
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
22
|
${camelName}DataValidator,
|
|
23
|
+
${camelName}PatchValidator,
|
|
23
24
|
${camelName}QueryValidator,
|
|
24
25
|
${camelName}Resolver,
|
|
26
|
+
${camelName}ExternalResolver,
|
|
25
27
|
${camelName}DataResolver,
|
|
26
|
-
${camelName}
|
|
27
|
-
${camelName}
|
|
28
|
+
${camelName}PatchResolver,
|
|
29
|
+
${camelName}QueryResolver
|
|
28
30
|
} from './${fileName}.schema'
|
|
29
31
|
`
|
|
30
32
|
: ''
|
|
@@ -41,7 +43,7 @@ export const ${camelName} = (app: Application) => {
|
|
|
41
43
|
// Register our service on the Feathers application
|
|
42
44
|
app.use('${path}', new ${className}(getOptions(app)), {
|
|
43
45
|
// A list of all methods this service exposes externally
|
|
44
|
-
methods: ['find', 'get', 'create', '
|
|
46
|
+
methods: ['find', 'get', 'create', 'patch', 'remove'],
|
|
45
47
|
// You can add additional custom events to be sent to clients here
|
|
46
48
|
events: []
|
|
47
49
|
})
|
|
@@ -53,16 +55,22 @@ export const ${camelName} = (app: Application) => {
|
|
|
53
55
|
? `
|
|
54
56
|
authenticate('jwt'),`
|
|
55
57
|
: ''
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
+
} ${
|
|
59
|
+
schema
|
|
60
|
+
? `
|
|
61
|
+
schemaHooks.resolveExternal(${camelName}ExternalResolver),
|
|
62
|
+
schemaHooks.resolveResult(${camelName}Resolver),`
|
|
63
|
+
: ''
|
|
64
|
+
}
|
|
65
|
+
],${
|
|
58
66
|
isEntityService
|
|
59
|
-
?
|
|
60
|
-
find: [
|
|
61
|
-
get: [
|
|
67
|
+
? `
|
|
68
|
+
find: [authenticate('jwt')],
|
|
69
|
+
get: [authenticate('jwt')],
|
|
62
70
|
create: [],
|
|
63
|
-
update: [
|
|
64
|
-
patch: [
|
|
65
|
-
remove: [
|
|
71
|
+
update: [authenticate('jwt')],
|
|
72
|
+
patch: [authenticate('jwt')],
|
|
73
|
+
remove: [authenticate('jwt')]`
|
|
66
74
|
: ''
|
|
67
75
|
}
|
|
68
76
|
},
|
|
@@ -71,22 +79,32 @@ export const ${camelName} = (app: Application) => {
|
|
|
71
79
|
schema
|
|
72
80
|
? `
|
|
73
81
|
schemaHooks.validateQuery(${camelName}QueryValidator),
|
|
82
|
+
schemaHooks.resolveQuery(${camelName}QueryResolver)
|
|
83
|
+
`
|
|
84
|
+
: ''
|
|
85
|
+
}],
|
|
86
|
+
find: [],
|
|
87
|
+
get: [],
|
|
88
|
+
create: [${
|
|
89
|
+
schema
|
|
90
|
+
? `
|
|
74
91
|
schemaHooks.validateData(${camelName}DataValidator),
|
|
75
|
-
schemaHooks.resolveQuery(${camelName}QueryResolver),
|
|
76
92
|
schemaHooks.resolveData(${camelName}DataResolver)
|
|
77
93
|
`
|
|
78
94
|
: ''
|
|
79
|
-
}]
|
|
80
|
-
|
|
81
|
-
after: {
|
|
82
|
-
all: [${
|
|
95
|
+
}],
|
|
96
|
+
patch: [${
|
|
83
97
|
schema
|
|
84
98
|
? `
|
|
85
|
-
schemaHooks.
|
|
86
|
-
schemaHooks.
|
|
99
|
+
schemaHooks.validateData(${camelName}PatchValidator),
|
|
100
|
+
schemaHooks.resolveData(${camelName}PatchResolver)
|
|
87
101
|
`
|
|
88
102
|
: ''
|
|
89
|
-
}]
|
|
103
|
+
}],
|
|
104
|
+
remove: []
|
|
105
|
+
},
|
|
106
|
+
after: {
|
|
107
|
+
all: []
|
|
90
108
|
},
|
|
91
109
|
error: {
|
|
92
110
|
all: []
|
|
@@ -3,7 +3,8 @@ 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 }) => /* ts */
|
|
6
|
+
const template = ({ relative, lib, path }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html
|
|
7
|
+
import assert from 'assert'
|
|
7
8
|
import { app } from '../${relative}/${lib}/app'
|
|
8
9
|
|
|
9
10
|
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,
|
|
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,EAChB,QAAQ,EACR,GAAG,EACH,IAAI,EACoB,EAAE,EAAE,CAAC,QAAQ,CAAC;;0BAEd,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,7 +2,12 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({
|
|
5
|
+
const template = ({
|
|
6
|
+
relative,
|
|
7
|
+
lib,
|
|
8
|
+
path
|
|
9
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html
|
|
10
|
+
import assert from 'assert'
|
|
6
11
|
import { app } from '../${relative}/${lib}/app'
|
|
7
12
|
|
|
8
13
|
describe('${path} service', () => {
|
|
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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, schema, fileName, relative }) =>
|
|
7
|
-
import type { Id, NullableId, Params } from '@feathersjs/feathers'
|
|
6
|
+
const template = ({ className, upperName, schema, fileName, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#custom-services
|
|
7
|
+
import type { Id, NullableId, Params, ServiceInterface } from '@feathersjs/feathers'
|
|
8
8
|
|
|
9
9
|
import type { Application } from '${relative}/declarations'
|
|
10
10
|
${schema
|
|
11
11
|
? `import type {
|
|
12
12
|
${upperName},
|
|
13
13
|
${upperName}Data,
|
|
14
|
+
${upperName}Patch,
|
|
14
15
|
${upperName}Query
|
|
15
16
|
} from './${fileName}.schema'
|
|
16
17
|
`
|
|
17
18
|
: `
|
|
18
19
|
export type ${upperName} = any
|
|
19
20
|
export type ${upperName}Data = any
|
|
21
|
+
export type ${upperName}Patch = any
|
|
20
22
|
export type ${upperName}Query = any
|
|
21
23
|
`}
|
|
22
24
|
|
|
@@ -29,7 +31,7 @@ export interface ${upperName}Params extends Params<${upperName}Query> {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
// This is a skeleton for a custom service class. Remove or add the methods you need here
|
|
32
|
-
export class ${className} {
|
|
34
|
+
export class ${className} implements ServiceInterface<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
33
35
|
constructor (public options: ${className}Options) {
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -57,6 +59,7 @@ export class ${className} {
|
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
// This method has to be added to the 'methods' option to make it available to clients
|
|
60
63
|
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
61
64
|
return {
|
|
62
65
|
id: 0,
|
|
@@ -64,9 +67,10 @@ export class ${className} {
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
async patch (id: NullableId, data: ${upperName}
|
|
70
|
+
async patch (id: NullableId, data: ${upperName}Patch, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
68
71
|
return {
|
|
69
72
|
id: 0,
|
|
73
|
+
text: \`Fallback for \${id}\`,
|
|
70
74
|
...data
|
|
71
75
|
}
|
|
72
76
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EACvB,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;oCAGJ,QAAQ;EAE1C,MAAM;IACJ,CAAC,CAAC;IACF,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;YACD,QAAQ;CACnB;IACG,CAAC,CAAC;cACQ,SAAS;cACT,SAAS;cACT,SAAS;cACT,SAAS;CAEvB;;mBAEmB,SAAS;;;;mBAIT,SAAS,yBAAyB,SAAS;;;;;eAK/C,SAAS,gCAAgC,SAAS,KAAK,SAAS,SAAS,SAAS,WAAW,SAAS;iCACpF,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;;;;;;;;;;;;wCAYjF,SAAS,mBAAmB,SAAS,oBAAoB,SAAS;;;;;;;uCAOnE,SAAS,oBAAoB,SAAS,oBAAoB,SAAS;;;;;;;;4CAQ9D,SAAS,oBAAoB,SAAS;;;;;;;;;;;CAWjF,CAAA;AA3FY,QAAA,QAAQ,YA2FpB;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"}
|
|
@@ -2,8 +2,14 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { renderSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
export const template = ({
|
|
6
|
-
|
|
5
|
+
export const template = ({
|
|
6
|
+
className,
|
|
7
|
+
upperName,
|
|
8
|
+
schema,
|
|
9
|
+
fileName,
|
|
10
|
+
relative
|
|
11
|
+
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#custom-services
|
|
12
|
+
import type { Id, NullableId, Params, ServiceInterface } from '@feathersjs/feathers'
|
|
7
13
|
|
|
8
14
|
import type { Application } from '${relative}/declarations'
|
|
9
15
|
${
|
|
@@ -11,12 +17,14 @@ ${
|
|
|
11
17
|
? `import type {
|
|
12
18
|
${upperName},
|
|
13
19
|
${upperName}Data,
|
|
20
|
+
${upperName}Patch,
|
|
14
21
|
${upperName}Query
|
|
15
22
|
} from './${fileName}.schema'
|
|
16
23
|
`
|
|
17
24
|
: `
|
|
18
25
|
export type ${upperName} = any
|
|
19
26
|
export type ${upperName}Data = any
|
|
27
|
+
export type ${upperName}Patch = any
|
|
20
28
|
export type ${upperName}Query = any
|
|
21
29
|
`
|
|
22
30
|
}
|
|
@@ -30,7 +38,7 @@ export interface ${upperName}Params extends Params<${upperName}Query> {
|
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
// This is a skeleton for a custom service class. Remove or add the methods you need here
|
|
33
|
-
export class ${className} {
|
|
41
|
+
export class ${className} implements ServiceInterface<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
34
42
|
constructor (public options: ${className}Options) {
|
|
35
43
|
}
|
|
36
44
|
|
|
@@ -58,6 +66,7 @@ export class ${className} {
|
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
|
|
69
|
+
// This method has to be added to the 'methods' option to make it available to clients
|
|
61
70
|
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
62
71
|
return {
|
|
63
72
|
id: 0,
|
|
@@ -65,9 +74,10 @@ export class ${className} {
|
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
async patch (id: NullableId, data: ${upperName}
|
|
77
|
+
async patch (id: NullableId, data: ${upperName}Patch, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
69
78
|
return {
|
|
70
79
|
id: 0,
|
|
80
|
+
text: \`Fallback for \${id}\`,
|
|
71
81
|
...data
|
|
72
82
|
}
|
|
73
83
|
}
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = exports.template = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const migrationTemplate = ({ kebabPath }) => /* ts */
|
|
6
|
+
const migrationTemplate = ({ kebabPath }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/knexfile.html
|
|
7
|
+
import type { Knex } from 'knex'
|
|
7
8
|
|
|
8
9
|
export async function up(knex: Knex): Promise<void> {
|
|
9
10
|
await knex.schema.createTable('${kebabPath}', table => {
|
|
@@ -16,7 +17,8 @@ export async function down(knex: Knex): Promise<void> {
|
|
|
16
17
|
await knex.schema.dropTable('${kebabPath}')
|
|
17
18
|
}
|
|
18
19
|
`;
|
|
19
|
-
const template = ({ className, upperName, feathers, schema, fileName, relative }) => /* ts */
|
|
20
|
+
const template = ({ className, upperName, feathers, schema, fileName, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
|
|
21
|
+
import type { Params } from '@feathersjs/feathers'
|
|
20
22
|
import { KnexService } from '@feathersjs/knex'
|
|
21
23
|
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
22
24
|
|
|
@@ -25,12 +27,14 @@ ${schema
|
|
|
25
27
|
? `import type {
|
|
26
28
|
${upperName},
|
|
27
29
|
${upperName}Data,
|
|
30
|
+
${upperName}Patch,
|
|
28
31
|
${upperName}Query
|
|
29
32
|
} from './${fileName}.schema'
|
|
30
33
|
`
|
|
31
34
|
: `
|
|
32
35
|
export type ${upperName} = any
|
|
33
36
|
export type ${upperName}Data = any
|
|
37
|
+
export type ${upperName}Patch = any
|
|
34
38
|
export type ${upperName}Query = any
|
|
35
39
|
`}
|
|
36
40
|
|
|
@@ -39,7 +43,7 @@ export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query>
|
|
|
39
43
|
|
|
40
44
|
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
41
45
|
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
42
|
-
extends KnexService<${upperName}, ${upperName}Data, ServiceParams> {
|
|
46
|
+
extends KnexService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export const getOptions = (app: Application): KnexAdapterOptions => {
|