This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 230
/
Copy pathbackend.service.js.map
1 lines (1 loc) · 41.5 KB
/
backend.service.js.map
1
{"version":3,"file":"backend.service.js","sourceRoot":"","sources":["backend.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAIL,qBAAqB,EAGrB,QAAQ,EAER,mBAAmB,EAKpB,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH;IAOE,wBACY,cAAiC,EAC3C,MAAsC;QAAtC,uBAAA,EAAA,WAAsC;QAD5B,mBAAc,GAAd,cAAc,CAAmB;QAPnC,WAAM,GAA8B,IAAI,qBAAqB,EAAE,CAAC;QAIhE,qBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAMtD,IAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAK,iCAAiC;QAClE,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,+CAA+C;QAChF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAGD,sBAAc,mCAAO;QADrB,qBAAqB;aACrB;YACE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;gBACxB,oCAAoC;gBACpC,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,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,CAAC,OAAO,CAAC,CAAC;QACjD,IAAM,GAAG,GAAG,EAAE,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACpC,OAAQ,EAAU,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,EAAkB,CAAC,CAAC,CAAC;gBACnE,EAAE,CAAC,EAAE,CAAC,CAAC;QACd,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,UAAC,CAAK;YAChC,KAAI,CAAC,EAAE,GAAG,CAAC,CAAC;YACZ,KAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEH,qBAAC;AAAD,CAAC,AAzoBD,IAyoBC","sourcesContent":["import { Observable, Observer, BehaviorSubject, of, from } from 'rxjs';\nimport { concatMap, first } from 'rxjs/operators';\n\nimport { getStatusText, isSuccess, STATUS } from './http-status-codes';\nimport { delayResponse } from './delay-response';\n\nimport {\n HeadersCore,\n RequestInfoUtilities,\n InMemoryDbService,\n InMemoryBackendConfig,\n InMemoryBackendConfigArgs,\n ParsedRequestUrl,\n parseUri,\n PassThruBackend,\n removeTrailingSlash,\n RequestCore,\n RequestInfo,\n ResponseOptions,\n UriInfo\n} from './interfaces';\n\n/**\n * Base class for in-memory web api back-ends\n * Simulate the behavior of a RESTy web api\n * backed by the simple in-memory data store provided by the injected `InMemoryDbService` service.\n * Conforms mostly to behavior described here:\n * http://www.restapitutorial.com/lessons/httpmethods.html\n */\nexport abstract class BackendService {\n protected config: InMemoryBackendConfigArgs = new InMemoryBackendConfig();\n protected db: Object;\n protected dbReadySubject: BehaviorSubject<boolean>;\n private passThruBackend: PassThruBackend;\n protected requestInfoUtils = this.getRequestInfoUtils();\n\n constructor(\n protected inMemDbService: InMemoryDbService,\n config: InMemoryBackendConfigArgs = {}\n ) {\n const loc = this.getLocation('/');\n this.config.host = loc.host; // default to app web server host\n this.config.rootPath = loc.path; // default to path when app is served (e.g.'/')\n Object.assign(this.config, config);\n }\n\n //// protected /////\n protected get dbReady(): Observable<boolean> {\n if (!this.dbReadySubject) {\n // first time the service is called.\n this.dbReadySubject = new BehaviorSubject(false);\n this.resetDb();\n }\n return this.dbReadySubject.asObservable().pipe(first((r: boolean) => r));\n }\n\n /**\n * Process Request and return an Observable of Http Response object\n * in the manner of a RESTy web api.\n *\n * Expect URI pattern in the form :base/:collectionName/:id?\n * Examples:\n * // for store with a 'customers' collection\n * GET api/customers // all customers\n * GET api/customers/42 // the character with id=42\n * GET api/customers?name=^j // 'j' is a regex; returns customers whose name starts with 'j' or 'J'\n * GET api/customers.json/42 // ignores the \".json\"\n *\n * Also accepts direct commands to the service in which the last segment of the apiBase is the word \"commands\"\n * Examples:\n * POST commands/resetDb,\n * GET/POST commands/config - get or (re)set the config\n *\n * HTTP overrides:\n * If the injected inMemDbService defines an HTTP method (lowercase)\n * The request is forwarded to that method as in\n * `inMemDbService.get(requestInfo)`\n * which must return either an Observable of the response type\n * for this http library or null|undefined (which means \"keep processing\").\n */\n protected handleRequest(req: RequestCore): Observable<any> {\n // handle the request when there is an in-memory database\n return this.dbReady.pipe(concatMap(() => this.handleRequest_(req)));\n }\n\n protected handleRequest_(req: RequestCore): Observable<any> {\n\n const url = req.urlWithParams ? req.urlWithParams : req.url;\n\n // Try override parser\n // If no override parser or it returns nothing, use default parser\n const parser = this.bind('parseRequestUrl');\n const parsed: ParsedRequestUrl =\n ( parser && parser(url, this.requestInfoUtils)) ||\n this.parseRequestUrl(url);\n\n const collectionName = parsed.collectionName;\n const collection = this.db[collectionName];\n\n const reqInfo: RequestInfo = {\n req: req,\n apiBase: parsed.apiBase,\n collection: collection,\n collectionName: collectionName,\n headers: this.createHeaders({ 'Content-Type': 'application/json' }),\n id: this.parseId(collection, collectionName, parsed.id),\n method: this.getRequestMethod(req),\n query: parsed.query,\n resourceUrl: parsed.resourceUrl,\n url: url,\n utils: this.requestInfoUtils\n };\n\n let resOptions: ResponseOptions;\n\n if (/commands\\/?$/i.test(reqInfo.apiBase)) {\n return this.commands(reqInfo);\n }\n\n const methodInterceptor = this.bind(reqInfo.method);\n if (methodInterceptor) {\n // InMemoryDbService intercepts this HTTP method.\n // if interceptor produced a response, return it.\n // else InMemoryDbService chose not to intercept; continue processing.\n const interceptorResponse = methodInterceptor(reqInfo);\n if (interceptorResponse) {\n return interceptorResponse;\n };\n }\n\n if (this.db[collectionName]) {\n // request is for a known collection of the InMemoryDbService\n return this.createResponse$(() => this.collectionHandler(reqInfo));\n }\n\n if (this.config.passThruUnknownUrl) {\n // unknown collection; pass request thru to a \"real\" backend.\n return this.getPassThruBackend().handle(req);\n }\n\n // 404 - can't handle this request\n resOptions = this.createErrorResponseOptions(\n url,\n STATUS.NOT_FOUND,\n `Collection '${collectionName}' not found`\n );\n return this.createResponse$(() => resOptions);\n }\n\n /**\n * Add configured delay to response observable unless delay === 0\n */\n protected addDelay(response: Observable<any>): Observable<any> {\n const d = this.config.delay;\n return d === 0 ? response : delayResponse(response, d || 500);\n }\n\n /**\n * Apply query/search parameters as a filter over the collection\n * This impl only supports RegExp queries on string properties of the collection\n * ANDs the conditions together\n */\n protected applyQuery(collection: any[], query: Map<string, string[]>): any[] {\n // extract filtering conditions - {propertyName, RegExps) - from query/search parameters\n const conditions: { name: string, rx: RegExp }[] = [];\n const caseSensitive = this.config.caseSensitiveSearch ? undefined : 'i';\n query.forEach((value: string[], name: string) => {\n value.forEach(v => conditions.push({ name, rx: new RegExp(decodeURI(v), caseSensitive) }));\n });\n\n const len = conditions.length;\n if (!len) { return collection; }\n\n // AND the RegExp conditions\n return collection.filter(row => {\n let ok = true;\n let i = len;\n while (ok && i) {\n i -= 1;\n const cond = conditions[i];\n ok = cond.rx.test(row[cond.name]);\n }\n return ok;\n });\n }\n\n /**\n * Get a method from the `InMemoryDbService` (if it exists), bound to that service\n */\n protected bind<T extends Function>(methodName: string) {\n const fn = this.inMemDbService[methodName] as T;\n return fn ? <T> fn.bind(this.inMemDbService) : undefined;\n }\n\n protected bodify(data: any) {\n return this.config.dataEncapsulation ? { data } : data;\n }\n\n protected clone(data: any) {\n return JSON.parse(JSON.stringify(data));\n }\n\n protected collectionHandler(reqInfo: RequestInfo): ResponseOptions {\n // const req = reqInfo.req;\n let resOptions: ResponseOptions;\n switch (reqInfo.method) {\n case 'get':\n resOptions = this.get(reqInfo);\n break;\n case 'post':\n resOptions = this.post(reqInfo);\n break;\n case 'put':\n resOptions = this.put(reqInfo);\n break;\n case 'delete':\n resOptions = this.delete(reqInfo);\n break;\n default:\n resOptions = this.createErrorResponseOptions(reqInfo.url, STATUS.METHOD_NOT_ALLOWED, 'Method not allowed');\n break;\n }\n\n // If `inMemDbService.responseInterceptor` exists, let it morph the response options\n const interceptor = this.bind('responseInterceptor');\n return interceptor ? interceptor(resOptions, reqInfo) : resOptions;\n }\n\n /**\n * Commands reconfigure the in-memory web api service or extract information from it.\n * Commands ignore the latency delay and respond ASAP.\n *\n * When the last segment of the `apiBase` path is \"commands\",\n * the `collectionName` is the command.\n *\n * Example URLs:\n * commands/resetdb (POST) // Reset the \"database\" to its original state\n * commands/config (GET) // Return this service's config object\n * commands/config (POST) // Update the config (e.g. the delay)\n *\n * Usage:\n * http.post('commands/resetdb', undefined);\n * http.get('commands/config');\n * http.post('commands/config', '{\"delay\":1000}');\n */\n protected commands(reqInfo: RequestInfo): Observable<any> {\n const command = reqInfo.collectionName.toLowerCase();\n const method = reqInfo.method;\n\n let resOptions: ResponseOptions = {\n url: reqInfo.url\n };\n\n switch (command) {\n case 'resetdb':\n resOptions.status = STATUS.NO_CONTENT;\n return this.resetDb(reqInfo).pipe(\n concatMap(() => this.createResponse$(() => resOptions, false /* no latency delay */))\n );\n\n case 'config':\n if (method === 'get') {\n resOptions.status = STATUS.OK;\n resOptions.body = this.clone(this.config);\n\n // any other HTTP method is assumed to be a config update\n } else {\n const body = this.getJsonBody(reqInfo.req);\n Object.assign(this.config, body);\n this.passThruBackend = undefined; // re-create when needed\n\n resOptions.status = STATUS.NO_CONTENT;\n }\n break;\n\n default:\n resOptions = this.createErrorResponseOptions(\n reqInfo.url,\n STATUS.INTERNAL_SERVER_ERROR,\n `Unknown command \"${command}\"`\n );\n }\n\n return this.createResponse$(() => resOptions, false /* no latency delay */);\n }\n\n protected createErrorResponseOptions(url: string, status: number, message: string): ResponseOptions {\n return {\n body: { error: `${message}` },\n url: url,\n headers: this.createHeaders({ 'Content-Type': 'application/json' }),\n status: status\n };\n }\n\n /**\n * Create standard HTTP headers object from hash map of header strings\n * @param headers\n */\n protected abstract createHeaders(headers: {[index: string]: string}): HeadersCore;\n\n /**\n * create the function that passes unhandled requests through to the \"real\" backend.\n */\n protected abstract createPassThruBackend(): PassThruBackend;\n\n /**\n * return a search map from a location query/search string\n */\n protected abstract createQueryMap(search: string): Map<string, string[]>;\n\n /**\n * Create a cold response Observable from a factory for ResponseOptions\n * @param resOptionsFactory - creates ResponseOptions when observable is subscribed\n * @param withDelay - if true (default), add simulated latency delay from configuration\n */\n protected createResponse$(resOptionsFactory: () => ResponseOptions, withDelay = true): Observable<any> {\n const resOptions$ = this.createResponseOptions$(resOptionsFactory);\n let resp$ = this.createResponse$fromResponseOptions$(resOptions$);\n return withDelay ? this.addDelay(resp$) : resp$;\n }\n\n /**\n * Create a Response observable from ResponseOptions observable.\n */\n protected abstract createResponse$fromResponseOptions$(resOptions$: Observable<ResponseOptions>): Observable<any>;\n\n /**\n * Create a cold Observable of ResponseOptions.\n * @param resOptionsFactory - creates ResponseOptions when observable is subscribed\n */\n protected createResponseOptions$(resOptionsFactory: () => ResponseOptions): Observable<ResponseOptions> {\n\n return new Observable<ResponseOptions>((responseObserver: Observer<ResponseOptions>) => {\n let resOptions: ResponseOptions;\n try {\n resOptions = resOptionsFactory();\n } catch (error) {\n const err = error.message || error;\n resOptions = this.createErrorResponseOptions('', STATUS.INTERNAL_SERVER_ERROR, `${err}`);\n }\n\n const status = resOptions.status;\n try {\n resOptions.statusText = getStatusText(status);\n } catch (e) { /* ignore failure */}\n if (isSuccess(status)) {\n responseObserver.next(resOptions);\n responseObserver.complete();\n } else {\n responseObserver.error(resOptions);\n }\n return () => { }; // unsubscribe function\n });\n }\n\n protected delete({ collection, collectionName, headers, id, url}: RequestInfo): ResponseOptions {\n // tslint:disable-next-line:triple-equals\n if (id == undefined) {\n return this.createErrorResponseOptions(url, STATUS.NOT_FOUND, `Missing \"${collectionName}\" id`);\n }\n const exists = this.removeById(collection, id);\n return {\n headers: headers,\n status: (exists || !this.config.delete404) ? STATUS.NO_CONTENT : STATUS.NOT_FOUND\n };\n }\n\n /**\n * Find first instance of item in collection by `item.id`\n * @param collection\n * @param id\n */\n protected findById<T extends { id: any }>(collection: T[], id: any): T {\n return collection.find((item: T) => item.id === id);\n }\n\n /**\n * Generate the next available id for item in this collection\n * Use method from `inMemDbService` if it exists and returns a value,\n * else delegates to `genIdDefault`.\n * @param collection - collection of items with `id` key property\n */\n protected genId<T extends { id: any }>(collection: T[], collectionName: string): any {\n const genId = this.bind('genId');\n if (genId) {\n const id = genId(collection, collectionName);\n // tslint:disable-next-line:triple-equals\n if (id != undefined) { return id; }\n }\n return this.genIdDefault(collection, collectionName);\n }\n\n /**\n * Default generator of the next available id for item in this collection\n * This default implementation works only for numeric ids.\n * @param collection - collection of items with `id` key property\n * @param collectionName - name of the collection\n */\n protected genIdDefault<T extends { id: any }>(collection: T[], collectionName: string): any {\n if (!this.isCollectionIdNumeric(collection, collectionName)) {\n throw new Error(\n `Collection '${collectionName}' id type is non-numeric or unknown. Can only generate numeric ids.`);\n }\n\n let maxId = 0;\n collection.reduce((prev: any, item: any) => {\n maxId = Math.max(maxId, typeof item.id === 'number' ? item.id : maxId);\n }, undefined);\n return maxId + 1;\n }\n\n protected get({ collection, collectionName, headers, id, query, url }: RequestInfo): ResponseOptions {\n let data = collection;\n\n // tslint:disable-next-line:triple-equals\n if (id != undefined && id !== '') {\n data = this.findById(collection, id);\n } else if (query) {\n data = this.applyQuery(collection, query);\n }\n\n if (!data) {\n return this.createErrorResponseOptions(url, STATUS.NOT_FOUND, `'${collectionName}' with id='${id}' not found`);\n }\n return {\n body: this.bodify(this.clone(data)),\n headers: headers,\n status: STATUS.OK\n };\n }\n\n /** Get JSON body from the request object */\n protected abstract getJsonBody(req: any): any;\n\n /**\n * Get location info from a url, even on server where `document` is not defined\n */\n protected getLocation(url: string): UriInfo {\n if (!url.startsWith('http')) {\n // get the document iff running in browser\n const doc: Document = (typeof document === 'undefined') ? undefined : document;\n // add host info to url before parsing. Use a fake host when not in browser.\n const base = doc ? doc.location.protocol + '//' + doc.location.host : 'http://fake';\n url = url.startsWith('/') ? base + url : base + '/' + url;\n }\n return parseUri(url);\n };\n\n /**\n * get or create the function that passes unhandled requests\n * through to the \"real\" backend.\n */\n protected getPassThruBackend(): PassThruBackend {\n return this.passThruBackend ?\n this.passThruBackend :\n this.passThruBackend = this.createPassThruBackend();\n }\n\n /**\n * Get utility methods from this service instance.\n * Useful within an HTTP method override\n */\n protected getRequestInfoUtils(): RequestInfoUtilities {\n return {\n createResponse$: this.createResponse$.bind(this),\n findById: this.findById.bind(this),\n isCollectionIdNumeric: this.isCollectionIdNumeric.bind(this),\n getConfig: () => this.config,\n getDb: () => this.db,\n getJsonBody: this.getJsonBody.bind(this),\n getLocation: this.getLocation.bind(this),\n getPassThruBackend: this.getPassThruBackend.bind(this),\n parseRequestUrl: this.parseRequestUrl.bind(this),\n };\n }\n\n /**\n * return canonical HTTP method name (lowercase) from the request object\n * e.g. (req.method || 'get').toLowerCase();\n * @param req - request object from the http call\n *\n */\n protected abstract getRequestMethod(req: any): string;\n\n protected indexOf(collection: any[], id: number) {\n return collection.findIndex((item: any) => item.id === id);\n }\n\n /** Parse the id as a number. Return original value if not a number. */\n protected parseId(collection: any[], collectionName: string, id: string): any {\n if (!this.isCollectionIdNumeric(collection, collectionName)) {\n // Can't confirm that `id` is a numeric type; don't parse as a number\n // or else `'42'` -> `42` and _get by id_ fails.\n return id;\n }\n const idNum = parseFloat(id);\n return isNaN(idNum) ? id : idNum;\n }\n\n /**\n * return true if can determine that the collection's `item.id` is a number\n * This implementation can't tell if the collection is empty so it assumes NO\n * */\n protected isCollectionIdNumeric<T extends { id: any }>(collection: T[], collectionName: string): boolean {\n // collectionName not used now but override might maintain collection type information\n // so that it could know the type of the `id` even when the collection is empty.\n return !!(collection && collection[0]) && typeof collection[0].id === 'number';\n }\n\n /**\n * Parses the request URL into a `ParsedRequestUrl` object.\n * Parsing depends upon certain values of `config`: `apiBase`, `host`, and `urlRoot`.\n *\n * Configuring the `apiBase` yields the most interesting changes to `parseRequestUrl` behavior:\n * When apiBase=undefined and url='http://localhost/api/collection/42'\n * {base: 'api/', collectionName: 'collection', id: '42', ...}\n * When apiBase='some/api/root/' and url='http://localhost/some/api/root/collection'\n * {base: 'some/api/root/', collectionName: 'collection', id: undefined, ...}\n * When apiBase='/' and url='http://localhost/collection'\n * {base: '/', collectionName: 'collection', id: undefined, ...}\n *\n * The actual api base segment values are ignored. Only the number of segments matters.\n * The following api base strings are considered identical: 'a/b' ~ 'some/api/' ~ `two/segments'\n *\n * To replace this default method, assign your alternative to your InMemDbService['parseRequestUrl']\n */\n protected parseRequestUrl(url: string): ParsedRequestUrl {\n try {\n const loc = this.getLocation(url);\n let drop = this.config.rootPath.length;\n let urlRoot = '';\n if (loc.host !== this.config.host) {\n // url for a server on a different host!\n // assume it's collection is actually here too.\n drop = 1; // the leading slash\n urlRoot = loc.protocol + '//' + loc.host + '/';\n }\n const path = loc.path.substring(drop);\n const pathSegments = path.split('/');\n let segmentIx = 0;\n\n // apiBase: the front part of the path devoted to getting to the api route\n // Assumes first path segment if no config.apiBase\n // else ignores as many path segments as are in config.apiBase\n // Does NOT care what the api base chars actually are.\n let apiBase: string;\n // tslint:disable-next-line:triple-equals\n if (this.config.apiBase == undefined) {\n apiBase = pathSegments[segmentIx++];\n } else {\n apiBase = removeTrailingSlash(this.config.apiBase.trim());\n if (apiBase) {\n segmentIx = apiBase.split('/').length;\n } else {\n segmentIx = 0; // no api base at all; unwise but allowed.\n }\n }\n apiBase += '/';\n\n let collectionName = pathSegments[segmentIx++];\n // ignore anything after a '.' (e.g.,the \"json\" in \"customers.json\")\n collectionName = collectionName && collectionName.split('.')[0];\n\n const id = pathSegments[segmentIx++];\n const query = this.createQueryMap(loc.query);\n const resourceUrl = urlRoot + apiBase + collectionName + '/';\n return { apiBase, collectionName, id, query, resourceUrl };\n\n } catch (err) {\n const msg = `unable to parse url '${url}'; original error: ${err.message}`;\n throw new Error(msg);\n }\n }\n\n // Create entity\n // Can update an existing entity too if post409 is false.\n protected post({ collection, collectionName, headers, id, req, resourceUrl, url }: RequestInfo): ResponseOptions {\n const item = this.clone(this.getJsonBody(req));\n\n // tslint:disable-next-line:triple-equals\n if (item.id == undefined) {\n try {\n item.id = id || this.genId(collection, collectionName);\n } catch (err) {\n const emsg: string = err.message || '';\n if (/id type is non-numeric/.test(emsg)) {\n return this.createErrorResponseOptions(url, STATUS.UNPROCESSABLE_ENTRY, emsg);\n } else {\n console.error(err);\n return this.createErrorResponseOptions(url, STATUS.INTERNAL_SERVER_ERROR,\n `Failed to generate new id for '${collectionName}'`);\n }\n }\n }\n\n if (id && id !== item.id) {\n return this.createErrorResponseOptions(url, STATUS.BAD_REQUEST, `Request id does not match item.id`);\n } else {\n id = item.id;\n }\n const existingIx = this.indexOf(collection, id);\n const body = this.bodify(item);\n\n if (existingIx === -1) {\n collection.push(item);\n headers.set('Location', resourceUrl + '/' + id);\n return { headers, body, status: STATUS.CREATED };\n } else if (this.config.post409) {\n return this.createErrorResponseOptions(url, STATUS.CONFLICT,\n `'${collectionName}' item with id='${id} exists and may not be updated with POST; use PUT instead.`);\n } else {\n collection[existingIx] = item;\n return this.config.post204 ?\n { headers, status: STATUS.NO_CONTENT } : // successful; no content\n { headers, body, status: STATUS.OK }; // successful; return entity\n }\n }\n\n // Update existing entity\n // Can create an entity too if put404 is false.\n protected put({ collection, collectionName, headers, id, req, url }: RequestInfo): ResponseOptions {\n const item = this.clone(this.getJsonBody(req));\n // tslint:disable-next-line:triple-equals\n if (item.id == undefined) {\n return this.createErrorResponseOptions(url, STATUS.NOT_FOUND, `Missing '${collectionName}' id`);\n }\n if (id && id !== item.id) {\n return this.createErrorResponseOptions(url, STATUS.BAD_REQUEST,\n `Request for '${collectionName}' id does not match item.id`);\n } else {\n id = item.id;\n }\n const existingIx = this.indexOf(collection, id);\n const body = this.bodify(item);\n\n if (existingIx > -1) {\n collection[existingIx] = item;\n return this.config.put204 ?\n { headers, status: STATUS.NO_CONTENT } : // successful; no content\n { headers, body, status: STATUS.OK }; // successful; return entity\n } else if (this.config.put404) {\n // item to update not found; use POST to create new item for this id.\n return this.createErrorResponseOptions(url, STATUS.NOT_FOUND,\n `'${collectionName}' item with id='${id} not found and may not be created with PUT; use POST instead.`);\n } else {\n // create new item for id not found\n collection.push(item);\n return { headers, body, status: STATUS.CREATED };\n }\n }\n\n protected removeById(collection: any[], id: number) {\n const ix = this.indexOf(collection, id);\n if (ix > -1) {\n collection.splice(ix, 1);\n return true;\n }\n return false;\n }\n\n /**\n * Tell your in-mem \"database\" to reset.\n * returns Observable of the database because resetting it could be async\n */\n protected resetDb(reqInfo?: RequestInfo): Observable<boolean> {\n this.dbReadySubject.next(false);\n const db = this.inMemDbService.createDb(reqInfo);\n const db$ = db instanceof Observable ? db :\n typeof (db as any).then === 'function' ? from(db as Promise<any>) :\n of(db);\n db$.pipe(first()).subscribe((d: {}) => {\n this.db = d;\n this.dbReadySubject.next(true);\n });\n return this.dbReady;\n }\n\n}\n"]}