@feathersjs/generators 5.0.27 → 5.0.29
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 +10 -0
- package/lib/app/index.d.ts +3 -3
- package/lib/app/index.js +1 -2
- package/lib/app/index.js.map +1 -1
- package/lib/app/templates/gitignore.tpl.d.ts +5 -0
- package/lib/app/{static/.gitignore → templates/gitignore.tpl.js} +5 -1
- package/lib/app/templates/gitignore.tpl.js.map +1 -0
- package/lib/authentication/index.d.ts +3 -3
- package/lib/commons.d.ts +4 -4
- package/lib/commons.js +4 -0
- package/lib/commons.js.map +1 -1
- package/lib/hook/index.d.ts +2 -2
- package/package.json +32 -33
- package/lib/app/index.ts +0 -215
- package/lib/app/templates/app.test.tpl.ts +0 -50
- package/lib/app/templates/app.tpl.ts +0 -141
- package/lib/app/templates/channels.tpl.ts +0 -54
- package/lib/app/templates/client.test.tpl.ts +0 -28
- package/lib/app/templates/client.tpl.ts +0 -53
- package/lib/app/templates/configuration.tpl.ts +0 -89
- package/lib/app/templates/declarations.tpl.ts +0 -42
- package/lib/app/templates/index.html.tpl.ts +0 -44
- package/lib/app/templates/index.tpl.ts +0 -26
- package/lib/app/templates/logger.tpl.ts +0 -56
- package/lib/app/templates/package.json.tpl.ts +0 -78
- package/lib/app/templates/prettierrc.tpl.ts +0 -14
- package/lib/app/templates/readme.md.tpl.ts +0 -57
- package/lib/app/templates/services.tpl.ts +0 -20
- package/lib/app/templates/tsconfig.json.tpl.ts +0 -29
- package/lib/app/templates/validators.tpl.ts +0 -39
- package/lib/authentication/index.ts +0 -119
- package/lib/authentication/templates/authentication.tpl.ts +0 -52
- package/lib/authentication/templates/client.test.tpl.ts +0 -78
- package/lib/authentication/templates/config.tpl.ts +0 -60
- package/lib/authentication/templates/declarations.tpl.ts +0 -38
- package/lib/commons.ts +0 -341
- package/lib/connection/index.ts +0 -138
- package/lib/connection/templates/knex.tpl.ts +0 -73
- package/lib/connection/templates/mongodb.tpl.ts +0 -50
- package/lib/hook/index.ts +0 -52
- package/lib/hook/templates/hook.tpl.ts +0 -33
- package/lib/index.ts +0 -8
- package/lib/service/index.ts +0 -214
- package/lib/service/templates/client.tpl.ts +0 -33
- package/lib/service/templates/schema.json.tpl.ts +0 -143
- package/lib/service/templates/schema.typebox.tpl.ts +0 -131
- package/lib/service/templates/service.tpl.ts +0 -161
- package/lib/service/templates/shared.tpl.ts +0 -64
- package/lib/service/templates/test.tpl.ts +0 -33
- package/lib/service/type/custom.tpl.ts +0 -112
- package/lib/service/type/knex.tpl.ts +0 -105
- package/lib/service/type/mongodb.tpl.ts +0 -64
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { toFile, when } from '@featherscloud/pinion'
|
|
2
|
-
import { fileExists, renderSource } from '../../commons.js'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index.js'
|
|
4
|
-
|
|
5
|
-
const sharedTemplate = ({
|
|
6
|
-
camelName,
|
|
7
|
-
upperName,
|
|
8
|
-
className,
|
|
9
|
-
fileName,
|
|
10
|
-
relative,
|
|
11
|
-
path
|
|
12
|
-
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.shared.html
|
|
13
|
-
import type { Params } from '@feathersjs/feathers'
|
|
14
|
-
import type { ClientApplication } from '${relative}/client'
|
|
15
|
-
import type {
|
|
16
|
-
${upperName},
|
|
17
|
-
${upperName}Data,
|
|
18
|
-
${upperName}Patch,
|
|
19
|
-
${upperName}Query,
|
|
20
|
-
${className}
|
|
21
|
-
} from './${fileName}.class'
|
|
22
|
-
|
|
23
|
-
export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query }
|
|
24
|
-
|
|
25
|
-
export type ${upperName}ClientService = Pick<
|
|
26
|
-
${className}<Params<${upperName}Query>>,
|
|
27
|
-
typeof ${camelName}Methods[number]
|
|
28
|
-
>
|
|
29
|
-
|
|
30
|
-
export const ${camelName}Path = '${path}'
|
|
31
|
-
|
|
32
|
-
export const ${camelName}Methods: Array<keyof ${className}> = ['find', 'get', 'create', 'patch', 'remove']
|
|
33
|
-
|
|
34
|
-
export const ${camelName}Client = (client: ClientApplication) => {
|
|
35
|
-
const connection = client.get('connection')
|
|
36
|
-
|
|
37
|
-
client.use(${camelName}Path, connection.service(${camelName}Path), {
|
|
38
|
-
methods: ${camelName}Methods
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Add this service to the client service type index
|
|
43
|
-
declare module '${relative}/client' {
|
|
44
|
-
interface ServiceTypes {
|
|
45
|
-
[${camelName}Path]: ${upperName}ClientService
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
export const generate = async (ctx: ServiceGeneratorContext) =>
|
|
51
|
-
Promise.resolve(ctx).then(
|
|
52
|
-
when<ServiceGeneratorContext>(
|
|
53
|
-
({ lib, language }) => fileExists(lib, `client.${language}`),
|
|
54
|
-
renderSource(
|
|
55
|
-
sharedTemplate,
|
|
56
|
-
toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [
|
|
57
|
-
lib,
|
|
58
|
-
'services',
|
|
59
|
-
...folder,
|
|
60
|
-
`${fileName}.shared`
|
|
61
|
-
])
|
|
62
|
-
)
|
|
63
|
-
)
|
|
64
|
-
)
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { toFile } from '@featherscloud/pinion'
|
|
2
|
-
import { renderSource } from '../../commons.js'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index.js'
|
|
4
|
-
|
|
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'
|
|
11
|
-
import { app } from '../${relative}/${lib}/app'
|
|
12
|
-
|
|
13
|
-
describe('${path} service', () => {
|
|
14
|
-
it('registered the service', () => {
|
|
15
|
-
const service = app.service('${path}')
|
|
16
|
-
|
|
17
|
-
assert.ok(service, 'Registered the service')
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
23
|
-
Promise.resolve(ctx).then(
|
|
24
|
-
renderSource(
|
|
25
|
-
template,
|
|
26
|
-
toFile<ServiceGeneratorContext>(({ test, folder, fileName }) => [
|
|
27
|
-
test,
|
|
28
|
-
'services',
|
|
29
|
-
...folder,
|
|
30
|
-
`${fileName}.test`
|
|
31
|
-
])
|
|
32
|
-
)
|
|
33
|
-
)
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { toFile } from '@featherscloud/pinion'
|
|
2
|
-
import { renderSource } from '../../commons.js'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index.js'
|
|
4
|
-
|
|
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'
|
|
13
|
-
|
|
14
|
-
import type { Application } from '${relative}/declarations'
|
|
15
|
-
${
|
|
16
|
-
schema
|
|
17
|
-
? `import type {
|
|
18
|
-
${upperName},
|
|
19
|
-
${upperName}Data,
|
|
20
|
-
${upperName}Patch,
|
|
21
|
-
${upperName}Query
|
|
22
|
-
} from './${fileName}.schema'
|
|
23
|
-
`
|
|
24
|
-
: `
|
|
25
|
-
type ${upperName} = any
|
|
26
|
-
type ${upperName}Data = any
|
|
27
|
-
type ${upperName}Patch = any
|
|
28
|
-
type ${upperName}Query = any
|
|
29
|
-
`
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query }
|
|
33
|
-
|
|
34
|
-
export interface ${className}Options {
|
|
35
|
-
app: Application
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface ${upperName}Params extends Params<${upperName}Query> {
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// This is a skeleton for a custom service class. Remove or add the methods you need here
|
|
43
|
-
export class ${className}<ServiceParams extends ${upperName}Params = ${upperName}Params>
|
|
44
|
-
implements ServiceInterface<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
45
|
-
constructor (public options: ${className}Options) {
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async find (_params?: ServiceParams): Promise<${upperName}[]> {
|
|
49
|
-
return []
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async get (id: Id, _params?: ServiceParams): Promise<${upperName}> {
|
|
53
|
-
return {
|
|
54
|
-
id: 0,
|
|
55
|
-
text: \`A new message with ID: \${id}!\`
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async create (data: ${upperName}Data, params?: ServiceParams): Promise<${upperName}>
|
|
60
|
-
async create (data: ${upperName}Data[], params?: ServiceParams): Promise<${upperName}[]>
|
|
61
|
-
async create (data: ${upperName}Data|${upperName}Data[], params?: ServiceParams): Promise<${upperName}|${upperName}[]> {
|
|
62
|
-
if (Array.isArray(data)) {
|
|
63
|
-
return Promise.all(data.map(current => this.create(current, params)));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
id: 0,
|
|
68
|
-
...data
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// This method has to be added to the 'methods' option to make it available to clients
|
|
73
|
-
async update (id: NullableId, data: ${upperName}Data, _params?: ServiceParams): Promise<${upperName}> {
|
|
74
|
-
return {
|
|
75
|
-
id: 0,
|
|
76
|
-
...data
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async patch (id: NullableId, data: ${upperName}Patch, _params?: ServiceParams): Promise<${upperName}> {
|
|
81
|
-
return {
|
|
82
|
-
id: 0,
|
|
83
|
-
text: \`Fallback for \${id}\`,
|
|
84
|
-
...data
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async remove (id: NullableId, _params?: ServiceParams): Promise<${upperName}> {
|
|
89
|
-
return {
|
|
90
|
-
id: 0,
|
|
91
|
-
text: 'removed'
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const getOptions = (app: Application) => {
|
|
97
|
-
return { app }
|
|
98
|
-
}
|
|
99
|
-
`
|
|
100
|
-
|
|
101
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
102
|
-
Promise.resolve(ctx).then(
|
|
103
|
-
renderSource(
|
|
104
|
-
template,
|
|
105
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
106
|
-
lib,
|
|
107
|
-
'services',
|
|
108
|
-
...folder,
|
|
109
|
-
`${fileName}.class`
|
|
110
|
-
])
|
|
111
|
-
)
|
|
112
|
-
)
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { toFile } from '@featherscloud/pinion'
|
|
2
|
-
import { renderSource, yyyymmddhhmmss } from '../../commons.js'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index.js'
|
|
4
|
-
|
|
5
|
-
const migrationTemplate = ({
|
|
6
|
-
kebabPath,
|
|
7
|
-
authStrategies,
|
|
8
|
-
isEntityService
|
|
9
|
-
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/knexfile.html
|
|
10
|
-
import type { Knex } from 'knex'
|
|
11
|
-
|
|
12
|
-
export async function up(knex: Knex): Promise<void> {
|
|
13
|
-
await knex.schema.createTable('${kebabPath}', table => {
|
|
14
|
-
table.increments('id')
|
|
15
|
-
${
|
|
16
|
-
isEntityService
|
|
17
|
-
? authStrategies
|
|
18
|
-
.map((name) =>
|
|
19
|
-
name === 'local'
|
|
20
|
-
? `
|
|
21
|
-
table.string('email').unique()
|
|
22
|
-
table.string('password')`
|
|
23
|
-
: `
|
|
24
|
-
table.string('${name}Id')`
|
|
25
|
-
)
|
|
26
|
-
.join('\n')
|
|
27
|
-
: `
|
|
28
|
-
table.string('text')`
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function down(knex: Knex): Promise<void> {
|
|
34
|
-
await knex.schema.dropTable('${kebabPath}')
|
|
35
|
-
}
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
export const template = ({
|
|
39
|
-
className,
|
|
40
|
-
upperName,
|
|
41
|
-
feathers,
|
|
42
|
-
schema,
|
|
43
|
-
fileName,
|
|
44
|
-
relative
|
|
45
|
-
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
|
|
46
|
-
import type { Params } from '@feathersjs/feathers'
|
|
47
|
-
import { KnexService } from '@feathersjs/knex'
|
|
48
|
-
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
49
|
-
|
|
50
|
-
import type { Application } from '${relative}/declarations'
|
|
51
|
-
${
|
|
52
|
-
schema
|
|
53
|
-
? `import type {
|
|
54
|
-
${upperName},
|
|
55
|
-
${upperName}Data,
|
|
56
|
-
${upperName}Patch,
|
|
57
|
-
${upperName}Query
|
|
58
|
-
} from './${fileName}.schema'
|
|
59
|
-
`
|
|
60
|
-
: `
|
|
61
|
-
type ${upperName} = any
|
|
62
|
-
type ${upperName}Data = any
|
|
63
|
-
type ${upperName}Patch = any
|
|
64
|
-
type ${upperName}Query = any
|
|
65
|
-
`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query }
|
|
69
|
-
|
|
70
|
-
export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
74
|
-
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
75
|
-
extends KnexService<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const getOptions = (app: Application): KnexAdapterOptions => {
|
|
79
|
-
return {
|
|
80
|
-
paginate: app.get('paginate'),
|
|
81
|
-
Model: app.get('${feathers.database}Client'),
|
|
82
|
-
name: '${fileName}'
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
`
|
|
86
|
-
|
|
87
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
88
|
-
Promise.resolve(ctx)
|
|
89
|
-
.then(
|
|
90
|
-
renderSource(
|
|
91
|
-
template,
|
|
92
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
93
|
-
lib,
|
|
94
|
-
'services',
|
|
95
|
-
...folder,
|
|
96
|
-
`${fileName}.class`
|
|
97
|
-
])
|
|
98
|
-
)
|
|
99
|
-
)
|
|
100
|
-
.then(
|
|
101
|
-
renderSource(
|
|
102
|
-
migrationTemplate,
|
|
103
|
-
toFile<ServiceGeneratorContext>('migrations', ({ kebabName }) => `${yyyymmddhhmmss()}_${kebabName}`)
|
|
104
|
-
)
|
|
105
|
-
)
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { toFile } from '@featherscloud/pinion'
|
|
2
|
-
import { renderSource } from '../../commons.js'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index.js'
|
|
4
|
-
|
|
5
|
-
export const template = ({
|
|
6
|
-
className,
|
|
7
|
-
upperName,
|
|
8
|
-
schema,
|
|
9
|
-
fileName,
|
|
10
|
-
kebabPath,
|
|
11
|
-
relative
|
|
12
|
-
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
|
|
13
|
-
import type { Params } from '@feathersjs/feathers'
|
|
14
|
-
import { MongoDBService } from \'@feathersjs/mongodb\'
|
|
15
|
-
import type { MongoDBAdapterParams, MongoDBAdapterOptions } from \'@feathersjs/mongodb\'
|
|
16
|
-
|
|
17
|
-
import type { Application } from '${relative}/declarations'
|
|
18
|
-
${
|
|
19
|
-
schema
|
|
20
|
-
? `import type {
|
|
21
|
-
${upperName},
|
|
22
|
-
${upperName}Data,
|
|
23
|
-
${upperName}Patch,
|
|
24
|
-
${upperName}Query
|
|
25
|
-
} from './${fileName}.schema'
|
|
26
|
-
`
|
|
27
|
-
: `
|
|
28
|
-
type ${upperName} = any
|
|
29
|
-
type ${upperName}Data = any
|
|
30
|
-
type ${upperName}Patch = any
|
|
31
|
-
type ${upperName}Query = any
|
|
32
|
-
`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query }
|
|
36
|
-
|
|
37
|
-
export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
|
|
41
|
-
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
42
|
-
extends MongoDBService<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const getOptions = (app: Application): MongoDBAdapterOptions => {
|
|
46
|
-
return {
|
|
47
|
-
paginate: app.get('paginate'),
|
|
48
|
-
Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}'))
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
`
|
|
52
|
-
|
|
53
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
54
|
-
Promise.resolve(ctx).then(
|
|
55
|
-
renderSource(
|
|
56
|
-
template,
|
|
57
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
58
|
-
lib,
|
|
59
|
-
'services',
|
|
60
|
-
...folder,
|
|
61
|
-
`${fileName}.class`
|
|
62
|
-
])
|
|
63
|
-
)
|
|
64
|
-
)
|