@feathersjs/cli 4.6.2 → 5.0.0-pre.24
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 -917
- package/LICENSE +1 -1
- package/README.md +9 -34
- package/bin/feathers +9 -0
- package/lib/app/index.d.ts +29 -0
- package/lib/app/index.js +123 -0
- package/lib/app/index.js.map +1 -0
- package/lib/app/index.ts +198 -0
- package/lib/app/static/.gitignore +121 -0
- package/lib/app/templates/app.test.tpl.d.ts +2 -0
- package/lib/app/templates/app.test.tpl.js +48 -0
- package/lib/app/templates/app.test.tpl.js.map +1 -0
- package/lib/app/templates/app.test.tpl.ts +48 -0
- package/lib/app/templates/app.tpl.d.ts +2 -0
- package/lib/app/templates/app.tpl.js +110 -0
- package/lib/app/templates/app.tpl.js.map +1 -0
- package/lib/app/templates/app.tpl.ts +119 -0
- package/lib/app/templates/channels.tpl.d.ts +2 -0
- package/lib/app/templates/channels.tpl.js +76 -0
- package/lib/app/templates/channels.tpl.js.map +1 -0
- package/lib/app/templates/channels.tpl.ts +81 -0
- package/lib/app/templates/client.tpl.d.ts +2 -0
- package/lib/app/templates/client.tpl.js +22 -0
- package/lib/app/templates/client.tpl.js.map +1 -0
- package/lib/app/templates/client.tpl.ts +27 -0
- package/lib/app/templates/config.tpl.d.ts +2 -0
- package/lib/app/templates/config.tpl.js +21 -0
- package/lib/app/templates/config.tpl.js.map +1 -0
- package/lib/app/templates/config.tpl.ts +21 -0
- package/lib/app/templates/configuration.tpl.d.ts +2 -0
- package/lib/app/templates/configuration.tpl.js +36 -0
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/configuration.tpl.ts +41 -0
- package/lib/app/templates/declarations.tpl.d.ts +2 -0
- package/lib/app/templates/declarations.tpl.js +23 -0
- package/lib/app/templates/declarations.tpl.js.map +1 -0
- package/lib/app/templates/declarations.tpl.ts +31 -0
- package/lib/app/templates/index.html.tpl.d.ts +2 -0
- package/lib/app/templates/index.html.tpl.js +85 -0
- package/lib/app/templates/index.html.tpl.js.map +1 -0
- package/lib/app/templates/index.html.tpl.ts +85 -0
- package/lib/app/templates/index.tpl.d.ts +2 -0
- package/lib/app/templates/index.tpl.js +18 -0
- package/lib/app/templates/index.tpl.js.map +1 -0
- package/lib/app/templates/index.tpl.ts +23 -0
- package/lib/app/templates/logger.tpl.d.ts +2 -0
- package/lib/app/templates/logger.tpl.js +33 -0
- package/lib/app/templates/logger.tpl.js.map +1 -0
- package/lib/app/templates/logger.tpl.ts +38 -0
- package/lib/app/templates/package.json.tpl.d.ts +2 -0
- package/lib/app/templates/package.json.tpl.js +53 -0
- package/lib/app/templates/package.json.tpl.js.map +1 -0
- package/lib/app/templates/package.json.tpl.ts +65 -0
- package/lib/app/templates/readme.md.tpl.d.ts +2 -0
- package/lib/app/templates/readme.md.tpl.js +50 -0
- package/lib/app/templates/readme.md.tpl.js.map +1 -0
- package/lib/app/templates/readme.md.tpl.ts +50 -0
- package/lib/app/templates/services.tpl.d.ts +2 -0
- package/lib/app/templates/services.tpl.js +14 -0
- package/lib/app/templates/services.tpl.js.map +1 -0
- package/lib/app/templates/services.tpl.ts +19 -0
- package/lib/app/templates/tsconfig.json.tpl.d.ts +2 -0
- package/lib/app/templates/tsconfig.json.tpl.js +20 -0
- package/lib/app/templates/tsconfig.json.tpl.js.map +1 -0
- package/lib/app/templates/tsconfig.json.tpl.ts +26 -0
- package/lib/authentication/index.d.ts +71 -0
- package/lib/authentication/index.js +94 -0
- package/lib/authentication/index.js.map +1 -0
- package/lib/authentication/index.ts +103 -0
- package/lib/authentication/templates/authentication.tpl.d.ts +2 -0
- package/lib/authentication/templates/authentication.tpl.js +40 -0
- package/lib/authentication/templates/authentication.tpl.js.map +1 -0
- package/lib/authentication/templates/authentication.tpl.ts +53 -0
- package/lib/authentication/templates/config.tpl.d.ts +2 -0
- package/lib/authentication/templates/config.tpl.js +46 -0
- package/lib/authentication/templates/config.tpl.js.map +1 -0
- package/lib/authentication/templates/config.tpl.ts +51 -0
- package/lib/authentication/templates/declarations.tpl.d.ts +2 -0
- package/lib/authentication/templates/declarations.tpl.js +19 -0
- package/lib/authentication/templates/declarations.tpl.js.map +1 -0
- package/lib/authentication/templates/declarations.tpl.ts +29 -0
- package/lib/authentication/templates/knex.tpl.d.ts +2 -0
- package/lib/authentication/templates/knex.tpl.js +41 -0
- package/lib/authentication/templates/knex.tpl.js.map +1 -0
- package/lib/authentication/templates/knex.tpl.ts +59 -0
- package/lib/authentication/templates/test.tpl.d.ts +2 -0
- package/lib/authentication/templates/test.tpl.js +43 -0
- package/lib/authentication/templates/test.tpl.js.map +1 -0
- package/lib/authentication/templates/test.tpl.ts +50 -0
- package/lib/authentication/templates/user.resolver.tpl.d.ts +2 -0
- package/lib/authentication/templates/user.resolver.tpl.js +96 -0
- package/lib/authentication/templates/user.resolver.tpl.js.map +1 -0
- package/lib/authentication/templates/user.resolver.tpl.ts +109 -0
- package/lib/authentication/templates/user.schema.tpl.d.ts +2 -0
- package/lib/authentication/templates/user.schema.tpl.js +85 -0
- package/lib/authentication/templates/user.schema.tpl.js.map +1 -0
- package/lib/authentication/templates/user.schema.tpl.ts +93 -0
- package/lib/commons.d.ts +120 -0
- package/lib/commons.js +137 -0
- package/lib/commons.js.map +1 -0
- package/lib/commons.ts +187 -0
- package/lib/connection/index.d.ts +53 -0
- package/lib/connection/index.js +86 -0
- package/lib/connection/index.js.map +1 -0
- package/lib/connection/index.ts +109 -0
- package/lib/connection/templates/knex.tpl.d.ts +2 -0
- package/lib/connection/templates/knex.tpl.js +59 -0
- package/lib/connection/templates/knex.tpl.js.map +1 -0
- package/lib/connection/templates/knex.tpl.ts +79 -0
- package/lib/connection/templates/mongodb.tpl.d.ts +2 -0
- package/lib/connection/templates/mongodb.tpl.js +39 -0
- package/lib/connection/templates/mongodb.tpl.js.map +1 -0
- package/lib/connection/templates/mongodb.tpl.ts +51 -0
- package/lib/hook/index.d.ts +22 -0
- package/lib/hook/index.js +40 -0
- package/lib/hook/index.js.map +1 -0
- package/lib/hook/index.ts +45 -0
- package/lib/hook/templates/hook.tpl.d.ts +2 -0
- package/lib/hook/templates/hook.tpl.js +21 -0
- package/lib/hook/templates/hook.tpl.js.map +1 -0
- package/lib/hook/templates/hook.tpl.ts +28 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +24 -62
- package/lib/index.js.map +1 -0
- package/lib/index.ts +27 -0
- package/lib/service/index.d.ts +130 -0
- package/lib/service/index.js +84 -0
- package/lib/service/index.js.map +1 -0
- package/lib/service/index.ts +150 -0
- package/lib/service/templates/client.tpl.d.ts +2 -0
- package/lib/service/templates/client.tpl.js +16 -0
- package/lib/service/templates/client.tpl.js.map +1 -0
- package/lib/service/templates/client.tpl.ts +27 -0
- package/lib/service/templates/resolver.tpl.d.ts +2 -0
- package/lib/service/templates/resolver.tpl.js +73 -0
- package/lib/service/templates/resolver.tpl.js.map +1 -0
- package/lib/service/templates/resolver.tpl.ts +78 -0
- package/lib/service/templates/schema.tpl.d.ts +2 -0
- package/lib/service/templates/schema.tpl.js +75 -0
- package/lib/service/templates/schema.tpl.js.map +1 -0
- package/lib/service/templates/schema.tpl.ts +80 -0
- package/lib/service/templates/service.tpl.d.ts +2 -0
- package/lib/service/templates/service.tpl.js +92 -0
- package/lib/service/templates/service.tpl.js.map +1 -0
- package/lib/service/templates/service.tpl.ts +117 -0
- package/lib/service/templates/test.tpl.d.ts +2 -0
- package/lib/service/templates/test.tpl.js +24 -0
- package/lib/service/templates/test.tpl.js.map +1 -0
- package/lib/service/templates/test.tpl.ts +29 -0
- package/lib/service/type/custom.tpl.d.ts +4 -0
- package/lib/service/type/custom.tpl.js +79 -0
- package/lib/service/type/custom.tpl.js.map +1 -0
- package/lib/service/type/custom.tpl.ts +81 -0
- package/lib/service/type/knex.tpl.d.ts +5 -0
- package/lib/service/type/knex.tpl.js +50 -0
- package/lib/service/type/knex.tpl.js.map +1 -0
- package/lib/service/type/knex.tpl.ts +62 -0
- package/lib/service/type/mongodb.tpl.d.ts +4 -0
- package/lib/service/type/mongodb.tpl.js +29 -0
- package/lib/service/type/mongodb.tpl.js.map +1 -0
- package/lib/service/type/mongodb.tpl.ts +34 -0
- package/package.json +56 -36
- package/bin/feathers.js +0 -5
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { generator, when, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { getDatabaseAdapter, renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const migrationTemplate = ({
|
|
6
|
+
kebabName,
|
|
7
|
+
authStrategies
|
|
8
|
+
}: AuthenticationGeneratorContext) => `import type { Knex } from 'knex'
|
|
9
|
+
|
|
10
|
+
export async function up(knex: Knex): Promise<void> {
|
|
11
|
+
await knex.schema.alterTable('${kebabName}', function (table) {
|
|
12
|
+
table.dropColumn('text')${authStrategies
|
|
13
|
+
.map((name) =>
|
|
14
|
+
name === 'local'
|
|
15
|
+
? `
|
|
16
|
+
table.string('email').unique()
|
|
17
|
+
table.string('password')`
|
|
18
|
+
: `
|
|
19
|
+
table.string('${name}Id')`
|
|
20
|
+
)
|
|
21
|
+
.join('\n')}
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function down(knex: Knex): Promise<void> {
|
|
26
|
+
await knex.schema.alterTable('${kebabName}', function (table) {
|
|
27
|
+
table.string('text')${authStrategies
|
|
28
|
+
.map((name) =>
|
|
29
|
+
name === 'local'
|
|
30
|
+
? `
|
|
31
|
+
table.dropColumn('email')
|
|
32
|
+
table.dropColumn('password')`
|
|
33
|
+
: `
|
|
34
|
+
table.dropColumn('${name}Id')`
|
|
35
|
+
)
|
|
36
|
+
.join(',\n')}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
42
|
+
generator(ctx).then(
|
|
43
|
+
when(
|
|
44
|
+
(ctx) => getDatabaseAdapter(ctx.feathers.database) === 'knex',
|
|
45
|
+
renderSource(
|
|
46
|
+
migrationTemplate,
|
|
47
|
+
toFile(
|
|
48
|
+
toFile<AuthenticationGeneratorContext>('migrations', () => {
|
|
49
|
+
const now = new Date()
|
|
50
|
+
const migrationDate =
|
|
51
|
+
`${now.getUTCFullYear()}${now.getUTCMonth()}${now.getUTCDay()}` +
|
|
52
|
+
`${now.getUTCHours()}${now.getUTCMinutes()}${now.getUTCSeconds() + 1}`
|
|
53
|
+
|
|
54
|
+
return `${migrationDate}_authentication`
|
|
55
|
+
})
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
)
|
|
@@ -0,0 +1,43 @@
|
|
|
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 = ({ authStrategies, relative, lib }) => `import assert from 'assert';
|
|
7
|
+
import { app } from '${relative}/${lib}/app';
|
|
8
|
+
|
|
9
|
+
describe('authentication', () => {
|
|
10
|
+
${authStrategies.includes('local')
|
|
11
|
+
? `
|
|
12
|
+
const userInfo = {
|
|
13
|
+
email: 'someone@example.com',
|
|
14
|
+
password: 'supersecret'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
before(async () => {
|
|
18
|
+
try {
|
|
19
|
+
await app.service('users').create(userInfo)
|
|
20
|
+
} catch (error) {
|
|
21
|
+
// Do nothing, it just means the user already exists and can be tested
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('authenticates user and creates accessToken', async () => {
|
|
26
|
+
const { user, accessToken } = await app.service('authentication').create({
|
|
27
|
+
strategy: 'local',
|
|
28
|
+
...userInfo
|
|
29
|
+
}, {})
|
|
30
|
+
|
|
31
|
+
assert.ok(accessToken, 'Created access token for user')
|
|
32
|
+
assert.ok(user, 'Includes user in authentication data')
|
|
33
|
+
})`
|
|
34
|
+
: ''}
|
|
35
|
+
|
|
36
|
+
it('registered the authentication service', () => {
|
|
37
|
+
assert.ok(app.service('authentication'))
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
`;
|
|
41
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test }) => test, 'authentication.test')));
|
|
42
|
+
exports.generate = generate;
|
|
43
|
+
//# sourceMappingURL=test.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAkC,EAAE,EAAE,CACrF;uBACqB,QAAQ,IAAI,GAAG;;;IAIlC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;KAsBH;IACC,CAAC,CAAC,EACN;;;;;;CAMD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAClF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({ authStrategies, relative, lib }: AuthenticationGeneratorContext) =>
|
|
6
|
+
`import assert from 'assert';
|
|
7
|
+
import { app } from '${relative}/${lib}/app';
|
|
8
|
+
|
|
9
|
+
describe('authentication', () => {
|
|
10
|
+
${
|
|
11
|
+
authStrategies.includes('local')
|
|
12
|
+
? `
|
|
13
|
+
const userInfo = {
|
|
14
|
+
email: 'someone@example.com',
|
|
15
|
+
password: 'supersecret'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
before(async () => {
|
|
19
|
+
try {
|
|
20
|
+
await app.service('users').create(userInfo)
|
|
21
|
+
} catch (error) {
|
|
22
|
+
// Do nothing, it just means the user already exists and can be tested
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('authenticates user and creates accessToken', async () => {
|
|
27
|
+
const { user, accessToken } = await app.service('authentication').create({
|
|
28
|
+
strategy: 'local',
|
|
29
|
+
...userInfo
|
|
30
|
+
}, {})
|
|
31
|
+
|
|
32
|
+
assert.ok(accessToken, 'Created access token for user')
|
|
33
|
+
assert.ok(user, 'Includes user in authentication data')
|
|
34
|
+
})`
|
|
35
|
+
: ''
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
it('registered the authentication service', () => {
|
|
39
|
+
assert.ok(app.service('authentication'))
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
`
|
|
43
|
+
|
|
44
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
45
|
+
generator(ctx).then(
|
|
46
|
+
renderSource(
|
|
47
|
+
template,
|
|
48
|
+
toFile<AuthenticationGeneratorContext>(({ test }) => test, 'authentication.test')
|
|
49
|
+
)
|
|
50
|
+
)
|
|
@@ -0,0 +1,96 @@
|
|
|
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, authStrategies, type, schemaPath }) => `import { resolve } from '@feathersjs/schema'
|
|
7
|
+
${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
|
|
8
|
+
import type { HookContext } from '${relative}/declarations'
|
|
9
|
+
import type {
|
|
10
|
+
${upperName}Data,
|
|
11
|
+
${upperName}Patch,
|
|
12
|
+
${upperName}Result,
|
|
13
|
+
${upperName}Query,
|
|
14
|
+
} from '../${schemaPath}'
|
|
15
|
+
import {
|
|
16
|
+
${camelName}DataSchema,
|
|
17
|
+
${camelName}PatchSchema,
|
|
18
|
+
${camelName}ResultSchema,
|
|
19
|
+
${camelName}QuerySchema
|
|
20
|
+
} from '../${schemaPath}'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// Resolver for the basic data model (e.g. creating new entries)
|
|
24
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
25
|
+
schema: ${camelName}DataSchema,
|
|
26
|
+
validate: 'before',
|
|
27
|
+
properties: {
|
|
28
|
+
${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// Resolver for making partial updates
|
|
34
|
+
export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
|
|
35
|
+
schema: ${camelName}PatchSchema,
|
|
36
|
+
validate: 'before',
|
|
37
|
+
properties: {}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// Resolver for the data that is being returned
|
|
42
|
+
export const ${camelName}ResultResolver = resolve<${upperName}Result, HookContext>({
|
|
43
|
+
schema: ${camelName}ResultSchema,
|
|
44
|
+
validate: false,
|
|
45
|
+
properties: {}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// Resolver for the "safe" version that external clients are allowed to see
|
|
50
|
+
export const ${camelName}DispatchResolver = resolve<${upperName}Result, HookContext>({
|
|
51
|
+
schema: ${camelName}ResultSchema,
|
|
52
|
+
validate: false,
|
|
53
|
+
properties: {
|
|
54
|
+
// The password should never be visible externally
|
|
55
|
+
password: async () => undefined
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// Resolver for allowed query properties
|
|
61
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
62
|
+
schema: ${camelName}QuerySchema,
|
|
63
|
+
validate: 'before',
|
|
64
|
+
properties: {
|
|
65
|
+
// If there is a user (e.g. with authentication), they are only allowed to see their own data
|
|
66
|
+
${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
|
|
67
|
+
if (context.params.user) {
|
|
68
|
+
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return value
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
// Export all resolvers in a format that can be used with the resolveAll hook
|
|
78
|
+
export const ${camelName}Resolvers = {
|
|
79
|
+
result: ${camelName}ResultResolver,
|
|
80
|
+
dispatch: ${camelName}DispatchResolver,
|
|
81
|
+
data: {
|
|
82
|
+
create: ${camelName}DataResolver,
|
|
83
|
+
update: ${camelName}DataResolver,
|
|
84
|
+
patch: ${camelName}PatchResolver
|
|
85
|
+
},
|
|
86
|
+
query: ${camelName}QueryResolver
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, kebabName }) => [
|
|
90
|
+
lib,
|
|
91
|
+
'resolvers',
|
|
92
|
+
...folder,
|
|
93
|
+
`${kebabName}.resolver`
|
|
94
|
+
]), { force: true }));
|
|
95
|
+
exports.generate = generate;
|
|
96
|
+
//# sourceMappingURL=user.resolver.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.resolver.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/user.resolver.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,UAAU,EACqB,EAAE,EAAE,CACnC;EACA,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iEAAiE,CAAC,CAAC,CAAC,EAAE;oCACvE,QAAQ;;IAExC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;aACA,UAAU;;IAEnB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;aACA,UAAU;;;;eAIR,SAAS,0BAA0B,SAAS;YAC/C,SAAS;;;MAGf,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,EAAE;;;;;;eAM9E,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;;;;eAON,SAAS,4BAA4B,SAAS;YACjD,SAAS;;;;;;;eAON,SAAS,8BAA8B,SAAS;YACnD,SAAS;;;;;;;;;;eAUN,SAAS,2BAA2B,SAAS;YAChD,SAAS;;;;MAIf,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;qCAEF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;;;;;eAUvD,SAAS;YACZ,SAAS;cACP,SAAS;;cAET,SAAS;cACT,SAAS;aACV,SAAS;;WAEX,SAAS;;CAEnB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAkC,EAAE,EAAE,CAAC;IACrE,GAAG;IACH,WAAW;IACX,GAAG,MAAM;IACT,GAAG,SAAS,WAAW;CACxB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAA;AAZU,QAAA,QAAQ,YAYlB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({
|
|
6
|
+
camelName,
|
|
7
|
+
upperName,
|
|
8
|
+
relative,
|
|
9
|
+
authStrategies,
|
|
10
|
+
type,
|
|
11
|
+
schemaPath
|
|
12
|
+
}: AuthenticationGeneratorContext) =>
|
|
13
|
+
`import { resolve } from '@feathersjs/schema'
|
|
14
|
+
${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
|
|
15
|
+
import type { HookContext } from '${relative}/declarations'
|
|
16
|
+
import type {
|
|
17
|
+
${upperName}Data,
|
|
18
|
+
${upperName}Patch,
|
|
19
|
+
${upperName}Result,
|
|
20
|
+
${upperName}Query,
|
|
21
|
+
} from '../${schemaPath}'
|
|
22
|
+
import {
|
|
23
|
+
${camelName}DataSchema,
|
|
24
|
+
${camelName}PatchSchema,
|
|
25
|
+
${camelName}ResultSchema,
|
|
26
|
+
${camelName}QuerySchema
|
|
27
|
+
} from '../${schemaPath}'
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Resolver for the basic data model (e.g. creating new entries)
|
|
31
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
32
|
+
schema: ${camelName}DataSchema,
|
|
33
|
+
validate: 'before',
|
|
34
|
+
properties: {
|
|
35
|
+
${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// Resolver for making partial updates
|
|
41
|
+
export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext>({
|
|
42
|
+
schema: ${camelName}PatchSchema,
|
|
43
|
+
validate: 'before',
|
|
44
|
+
properties: {}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// Resolver for the data that is being returned
|
|
49
|
+
export const ${camelName}ResultResolver = resolve<${upperName}Result, HookContext>({
|
|
50
|
+
schema: ${camelName}ResultSchema,
|
|
51
|
+
validate: false,
|
|
52
|
+
properties: {}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// Resolver for the "safe" version that external clients are allowed to see
|
|
57
|
+
export const ${camelName}DispatchResolver = resolve<${upperName}Result, HookContext>({
|
|
58
|
+
schema: ${camelName}ResultSchema,
|
|
59
|
+
validate: false,
|
|
60
|
+
properties: {
|
|
61
|
+
// The password should never be visible externally
|
|
62
|
+
password: async () => undefined
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// Resolver for allowed query properties
|
|
68
|
+
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
69
|
+
schema: ${camelName}QuerySchema,
|
|
70
|
+
validate: 'before',
|
|
71
|
+
properties: {
|
|
72
|
+
// If there is a user (e.g. with authentication), they are only allowed to see their own data
|
|
73
|
+
${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
|
|
74
|
+
if (context.params.user) {
|
|
75
|
+
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return value
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
// Export all resolvers in a format that can be used with the resolveAll hook
|
|
85
|
+
export const ${camelName}Resolvers = {
|
|
86
|
+
result: ${camelName}ResultResolver,
|
|
87
|
+
dispatch: ${camelName}DispatchResolver,
|
|
88
|
+
data: {
|
|
89
|
+
create: ${camelName}DataResolver,
|
|
90
|
+
update: ${camelName}DataResolver,
|
|
91
|
+
patch: ${camelName}PatchResolver
|
|
92
|
+
},
|
|
93
|
+
query: ${camelName}QueryResolver
|
|
94
|
+
}
|
|
95
|
+
`
|
|
96
|
+
|
|
97
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
98
|
+
generator(ctx).then(
|
|
99
|
+
renderSource(
|
|
100
|
+
template,
|
|
101
|
+
toFile(({ lib, folder, kebabName }: AuthenticationGeneratorContext) => [
|
|
102
|
+
lib,
|
|
103
|
+
'resolvers',
|
|
104
|
+
...folder,
|
|
105
|
+
`${kebabName}.resolver`
|
|
106
|
+
]),
|
|
107
|
+
{ force: true }
|
|
108
|
+
)
|
|
109
|
+
)
|
|
@@ -0,0 +1,85 @@
|
|
|
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, authStrategies, type }) => `import { schema, querySyntax } from '@feathersjs/schema'
|
|
7
|
+
import type { Infer } from '@feathersjs/schema'
|
|
8
|
+
|
|
9
|
+
// Schema for the basic data model (e.g. creating new entries)
|
|
10
|
+
export const ${camelName}DataSchema = schema({
|
|
11
|
+
$id: '${upperName}Data',
|
|
12
|
+
type: 'object',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
required: [ ${authStrategies.includes('local') ? "'email', 'password'" : ''} ],
|
|
15
|
+
properties: {
|
|
16
|
+
${authStrategies
|
|
17
|
+
.map((name) => name === 'local'
|
|
18
|
+
? `email: {
|
|
19
|
+
type: 'string'
|
|
20
|
+
},
|
|
21
|
+
password: {
|
|
22
|
+
type: 'string'
|
|
23
|
+
}`
|
|
24
|
+
: ` ${name}Id: {
|
|
25
|
+
type: 'string'
|
|
26
|
+
}`)
|
|
27
|
+
.join(',\n')}
|
|
28
|
+
}
|
|
29
|
+
} as const)
|
|
30
|
+
|
|
31
|
+
export type ${upperName}Data = Infer<typeof ${camelName}DataSchema>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// Schema for making partial updates
|
|
35
|
+
export const ${camelName}PatchSchema = schema({
|
|
36
|
+
$id: '${upperName}Patch',
|
|
37
|
+
type: 'object',
|
|
38
|
+
additionalProperties: false,
|
|
39
|
+
required: [],
|
|
40
|
+
properties: {
|
|
41
|
+
...${camelName}DataSchema.properties
|
|
42
|
+
}
|
|
43
|
+
} as const)
|
|
44
|
+
|
|
45
|
+
export type ${upperName}Patch = Infer<typeof ${camelName}PatchSchema>
|
|
46
|
+
|
|
47
|
+
// Schema for the data that is being returned
|
|
48
|
+
export const ${camelName}ResultSchema = schema({
|
|
49
|
+
$id: '${upperName}Result',
|
|
50
|
+
type: 'object',
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
required: [ '${type === 'mongodb' ? '_id' : 'id'}' ],
|
|
53
|
+
properties: {
|
|
54
|
+
...${camelName}DataSchema.properties,
|
|
55
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
56
|
+
type: 'string'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} as const)
|
|
60
|
+
|
|
61
|
+
export type ${upperName}Result = Infer<typeof ${camelName}ResultSchema>
|
|
62
|
+
|
|
63
|
+
// Queries shouldn't allow doing anything with the password
|
|
64
|
+
const { password, ...${camelName}QueryProperties } = ${camelName}ResultSchema.properties
|
|
65
|
+
|
|
66
|
+
// Schema for allowed query properties
|
|
67
|
+
export const ${camelName}QuerySchema = schema({
|
|
68
|
+
$id: '${upperName}Query',
|
|
69
|
+
type: 'object',
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
properties: {
|
|
72
|
+
...querySyntax(${camelName}QueryProperties)
|
|
73
|
+
}
|
|
74
|
+
} as const)
|
|
75
|
+
|
|
76
|
+
export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
|
|
77
|
+
`;
|
|
78
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, folder, kebabName }) => [
|
|
79
|
+
lib,
|
|
80
|
+
'schemas',
|
|
81
|
+
...folder,
|
|
82
|
+
`${kebabName}.schema`
|
|
83
|
+
]), { force: true }));
|
|
84
|
+
exports.generate = generate;
|
|
85
|
+
//# sourceMappingURL=user.schema.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.schema.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/user.schema.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAkC,EAAE,EAAE,CAClG;;;;eAIa,SAAS;UACd,SAAS;;;gBAGH,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;;MAEvE,cAAc;KACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;;;;;MAKN;IACI,CAAC,CAAC,OAAO,IAAI;;MAEjB,CACC;KACA,IAAI,CAAC,KAAK,CAAC;;;;cAIJ,SAAS,uBAAuB,SAAS;;;;eAIxC,SAAS;UACd,SAAS;;;;;SAKV,SAAS;;;;cAIJ,SAAS,wBAAwB,SAAS;;;eAGzC,SAAS;UACd,SAAS;;;iBAGF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;SAEzC,SAAS;MACZ,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;;;;cAMzB,SAAS,yBAAyB,SAAS;;;uBAGlC,SAAS,uBAAuB,SAAS;;;eAGjD,SAAS;UACd,SAAS;;;;qBAIE,SAAS;;;;cAIhB,SAAS,wBAAwB,SAAS;CACvD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAkC,EAAE,EAAE,CAAC;IACrE,GAAG;IACH,SAAS;IACT,GAAG,MAAM;IACT,GAAG,SAAS,SAAS;CACtB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAA;AAZU,QAAA,QAAQ,YAYlB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({ camelName, upperName, authStrategies, type }: AuthenticationGeneratorContext) =>
|
|
6
|
+
`import { schema, querySyntax } from '@feathersjs/schema'
|
|
7
|
+
import type { Infer } from '@feathersjs/schema'
|
|
8
|
+
|
|
9
|
+
// Schema for the basic data model (e.g. creating new entries)
|
|
10
|
+
export const ${camelName}DataSchema = schema({
|
|
11
|
+
$id: '${upperName}Data',
|
|
12
|
+
type: 'object',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
required: [ ${authStrategies.includes('local') ? "'email', 'password'" : ''} ],
|
|
15
|
+
properties: {
|
|
16
|
+
${authStrategies
|
|
17
|
+
.map((name) =>
|
|
18
|
+
name === 'local'
|
|
19
|
+
? `email: {
|
|
20
|
+
type: 'string'
|
|
21
|
+
},
|
|
22
|
+
password: {
|
|
23
|
+
type: 'string'
|
|
24
|
+
}`
|
|
25
|
+
: ` ${name}Id: {
|
|
26
|
+
type: 'string'
|
|
27
|
+
}`
|
|
28
|
+
)
|
|
29
|
+
.join(',\n')}
|
|
30
|
+
}
|
|
31
|
+
} as const)
|
|
32
|
+
|
|
33
|
+
export type ${upperName}Data = Infer<typeof ${camelName}DataSchema>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// Schema for making partial updates
|
|
37
|
+
export const ${camelName}PatchSchema = schema({
|
|
38
|
+
$id: '${upperName}Patch',
|
|
39
|
+
type: 'object',
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
required: [],
|
|
42
|
+
properties: {
|
|
43
|
+
...${camelName}DataSchema.properties
|
|
44
|
+
}
|
|
45
|
+
} as const)
|
|
46
|
+
|
|
47
|
+
export type ${upperName}Patch = Infer<typeof ${camelName}PatchSchema>
|
|
48
|
+
|
|
49
|
+
// Schema for the data that is being returned
|
|
50
|
+
export const ${camelName}ResultSchema = schema({
|
|
51
|
+
$id: '${upperName}Result',
|
|
52
|
+
type: 'object',
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
required: [ '${type === 'mongodb' ? '_id' : 'id'}' ],
|
|
55
|
+
properties: {
|
|
56
|
+
...${camelName}DataSchema.properties,
|
|
57
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
58
|
+
type: 'string'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} as const)
|
|
62
|
+
|
|
63
|
+
export type ${upperName}Result = Infer<typeof ${camelName}ResultSchema>
|
|
64
|
+
|
|
65
|
+
// Queries shouldn't allow doing anything with the password
|
|
66
|
+
const { password, ...${camelName}QueryProperties } = ${camelName}ResultSchema.properties
|
|
67
|
+
|
|
68
|
+
// Schema for allowed query properties
|
|
69
|
+
export const ${camelName}QuerySchema = schema({
|
|
70
|
+
$id: '${upperName}Query',
|
|
71
|
+
type: 'object',
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
properties: {
|
|
74
|
+
...querySyntax(${camelName}QueryProperties)
|
|
75
|
+
}
|
|
76
|
+
} as const)
|
|
77
|
+
|
|
78
|
+
export type ${upperName}Query = Infer<typeof ${camelName}QuerySchema>
|
|
79
|
+
`
|
|
80
|
+
|
|
81
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
82
|
+
generator(ctx).then(
|
|
83
|
+
renderSource(
|
|
84
|
+
template,
|
|
85
|
+
toFile(({ lib, folder, kebabName }: AuthenticationGeneratorContext) => [
|
|
86
|
+
lib,
|
|
87
|
+
'schemas',
|
|
88
|
+
...folder,
|
|
89
|
+
`${kebabName}.schema`
|
|
90
|
+
]),
|
|
91
|
+
{ force: true }
|
|
92
|
+
)
|
|
93
|
+
)
|
package/lib/commons.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { PackageJson } from 'type-fest';
|
|
2
|
+
import { Callable, PinionContext } from '@feathershq/pinion';
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
|
+
export declare type DependencyVersions = {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The database types supported by this generator
|
|
9
|
+
*/
|
|
10
|
+
export declare type DatabaseType = 'mongodb' | 'mysql' | 'postgresql' | 'sqlite' | 'mssql';
|
|
11
|
+
/**
|
|
12
|
+
* Returns the name of the Feathers database adapter for a supported database type
|
|
13
|
+
*
|
|
14
|
+
* @param database The type of the database
|
|
15
|
+
* @returns The name of the adapter
|
|
16
|
+
*/
|
|
17
|
+
export declare const getDatabaseAdapter: (database: DatabaseType) => "mongodb" | "knex";
|
|
18
|
+
export declare type FeathersAppInfo = {
|
|
19
|
+
/**
|
|
20
|
+
* The application language
|
|
21
|
+
*/
|
|
22
|
+
language: 'ts' | 'js';
|
|
23
|
+
/**
|
|
24
|
+
* The main database
|
|
25
|
+
*/
|
|
26
|
+
database: DatabaseType;
|
|
27
|
+
/**
|
|
28
|
+
* The package manager used
|
|
29
|
+
*/
|
|
30
|
+
packager: 'yarn' | 'npm';
|
|
31
|
+
/**
|
|
32
|
+
* A list of all chosen transports
|
|
33
|
+
*/
|
|
34
|
+
transports: ('rest' | 'websockets')[];
|
|
35
|
+
/**
|
|
36
|
+
* The HTTP framework used
|
|
37
|
+
*/
|
|
38
|
+
framework: 'koa' | 'express';
|
|
39
|
+
};
|
|
40
|
+
export interface AppPackageJson extends PackageJson {
|
|
41
|
+
feathers?: FeathersAppInfo;
|
|
42
|
+
}
|
|
43
|
+
export interface FeathersBaseContext extends PinionContext {
|
|
44
|
+
/**
|
|
45
|
+
* Information about the Feathers application (like chosen language, database etc.)
|
|
46
|
+
* usually taken from `package.json`
|
|
47
|
+
*/
|
|
48
|
+
feathers: FeathersAppInfo;
|
|
49
|
+
/**
|
|
50
|
+
* The package.json file
|
|
51
|
+
*/
|
|
52
|
+
pkg: AppPackageJson;
|
|
53
|
+
/**
|
|
54
|
+
* The folder where source files are put
|
|
55
|
+
*/
|
|
56
|
+
lib: string;
|
|
57
|
+
/**
|
|
58
|
+
* The folder where test files are put
|
|
59
|
+
*/
|
|
60
|
+
test: string;
|
|
61
|
+
/**
|
|
62
|
+
* The language the app is generated in
|
|
63
|
+
*/
|
|
64
|
+
language: 'js' | 'ts';
|
|
65
|
+
/**
|
|
66
|
+
* A list dependencies that should be installed with a certain version.
|
|
67
|
+
* Used for installing development dependencies during testing.
|
|
68
|
+
*/
|
|
69
|
+
dependencyVersions?: DependencyVersions;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns dependencies with the versions from the context attached (if available)
|
|
73
|
+
*
|
|
74
|
+
* @param dependencies The dependencies to install
|
|
75
|
+
* @param versions The dependency version list
|
|
76
|
+
* @returns A list of dependencies with their versions
|
|
77
|
+
*/
|
|
78
|
+
export declare const addVersions: (dependencies: string[], versions: DependencyVersions) => string[];
|
|
79
|
+
/**
|
|
80
|
+
* Loads the application package.json and populates information like the library and test directory
|
|
81
|
+
* and Feathers app specific information.
|
|
82
|
+
*
|
|
83
|
+
* @returns The updated context
|
|
84
|
+
*/
|
|
85
|
+
export declare const initializeBaseContext: () => <C extends FeathersBaseContext>(ctx: C) => Promise<C & {
|
|
86
|
+
lib: string;
|
|
87
|
+
test: string;
|
|
88
|
+
language: "js" | "ts";
|
|
89
|
+
feathers: FeathersAppInfo;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the transpiled and prettified JavaScript for a TypeScript source code
|
|
93
|
+
*
|
|
94
|
+
* @param typescript The TypeScript source code
|
|
95
|
+
* @param options TypeScript transpilation options
|
|
96
|
+
* @returns The formatted JavaScript source code
|
|
97
|
+
*/
|
|
98
|
+
export declare const getJavaScript: (typescript: string, options?: ts.TranspileOptions) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Render a source file template for the language set in the context. Will do nothing
|
|
101
|
+
* it there is no template for the selected language.
|
|
102
|
+
*
|
|
103
|
+
* @param templates The JavaScript and TypeScript template to render
|
|
104
|
+
* @param toFile The target filename without extension (will be added based on language)
|
|
105
|
+
* @returns The updated context
|
|
106
|
+
*/
|
|
107
|
+
export declare const renderSource: <C extends PinionContext & {
|
|
108
|
+
language: 'js' | 'ts';
|
|
109
|
+
}>(template: Callable<string, C>, toFile: Callable<string, C>, options?: {
|
|
110
|
+
force: boolean;
|
|
111
|
+
}) => (ctx: C) => Promise<C>;
|
|
112
|
+
/**
|
|
113
|
+
* Returns the TypeScript or transpiled JavaScript source code
|
|
114
|
+
*
|
|
115
|
+
* @param template The source template
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
export declare const getSource: <C extends PinionContext & {
|
|
119
|
+
language: 'js' | 'ts';
|
|
120
|
+
}>(template: Callable<string, C>) => <T extends C>(ctx: T) => Promise<string>;
|