@feathersjs/cli 5.0.0-pre.30 → 5.0.0-pre.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/app/index.js +1 -1
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +10 -1
- package/lib/app/templates/client.test.tpl.d.ts +2 -0
- package/lib/app/templates/client.test.tpl.js +27 -0
- package/lib/app/templates/client.test.tpl.js.map +1 -0
- package/lib/app/templates/client.test.tpl.ts +26 -0
- package/lib/app/templates/client.tpl.js +1 -1
- package/lib/app/templates/client.tpl.ts +1 -1
- package/lib/app/templates/logger.tpl.js +8 -2
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +8 -2
- package/lib/app/templates/schemas.tpl.js +4 -5
- package/lib/app/templates/schemas.tpl.js.map +1 -1
- package/lib/app/templates/schemas.tpl.ts +4 -5
- package/lib/authentication/index.d.ts +1 -0
- package/lib/authentication/templates/{test.tpl.d.ts → client.test.tpl.d.ts} +0 -0
- package/lib/authentication/templates/client.test.tpl.js +66 -0
- package/lib/authentication/templates/client.test.tpl.js.map +1 -0
- package/lib/authentication/templates/client.test.tpl.ts +80 -0
- package/lib/authentication/templates/client.tpl.d.ts +2 -0
- package/lib/authentication/templates/client.tpl.js +14 -0
- package/lib/authentication/templates/client.tpl.js.map +1 -0
- package/lib/authentication/templates/client.tpl.ts +19 -0
- package/lib/authentication/templates/declarations.tpl.js +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +1 -1
- package/lib/authentication/templates/knex.tpl.js +3 -3
- package/lib/authentication/templates/knex.tpl.ts +3 -3
- package/lib/authentication/templates/schema.json.tpl.js +24 -24
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.json.tpl.ts +24 -24
- package/lib/authentication/templates/schema.typebox.tpl.js +24 -26
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +26 -26
- package/lib/service/index.d.ts +5 -63
- package/lib/service/index.js +74 -75
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +10 -4
- package/lib/service/templates/client.tpl.js +14 -19
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +32 -21
- package/lib/service/templates/schema.json.tpl.js +24 -22
- package/lib/service/templates/schema.json.tpl.js.map +1 -1
- package/lib/service/templates/schema.json.tpl.ts +24 -22
- package/lib/service/templates/schema.typebox.tpl.js +22 -25
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/service/templates/schema.typebox.tpl.ts +22 -25
- package/lib/service/type/knex.tpl.d.ts +1 -1
- package/lib/service/type/knex.tpl.js +10 -8
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +10 -9
- package/lib/service/type/mongodb.tpl.d.ts +1 -1
- package/lib/service/type/mongodb.tpl.js +7 -5
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +8 -6
- package/package.json +18 -16
- package/lib/authentication/templates/test.tpl.js +0 -43
- package/lib/authentication/templates/test.tpl.js.map +0 -1
- package/lib/authentication/templates/test.tpl.ts +0 -53
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538))
|
|
11
|
+
- **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6))
|
|
12
|
+
|
|
6
13
|
# [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07)
|
|
7
14
|
|
|
8
15
|
### Bug Fixes
|
package/lib/app/index.js
CHANGED
|
@@ -136,7 +136,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
136
136
|
return (0, commons_1.addVersions)(dependencies, dependencyVersions);
|
|
137
137
|
}, false, ctx.packager))
|
|
138
138
|
.then((0, pinion_1.install)(({ language, framework, devDependencies, dependencyVersions }) => {
|
|
139
|
-
devDependencies.push('nodemon', 'axios', 'mocha', 'cross-env', 'prettier', '@feathersjs/cli');
|
|
139
|
+
devDependencies.push('nodemon', 'axios', 'mocha', 'cross-env', 'prettier', '@feathersjs/cli', '@feathersjs/rest-client', '@feathersjs/authentication-client');
|
|
140
140
|
if (language === 'ts') {
|
|
141
141
|
devDependencies.push('@types/mocha', framework === 'koa' ? '@types/koa-static' : '@types/compression', '@types/node', 'nodemon', 'ts-node', 'typescript', 'shx');
|
|
142
142
|
}
|
package/lib/app/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA0B;AAC1B,kDAAyB;AACzB,+CAS2B;AAC3B,wCAAqG;AACrG,sDAAyG;AACzG,8CAA6F;AAiCtF,MAAM,QAAQ,GAAG,CAAC,GAA0B,EAAE,EAAE,CACrD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACd,GAAG,GAAG;IACN,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE;CACpB,CA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EACP,OAAO,EACP,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACpC,CAAA;IAED,IAAI,QAAQ,KAAK,IAAI,EAAE;QACrB,eAAe,CAAC,IAAI,CAClB,cAAc,EACd,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,oBAAoB,EAChE,aAAa,EACb,SAAS,EACT,SAAS,EACT,YAAY,EACZ,KAAK,CACN,CAAA;KACF;IAED,OAAO,IAAA,qBAAW,EAAC,eAAe,EAAE,kBAAkB,CAAC,CAAA;AACzD,CAAC,EACD,IAAI,EACJ,GAAG,CAAC,QAAQ,CACb,CACF,CAAA;AA3LQ,QAAA,QAAQ,YA2LhB"}
|
package/lib/app/index.ts
CHANGED
|
@@ -204,7 +204,16 @@ export const generate = (ctx: AppGeneratorArguments) =>
|
|
|
204
204
|
.then(
|
|
205
205
|
install<AppGeneratorContext>(
|
|
206
206
|
({ language, framework, devDependencies, dependencyVersions }) => {
|
|
207
|
-
devDependencies.push(
|
|
207
|
+
devDependencies.push(
|
|
208
|
+
'nodemon',
|
|
209
|
+
'axios',
|
|
210
|
+
'mocha',
|
|
211
|
+
'cross-env',
|
|
212
|
+
'prettier',
|
|
213
|
+
'@feathersjs/cli',
|
|
214
|
+
'@feathersjs/rest-client',
|
|
215
|
+
'@feathersjs/authentication-client'
|
|
216
|
+
)
|
|
208
217
|
|
|
209
218
|
if (language === 'ts') {
|
|
210
219
|
devDependencies.push(
|
|
@@ -0,0 +1,27 @@
|
|
|
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 = ({ lib }) => /* ts */ `import assert from 'assert'
|
|
7
|
+
import axios from 'axios'
|
|
8
|
+
import type { Server } from 'http'
|
|
9
|
+
import { app } from '../${lib}/app'
|
|
10
|
+
import { createClient } from '../${lib}/client'
|
|
11
|
+
|
|
12
|
+
import rest from '@feathersjs/rest-client'
|
|
13
|
+
|
|
14
|
+
const port = app.get('port')
|
|
15
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
16
|
+
|
|
17
|
+
describe('client tests', () => {
|
|
18
|
+
const client = createClient(rest(appUrl).axios(axios))
|
|
19
|
+
|
|
20
|
+
it('initialized the client', () => {
|
|
21
|
+
assert.ok(client)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
`;
|
|
25
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)('test', 'client.test')));
|
|
26
|
+
exports.generate = generate;
|
|
27
|
+
//# sourceMappingURL=client.test.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/client.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;0BAGlC,GAAG;mCACM,GAAG;;;;;;;;;;;;;;CAcrC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAY,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;AAD/D,QAAA,QAAQ,YACuD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({ lib }: AppGeneratorContext) => /* ts */ `import assert from 'assert'
|
|
6
|
+
import axios from 'axios'
|
|
7
|
+
import type { Server } from 'http'
|
|
8
|
+
import { app } from '../${lib}/app'
|
|
9
|
+
import { createClient } from '../${lib}/client'
|
|
10
|
+
|
|
11
|
+
import rest from '@feathersjs/rest-client'
|
|
12
|
+
|
|
13
|
+
const port = app.get('port')
|
|
14
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
15
|
+
|
|
16
|
+
describe('client tests', () => {
|
|
17
|
+
const client = createClient(rest(appUrl).axios(axios))
|
|
18
|
+
|
|
19
|
+
it('initialized the client', () => {
|
|
20
|
+
assert.ok(client)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
26
|
+
generator(ctx).then(renderSource(template, toFile('test', 'client.test')))
|
|
@@ -4,7 +4,7 @@ exports.generate = void 0;
|
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
6
|
const template = ({}) => /* ts */ `import { feathers } from '@feathersjs/feathers'
|
|
7
|
-
import type {
|
|
7
|
+
import type { TransportConnection, Params } from '@feathersjs/feathers'
|
|
8
8
|
|
|
9
9
|
export interface ServiceTypes {
|
|
10
10
|
//
|
|
@@ -3,7 +3,7 @@ import { renderSource } from '../../commons'
|
|
|
3
3
|
import { AppGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
const template = ({}: AppGeneratorContext) => /* ts */ `import { feathers } from '@feathersjs/feathers'
|
|
6
|
-
import type {
|
|
6
|
+
import type { TransportConnection, Params } from '@feathersjs/feathers'
|
|
7
7
|
|
|
8
8
|
export interface ServiceTypes {
|
|
9
9
|
//
|
|
@@ -22,8 +22,14 @@ export const logger = createLogger({
|
|
|
22
22
|
export const logErrorHook = async (context: HookContext, next: NextFunction) => {
|
|
23
23
|
try {
|
|
24
24
|
await next()
|
|
25
|
-
} catch (error) {
|
|
26
|
-
logger.error(error)
|
|
25
|
+
} catch (error: any) {
|
|
26
|
+
logger.error(error.stack)
|
|
27
|
+
|
|
28
|
+
// Log validation errors
|
|
29
|
+
if (error.errors) {
|
|
30
|
+
logger.error(error.errors)
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
throw error
|
|
28
34
|
}
|
|
29
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/logger.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GACZ,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"logger.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/logger.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GACZ,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BvC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,CACxD,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -22,8 +22,14 @@ export const logger = createLogger({
|
|
|
22
22
|
export const logErrorHook = async (context: HookContext, next: NextFunction) => {
|
|
23
23
|
try {
|
|
24
24
|
await next()
|
|
25
|
-
} catch (error) {
|
|
26
|
-
logger.error(error)
|
|
25
|
+
} catch (error: any) {
|
|
26
|
+
logger.error(error.stack)
|
|
27
|
+
|
|
28
|
+
// Log validation errors
|
|
29
|
+
if (error.errors) {
|
|
30
|
+
logger.error(error.errors)
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
throw error
|
|
28
34
|
}
|
|
29
35
|
}
|
|
@@ -29,7 +29,7 @@ export const queryValidator = addFormats(new Ajv({
|
|
|
29
29
|
coerceTypes: true
|
|
30
30
|
}), formats)
|
|
31
31
|
`;
|
|
32
|
-
const configurationJsonTemplate = ({}) => /* ts */ `import { defaultAppSettings,
|
|
32
|
+
const configurationJsonTemplate = ({}) => /* ts */ `import { defaultAppSettings, getValidator } from '@feathersjs/schema'
|
|
33
33
|
import type { FromSchema } from '@feathersjs/schema'
|
|
34
34
|
|
|
35
35
|
import { dataValidator } from './validators'
|
|
@@ -46,12 +46,11 @@ export const configurationSchema = {
|
|
|
46
46
|
}
|
|
47
47
|
} as const
|
|
48
48
|
|
|
49
|
-
export const configurationValidator =
|
|
49
|
+
export const configurationValidator = getValidator(configurationSchema, dataValidator)
|
|
50
50
|
|
|
51
51
|
export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
|
|
52
52
|
`;
|
|
53
|
-
const configurationTypeboxTemplate = ({}) => /* ts */ `import {
|
|
54
|
-
import { Type, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
53
|
+
const configurationTypeboxTemplate = ({}) => /* ts */ `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
55
54
|
import type { Static } from '@feathersjs/typebox'
|
|
56
55
|
|
|
57
56
|
import { dataValidator } from './validators'
|
|
@@ -67,7 +66,7 @@ export const configurationSchema = Type.Intersect([
|
|
|
67
66
|
|
|
68
67
|
export type ApplicationConfiguration = Static<typeof configurationSchema>
|
|
69
68
|
|
|
70
|
-
export const configurationValidator =
|
|
69
|
+
export const configurationValidator = getValidator(configurationSchema, dataValidator)
|
|
71
70
|
`;
|
|
72
71
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
73
72
|
.then((0, commons_1.renderSource)(async (ctx) => ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx), (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'configuration')))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/schemas.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlC,CAAA;AAED,MAAM,yBAAyB,GAC7B,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAA;AAED,MAAM,4BAA4B,GAChC,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"schemas.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/schemas.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlC,CAAA;AAED,MAAM,yBAAyB,GAC7B,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAA;AAED,MAAM,4BAA4B,GAChC,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;CAiBvC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,KAAK,EAAE,GAAG,EAAE,EAAE,CACZ,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,EAC/F,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,CAAC,CAC1E,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,CACvE,CACF,CAAA;AAdQ,QAAA,QAAQ,YAchB"}
|
|
@@ -30,7 +30,7 @@ export const queryValidator = addFormats(new Ajv({
|
|
|
30
30
|
`
|
|
31
31
|
|
|
32
32
|
const configurationJsonTemplate =
|
|
33
|
-
({}: AppGeneratorContext) => /* ts */ `import { defaultAppSettings,
|
|
33
|
+
({}: AppGeneratorContext) => /* ts */ `import { defaultAppSettings, getValidator } from '@feathersjs/schema'
|
|
34
34
|
import type { FromSchema } from '@feathersjs/schema'
|
|
35
35
|
|
|
36
36
|
import { dataValidator } from './validators'
|
|
@@ -47,14 +47,13 @@ export const configurationSchema = {
|
|
|
47
47
|
}
|
|
48
48
|
} as const
|
|
49
49
|
|
|
50
|
-
export const configurationValidator =
|
|
50
|
+
export const configurationValidator = getValidator(configurationSchema, dataValidator)
|
|
51
51
|
|
|
52
52
|
export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
|
|
53
53
|
`
|
|
54
54
|
|
|
55
55
|
const configurationTypeboxTemplate =
|
|
56
|
-
({}: AppGeneratorContext) => /* ts */ `import {
|
|
57
|
-
import { Type, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
56
|
+
({}: AppGeneratorContext) => /* ts */ `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
58
57
|
import type { Static } from '@feathersjs/typebox'
|
|
59
58
|
|
|
60
59
|
import { dataValidator } from './validators'
|
|
@@ -70,7 +69,7 @@ export const configurationSchema = Type.Intersect([
|
|
|
70
69
|
|
|
71
70
|
export type ApplicationConfiguration = Static<typeof configurationSchema>
|
|
72
71
|
|
|
73
|
-
export const configurationValidator =
|
|
72
|
+
export const configurationValidator = getValidator(configurationSchema, dataValidator)
|
|
74
73
|
`
|
|
75
74
|
|
|
76
75
|
export const generate = (ctx: AppGeneratorContext) =>
|
|
@@ -50,6 +50,7 @@ export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promis
|
|
|
50
50
|
className: string;
|
|
51
51
|
kebabName: string;
|
|
52
52
|
fileName: string;
|
|
53
|
+
kebabPath: string;
|
|
53
54
|
relative: string;
|
|
54
55
|
type: "mongodb" | "knex" | "custom";
|
|
55
56
|
schema: false | "typebox" | "json";
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
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, upperName, type, lib }) => /* ts */ `import assert from 'assert'
|
|
7
|
+
import axios from 'axios'
|
|
8
|
+
|
|
9
|
+
import rest from '@feathersjs/rest-client'
|
|
10
|
+
${authStrategies.includes('local')
|
|
11
|
+
? `import authenticationClient from '@feathersjs/authentication-client'`
|
|
12
|
+
: ''}
|
|
13
|
+
import { app } from '../${lib}/app'
|
|
14
|
+
import { createClient } from '../${lib}/client'
|
|
15
|
+
${authStrategies.includes('local') ? `import type { ${upperName}Data } from '../${lib}/client'` : ''}
|
|
16
|
+
|
|
17
|
+
const port = app.get('port')
|
|
18
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
19
|
+
|
|
20
|
+
describe('application client tests', () => {
|
|
21
|
+
const client = createClient(rest(appUrl).axios(axios))
|
|
22
|
+
|
|
23
|
+
client.configure(authenticationClient())
|
|
24
|
+
|
|
25
|
+
before(async () => {
|
|
26
|
+
await app.listen(port)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
after(async () => {
|
|
30
|
+
await app.teardown()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('initialized the client', () => {
|
|
34
|
+
assert.ok(client)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
${authStrategies.includes('local')
|
|
38
|
+
? `
|
|
39
|
+
it('creates and authenticates a user with email and password', async () => {
|
|
40
|
+
const userData: ${upperName}Data = {
|
|
41
|
+
email: 'someone@example.com',
|
|
42
|
+
password: 'supersecret'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await client.service('users').create(userData)
|
|
46
|
+
|
|
47
|
+
const { user, accessToken } = await client.authenticate({
|
|
48
|
+
strategy: 'local',
|
|
49
|
+
...userData
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
assert.ok(accessToken, 'Created access token for user')
|
|
53
|
+
assert.ok(user, 'Includes user in authentication data')
|
|
54
|
+
assert.strictEqual(user.password, undefined, 'Password is hidden to clients')
|
|
55
|
+
|
|
56
|
+
await client.logout()
|
|
57
|
+
|
|
58
|
+
// Remove the test user on the server
|
|
59
|
+
await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'})
|
|
60
|
+
})`
|
|
61
|
+
: ''}
|
|
62
|
+
})
|
|
63
|
+
`;
|
|
64
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test }) => test, 'client.test'), { force: true }));
|
|
65
|
+
exports.generate = generate;
|
|
66
|
+
//# sourceMappingURL=client.test.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACd,SAAS,EACT,IAAI,EACJ,GAAG,EAC4B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;EAK7C,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC,sEAAsE;IACxE,CAAC,CAAC,EACN;0BAC0B,GAAG;mCACM,GAAG;EACpC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,SAAS,mBAAmB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;IAuBhG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC;;sBAEc,SAAS;;;;;;;;;;;;;;;;;;;6CAmBc,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;KACzE;IACC,CAAC,CAAC,EACN;;CAED,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,aAAa,CAAC,EACzE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAA;AAPU,QAAA,QAAQ,YAOlB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({
|
|
6
|
+
authStrategies,
|
|
7
|
+
upperName,
|
|
8
|
+
type,
|
|
9
|
+
lib
|
|
10
|
+
}: AuthenticationGeneratorContext) => /* ts */ `import assert from 'assert'
|
|
11
|
+
import axios from 'axios'
|
|
12
|
+
|
|
13
|
+
import rest from '@feathersjs/rest-client'
|
|
14
|
+
${
|
|
15
|
+
authStrategies.includes('local')
|
|
16
|
+
? `import authenticationClient from '@feathersjs/authentication-client'`
|
|
17
|
+
: ''
|
|
18
|
+
}
|
|
19
|
+
import { app } from '../${lib}/app'
|
|
20
|
+
import { createClient } from '../${lib}/client'
|
|
21
|
+
${authStrategies.includes('local') ? `import type { ${upperName}Data } from '../${lib}/client'` : ''}
|
|
22
|
+
|
|
23
|
+
const port = app.get('port')
|
|
24
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
25
|
+
|
|
26
|
+
describe('application client tests', () => {
|
|
27
|
+
const client = createClient(rest(appUrl).axios(axios))
|
|
28
|
+
|
|
29
|
+
client.configure(authenticationClient())
|
|
30
|
+
|
|
31
|
+
before(async () => {
|
|
32
|
+
await app.listen(port)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
after(async () => {
|
|
36
|
+
await app.teardown()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('initialized the client', () => {
|
|
40
|
+
assert.ok(client)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
${
|
|
44
|
+
authStrategies.includes('local')
|
|
45
|
+
? `
|
|
46
|
+
it('creates and authenticates a user with email and password', async () => {
|
|
47
|
+
const userData: ${upperName}Data = {
|
|
48
|
+
email: 'someone@example.com',
|
|
49
|
+
password: 'supersecret'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await client.service('users').create(userData)
|
|
53
|
+
|
|
54
|
+
const { user, accessToken } = await client.authenticate({
|
|
55
|
+
strategy: 'local',
|
|
56
|
+
...userData
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
assert.ok(accessToken, 'Created access token for user')
|
|
60
|
+
assert.ok(user, 'Includes user in authentication data')
|
|
61
|
+
assert.strictEqual(user.password, undefined, 'Password is hidden to clients')
|
|
62
|
+
|
|
63
|
+
await client.logout()
|
|
64
|
+
|
|
65
|
+
// Remove the test user on the server
|
|
66
|
+
await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'})
|
|
67
|
+
})`
|
|
68
|
+
: ''
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
`
|
|
72
|
+
|
|
73
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
74
|
+
generator(ctx).then(
|
|
75
|
+
renderSource(
|
|
76
|
+
template,
|
|
77
|
+
toFile<AuthenticationGeneratorContext>(({ test }) => test, 'client.test'),
|
|
78
|
+
{ force: true }
|
|
79
|
+
)
|
|
80
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
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 importTemplate = /* ts */ `import type { AuthenticationService } from '@feathersjs/authentication'
|
|
7
|
+
`;
|
|
8
|
+
const declarationTemplate = ` authentication: Pick<AuthenticationService, 'create' | 'remove'>`;
|
|
9
|
+
const toClientFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'client']);
|
|
10
|
+
const generate = async (ctx) => (0, pinion_1.generator)(ctx)
|
|
11
|
+
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.after)("from '@feathersjs/feathers'"), toClientFile))
|
|
12
|
+
.then((0, pinion_1.when)(({ language }) => language === 'ts', (0, commons_1.injectSource)(declarationTemplate, (0, pinion_1.after)('export interface ServiceTypes'), toClientFile)));
|
|
13
|
+
exports.generate = generate;
|
|
14
|
+
//# sourceMappingURL=client.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAmE;AACnE,2CAA4C;AAG5C,MAAM,cAAc,GAAG,QAAQ,CAAC;CAC/B,CAAA;AACD,MAAM,mBAAmB,GAAG,oEAAoE,CAAA;AAEhG,MAAM,YAAY,GAAG,IAAA,eAAM,EAA0B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE3E,MAAM,QAAQ,GAAG,KAAK,EAAE,GAA4B,EAAE,EAAE,CAC7D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,cAAK,EAAC,6BAA6B,CAAC,EAAE,YAAY,CAAC,CAAC;KACtF,IAAI,CACH,IAAA,aAAI,EACF,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,EACnC,IAAA,sBAAY,EAAC,mBAAmB,EAAE,IAAA,cAAK,EAAC,+BAA+B,CAAC,EAAE,YAAY,CAAC,CACxF,CACF,CAAA;AARQ,QAAA,QAAQ,YAQhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { generator, toFile, after, when } from '@feathershq/pinion'
|
|
2
|
+
import { injectSource } from '../../commons'
|
|
3
|
+
import { ServiceGeneratorContext } from '../../service'
|
|
4
|
+
|
|
5
|
+
const importTemplate = /* ts */ `import type { AuthenticationService } from '@feathersjs/authentication'
|
|
6
|
+
`
|
|
7
|
+
const declarationTemplate = ` authentication: Pick<AuthenticationService, 'create' | 'remove'>`
|
|
8
|
+
|
|
9
|
+
const toClientFile = toFile<ServiceGeneratorContext>(({ lib }) => [lib, 'client'])
|
|
10
|
+
|
|
11
|
+
export const generate = async (ctx: ServiceGeneratorContext) =>
|
|
12
|
+
generator(ctx)
|
|
13
|
+
.then(injectSource(importTemplate, after("from '@feathersjs/feathers'"), toClientFile))
|
|
14
|
+
.then(
|
|
15
|
+
when(
|
|
16
|
+
({ language }) => language === 'ts',
|
|
17
|
+
injectSource(declarationTemplate, after('export interface ServiceTypes'), toClientFile)
|
|
18
|
+
)
|
|
19
|
+
)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const importTemplate = ({ upperName, folder, fileName }) => /* ts */ `import { ${upperName} } from './services/${folder.join('/')}/${fileName}
|
|
5
|
+
const importTemplate = ({ upperName, folder, fileName }) => /* ts */ `import { ${upperName} } from './services/${folder.join('/')}/${fileName}'
|
|
6
6
|
`;
|
|
7
7
|
const paramsTemplate = ({ entity, upperName }) => /* ts */ `// Add the ${entity} as an optional property to all params
|
|
8
8
|
declare module '@feathersjs/feathers' {
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const migrationTemplate = ({
|
|
6
|
+
const migrationTemplate = ({ kebabPath, authStrategies }) => /* ts */ `import type { Knex } from 'knex'
|
|
7
7
|
|
|
8
8
|
export async function up(knex: Knex): Promise<void> {
|
|
9
|
-
await knex.schema.alterTable('${
|
|
9
|
+
await knex.schema.alterTable('${kebabPath}', function (table) {
|
|
10
10
|
table.dropColumn('text')${authStrategies
|
|
11
11
|
.map((name) => name === 'local'
|
|
12
12
|
? `
|
|
@@ -19,7 +19,7 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export async function down(knex: Knex): Promise<void> {
|
|
22
|
-
await knex.schema.alterTable('${
|
|
22
|
+
await knex.schema.alterTable('${kebabPath}', function (table) {
|
|
23
23
|
table.string('text')${authStrategies
|
|
24
24
|
.map((name) => name === 'local'
|
|
25
25
|
? `
|
|
@@ -3,12 +3,12 @@ import { getDatabaseAdapter, renderSource } from '../../commons'
|
|
|
3
3
|
import { AuthenticationGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
const migrationTemplate = ({
|
|
6
|
-
|
|
6
|
+
kebabPath,
|
|
7
7
|
authStrategies
|
|
8
8
|
}: AuthenticationGeneratorContext) => /* ts */ `import type { Knex } from 'knex'
|
|
9
9
|
|
|
10
10
|
export async function up(knex: Knex): Promise<void> {
|
|
11
|
-
await knex.schema.alterTable('${
|
|
11
|
+
await knex.schema.alterTable('${kebabPath}', function (table) {
|
|
12
12
|
table.dropColumn('text')${authStrategies
|
|
13
13
|
.map((name) =>
|
|
14
14
|
name === 'local'
|
|
@@ -23,7 +23,7 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export async function down(knex: Knex): Promise<void> {
|
|
26
|
-
await knex.schema.alterTable('${
|
|
26
|
+
await knex.schema.alterTable('${kebabPath}', function (table) {
|
|
27
27
|
table.string('text')${authStrategies
|
|
28
28
|
.map((name) =>
|
|
29
29
|
name === 'local'
|
|
@@ -3,20 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ camelName, upperName, authStrategies, type, relative }) => /* ts */ `import { resolve,
|
|
6
|
+
const template = ({ camelName, upperName, authStrategies, type, relative }) => /* ts */ `import { resolve, querySyntax, getValidator, getDataValidator } from '@feathersjs/schema'
|
|
7
7
|
import type { FromSchema } from '@feathersjs/schema'
|
|
8
8
|
${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
|
|
9
9
|
|
|
10
10
|
import type { HookContext } from '${relative}/declarations'
|
|
11
11
|
import { dataValidator, queryValidator } from '${relative}/schemas/validators'
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
export const ${camelName}
|
|
15
|
-
$id: '${upperName}
|
|
13
|
+
// Main data model schema
|
|
14
|
+
export const ${camelName}Schema = {
|
|
15
|
+
$id: '${upperName}',
|
|
16
16
|
type: 'object',
|
|
17
17
|
additionalProperties: false,
|
|
18
|
-
required: [ ${authStrategies.includes('local') ? "'email'" : ''} ],
|
|
18
|
+
required: [ '${type === 'mongodb' ? '_id' : 'id'}'${authStrategies.includes('local') ? ", 'email'" : ''} ],
|
|
19
19
|
properties: {
|
|
20
|
+
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
21
|
+
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
22
|
+
},
|
|
20
23
|
${authStrategies
|
|
21
24
|
.map((name) => name === 'local'
|
|
22
25
|
? ` email: { type: 'string' },
|
|
@@ -25,30 +28,27 @@ export const ${camelName}DataSchema = {
|
|
|
25
28
|
.join(',\n')}
|
|
26
29
|
}
|
|
27
30
|
} as const
|
|
28
|
-
export type ${upperName}
|
|
29
|
-
export const ${camelName}
|
|
30
|
-
|
|
31
|
-
properties: {
|
|
32
|
-
${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
|
|
33
|
-
}
|
|
31
|
+
export type ${upperName} = FromSchema<typeof ${camelName}Schema>
|
|
32
|
+
export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
|
|
33
|
+
properties: {}
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
// Schema for the data
|
|
37
|
-
export const ${camelName}
|
|
38
|
-
$id: '${upperName}',
|
|
36
|
+
// Schema for the basic data model (e.g. creating new entries)
|
|
37
|
+
export const ${camelName}DataSchema = {
|
|
38
|
+
$id: '${upperName}Data',
|
|
39
39
|
type: 'object',
|
|
40
40
|
additionalProperties: false,
|
|
41
|
-
required: [
|
|
41
|
+
required: [ ],
|
|
42
42
|
properties: {
|
|
43
|
-
...${camelName}
|
|
44
|
-
${type === 'mongodb' ? '_id' : 'id'}: {
|
|
45
|
-
type: '${type === 'mongodb' ? 'string' : 'number'}'
|
|
46
|
-
}
|
|
43
|
+
...${camelName}Schema.properties
|
|
47
44
|
}
|
|
48
45
|
} as const
|
|
49
|
-
export type ${upperName} = FromSchema<typeof ${camelName}
|
|
50
|
-
export const ${camelName}
|
|
51
|
-
|
|
46
|
+
export type ${upperName}Data = FromSchema<typeof ${camelName}DataSchema>
|
|
47
|
+
export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema, dataValidator)
|
|
48
|
+
export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
|
|
49
|
+
properties: {
|
|
50
|
+
${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
|
|
51
|
+
}
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
|
|
@@ -64,11 +64,11 @@ export const ${camelName}QuerySchema = {
|
|
|
64
64
|
type: 'object',
|
|
65
65
|
additionalProperties: false,
|
|
66
66
|
properties: {
|
|
67
|
-
...
|
|
67
|
+
...querySyntax(${camelName}Schema.properties)
|
|
68
68
|
}
|
|
69
69
|
} as const
|
|
70
70
|
export type ${upperName}Query = FromSchema<typeof ${camelName}QuerySchema>
|
|
71
|
-
export const ${camelName}QueryValidator =
|
|
71
|
+
export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator)
|
|
72
72
|
export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
|
|
73
73
|
properties: {
|
|
74
74
|
// If there is a user (e.g. with authentication), they are only allowed to see their own data
|