@feathersjs/adapter-commons 5.0.0-pre.2 → 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 CHANGED
@@ -3,7 +3,193 @@
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.2](https://github.com/feathersjs/databases/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
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
+ ### Features
44
+
45
+ * **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023))
46
+ * **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa))
47
+
48
+
49
+
50
+
51
+
52
+ # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
53
+
54
+ **Note:** Version bump only for package @feathersjs/adapter-commons
55
+
56
+
57
+
58
+
59
+
60
+ # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
61
+
62
+ **Note:** Version bump only for package @feathersjs/adapter-commons
63
+
64
+
65
+
66
+
67
+
68
+ # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * **adapter-commons:** clean up in sort.ts and select function ([#2492](https://github.com/feathersjs/feathers/issues/2492)) ([c3ec8a4](https://github.com/feathersjs/feathers/commit/c3ec8a418bdc85506e3c5100015720a45454d8d3))
74
+ * **adapter-commons:** Fix sorting for embedded objects ([#2488](https://github.com/feathersjs/feathers/issues/2488)) ([9c22f70](https://github.com/feathersjs/feathers/commit/9c22f70a838cb6341775d91705a7527c8fc5590e))
75
+ * **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
76
+
77
+
78
+
79
+
80
+
81
+ # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
82
+
83
+ **Note:** Version bump only for package @feathersjs/adapter-commons
84
+
85
+
86
+
87
+
88
+
89
+ # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
90
+
91
+ **Note:** Version bump only for package @feathersjs/adapter-commons
92
+
93
+
94
+
95
+
96
+
97
+ # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
98
+
99
+ **Note:** Version bump only for package @feathersjs/adapter-commons
100
+
101
+
102
+
103
+
104
+
105
+ # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
106
+
107
+ **Note:** Version bump only for package @feathersjs/adapter-commons
108
+
109
+
110
+
111
+
112
+
113
+ # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
114
+
115
+ **Note:** Version bump only for package @feathersjs/adapter-commons
116
+
117
+
118
+
119
+
120
+
121
+ # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
122
+
123
+ **Note:** Version bump only for package @feathersjs/adapter-commons
124
+
125
+
126
+
127
+
128
+
129
+ # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
130
+
131
+ **Note:** Version bump only for package @feathersjs/adapter-commons
132
+
133
+
134
+
135
+
136
+
137
+ # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
138
+
139
+ **Note:** Version bump only for package @feathersjs/adapter-commons
140
+
141
+
142
+
143
+
144
+
145
+ # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
146
+
147
+ **Note:** Version bump only for package @feathersjs/adapter-commons
148
+
149
+
150
+
151
+
152
+
153
+ # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
154
+
155
+
156
+ ### Bug Fixes
157
+
158
+ * Update database adapter common repository urls ([#2380](https://github.com/feathersjs/feathers/issues/2380)) ([3f4db68](https://github.com/feathersjs/feathers/commit/3f4db68d6700c7d9023ecd17d0d39893f75a19fd))
159
+
160
+
161
+ ### Features
162
+
163
+ * **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f))
164
+ * **typescript:** Allow to pass generic service options to adapter services ([#2392](https://github.com/feathersjs/feathers/issues/2392)) ([f9431f2](https://github.com/feathersjs/feathers/commit/f9431f242354f804cafb835519f98dd405ac4f0b))
165
+
166
+
167
+
168
+
169
+
170
+ # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
171
+
172
+
173
+ ### Bug Fixes
174
+
175
+ * **typescript:** Move Paginated type back for better compatibility ([#2350](https://github.com/feathersjs/feathers/issues/2350)) ([2917d05](https://github.com/feathersjs/feathers/commit/2917d05fffb4716d3c4cdaa5ac6a1aee0972e8a6))
176
+
177
+
178
+
179
+
180
+
181
+ # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
182
+
183
+
184
+ ### Bug Fixes
185
+
186
+ * **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
187
+
188
+
189
+
190
+
191
+
192
+ # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
7
193
 
8
194
  **Note:** Version bump only for package @feathersjs/adapter-commons
9
195
 
@@ -11,52 +197,52 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
197
 
12
198
 
13
199
 
14
- # [5.0.0-beta.1](https://github.com/feathersjs/databases/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03)
200
+ # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03)
15
201
 
16
202
 
17
203
  ### Bug Fixes
18
204
 
19
- * **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/databases/issues/2284)) ([05b03b2](https://github.com/feathersjs/databases/commit/05b03b27b40604d956047e3021d8053c3a137616))
205
+ * **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616))
20
206
 
21
207
 
22
208
  ### Features
23
209
 
24
- * **adapter-commons:** Added mongoDB like search in embedded objects ([687e3c7](https://github.com/feathersjs/databases/commit/687e3c7c36904221b2707d0220c0893e3cb1faa9))
210
+ * **adapter-commons:** Added mongoDB like search in embedded objects ([687e3c7](https://github.com/feathersjs/feathers/commit/687e3c7c36904221b2707d0220c0893e3cb1faa9))
25
211
 
26
212
 
27
213
 
28
214
 
29
215
 
30
- # [5.0.0-beta.0](https://github.com/feathersjs/databases/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28)
216
+ # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28)
31
217
 
32
218
 
33
219
  ### Bug Fixes
34
220
 
35
- * **adapter-commons:** Always respect paginate.max ([#2267](https://github.com/feathersjs/databases/issues/2267)) ([f588257](https://github.com/feathersjs/databases/commit/f5882575536624ed3a32bb6e3ff1919fa17e366d))
36
- * Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/databases/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/databases/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60))
37
- * **adapter-commons:** Return missing overloads ([#2203](https://github.com/feathersjs/databases/issues/2203)) ([bbe7e2a](https://github.com/feathersjs/databases/commit/bbe7e2a131633e9a6e7aac7f7fa02a312bca63c7))
221
+ * **adapter-commons:** Always respect paginate.max ([#2267](https://github.com/feathersjs/feathers/issues/2267)) ([f588257](https://github.com/feathersjs/feathers/commit/f5882575536624ed3a32bb6e3ff1919fa17e366d))
222
+ * Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60))
223
+ * **adapter-commons:** Return missing overloads ([#2203](https://github.com/feathersjs/feathers/issues/2203)) ([bbe7e2a](https://github.com/feathersjs/feathers/commit/bbe7e2a131633e9a6e7aac7f7fa02a312bca63c7))
38
224
 
39
225
 
40
226
  ### Features
41
227
 
42
- * Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/databases/issues/2255)) ([2dafb7c](https://github.com/feathersjs/databases/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9))
228
+ * Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9))
43
229
 
44
230
 
45
231
 
46
232
 
47
233
 
48
- # [5.0.0-pre.1](https://github.com/feathersjs/databases/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
234
+ # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
49
235
 
50
236
 
51
237
  ### Features
52
238
 
53
- * **memory:** Move feathers-memory into @feathersjs/adapter-memory ([#2153](https://github.com/feathersjs/databases/issues/2153)) ([dd61fe3](https://github.com/feathersjs/databases/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6))
239
+ * **memory:** Move feathers-memory into @feathersjs/memory ([#2153](https://github.com/feathersjs/feathers/issues/2153)) ([dd61fe3](https://github.com/feathersjs/feathers/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6))
54
240
 
55
241
 
56
242
 
57
243
 
58
244
 
59
- ## [4.5.11](https://github.com/feathersjs/databases/compare/v4.5.10...v4.5.11) (2020-12-05)
245
+ ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05)
60
246
 
61
247
  **Note:** Version bump only for package @feathersjs/adapter-commons
62
248
 
@@ -64,7 +250,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
64
250
 
65
251
 
66
252
 
67
- ## [4.5.7](https://github.com/feathersjs/databases/compare/@feathersjs/adapter-commons@4.5.6...@feathersjs/adapter-commons@4.5.7) (2020-10-21)
253
+ ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-10-21)
68
254
 
69
255
 
70
256
  ### Bug Fixes
@@ -75,7 +261,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
75
261
 
76
262
 
77
263
 
78
- ## [4.5.6](https://github.com/feathersjs/databases/compare/@feathersjs/adapter-commons@4.5.5...@feathersjs/adapter-commons@4.5.6) (2020-10-21)
264
+ ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-10-21)
79
265
 
80
266
 
81
267
  ### Bug Fixes
@@ -86,7 +272,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
86
272
 
87
273
 
88
274
 
89
- ## [4.5.5](https://github.com/feathersjs/databases/compare/@feathersjs/adapter-commons@4.5.4...@feathersjs/adapter-commons@4.5.5) (2020-10-21)
275
+ ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-10-21)
90
276
 
91
277
 
92
278
  ### Bug Fixes
@@ -97,7 +283,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
97
283
 
98
284
 
99
285
 
100
- ## [4.5.4](https://github.com/feathersjs/databases/compare/@feathersjs/adapter-commons@4.5.3...@feathersjs/adapter-commons@4.5.4) (2020-09-27)
286
+ ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-09-27)
101
287
 
102
288
  **Note:** Version bump only for package @feathersjs/adapter-commons
103
289
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Feathers
3
+ Copyright (c) 2022 Feathers
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Feathers Adapter Commons
2
2
 
3
3
  [![CI](https://github.com/feathersjs/feathers/workflows/Node.js%20CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3A%22Node.js+CI%22)
4
- [![Dependency Status](https://img.shields.io/david/feathersjs/feathers.svg?style=flat-square&path=packages/adapter-commons)](https://david-dm.org/feathersjs/feathers?path=packages/adapter-commons)
5
4
  [![Download Status](https://img.shields.io/npm/dm/@feathersjs/adapter-commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/adapter-commons)
5
+ [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx)
6
6
 
7
7
  > Shared utility functions for Feathers adatabase adapters
8
8
 
@@ -17,6 +17,6 @@ This is a repository for handling Feathers common database syntax. See the [API
17
17
 
18
18
  ## License
19
19
 
20
- Copyright (c) 2021 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
20
+ Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
21
21
 
22
22
  Licensed under the [MIT license](LICENSE).
@@ -0,0 +1,146 @@
1
+ import { Query, Params, Paginated, Id, NullableId } from '@feathersjs/feathers';
2
+ export declare type FilterQueryOptions = {
3
+ filters?: FilterSettings;
4
+ operators?: string[];
5
+ paginate?: PaginationParams;
6
+ };
7
+ export declare type QueryFilter = (value: any, options: FilterQueryOptions) => any;
8
+ export declare type FilterSettings = {
9
+ [key: string]: QueryFilter | true;
10
+ };
11
+ export interface PaginationOptions {
12
+ default?: number;
13
+ max?: number;
14
+ }
15
+ export declare type PaginationParams = false | PaginationOptions;
16
+ export interface AdapterServiceOptions {
17
+ /**
18
+ * Whether to allow multiple updates for everything (`true`) or specific methods (e.g. `['create', 'remove']`)
19
+ */
20
+ multi?: boolean | string[];
21
+ /**
22
+ * The name of the id property
23
+ */
24
+ id?: string;
25
+ /**
26
+ * Pagination settings for this service
27
+ */
28
+ paginate?: PaginationParams;
29
+ /**
30
+ * A list of additional property query operators to allow in a query
31
+ */
32
+ operators?: string[];
33
+ /**
34
+ * An object of additional top level query filters, e.g. `{ $populate: true }`
35
+ * Can also be a converter function like `{ $ignoreCase: (value) => value === 'true' ? true : false }`
36
+ */
37
+ filters?: FilterSettings;
38
+ /**
39
+ * @deprecated Use service `events` option when registering the service with `app.use`.
40
+ */
41
+ events?: string[];
42
+ /**
43
+ * @deprecated renamed to `operators`.
44
+ */
45
+ whitelist?: string[];
46
+ }
47
+ export interface AdapterQuery extends Query {
48
+ $limit?: number;
49
+ $skip?: number;
50
+ $select?: string[];
51
+ $sort?: {
52
+ [key: string]: 1 | -1;
53
+ };
54
+ }
55
+ /**
56
+ * Additional `params` that can be passed to an adapter service method call.
57
+ */
58
+ export interface AdapterParams<Q = AdapterQuery, A extends Partial<AdapterServiceOptions> = Partial<AdapterServiceOptions>> extends Params<Q> {
59
+ adapter?: A;
60
+ paginate?: PaginationParams;
61
+ }
62
+ /**
63
+ * Hook-less (internal) service methods. Directly call database adapter service methods
64
+ * without running any service-level hooks or sanitization. This can be useful if you need the raw data
65
+ * from the service and don't want to trigger any of its hooks.
66
+ *
67
+ * Important: These methods are only available internally on the server, not on the client
68
+ * side and only for the Feathers database adapters.
69
+ *
70
+ * These methods do not trigger events.
71
+ *
72
+ * @see {@link https://docs.feathersjs.com/guides/migrating.html#hook-less-service-methods}
73
+ */
74
+ export interface InternalServiceMethods<T = any, D = Partial<T>, P extends AdapterParams = AdapterParams> {
75
+ /**
76
+ * Retrieve all resources from this service.
77
+ * Does not sanitize the query and should only be used on the server.
78
+ *
79
+ * @param _params - Service call parameters {@link Params}
80
+ */
81
+ $find(_params?: P & {
82
+ paginate?: PaginationOptions;
83
+ }): Promise<Paginated<T>>;
84
+ $find(_params?: P & {
85
+ paginate: false;
86
+ }): Promise<T[]>;
87
+ $find(params?: P): Promise<T[] | Paginated<T>>;
88
+ /**
89
+ * Retrieve a single resource matching the given ID, skipping any service-level hooks.
90
+ * Does not sanitize the query and should only be used on the server.
91
+ *
92
+ * @param id - ID of the resource to locate
93
+ * @param params - Service call parameters {@link Params}
94
+ * @see {@link HookLessServiceMethods}
95
+ * @see {@link https://docs.feathersjs.com/api/services.html#get-id-params|Feathers API Documentation: .get(id, params)}
96
+ */
97
+ $get(id: Id, params?: P): Promise<T>;
98
+ /**
99
+ * Create a new resource for this service, skipping any service-level hooks.
100
+ * Does not sanitize data or checks if multiple updates are allowed and should only be used on the server.
101
+ *
102
+ * @param data - Data to insert into this service.
103
+ * @param params - Service call parameters {@link Params}
104
+ * @see {@link HookLessServiceMethods}
105
+ * @see {@link https://docs.feathersjs.com/api/services.html#create-data-params|Feathers API Documentation: .create(data, params)}
106
+ */
107
+ $create(data: Partial<D>, params?: P): Promise<T>;
108
+ $create(data: Partial<D>[], params?: P): Promise<T[]>;
109
+ $create(data: Partial<D> | Partial<D>[], params?: P): Promise<T | T[]>;
110
+ /**
111
+ * Completely replace the resource identified by id, skipping any service-level hooks.
112
+ * Does not sanitize data or query and should only be used on the server.
113
+ *
114
+ * @param id - ID of the resource to be updated
115
+ * @param data - Data to be put in place of the current resource.
116
+ * @param params - Service call parameters {@link Params}
117
+ * @see {@link HookLessServiceMethods}
118
+ * @see {@link https://docs.feathersjs.com/api/services.html#update-id-data-params|Feathers API Documentation: .update(id, data, params)}
119
+ */
120
+ $update(id: Id, data: D, params?: P): Promise<T>;
121
+ /**
122
+ * Merge any resources matching the given ID with the given data, skipping any service-level hooks.
123
+ * Does not sanitize the data or query and should only be used on the server.
124
+ *
125
+ * @param id - ID of the resource to be patched
126
+ * @param data - Data to merge with the current resource.
127
+ * @param params - Service call parameters {@link Params}
128
+ * @see {@link HookLessServiceMethods}
129
+ * @see {@link https://docs.feathersjs.com/api/services.html#patch-id-data-params|Feathers API Documentation: .patch(id, data, params)}
130
+ */
131
+ $patch(id: null, data: Partial<D>, params?: P): Promise<T[]>;
132
+ $patch(id: Id, data: Partial<D>, params?: P): Promise<T>;
133
+ $patch(id: NullableId, data: Partial<D>, params?: P): Promise<T | T[]>;
134
+ /**
135
+ * Remove resources matching the given ID from the this service, skipping any service-level hooks.
136
+ * Does not sanitize query and should only be used on the server.
137
+ *
138
+ * @param id - ID of the resource to be removed
139
+ * @param params - Service call parameters {@link Params}
140
+ * @see {@link HookLessServiceMethods}
141
+ * @see {@link https://docs.feathersjs.com/api/services.html#remove-id-params|Feathers API Documentation: .remove(id, params)}
142
+ */
143
+ $remove(id: null, params?: P): Promise<T[]>;
144
+ $remove(id: Id, params?: P): Promise<T>;
145
+ $remove(id: NullableId, params?: P): Promise<T | T[]>;
146
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.js","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":""}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- export { AdapterService, InternalServiceMethods, ServiceOptions, Paginated } from './service';
2
- export { filterQuery, FILTERS, OPERATORS } from './filter-query';
1
+ import { Params } from '@feathersjs/feathers';
2
+ export * from './declarations';
3
+ export * from './service';
4
+ export { filterQuery, FILTERS, OPERATORS } from './query';
3
5
  export * from './sort';
4
- export declare function select(params: any, ...otherFields: any[]): (result: any) => any;
6
+ export declare function select(params: Params, ...otherFields: string[]): (result: any) => any;
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,29 +14,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.select = exports.OPERATORS = exports.FILTERS = exports.filterQuery = exports.AdapterService = void 0;
17
+ exports.select = exports.OPERATORS = exports.FILTERS = exports.filterQuery = void 0;
14
18
  const commons_1 = require("@feathersjs/commons");
15
- var service_1 = require("./service");
16
- Object.defineProperty(exports, "AdapterService", { enumerable: true, get: function () { return service_1.AdapterService; } });
17
- var filter_query_1 = require("./filter-query");
18
- Object.defineProperty(exports, "filterQuery", { enumerable: true, get: function () { return filter_query_1.filterQuery; } });
19
- Object.defineProperty(exports, "FILTERS", { enumerable: true, get: function () { return filter_query_1.FILTERS; } });
20
- Object.defineProperty(exports, "OPERATORS", { enumerable: true, get: function () { return filter_query_1.OPERATORS; } });
19
+ __exportStar(require("./declarations"), exports);
20
+ __exportStar(require("./service"), exports);
21
+ var query_1 = require("./query");
22
+ Object.defineProperty(exports, "filterQuery", { enumerable: true, get: function () { return query_1.filterQuery; } });
23
+ Object.defineProperty(exports, "FILTERS", { enumerable: true, get: function () { return query_1.FILTERS; } });
24
+ Object.defineProperty(exports, "OPERATORS", { enumerable: true, get: function () { return query_1.OPERATORS; } });
21
25
  __exportStar(require("./sort"), exports);
22
26
  // Return a function that filters a result object or array
23
27
  // and picks only the fields passed as `params.query.$select`
24
28
  // and additional `otherFields`
25
29
  function select(params, ...otherFields) {
26
- const fields = params && params.query && params.query.$select;
27
- if (Array.isArray(fields) && otherFields.length) {
28
- fields.push(...otherFields);
30
+ var _a;
31
+ const queryFields = (_a = params === null || params === void 0 ? void 0 : params.query) === null || _a === void 0 ? void 0 : _a.$select;
32
+ if (!queryFields) {
33
+ return (result) => result;
29
34
  }
30
- const convert = (result) => {
31
- if (!Array.isArray(fields)) {
32
- return result;
33
- }
34
- return commons_1._.pick(result, ...fields);
35
- };
35
+ const resultFields = queryFields.concat(otherFields);
36
+ const convert = (result) => commons_1._.pick(result, ...resultFields);
36
37
  return (result) => {
37
38
  if (Array.isArray(result)) {
38
39
  return result.map(convert);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAAwC;AAExC,qCAA8F;AAArF,yGAAA,cAAc,OAAA;AACvB,+CAAiE;AAAxD,2GAAA,WAAW,OAAA;AAAE,uGAAA,OAAO,OAAA;AAAE,yGAAA,SAAS,OAAA;AACxC,yCAAuB;AAEvB,0DAA0D;AAC1D,6DAA6D;AAC7D,+BAA+B;AAC/B,SAAgB,MAAM,CAAE,MAAW,EAAE,GAAG,WAAkB;IACxD,MAAM,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;IAE9D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE;QAC/C,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;KAC7B;IAED,MAAM,OAAO,GAAG,CAAC,MAAW,EAAE,EAAE;QAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC1B,OAAO,MAAM,CAAC;SACf;QAED,OAAO,WAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC5B;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC;AAtBD,wBAsBC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAAwC;AAGxC,iDAA+B;AAC/B,4CAA0B;AAC1B,iCAA0D;AAAjD,oGAAA,WAAW,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,kGAAA,SAAS,OAAA;AACxC,yCAAuB;AAEvB,0DAA0D;AAC1D,6DAA6D;AAC7D,+BAA+B;AAC/B,SAAgB,MAAM,CAAE,MAAc,EAAE,GAAG,WAAqB;;IAC9D,MAAM,WAAW,GAAyB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,OAAO,CAAC;IAEjE,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC;KAChC;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,CAAC,MAAW,EAAE,EAAE,CAAC,WAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC;IAEjE,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SAC5B;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC;AAjBD,wBAiBC"}
package/lib/query.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Query } from '@feathersjs/feathers';
2
+ import { FilterQueryOptions, FilterSettings } from './declarations';
3
+ export declare const OPERATORS: string[];
4
+ export declare const FILTERS: FilterSettings;
5
+ /**
6
+ * Converts Feathers special query parameters and pagination settings
7
+ * and returns them separately as `filters` and the rest of the query
8
+ * as `query`. `options` also gets passed the pagination settings and
9
+ * a list of additional `operators` to allow when querying properties.
10
+ *
11
+ * @param query The initial query
12
+ * @param options Options for filtering the query
13
+ * @returns An object with `query` which contains the query without `filters`
14
+ * and `filters` which contains the converted values for each filter.
15
+ */
16
+ export declare function filterQuery(_query: Query, options?: FilterQueryOptions): {
17
+ filters: {
18
+ [key: string]: any;
19
+ };
20
+ query: Query;
21
+ };