@feathersjs/memory 5.0.0-pre.17 → 5.0.0-pre.20
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 +45 -0
- package/README.md +1 -0
- package/lib/index.d.ts +55 -21
- package/lib/index.js +72 -34
- package/lib/index.js.map +1 -1
- package/package.json +17 -16
- package/src/index.ts +115 -44
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,51 @@
|
|
|
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.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **adapter-commons:** Clarify adapter query filtering ([#2607](https://github.com/feathersjs/feathers/issues/2607)) ([2dac771](https://github.com/feathersjs/feathers/commit/2dac771b0a3298d6dd25994d05186701b0617718))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **mongodb:** Add feathers-mongodb adapter as @feathersjs/mongodb ([#2610](https://github.com/feathersjs/feathers/issues/2610)) ([6d43734](https://github.com/feathersjs/feathers/commit/6d43734a53db02c435cafc52a22dca414e5d0940))
|
|
28
|
+
* **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5))
|
|
29
|
+
* **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
* **adapter-commons:** Changes the common adapter base class to use `sanitizeQuery` and `sanitizeData`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* **adapter-tests:** Add tests for pagination in multi updates ([#2472](https://github.com/feathersjs/feathers/issues/2472)) ([98a811a](https://github.com/feathersjs/feathers/commit/98a811ac605575ff812a08d0504729a5efe7a69c))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
6
51
|
# [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
|
|
7
52
|
|
|
8
53
|
**Note:** Version bump only for package @feathersjs/memory
|
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
4
4
|
[](https://www.npmjs.com/package/@feathersjs/memory)
|
|
5
|
+
[](https://discord.gg/qa8kez8QBx)
|
|
5
6
|
|
|
6
7
|
A [Feathers](https://feathersjs.com) service adapter for in-memory data storage that works on all platforms.
|
|
7
8
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,30 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NullableId, Id } from '@feathersjs/feathers';
|
|
1
|
+
import { AdapterBase, AdapterServiceOptions, PaginationOptions, AdapterParams } from '@feathersjs/adapter-commons';
|
|
2
|
+
import { NullableId, Id, Params, ServiceMethods, Paginated } from '@feathersjs/feathers';
|
|
3
3
|
export interface MemoryServiceStore<T> {
|
|
4
4
|
[key: string]: T;
|
|
5
5
|
}
|
|
6
|
-
export interface MemoryServiceOptions<T = any> extends
|
|
7
|
-
store
|
|
8
|
-
startId
|
|
6
|
+
export interface MemoryServiceOptions<T = any> extends AdapterServiceOptions {
|
|
7
|
+
store?: MemoryServiceStore<T>;
|
|
8
|
+
startId?: number;
|
|
9
9
|
matcher?: (query: any) => any;
|
|
10
10
|
sorter?: (sort: any) => any;
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
13
|
-
options: MemoryServiceOptions;
|
|
12
|
+
export declare class MemoryAdapter<T = any, D = Partial<T>, P extends Params = Params> extends AdapterBase<T, D, P, MemoryServiceOptions<T>> {
|
|
14
13
|
store: MemoryServiceStore<T>;
|
|
15
14
|
_uId: number;
|
|
16
|
-
constructor(options?:
|
|
17
|
-
getEntries(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
constructor(options?: MemoryServiceOptions<T>);
|
|
16
|
+
getEntries(_params?: P): Promise<T[]>;
|
|
17
|
+
getQuery(params: P): {
|
|
18
|
+
query: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
filters: {
|
|
22
|
+
$skip: any;
|
|
23
|
+
$sort: any;
|
|
24
|
+
$limit: any;
|
|
25
|
+
$select: any;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
$find(_params?: P & {
|
|
29
|
+
paginate?: PaginationOptions;
|
|
30
|
+
}): Promise<Paginated<T>>;
|
|
31
|
+
$find(_params?: P & {
|
|
32
|
+
paginate: false;
|
|
33
|
+
}): Promise<T[]>;
|
|
34
|
+
$find(_params?: P): Promise<Paginated<T> | T[]>;
|
|
35
|
+
$get(id: Id, params?: P): Promise<T>;
|
|
36
|
+
$create(data: Partial<D>, params?: P): Promise<T>;
|
|
37
|
+
$create(data: Partial<D>[], params?: P): Promise<T[]>;
|
|
38
|
+
$create(data: Partial<D> | Partial<D>[], _params?: P): Promise<T | T[]>;
|
|
39
|
+
$update(id: Id, data: D, params?: P): Promise<T>;
|
|
40
|
+
$patch(id: null, data: Partial<D>, params?: P): Promise<T[]>;
|
|
41
|
+
$patch(id: Id, data: Partial<D>, params?: P): Promise<T>;
|
|
42
|
+
$patch(id: NullableId, data: Partial<D>, _params?: P): Promise<T | T[]>;
|
|
43
|
+
$remove(id: null, params?: P): Promise<T[]>;
|
|
44
|
+
$remove(id: Id, params?: P): Promise<T>;
|
|
45
|
+
$remove(id: NullableId, _params?: P): Promise<T | T[]>;
|
|
46
|
+
}
|
|
47
|
+
export declare class MemoryService<T = any, D = Partial<T>, P extends AdapterParams = AdapterParams> extends MemoryAdapter<T, D, P> implements ServiceMethods<T | Paginated<T>, D, P> {
|
|
48
|
+
find(params?: P & {
|
|
49
|
+
paginate?: PaginationOptions;
|
|
50
|
+
}): Promise<Paginated<T>>;
|
|
51
|
+
find(params?: P & {
|
|
52
|
+
paginate: false;
|
|
53
|
+
}): Promise<T[]>;
|
|
54
|
+
find(params?: P): Promise<Paginated<T> | T[]>;
|
|
55
|
+
get(id: Id, params?: P): Promise<T>;
|
|
56
|
+
create(data: Partial<D>, params?: P): Promise<T>;
|
|
57
|
+
create(data: Partial<D>[], params?: P): Promise<T[]>;
|
|
58
|
+
update(id: Id, data: D, params?: P): Promise<T>;
|
|
59
|
+
patch(id: Id, data: Partial<D>, params?: P): Promise<T>;
|
|
60
|
+
patch(id: null, data: Partial<D>, params?: P): Promise<T[]>;
|
|
61
|
+
remove(id: Id, params?: P): Promise<T>;
|
|
62
|
+
remove(id: null, params?: P): Promise<T[]>;
|
|
29
63
|
}
|
|
30
|
-
export declare function memory(options?: Partial<MemoryServiceOptions
|
|
64
|
+
export declare function memory<T = any, D = Partial<T>, P extends Params = Params>(options?: Partial<MemoryServiceOptions<T>>): MemoryService<T, D, P>;
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.memory = exports.
|
|
6
|
+
exports.memory = exports.MemoryService = exports.MemoryAdapter = void 0;
|
|
7
7
|
const errors_1 = require("@feathersjs/errors");
|
|
8
8
|
const commons_1 = require("@feathersjs/commons");
|
|
9
9
|
const adapter_commons_1 = require("@feathersjs/adapter-commons");
|
|
@@ -12,25 +12,36 @@ const _select = (data, params, ...args) => {
|
|
|
12
12
|
const base = (0, adapter_commons_1.select)(params, ...args);
|
|
13
13
|
return base(JSON.parse(JSON.stringify(data)));
|
|
14
14
|
};
|
|
15
|
-
class
|
|
15
|
+
class MemoryAdapter extends adapter_commons_1.AdapterBase {
|
|
16
16
|
constructor(options = {}) {
|
|
17
|
-
super(
|
|
17
|
+
super({
|
|
18
18
|
id: 'id',
|
|
19
19
|
matcher: sift_1.default,
|
|
20
|
-
sorter: adapter_commons_1.sorter
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
sorter: adapter_commons_1.sorter,
|
|
21
|
+
store: {},
|
|
22
|
+
startId: 0,
|
|
23
|
+
...options
|
|
24
|
+
});
|
|
25
|
+
this._uId = this.options.startId;
|
|
26
|
+
this.store = { ...this.options.store };
|
|
24
27
|
}
|
|
25
|
-
async getEntries(
|
|
26
|
-
const
|
|
27
|
-
return this
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
28
|
+
async getEntries(_params) {
|
|
29
|
+
const params = _params || {};
|
|
30
|
+
return this.$find({
|
|
31
|
+
...params,
|
|
32
|
+
paginate: false
|
|
33
|
+
});
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
const {
|
|
35
|
+
getQuery(params) {
|
|
36
|
+
const { $skip, $sort, $limit, $select, ...query } = params.query || {};
|
|
37
|
+
return {
|
|
38
|
+
query,
|
|
39
|
+
filters: { $skip, $sort, $limit, $select }
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async $find(params = {}) {
|
|
43
|
+
const { paginate } = this.getOptions(params);
|
|
44
|
+
const { query, filters } = this.getQuery(params);
|
|
34
45
|
let values = commons_1._.values(this.store).filter(this.options.matcher(query));
|
|
35
46
|
const total = values.length;
|
|
36
47
|
if (filters.$sort !== undefined) {
|
|
@@ -48,14 +59,14 @@ class Service extends adapter_commons_1.AdapterService {
|
|
|
48
59
|
skip: filters.$skip || 0,
|
|
49
60
|
data: values.map(value => _select(value, params))
|
|
50
61
|
};
|
|
51
|
-
if (!
|
|
62
|
+
if (!paginate) {
|
|
52
63
|
return result.data;
|
|
53
64
|
}
|
|
54
65
|
return result;
|
|
55
66
|
}
|
|
56
|
-
async
|
|
67
|
+
async $get(id, params = {}) {
|
|
68
|
+
const { query } = this.getQuery(params);
|
|
57
69
|
if (id in this.store) {
|
|
58
|
-
const { query } = this.filterQuery(params);
|
|
59
70
|
const value = this.store[id];
|
|
60
71
|
if (this.options.matcher(query)(value)) {
|
|
61
72
|
return _select(value, params, this.id);
|
|
@@ -63,51 +74,78 @@ class Service extends adapter_commons_1.AdapterService {
|
|
|
63
74
|
}
|
|
64
75
|
throw new errors_1.NotFound(`No record found for id '${id}'`);
|
|
65
76
|
}
|
|
66
|
-
|
|
67
|
-
async _create(data, params = {}) {
|
|
77
|
+
async $create(data, params = {}) {
|
|
68
78
|
if (Array.isArray(data)) {
|
|
69
|
-
return Promise.all(data.map(current => this
|
|
79
|
+
return Promise.all(data.map(current => this.$create(current, params)));
|
|
70
80
|
}
|
|
71
81
|
const id = data[this.id] || this._uId++;
|
|
72
82
|
const current = commons_1._.extend({}, data, { [this.id]: id });
|
|
73
83
|
const result = (this.store[id] = current);
|
|
74
84
|
return _select(result, params, this.id);
|
|
75
85
|
}
|
|
76
|
-
async
|
|
77
|
-
const oldEntry = await this
|
|
86
|
+
async $update(id, data, params = {}) {
|
|
87
|
+
const oldEntry = await this.$get(id);
|
|
78
88
|
// We don't want our id to change type if it can be coerced
|
|
79
89
|
const oldId = oldEntry[this.id];
|
|
80
90
|
// eslint-disable-next-line eqeqeq
|
|
81
91
|
id = oldId == id ? oldId : id;
|
|
82
92
|
this.store[id] = commons_1._.extend({}, data, { [this.id]: id });
|
|
83
|
-
return this
|
|
93
|
+
return this.$get(id, params);
|
|
84
94
|
}
|
|
85
|
-
async
|
|
95
|
+
async $patch(id, data, params = {}) {
|
|
96
|
+
const { query } = this.getQuery(params);
|
|
86
97
|
const patchEntry = (entry) => {
|
|
87
98
|
const currentId = entry[this.id];
|
|
88
99
|
this.store[currentId] = commons_1._.extend(this.store[currentId], commons_1._.omit(data, this.id));
|
|
89
100
|
return _select(this.store[currentId], params, this.id);
|
|
90
101
|
};
|
|
91
102
|
if (id === null) {
|
|
92
|
-
const entries = await this.getEntries(
|
|
103
|
+
const entries = await this.getEntries({
|
|
104
|
+
...params,
|
|
105
|
+
query
|
|
106
|
+
});
|
|
93
107
|
return entries.map(patchEntry);
|
|
94
108
|
}
|
|
95
|
-
return patchEntry(await this
|
|
109
|
+
return patchEntry(await this.$get(id, params)); // Will throw an error if not found
|
|
96
110
|
}
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
async $remove(id, params = {}) {
|
|
112
|
+
const { query } = this.getQuery(params);
|
|
99
113
|
if (id === null) {
|
|
100
|
-
const entries = await this.getEntries(
|
|
101
|
-
|
|
114
|
+
const entries = await this.getEntries({
|
|
115
|
+
...params,
|
|
116
|
+
query
|
|
117
|
+
});
|
|
118
|
+
return Promise.all(entries.map((current) => this.$remove(current[this.id], params)));
|
|
102
119
|
}
|
|
103
|
-
const entry = await this
|
|
120
|
+
const entry = await this.$get(id, params);
|
|
104
121
|
delete this.store[id];
|
|
105
122
|
return entry;
|
|
106
123
|
}
|
|
107
124
|
}
|
|
108
|
-
exports.
|
|
125
|
+
exports.MemoryAdapter = MemoryAdapter;
|
|
126
|
+
class MemoryService extends MemoryAdapter {
|
|
127
|
+
async find(params) {
|
|
128
|
+
return this._find(params);
|
|
129
|
+
}
|
|
130
|
+
async get(id, params) {
|
|
131
|
+
return this._get(id, params);
|
|
132
|
+
}
|
|
133
|
+
async create(data, params) {
|
|
134
|
+
return this._create(data, params);
|
|
135
|
+
}
|
|
136
|
+
async update(id, data, params) {
|
|
137
|
+
return this._update(id, data, params);
|
|
138
|
+
}
|
|
139
|
+
async patch(id, data, params) {
|
|
140
|
+
return this._patch(id, data, params);
|
|
141
|
+
}
|
|
142
|
+
async remove(id, params) {
|
|
143
|
+
return this._remove(id, params);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.MemoryService = MemoryService;
|
|
109
147
|
function memory(options = {}) {
|
|
110
|
-
return new
|
|
148
|
+
return new MemoryService(options);
|
|
111
149
|
}
|
|
112
150
|
exports.memory = memory;
|
|
113
151
|
//# 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":";;;;;;AAAA,+CAA8C;AAC9C,iDAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA8C;AAC9C,iDAAwC;AACxC,iEAAmI;AACnI,gDAAwB;AAcxB,MAAM,OAAO,GAAG,CAAC,IAAS,EAAE,MAAW,EAAE,GAAG,IAAW,EAAE,EAAE;IACzD,MAAM,IAAI,GAAG,IAAA,wBAAM,EAAC,MAAM,EA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,CAAC;IACvC,CAAC;IAID,KAAK,CAAC,MAAM,CAAE,EAAc,EAAE,MAAU;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;CACF;AAlCD,sCAkCC;AAED,SAAgB,MAAM,CACpB,UAA4C,EAAE;IAE9C,OAAO,IAAI,aAAa,CAAU,OAAO,CAAC,CAAA;AAC5C,CAAC;AAJD,wBAIC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/memory",
|
|
3
3
|
"description": "An in memory service store",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.20",
|
|
5
5
|
"homepage": "https://github.com/feathersjs/feathers",
|
|
6
6
|
"main": "lib/",
|
|
7
|
+
"types": "lib/",
|
|
7
8
|
"keywords": [
|
|
8
9
|
"feathers",
|
|
9
10
|
"feathers-plugin"
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
14
|
-
"url": "git://github.com/feathersjs/feathers.git"
|
|
15
|
+
"url": "git://github.com/feathersjs/feathers.git",
|
|
16
|
+
"directory": "packages/memory"
|
|
15
17
|
},
|
|
16
18
|
"author": {
|
|
17
19
|
"name": "Feathers contributors",
|
|
@@ -36,8 +38,7 @@
|
|
|
36
38
|
"scripts": {
|
|
37
39
|
"prepublish": "npm run compile",
|
|
38
40
|
"compile": "shx rm -rf lib/ && tsc",
|
|
39
|
-
"test": "
|
|
40
|
-
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
|
41
|
+
"test": "mocha --config ../../.mocharc.json --recursive test/**/*.test.ts"
|
|
41
42
|
},
|
|
42
43
|
"publishConfig": {
|
|
43
44
|
"access": "public"
|
|
@@ -46,20 +47,20 @@
|
|
|
46
47
|
"lib": "lib"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@feathersjs/adapter-commons": "^5.0.0-pre.
|
|
50
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
51
|
-
"@feathersjs/errors": "^5.0.0-pre.
|
|
52
|
-
"sift": "^
|
|
50
|
+
"@feathersjs/adapter-commons": "^5.0.0-pre.20",
|
|
51
|
+
"@feathersjs/commons": "^5.0.0-pre.20",
|
|
52
|
+
"@feathersjs/errors": "^5.0.0-pre.20",
|
|
53
|
+
"sift": "^16.0.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@feathersjs/adapter-tests": "^5.0.0-pre.
|
|
56
|
-
"@feathersjs/feathers": "^5.0.0-pre.
|
|
57
|
-
"@types/mocha": "^9.1.
|
|
58
|
-
"@types/node": "^17.0.
|
|
59
|
-
"mocha": "^
|
|
56
|
+
"@feathersjs/adapter-tests": "^5.0.0-pre.20",
|
|
57
|
+
"@feathersjs/feathers": "^5.0.0-pre.20",
|
|
58
|
+
"@types/mocha": "^9.1.1",
|
|
59
|
+
"@types/node": "^17.0.31",
|
|
60
|
+
"mocha": "^10.0.0",
|
|
60
61
|
"shx": "^0.3.4",
|
|
61
|
-
"ts-node": "^10.
|
|
62
|
-
"typescript": "^4.
|
|
62
|
+
"ts-node": "^10.7.0",
|
|
63
|
+
"typescript": "^4.6.4"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "54de749a0b392c7da726c668002b50cafaca530c"
|
|
65
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { NotFound } from '@feathersjs/errors';
|
|
2
2
|
import { _ } from '@feathersjs/commons';
|
|
3
|
-
import { sorter, select,
|
|
3
|
+
import { sorter, select, AdapterBase, AdapterServiceOptions, PaginationOptions, AdapterParams } from '@feathersjs/adapter-commons';
|
|
4
4
|
import sift from 'sift';
|
|
5
|
-
import { NullableId, Id } from '@feathersjs/feathers';
|
|
5
|
+
import { NullableId, Id, Params, ServiceMethods, Paginated } from '@feathersjs/feathers';
|
|
6
6
|
|
|
7
7
|
export interface MemoryServiceStore<T> {
|
|
8
8
|
[key: string]: T;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface MemoryServiceOptions<T = any> extends
|
|
12
|
-
store
|
|
13
|
-
startId
|
|
11
|
+
export interface MemoryServiceOptions<T = any> extends AdapterServiceOptions {
|
|
12
|
+
store?: MemoryServiceStore<T>;
|
|
13
|
+
startId?: number;
|
|
14
14
|
matcher?: (query: any) => any;
|
|
15
15
|
sorter?: (sort: any) => any;
|
|
16
16
|
}
|
|
@@ -21,32 +21,48 @@ const _select = (data: any, params: any, ...args: any[]) => {
|
|
|
21
21
|
return base(JSON.parse(JSON.stringify(data)));
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export class
|
|
25
|
-
options: MemoryServiceOptions;
|
|
24
|
+
export class MemoryAdapter<T = any, D = Partial<T>, P extends Params = Params> extends AdapterBase<T, D, P, MemoryServiceOptions<T>> {
|
|
26
25
|
store: MemoryServiceStore<T>;
|
|
27
26
|
_uId: number;
|
|
28
27
|
|
|
29
|
-
constructor (options:
|
|
30
|
-
super(
|
|
28
|
+
constructor (options: MemoryServiceOptions<T> = {}) {
|
|
29
|
+
super({
|
|
31
30
|
id: 'id',
|
|
32
31
|
matcher: sift,
|
|
33
|
-
sorter
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
sorter,
|
|
33
|
+
store: {},
|
|
34
|
+
startId: 0,
|
|
35
|
+
...options
|
|
36
|
+
});
|
|
37
|
+
this._uId = this.options.startId;
|
|
38
|
+
this.store = { ...this.options.store };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getEntries (_params?: P) {
|
|
42
|
+
const params = _params || {} as P;
|
|
43
|
+
|
|
44
|
+
return this.$find({
|
|
45
|
+
...params,
|
|
46
|
+
paginate: false
|
|
47
|
+
});
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
const { query } =
|
|
50
|
+
getQuery (params: P) {
|
|
51
|
+
const { $skip, $sort, $limit, $select, ...query } = params.query || {};
|
|
41
52
|
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
53
|
+
return {
|
|
54
|
+
query,
|
|
55
|
+
filters: { $skip, $sort, $limit, $select }
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
async
|
|
49
|
-
|
|
59
|
+
async $find (_params?: P & { paginate?: PaginationOptions }): Promise<Paginated<T>>;
|
|
60
|
+
async $find (_params?: P & { paginate: false }): Promise<T[]>;
|
|
61
|
+
async $find (_params?: P): Promise<Paginated<T>|T[]>;
|
|
62
|
+
async $find (params: P = {} as P): Promise<Paginated<T>|T[]> {
|
|
63
|
+
const { paginate } = this.getOptions(params);
|
|
64
|
+
const { query, filters } = this.getQuery(params);
|
|
65
|
+
|
|
50
66
|
let values = _.values(this.store).filter(this.options.matcher(query));
|
|
51
67
|
const total = values.length;
|
|
52
68
|
|
|
@@ -62,23 +78,24 @@ export class Service<T = any, D = Partial<T>> extends AdapterService<T, D> imple
|
|
|
62
78
|
values = values.slice(0, filters.$limit);
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
const result = {
|
|
81
|
+
const result: Paginated<T> = {
|
|
66
82
|
total,
|
|
67
83
|
limit: filters.$limit,
|
|
68
84
|
skip: filters.$skip || 0,
|
|
69
85
|
data: values.map(value => _select(value, params))
|
|
70
86
|
};
|
|
71
87
|
|
|
72
|
-
if (!
|
|
88
|
+
if (!paginate) {
|
|
73
89
|
return result.data;
|
|
74
90
|
}
|
|
75
91
|
|
|
76
92
|
return result;
|
|
77
93
|
}
|
|
78
94
|
|
|
79
|
-
async
|
|
95
|
+
async $get (id: Id, params: P = {} as P): Promise<T> {
|
|
96
|
+
const { query } = this.getQuery(params);
|
|
97
|
+
|
|
80
98
|
if (id in this.store) {
|
|
81
|
-
const { query } = this.filterQuery(params);
|
|
82
99
|
const value = this.store[id];
|
|
83
100
|
|
|
84
101
|
if (this.options.matcher(query)(value)) {
|
|
@@ -89,33 +106,39 @@ export class Service<T = any, D = Partial<T>> extends AdapterService<T, D> imple
|
|
|
89
106
|
throw new NotFound(`No record found for id '${id}'`);
|
|
90
107
|
}
|
|
91
108
|
|
|
92
|
-
|
|
93
|
-
async
|
|
109
|
+
async $create (data: Partial<D>, params?: P): Promise<T>;
|
|
110
|
+
async $create (data: Partial<D>[], params?: P): Promise<T[]>;
|
|
111
|
+
async $create (data: Partial<D>|Partial<D>[], _params?: P): Promise<T|T[]>;
|
|
112
|
+
async $create (data: Partial<D>|Partial<D>[], params: P = {} as P): Promise<T|T[]> {
|
|
94
113
|
if (Array.isArray(data)) {
|
|
95
|
-
return Promise.all(data.map(current => this
|
|
114
|
+
return Promise.all(data.map(current => this.$create(current, params)));
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
const id = (data as any)[this.id] || this._uId++;
|
|
99
118
|
const current = _.extend({}, data, { [this.id]: id });
|
|
100
119
|
const result = (this.store[id] = current);
|
|
101
120
|
|
|
102
|
-
return _select(result, params, this.id);
|
|
121
|
+
return _select(result, params, this.id) as T;
|
|
103
122
|
}
|
|
104
123
|
|
|
105
|
-
async
|
|
106
|
-
const oldEntry = await this
|
|
124
|
+
async $update (id: Id, data: D, params: P = {} as P): Promise<T> {
|
|
125
|
+
const oldEntry = await this.$get(id);
|
|
107
126
|
// We don't want our id to change type if it can be coerced
|
|
108
|
-
const oldId = oldEntry[this.id];
|
|
127
|
+
const oldId = (oldEntry as any)[this.id];
|
|
109
128
|
|
|
110
129
|
// eslint-disable-next-line eqeqeq
|
|
111
130
|
id = oldId == id ? oldId : id;
|
|
112
131
|
|
|
113
132
|
this.store[id] = _.extend({}, data, { [this.id]: id });
|
|
114
133
|
|
|
115
|
-
return this
|
|
134
|
+
return this.$get(id, params);
|
|
116
135
|
}
|
|
117
136
|
|
|
118
|
-
async
|
|
137
|
+
async $patch (id: null, data: Partial<D>, params?: P): Promise<T[]>;
|
|
138
|
+
async $patch (id: Id, data: Partial<D>, params?: P): Promise<T>;
|
|
139
|
+
async $patch (id: NullableId, data: Partial<D>, _params?: P): Promise<T|T[]>;
|
|
140
|
+
async $patch (id: NullableId, data: Partial<D>, params: P = {} as P): Promise<T|T[]> {
|
|
141
|
+
const { query } = this.getQuery(params);
|
|
119
142
|
const patchEntry = (entry: T) => {
|
|
120
143
|
const currentId = (entry as any)[this.id];
|
|
121
144
|
|
|
@@ -125,25 +148,35 @@ export class Service<T = any, D = Partial<T>> extends AdapterService<T, D> imple
|
|
|
125
148
|
};
|
|
126
149
|
|
|
127
150
|
if (id === null) {
|
|
128
|
-
const entries = await this.getEntries(
|
|
151
|
+
const entries = await this.getEntries({
|
|
152
|
+
...params,
|
|
153
|
+
query
|
|
154
|
+
});
|
|
129
155
|
|
|
130
156
|
return entries.map(patchEntry);
|
|
131
157
|
}
|
|
132
158
|
|
|
133
|
-
return patchEntry(await this
|
|
159
|
+
return patchEntry(await this.$get(id, params)); // Will throw an error if not found
|
|
134
160
|
}
|
|
135
161
|
|
|
136
|
-
|
|
137
|
-
async
|
|
162
|
+
async $remove (id: null, params?: P): Promise<T[]>;
|
|
163
|
+
async $remove (id: Id, params?: P): Promise<T>;
|
|
164
|
+
async $remove (id: NullableId, _params?: P): Promise<T|T[]>;
|
|
165
|
+
async $remove (id: NullableId, params: P = {} as P): Promise<T|T[]> {
|
|
166
|
+
const { query } = this.getQuery(params);
|
|
167
|
+
|
|
138
168
|
if (id === null) {
|
|
139
|
-
const entries = await this.getEntries(
|
|
169
|
+
const entries = await this.getEntries({
|
|
170
|
+
...params,
|
|
171
|
+
query
|
|
172
|
+
});
|
|
140
173
|
|
|
141
|
-
return Promise.all(entries.map(current =>
|
|
142
|
-
this
|
|
174
|
+
return Promise.all(entries.map((current: any) =>
|
|
175
|
+
this.$remove(current[this.id] as Id, params)
|
|
143
176
|
));
|
|
144
177
|
}
|
|
145
178
|
|
|
146
|
-
const entry = await this
|
|
179
|
+
const entry = await this.$get(id, params);
|
|
147
180
|
|
|
148
181
|
delete this.store[id];
|
|
149
182
|
|
|
@@ -151,6 +184,44 @@ export class Service<T = any, D = Partial<T>> extends AdapterService<T, D> imple
|
|
|
151
184
|
}
|
|
152
185
|
}
|
|
153
186
|
|
|
154
|
-
export
|
|
155
|
-
|
|
187
|
+
export class MemoryService<T = any, D = Partial<T>, P extends AdapterParams = AdapterParams>
|
|
188
|
+
extends MemoryAdapter<T, D, P> implements ServiceMethods<T|Paginated<T>, D, P> {
|
|
189
|
+
async find (params?: P & { paginate?: PaginationOptions }): Promise<Paginated<T>>;
|
|
190
|
+
async find (params?: P & { paginate: false }): Promise<T[]>;
|
|
191
|
+
async find (params?: P): Promise<Paginated<T>|T[]>;
|
|
192
|
+
async find (params?: P): Promise<Paginated<T>|T[]> {
|
|
193
|
+
return this._find(params) as any;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async get (id: Id, params?: P): Promise<T> {
|
|
197
|
+
return this._get(id, params);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async create (data: Partial<D>, params?: P): Promise<T>;
|
|
201
|
+
async create (data: Partial<D>[], params?: P): Promise<T[]>;
|
|
202
|
+
async create (data: Partial<D>|Partial<D>[], params?: P): Promise<T|T[]> {
|
|
203
|
+
return this._create(data, params);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async update (id: Id, data: D, params?: P): Promise<T> {
|
|
207
|
+
return this._update(id, data, params);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async patch (id: Id, data: Partial<D>, params?: P): Promise<T>;
|
|
211
|
+
async patch (id: null, data: Partial<D>, params?: P): Promise<T[]>;
|
|
212
|
+
async patch (id: NullableId, data: Partial<D>, params?: P): Promise<T | T[]> {
|
|
213
|
+
return this._patch(id, data, params);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async remove (id: Id, params?: P): Promise<T>;
|
|
217
|
+
async remove (id: null, params?: P): Promise<T[]>;
|
|
218
|
+
async remove (id: NullableId, params?: P): Promise<T | T[]> {
|
|
219
|
+
return this._remove(id, params);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function memory<T = any, D = Partial<T>, P extends Params = Params> (
|
|
224
|
+
options: Partial<MemoryServiceOptions<T>> = {}
|
|
225
|
+
) {
|
|
226
|
+
return new MemoryService<T, D, P>(options)
|
|
156
227
|
}
|