Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fakerest

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fakerest - npm Package Compare versions

Comparing version 4.0.0-beta.3 to 4.0.0

2

package.json
{
"name": "fakerest",
"version": "4.0.0-beta.3",
"version": "4.0.0",
"repository": "https://github.com/marmelab/FakeRest",

@@ -5,0 +5,0 @@ "description": "Patch XMLHttpRequest to fake a REST server based on JSON data. ",

@@ -59,3 +59,3 @@ import { SimpleRestServer } from '../SimpleRestServer.ts';

response: BaseResponse,
normalizedRequest: NormalizedRequest
normalizedRequest: NormalizedRequest,
) {

@@ -68,3 +68,3 @@ if (!this.loggingEnabled) return;

normalizedRequest.url,
'(FakeRest)'
'(FakeRest)',
);

@@ -89,3 +89,3 @@ console.group('request');

'body',
request.requestJson
request.requestJson,
);

@@ -98,3 +98,3 @@ console.log(

'body',
response.body
response.body,
);

@@ -101,0 +101,0 @@ }

@@ -27,4 +27,4 @@ import { SimpleRestServer } from '../SimpleRestServer.ts';

Array.from(new URLSearchParams(url.search).entries()).map(
([key, value]) => [key, JSON.parse(value)]
)
([key, value]) => [key, JSON.parse(value)],
),
);

@@ -31,0 +31,0 @@ let requestBody: Record<string, any> | undefined = undefined;

@@ -9,3 +9,3 @@ import sinon, { type SinonFakeXMLHttpRequest } from 'sinon';

url: string,
data?: any
data?: any,
): SinonFakeXMLHttpRequest | null {

@@ -60,3 +60,3 @@ const xhr = sinon.useFakeXMLHttpRequest();

expect(request?.getResponseHeader('Content-Range')).toEqual(
'items 0-0/2'
'items 0-0/2',
);

@@ -70,3 +70,3 @@ request = getFakeXMLHTTPRequest('GET', '/foo?_start=2&_end=2');

expect(request?.getResponseHeader('Content-Range')).toEqual(
'items 1-1/2'
'items 1-1/2',
);

@@ -106,3 +106,3 @@ });

expect(request.responseText).toEqual(
'{"data":[{"id":1,"name":"foo"},{"id":2,"name":"bar"}],"status":200}'
'{"data":[{"id":1,"name":"foo"},{"id":2,"name":"bar"}],"status":200}',
);

@@ -138,9 +138,9 @@ });

expect(request.responseText).toEqual(
'[{"id":1,"name":"foo"},{"id":2,"name":"bar"}]'
'[{"id":1,"name":"foo"},{"id":2,"name":"bar"}]',
);
expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);
expect(request.getResponseHeader('Content-Range')).toEqual(
'items 0-1/2'
'items 0-1/2',
);

@@ -163,3 +163,3 @@ });

'GET',
'/foos?filter={"arg":true}&sort=name&slice=[0,10]&embed=["bars"]'
'/foos?filter={"arg":true}&sort=name&slice=[0,10]&embed=["bars"]',
);

@@ -171,9 +171,9 @@ if (request == null) throw new Error('request is null');

expect(request.responseText).toEqual(
'[{"id":2,"name":"a","arg":true,"bars":[]},{"id":1,"name":"b","arg":true,"bars":[{"id":0,"name":"a","foo_id":1}]}]'
'[{"id":2,"name":"a","arg":true,"bars":[]},{"id":1,"name":"b","arg":true,"bars":[{"id":0,"name":"a","foo_id":1}]}]',
);
expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);
expect(request.getResponseHeader('Content-Range')).toEqual(
'items 0-1/2'
'items 0-1/2',
);

@@ -193,3 +193,3 @@ });

expect(request.getResponseHeader('Content-Range')).toEqual(
'items 0-10/11'
'items 0-10/11',
);

@@ -201,3 +201,3 @@ request = getFakeXMLHTTPRequest('GET', '/foo?range=[0,4]');

expect(request.getResponseHeader('Content-Range')).toEqual(
'items 0-4/11'
'items 0-4/11',
);

@@ -209,3 +209,3 @@ request = getFakeXMLHTTPRequest('GET', '/foo?range=[5,9]');

expect(request.getResponseHeader('Content-Range')).toEqual(
'items 5-9/11'
'items 5-9/11',
);

@@ -217,3 +217,3 @@ request = getFakeXMLHTTPRequest('GET', '/foo?range=[10,14]');

expect(request.getResponseHeader('Content-Range')).toEqual(
'items 10-10/11'
'items 10-10/11',
);

@@ -234,3 +234,3 @@ });

expect(request.getResponseHeader('Content-Range')).toEqual(
'items */0'
'items */0',
);

@@ -252,3 +252,3 @@ });

'/foo',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -261,3 +261,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -279,3 +279,3 @@ expect(request.getResponseHeader('Location')).toEqual('/foo/3');

'/foo',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -288,3 +288,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -315,3 +315,3 @@ expect(request.getResponseHeader('Location')).toEqual('/foo/0');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -342,3 +342,3 @@ });

'/foo/2',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -351,3 +351,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -367,3 +367,3 @@ // @ts-ignore

'/foo/3',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -388,3 +388,3 @@ if (request == null) throw new Error('request is null');

'/foo/2',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -397,3 +397,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -413,3 +413,3 @@ // @ts-ignore

'/foo/3',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -438,3 +438,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -468,3 +468,3 @@ // @ts-ignore

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -481,3 +481,3 @@ });

'/foo/',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -490,3 +490,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -507,3 +507,3 @@ // @ts-ignore

'/foo/',
JSON.stringify({ name: 'baz' })
JSON.stringify({ name: 'baz' }),
);

@@ -516,3 +516,3 @@ if (request == null) throw new Error('request is null');

expect(request.getResponseHeader('Content-Type')).toEqual(
'application/json'
'application/json',
);

@@ -538,3 +538,3 @@ // @ts-ignore

expect(request.getResponseHeader('Content-Range')).toEqual(
'items 2-4/10'
'items 2-4/10',
);

@@ -557,3 +557,3 @@ const expected = [{ id: 2 }, { id: 3 }, { id: 4 }];

expect(request.getResponseHeader('Content-Range')).toEqual(
'items 0-4/10'
'items 0-4/10',
);

@@ -560,0 +560,0 @@ const expected = [

@@ -48,3 +48,3 @@ import type { SinonFakeXMLHttpRequest } from 'sinon';

requestBody = JSON.parse(
(req as SinonFakeXMLHttpRequest).requestBody
(req as SinonFakeXMLHttpRequest).requestBody,
);

@@ -101,3 +101,3 @@ } catch (error) {

sinonResponse.headers,
JSON.stringify(sinonResponse.body)
JSON.stringify(sinonResponse.body),
);

@@ -131,3 +131,3 @@

'body',
request.requestBody
request.requestBody,
);

@@ -140,3 +140,3 @@ console.log(

'body',
response.body
response.body,
);

@@ -143,0 +143,0 @@ }

@@ -124,3 +124,3 @@ import { Collection } from './Collection.ts';

expect(collection.getAll({ sort: ['name', 'asc'] })).toEqual(
expected
expected,
);

@@ -133,3 +133,3 @@ expected = [

expect(collection.getAll({ sort: ['name', 'desc'] })).toEqual(
expected
expected,
);

@@ -181,3 +181,3 @@ });

expect(collection.getAll({ filter: { name: 'b' } })).toEqual(
expected
expected,
);

@@ -196,3 +196,3 @@ });

expect(
collection.getAll({ filter: { 'deep.value': 'b' } })
collection.getAll({ filter: { 'deep.value': 'b' } }),
).toEqual(expected);

@@ -211,3 +211,3 @@ });

expect(
collection.getAll({ filter: { deep: { value: 'b' } } })
collection.getAll({ filter: { deep: { value: 'b' } } }),
).toEqual(expected);

@@ -230,12 +230,12 @@ });

expect(collection.getAll({ filter: { is: 'false' } })).toEqual(
expectedFalse
expectedFalse,
);
expect(collection.getAll({ filter: { is: false } })).toEqual(
expectedFalse
expectedFalse,
);
expect(collection.getAll({ filter: { is: 'true' } })).toEqual(
expectedTrue
expectedTrue,
);
expect(collection.getAll({ filter: { is: true } })).toEqual(
expectedTrue
expectedTrue,
);

@@ -257,6 +257,6 @@ });

expect(collection.getAll({ filter: { tags: 'b' } })).toEqual(
expected
expected,
);
expect(collection.getAll({ filter: { tags: 'f' } })).toEqual(
[]
[],
);

@@ -278,6 +278,6 @@ });

expect(
collection.getAll({ filter: { 'deep.tags': 'b' } })
collection.getAll({ filter: { 'deep.tags': 'b' } }),
).toEqual(expected);
expect(
collection.getAll({ filter: { 'deep.tags': 'f' } })
collection.getAll({ filter: { 'deep.tags': 'f' } }),
).toEqual([]);

@@ -299,6 +299,6 @@ });

expect(
collection.getAll({ filter: { 'tags.deep': 'b' } })
collection.getAll({ filter: { 'tags.deep': 'b' } }),
).toEqual(expected);
expect(
collection.getAll({ filter: { 'tags.deep': 'f' } })
collection.getAll({ filter: { 'tags.deep': 'f' } }),
).toEqual([]);

@@ -326,6 +326,6 @@ });

expect(
collection.getAll({ filter: { 'tags.name': 'b' } })
collection.getAll({ filter: { 'tags.name': 'b' } }),
).toEqual(expected);
expect(
collection.getAll({ filter: { 'tags.name': 'f' } })
collection.getAll({ filter: { 'tags.name': 'f' } }),
).toEqual([]);

@@ -344,3 +344,3 @@ });

expect(
collection.getAll({ filter: { 'deep.tags': ['b', 'd'] } })
collection.getAll({ filter: { 'deep.tags': ['b', 'd'] } }),
).toEqual(expected);

@@ -350,3 +350,3 @@ expect(

filter: { 'deep.tags': ['a', 'b', 'e'] },
})
}),
).toEqual([]);

@@ -374,6 +374,6 @@ });

expect(
collection.getAll({ filter: { 'tags.name': ['c'] } })
collection.getAll({ filter: { 'tags.name': ['c'] } }),
).toEqual(expected);
expect(
collection.getAll({ filter: { 'tags.name': ['h', 'i'] } })
collection.getAll({ filter: { 'tags.name': ['h', 'i'] } }),
).toEqual([]);

@@ -392,6 +392,6 @@ });

expect(
collection.getAll({ filter: { tags: ['b', 'd'] } })
collection.getAll({ filter: { tags: ['b', 'd'] } }),
).toEqual(expected);
expect(
collection.getAll({ filter: { tags: ['a', 'b', 'e'] } })
collection.getAll({ filter: { tags: ['a', 'b', 'e'] } }),
).toEqual([]);

@@ -468,3 +468,3 @@ });

expect(
collection.getAll({ filter: { v_eq_any: [1, 3] } })
collection.getAll({ filter: { v_eq_any: [1, 3] } }),
).toEqual([

@@ -481,3 +481,3 @@ { v: 1, id: 0 },

expect(
collection.getAll({ filter: { v_neq_any: [1, 3] } })
collection.getAll({ filter: { v_neq_any: [1, 3] } }),
).toEqual([{ v: 2, id: 1 }]);

@@ -491,3 +491,3 @@ });

expect(
collection.getAll({ filter: { v_inc_any: [1, 3] } })
collection.getAll({ filter: { v_inc_any: [1, 3] } }),
).toEqual([

@@ -504,3 +504,3 @@ { v: [1, 2], id: 0 },

expect(
collection.getAll({ filter: { v_ninc_any: [1, 3] } })
collection.getAll({ filter: { v_ninc_any: [1, 3] } }),
).toEqual([{ v: [2, 4], id: 1 }]);

@@ -514,3 +514,3 @@ });

expect(
collection.getAll({ filter: { v_inc: [1, 3] } })
collection.getAll({ filter: { v_inc: [1, 3] } }),
).toEqual([{ v: [3, 1], id: 2 }]);

@@ -545,3 +545,3 @@ });

expect(
collection.getAll({ filter: { id: [1, 2, 3] } })
collection.getAll({ filter: { id: [1, 2, 3] } }),
).toEqual([

@@ -553,3 +553,3 @@ { id: 1, a: 'e' },

expect(
collection.getAll({ filter: { id: ['1', '2', '3'] } })
collection.getAll({ filter: { id: ['1', '2', '3'] } }),
).toEqual([

@@ -567,3 +567,3 @@ { id: 1, a: 'e' },

expect(
collection.getAll({ filter: { v_gte: 2, v_lte: 2 } })
collection.getAll({ filter: { v_gte: 2, v_lte: 2 } }),
).toEqual([{ v: 2, id: 1 }]);

@@ -657,3 +657,3 @@ });

}).toThrow(
new Error("Can't embed a non-existing collection bar")
new Error("Can't embed a non-existing collection bar"),
);

@@ -717,3 +717,3 @@ });

}).toThrow(
new Error("Can't embed a non-existing collection bars")
new Error("Can't embed a non-existing collection bars"),
);

@@ -872,3 +872,3 @@ });

expect(authors.getAll({ embed: ['books', 'country'] })).toEqual(
expected
expected,
);

@@ -969,3 +969,3 @@ });

}).toThrow(
new Error('An item with the identifier 0 already exists')
new Error('An item with the identifier 0 already exists'),
);

@@ -1065,3 +1065,3 @@ });

expect(
collection.getOne('6090eb22-e140-4720-b7b2-e1416a3d2447')
collection.getOne('6090eb22-e140-4720-b7b2-e1416a3d2447'),
).toEqual({

@@ -1068,0 +1068,0 @@ id: '6090eb22-e140-4720-b7b2-e1416a3d2447',

@@ -33,3 +33,3 @@ import get from 'lodash/get.js';

throw new Error(
"Can't initialize a Collection with anything else than an array of items"
"Can't initialize a Collection with anything else than an array of items",
);

@@ -76,3 +76,3 @@ }

throw new Error(
`Can't embed a non-existing collection ${resourceName}`
`Can't embed a non-existing collection ${resourceName}`,
);

@@ -85,3 +85,3 @@ if (Array.isArray(item[resourceName])) {

item[resourceName].indexOf(
i[otherCollection.identifierName]
i[otherCollection.identifierName],
) !== -1,

@@ -121,3 +121,3 @@ });

throw new Error(
`Can't embed a non-existing collection ${resourceName}`
`Can't embed a non-existing collection ${resourceName}`,
);

@@ -127,3 +127,3 @@ try {

item[resourceName] = otherCollection.getOne(
item[referenceName]
item[referenceName],
);

@@ -146,3 +146,3 @@ } catch (e) {

? this._oneToManyEmbedder(resourceName)
: this._manyToOneEmbedder(resourceName)
: this._manyToOneEmbedder(resourceName),
);

@@ -152,3 +152,3 @@ return (item: T) =>

(itemWithEmbeds, embedder) => embedder(itemWithEmbeds),
item
item,
);

@@ -184,3 +184,3 @@ }

// biome-ignore lint/suspicious/noDoubleEquals: we want implicit type coercion
(item) => item[this.identifierName] == identifier
(item) => item[this.identifierName] == identifier,
);

@@ -211,3 +211,3 @@ }

throw new Error(
`An item with the identifier ${identifier} already exists`
`An item with the identifier ${identifier} already exists`,
);

@@ -254,3 +254,3 @@ }

array: T[],
predicate: Predicate
predicate: Predicate,
) => array.reduce((acc, value) => acc && predicate(value), true);

@@ -260,3 +260,3 @@

array: T[],
predicate: Predicate
predicate: Predicate,
) => array.reduce((acc, value) => acc || predicate(value), false);

@@ -266,21 +266,24 @@

keyParts: string[],
item: T
item: T,
) =>
keyParts.reduce((acc, key, index) => {
// If we already found an array, we don't need to explore further
// For example with path `tags.name` when tags is an array of objects
if (acc != null) {
return acc;
}
keyParts.reduce(
(acc, key, index) => {
// If we already found an array, we don't need to explore further
// For example with path `tags.name` when tags is an array of objects
if (acc != null) {
return acc;
}
const keyToArray = keyParts.slice(0, index + 1).join('.');
const keyToItem = keyParts.slice(index + 1).join('.');
const itemValue = get(item, keyToArray);
const keyToArray = keyParts.slice(0, index + 1).join('.');
const keyToItem = keyParts.slice(index + 1).join('.');
const itemValue = get(item, keyToArray);
// If the array is at the end of the key path, we will process it like we do normally with arrays
// For example with path `deep.tags` where tags is the array. In this case, we return undefined
return Array.isArray(itemValue) && index < keyParts.length - 1
? [keyToArray, keyToItem]
: undefined;
}, undefined as Array<string> | undefined);
// If the array is at the end of the key path, we will process it like we do normally with arrays
// For example with path `deep.tags` where tags is the array. In this case, we return undefined
return Array.isArray(itemValue) && index < keyParts.length - 1
? [keyToArray, keyToItem]
: undefined;
},
undefined as Array<string> | undefined,
);

@@ -325,3 +328,3 @@ const getSimpleFilter = (key: string, value: any) => {

return <T extends CollectionItem = CollectionItem>(
item: T
item: T,
// biome-ignore lint/suspicious/noDoubleEquals: we want implicit type coercion

@@ -334,3 +337,3 @@ ) => finalValue.every((val) => get(item, realKey) != val);

return <T extends CollectionItem = CollectionItem>(
item: T
item: T,
// biome-ignore lint/suspicious/noDoubleEquals: we want implicit type coercion

@@ -344,3 +347,3 @@ ) => get(item, realKey) != value;

return <T extends CollectionItem = CollectionItem>(
item: T
item: T,
// biome-ignore lint/suspicious/noDoubleEquals: we want implicit type coercion

@@ -353,3 +356,3 @@ ) => finalValue.some((val) => get(item, realKey) == val);

return <T extends CollectionItem = CollectionItem>(
item: T
item: T,
// biome-ignore lint/suspicious/noDoubleEquals: we want implicit type coercion

@@ -448,3 +451,3 @@ ) => get(item, realKey) == value;

items: T[],
filter: Filter
filter: Filter,
) {

@@ -461,5 +464,5 @@ if (typeof filter === 'function') {

const filterWithQuery = <
T2 extends CollectionItem = CollectionItem
T2 extends CollectionItem = CollectionItem,
>(
item: T2
item: T2,
) => {

@@ -492,7 +495,7 @@ for (const itemKey in item) {

return <T2 extends CollectionItem = CollectionItem>(
item: T2
item: T2,
): boolean => {
const arrayOfObjectsPaths = getArrayOfObjectsPaths(
keyParts,
item
item,
);

@@ -522,4 +525,4 @@

(selected, filterFunction) => selected && filterFunction(item),
true
)
true,
),
);

@@ -532,3 +535,3 @@ }

items: T[],
sort: Sort
sort: Sort,
) {

@@ -567,3 +570,3 @@ if (typeof sort === 'function') {

items: T[],
range: Range
range: Range,
) {

@@ -573,3 +576,3 @@ if (Array.isArray(range)) {

range[0],
range[1] !== undefined ? range[1] + 1 : undefined
range[1] !== undefined ? range[1] + 1 : undefined,
);

@@ -576,0 +579,0 @@ }

@@ -61,7 +61,7 @@ import { Database } from './Database.ts';

],
})
}),
);
server.addCollection(
'baz',
new Collection({ items: [{ id: 1, name: 'baz' }] })
new Collection({ items: [{ id: 1, name: 'baz' }] }),
);

@@ -85,3 +85,3 @@ expect(server.getAll('foo')).toEqual([

],
})
}),
);

@@ -106,3 +106,3 @@ const params = {

'foo',
new Collection({ items: [{ id: 1, name: 'foo' }] })
new Collection({ items: [{ id: 1, name: 'foo' }] }),
);

@@ -123,3 +123,3 @@ expect(() => {

],
})
}),
);

@@ -140,3 +140,3 @@ expect(server.getOne('foo', 1)).toEqual({ id: 1, name: 'foo' });

identifierName: '_id',
})
}),
);

@@ -143,0 +143,0 @@ expect(server.getOne('foo', 1)).toEqual({ _id: 1, name: 'foo' });

@@ -37,3 +37,3 @@ import { Collection } from './Collection.ts';

getNewId: this.getNewId,
})
}),
);

@@ -48,3 +48,3 @@ } else {

name: string,
collection: Collection<T>
collection: Collection<T>,
) {

@@ -66,3 +66,3 @@ this.collections[name] = collection;

name: string,
single: Single<T>
single: Single<T>,
) {

@@ -110,3 +110,3 @@ this.singles[name] = single;

getNewId: this.getNewId,
})
}),
);

@@ -113,0 +113,0 @@ }

@@ -47,3 +47,3 @@ import type { Collection } from './Collection.ts';

const matches = normalizedRequest.url?.match(
new RegExp(`^${this.baseUrl}\\/(${name})(\\/?.*)?$`)
new RegExp(`^${this.baseUrl}\\/(${name})(\\/?.*)?$`),
);

@@ -58,3 +58,3 @@ if (!matches) continue;

const matches = normalizedRequest.url?.match(
new RegExp(`^${this.baseUrl}\\/([^\\/?]+)(\\/(\\w))?(\\?.*)?$`)
new RegExp(`^${this.baseUrl}\\/([^\\/?]+)(\\/(\\w))?(\\?.*)?$`),
);

@@ -66,3 +66,3 @@ if (matches) {

this.defaultQuery(name),
normalizedRequest.params
normalizedRequest.params,
);

@@ -110,3 +110,3 @@

const matches = context.url?.match(
new RegExp(`^${this.baseUrl}\\/(${name})(\\/?.*)?$`)
new RegExp(`^${this.baseUrl}\\/(${name})(\\/?.*)?$`),
);

@@ -143,3 +143,3 @@ if (!matches) continue;

name,
context.requestBody
context.requestBody,
),

@@ -169,3 +169,3 @@ headers: {

name,
context.requestBody
context.requestBody,
),

@@ -187,3 +187,3 @@ headers: {

const matches = context.url?.match(
new RegExp(`^${this.baseUrl}\\/([^\\/?]+)(\\/(\\w))?(\\?.*)?$`)
new RegExp(`^${this.baseUrl}\\/([^\\/?]+)(\\/(\\w))?(\\?.*)?$`),
);

@@ -197,3 +197,3 @@ if (!matches) {

this.defaultQuery(name),
context.params
context.params,
);

@@ -207,3 +207,3 @@ if (!matches[2]) {

name,
params.filter ? { filter: params.filter } : {}
params.filter ? { filter: params.filter } : {},
);

@@ -217,3 +217,3 @@ if (count > 0) {

items.length - 1 + first,
params.range[1]
params.range[1],
)

@@ -251,3 +251,3 @@ : items.length - 1;

name,
context.requestBody
context.requestBody,
);

@@ -303,3 +303,3 @@ const newResourceURI = `${this.baseUrl}/${name}/${

id,
context.requestBody
context.requestBody,
),

@@ -330,3 +330,3 @@ headers: {

id,
context.requestBody
context.requestBody,
),

@@ -373,3 +373,3 @@ headers: {

name: string,
collection: Collection<T>
collection: Collection<T>,
) {

@@ -389,3 +389,3 @@ this.database.addCollection(name, collection);

name: string,
single: Single<T>
single: Single<T>,
) {

@@ -406,3 +406,3 @@ this.database.addSingle(name, single);

context: FakeRestContext,
next: (context: FakeRestContext) => Promise<BaseResponse> | BaseResponse
next: (context: FakeRestContext) => Promise<BaseResponse> | BaseResponse,
) => Promise<BaseResponse> | BaseResponse;

@@ -409,0 +409,0 @@

@@ -27,3 +27,3 @@ import { Single } from './Single.ts';

}).toThrow(
new Error("Can't embed a non-existing collection bar")
new Error("Can't embed a non-existing collection bar"),
);

@@ -69,3 +69,3 @@ });

}).toThrow(
new Error("Can't embed a non-existing collection bars")
new Error("Can't embed a non-existing collection bars"),
);

@@ -132,3 +132,3 @@ });

expect(foo.getOnly({ embed: ['bars', 'bazs'] })).toEqual(
expected
expected,
);

@@ -135,0 +135,0 @@ });

@@ -12,3 +12,3 @@ import type { Database } from './Database.ts';

throw new Error(
"Can't initialize a Single with anything except an object"
"Can't initialize a Single with anything except an object",
);

@@ -42,3 +42,3 @@ }

throw new Error(
`Can't embed a non-existing collection ${resourceName}`
`Can't embed a non-existing collection ${resourceName}`,
);

@@ -51,3 +51,3 @@ // We have an array of ids {posts: [1,2]} (back refs are not valid

item[resourceName].indexOf(
i[otherCollection.identifierName]
i[otherCollection.identifierName],
) !== -1,

@@ -70,3 +70,3 @@ });

throw new Error(
`Can't embed a non-existing collection ${resourceName}`
`Can't embed a non-existing collection ${resourceName}`,
);

@@ -76,3 +76,3 @@ try {

item[resourceName] = otherCollection.getOne(
item[referenceName]
item[referenceName],
);

@@ -91,3 +91,3 @@ } catch (e) {

? this._oneToManyEmbedder(resourceName)
: this._manyToOneEmbedder(resourceName)
: this._manyToOneEmbedder(resourceName),
);

@@ -97,3 +97,3 @@ return (item: T) =>

(itemWithEmbeds, embedder) => embedder(itemWithEmbeds),
item
item,
);

@@ -100,0 +100,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc