@feathersjs/cli 5.0.0-pre.34 → 5.0.0-pre.35
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 +13 -0
- package/lib/index.d.ts +6 -2
- package/lib/index.js +59 -2
- package/lib/index.js.map +1 -1
- package/package.json +28 -30
- package/lib/app/index.d.ts +0 -29
- package/lib/app/index.js +0 -146
- package/lib/app/index.js.map +0 -1
- package/lib/app/index.ts +0 -228
- package/lib/app/static/.gitignore +0 -121
- package/lib/app/templates/app.test.tpl.d.ts +0 -2
- package/lib/app/templates/app.test.tpl.js +0 -49
- package/lib/app/templates/app.test.tpl.js.map +0 -1
- package/lib/app/templates/app.test.tpl.ts +0 -50
- package/lib/app/templates/app.tpl.d.ts +0 -2
- package/lib/app/templates/app.tpl.js +0 -123
- package/lib/app/templates/app.tpl.js.map +0 -1
- package/lib/app/templates/app.tpl.ts +0 -138
- package/lib/app/templates/channels.tpl.d.ts +0 -2
- package/lib/app/templates/channels.tpl.js +0 -49
- package/lib/app/templates/channels.tpl.js.map +0 -1
- package/lib/app/templates/channels.tpl.ts +0 -55
- package/lib/app/templates/client.test.tpl.d.ts +0 -2
- package/lib/app/templates/client.test.tpl.js +0 -27
- package/lib/app/templates/client.test.tpl.js.map +0 -1
- package/lib/app/templates/client.test.tpl.ts +0 -26
- package/lib/app/templates/client.tpl.d.ts +0 -2
- package/lib/app/templates/client.tpl.js +0 -38
- package/lib/app/templates/client.tpl.js.map +0 -1
- package/lib/app/templates/client.tpl.ts +0 -45
- package/lib/app/templates/configuration.tpl.d.ts +0 -2
- package/lib/app/templates/configuration.tpl.js +0 -71
- package/lib/app/templates/configuration.tpl.js.map +0 -1
- package/lib/app/templates/configuration.tpl.ts +0 -82
- package/lib/app/templates/declarations.tpl.d.ts +0 -2
- package/lib/app/templates/declarations.tpl.js +0 -28
- package/lib/app/templates/declarations.tpl.js.map +0 -1
- package/lib/app/templates/declarations.tpl.ts +0 -37
- package/lib/app/templates/index.html.tpl.d.ts +0 -2
- package/lib/app/templates/index.html.tpl.js +0 -45
- package/lib/app/templates/index.html.tpl.js.map +0 -1
- package/lib/app/templates/index.html.tpl.ts +0 -44
- package/lib/app/templates/index.tpl.d.ts +0 -2
- package/lib/app/templates/index.tpl.js +0 -18
- package/lib/app/templates/index.tpl.js.map +0 -1
- package/lib/app/templates/index.tpl.ts +0 -22
- package/lib/app/templates/logger.tpl.d.ts +0 -3
- package/lib/app/templates/logger.tpl.js +0 -45
- package/lib/app/templates/logger.tpl.js.map +0 -1
- package/lib/app/templates/logger.tpl.ts +0 -56
- package/lib/app/templates/package.json.tpl.d.ts +0 -2
- package/lib/app/templates/package.json.tpl.js +0 -58
- package/lib/app/templates/package.json.tpl.js.map +0 -1
- package/lib/app/templates/package.json.tpl.ts +0 -71
- package/lib/app/templates/prettierrc.tpl.d.ts +0 -2
- package/lib/app/templates/prettierrc.tpl.js +0 -11
- package/lib/app/templates/prettierrc.tpl.js.map +0 -1
- package/lib/app/templates/prettierrc.tpl.ts +0 -14
- package/lib/app/templates/readme.md.tpl.d.ts +0 -2
- package/lib/app/templates/readme.md.tpl.js +0 -54
- package/lib/app/templates/readme.md.tpl.js.map +0 -1
- package/lib/app/templates/readme.md.tpl.ts +0 -57
- package/lib/app/templates/services.tpl.d.ts +0 -2
- package/lib/app/templates/services.tpl.js +0 -15
- package/lib/app/templates/services.tpl.js.map +0 -1
- package/lib/app/templates/services.tpl.ts +0 -20
- package/lib/app/templates/tsconfig.json.tpl.d.ts +0 -2
- package/lib/app/templates/tsconfig.json.tpl.js +0 -22
- package/lib/app/templates/tsconfig.json.tpl.js.map +0 -1
- package/lib/app/templates/tsconfig.json.tpl.ts +0 -28
- package/lib/app/templates/validators.tpl.d.ts +0 -2
- package/lib/app/templates/validators.tpl.js +0 -36
- package/lib/app/templates/validators.tpl.js.map +0 -1
- package/lib/app/templates/validators.tpl.ts +0 -40
- package/lib/authentication/index.d.ts +0 -73
- package/lib/authentication/index.js +0 -107
- package/lib/authentication/index.js.map +0 -1
- package/lib/authentication/index.ts +0 -126
- package/lib/authentication/templates/authentication.tpl.d.ts +0 -2
- package/lib/authentication/templates/authentication.tpl.js +0 -40
- package/lib/authentication/templates/authentication.tpl.js.map +0 -1
- package/lib/authentication/templates/authentication.tpl.ts +0 -51
- package/lib/authentication/templates/client.test.tpl.d.ts +0 -2
- package/lib/authentication/templates/client.test.tpl.js +0 -62
- package/lib/authentication/templates/client.test.tpl.js.map +0 -1
- package/lib/authentication/templates/client.test.tpl.ts +0 -74
- package/lib/authentication/templates/config.tpl.d.ts +0 -2
- package/lib/authentication/templates/config.tpl.js +0 -50
- package/lib/authentication/templates/config.tpl.js.map +0 -1
- package/lib/authentication/templates/config.tpl.ts +0 -57
- package/lib/authentication/templates/declarations.tpl.d.ts +0 -2
- package/lib/authentication/templates/declarations.tpl.js +0 -19
- package/lib/authentication/templates/declarations.tpl.js.map +0 -1
- package/lib/authentication/templates/declarations.tpl.ts +0 -34
- package/lib/authentication/templates/knex.tpl.d.ts +0 -2
- package/lib/authentication/templates/knex.tpl.js +0 -45
- package/lib/authentication/templates/knex.tpl.js.map +0 -1
- package/lib/authentication/templates/knex.tpl.ts +0 -62
- package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
- package/lib/authentication/templates/schema.json.tpl.js +0 -103
- package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.json.tpl.ts +0 -124
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
- package/lib/authentication/templates/schema.typebox.tpl.js +0 -86
- package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +0 -108
- package/lib/cli.d.ts +0 -6
- package/lib/cli.js +0 -75
- package/lib/cli.js.map +0 -1
- package/lib/cli.ts +0 -68
- package/lib/commons.d.ts +0 -150
- package/lib/commons.js +0 -198
- package/lib/commons.js.map +0 -1
- package/lib/commons.ts +0 -284
- package/lib/connection/index.d.ts +0 -55
- package/lib/connection/index.js +0 -88
- package/lib/connection/index.js.map +0 -1
- package/lib/connection/index.ts +0 -123
- package/lib/connection/templates/knex.tpl.d.ts +0 -2
- package/lib/connection/templates/knex.tpl.js +0 -48
- package/lib/connection/templates/knex.tpl.js.map +0 -1
- package/lib/connection/templates/knex.tpl.ts +0 -67
- package/lib/connection/templates/mongodb.tpl.d.ts +0 -2
- package/lib/connection/templates/mongodb.tpl.js +0 -34
- package/lib/connection/templates/mongodb.tpl.js.map +0 -1
- package/lib/connection/templates/mongodb.tpl.ts +0 -40
- package/lib/hook/index.d.ts +0 -22
- package/lib/hook/index.js +0 -43
- package/lib/hook/index.js.map +0 -1
- package/lib/hook/index.ts +0 -47
- package/lib/hook/templates/hook.tpl.d.ts +0 -2
- package/lib/hook/templates/hook.tpl.js +0 -22
- package/lib/hook/templates/hook.tpl.js.map +0 -1
- package/lib/hook/templates/hook.tpl.ts +0 -33
- package/lib/index.ts +0 -2
- package/lib/service/index.d.ts +0 -64
- package/lib/service/index.js +0 -116
- package/lib/service/index.js.map +0 -1
- package/lib/service/index.ts +0 -191
- package/lib/service/templates/client.tpl.d.ts +0 -2
- package/lib/service/templates/client.tpl.js +0 -31
- package/lib/service/templates/client.tpl.js.map +0 -1
- package/lib/service/templates/client.tpl.ts +0 -57
- package/lib/service/templates/schema.json.tpl.d.ts +0 -2
- package/lib/service/templates/schema.json.tpl.js +0 -83
- package/lib/service/templates/schema.json.tpl.js.map +0 -1
- package/lib/service/templates/schema.json.tpl.ts +0 -98
- package/lib/service/templates/schema.typebox.tpl.d.ts +0 -2
- package/lib/service/templates/schema.typebox.tpl.js +0 -61
- package/lib/service/templates/schema.typebox.tpl.js.map +0 -1
- package/lib/service/templates/schema.typebox.tpl.ts +0 -76
- package/lib/service/templates/service.tpl.d.ts +0 -3
- package/lib/service/templates/service.tpl.js +0 -112
- package/lib/service/templates/service.tpl.js.map +0 -1
- package/lib/service/templates/service.tpl.ts +0 -152
- package/lib/service/templates/test.tpl.d.ts +0 -2
- package/lib/service/templates/test.tpl.js +0 -25
- package/lib/service/templates/test.tpl.js.map +0 -1
- package/lib/service/templates/test.tpl.ts +0 -33
- package/lib/service/type/custom.tpl.d.ts +0 -3
- package/lib/service/type/custom.tpl.js +0 -98
- package/lib/service/type/custom.tpl.js.map +0 -1
- package/lib/service/type/custom.tpl.ts +0 -109
- package/lib/service/type/knex.tpl.d.ts +0 -3
- package/lib/service/type/knex.tpl.js +0 -71
- package/lib/service/type/knex.tpl.js.map +0 -1
- package/lib/service/type/knex.tpl.ts +0 -92
- package/lib/service/type/mongodb.tpl.d.ts +0 -3
- package/lib/service/type/mongodb.tpl.js +0 -50
- package/lib/service/type/mongodb.tpl.js.map +0 -1
- package/lib/service/type/mongodb.tpl.ts +0 -62
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index'
|
|
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
|
-
export type ${upperName} = any
|
|
26
|
-
export type ${upperName}Data = any
|
|
27
|
-
export type ${upperName}Patch = any
|
|
28
|
-
export type ${upperName}Query = any
|
|
29
|
-
`
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ${className}Options {
|
|
33
|
-
app: Application
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ${upperName}Params extends Params<${upperName}Query> {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// This is a skeleton for a custom service class. Remove or add the methods you need here
|
|
41
|
-
export class ${className} implements ServiceInterface<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> {
|
|
42
|
-
constructor (public options: ${className}Options) {
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async find (_params?: ${upperName}Params): Promise<${upperName}[]> {
|
|
46
|
-
return []
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async get (id: Id, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
50
|
-
return {
|
|
51
|
-
id: 0,
|
|
52
|
-
text: \`A new message with ID: \${id}!\`
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async create (data: ${upperName}Data, params?: ${upperName}Params): Promise<${upperName}>
|
|
57
|
-
async create (data: ${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}[]>
|
|
58
|
-
async create (data: ${upperName}Data|${upperName}Data[], params?: ${upperName}Params): Promise<${upperName}|${upperName}[]> {
|
|
59
|
-
if (Array.isArray(data)) {
|
|
60
|
-
return Promise.all(data.map(current => this.create(current, params)));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
id: 0,
|
|
65
|
-
...data
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// This method has to be added to the 'methods' option to make it available to clients
|
|
70
|
-
async update (id: NullableId, data: ${upperName}Data, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
71
|
-
return {
|
|
72
|
-
id: 0,
|
|
73
|
-
...data
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async patch (id: NullableId, data: ${upperName}Patch, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
78
|
-
return {
|
|
79
|
-
id: 0,
|
|
80
|
-
text: \`Fallback for \${id}\`,
|
|
81
|
-
...data
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async remove (id: NullableId, _params?: ${upperName}Params): Promise<${upperName}> {
|
|
86
|
-
return {
|
|
87
|
-
id: 0,
|
|
88
|
-
text: 'removed'
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const getOptions = (app: Application) => {
|
|
94
|
-
return { app }
|
|
95
|
-
}
|
|
96
|
-
`
|
|
97
|
-
|
|
98
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
99
|
-
generator(ctx).then(
|
|
100
|
-
renderSource(
|
|
101
|
-
template,
|
|
102
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
103
|
-
lib,
|
|
104
|
-
'services',
|
|
105
|
-
...folder,
|
|
106
|
-
`${fileName}.class`
|
|
107
|
-
])
|
|
108
|
-
)
|
|
109
|
-
)
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ServiceGeneratorContext } from '../index';
|
|
2
|
-
export declare const template: ({ className, upperName, feathers, schema, fileName, relative }: ServiceGeneratorContext) => string;
|
|
3
|
-
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = exports.template = void 0;
|
|
4
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const commons_1 = require("../../commons");
|
|
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'
|
|
8
|
-
|
|
9
|
-
export async function up(knex: Knex): Promise<void> {
|
|
10
|
-
await knex.schema.createTable('${kebabPath}', table => {
|
|
11
|
-
table.increments('id')
|
|
12
|
-
table.string('text')
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function down(knex: Knex): Promise<void> {
|
|
17
|
-
await knex.schema.dropTable('${kebabPath}')
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
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'
|
|
22
|
-
import { KnexService } from '@feathersjs/knex'
|
|
23
|
-
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
24
|
-
|
|
25
|
-
import type { Application } from '${relative}/declarations'
|
|
26
|
-
${schema
|
|
27
|
-
? `import type {
|
|
28
|
-
${upperName},
|
|
29
|
-
${upperName}Data,
|
|
30
|
-
${upperName}Patch,
|
|
31
|
-
${upperName}Query
|
|
32
|
-
} from './${fileName}.schema'
|
|
33
|
-
`
|
|
34
|
-
: `
|
|
35
|
-
export type ${upperName} = any
|
|
36
|
-
export type ${upperName}Data = any
|
|
37
|
-
export type ${upperName}Patch = any
|
|
38
|
-
export type ${upperName}Query = any
|
|
39
|
-
`}
|
|
40
|
-
|
|
41
|
-
export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
45
|
-
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
46
|
-
extends KnexService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const getOptions = (app: Application): KnexAdapterOptions => {
|
|
50
|
-
return {
|
|
51
|
-
paginate: app.get('paginate'),
|
|
52
|
-
Model: app.get('${feathers.database}Client'),
|
|
53
|
-
name: '${fileName}'
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
`;
|
|
57
|
-
exports.template = template;
|
|
58
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
59
|
-
.then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
60
|
-
lib,
|
|
61
|
-
'services',
|
|
62
|
-
...folder,
|
|
63
|
-
`${fileName}.class`
|
|
64
|
-
])))
|
|
65
|
-
.then((0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)('migrations', ({ kebabName }) => {
|
|
66
|
-
// Probably not great but it works to align with the Knex migration file format
|
|
67
|
-
const migrationDate = new Date().toISOString().replace(/\D/g, '').substring(0, 14);
|
|
68
|
-
return `${migrationDate}_${kebabName}`;
|
|
69
|
-
})));
|
|
70
|
-
exports.generate = generate;
|
|
71
|
-
//# sourceMappingURL=knex.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;mCAIL,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;;;;;oCAKJ,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,oCAAoC,SAAS;;;;eAI1D,SAAS,mCAAmC,SAAS;wBAC5C,SAAS,KAAK,SAAS,wBAAwB,SAAS;;;;;;sBAM1D,QAAQ,CAAC,QAAQ;aAC1B,QAAQ;;;CAGpB,CAAA;AA7CY,QAAA,QAAQ,YA6CpB;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"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index'
|
|
4
|
-
|
|
5
|
-
const migrationTemplate = ({
|
|
6
|
-
kebabPath
|
|
7
|
-
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/knexfile.html
|
|
8
|
-
import type { Knex } from 'knex'
|
|
9
|
-
|
|
10
|
-
export async function up(knex: Knex): Promise<void> {
|
|
11
|
-
await knex.schema.createTable('${kebabPath}', table => {
|
|
12
|
-
table.increments('id')
|
|
13
|
-
table.string('text')
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function down(knex: Knex): Promise<void> {
|
|
18
|
-
await knex.schema.dropTable('${kebabPath}')
|
|
19
|
-
}
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
export const template = ({
|
|
23
|
-
className,
|
|
24
|
-
upperName,
|
|
25
|
-
feathers,
|
|
26
|
-
schema,
|
|
27
|
-
fileName,
|
|
28
|
-
relative
|
|
29
|
-
}: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
|
|
30
|
-
import type { Params } from '@feathersjs/feathers'
|
|
31
|
-
import { KnexService } from '@feathersjs/knex'
|
|
32
|
-
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'
|
|
33
|
-
|
|
34
|
-
import type { Application } from '${relative}/declarations'
|
|
35
|
-
${
|
|
36
|
-
schema
|
|
37
|
-
? `import type {
|
|
38
|
-
${upperName},
|
|
39
|
-
${upperName}Data,
|
|
40
|
-
${upperName}Patch,
|
|
41
|
-
${upperName}Query
|
|
42
|
-
} from './${fileName}.schema'
|
|
43
|
-
`
|
|
44
|
-
: `
|
|
45
|
-
export type ${upperName} = any
|
|
46
|
-
export type ${upperName}Data = any
|
|
47
|
-
export type ${upperName}Patch = any
|
|
48
|
-
export type ${upperName}Query = any
|
|
49
|
-
`
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> {
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
|
|
56
|
-
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
57
|
-
extends KnexService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const getOptions = (app: Application): KnexAdapterOptions => {
|
|
61
|
-
return {
|
|
62
|
-
paginate: app.get('paginate'),
|
|
63
|
-
Model: app.get('${feathers.database}Client'),
|
|
64
|
-
name: '${fileName}'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
`
|
|
68
|
-
|
|
69
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
70
|
-
generator(ctx)
|
|
71
|
-
.then(
|
|
72
|
-
renderSource(
|
|
73
|
-
template,
|
|
74
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
75
|
-
lib,
|
|
76
|
-
'services',
|
|
77
|
-
...folder,
|
|
78
|
-
`${fileName}.class`
|
|
79
|
-
])
|
|
80
|
-
)
|
|
81
|
-
)
|
|
82
|
-
.then(
|
|
83
|
-
renderSource(
|
|
84
|
-
migrationTemplate,
|
|
85
|
-
toFile<ServiceGeneratorContext>('migrations', ({ kebabName }) => {
|
|
86
|
-
// Probably not great but it works to align with the Knex migration file format
|
|
87
|
-
const migrationDate = new Date().toISOString().replace(/\D/g, '').substring(0, 14)
|
|
88
|
-
|
|
89
|
-
return `${migrationDate}_${kebabName}`
|
|
90
|
-
})
|
|
91
|
-
)
|
|
92
|
-
)
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ServiceGeneratorContext } from '../index';
|
|
2
|
-
export declare const template: ({ className, upperName, schema, fileName, kebabPath, relative }: ServiceGeneratorContext) => string;
|
|
3
|
-
export declare const generate: (ctx: ServiceGeneratorContext) => Promise<ServiceGeneratorContext>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = exports.template = void 0;
|
|
4
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ className, upperName, schema, fileName, kebabPath, relative }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
|
|
7
|
-
import type { Params } from '@feathersjs/feathers'
|
|
8
|
-
import { MongoDBService } from \'@feathersjs/mongodb\'
|
|
9
|
-
import type { MongoDBAdapterParams, MongoDBAdapterOptions } from \'@feathersjs/mongodb\'
|
|
10
|
-
|
|
11
|
-
import type { Application } from '${relative}/declarations'
|
|
12
|
-
${schema
|
|
13
|
-
? `import type {
|
|
14
|
-
${upperName},
|
|
15
|
-
${upperName}Data,
|
|
16
|
-
${upperName}Patch,
|
|
17
|
-
${upperName}Query
|
|
18
|
-
} from './${fileName}.schema'
|
|
19
|
-
`
|
|
20
|
-
: `
|
|
21
|
-
export type ${upperName} = any
|
|
22
|
-
export type ${upperName}Data = any
|
|
23
|
-
export type ${upperName}Patch = any
|
|
24
|
-
export type ${upperName}Query = any
|
|
25
|
-
`}
|
|
26
|
-
|
|
27
|
-
export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
|
|
31
|
-
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
32
|
-
extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const getOptions = (app: Application): MongoDBAdapterOptions => {
|
|
36
|
-
return {
|
|
37
|
-
paginate: app.get('paginate'),
|
|
38
|
-
Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}'))
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
`;
|
|
42
|
-
exports.template = template;
|
|
43
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
44
|
-
lib,
|
|
45
|
-
'services',
|
|
46
|
-
...folder,
|
|
47
|
-
`${fileName}.class`
|
|
48
|
-
])));
|
|
49
|
-
exports.generate = generate;
|
|
50
|
-
//# sourceMappingURL=mongodb.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/service/type/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACgB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;oCAKJ,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,uCAAuC,SAAS;;;;eAI7D,SAAS,mCAAmC,SAAS;2BACzC,SAAS,KAAK,SAAS,wBAAwB,SAAS;;;;;;gEAMnB,SAAS;;;CAGxE,CAAA;AA5CY,QAAA,QAAQ,YA4CpB;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"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
3
|
-
import { ServiceGeneratorContext } from '../index'
|
|
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
|
-
export type ${upperName} = any
|
|
29
|
-
export type ${upperName}Data = any
|
|
30
|
-
export type ${upperName}Patch = any
|
|
31
|
-
export type ${upperName}Query = any
|
|
32
|
-
`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> {
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// By default calls the standard MongoDB adapter service methods but can be customized with your own functionality.
|
|
39
|
-
export class ${className}<ServiceParams extends Params = ${upperName}Params>
|
|
40
|
-
extends MongoDBService<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> {
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const getOptions = (app: Application): MongoDBAdapterOptions => {
|
|
44
|
-
return {
|
|
45
|
-
paginate: app.get('paginate'),
|
|
46
|
-
Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}'))
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
export const generate = (ctx: ServiceGeneratorContext) =>
|
|
52
|
-
generator(ctx).then(
|
|
53
|
-
renderSource(
|
|
54
|
-
template,
|
|
55
|
-
toFile<ServiceGeneratorContext>(({ lib, folder, fileName }) => [
|
|
56
|
-
lib,
|
|
57
|
-
'services',
|
|
58
|
-
...folder,
|
|
59
|
-
`${fileName}.class`
|
|
60
|
-
])
|
|
61
|
-
)
|
|
62
|
-
)
|