@feathersjs/cli 5.0.0-pre.28 → 5.0.0-pre.30
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 +28 -28
- package/bin/feathers +3 -6
- package/lib/app/index.js +34 -11
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +81 -53
- package/lib/app/templates/app.test.tpl.js +1 -1
- package/lib/app/templates/app.test.tpl.js.map +1 -1
- package/lib/app/templates/app.test.tpl.ts +1 -2
- package/lib/app/templates/app.tpl.js +24 -12
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +28 -14
- package/lib/app/templates/channels.tpl.js +1 -1
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +1 -2
- package/lib/app/templates/client.tpl.js +3 -3
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +3 -4
- package/lib/app/templates/config.tpl.js +10 -1
- package/lib/app/templates/config.tpl.js.map +1 -1
- package/lib/app/templates/config.tpl.ts +10 -0
- package/lib/app/templates/declarations.tpl.js +3 -3
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +5 -4
- package/lib/app/templates/index.html.tpl.js +12 -52
- package/lib/app/templates/index.html.tpl.js.map +1 -1
- package/lib/app/templates/index.html.tpl.ts +12 -53
- package/lib/app/templates/index.tpl.js +1 -1
- package/lib/app/templates/index.tpl.js.map +1 -1
- package/lib/app/templates/index.tpl.ts +1 -2
- package/lib/app/templates/logger.tpl.js +1 -1
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +2 -2
- package/lib/app/templates/package.json.tpl.js +4 -3
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -3
- package/lib/app/templates/readme.md.tpl.js +11 -7
- package/lib/app/templates/readme.md.tpl.js.map +1 -1
- package/lib/app/templates/readme.md.tpl.ts +15 -8
- package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
- package/lib/app/templates/schemas.tpl.js +76 -0
- package/lib/app/templates/schemas.tpl.js.map +1 -0
- package/lib/app/templates/schemas.tpl.ts +90 -0
- package/lib/app/templates/services.tpl.js +1 -1
- package/lib/app/templates/services.tpl.js.map +1 -1
- package/lib/app/templates/services.tpl.ts +1 -2
- package/lib/authentication/index.d.ts +4 -3
- package/lib/authentication/index.js +12 -3
- package/lib/authentication/index.js.map +1 -1
- package/lib/authentication/index.ts +23 -5
- package/lib/authentication/templates/authentication.tpl.js +4 -6
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +6 -9
- package/lib/authentication/templates/config.tpl.js +10 -6
- package/lib/authentication/templates/config.tpl.js.map +1 -1
- package/lib/authentication/templates/config.tpl.ts +40 -34
- package/lib/authentication/templates/declarations.tpl.js +3 -3
- package/lib/authentication/templates/declarations.tpl.js.map +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +9 -4
- package/lib/authentication/templates/knex.tpl.js +5 -4
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +5 -4
- package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/authentication/templates/schema.json.tpl.js +92 -0
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.json.tpl.ts +108 -0
- package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
- package/lib/authentication/templates/test.tpl.js +2 -2
- package/lib/authentication/templates/test.tpl.js.map +1 -1
- package/lib/authentication/templates/test.tpl.ts +6 -3
- package/lib/cli.d.ts +6 -0
- package/lib/cli.js +75 -0
- package/lib/cli.js.map +1 -0
- package/lib/cli.ts +68 -0
- package/lib/commons.d.ts +14 -1
- package/lib/commons.js +24 -4
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +29 -1
- package/lib/connection/index.d.ts +5 -3
- package/lib/connection/index.js +5 -3
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +19 -5
- package/lib/connection/templates/knex.tpl.js +2 -12
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -20
- package/lib/connection/templates/mongodb.tpl.js +1 -3
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +1 -12
- package/lib/hook/index.d.ts +1 -1
- package/lib/hook/index.js +3 -0
- package/lib/hook/index.js.map +1 -1
- package/lib/hook/index.ts +3 -1
- package/lib/hook/templates/hook.tpl.js +2 -3
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +5 -3
- package/lib/index.d.ts +2 -16
- package/lib/index.js +16 -24
- package/lib/index.js.map +1 -1
- package/lib/index.ts +2 -28
- package/lib/service/index.d.ts +10 -2
- package/lib/service/index.js +79 -41
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +54 -6
- package/lib/service/templates/client.tpl.js +26 -6
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +41 -12
- package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.json.tpl.js +73 -0
- package/lib/service/templates/schema.json.tpl.js.map +1 -0
- package/lib/service/templates/schema.json.tpl.ts +85 -0
- package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.typebox.tpl.js +58 -0
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/service/templates/schema.typebox.tpl.ts +70 -0
- package/lib/service/templates/service.tpl.d.ts +1 -0
- package/lib/service/templates/service.tpl.js +67 -15
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +98 -19
- package/lib/service/templates/test.tpl.js +1 -1
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +1 -2
- package/lib/service/type/custom.tpl.d.ts +1 -2
- package/lib/service/type/custom.tpl.js +32 -25
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +44 -35
- package/lib/service/type/knex.tpl.d.ts +1 -3
- package/lib/service/type/knex.tpl.js +33 -23
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +51 -29
- package/lib/service/type/mongodb.tpl.d.ts +1 -2
- package/lib/service/type/mongodb.tpl.js +30 -20
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +47 -29
- package/package.json +23 -24
- package/lib/app/templates/configuration.tpl.js +0 -39
- package/lib/app/templates/configuration.tpl.js.map +0 -1
- package/lib/app/templates/configuration.tpl.ts +0 -44
- package/lib/authentication/templates/user.resolver.tpl.js +0 -98
- package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
- package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
- package/lib/authentication/templates/user.schema.tpl.js +0 -79
- package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
- package/lib/authentication/templates/user.schema.tpl.ts +0 -87
- package/lib/service/templates/class.tpl.js +0 -63
- package/lib/service/templates/class.tpl.js.map +0 -1
- package/lib/service/templates/class.tpl.ts +0 -79
- package/lib/service/templates/resolver.tpl.js +0 -73
- package/lib/service/templates/resolver.tpl.js.map +0 -1
- package/lib/service/templates/resolver.tpl.ts +0 -78
- package/lib/service/templates/schema.tpl.d.ts +0 -2
- package/lib/service/templates/schema.tpl.js +0 -75
- package/lib/service/templates/schema.tpl.js.map +0 -1
- package/lib/service/templates/schema.tpl.ts +0 -80
|
@@ -2,8 +2,10 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { HookGeneratorContext } from '../index'
|
|
3
3
|
import { renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const aroundTemplate = ({
|
|
6
|
-
|
|
5
|
+
const aroundTemplate = ({
|
|
6
|
+
camelName,
|
|
7
|
+
name
|
|
8
|
+
}: HookGeneratorContext) => /* ts */ `import type { HookContext, NextFunction } from '../declarations'
|
|
7
9
|
|
|
8
10
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
9
11
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -14,7 +16,7 @@ export const ${camelName} = async (context: HookContext, next: NextFunction) =>
|
|
|
14
16
|
const regularTemplate = ({
|
|
15
17
|
camelName,
|
|
16
18
|
name
|
|
17
|
-
}: HookGeneratorContext) => `import type { HookContext } from '../declarations'
|
|
19
|
+
}: HookGeneratorContext) => /* ts */ `import type { HookContext } from '../declarations'
|
|
18
20
|
|
|
19
21
|
export const ${camelName} = async (context: HookContext) => {
|
|
20
22
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
package/lib/index.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { FeathersBaseContext } from './commons';
|
|
4
|
-
export declare const commandRunner: (yarg: any) => Promise<FeathersBaseContext & {
|
|
5
|
-
lib: string;
|
|
6
|
-
test: string;
|
|
7
|
-
language: "js" | "ts";
|
|
8
|
-
feathers: import("./commons").FeathersAppInfo;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const generate: (ctx: FeathersBaseContext) => Promise<FeathersBaseContext & {
|
|
11
|
-
lib: string;
|
|
12
|
-
test: string;
|
|
13
|
-
language: "js" | "ts";
|
|
14
|
-
feathers: import("./commons").FeathersAppInfo;
|
|
15
|
-
}>;
|
|
16
|
-
export declare const command: (yargs: Argv) => Argv<{}>;
|
|
1
|
+
export * from './cli';
|
|
2
|
+
export * from './commons';
|
package/lib/index.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
|
-
exports
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.then((0, pinion_1.runGenerator)(__dirname, (ctx) => `${ctx._[1]}`, 'index'));
|
|
16
|
-
exports.generate = generate;
|
|
17
|
-
const command = (yargs) => yargs
|
|
18
|
-
.command('generate', 'Run a generator', (yarg) => yarg
|
|
19
|
-
.command('app', 'Generate a new app', exports.commandRunner)
|
|
20
|
-
.command('service', 'Generate a service', exports.commandRunner)
|
|
21
|
-
.command('hook', 'Generate a hook', exports.commandRunner)
|
|
22
|
-
.command('connection', 'Connect to a different database', exports.commandRunner)
|
|
23
|
-
.command('authentication', 'Set up authentication with a custom entity', exports.commandRunner))
|
|
24
|
-
.usage('Usage: $0 <command> [options]')
|
|
25
|
-
.help();
|
|
26
|
-
exports.command = command;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cli"), exports);
|
|
18
|
+
__exportStar(require("./commons"), exports);
|
|
27
19
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,4CAAyB"}
|
package/lib/index.ts
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const commandRunner = (yarg: any) => {
|
|
5
|
-
const ctx = getContext<FeathersBaseContext>({
|
|
6
|
-
...yarg.argv
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
return generate(ctx)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const generate = (ctx: FeathersBaseContext) =>
|
|
13
|
-
generator(ctx)
|
|
14
|
-
.then(initializeBaseContext())
|
|
15
|
-
.then(runGenerator(__dirname, (ctx: FeathersBaseContext) => `${ctx._[1]}`, 'index'))
|
|
16
|
-
|
|
17
|
-
export const command = (yargs: Argv) =>
|
|
18
|
-
yargs
|
|
19
|
-
.command('generate', 'Run a generator', (yarg) =>
|
|
20
|
-
yarg
|
|
21
|
-
.command('app', 'Generate a new app', commandRunner)
|
|
22
|
-
.command('service', 'Generate a service', commandRunner)
|
|
23
|
-
.command('hook', 'Generate a hook', commandRunner)
|
|
24
|
-
.command('connection', 'Connect to a different database', commandRunner)
|
|
25
|
-
.command('authentication', 'Set up authentication with a custom entity', commandRunner)
|
|
26
|
-
)
|
|
27
|
-
.usage('Usage: $0 <command> [options]')
|
|
28
|
-
.help()
|
|
1
|
+
export * from './cli'
|
|
2
|
+
export * from './commons'
|
package/lib/service/index.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
40
40
|
* The chosen service type
|
|
41
41
|
*/
|
|
42
42
|
type: 'knex' | 'mongodb' | 'custom';
|
|
43
|
+
/**
|
|
44
|
+
* Which schema definition format to use
|
|
45
|
+
*/
|
|
46
|
+
schema: 'typebox' | 'json' | false;
|
|
43
47
|
/**
|
|
44
48
|
* Wether this service uses authentication
|
|
45
49
|
*/
|
|
@@ -52,7 +56,7 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
52
56
|
/**
|
|
53
57
|
* Parameters the generator is called with
|
|
54
58
|
*/
|
|
55
|
-
export declare type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService'>>;
|
|
59
|
+
export declare type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>>;
|
|
56
60
|
export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
57
61
|
/**
|
|
58
62
|
* The chosen service name
|
|
@@ -94,6 +98,10 @@ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
|
94
98
|
* The chosen service type
|
|
95
99
|
*/
|
|
96
100
|
type: 'knex' | 'mongodb' | 'custom';
|
|
101
|
+
/**
|
|
102
|
+
* Which schema definition format to use
|
|
103
|
+
*/
|
|
104
|
+
schema: 'typebox' | 'json' | false;
|
|
97
105
|
/**
|
|
98
106
|
* Wether this service uses authentication
|
|
99
107
|
*/
|
|
@@ -106,7 +114,7 @@ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
|
106
114
|
pkg: import("../commons").AppPackageJson;
|
|
107
115
|
lib: string;
|
|
108
116
|
test: string;
|
|
109
|
-
language: "
|
|
117
|
+
language: "ts" | "js";
|
|
110
118
|
dependencyVersions?: import("../commons").DependencyVersions;
|
|
111
119
|
cwd: string;
|
|
112
120
|
_?: (string | number)[];
|
package/lib/service/index.js
CHANGED
|
@@ -8,48 +8,86 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const pinion_1 = require("@feathershq/pinion");
|
|
9
9
|
const commons_1 = require("../commons");
|
|
10
10
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
11
|
-
.then((0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name: 'authentication',
|
|
27
|
-
type: 'confirm',
|
|
28
|
-
when: authentication === undefined && !isEntityService,
|
|
29
|
-
message: 'Does this service require authentication?'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'type',
|
|
33
|
-
type: 'list',
|
|
34
|
-
when: !type,
|
|
35
|
-
message: 'What kind of service is it?',
|
|
36
|
-
default: (0, commons_1.getDatabaseAdapter)(ctx.feathers.database),
|
|
37
|
-
choices: [
|
|
38
|
-
{
|
|
39
|
-
value: 'knex',
|
|
40
|
-
name: 'SQL'
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
value: 'mongodb',
|
|
44
|
-
name: 'MongoDB'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
value: 'custom',
|
|
48
|
-
name: 'A custom service'
|
|
11
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
12
|
+
.then((0, commons_1.checkPreconditions)())
|
|
13
|
+
.then((0, pinion_1.prompt)(({ name, path, type, schema, authentication, isEntityService }) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'name',
|
|
18
|
+
type: 'input',
|
|
19
|
+
when: !name,
|
|
20
|
+
message: 'What is the name of your service?',
|
|
21
|
+
validate: (input) => {
|
|
22
|
+
if (!input || input === 'authentication') {
|
|
23
|
+
return 'Invalid service name';
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
49
26
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'path',
|
|
30
|
+
type: 'input',
|
|
31
|
+
when: !path,
|
|
32
|
+
message: 'Which path should the service be registered on?',
|
|
33
|
+
default: (answers) => `${lodash_1.default.kebabCase(answers.name)}`,
|
|
34
|
+
validate: (input) => {
|
|
35
|
+
if (!input || input === 'authentication') {
|
|
36
|
+
return 'Invalid service path';
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'authentication',
|
|
43
|
+
type: 'confirm',
|
|
44
|
+
when: authentication === undefined && !isEntityService,
|
|
45
|
+
message: 'Does this service require authentication?'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'type',
|
|
49
|
+
type: 'list',
|
|
50
|
+
when: !type,
|
|
51
|
+
message: 'What kind of service is it?',
|
|
52
|
+
default: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database),
|
|
53
|
+
choices: [
|
|
54
|
+
{
|
|
55
|
+
value: 'knex',
|
|
56
|
+
name: 'SQL'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: 'mongodb',
|
|
60
|
+
name: 'MongoDB'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: 'custom',
|
|
64
|
+
name: 'A custom service'
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'schema',
|
|
70
|
+
type: 'list',
|
|
71
|
+
when: schema === undefined,
|
|
72
|
+
message: 'Which schema definition format do you want to use?',
|
|
73
|
+
default: ((_b = ctx.feathers) === null || _b === void 0 ? void 0 : _b.schema) || 'json',
|
|
74
|
+
choices: [
|
|
75
|
+
{
|
|
76
|
+
value: 'typebox',
|
|
77
|
+
name: 'TypeBox'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: 'json',
|
|
81
|
+
name: 'JSON schema'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: false,
|
|
85
|
+
name: 'No schema'
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
}))
|
|
53
91
|
.then(async (ctx) => {
|
|
54
92
|
const { name, path, type } = ctx;
|
|
55
93
|
const kebabName = lodash_1.default.kebabCase(name);
|
package/lib/service/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAKmB;AAiEZ,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAE,EAAE,CACzD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAAI,CAAC,IAAA,4BAAkB,GAAE,CAAC;KAC1B,IAAI,CACH,IAAA,eAAM,EACJ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;;IAAC,OAAA;QACjE;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,CAAC,IAAI;YACX,OAAO,EAAE,mCAAmC;YAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAClB,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,gBAAgB,EAAE;oBACxC,OAAO,sBAAsB,CAAA;iBAC9B;gBAED,OAAO,IAAI,CAAA;YACb,C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,MAAM,CAAC,CAAC,CAAA;AA/GnF,QAAA,QAAQ,YA+G2E"}
|
package/lib/service/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
2
|
import { generator, runGenerator, runGenerators, prompt } from '@feathershq/pinion'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
checkPreconditions,
|
|
6
|
+
FeathersBaseContext,
|
|
7
|
+
getDatabaseAdapter,
|
|
8
|
+
initializeBaseContext
|
|
9
|
+
} from '../commons'
|
|
5
10
|
|
|
6
11
|
export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
7
12
|
/**
|
|
@@ -44,6 +49,10 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
44
49
|
* The chosen service type
|
|
45
50
|
*/
|
|
46
51
|
type: 'knex' | 'mongodb' | 'custom'
|
|
52
|
+
/**
|
|
53
|
+
* Which schema definition format to use
|
|
54
|
+
*/
|
|
55
|
+
schema: 'typebox' | 'json' | false
|
|
47
56
|
/**
|
|
48
57
|
* Wether this service uses authentication
|
|
49
58
|
*/
|
|
@@ -58,25 +67,43 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
58
67
|
* Parameters the generator is called with
|
|
59
68
|
*/
|
|
60
69
|
export type ServiceGeneratorArguments = FeathersBaseContext &
|
|
61
|
-
Partial<
|
|
70
|
+
Partial<
|
|
71
|
+
Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>
|
|
72
|
+
>
|
|
62
73
|
|
|
63
74
|
export const generate = (ctx: ServiceGeneratorArguments) =>
|
|
64
75
|
generator(ctx)
|
|
76
|
+
.then(initializeBaseContext())
|
|
77
|
+
.then(checkPreconditions())
|
|
65
78
|
.then(
|
|
66
79
|
prompt<ServiceGeneratorArguments, ServiceGeneratorContext>(
|
|
67
|
-
({ name, path, type, authentication, isEntityService }) => [
|
|
80
|
+
({ name, path, type, schema, authentication, isEntityService }) => [
|
|
68
81
|
{
|
|
69
82
|
name: 'name',
|
|
70
83
|
type: 'input',
|
|
71
84
|
when: !name,
|
|
72
|
-
message: 'What is the name of your service?'
|
|
85
|
+
message: 'What is the name of your service?',
|
|
86
|
+
validate: (input) => {
|
|
87
|
+
if (!input || input === 'authentication') {
|
|
88
|
+
return 'Invalid service name'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
73
93
|
},
|
|
74
94
|
{
|
|
75
95
|
name: 'path',
|
|
76
96
|
type: 'input',
|
|
77
97
|
when: !path,
|
|
78
98
|
message: 'Which path should the service be registered on?',
|
|
79
|
-
default: (answers: ServiceGeneratorArguments) => `${_.kebabCase(answers.name)}
|
|
99
|
+
default: (answers: ServiceGeneratorArguments) => `${_.kebabCase(answers.name)}`,
|
|
100
|
+
validate: (input) => {
|
|
101
|
+
if (!input || input === 'authentication') {
|
|
102
|
+
return 'Invalid service path'
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return true
|
|
106
|
+
}
|
|
80
107
|
},
|
|
81
108
|
{
|
|
82
109
|
name: 'authentication',
|
|
@@ -89,7 +116,7 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
|
|
|
89
116
|
type: 'list',
|
|
90
117
|
when: !type,
|
|
91
118
|
message: 'What kind of service is it?',
|
|
92
|
-
default: getDatabaseAdapter(ctx.feathers
|
|
119
|
+
default: getDatabaseAdapter(ctx.feathers?.database),
|
|
93
120
|
choices: [
|
|
94
121
|
{
|
|
95
122
|
value: 'knex',
|
|
@@ -104,6 +131,27 @@ export const generate = (ctx: ServiceGeneratorArguments) =>
|
|
|
104
131
|
name: 'A custom service'
|
|
105
132
|
}
|
|
106
133
|
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'schema',
|
|
137
|
+
type: 'list',
|
|
138
|
+
when: schema === undefined,
|
|
139
|
+
message: 'Which schema definition format do you want to use?',
|
|
140
|
+
default: ctx.feathers?.schema || 'json',
|
|
141
|
+
choices: [
|
|
142
|
+
{
|
|
143
|
+
value: 'typebox',
|
|
144
|
+
name: 'TypeBox'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
value: 'json',
|
|
148
|
+
name: 'JSON schema'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
value: false,
|
|
152
|
+
name: 'No schema'
|
|
153
|
+
}
|
|
154
|
+
]
|
|
107
155
|
}
|
|
108
156
|
]
|
|
109
157
|
)
|
|
@@ -2,15 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const
|
|
5
|
+
const commons_1 = require("../../commons");
|
|
6
|
+
const schemaImports = ({ upperName, folder, fileName }) => /* ts */ `import type {
|
|
7
|
+
${upperName},
|
|
6
8
|
${upperName}Data,
|
|
7
|
-
${upperName}Result,
|
|
8
9
|
${upperName}Query,
|
|
9
|
-
} from './services/${folder.join('/')}/${fileName}
|
|
10
|
+
} from './services/${folder.join('/')}/${fileName}'
|
|
10
11
|
|
|
11
|
-
export
|
|
12
|
-
|
|
12
|
+
export type {
|
|
13
|
+
${upperName},
|
|
14
|
+
${upperName}Data,
|
|
15
|
+
${upperName}Query,
|
|
16
|
+
}`;
|
|
17
|
+
const declarationTemplate = ({ path, upperName }) => ` '${path}': ClientService<
|
|
18
|
+
${upperName},
|
|
19
|
+
${upperName}Data,
|
|
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
|
+
})
|
|
30
|
+
`;
|
|
13
31
|
const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client.ts']);
|
|
14
|
-
const generate = async (ctx) => (0, pinion_1.generator)(ctx)
|
|
32
|
+
const generate = async (ctx) => (0, pinion_1.generator)(ctx)
|
|
33
|
+
.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 === 'ts', (0, pinion_1.inject)(schemaImports, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile), (0, pinion_1.inject)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
|
|
15
35
|
exports.generate = generate;
|
|
16
36
|
//# 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,+CAAmF;AACnF,2CAA4C;AAG5C,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC,QAAQ,CAAC;IACzF,SAAS;IACT,SAAS;IACT,SAAS;qBACQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ;;;IAG7C,SAAS;IACT,SAAS;IACT,SAAS;EACX,CAAA;AAEF,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAA2B,EAAE,EAAE,CAC3E,MAAM,IAAI;MACN,SAAS;MACT,SAAS;cACD,SAAS;gBACP,SAAS;aACZ,SAAS;;;IAGlB,CAAA;AAEJ,MAAM,oBAAoB,GAAG,CAAC,EAC5B,IAAI,EACoB,EAAE,EAAE,CAAC,iBAAiB,IAAI,0BAA0B,IAAI;;;;CAIjF,CAAA;AAED,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAA;AAE9E,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,eAAM,EAAC,aAAa,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,EACzE,IAAA,eAAM,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CAClF,CACF,CAAA;AAfQ,QAAA,QAAQ,YAehB"}
|
|
@@ -1,24 +1,53 @@
|
|
|
1
|
-
import { generator, inject, toFile, when, after } from '@feathershq/pinion'
|
|
1
|
+
import { generator, inject, toFile, when, after, before } from '@feathershq/pinion'
|
|
2
|
+
import { injectSource } from '../../commons'
|
|
2
3
|
import { ServiceGeneratorContext } from '../index'
|
|
3
4
|
|
|
4
|
-
const schemaImports = ({ upperName, folder, fileName }: ServiceGeneratorContext) => `import type {
|
|
5
|
+
const schemaImports = ({ upperName, folder, fileName }: ServiceGeneratorContext) => /* ts */ `import type {
|
|
6
|
+
${upperName},
|
|
5
7
|
${upperName}Data,
|
|
6
|
-
${upperName}Result,
|
|
7
8
|
${upperName}Query,
|
|
8
|
-
} from './services/${folder.join('/')}/${fileName}
|
|
9
|
+
} from './services/${folder.join('/')}/${fileName}'
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
+
export type {
|
|
12
|
+
${upperName},
|
|
13
|
+
${upperName}Data,
|
|
14
|
+
${upperName}Query,
|
|
15
|
+
}`
|
|
11
16
|
|
|
12
17
|
const declarationTemplate = ({ path, upperName }: ServiceGeneratorContext) =>
|
|
13
|
-
` '${path}':
|
|
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
|
+
}`
|
|
27
|
+
|
|
28
|
+
const registrationTemplate = ({
|
|
29
|
+
path
|
|
30
|
+
}: ServiceGeneratorContext) => ` client.use('${path}', connection.service('${path}'), {
|
|
31
|
+
// List all standard and custom methods
|
|
32
|
+
methods: ['find', 'get', 'create', 'update', 'patch', 'remove']
|
|
33
|
+
})
|
|
34
|
+
`
|
|
14
35
|
|
|
15
36
|
const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client.ts'])
|
|
16
37
|
|
|
17
38
|
export const generate = async (ctx: ServiceGeneratorContext) =>
|
|
18
|
-
generator(ctx)
|
|
19
|
-
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
generator(ctx)
|
|
40
|
+
.then(
|
|
41
|
+
injectSource(
|
|
42
|
+
registrationTemplate,
|
|
43
|
+
before('return client'),
|
|
44
|
+
toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client'])
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
.then(
|
|
48
|
+
when(
|
|
49
|
+
(ctx) => ctx.language === 'ts',
|
|
50
|
+
inject(schemaImports, after("from '@feathersjs/feathers'"), toClientFile),
|
|
51
|
+
inject(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
|
|
52
|
+
)
|
|
23
53
|
)
|
|
24
|
-
)
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const commons_1 = require("../../commons");
|
|
6
|
+
const template = ({ camelName, upperName, relative, type }) => /* ts */ `import { jsonSchema, resolve } from '@feathersjs/schema'
|
|
7
|
+
import type { FromSchema } from '@feathersjs/schema'
|
|
8
|
+
|
|
9
|
+
import type { HookContext } from '${relative}/declarations'
|
|
10
|
+
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
11
|
+
|
|
12
|
+
// Schema for the basic data model (e.g. creating new entries)
|
|
13
|
+
export const ${camelName}DataSchema = {
|
|
14
|
+
$id: '${upperName}Data',
|
|
15
|
+
type: 'object',
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
required: [ 'text' ],
|
|
18
|
+
properties: {
|
|
19
|
+
text: {
|
|
20
|
+
type: 'string'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} as const
|
|
24
|
+
export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
|
|
25
|
+
export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
|
|
26
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
27
|
+
properties: {}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Schema for the data that is being returned
|
|
31
|
+
export const ${camelName}Schema = {
|
|
32
|
+
$id: '${upperName}',
|
|
33
|
+
type: 'object',
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
required: [ ...${camelName}DataSchema.required, '${type === 'mongodb' ? '_id' : 'id'}' ],
|
|
36
|
+
properties: {
|
|
37
|
+
...${camelName}DataSchema.properties,
|
|
38
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
39
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} as const
|
|
43
|
+
export type ${upperName} = FromSchema<typeof ${camelName}Schema>
|
|
44
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
45
|
+
properties: {}
|
|
46
|
+
})
|
|
47
|
+
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
48
|
+
properties: {}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
// Schema for allowed query properties
|
|
52
|
+
export const ${camelName}QuerySchema = {
|
|
53
|
+
$id: '${upperName}Query',
|
|
54
|
+
type: 'object',
|
|
55
|
+
additionalProperties: false,
|
|
56
|
+
properties: {
|
|
57
|
+
...jsonSchema.querySyntax(${camelName}Schema.properties)
|
|
58
|
+
}
|
|
59
|
+
} as const
|
|
60
|
+
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
61
|
+
export const ${camelName}QueryValidator = jsonSchema.getValidator(${camelName}QuerySchema, queryValidator)
|
|
62
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
63
|
+
properties: {}
|
|
64
|
+
})
|
|
65
|
+
`;
|
|
66
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'json', (0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
|
|
67
|
+
lib,
|
|
68
|
+
'services',
|
|
69
|
+
...folder,
|
|
70
|
+
`${fileName}.schema`
|
|
71
|
+
]))));
|
|
72
|
+
exports.generate = generate;
|
|
73
|
+
//# sourceMappingURL=schema.json.tpl.js.map
|
|
@@ -0,0 +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,QA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