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 pathinterfaces.js
103 lines (103 loc) · 3.88 KB
/
interfaces.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Injectable } from '@angular/core';
/**
* Interface for a class that creates an in-memory database
*
* Its `createDb` method creates a hash of named collections that represents the database
*
* For maximum flexibility, the service may define HTTP method overrides.
* Such methods must match the spelling of an HTTP method in lower case (e.g, "get").
* If a request has a matching method, it will be called as in
* `get(info: requestInfo, db: {})` where `db` is the database object described above.
*/
var InMemoryDbService = /** @class */ (function () {
function InMemoryDbService() {
}
return InMemoryDbService;
}());
export { InMemoryDbService };
/**
* Interface for InMemoryBackend configuration options
*/
var InMemoryBackendConfigArgs = /** @class */ (function () {
function InMemoryBackendConfigArgs() {
}
return InMemoryBackendConfigArgs;
}());
export { InMemoryBackendConfigArgs };
/////////////////////////////////
/**
* InMemoryBackendService configuration options
* Usage:
* InMemoryWebApiModule.forRoot(InMemHeroService, {delay: 600})
*
* or if providing separately:
* provide(InMemoryBackendConfig, {useValue: {delay: 600}}),
*/
var InMemoryBackendConfig = /** @class */ (function () {
function InMemoryBackendConfig(config) {
if (config === void 0) { config = {}; }
Object.assign(this, {
// default config:
caseSensitiveSearch: false,
dataEncapsulation: false,
delay: 500,
delete404: false,
passThruUnknownUrl: false,
post204: true,
post409: false,
put204: true,
put404: false,
apiBase: undefined,
host: undefined,
rootPath: undefined // default value is actually set in InMemoryBackendService ctor
}, config);
}
InMemoryBackendConfig = __decorate([
Injectable(),
__metadata("design:paramtypes", [InMemoryBackendConfigArgs])
], InMemoryBackendConfig);
return InMemoryBackendConfig;
}());
export { InMemoryBackendConfig };
/** Return information (UriInfo) about a URI */
export function parseUri(str) {
// Adapted from parseuri package - http://blog.stevenlevithan.com/archives/parseuri
// tslint:disable-next-line:max-line-length
var URL_REGEX = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
var m = URL_REGEX.exec(str);
var uri = {
source: '',
protocol: '',
authority: '',
userInfo: '',
user: '',
password: '',
host: '',
port: '',
relative: '',
path: '',
directory: '',
file: '',
query: '',
anchor: ''
};
var keys = Object.keys(uri);
var i = keys.length;
while (i--) {
uri[keys[i]] = m[i] || '';
}
return uri;
}
export function removeTrailingSlash(path) {
return path.replace(/\/$/, '');
}
//# sourceMappingURL=interfaces.js.map