@feathersjs/cli 5.0.0-pre.30 → 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 +7 -0
- package/lib/app/index.js +1 -1
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +10 -1
- package/lib/app/templates/client.test.tpl.d.ts +2 -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 +1 -1
- package/lib/app/templates/client.tpl.ts +1 -1
- package/lib/app/templates/logger.tpl.js +8 -2
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +8 -2
- package/lib/app/templates/schemas.tpl.js +4 -5
- package/lib/app/templates/schemas.tpl.js.map +1 -1
- package/lib/app/templates/schemas.tpl.ts +4 -5
- package/lib/authentication/index.d.ts +1 -0
- 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/authentication/templates/client.tpl.d.ts +2 -0
- 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/declarations.tpl.js +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +1 -1
- package/lib/authentication/templates/knex.tpl.js +3 -3
- package/lib/authentication/templates/knex.tpl.ts +3 -3
- package/lib/authentication/templates/schema.json.tpl.js +24 -24
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.json.tpl.ts +24 -24
- package/lib/authentication/templates/schema.typebox.tpl.js +24 -26
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +26 -26
- package/lib/service/index.d.ts +5 -63
- package/lib/service/index.js +74 -75
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +10 -4
- package/lib/service/templates/client.tpl.js +14 -19
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +32 -21
- package/lib/service/templates/schema.json.tpl.js +24 -22
- package/lib/service/templates/schema.json.tpl.js.map +1 -1
- package/lib/service/templates/schema.json.tpl.ts +24 -22
- package/lib/service/templates/schema.typebox.tpl.js +22 -25
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/service/templates/schema.typebox.tpl.ts +22 -25
- package/lib/service/type/knex.tpl.d.ts +1 -1
- package/lib/service/type/knex.tpl.js +10 -8
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +10 -9
- package/lib/service/type/mongodb.tpl.d.ts +1 -1
- package/lib/service/type/mongodb.tpl.js +7 -5
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +8 -6
- package/package.json +18 -16
- 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 -53
|
@@ -3,34 +3,29 @@ 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
|
|
6
|
+
const importTemplate = ({ upperName, folder, fileName, className }) => /* ts */ `import type {
|
|
7
7
|
${upperName},
|
|
8
8
|
${upperName}Data,
|
|
9
9
|
${upperName}Query,
|
|
10
|
+
${className}
|
|
10
11
|
} from './services/${folder.join('/')}/${fileName}'
|
|
11
|
-
|
|
12
12
|
export type {
|
|
13
13
|
${upperName},
|
|
14
14
|
${upperName}Data,
|
|
15
|
-
${upperName}Query
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Partial<${upperName}Data>,
|
|
21
|
-
Paginated<${upperName}>,
|
|
22
|
-
Params<${upperName}Query>
|
|
23
|
-
> & {
|
|
24
|
-
// Add custom methods here
|
|
25
|
-
}`;
|
|
26
|
-
const registrationTemplate = ({ path }) => ` client.use('${path}', connection.service('${path}'), {
|
|
27
|
-
// List all standard and custom methods
|
|
28
|
-
methods: ['find', 'get', 'create', 'update', 'patch', 'remove']
|
|
29
|
-
})
|
|
15
|
+
${upperName}Query
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
const methodsTemplate = ({ camelName, upperName, className, type }) => `const ${camelName}ServiceMethods = ['find', 'get', 'create', 'update', 'patch', 'remove'] as const
|
|
19
|
+
type ${upperName}ClientService = Pick<${className}${type !== 'custom' ? `<Params<${upperName}Query>>` : ''}, typeof ${camelName}ServiceMethods[number]>
|
|
30
20
|
`;
|
|
31
|
-
const
|
|
21
|
+
const declarationTemplate = ({ path, upperName }) => ` '${path}': ${upperName}ClientService`;
|
|
22
|
+
const registrationTemplate = ({ camelName, path }) => ` client.use('${path}', connection.service('${path}'), {
|
|
23
|
+
methods: ${camelName}ServiceMethods
|
|
24
|
+
})`;
|
|
25
|
+
const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client']);
|
|
32
26
|
const generate = async (ctx) => (0, pinion_1.generator)(ctx)
|
|
33
27
|
.then((0, commons_1.injectSource)(registrationTemplate, (0, pinion_1.before)('return client'), (0, pinion_1.toFile)(({ lib }) => [lib, 'client'])))
|
|
34
|
-
.then((0, pinion_1.when)((ctx) => ctx.language === '
|
|
28
|
+
.then((0, pinion_1.when)((ctx) => ctx.language === 'js', (0, commons_1.injectSource)(methodsTemplate, (0, pinion_1.before)('\nexport const createClient'), toClientFile)))
|
|
29
|
+
.then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, commons_1.injectSource)(methodsTemplate, (0, pinion_1.before)('\nexport interface ServiceTypes'), toClientFile), (0, commons_1.injectSource)(importTemplate, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile), (0, commons_1.injectSource)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
|
|
35
30
|
exports.generate = generate;
|
|
36
31
|
//# sourceMappingURL=client.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAC3E,2CAA4C;AAG5C,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACe,EAAE,EAAE,CAAC,QAAQ,CAAC;IACpC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;qBACQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ;;IAE7C,SAAS;IACT,SAAS;IACT,SAAS;;CAEZ,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAA2B,EAAE,EAAE,CAC7F,SAAS,SAAS;OACb,SAAS,wBAAwB,SAAS,GAC7C,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,SAAS,SAAS,CAAC,CAAC,CAAC,EACtD,YAAY,SAAS;CACtB,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC3E,MAAM,IAAI,MAAM,SAAS,eAAe,CAAA;AAE1C,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,IAAI,EACoB,EAAE,EAAE,CAAC,iBAAiB,IAAI,0BAA0B,IAAI;aACrE,SAAS;GACnB,CAAA;AAEH,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE3E,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA4B,EAAE,EAAE,CAC7D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,oBAAoB,EACpB,IAAA,eAAM,EAAC,eAAe,CAAC,EACvB,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC9D,CACF;KACA,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,sBAAY,EAAC,eAAe,EAAE,IAAA,eAAM,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,CACnF,CACF;KACA,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,sBAAY,EAAC,eAAe,EAAE,IAAA,eAAM,EAAC,iCAAiC,CAAC,EAAE,YAAY,CAAC,EACtF,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,EAChF,IAAA,sBAAY,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CACxF,CACF,CAAA;AAtBQ,QAAA,QAAQ,YAsBhB"}
|
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
import { generator,
|
|
1
|
+
import { generator, toFile, when, after, before } from '@feathershq/pinion'
|
|
2
2
|
import { injectSource } from '../../commons'
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const importTemplate = ({
|
|
6
|
+
upperName,
|
|
7
|
+
folder,
|
|
8
|
+
fileName,
|
|
9
|
+
className
|
|
10
|
+
}: ServiceGeneratorContext) => /* ts */ `import type {
|
|
6
11
|
${upperName},
|
|
7
12
|
${upperName}Data,
|
|
8
13
|
${upperName}Query,
|
|
14
|
+
${className}
|
|
9
15
|
} from './services/${folder.join('/')}/${fileName}'
|
|
10
|
-
|
|
11
16
|
export type {
|
|
12
17
|
${upperName},
|
|
13
18
|
${upperName}Data,
|
|
14
|
-
${upperName}Query
|
|
15
|
-
}
|
|
19
|
+
${upperName}Query
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
const methodsTemplate = ({ camelName, upperName, className, type }: ServiceGeneratorContext) =>
|
|
24
|
+
`const ${camelName}ServiceMethods = ['find', 'get', 'create', 'update', 'patch', 'remove'] as const
|
|
25
|
+
type ${upperName}ClientService = Pick<${className}${
|
|
26
|
+
type !== 'custom' ? `<Params<${upperName}Query>>` : ''
|
|
27
|
+
}, typeof ${camelName}ServiceMethods[number]>
|
|
28
|
+
`
|
|
16
29
|
|
|
17
30
|
const declarationTemplate = ({ path, upperName }: ServiceGeneratorContext) =>
|
|
18
|
-
` '${path}': ClientService
|
|
19
|
-
${upperName},
|
|
20
|
-
${upperName}Data,
|
|
21
|
-
Partial<${upperName}Data>,
|
|
22
|
-
Paginated<${upperName}>,
|
|
23
|
-
Params<${upperName}Query>
|
|
24
|
-
> & {
|
|
25
|
-
// Add custom methods here
|
|
26
|
-
}`
|
|
31
|
+
` '${path}': ${upperName}ClientService`
|
|
27
32
|
|
|
28
33
|
const registrationTemplate = ({
|
|
34
|
+
camelName,
|
|
29
35
|
path
|
|
30
36
|
}: ServiceGeneratorContext) => ` client.use('${path}', connection.service('${path}'), {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
`
|
|
37
|
+
methods: ${camelName}ServiceMethods
|
|
38
|
+
})`
|
|
35
39
|
|
|
36
|
-
const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client
|
|
40
|
+
const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client'])
|
|
37
41
|
|
|
38
42
|
export const generate = async (ctx: ServiceGeneratorContext) =>
|
|
39
43
|
generator(ctx)
|
|
@@ -44,10 +48,17 @@ export const generate = async (ctx: ServiceGeneratorContext) =>
|
|
|
44
48
|
toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client'])
|
|
45
49
|
)
|
|
46
50
|
)
|
|
51
|
+
.then(
|
|
52
|
+
when(
|
|
53
|
+
(ctx) => ctx.language === 'js',
|
|
54
|
+
injectSource(methodsTemplate, before('\nexport const createClient'), toClientFile)
|
|
55
|
+
)
|
|
56
|
+
)
|
|
47
57
|
.then(
|
|
48
58
|
when(
|
|
49
59
|
(ctx) => ctx.language === 'ts',
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
injectSource(methodsTemplate, before('\nexport interface ServiceTypes'), toClientFile),
|
|
61
|
+
injectSource(importTemplate, after("from '@feathersjs/feathers'"), toClientFile),
|
|
62
|
+
injectSource(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
|
|
52
63
|
)
|
|
53
64
|
)
|
|
@@ -3,48 +3,50 @@ 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 */ `import {
|
|
6
|
+
const template = ({ camelName, upperName, relative, type }) => /* ts */ `import { resolve, getDataValidator, getValidator, querySyntax } from '@feathersjs/schema'
|
|
7
7
|
import type { FromSchema } from '@feathersjs/schema'
|
|
8
8
|
|
|
9
9
|
import type { HookContext } from '${relative}/declarations'
|
|
10
10
|
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
export const ${camelName}
|
|
14
|
-
$id: '${upperName}
|
|
12
|
+
// Main data model schema
|
|
13
|
+
export const ${camelName}Schema = {
|
|
14
|
+
$id: '${upperName}',
|
|
15
15
|
type: 'object',
|
|
16
16
|
additionalProperties: false,
|
|
17
|
-
required: [ 'text' ],
|
|
17
|
+
required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
|
|
18
18
|
properties: {
|
|
19
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
20
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
21
|
+
},
|
|
19
22
|
text: {
|
|
20
23
|
type: 'string'
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
} as const
|
|
24
|
-
export type ${upperName}
|
|
25
|
-
export const ${camelName}
|
|
26
|
-
|
|
27
|
+
export type ${upperName} = FromSchema<typeof ${camelName}Schema>
|
|
28
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
29
|
+
properties: {}
|
|
30
|
+
})
|
|
31
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
27
32
|
properties: {}
|
|
28
33
|
})
|
|
29
34
|
|
|
30
|
-
// Schema for
|
|
31
|
-
export const ${camelName}
|
|
32
|
-
$id: '${upperName}',
|
|
35
|
+
// Schema for creating new data
|
|
36
|
+
export const ${camelName}DataSchema = {
|
|
37
|
+
$id: '${upperName}Data',
|
|
33
38
|
type: 'object',
|
|
34
39
|
additionalProperties: false,
|
|
35
|
-
required: [
|
|
40
|
+
required: [ 'text' ],
|
|
36
41
|
properties: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
42
|
+
text: {
|
|
43
|
+
type: 'string'
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
} as const
|
|
43
|
-
export type ${upperName} = FromSchema<typeof ${camelName}
|
|
44
|
-
export const ${camelName}
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
47
|
+
export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
|
|
48
|
+
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
49
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
48
50
|
properties: {}
|
|
49
51
|
})
|
|
50
52
|
|
|
@@ -54,11 +56,11 @@ export const ${camelName}QuerySchema = {
|
|
|
54
56
|
type: 'object',
|
|
55
57
|
additionalProperties: false,
|
|
56
58
|
properties: {
|
|
57
|
-
...
|
|
59
|
+
...querySyntax(${camelName}Schema.properties)
|
|
58
60
|
}
|
|
59
61
|
} as const
|
|
60
62
|
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
61
|
-
export const ${camelName}QueryValidator =
|
|
63
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
62
64
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
63
65
|
properties: {}
|
|
64
66
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.json.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;;;oCAGJ,QAAQ;iDACK,QAAQ;;;eAG1C,SAAS;UACd,SAAS
|
|
1
|
+
{"version":3,"file":"schema.json.tpl.js","sourceRoot":"","sources":["../../../src/service/templates/schema.json.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;;;oCAGJ,QAAQ;iDACK,QAAQ;;;eAG1C,SAAS;UACd,SAAS;;;iBAGF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;MAE5C,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;eACxB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;;;;;;;cAOzC,SAAS,wBAAwB,SAAS;eACzC,SAAS,sBAAsB,SAAS;;;eAGxC,SAAS,8BAA8B,SAAS;;;;;eAKhD,SAAS;UACd,SAAS;;;;;;;;;;cAUL,SAAS,4BAA4B,SAAS;eAC7C,SAAS,oCAAoC,SAAS;eACtD,SAAS,0BAA0B,SAAS;;;;;eAK5C,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;cAGhB,SAAS,6BAA6B,SAAS;eAC9C,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,MAAM,EACjC,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"}
|
|
@@ -7,48 +7,50 @@ const template = ({
|
|
|
7
7
|
upperName,
|
|
8
8
|
relative,
|
|
9
9
|
type
|
|
10
|
-
}: ServiceGeneratorContext) => /* ts */ `import {
|
|
10
|
+
}: ServiceGeneratorContext) => /* ts */ `import { resolve, getDataValidator, getValidator, querySyntax } from '@feathersjs/schema'
|
|
11
11
|
import type { FromSchema } from '@feathersjs/schema'
|
|
12
12
|
|
|
13
13
|
import type { HookContext } from '${relative}/declarations'
|
|
14
14
|
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
export const ${camelName}
|
|
18
|
-
$id: '${upperName}
|
|
16
|
+
// Main data model schema
|
|
17
|
+
export const ${camelName}Schema = {
|
|
18
|
+
$id: '${upperName}',
|
|
19
19
|
type: 'object',
|
|
20
20
|
additionalProperties: false,
|
|
21
|
-
required: [ 'text' ],
|
|
21
|
+
required: [ '${type === 'mongodb' ? '_id' : 'id'}', 'text' ],
|
|
22
22
|
properties: {
|
|
23
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
24
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
25
|
+
},
|
|
23
26
|
text: {
|
|
24
27
|
type: 'string'
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
} as const
|
|
28
|
-
export type ${upperName}
|
|
29
|
-
export const ${camelName}
|
|
30
|
-
|
|
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>({
|
|
31
36
|
properties: {}
|
|
32
37
|
})
|
|
33
38
|
|
|
34
|
-
// Schema for
|
|
35
|
-
export const ${camelName}
|
|
36
|
-
$id: '${upperName}',
|
|
39
|
+
// Schema for creating new data
|
|
40
|
+
export const ${camelName}DataSchema = {
|
|
41
|
+
$id: '${upperName}Data',
|
|
37
42
|
type: 'object',
|
|
38
43
|
additionalProperties: false,
|
|
39
|
-
required: [
|
|
44
|
+
required: [ 'text' ],
|
|
40
45
|
properties: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
46
|
+
text: {
|
|
47
|
+
type: 'string'
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
} as const
|
|
47
|
-
export type ${upperName} = FromSchema<typeof ${camelName}
|
|
48
|
-
export const ${camelName}
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
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>({
|
|
52
54
|
properties: {}
|
|
53
55
|
})
|
|
54
56
|
|
|
@@ -58,11 +60,11 @@ export const ${camelName}QuerySchema = {
|
|
|
58
60
|
type: 'object',
|
|
59
61
|
additionalProperties: false,
|
|
60
62
|
properties: {
|
|
61
|
-
...
|
|
63
|
+
...querySyntax(${camelName}Schema.properties)
|
|
62
64
|
}
|
|
63
65
|
} as const
|
|
64
66
|
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
65
|
-
export const ${camelName}QueryValidator =
|
|
67
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
66
68
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
67
69
|
properties: {}
|
|
68
70
|
})
|
|
@@ -3,30 +3,18 @@ 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 */ `import {
|
|
7
|
-
import { Type, querySyntax } from '@feathersjs/typebox'
|
|
6
|
+
const template = ({ camelName, upperName, relative, type }) => /* ts */ `import { resolve } from '@feathersjs/schema'
|
|
7
|
+
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
8
8
|
import type { Static } from '@feathersjs/typebox'
|
|
9
9
|
|
|
10
10
|
import type { HookContext } from '${relative}/declarations'
|
|
11
11
|
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
export const ${camelName}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
|
|
19
|
-
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
20
|
-
properties: {}
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
// Schema for the data that is being returned
|
|
24
|
-
export const ${camelName}Schema = Type.Intersect([
|
|
25
|
-
${camelName}DataSchema,
|
|
26
|
-
Type.Object({
|
|
27
|
-
${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'}
|
|
28
|
-
})
|
|
29
|
-
], { $id: '${upperName}', additionalProperties: false })
|
|
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 })
|
|
30
18
|
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
31
19
|
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
32
20
|
properties: {}
|
|
@@ -36,14 +24,23 @@ export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
|
36
24
|
properties: {}
|
|
37
25
|
})
|
|
38
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
|
+
|
|
39
37
|
// Schema for allowed query properties
|
|
40
|
-
export const ${camelName}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
])
|
|
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)
|
|
45
42
|
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
46
|
-
export const ${camelName}QueryValidator =
|
|
43
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
47
44
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
48
45
|
properties: {}
|
|
49
46
|
})
|
|
@@ -1 +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;;
|
|
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"}
|
|
@@ -7,30 +7,18 @@ const template = ({
|
|
|
7
7
|
upperName,
|
|
8
8
|
relative,
|
|
9
9
|
type
|
|
10
|
-
}: ServiceGeneratorContext) => /* ts */ `import {
|
|
11
|
-
import { Type, querySyntax } from '@feathersjs/typebox'
|
|
10
|
+
}: ServiceGeneratorContext) => /* ts */ `import { resolve } from '@feathersjs/schema'
|
|
11
|
+
import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/typebox'
|
|
12
12
|
import type { Static } from '@feathersjs/typebox'
|
|
13
13
|
|
|
14
14
|
import type { HookContext } from '${relative}/declarations'
|
|
15
15
|
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
16
16
|
|
|
17
|
-
//
|
|
18
|
-
export const ${camelName}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
|
|
23
|
-
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
24
|
-
properties: {}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// Schema for the data that is being returned
|
|
28
|
-
export const ${camelName}Schema = Type.Intersect([
|
|
29
|
-
${camelName}DataSchema,
|
|
30
|
-
Type.Object({
|
|
31
|
-
${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'}
|
|
32
|
-
})
|
|
33
|
-
], { $id: '${upperName}', additionalProperties: false })
|
|
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 })
|
|
34
22
|
export type ${upperName} = Static<typeof ${camelName}Schema>
|
|
35
23
|
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
36
24
|
properties: {}
|
|
@@ -40,14 +28,23 @@ export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
|
40
28
|
properties: {}
|
|
41
29
|
})
|
|
42
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
|
+
|
|
43
41
|
// Schema for allowed query properties
|
|
44
|
-
export const ${camelName}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
])
|
|
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)
|
|
49
46
|
export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
|
|
50
|
-
export const ${camelName}QueryValidator =
|
|
47
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
51
48
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
52
49
|
properties: {}
|
|
53
50
|
})
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ServiceGeneratorContext } from '../index';
|
|
2
|
-
export declare const template: ({ className, upperName,
|
|
2
|
+
export declare const template: ({ className, upperName, feathers, schema, fileName, relative }: ServiceGeneratorContext) => string;
|
|
3
3
|
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -3,21 +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 migrationTemplate = ({
|
|
6
|
+
const migrationTemplate = ({ kebabPath }) => /* ts */ `import type { Knex } from 'knex'
|
|
7
7
|
|
|
8
8
|
export async function up(knex: Knex): Promise<void> {
|
|
9
|
-
await knex.schema.createTable('${
|
|
9
|
+
await knex.schema.createTable('${kebabPath}', table => {
|
|
10
10
|
table.increments('id')
|
|
11
11
|
table.string('text')
|
|
12
12
|
})
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export async function down(knex: Knex): Promise<void> {
|
|
16
|
-
await knex.schema.dropTable('${
|
|
16
|
+
await knex.schema.dropTable('${kebabPath}')
|
|
17
17
|
}
|
|
18
18
|
`;
|
|
19
|
-
const template = ({ className, upperName,
|
|
20
|
-
import
|
|
19
|
+
const template = ({ className, upperName, feathers, schema, fileName, relative }) => /* ts */ `import type { Params } from '@feathersjs/feathers'
|
|
20
|
+
import { KnexService } from '@feathersjs/knex'
|
|
21
|
+
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
21
22
|
|
|
22
23
|
import type { Application } from '${relative}/declarations'
|
|
23
24
|
${schema
|
|
@@ -37,14 +38,15 @@ export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query>
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
40
|
-
export class ${className} extends
|
|
41
|
+
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
42
|
+
extends KnexService<${upperName}, ${upperName}Data, ServiceParams> {
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
export const getOptions = (app: Application) => {
|
|
45
|
+
export const getOptions = (app: Application): KnexAdapterOptions => {
|
|
44
46
|
return {
|
|
45
47
|
paginate: app.get('paginate'),
|
|
46
48
|
Model: app.get('${feathers.database}Client'),
|
|
47
|
-
name: '${
|
|
49
|
+
name: '${fileName}'
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACe,EAAE,EAAE,CAAC,QAAQ,CAAC;;;mCAGL,SAAS;;;;;;;iCAOX,SAAS;;CAEzC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/service/type/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACe,EAAE,EAAE,CAAC,QAAQ,CAAC;;;mCAGL,SAAS;;;;;;;iCAOX,SAAS;;CAEzC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;oCAIJ,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,oCAAoC,SAAS;;;;eAI1D,SAAS,mCAAmC,SAAS;wBAC5C,SAAS,KAAK,SAAS;;;;;;sBAMzB,QAAQ,CAAC,QAAQ;aAC1B,QAAQ;;;CAGpB,CAAA;AA1CY,QAAA,QAAQ,YA0CpB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,EAAE,CACvD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,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;KACA,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;AAvBQ,QAAA,QAAQ,YAuBhB"}
|
|
@@ -3,31 +3,31 @@ import { renderSource } from '../../commons'
|
|
|
3
3
|
import { ServiceGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
const migrationTemplate = ({
|
|
6
|
-
|
|
6
|
+
kebabPath
|
|
7
7
|
}: ServiceGeneratorContext) => /* ts */ `import type { Knex } from 'knex'
|
|
8
8
|
|
|
9
9
|
export async function up(knex: Knex): Promise<void> {
|
|
10
|
-
await knex.schema.createTable('${
|
|
10
|
+
await knex.schema.createTable('${kebabPath}', table => {
|
|
11
11
|
table.increments('id')
|
|
12
12
|
table.string('text')
|
|
13
13
|
})
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export async function down(knex: Knex): Promise<void> {
|
|
17
|
-
await knex.schema.dropTable('${
|
|
17
|
+
await knex.schema.dropTable('${kebabPath}')
|
|
18
18
|
}
|
|
19
19
|
`
|
|
20
20
|
|
|
21
21
|
export const template = ({
|
|
22
22
|
className,
|
|
23
23
|
upperName,
|
|
24
|
-
kebabName,
|
|
25
24
|
feathers,
|
|
26
25
|
schema,
|
|
27
26
|
fileName,
|
|
28
27
|
relative
|
|
29
|
-
}: ServiceGeneratorContext) => /* ts */ `import {
|
|
30
|
-
import
|
|
28
|
+
}: ServiceGeneratorContext) => /* ts */ `import type { Params } from '@feathersjs/feathers'
|
|
29
|
+
import { KnexService } from '@feathersjs/knex'
|
|
30
|
+
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
31
31
|
|
|
32
32
|
import type { Application } from '${relative}/declarations'
|
|
33
33
|
${
|
|
@@ -49,14 +49,15 @@ export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query>
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
52
|
-
export class ${className} extends
|
|
52
|
+
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
53
|
+
extends KnexService<${upperName}, ${upperName}Data, ServiceParams> {
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
export const getOptions = (app: Application) => {
|
|
56
|
+
export const getOptions = (app: Application): KnexAdapterOptions => {
|
|
56
57
|
return {
|
|
57
58
|
paginate: app.get('paginate'),
|
|
58
59
|
Model: app.get('${feathers.database}Client'),
|
|
59
|
-
name: '${
|
|
60
|
+
name: '${fileName}'
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ServiceGeneratorContext } from '../index';
|
|
2
|
-
export declare const template: ({ className, upperName,
|
|
2
|
+
export declare const template: ({ className, upperName, schema, fileName, kebabPath, relative }: ServiceGeneratorContext) => string;
|
|
3
3
|
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -3,8 +3,9 @@ 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,
|
|
7
|
-
import
|
|
6
|
+
const template = ({ className, upperName, schema, fileName, kebabPath, relative }) => /* ts */ `import type { Params } from '@feathersjs/feathers'
|
|
7
|
+
import { MongoDBService } from \'@feathersjs/mongodb\'
|
|
8
|
+
import type { MongoDBAdapterParams, MongoDBAdapterOptions } from \'@feathersjs/mongodb\'
|
|
8
9
|
|
|
9
10
|
import type { Application } from '${relative}/declarations'
|
|
10
11
|
${schema
|
|
@@ -24,13 +25,14 @@ export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Que
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
// By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
|
|
27
|
-
export class ${className} extends
|
|
28
|
+
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
29
|
+
extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams> {
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
export const getOptions = (app: Application) => {
|
|
32
|
+
export const getOptions = (app: Application): MongoDBAdapterOptions => {
|
|
31
33
|
return {
|
|
32
34
|
paginate: app.get('paginate'),
|
|
33
|
-
Model: app.get('mongodbClient').then(db => db.collection('${
|
|
35
|
+
Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}'))
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
`;
|