UNPKG

37.1 kBJavaScriptView Raw
1System.register("in-memory-web-api/in-memory-backend.service", ["@angular/core", "@angular/http", "rxjs/Observable", "rxjs/add/operator/delay", "./http-status-codes"], function(exports_1, context_1) {
2 "use strict";
3 var __moduleName = context_1 && context_1.id;
4 var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
5 var c = arguments.length,
6 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
7 d;
8 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
9 r = Reflect.decorate(decorators, target, key, desc);
10 else
11 for (var i = decorators.length - 1; i >= 0; i--)
12 if (d = decorators[i])
13 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14 return c > 3 && r && Object.defineProperty(target, key, r), r;
15 };
16 var __metadata = (this && this.__metadata) || function(k, v) {
17 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
18 return Reflect.metadata(k, v);
19 };
20 var __param = (this && this.__param) || function(paramIndex, decorator) {
21 return function(target, key) {
22 decorator(target, key, paramIndex);
23 };
24 };
25 var core_1,
26 http_1,
27 Observable_1,
28 http_status_codes_1;
29 var SEED_DATA,
30 InMemoryBackendConfig,
31 isSuccess,
32 InMemoryBackendService;
33 return {
34 setters: [function(core_1_1) {
35 core_1 = core_1_1;
36 }, function(http_1_1) {
37 http_1 = http_1_1;
38 }, function(Observable_1_1) {
39 Observable_1 = Observable_1_1;
40 }, function(_1) {}, function(http_status_codes_1_1) {
41 http_status_codes_1 = http_status_codes_1_1;
42 }],
43 execute: function() {
44 exports_1("SEED_DATA", SEED_DATA = new core_1.OpaqueToken('seedData'));
45 InMemoryBackendConfig = (function() {
46 function InMemoryBackendConfig(config) {
47 if (config === void 0) {
48 config = {};
49 }
50 Object.assign(this, {
51 defaultResponseOptions: new http_1.BaseResponseOptions(),
52 delay: 500,
53 delete404: false
54 }, config);
55 }
56 return InMemoryBackendConfig;
57 }());
58 exports_1("InMemoryBackendConfig", InMemoryBackendConfig);
59 exports_1("isSuccess", isSuccess = function(status) {
60 return (status >= 200 && status < 300);
61 });
62 InMemoryBackendService = (function() {
63 function InMemoryBackendService(_seedData, config) {
64 this._seedData = _seedData;
65 this._config = new InMemoryBackendConfig();
66 this._resetDb();
67 var loc = this._getLocation('./');
68 this._config.host = loc.host;
69 this._config.rootPath = loc.pathname;
70 Object.assign(this._config, config);
71 }
72 InMemoryBackendService.prototype.createConnection = function(req) {
73 var res = this._handleRequest(req);
74 var response = new Observable_1.Observable(function(responseObserver) {
75 if (isSuccess(res.status)) {
76 responseObserver.next(res);
77 responseObserver.complete();
78 } else {
79 responseObserver.error(res);
80 }
81 return function() {};
82 });
83 response = response.delay(this._config.delay || 500);
84 return {response: response};
85 };
86 InMemoryBackendService.prototype._handleRequest = function(req) {
87 var _a = this._parseUrl(req.url),
88 base = _a.base,
89 collectionName = _a.collectionName,
90 id = _a.id,
91 resourceUrl = _a.resourceUrl;
92 var reqInfo = {
93 req: req,
94 base: base,
95 collection: this._db[collectionName],
96 collectionName: collectionName,
97 headers: new http_1.Headers({'Content-Type': 'application/json'}),
98 id: this._parseId(id),
99 resourceUrl: resourceUrl
100 };
101 var options;
102 try {
103 if ('commands' === reqInfo.base.toLowerCase()) {
104 options = this._commands(reqInfo);
105 } else if (reqInfo.collection) {
106 switch (req.method) {
107 case http_1.RequestMethod.Get:
108 options = this._get(reqInfo);
109 break;
110 case http_1.RequestMethod.Post:
111 options = this._post(reqInfo);
112 break;
113 case http_1.RequestMethod.Put:
114 options = this._put(reqInfo);
115 break;
116 case http_1.RequestMethod.Delete:
117 options = this._delete(reqInfo);
118 break;
119 default:
120 options = this._createErrorResponse(http_status_codes_1.STATUS.METHOD_NOT_ALLOWED, 'Method not allowed');
121 break;
122 }
123 } else {
124 options = this._createErrorResponse(http_status_codes_1.STATUS.NOT_FOUND, "Collection '" + collectionName + "' not found");
125 }
126 } catch (error) {
127 var err = error.message || error;
128 options = this._createErrorResponse(http_status_codes_1.STATUS.INTERNAL_SERVER_ERROR, "" + err);
129 }
130 options = this._setStatusText(options);
131 if (this._config.defaultResponseOptions) {
132 options = this._config.defaultResponseOptions.merge(options);
133 }
134 return new http_1.Response(options);
135 };
136 InMemoryBackendService.prototype._clone = function(data) {
137 return JSON.parse(JSON.stringify(data));
138 };
139 InMemoryBackendService.prototype._commands = function(reqInfo) {
140 var command = reqInfo.collectionName.toLowerCase();
141 var method = reqInfo.req.method;
142 var options;
143 switch (command) {
144 case 'resetdb':
145 this._resetDb();
146 options = new http_1.ResponseOptions({status: http_status_codes_1.STATUS.OK});
147 break;
148 case 'config':
149 if (method === http_1.RequestMethod.Get) {
150 options = new http_1.ResponseOptions({
151 body: this._clone(this._config),
152 status: http_status_codes_1.STATUS.OK
153 });
154 } else {
155 var body = JSON.parse(reqInfo.req.text() || '{}');
156 Object.assign(this._config, body);
157 options = new http_1.ResponseOptions({status: http_status_codes_1.STATUS.NO_CONTENT});
158 }
159 break;
160 default:
161 options = this._createErrorResponse(http_status_codes_1.STATUS.INTERNAL_SERVER_ERROR, "Unknown command \"" + command + "\"");
162 }
163 return options;
164 };
165 InMemoryBackendService.prototype._createErrorResponse = function(status, message) {
166 return new http_1.ResponseOptions({
167 body: {'error': "" + message},
168 headers: new http_1.Headers({'Content-Type': 'application/json'}),
169 status: status
170 });
171 };
172 InMemoryBackendService.prototype._delete = function(_a) {
173 var id = _a.id,
174 collection = _a.collection,
175 collectionName = _a.collectionName,
176 headers = _a.headers;
177 if (!id) {
178 return this._createErrorResponse(http_status_codes_1.STATUS.NOT_FOUND, "Missing \"" + collectionName + "\" id");
179 }
180 var exists = this._removeById(collection, id);
181 return new http_1.ResponseOptions({
182 headers: headers,
183 status: (exists || !this._config.delete404) ? http_status_codes_1.STATUS.NO_CONTENT : http_status_codes_1.STATUS.NOT_FOUND
184 });
185 };
186 InMemoryBackendService.prototype._findById = function(collection, id) {
187 return collection.find(function(item) {
188 return item.id === id;
189 });
190 };
191 InMemoryBackendService.prototype._genId = function(collection) {
192 var maxId = 0;
193 collection.reduce(function(prev, item) {
194 maxId = Math.max(maxId, typeof item.id === 'number' ? item.id : maxId);
195 }, null);
196 return maxId + 1;
197 };
198 InMemoryBackendService.prototype._get = function(_a) {
199 var id = _a.id,
200 collection = _a.collection,
201 collectionName = _a.collectionName,
202 headers = _a.headers;
203 var data = (id) ? this._findById(collection, id) : collection;
204 if (!data) {
205 return this._createErrorResponse(http_status_codes_1.STATUS.NOT_FOUND, "'" + collectionName + "' with id='" + id + "' not found");
206 }
207 return new http_1.ResponseOptions({
208 body: {data: this._clone(data)},
209 headers: headers,
210 status: http_status_codes_1.STATUS.OK
211 });
212 };
213 InMemoryBackendService.prototype._getLocation = function(href) {
214 var l = document.createElement('a');
215 l.href = href;
216 return l;
217 };
218 ;
219 InMemoryBackendService.prototype._indexOf = function(collection, id) {
220 return collection.findIndex(function(item) {
221 return item.id === id;
222 });
223 };
224 InMemoryBackendService.prototype._parseId = function(id) {
225 if (!id) {
226 return null;
227 }
228 var idNum = parseInt(id, 10);
229 return isNaN(idNum) ? id : idNum;
230 };
231 InMemoryBackendService.prototype._parseUrl = function(url) {
232 try {
233 var loc = this._getLocation(url);
234 var drop = this._config.rootPath.length;
235 var urlRoot = '';
236 if (loc.host !== this._config.host) {
237 drop = 1;
238 urlRoot = loc.protocol + '//' + loc.host + '/';
239 }
240 var path = loc.pathname.substring(drop);
241 var _a = path.split('/'),
242 base = _a[0],
243 collectionName = _a[1],
244 id = _a[2];
245 var resourceUrl = urlRoot + base + '/' + collectionName + '/';
246 collectionName = collectionName.split('.')[0];
247 return {
248 base: base,
249 id: id,
250 collectionName: collectionName,
251 resourceUrl: resourceUrl
252 };
253 } catch (err) {
254 var msg = "unable to parse url '" + url + "'; original error: " + err.message;
255 throw new Error(msg);
256 }
257 };
258 InMemoryBackendService.prototype._post = function(_a) {
259 var collection = _a.collection,
260 headers = _a.headers,
261 id = _a.id,
262 req = _a.req,
263 resourceUrl = _a.resourceUrl;
264 var item = JSON.parse(req.text());
265 if (!item.id) {
266 item.id = id || this._genId(collection);
267 }
268 id = item.id;
269 var existingIx = this._indexOf(collection, id);
270 if (existingIx > -1) {
271 collection[existingIx] = item;
272 return new http_1.ResponseOptions({
273 headers: headers,
274 status: http_status_codes_1.STATUS.NO_CONTENT
275 });
276 } else {
277 collection.push(item);
278 headers.set('Location', resourceUrl + '/' + id);
279 return new http_1.ResponseOptions({
280 headers: headers,
281 body: {data: this._clone(item)},
282 status: http_status_codes_1.STATUS.CREATED
283 });
284 }
285 };
286 InMemoryBackendService.prototype._put = function(_a) {
287 var id = _a.id,
288 collection = _a.collection,
289 collectionName = _a.collectionName,
290 headers = _a.headers,
291 req = _a.req;
292 var item = JSON.parse(req.text());
293 if (!id) {
294 return this._createErrorResponse(http_status_codes_1.STATUS.NOT_FOUND, "Missing '" + collectionName + "' id");
295 }
296 if (id !== item.id) {
297 return this._createErrorResponse(http_status_codes_1.STATUS.BAD_REQUEST, "\"" + collectionName + "\" id does not match item.id");
298 }
299 var existingIx = this._indexOf(collection, id);
300 if (existingIx > -1) {
301 collection[existingIx] = item;
302 return new http_1.ResponseOptions({
303 headers: headers,
304 status: http_status_codes_1.STATUS.NO_CONTENT
305 });
306 } else {
307 collection.push(item);
308 return new http_1.ResponseOptions({
309 body: {data: this._clone(item)},
310 headers: headers,
311 status: http_status_codes_1.STATUS.CREATED
312 });
313 }
314 };
315 InMemoryBackendService.prototype._removeById = function(collection, id) {
316 var ix = this._indexOf(collection, id);
317 if (ix > -1) {
318 collection.splice(ix, 1);
319 return true;
320 }
321 return false;
322 };
323 InMemoryBackendService.prototype._resetDb = function() {
324 this._db = this._seedData.createDb();
325 };
326 InMemoryBackendService.prototype._setStatusText = function(options) {
327 try {
328 var statusCode = http_status_codes_1.STATUS_CODE_INFO[options.status];
329 options['statusText'] = statusCode ? statusCode.text : 'Unknown Status';
330 return options;
331 } catch (err) {
332 return new http_1.ResponseOptions({
333 status: http_status_codes_1.STATUS.INTERNAL_SERVER_ERROR,
334 statusText: 'Invalid Server Operation'
335 });
336 }
337 };
338 InMemoryBackendService = __decorate([__param(0, core_1.Inject(SEED_DATA)), __param(1, core_1.Inject(InMemoryBackendConfig)), __param(1, core_1.Optional()), __metadata('design:paramtypes', [Object, Object])], InMemoryBackendService);
339 return InMemoryBackendService;
340 }());
341 exports_1("InMemoryBackendService", InMemoryBackendService);
342 }
343 };
344});
345
346System.register("in-memory-web-api/http-status-codes", [], function(exports_1, context_1) {
347 "use strict";
348 var __moduleName = context_1 && context_1.id;
349 var STATUS,
350 STATUS_CODE_INFO;
351 return {
352 setters: [],
353 execute: function() {
354 exports_1("STATUS", STATUS = {
355 CONTINUE: 100,
356 SWITCHING_PROTOCOLS: 101,
357 OK: 200,
358 CREATED: 201,
359 ACCEPTED: 202,
360 NON_AUTHORITATIVE_INFORMATION: 203,
361 NO_CONTENT: 204,
362 RESET_CONTENT: 205,
363 PARTIAL_CONTENT: 206,
364 MULTIPLE_CHOICES: 300,
365 MOVED_PERMANTENTLY: 301,
366 FOUND: 302,
367 SEE_OTHER: 303,
368 NOT_MODIFIED: 304,
369 USE_PROXY: 305,
370 TEMPORARY_REDIRECT: 307,
371 BAD_REQUEST: 400,
372 UNAUTHORIZED: 401,
373 PAYMENT_REQUIRED: 402,
374 FORBIDDEN: 403,
375 NOT_FOUND: 404,
376 METHOD_NOT_ALLOWED: 405,
377 NOT_ACCEPTABLE: 406,
378 PROXY_AUTHENTICATION_REQUIRED: 407,
379 REQUEST_TIMEOUT: 408,
380 CONFLICT: 409,
381 GONE: 410,
382 LENGTH_REQUIRED: 411,
383 PRECONDITION_FAILED: 412,
384 PAYLOAD_TO_LARGE: 413,
385 URI_TOO_LONG: 414,
386 UNSUPPORTED_MEDIA_TYPE: 415,
387 RANGE_NOT_SATISFIABLE: 416,
388 EXPECTATION_FAILED: 417,
389 IM_A_TEAPOT: 418,
390 UPGRADE_REQUIRED: 426,
391 INTERNAL_SERVER_ERROR: 500,
392 NOT_IMPLEMENTED: 501,
393 BAD_GATEWAY: 502,
394 SERVICE_UNAVAILABLE: 503,
395 GATEWAY_TIMEOUT: 504,
396 HTTP_VERSION_NOT_SUPPORTED: 505,
397 PROCESSING: 102,
398 MULTI_STATUS: 207,
399 IM_USED: 226,
400 PERMANENT_REDIRECT: 308,
401 UNPROCESSABLE_ENTRY: 422,
402 LOCKED: 423,
403 FAILED_DEPENDENCY: 424,
404 PRECONDITION_REQUIRED: 428,
405 TOO_MANY_REQUESTS: 429,
406 REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
407 UNAVAILABLE_FOR_LEGAL_REASONS: 451,
408 VARIANT_ALSO_NEGOTIATES: 506,
409 INSUFFICIENT_STORAGE: 507,
410 NETWORK_AUTHENTICATION_REQUIRED: 511
411 });
412 exports_1("STATUS_CODE_INFO", STATUS_CODE_INFO = {
413 "100": {
414 "code": 100,
415 "text": "Continue",
416 "description": "\"The initial part of a request has been received and has not yet been rejected by the server.\"",
417 "spec_title": "RFC7231#6.2.1",
418 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.2.1"
419 },
420 "101": {
421 "code": 101,
422 "text": "Switching Protocols",
423 "description": "\"The server understands and is willing to comply with the client's request, via the Upgrade header field, for a change in the application protocol being used on this connection.\"",
424 "spec_title": "RFC7231#6.2.2",
425 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.2.2"
426 },
427 "200": {
428 "code": 200,
429 "text": "OK",
430 "description": "\"The request has succeeded.\"",
431 "spec_title": "RFC7231#6.3.1",
432 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.1"
433 },
434 "201": {
435 "code": 201,
436 "text": "Created",
437 "description": "\"The request has been fulfilled and has resulted in one or more new resources being created.\"",
438 "spec_title": "RFC7231#6.3.2",
439 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.2"
440 },
441 "202": {
442 "code": 202,
443 "text": "Accepted",
444 "description": "\"The request has been accepted for processing, but the processing has not been completed.\"",
445 "spec_title": "RFC7231#6.3.3",
446 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.3"
447 },
448 "203": {
449 "code": 203,
450 "text": "Non-Authoritative Information",
451 "description": "\"The request was successful but the enclosed payload has been modified from that of the origin server's 200 (OK) response by a transforming proxy.\"",
452 "spec_title": "RFC7231#6.3.4",
453 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.4"
454 },
455 "204": {
456 "code": 204,
457 "text": "No Content",
458 "description": "\"The server has successfully fulfilled the request and that there is no additional content to send in the response payload body.\"",
459 "spec_title": "RFC7231#6.3.5",
460 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.5"
461 },
462 "205": {
463 "code": 205,
464 "text": "Reset Content",
465 "description": "\"The server has fulfilled the request and desires that the user agent reset the \"document view\", which caused the request to be sent, to its original state as received from the origin server.\"",
466 "spec_title": "RFC7231#6.3.6",
467 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.6"
468 },
469 "206": {
470 "code": 206,
471 "text": "Partial Content",
472 "description": "\"The server is successfully fulfilling a range request for the target resource by transferring one or more parts of the selected representation that correspond to the satisfiable ranges found in the requests's Range header field.\"",
473 "spec_title": "RFC7233#4.1",
474 "spec_href": "http://tools.ietf.org/html/rfc7233#section-4.1"
475 },
476 "300": {
477 "code": 300,
478 "text": "Multiple Choices",
479 "description": "\"The target resource has more than one representation, each with its own more specific identifier, and information about the alternatives is being provided so that the user (or user agent) can select a preferred representation by redirecting its request to one or more of those identifiers.\"",
480 "spec_title": "RFC7231#6.4.1",
481 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.4.1"
482 },
483 "301": {
484 "code": 301,
485 "text": "Moved Permanently",
486 "description": "\"The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.\"",
487 "spec_title": "RFC7231#6.4.2",
488 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.4.2"
489 },
490 "302": {
491 "code": 302,
492 "text": "Found",
493 "description": "\"The target resource resides temporarily under a different URI.\"",
494 "spec_title": "RFC7231#6.4.3",
495 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.4.3"
496 },
497 "303": {
498 "code": 303,
499 "text": "See Other",
500 "description": "\"The server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, that is intended to provide an indirect response to the original request.\"",
501 "spec_title": "RFC7231#6.4.4",
502 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.4.4"
503 },
504 "304": {
505 "code": 304,
506 "text": "Not Modified",
507 "description": "\"A conditional GET request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition has evaluated to false.\"",
508 "spec_title": "RFC7232#4.1",
509 "spec_href": "http://tools.ietf.org/html/rfc7232#section-4.1"
510 },
511 "305": {
512 "code": 305,
513 "text": "Use Proxy",
514 "description": "*deprecated*",
515 "spec_title": "RFC7231#6.4.5",
516 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.4.5"
517 },
518 "307": {
519 "code": 307,
520 "text": "Temporary Redirect",
521 "description": "\"The target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.\"",
522 "spec_title": "RFC7231#6.4.7",
523 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.4.7"
524 },
525 "400": {
526 "code": 400,
527 "text": "Bad Request",
528 "description": "\"The server cannot or will not process the request because the received syntax is invalid, nonsensical, or exceeds some limitation on what the server is willing to process.\"",
529 "spec_title": "RFC7231#6.5.1",
530 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.1"
531 },
532 "401": {
533 "code": 401,
534 "text": "Unauthorized",
535 "description": "\"The request has not been applied because it lacks valid authentication credentials for the target resource.\"",
536 "spec_title": "RFC7235#6.3.1",
537 "spec_href": "http://tools.ietf.org/html/rfc7235#section-3.1"
538 },
539 "402": {
540 "code": 402,
541 "text": "Payment Required",
542 "description": "*reserved*",
543 "spec_title": "RFC7231#6.5.2",
544 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.2"
545 },
546 "403": {
547 "code": 403,
548 "text": "Forbidden",
549 "description": "\"The server understood the request but refuses to authorize it.\"",
550 "spec_title": "RFC7231#6.5.3",
551 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.3"
552 },
553 "404": {
554 "code": 404,
555 "text": "Not Found",
556 "description": "\"The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\"",
557 "spec_title": "RFC7231#6.5.4",
558 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.4"
559 },
560 "405": {
561 "code": 405,
562 "text": "Method Not Allowed",
563 "description": "\"The method specified in the request-line is known by the origin server but not supported by the target resource.\"",
564 "spec_title": "RFC7231#6.5.5",
565 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.5"
566 },
567 "406": {
568 "code": 406,
569 "text": "Not Acceptable",
570 "description": "\"The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.\"",
571 "spec_title": "RFC7231#6.5.6",
572 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.6"
573 },
574 "407": {
575 "code": 407,
576 "text": "Proxy Authentication Required",
577 "description": "\"The client needs to authenticate itself in order to use a proxy.\"",
578 "spec_title": "RFC7231#6.3.2",
579 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.3.2"
580 },
581 "408": {
582 "code": 408,
583 "text": "Request Timeout",
584 "description": "\"The server did not receive a complete request message within the time that it was prepared to wait.\"",
585 "spec_title": "RFC7231#6.5.7",
586 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.7"
587 },
588 "409": {
589 "code": 409,
590 "text": "Conflict",
591 "description": "\"The request could not be completed due to a conflict with the current state of the resource.\"",
592 "spec_title": "RFC7231#6.5.8",
593 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.8"
594 },
595 "410": {
596 "code": 410,
597 "text": "Gone",
598 "description": "\"Access to the target resource is no longer available at the origin server and that this condition is likely to be permanent.\"",
599 "spec_title": "RFC7231#6.5.9",
600 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.9"
601 },
602 "411": {
603 "code": 411,
604 "text": "Length Required",
605 "description": "\"The server refuses to accept the request without a defined Content-Length.\"",
606 "spec_title": "RFC7231#6.5.10",
607 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.10"
608 },
609 "412": {
610 "code": 412,
611 "text": "Precondition Failed",
612 "description": "\"One or more preconditions given in the request header fields evaluated to false when tested on the server.\"",
613 "spec_title": "RFC7232#4.2",
614 "spec_href": "http://tools.ietf.org/html/rfc7232#section-4.2"
615 },
616 "413": {
617 "code": 413,
618 "text": "Payload Too Large",
619 "description": "\"The server is refusing to process a request because the request payload is larger than the server is willing or able to process.\"",
620 "spec_title": "RFC7231#6.5.11",
621 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.11"
622 },
623 "414": {
624 "code": 414,
625 "text": "URI Too Long",
626 "description": "\"The server is refusing to service the request because the request-target is longer than the server is willing to interpret.\"",
627 "spec_title": "RFC7231#6.5.12",
628 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.12"
629 },
630 "415": {
631 "code": 415,
632 "text": "Unsupported Media Type",
633 "description": "\"The origin server is refusing to service the request because the payload is in a format not supported by the target resource for this method.\"",
634 "spec_title": "RFC7231#6.5.13",
635 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.13"
636 },
637 "416": {
638 "code": 416,
639 "text": "Range Not Satisfiable",
640 "description": "\"None of the ranges in the request's Range header field overlap the current extent of the selected resource or that the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.\"",
641 "spec_title": "RFC7233#4.4",
642 "spec_href": "http://tools.ietf.org/html/rfc7233#section-4.4"
643 },
644 "417": {
645 "code": 417,
646 "text": "Expectation Failed",
647 "description": "\"The expectation given in the request's Expect header field could not be met by at least one of the inbound servers.\"",
648 "spec_title": "RFC7231#6.5.14",
649 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.14"
650 },
651 "418": {
652 "code": 418,
653 "text": "I'm a teapot",
654 "description": "\"1988 April Fools Joke. Returned by tea pots requested to brew coffee.\"",
655 "spec_title": "RFC 2324",
656 "spec_href": "https://tools.ietf.org/html/rfc2324"
657 },
658 "426": {
659 "code": 426,
660 "text": "Upgrade Required",
661 "description": "\"The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.\"",
662 "spec_title": "RFC7231#6.5.15",
663 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.5.15"
664 },
665 "500": {
666 "code": 500,
667 "text": "Internal Server Error",
668 "description": "\"The server encountered an unexpected condition that prevented it from fulfilling the request.\"",
669 "spec_title": "RFC7231#6.6.1",
670 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.6.1"
671 },
672 "501": {
673 "code": 501,
674 "text": "Not Implemented",
675 "description": "\"The server does not support the functionality required to fulfill the request.\"",
676 "spec_title": "RFC7231#6.6.2",
677 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.6.2"
678 },
679 "502": {
680 "code": 502,
681 "text": "Bad Gateway",
682 "description": "\"The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.\"",
683 "spec_title": "RFC7231#6.6.3",
684 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.6.3"
685 },
686 "503": {
687 "code": 503,
688 "text": "Service Unavailable",
689 "description": "\"The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay.\"",
690 "spec_title": "RFC7231#6.6.4",
691 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.6.4"
692 },
693 "504": {
694 "code": 504,
695 "text": "Gateway Time-out",
696 "description": "\"The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.\"",
697 "spec_title": "RFC7231#6.6.5",
698 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.6.5"
699 },
700 "505": {
701 "code": 505,
702 "text": "HTTP Version Not Supported",
703 "description": "\"The server does not support, or refuses to support, the protocol version that was used in the request message.\"",
704 "spec_title": "RFC7231#6.6.6",
705 "spec_href": "http://tools.ietf.org/html/rfc7231#section-6.6.6"
706 },
707 "102": {
708 "code": 102,
709 "text": "Processing",
710 "description": "\"An interim response to inform the client that the server has accepted the complete request, but has not yet completed it.\"",
711 "spec_title": "RFC5218#10.1",
712 "spec_href": "http://tools.ietf.org/html/rfc2518#section-10.1"
713 },
714 "207": {
715 "code": 207,
716 "text": "Multi-Status",
717 "description": "\"Status for multiple independent operations.\"",
718 "spec_title": "RFC5218#10.2",
719 "spec_href": "http://tools.ietf.org/html/rfc2518#section-10.2"
720 },
721 "226": {
722 "code": 226,
723 "text": "IM Used",
724 "description": "\"The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.\"",
725 "spec_title": "RFC3229#10.4.1",
726 "spec_href": "http://tools.ietf.org/html/rfc3229#section-10.4.1"
727 },
728 "308": {
729 "code": 308,
730 "text": "Permanent Redirect",
731 "description": "\"The target resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. [...] This status code is similar to 301 Moved Permanently (Section 7.3.2 of rfc7231), except that it does not allow rewriting the request method from POST to GET.\"",
732 "spec_title": "RFC7238",
733 "spec_href": "http://tools.ietf.org/html/rfc7238"
734 },
735 "422": {
736 "code": 422,
737 "text": "Unprocessable Entity",
738 "description": "\"The server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.\"",
739 "spec_title": "RFC5218#10.3",
740 "spec_href": "http://tools.ietf.org/html/rfc2518#section-10.3"
741 },
742 "423": {
743 "code": 423,
744 "text": "Locked",
745 "description": "\"The source or destination resource of a method is locked.\"",
746 "spec_title": "RFC5218#10.4",
747 "spec_href": "http://tools.ietf.org/html/rfc2518#section-10.4"
748 },
749 "424": {
750 "code": 424,
751 "text": "Failed Dependency",
752 "description": "\"The method could not be performed on the resource because the requested action depended on another action and that action failed.\"",
753 "spec_title": "RFC5218#10.5",
754 "spec_href": "http://tools.ietf.org/html/rfc2518#section-10.5"
755 },
756 "428": {
757 "code": 428,
758 "text": "Precondition Required",
759 "description": "\"The origin server requires the request to be conditional.\"",
760 "spec_title": "RFC6585#3",
761 "spec_href": "http://tools.ietf.org/html/rfc6585#section-3"
762 },
763 "429": {
764 "code": 429,
765 "text": "Too Many Requests",
766 "description": "\"The user has sent too many requests in a given amount of time (\"rate limiting\").\"",
767 "spec_title": "RFC6585#4",
768 "spec_href": "http://tools.ietf.org/html/rfc6585#section-4"
769 },
770 "431": {
771 "code": 431,
772 "text": "Request Header Fields Too Large",
773 "description": "\"The server is unwilling to process the request because its header fields are too large.\"",
774 "spec_title": "RFC6585#5",
775 "spec_href": "http://tools.ietf.org/html/rfc6585#section-5"
776 },
777 "451": {
778 "code": 451,
779 "text": "Unavailable For Legal Reasons",
780 "description": "\"The server is denying access to the resource in response to a legal demand.\"",
781 "spec_title": "draft-ietf-httpbis-legally-restricted-status",
782 "spec_href": "http://tools.ietf.org/html/draft-ietf-httpbis-legally-restricted-status"
783 },
784 "506": {
785 "code": 506,
786 "text": "Variant Also Negotiates",
787 "description": "\"The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.\"",
788 "spec_title": "RFC2295#8.1",
789 "spec_href": "http://tools.ietf.org/html/rfc2295#section-8.1"
790 },
791 "507": {
792 "code": 507,
793 "text": "Insufficient Storage",
794 "description": "\The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.\"",
795 "spec_title": "RFC5218#10.6",
796 "spec_href": "http://tools.ietf.org/html/rfc2518#section-10.6"
797 },
798 "511": {
799 "code": 511,
800 "text": "Network Authentication Required",
801 "description": "\"The client needs to authenticate to gain network access.\"",
802 "spec_title": "RFC6585#6",
803 "spec_href": "http://tools.ietf.org/html/rfc6585#section-6"
804 }
805 });
806 }
807 };
808});
809
810System.register("in-memory-web-api/core", ["./in-memory-backend.service", "./http-status-codes"], function(exports_1, context_1) {
811 "use strict";
812 var __moduleName = context_1 && context_1.id;
813 function exportStar_1(m) {
814 var exports = {};
815 for (var n in m) {
816 if (n !== "default")
817 exports[n] = m[n];
818 }
819 exports_1(exports);
820 }
821 return {
822 setters: [function(in_memory_backend_service_1_1) {
823 exportStar_1(in_memory_backend_service_1_1);
824 }, function(http_status_codes_1_1) {
825 exportStar_1(http_status_codes_1_1);
826 }],
827 execute: function() {}
828 };
829});