@feathersjs/client 5.0.0-pre.0 → 5.0.0-pre.15

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +2 -2
  3. package/dist/core.d.ts +1 -0
  4. package/dist/core.js +1861 -3627
  5. package/dist/core.js.map +1 -1
  6. package/dist/core.min.js +1 -1
  7. package/dist/feathers.d.ts +8 -0
  8. package/dist/feathers.js +5106 -5755
  9. package/dist/feathers.js.map +1 -1
  10. package/dist/feathers.min.js +1 -1
  11. package/package.json +44 -38
  12. package/src/core.ts +1 -0
  13. package/src/feathers.ts +13 -0
  14. package/.babelrc +0 -8
  15. package/.cache/lasso/default/6a3076a5/dependencyFingerprints/cache +0 -0
  16. package/.cache/lasso/default/6a3076a5/key +0 -1
  17. package/.cache/lasso/default/6a3076a5/lasso-require/inspect-/5d47a286cdceb98f64bf9128488dd355fde40e81/cache +0 -0
  18. package/.cache/lasso/default/7be4a25c/dependencyFingerprints/cache +0 -0
  19. package/.cache/lasso/default/7be4a25c/key +0 -1
  20. package/.cache/lasso/default/7be4a25c/lasso-require/inspect/cache +0 -0
  21. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/filter-query.js +0 -1998
  22. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/index.js +0 -694
  23. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/service.js +0 -1636
  24. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/sort.js +0 -2259
  25. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/filter-query.js +0 -98
  26. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/index.js +0 -37
  27. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/service.js +0 -94
  28. package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/sort.js +0 -112
  29. package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.0/browser/test-run.js +0 -1
  30. package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.0/browser/test.js +0 -1037
  31. package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.0/dist/feathers.js +0 -78377
  32. package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.1/browser/test-run.js +0 -1
  33. package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.1/browser/test.js +0 -102
  34. package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.1/dist/feathers.js +0 -5231
  35. package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.0/lib/hooks.js +0 -2626
  36. package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.0/lib/index.js +0 -540
  37. package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.0/lib/utils.js +0 -1991
  38. package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.1/lib/hooks.js +0 -170
  39. package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.1/lib/index.js +0 -17
  40. package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.1/lib/utils.js +0 -102
  41. package/.mocha-puppeteer/test-page/@feathersjs/errors$4.5.0/lib/index.js +0 -2262
  42. package/.mocha-puppeteer/test-page/@feathersjs/errors$4.5.1/lib/index.js +0 -251
  43. package/.mocha-puppeteer/test-page/@feathersjs/tests$4.5.0/lib/client.js +0 -1506
  44. package/.mocha-puppeteer/test-page/@feathersjs/tests$4.5.1/lib/client.js +0 -83
  45. package/.mocha-puppeteer/test-page/assert$1.5.0/assert.js +0 -508
  46. package/.mocha-puppeteer/test-page/debug$4.1.1/src/browser.js +0 -266
  47. package/.mocha-puppeteer/test-page/debug$4.1.1/src/common.js +0 -268
  48. package/.mocha-puppeteer/test-page/feathers-memory$4.1.0/lib/index.js +0 -143
  49. package/.mocha-puppeteer/test-page/inherits$2.0.1/inherits_browser.js +0 -25
  50. package/.mocha-puppeteer/test-page/lasso-modules-client$2.0.5/src/index.js +0 -592
  51. package/.mocha-puppeteer/test-page/lasso-modules-meta.js +0 -28
  52. package/.mocha-puppeteer/test-page/marko$4.18.35/src/runtime/components/boot-run.js +0 -1
  53. package/.mocha-puppeteer/test-page/marko$4.18.35/src/runtime/components/boot.js +0 -95
  54. package/.mocha-puppeteer/test-page/marko$4.18.42/src/runtime/components/boot-run.js +0 -1
  55. package/.mocha-puppeteer/test-page/marko$4.18.42/src/runtime/components/boot.js +0 -95
  56. package/.mocha-puppeteer/test-page/marko$4.19.0/src/runtime/components/boot-run.js +0 -1
  57. package/.mocha-puppeteer/test-page/marko$4.19.0/src/runtime/components/boot.js +0 -3
  58. package/.mocha-puppeteer/test-page/mocha$3.5.3/mocha.css +0 -326
  59. package/.mocha-puppeteer/test-page/mocha$3.5.3/mocha.js +0 -16590
  60. package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/run-tests-run.js +0 -1
  61. package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/run-tests.js +0 -53
  62. package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/setup-run.js +0 -1
  63. package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/setup.js +0 -10
  64. package/.mocha-puppeteer/test-page/ms$2.1.2/index.js +0 -164
  65. package/.mocha-puppeteer/test-page/object-assign$4.1.1/index.js +0 -92
  66. package/.mocha-puppeteer/test-page/process$0.11.10/browser.js +0 -186
  67. package/.mocha-puppeteer/test-page/sift$8.5.1/lib/index.js +0 -738
  68. package/.mocha-puppeteer/test-page/superagent$3.8.3/superagent.js +0 -2035
  69. package/.mocha-puppeteer/test-page/util$0.10.3/support/isBufferBrowser.js +0 -7
  70. package/.mocha-puppeteer/test-page/util$0.10.3/util.js +0 -588
  71. package/.nyc_output/coverage.json +0 -1
  72. package/authentication.js +0 -1
  73. package/dist/authentication.js +0 -2242
  74. package/dist/authentication.js.map +0 -1
  75. package/dist/authentication.min.js +0 -1
  76. package/dist/rest.js +0 -3287
  77. package/dist/rest.js.map +0 -1
  78. package/dist/rest.min.js +0 -1
  79. package/dist/socketio.js +0 -2384
  80. package/dist/socketio.js.map +0 -1
  81. package/dist/socketio.min.js +0 -1
  82. package/index.d.ts +0 -23
  83. package/index.js +0 -1
  84. package/rest.js +0 -1
  85. package/socketio.js +0 -1
  86. package/webpack.config.js +0 -69
@@ -1,266 +0,0 @@
1
- $_mod.def("/debug$4.1.1/src/browser", function(require, exports, module, __filename, __dirname) { var process=require("process"); /* eslint-env browser */
2
-
3
- /**
4
- * This is the web browser implementation of `debug()`.
5
- */
6
-
7
- exports.log = log;
8
- exports.formatArgs = formatArgs;
9
- exports.save = save;
10
- exports.load = load;
11
- exports.useColors = useColors;
12
- exports.storage = localstorage();
13
-
14
- /**
15
- * Colors.
16
- */
17
-
18
- exports.colors = [
19
- '#0000CC',
20
- '#0000FF',
21
- '#0033CC',
22
- '#0033FF',
23
- '#0066CC',
24
- '#0066FF',
25
- '#0099CC',
26
- '#0099FF',
27
- '#00CC00',
28
- '#00CC33',
29
- '#00CC66',
30
- '#00CC99',
31
- '#00CCCC',
32
- '#00CCFF',
33
- '#3300CC',
34
- '#3300FF',
35
- '#3333CC',
36
- '#3333FF',
37
- '#3366CC',
38
- '#3366FF',
39
- '#3399CC',
40
- '#3399FF',
41
- '#33CC00',
42
- '#33CC33',
43
- '#33CC66',
44
- '#33CC99',
45
- '#33CCCC',
46
- '#33CCFF',
47
- '#6600CC',
48
- '#6600FF',
49
- '#6633CC',
50
- '#6633FF',
51
- '#66CC00',
52
- '#66CC33',
53
- '#9900CC',
54
- '#9900FF',
55
- '#9933CC',
56
- '#9933FF',
57
- '#99CC00',
58
- '#99CC33',
59
- '#CC0000',
60
- '#CC0033',
61
- '#CC0066',
62
- '#CC0099',
63
- '#CC00CC',
64
- '#CC00FF',
65
- '#CC3300',
66
- '#CC3333',
67
- '#CC3366',
68
- '#CC3399',
69
- '#CC33CC',
70
- '#CC33FF',
71
- '#CC6600',
72
- '#CC6633',
73
- '#CC9900',
74
- '#CC9933',
75
- '#CCCC00',
76
- '#CCCC33',
77
- '#FF0000',
78
- '#FF0033',
79
- '#FF0066',
80
- '#FF0099',
81
- '#FF00CC',
82
- '#FF00FF',
83
- '#FF3300',
84
- '#FF3333',
85
- '#FF3366',
86
- '#FF3399',
87
- '#FF33CC',
88
- '#FF33FF',
89
- '#FF6600',
90
- '#FF6633',
91
- '#FF9900',
92
- '#FF9933',
93
- '#FFCC00',
94
- '#FFCC33'
95
- ];
96
-
97
- /**
98
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
99
- * and the Firebug extension (any Firefox version) are known
100
- * to support "%c" CSS customizations.
101
- *
102
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
103
- */
104
-
105
- // eslint-disable-next-line complexity
106
- function useColors() {
107
- // NB: In an Electron preload script, document will be defined but not fully
108
- // initialized. Since we know we're in Chrome, we'll just detect this case
109
- // explicitly
110
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
111
- return true;
112
- }
113
-
114
- // Internet Explorer and Edge do not support colors.
115
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
116
- return false;
117
- }
118
-
119
- // Is webkit? http://stackoverflow.com/a/16459606/376773
120
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
121
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
122
- // Is firebug? http://stackoverflow.com/a/398120/376773
123
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
124
- // Is firefox >= v31?
125
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
126
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
127
- // Double check webkit in userAgent just in case we are in a worker
128
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
129
- }
130
-
131
- /**
132
- * Colorize log arguments if enabled.
133
- *
134
- * @api public
135
- */
136
-
137
- function formatArgs(args) {
138
- args[0] = (this.useColors ? '%c' : '') +
139
- this.namespace +
140
- (this.useColors ? ' %c' : ' ') +
141
- args[0] +
142
- (this.useColors ? '%c ' : ' ') +
143
- '+' + module.exports.humanize(this.diff);
144
-
145
- if (!this.useColors) {
146
- return;
147
- }
148
-
149
- const c = 'color: ' + this.color;
150
- args.splice(1, 0, c, 'color: inherit');
151
-
152
- // The final "%c" is somewhat tricky, because there could be other
153
- // arguments passed either before or after the %c, so we need to
154
- // figure out the correct index to insert the CSS into
155
- let index = 0;
156
- let lastC = 0;
157
- args[0].replace(/%[a-zA-Z%]/g, match => {
158
- if (match === '%%') {
159
- return;
160
- }
161
- index++;
162
- if (match === '%c') {
163
- // We only are interested in the *last* %c
164
- // (the user may have provided their own)
165
- lastC = index;
166
- }
167
- });
168
-
169
- args.splice(lastC, 0, c);
170
- }
171
-
172
- /**
173
- * Invokes `console.log()` when available.
174
- * No-op when `console.log` is not a "function".
175
- *
176
- * @api public
177
- */
178
- function log(...args) {
179
- // This hackery is required for IE8/9, where
180
- // the `console.log` function doesn't have 'apply'
181
- return typeof console === 'object' &&
182
- console.log &&
183
- console.log(...args);
184
- }
185
-
186
- /**
187
- * Save `namespaces`.
188
- *
189
- * @param {String} namespaces
190
- * @api private
191
- */
192
- function save(namespaces) {
193
- try {
194
- if (namespaces) {
195
- exports.storage.setItem('debug', namespaces);
196
- } else {
197
- exports.storage.removeItem('debug');
198
- }
199
- } catch (error) {
200
- // Swallow
201
- // XXX (@Qix-) should we be logging these?
202
- }
203
- }
204
-
205
- /**
206
- * Load `namespaces`.
207
- *
208
- * @return {String} returns the previously persisted debug modes
209
- * @api private
210
- */
211
- function load() {
212
- let r;
213
- try {
214
- r = exports.storage.getItem('debug');
215
- } catch (error) {
216
- // Swallow
217
- // XXX (@Qix-) should we be logging these?
218
- }
219
-
220
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
221
- if (!r && typeof process !== 'undefined' && 'env' in process) {
222
- r = process.env.DEBUG;
223
- }
224
-
225
- return r;
226
- }
227
-
228
- /**
229
- * Localstorage attempts to return the localstorage.
230
- *
231
- * This is necessary because safari throws
232
- * when a user disables cookies/localstorage
233
- * and you attempt to access it.
234
- *
235
- * @return {LocalStorage}
236
- * @api private
237
- */
238
-
239
- function localstorage() {
240
- try {
241
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
242
- // The Browser also has localStorage in the global context.
243
- return localStorage;
244
- } catch (error) {
245
- // Swallow
246
- // XXX (@Qix-) should we be logging these?
247
- }
248
- }
249
-
250
- module.exports = require('/debug$4.1.1/src/common'/*'./common'*/)(exports);
251
-
252
- const {formatters} = module.exports;
253
-
254
- /**
255
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
256
- */
257
-
258
- formatters.j = function (v) {
259
- try {
260
- return JSON.stringify(v);
261
- } catch (error) {
262
- return '[UnexpectedJSONParseError]: ' + error.message;
263
- }
264
- };
265
-
266
- });
@@ -1,268 +0,0 @@
1
- $_mod.def("/debug$4.1.1/src/common", function(require, exports, module, __filename, __dirname) {
2
- /**
3
- * This is the common logic for both the Node.js and web browser
4
- * implementations of `debug()`.
5
- */
6
-
7
- function setup(env) {
8
- createDebug.debug = createDebug;
9
- createDebug.default = createDebug;
10
- createDebug.coerce = coerce;
11
- createDebug.disable = disable;
12
- createDebug.enable = enable;
13
- createDebug.enabled = enabled;
14
- createDebug.humanize = require('/ms$2.1.2/index'/*'ms'*/);
15
-
16
- Object.keys(env).forEach(key => {
17
- createDebug[key] = env[key];
18
- });
19
-
20
- /**
21
- * Active `debug` instances.
22
- */
23
- createDebug.instances = [];
24
-
25
- /**
26
- * The currently active debug mode names, and names to skip.
27
- */
28
-
29
- createDebug.names = [];
30
- createDebug.skips = [];
31
-
32
- /**
33
- * Map of special "%n" handling functions, for the debug "format" argument.
34
- *
35
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
36
- */
37
- createDebug.formatters = {};
38
-
39
- /**
40
- * Selects a color for a debug namespace
41
- * @param {String} namespace The namespace string for the for the debug instance to be colored
42
- * @return {Number|String} An ANSI color code for the given namespace
43
- * @api private
44
- */
45
- function selectColor(namespace) {
46
- let hash = 0;
47
-
48
- for (let i = 0; i < namespace.length; i++) {
49
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
50
- hash |= 0; // Convert to 32bit integer
51
- }
52
-
53
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
54
- }
55
- createDebug.selectColor = selectColor;
56
-
57
- /**
58
- * Create a debugger with the given `namespace`.
59
- *
60
- * @param {String} namespace
61
- * @return {Function}
62
- * @api public
63
- */
64
- function createDebug(namespace) {
65
- let prevTime;
66
-
67
- function debug(...args) {
68
- // Disabled?
69
- if (!debug.enabled) {
70
- return;
71
- }
72
-
73
- const self = debug;
74
-
75
- // Set `diff` timestamp
76
- const curr = Number(new Date());
77
- const ms = curr - (prevTime || curr);
78
- self.diff = ms;
79
- self.prev = prevTime;
80
- self.curr = curr;
81
- prevTime = curr;
82
-
83
- args[0] = createDebug.coerce(args[0]);
84
-
85
- if (typeof args[0] !== 'string') {
86
- // Anything else let's inspect with %O
87
- args.unshift('%O');
88
- }
89
-
90
- // Apply any `formatters` transformations
91
- let index = 0;
92
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
93
- // If we encounter an escaped % then don't increase the array index
94
- if (match === '%%') {
95
- return match;
96
- }
97
- index++;
98
- const formatter = createDebug.formatters[format];
99
- if (typeof formatter === 'function') {
100
- const val = args[index];
101
- match = formatter.call(self, val);
102
-
103
- // Now we need to remove `args[index]` since it's inlined in the `format`
104
- args.splice(index, 1);
105
- index--;
106
- }
107
- return match;
108
- });
109
-
110
- // Apply env-specific formatting (colors, etc.)
111
- createDebug.formatArgs.call(self, args);
112
-
113
- const logFn = self.log || createDebug.log;
114
- logFn.apply(self, args);
115
- }
116
-
117
- debug.namespace = namespace;
118
- debug.enabled = createDebug.enabled(namespace);
119
- debug.useColors = createDebug.useColors();
120
- debug.color = selectColor(namespace);
121
- debug.destroy = destroy;
122
- debug.extend = extend;
123
- // Debug.formatArgs = formatArgs;
124
- // debug.rawLog = rawLog;
125
-
126
- // env-specific initialization logic for debug instances
127
- if (typeof createDebug.init === 'function') {
128
- createDebug.init(debug);
129
- }
130
-
131
- createDebug.instances.push(debug);
132
-
133
- return debug;
134
- }
135
-
136
- function destroy() {
137
- const index = createDebug.instances.indexOf(this);
138
- if (index !== -1) {
139
- createDebug.instances.splice(index, 1);
140
- return true;
141
- }
142
- return false;
143
- }
144
-
145
- function extend(namespace, delimiter) {
146
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
147
- newDebug.log = this.log;
148
- return newDebug;
149
- }
150
-
151
- /**
152
- * Enables a debug mode by namespaces. This can include modes
153
- * separated by a colon and wildcards.
154
- *
155
- * @param {String} namespaces
156
- * @api public
157
- */
158
- function enable(namespaces) {
159
- createDebug.save(namespaces);
160
-
161
- createDebug.names = [];
162
- createDebug.skips = [];
163
-
164
- let i;
165
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
166
- const len = split.length;
167
-
168
- for (i = 0; i < len; i++) {
169
- if (!split[i]) {
170
- // ignore empty strings
171
- continue;
172
- }
173
-
174
- namespaces = split[i].replace(/\*/g, '.*?');
175
-
176
- if (namespaces[0] === '-') {
177
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
178
- } else {
179
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
180
- }
181
- }
182
-
183
- for (i = 0; i < createDebug.instances.length; i++) {
184
- const instance = createDebug.instances[i];
185
- instance.enabled = createDebug.enabled(instance.namespace);
186
- }
187
- }
188
-
189
- /**
190
- * Disable debug output.
191
- *
192
- * @return {String} namespaces
193
- * @api public
194
- */
195
- function disable() {
196
- const namespaces = [
197
- ...createDebug.names.map(toNamespace),
198
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
199
- ].join(',');
200
- createDebug.enable('');
201
- return namespaces;
202
- }
203
-
204
- /**
205
- * Returns true if the given mode name is enabled, false otherwise.
206
- *
207
- * @param {String} name
208
- * @return {Boolean}
209
- * @api public
210
- */
211
- function enabled(name) {
212
- if (name[name.length - 1] === '*') {
213
- return true;
214
- }
215
-
216
- let i;
217
- let len;
218
-
219
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
220
- if (createDebug.skips[i].test(name)) {
221
- return false;
222
- }
223
- }
224
-
225
- for (i = 0, len = createDebug.names.length; i < len; i++) {
226
- if (createDebug.names[i].test(name)) {
227
- return true;
228
- }
229
- }
230
-
231
- return false;
232
- }
233
-
234
- /**
235
- * Convert regexp to namespace
236
- *
237
- * @param {RegExp} regxep
238
- * @return {String} namespace
239
- * @api private
240
- */
241
- function toNamespace(regexp) {
242
- return regexp.toString()
243
- .substring(2, regexp.toString().length - 2)
244
- .replace(/\.\*\?$/, '*');
245
- }
246
-
247
- /**
248
- * Coerce `val`.
249
- *
250
- * @param {Mixed} val
251
- * @return {Mixed}
252
- * @api private
253
- */
254
- function coerce(val) {
255
- if (val instanceof Error) {
256
- return val.stack || val.message;
257
- }
258
- return val;
259
- }
260
-
261
- createDebug.enable(createDebug.load());
262
-
263
- return createDebug;
264
- }
265
-
266
- module.exports = setup;
267
-
268
- });
@@ -1,143 +0,0 @@
1
- $_mod.def("/feathers-memory$4.1.0/lib/index", function(require, exports, module, __filename, __dirname) { const errors = require('/@feathersjs/errors$4.5.1/lib/index'/*'@feathersjs/errors'*/);
2
- const { _ } = require('/@feathersjs/commons$4.5.1/lib/index'/*'@feathersjs/commons'*/);
3
- const { sorter, select, AdapterService } = require('/@feathersjs/adapter-commons$4.5.1/lib/index'/*'@feathersjs/adapter-commons'*/);
4
- const sift = require('/sift$8.5.1/lib/index'/*'sift'*/).default;
5
-
6
- const _select = (data, ...args) => {
7
- const base = select(...args);
8
-
9
- return base(JSON.parse(JSON.stringify(data)));
10
- };
11
-
12
- class Service extends AdapterService {
13
- constructor (options = {}) {
14
- super(_.extend({
15
- id: 'id',
16
- matcher: sift,
17
- sorter
18
- }, options));
19
- this._uId = options.startId || 0;
20
- this.store = options.store || {};
21
- }
22
-
23
- async getEntries (params = {}) {
24
- const { query } = this.filterQuery(params);
25
-
26
- return this._find(Object.assign({}, params, {
27
- paginate: false,
28
- query
29
- }));
30
- }
31
-
32
- async _find (params = {}) {
33
- const { query, filters, paginate } = this.filterQuery(params);
34
- let values = _.values(this.store).filter(this.options.matcher(query));
35
- const total = values.length;
36
-
37
- if (filters.$sort !== undefined) {
38
- values.sort(this.options.sorter(filters.$sort));
39
- }
40
-
41
- if (filters.$skip !== undefined) {
42
- values = values.slice(filters.$skip);
43
- }
44
-
45
- if (filters.$limit !== undefined) {
46
- values = values.slice(0, filters.$limit);
47
- }
48
-
49
- const result = {
50
- total,
51
- limit: filters.$limit,
52
- skip: filters.$skip || 0,
53
- data: values.map(value => _select(value, params))
54
- };
55
-
56
- if (!(paginate && paginate.default)) {
57
- return result.data;
58
- }
59
-
60
- return result;
61
- }
62
-
63
- async _get (id, params = {}) {
64
- if (id in this.store) {
65
- const { query } = this.filterQuery(params);
66
- const value = this.store[id];
67
-
68
- if (this.options.matcher(query)(value)) {
69
- return _select(value, params, this.id);
70
- }
71
- }
72
-
73
- throw new errors.NotFound(`No record found for id '${id}'`);
74
- }
75
-
76
- // Create without hooks and mixins that can be used internally
77
- async _create (data, params = {}) {
78
- if (Array.isArray(data)) {
79
- return Promise.all(data.map(current => this._create(current, params)));
80
- }
81
-
82
- const id = data[this.id] || this._uId++;
83
- const current = _.extend({}, data, { [this.id]: id });
84
- const result = (this.store[id] = current);
85
-
86
- return _select(result, params, this.id);
87
- }
88
-
89
- async _update (id, data, params = {}) {
90
- const oldEntry = await this._get(id);
91
- // We don't want our id to change type if it can be coerced
92
- const oldId = oldEntry[this.id];
93
-
94
- id = oldId == id ? oldId : id; // eslint-disable-line
95
-
96
- this.store[id] = _.extend({}, data, { [this.id]: id });
97
-
98
- return this._get(id, params);
99
- }
100
-
101
- async _patch (id, data, params = {}) {
102
- const patchEntry = entry => {
103
- const currentId = entry[this.id];
104
-
105
- this.store[currentId] = _.extend(this.store[currentId], _.omit(data, this.id));
106
-
107
- return _select(this.store[currentId], params, this.id);
108
- };
109
-
110
- if (id === null) {
111
- const entries = await this.getEntries(params);
112
-
113
- return entries.map(patchEntry);
114
- }
115
-
116
- return patchEntry(await this._get(id, params)); // Will throw an error if not found
117
- }
118
-
119
- // Remove without hooks and mixins that can be used internally
120
- async _remove (id, params = {}) {
121
- if (id === null) {
122
- const entries = await this.getEntries(params);
123
-
124
- return Promise.all(entries.map(
125
- current => this._remove(current[this.id], params))
126
- );
127
- }
128
-
129
- const entry = await this._get(id, params);
130
-
131
- delete this.store[id];
132
-
133
- return entry;
134
- }
135
- }
136
-
137
- module.exports = options => {
138
- return new Service(options);
139
- };
140
-
141
- module.exports.Service = Service;
142
-
143
- });
@@ -1,25 +0,0 @@
1
- $_mod.def("/inherits$2.0.1/inherits_browser", function(require, exports, module, __filename, __dirname) { if (typeof Object.create === 'function') {
2
- // implementation from standard node.js 'util' module
3
- module.exports = function inherits(ctor, superCtor) {
4
- ctor.super_ = superCtor
5
- ctor.prototype = Object.create(superCtor.prototype, {
6
- constructor: {
7
- value: ctor,
8
- enumerable: false,
9
- writable: true,
10
- configurable: true
11
- }
12
- });
13
- };
14
- } else {
15
- // old school shim for old browsers
16
- module.exports = function inherits(ctor, superCtor) {
17
- ctor.super_ = superCtor
18
- var TempCtor = function () {}
19
- TempCtor.prototype = superCtor.prototype
20
- ctor.prototype = new TempCtor()
21
- ctor.prototype.constructor = ctor
22
- }
23
- }
24
-
25
- });