@feathersjs/feathers 5.0.0-pre.22 → 5.0.0-pre.25
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 +32 -0
- package/lib/application.d.ts +3 -4
- package/lib/application.js +36 -34
- package/lib/application.js.map +1 -1
- package/lib/declarations.d.ts +37 -18
- package/lib/events.d.ts +1 -1
- package/lib/events.js +4 -5
- package/lib/events.js.map +1 -1
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +169 -0
- package/lib/hooks.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/service.js +9 -15
- package/lib/service.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +9 -9
- package/src/application.ts +106 -97
- package/src/declarations.ts +144 -145
- package/src/events.ts +15 -15
- package/src/hooks.ts +230 -0
- package/src/index.ts +13 -12
- package/src/service.ts +33 -49
- package/src/version.ts +1 -1
- package/lib/dependencies.d.ts +0 -4
- package/lib/dependencies.js +0 -22
- package/lib/dependencies.js.map +0 -1
- package/lib/hooks/index.d.ts +0 -13
- package/lib/hooks/index.js +0 -96
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/regular.d.ts +0 -12
- package/lib/hooks/regular.js +0 -169
- package/lib/hooks/regular.js.map +0 -1
- package/src/dependencies.ts +0 -5
- package/src/hooks/index.ts +0 -122
- package/src/hooks/regular.ts +0 -207
package/lib/service.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wrapService = exports.getServiceOptions = exports.getHookMethods = exports.protectedMethods = exports.defaultEventMap = exports.defaultServiceMethods = exports.defaultServiceArguments = exports.SERVICE = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const commons_1 = require("@feathersjs/commons");
|
|
6
|
+
exports.SERVICE = (0, commons_1.createSymbol)('@feathersjs/service');
|
|
6
7
|
exports.defaultServiceArguments = {
|
|
7
8
|
find: ['params'],
|
|
8
9
|
get: ['id', 'params'],
|
|
@@ -19,20 +20,13 @@ exports.defaultEventMap = {
|
|
|
19
20
|
remove: 'removed'
|
|
20
21
|
};
|
|
21
22
|
exports.protectedMethods = Object.keys(Object.prototype)
|
|
22
|
-
.concat(Object.keys(
|
|
23
|
-
.concat([
|
|
24
|
-
'all',
|
|
25
|
-
'before',
|
|
26
|
-
'after',
|
|
27
|
-
'error',
|
|
28
|
-
'hooks',
|
|
29
|
-
'setup',
|
|
30
|
-
'teardown',
|
|
31
|
-
'publish'
|
|
32
|
-
]);
|
|
23
|
+
.concat(Object.keys(events_1.EventEmitter.prototype))
|
|
24
|
+
.concat(['all', 'around', 'before', 'after', 'error', 'hooks', 'setup', 'teardown', 'publish']);
|
|
33
25
|
function getHookMethods(service, options) {
|
|
34
26
|
const { methods } = options;
|
|
35
|
-
return exports.defaultServiceMethods
|
|
27
|
+
return exports.defaultServiceMethods
|
|
28
|
+
.filter((m) => typeof service[m] === 'function' && !methods.includes(m))
|
|
29
|
+
.concat(methods);
|
|
36
30
|
}
|
|
37
31
|
exports.getHookMethods = getHookMethods;
|
|
38
32
|
function getServiceOptions(service, options = {}) {
|
|
@@ -40,7 +34,7 @@ function getServiceOptions(service, options = {}) {
|
|
|
40
34
|
if (existingOptions) {
|
|
41
35
|
return existingOptions;
|
|
42
36
|
}
|
|
43
|
-
const { methods = exports.defaultServiceMethods.filter(method => typeof service[method] === 'function'), events = service.events || [] } = options;
|
|
37
|
+
const { methods = exports.defaultServiceMethods.filter((method) => typeof service[method] === 'function'), events = service.events || [] } = options;
|
|
44
38
|
const { serviceEvents = Object.values(exports.defaultEventMap).concat(events) } = options;
|
|
45
39
|
return {
|
|
46
40
|
...options,
|
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"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"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "5.0.0-pre.
|
|
1
|
+
declare const _default: "5.0.0-pre.25";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,cAAc,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/feathers",
|
|
3
3
|
"description": "A framework for real-time applications and REST API with JavaScript and TypeScript",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.25",
|
|
5
5
|
"homepage": "http://feathersjs.com",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"*.js"
|
|
43
43
|
],
|
|
44
44
|
"scripts": {
|
|
45
|
-
"write-version": "node -e \"console.log('export default \\'' + require('./package.json').version + '\\'
|
|
46
|
-
"reset-version": "node -e \"console.log('export default \\'development\\'
|
|
45
|
+
"write-version": "node -e \"console.log('export default \\'' + require('./package.json').version + '\\'')\" > src/version.ts",
|
|
46
|
+
"reset-version": "node -e \"console.log('export default \\'development\\'')\" > src/version.ts",
|
|
47
47
|
"prepublish": "npm run compile",
|
|
48
48
|
"version": "npm run write-version",
|
|
49
49
|
"publish": "npm run reset-version",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
61
|
-
"@feathersjs/hooks": "^0.7.
|
|
60
|
+
"@feathersjs/commons": "^5.0.0-pre.25",
|
|
61
|
+
"@feathersjs/hooks": "^0.7.5",
|
|
62
62
|
"events": "^3.3.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/mocha": "^9.1.1",
|
|
66
|
-
"@types/node": "^17.0.
|
|
66
|
+
"@types/node": "^17.0.40",
|
|
67
67
|
"mocha": "^10.0.0",
|
|
68
68
|
"shx": "^0.3.4",
|
|
69
|
-
"ts-node": "^10.
|
|
70
|
-
"typescript": "^4.
|
|
69
|
+
"ts-node": "^10.8.1",
|
|
70
|
+
"typescript": "^4.7.3"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c0ab3b603920dff6e9c912b2767cf168094d45c8"
|
|
73
73
|
}
|
package/src/application.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import version from './version'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from '
|
|
5
|
-
import { eventHook, eventMixin } from './events'
|
|
6
|
-
import { hookMixin } from './hooks
|
|
7
|
-
import { wrapService, getServiceOptions, protectedMethods } from './service'
|
|
1
|
+
import version from './version'
|
|
2
|
+
import { EventEmitter } from 'events'
|
|
3
|
+
import { stripSlashes, createDebug } from '@feathersjs/commons'
|
|
4
|
+
import { hooks, middleware } from '@feathersjs/hooks'
|
|
5
|
+
import { eventHook, eventMixin } from './events'
|
|
6
|
+
import { hookMixin } from './hooks'
|
|
7
|
+
import { wrapService, getServiceOptions, protectedMethods } from './service'
|
|
8
8
|
import {
|
|
9
9
|
FeathersApplication,
|
|
10
10
|
ServiceMixin,
|
|
@@ -13,28 +13,26 @@ import {
|
|
|
13
13
|
ServiceInterface,
|
|
14
14
|
Application,
|
|
15
15
|
FeathersService,
|
|
16
|
-
HookMap,
|
|
17
16
|
ApplicationHookOptions
|
|
18
|
-
} from './declarations'
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
const debug = createDebug('@feathersjs/feathers')
|
|
22
|
-
|
|
23
|
-
export class Feathers<Services, Settings>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
constructor
|
|
36
|
-
super()
|
|
37
|
-
this.regularHooks = enableRegularHooks(this);
|
|
17
|
+
} from './declarations'
|
|
18
|
+
import { enableHooks } from './hooks'
|
|
19
|
+
|
|
20
|
+
const debug = createDebug('@feathersjs/feathers')
|
|
21
|
+
|
|
22
|
+
export class Feathers<Services, Settings>
|
|
23
|
+
extends EventEmitter
|
|
24
|
+
implements FeathersApplication<Services, Settings>
|
|
25
|
+
{
|
|
26
|
+
services: Services = {} as Services
|
|
27
|
+
settings: Settings = {} as Settings
|
|
28
|
+
mixins: ServiceMixin<Application<Services, Settings>>[] = [hookMixin, eventMixin]
|
|
29
|
+
version: string = version
|
|
30
|
+
_isSetup = false
|
|
31
|
+
|
|
32
|
+
protected registerHooks: (this: any, allHooks: any) => any
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super()
|
|
38
36
|
hooks(this, {
|
|
39
37
|
setup: middleware().params('server').props({
|
|
40
38
|
app: this
|
|
@@ -42,137 +40,148 @@ export class Feathers<Services, Settings> extends EventEmitter implements Feathe
|
|
|
42
40
|
teardown: middleware().params('server').props({
|
|
43
41
|
app: this
|
|
44
42
|
})
|
|
45
|
-
})
|
|
43
|
+
})
|
|
44
|
+
this.registerHooks = enableHooks(this)
|
|
45
|
+
this.registerHooks({
|
|
46
|
+
around: [eventHook]
|
|
47
|
+
})
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
get<L extends keyof Settings & string>
|
|
49
|
-
return this.settings[name]
|
|
50
|
+
get<L extends keyof Settings & string>(name: L): Settings[L] {
|
|
51
|
+
return this.settings[name]
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
set<L extends keyof Settings & string>
|
|
53
|
-
this.settings[name] = value
|
|
54
|
-
return this
|
|
54
|
+
set<L extends keyof Settings & string>(name: L, value: Settings[L]) {
|
|
55
|
+
this.settings[name] = value
|
|
56
|
+
return this
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
configure
|
|
58
|
-
callback.call(this, this)
|
|
59
|
+
configure(callback: (this: this, app: this) => void) {
|
|
60
|
+
callback.call(this, this)
|
|
59
61
|
|
|
60
|
-
return this
|
|
62
|
+
return this
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
defaultService
|
|
64
|
-
throw new Error(`Can not find service '${location}'`)
|
|
65
|
+
defaultService(location: string): ServiceInterface {
|
|
66
|
+
throw new Error(`Can not find service '${location}'`)
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
service<L extends keyof Services & string>
|
|
69
|
+
service<L extends keyof Services & string>(
|
|
68
70
|
location: L
|
|
69
71
|
): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]> {
|
|
70
|
-
const path = (stripSlashes(location) || '/') as L
|
|
71
|
-
const current = this.services[path]
|
|
72
|
+
const path = (stripSlashes(location) || '/') as L
|
|
73
|
+
const current = this.services[path]
|
|
72
74
|
|
|
73
75
|
if (typeof current === 'undefined') {
|
|
74
|
-
this.use(path, this.defaultService(path) as any)
|
|
75
|
-
return this.service(path)
|
|
76
|
+
this.use(path, this.defaultService(path) as any)
|
|
77
|
+
return this.service(path)
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
return current as any
|
|
80
|
+
return current as any
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
use<L extends keyof Services & string>
|
|
83
|
+
use<L extends keyof Services & string>(
|
|
82
84
|
path: L,
|
|
83
85
|
service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L],
|
|
84
86
|
options?: ServiceOptions
|
|
85
87
|
): this {
|
|
86
88
|
if (typeof path !== 'string') {
|
|
87
|
-
throw new Error(`'${path}' is not a valid service path.`)
|
|
89
|
+
throw new Error(`'${path}' is not a valid service path.`)
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
const location = (stripSlashes(path) || '/') as L
|
|
91
|
-
const subApp = service as Application
|
|
92
|
-
const isSubApp = typeof subApp.service === 'function' && subApp.services
|
|
92
|
+
const location = (stripSlashes(path) || '/') as L
|
|
93
|
+
const subApp = service as Application
|
|
94
|
+
const isSubApp = typeof subApp.service === 'function' && subApp.services
|
|
93
95
|
|
|
94
96
|
if (isSubApp) {
|
|
95
|
-
Object.keys(subApp.services).forEach(subPath =>
|
|
97
|
+
Object.keys(subApp.services).forEach((subPath) =>
|
|
96
98
|
this.use(`${location}/${subPath}` as any, subApp.service(subPath) as any)
|
|
97
|
-
)
|
|
99
|
+
)
|
|
98
100
|
|
|
99
|
-
return this
|
|
101
|
+
return this
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
const protoService = wrapService(location, service, options)
|
|
103
|
-
const serviceOptions = getServiceOptions(protoService)
|
|
104
|
+
const protoService = wrapService(location, service, options)
|
|
105
|
+
const serviceOptions = getServiceOptions(protoService)
|
|
104
106
|
|
|
105
107
|
for (const name of protectedMethods) {
|
|
106
108
|
if (serviceOptions.methods.includes(name)) {
|
|
107
|
-
throw new Error(`'${name}' on service '${location}' is not allowed as a custom method name`)
|
|
109
|
+
throw new Error(`'${name}' on service '${location}' is not allowed as a custom method name`)
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
debug(`Registering new service at \`${location}\``)
|
|
113
|
+
debug(`Registering new service at \`${location}\``)
|
|
112
114
|
|
|
113
115
|
// Add all the mixins
|
|
114
|
-
this.mixins.forEach(fn => fn.call(this, protoService, location, serviceOptions))
|
|
116
|
+
this.mixins.forEach((fn) => fn.call(this, protoService, location, serviceOptions))
|
|
115
117
|
|
|
116
|
-
this.services[location] = protoService
|
|
118
|
+
this.services[location] = protoService
|
|
117
119
|
|
|
118
120
|
// If we ran setup already, set this service up explicitly, this will not `await`
|
|
119
121
|
if (this._isSetup && typeof protoService.setup === 'function') {
|
|
120
|
-
debug(`Setting up service for \`${location}\``)
|
|
121
|
-
protoService.setup(this, location)
|
|
122
|
+
debug(`Setting up service for \`${location}\``)
|
|
123
|
+
protoService.setup(this, location)
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
return this
|
|
126
|
+
return this
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
hooks
|
|
128
|
-
const untypedMap = hookMap as any
|
|
129
|
+
hooks(hookMap: ApplicationHookOptions<this>) {
|
|
130
|
+
const untypedMap = hookMap as any
|
|
129
131
|
|
|
130
|
-
if (untypedMap.before || untypedMap.after || untypedMap.error) {
|
|
131
|
-
|
|
132
|
+
if (untypedMap.before || untypedMap.after || untypedMap.error || untypedMap.around) {
|
|
133
|
+
// regular hooks for all service methods
|
|
134
|
+
this.registerHooks(untypedMap)
|
|
132
135
|
} else if (untypedMap.setup || untypedMap.teardown) {
|
|
133
|
-
hooks
|
|
134
|
-
|
|
135
|
-
this.appHooks[HOOKS].push(...hookMap as any);
|
|
136
|
+
// .setup and .teardown application hooks
|
|
137
|
+
hooks(this, untypedMap)
|
|
136
138
|
} else {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.appHooks[key] = methodHooks.concat(methodHookMap[key]);
|
|
143
|
-
});
|
|
139
|
+
// Other registration formats are just `around` hooks
|
|
140
|
+
this.registerHooks({
|
|
141
|
+
around: untypedMap
|
|
142
|
+
})
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
return this
|
|
145
|
+
return this
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
setup
|
|
150
|
-
this._isSetup = true
|
|
148
|
+
setup() {
|
|
149
|
+
this._isSetup = true
|
|
151
150
|
|
|
152
|
-
return Object.keys(this.services)
|
|
153
|
-
.
|
|
154
|
-
|
|
151
|
+
return Object.keys(this.services)
|
|
152
|
+
.reduce(
|
|
153
|
+
(current, path) =>
|
|
154
|
+
current.then(() => {
|
|
155
|
+
const service: any = this.service(path as any)
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
if (typeof service.setup === 'function') {
|
|
158
|
+
debug(`Setting up service for \`${path}\``)
|
|
158
159
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
return service.setup(this, path)
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
Promise.resolve()
|
|
164
|
+
)
|
|
165
|
+
.then(() => this)
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
teardown
|
|
165
|
-
this._isSetup = false
|
|
168
|
+
teardown() {
|
|
169
|
+
this._isSetup = false
|
|
166
170
|
|
|
167
|
-
return Object.keys(this.services)
|
|
168
|
-
.
|
|
169
|
-
|
|
171
|
+
return Object.keys(this.services)
|
|
172
|
+
.reduce(
|
|
173
|
+
(current, path) =>
|
|
174
|
+
current.then(() => {
|
|
175
|
+
const service: any = this.service(path as any)
|
|
170
176
|
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
if (typeof service.teardown === 'function') {
|
|
178
|
+
debug(`Tearing down service for \`${path}\``)
|
|
173
179
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
return service.teardown(this, path)
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
Promise.resolve()
|
|
184
|
+
)
|
|
185
|
+
.then(() => this)
|
|
177
186
|
}
|
|
178
187
|
}
|