@feathersjs/adapter-commons 5.0.0-pre.2 → 5.0.0-pre.22

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,7 @@
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.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24)
7
7
 
8
8
  **Note:** Version bump only for package @feathersjs/adapter-commons
9
9
 
@@ -11,52 +11,254 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
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)
14
+ # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23)
15
+
16
+ **Note:** Version bump only for package @feathersjs/adapter-commons
17
+
18
+
19
+
20
+
21
+
22
+ # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507))
28
+
29
+
30
+
31
+
32
+
33
+ # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * **adapter-commons:** Clarify adapter query filtering ([#2607](https://github.com/feathersjs/feathers/issues/2607)) ([2dac771](https://github.com/feathersjs/feathers/commit/2dac771b0a3298d6dd25994d05186701b0617718))
39
+
40
+
41
+ ### Features
42
+
43
+ * **mongodb:** Add feathers-mongodb adapter as @feathersjs/mongodb ([#2610](https://github.com/feathersjs/feathers/issues/2610)) ([6d43734](https://github.com/feathersjs/feathers/commit/6d43734a53db02c435cafc52a22dca414e5d0940))
44
+ * **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5))
45
+ * **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28))
46
+
47
+
48
+ ### BREAKING CHANGES
49
+
50
+ * **adapter-commons:** Changes the common adapter base class to use `sanitizeQuery` and `sanitizeData`
51
+
52
+
53
+
54
+
55
+
56
+ # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
57
+
58
+
59
+ ### Features
60
+
61
+ * **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023))
62
+ * **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa))
63
+
64
+
65
+
66
+
67
+
68
+ # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
69
+
70
+ **Note:** Version bump only for package @feathersjs/adapter-commons
71
+
72
+
73
+
74
+
75
+
76
+ # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
77
+
78
+ **Note:** Version bump only for package @feathersjs/adapter-commons
79
+
80
+
81
+
82
+
83
+
84
+ # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
85
+
86
+
87
+ ### Bug Fixes
88
+
89
+ * **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))
90
+ * **adapter-commons:** Fix sorting for embedded objects ([#2488](https://github.com/feathersjs/feathers/issues/2488)) ([9c22f70](https://github.com/feathersjs/feathers/commit/9c22f70a838cb6341775d91705a7527c8fc5590e))
91
+ * **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
92
+
93
+
94
+
95
+
96
+
97
+ # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
98
+
99
+ **Note:** Version bump only for package @feathersjs/adapter-commons
100
+
101
+
102
+
103
+
104
+
105
+ # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
106
+
107
+ **Note:** Version bump only for package @feathersjs/adapter-commons
108
+
109
+
110
+
111
+
112
+
113
+ # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
114
+
115
+ **Note:** Version bump only for package @feathersjs/adapter-commons
116
+
117
+
118
+
119
+
120
+
121
+ # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
122
+
123
+ **Note:** Version bump only for package @feathersjs/adapter-commons
124
+
125
+
126
+
127
+
128
+
129
+ # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
130
+
131
+ **Note:** Version bump only for package @feathersjs/adapter-commons
132
+
133
+
134
+
135
+
136
+
137
+ # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
138
+
139
+ **Note:** Version bump only for package @feathersjs/adapter-commons
140
+
141
+
142
+
143
+
144
+
145
+ # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
146
+
147
+ **Note:** Version bump only for package @feathersjs/adapter-commons
148
+
149
+
150
+
151
+
152
+
153
+ # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
154
+
155
+ **Note:** Version bump only for package @feathersjs/adapter-commons
156
+
157
+
158
+
159
+
160
+
161
+ # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
162
+
163
+ **Note:** Version bump only for package @feathersjs/adapter-commons
164
+
165
+
166
+
167
+
168
+
169
+ # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
170
+
171
+
172
+ ### Bug Fixes
173
+
174
+ * Update database adapter common repository urls ([#2380](https://github.com/feathersjs/feathers/issues/2380)) ([3f4db68](https://github.com/feathersjs/feathers/commit/3f4db68d6700c7d9023ecd17d0d39893f75a19fd))
175
+
176
+
177
+ ### Features
178
+
179
+ * **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))
180
+ * **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))
181
+
182
+
183
+
184
+
185
+
186
+ # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
187
+
188
+
189
+ ### Bug Fixes
190
+
191
+ * **typescript:** Move Paginated type back for better compatibility ([#2350](https://github.com/feathersjs/feathers/issues/2350)) ([2917d05](https://github.com/feathersjs/feathers/commit/2917d05fffb4716d3c4cdaa5ac6a1aee0972e8a6))
192
+
193
+
194
+
195
+
196
+
197
+ # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
198
+
199
+
200
+ ### Bug Fixes
201
+
202
+ * **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
203
+
204
+
205
+
206
+
207
+
208
+ # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
209
+
210
+ **Note:** Version bump only for package @feathersjs/adapter-commons
211
+
212
+
213
+
214
+
215
+
216
+ # [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
217
 
16
218
 
17
219
  ### Bug Fixes
18
220
 
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))
221
+ * **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
222
 
21
223
 
22
224
  ### Features
23
225
 
24
- * **adapter-commons:** Added mongoDB like search in embedded objects ([687e3c7](https://github.com/feathersjs/databases/commit/687e3c7c36904221b2707d0220c0893e3cb1faa9))
226
+ * **adapter-commons:** Added mongoDB like search in embedded objects ([687e3c7](https://github.com/feathersjs/feathers/commit/687e3c7c36904221b2707d0220c0893e3cb1faa9))
25
227
 
26
228
 
27
229
 
28
230
 
29
231
 
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)
232
+ # [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
233
 
32
234
 
33
235
  ### Bug Fixes
34
236
 
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))
237
+ * **adapter-commons:** Always respect paginate.max ([#2267](https://github.com/feathersjs/feathers/issues/2267)) ([f588257](https://github.com/feathersjs/feathers/commit/f5882575536624ed3a32bb6e3ff1919fa17e366d))
238
+ * Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60))
239
+ * **adapter-commons:** Return missing overloads ([#2203](https://github.com/feathersjs/feathers/issues/2203)) ([bbe7e2a](https://github.com/feathersjs/feathers/commit/bbe7e2a131633e9a6e7aac7f7fa02a312bca63c7))
38
240
 
39
241
 
40
242
  ### Features
41
243
 
42
- * Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/databases/issues/2255)) ([2dafb7c](https://github.com/feathersjs/databases/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9))
244
+ * Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9))
43
245
 
44
246
 
45
247
 
46
248
 
47
249
 
48
- # [5.0.0-pre.1](https://github.com/feathersjs/databases/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
250
+ # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
49
251
 
50
252
 
51
253
  ### Features
52
254
 
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))
255
+ * **memory:** Move feathers-memory into @feathersjs/memory ([#2153](https://github.com/feathersjs/feathers/issues/2153)) ([dd61fe3](https://github.com/feathersjs/feathers/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6))
54
256
 
55
257
 
56
258
 
57
259
 
58
260
 
59
- ## [4.5.11](https://github.com/feathersjs/databases/compare/v4.5.10...v4.5.11) (2020-12-05)
261
+ ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05)
60
262
 
61
263
  **Note:** Version bump only for package @feathersjs/adapter-commons
62
264
 
@@ -64,7 +266,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
64
266
 
65
267
 
66
268
 
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)
269
+ ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-10-21)
68
270
 
69
271
 
70
272
  ### Bug Fixes
@@ -75,7 +277,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
75
277
 
76
278
 
77
279
 
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)
280
+ ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-10-21)
79
281
 
80
282
 
81
283
  ### Bug Fixes
@@ -86,7 +288,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
86
288
 
87
289
 
88
290
 
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)
291
+ ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-10-21)
90
292
 
91
293
 
92
294
  ### Bug Fixes
@@ -97,7 +299,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
97
299
 
98
300
 
99
301
 
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)
302
+ ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-09-27)
101
303
 
102
304
  **Note:** Version bump only for package @feathersjs/adapter-commons
103
305
 
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
+ };