@delon/mock 12.3.0 → 13.0.0-beta.1
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.
- package/{esm2015/mock.js → esm2020/mock.mjs} +0 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
- package/{esm2015/src/interface.js → esm2020/src/interface.mjs} +0 -0
- package/{esm2015/src/mock.config.js → esm2020/src/mock.config.mjs} +0 -0
- package/esm2020/src/mock.interceptor.mjs +109 -0
- package/esm2020/src/mock.module.mjs +30 -0
- package/esm2020/src/mock.service.mjs +140 -0
- package/{esm2015/src/status.error.js → esm2020/src/status.error.mjs} +1 -1
- package/fesm2015/{mock.js → mock.mjs} +21 -21
- package/fesm2015/mock.mjs.map +1 -0
- package/fesm2020/mock.mjs +292 -0
- package/fesm2020/mock.mjs.map +1 -0
- package/mock.d.ts +1 -0
- package/package.json +21 -9
- package/src/mock.interceptor.d.ts +3 -0
- package/src/mock.module.d.ts +4 -0
- package/src/mock.service.d.ts +3 -0
- package/src/status.error.d.ts +1 -1
- package/bundles/mock.umd.js +0 -338
- package/bundles/mock.umd.js.map +0 -1
- package/esm2015/src/mock.interceptor.js +0 -109
- package/esm2015/src/mock.module.js +0 -25
- package/esm2015/src/mock.service.js +0 -144
- package/fesm2015/mock.js.map +0 -1
- package/mock.metadata.json +0 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@delon/util/config';
|
|
4
|
+
import { HttpErrorResponse, HttpResponseBase, HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
5
|
+
import { throwError, of } from 'rxjs';
|
|
6
|
+
import { delay } from 'rxjs/operators';
|
|
7
|
+
import { deepCopy } from '@delon/util/other';
|
|
8
|
+
|
|
9
|
+
class MockOptions {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class MockStatusError {
|
|
13
|
+
constructor(status, error) {
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.error = error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const MOCK_DEFULAT_CONFIG = {
|
|
20
|
+
delay: 300,
|
|
21
|
+
force: false,
|
|
22
|
+
log: true,
|
|
23
|
+
executeOtherInterceptors: true
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class MockService {
|
|
27
|
+
constructor(cogSrv, options) {
|
|
28
|
+
this.cached = [];
|
|
29
|
+
this.config = cogSrv.merge('mock', MOCK_DEFULAT_CONFIG);
|
|
30
|
+
this.setData(options?.data);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reset request data
|
|
34
|
+
*
|
|
35
|
+
* 重新设置请求数据
|
|
36
|
+
*/
|
|
37
|
+
setData(data) {
|
|
38
|
+
this.applyMock(data);
|
|
39
|
+
}
|
|
40
|
+
// #region parse rule
|
|
41
|
+
applyMock(data) {
|
|
42
|
+
this.cached = [];
|
|
43
|
+
try {
|
|
44
|
+
this.realApplyMock(data);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
this.outputError(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
realApplyMock(data) {
|
|
51
|
+
if (!data)
|
|
52
|
+
return;
|
|
53
|
+
Object.keys(data).forEach((key) => {
|
|
54
|
+
const rules = data[key];
|
|
55
|
+
if (!rules)
|
|
56
|
+
return;
|
|
57
|
+
Object.keys(rules).forEach((ruleKey) => {
|
|
58
|
+
const value = rules[ruleKey];
|
|
59
|
+
if (!(typeof value === 'function' || typeof value === 'object' || typeof value === 'string')) {
|
|
60
|
+
throw Error(`mock value of [${key}-${ruleKey}] should be function or object or string, but got ${typeof value}`);
|
|
61
|
+
}
|
|
62
|
+
const rule = this.genRule(ruleKey, value);
|
|
63
|
+
if (['GET', 'POST', 'PUT', 'HEAD', 'DELETE', 'PATCH', 'OPTIONS'].indexOf(rule.method) === -1) {
|
|
64
|
+
throw Error(`method of ${key}-${ruleKey} is not valid`);
|
|
65
|
+
}
|
|
66
|
+
const item = this.cached.find(w => w.url === rule.url && w.method === rule.method);
|
|
67
|
+
if (item) {
|
|
68
|
+
item.callback = rule.callback;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.cached.push(rule);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
// regular ordering
|
|
76
|
+
this.cached.sort((a, b) => (b.martcher || '').toString().length - (a.martcher || '').toString().length);
|
|
77
|
+
}
|
|
78
|
+
genRule(key, callback) {
|
|
79
|
+
let method = 'GET';
|
|
80
|
+
let url = key;
|
|
81
|
+
if (key.indexOf(' ') > -1) {
|
|
82
|
+
const splited = key.split(' ');
|
|
83
|
+
method = splited[0].toLowerCase();
|
|
84
|
+
url = splited[1];
|
|
85
|
+
}
|
|
86
|
+
let martcher = null;
|
|
87
|
+
let segments = [];
|
|
88
|
+
if (~url.indexOf(':')) {
|
|
89
|
+
segments = url
|
|
90
|
+
.split('/')
|
|
91
|
+
.filter(segment => segment.startsWith(':'))
|
|
92
|
+
.map(v => v.substring(1));
|
|
93
|
+
const reStr = url
|
|
94
|
+
.split('/')
|
|
95
|
+
.map(segment => (segment.startsWith(':') ? `([^/]+)` : segment))
|
|
96
|
+
.join('/');
|
|
97
|
+
martcher = new RegExp(`^${reStr}`, 'i');
|
|
98
|
+
}
|
|
99
|
+
else if (/(\([^)]+\))/i.test(url)) {
|
|
100
|
+
martcher = new RegExp(url, 'i');
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
url,
|
|
104
|
+
martcher,
|
|
105
|
+
segments,
|
|
106
|
+
callback,
|
|
107
|
+
method: method.toUpperCase()
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
outputError(error) {
|
|
111
|
+
const filePath = error.message.split(': ')[0];
|
|
112
|
+
const errors = error.stack
|
|
113
|
+
.split('\n')
|
|
114
|
+
.filter(line => line.trim().indexOf('at ') !== 0)
|
|
115
|
+
.map(line => line.replace(`${filePath}: `, ''));
|
|
116
|
+
errors.splice(1, 0, '');
|
|
117
|
+
console.group();
|
|
118
|
+
console.warn(`==========Failed to parse mock config.==========`);
|
|
119
|
+
console.log(errors.join('\n'));
|
|
120
|
+
console.groupEnd();
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
// #endregion
|
|
124
|
+
getRule(method, url) {
|
|
125
|
+
method = (method || 'GET').toUpperCase();
|
|
126
|
+
const params = {};
|
|
127
|
+
const list = this.cached.filter(w => w.method === method && (w.martcher ? w.martcher.test(url) : w.url === url));
|
|
128
|
+
if (list.length === 0)
|
|
129
|
+
return null;
|
|
130
|
+
const ret = list.find(w => w.url === url) || list[0];
|
|
131
|
+
if (ret.martcher) {
|
|
132
|
+
const execArr = ret.martcher.exec(url);
|
|
133
|
+
execArr.slice(1).map((value, index) => {
|
|
134
|
+
params[ret.segments[index]] = value;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
url,
|
|
139
|
+
method: ret.method,
|
|
140
|
+
params,
|
|
141
|
+
callback: ret.callback
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
clearCache() {
|
|
145
|
+
this.cached = [];
|
|
146
|
+
}
|
|
147
|
+
get rules() {
|
|
148
|
+
return this.cached;
|
|
149
|
+
}
|
|
150
|
+
ngOnDestroy() {
|
|
151
|
+
this.clearCache();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
MockService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MockService, deps: [{ token: i1.AlainConfigService }, { token: MockOptions }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
155
|
+
MockService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MockService, providedIn: 'root' });
|
|
156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MockService, decorators: [{
|
|
157
|
+
type: Injectable,
|
|
158
|
+
args: [{ providedIn: 'root' }]
|
|
159
|
+
}], ctorParameters: function () { return [{ type: i1.AlainConfigService }, { type: MockOptions }]; } });
|
|
160
|
+
|
|
161
|
+
class HttpMockInterceptorHandler {
|
|
162
|
+
constructor(next, interceptor) {
|
|
163
|
+
this.next = next;
|
|
164
|
+
this.interceptor = interceptor;
|
|
165
|
+
}
|
|
166
|
+
handle(req) {
|
|
167
|
+
return this.interceptor.intercept(req, this.next);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
class MockInterceptor {
|
|
171
|
+
constructor(injector) {
|
|
172
|
+
this.injector = injector;
|
|
173
|
+
}
|
|
174
|
+
intercept(req, next) {
|
|
175
|
+
const src = this.injector.get(MockService);
|
|
176
|
+
const config = src.config;
|
|
177
|
+
const rule = src.getRule(req.method, req.url.split('?')[0]);
|
|
178
|
+
if (!rule && !config.force) {
|
|
179
|
+
return next.handle(req);
|
|
180
|
+
}
|
|
181
|
+
let res;
|
|
182
|
+
switch (typeof rule.callback) {
|
|
183
|
+
case 'function':
|
|
184
|
+
const mockRequest = {
|
|
185
|
+
original: req,
|
|
186
|
+
body: req.body,
|
|
187
|
+
queryString: {},
|
|
188
|
+
headers: {},
|
|
189
|
+
params: rule.params
|
|
190
|
+
};
|
|
191
|
+
const urlParams = req.url.split('?');
|
|
192
|
+
if (urlParams.length > 1) {
|
|
193
|
+
urlParams[1].split('&').forEach(item => {
|
|
194
|
+
const itemArr = item.split('=');
|
|
195
|
+
const key = itemArr[0];
|
|
196
|
+
const value = itemArr[1];
|
|
197
|
+
// is array
|
|
198
|
+
if (Object.keys(mockRequest.queryString).includes(key)) {
|
|
199
|
+
if (!Array.isArray(mockRequest.queryString[key])) {
|
|
200
|
+
mockRequest.queryString[key] = [mockRequest.queryString[key]];
|
|
201
|
+
}
|
|
202
|
+
mockRequest.queryString[key].push(value);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
mockRequest.queryString[key] = value;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
req.params.keys().forEach(key => (mockRequest.queryString[key] = req.params.get(key)));
|
|
210
|
+
req.headers.keys().forEach(key => (mockRequest.headers[key] = req.headers.get(key)));
|
|
211
|
+
try {
|
|
212
|
+
res = rule.callback.call(this, mockRequest);
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
res = new HttpErrorResponse({
|
|
216
|
+
url: req.url,
|
|
217
|
+
headers: req.headers,
|
|
218
|
+
status: e instanceof MockStatusError ? e.status : 400,
|
|
219
|
+
statusText: e.statusText || 'Unknown Error',
|
|
220
|
+
error: e.error
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
default:
|
|
225
|
+
res = rule.callback;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
if (!(res instanceof HttpResponseBase)) {
|
|
229
|
+
res = new HttpResponse({
|
|
230
|
+
status: 200,
|
|
231
|
+
url: req.url,
|
|
232
|
+
body: res
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (res.body) {
|
|
236
|
+
res.body = deepCopy(res.body);
|
|
237
|
+
}
|
|
238
|
+
if (config.log) {
|
|
239
|
+
console.log(`%c👽${req.method}->${req.urlWithParams}->request`, 'background:#000;color:#bada55', req);
|
|
240
|
+
console.log(`%c👽${req.method}->${req.urlWithParams}->response`, 'background:#000;color:#bada55', res);
|
|
241
|
+
}
|
|
242
|
+
const res$ = res instanceof HttpErrorResponse ? throwError(() => res) : of(res);
|
|
243
|
+
if (config.executeOtherInterceptors) {
|
|
244
|
+
const interceptors = this.injector.get(HTTP_INTERCEPTORS, []);
|
|
245
|
+
const lastInterceptors = interceptors.slice(interceptors.indexOf(this) + 1);
|
|
246
|
+
if (lastInterceptors.length > 0) {
|
|
247
|
+
const chain = lastInterceptors.reduceRight((_next, _interceptor) => new HttpMockInterceptorHandler(_next, _interceptor), {
|
|
248
|
+
handle: () => res$
|
|
249
|
+
});
|
|
250
|
+
return chain.handle(req).pipe(delay(config.delay));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return res$.pipe(delay(config.delay));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
MockInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MockInterceptor, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
257
|
+
MockInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MockInterceptor });
|
|
258
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MockInterceptor, decorators: [{
|
|
259
|
+
type: Injectable
|
|
260
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
261
|
+
|
|
262
|
+
class DelonMockModule {
|
|
263
|
+
static forRoot(options) {
|
|
264
|
+
return {
|
|
265
|
+
ngModule: DelonMockModule,
|
|
266
|
+
providers: [
|
|
267
|
+
{ provide: MockOptions, useValue: options },
|
|
268
|
+
{ provide: HTTP_INTERCEPTORS, useClass: MockInterceptor, multi: true }
|
|
269
|
+
]
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
static forChild() {
|
|
273
|
+
return {
|
|
274
|
+
ngModule: DelonMockModule,
|
|
275
|
+
providers: [{ provide: HTTP_INTERCEPTORS, useClass: MockInterceptor, multi: true }]
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
DelonMockModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DelonMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
280
|
+
DelonMockModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DelonMockModule });
|
|
281
|
+
DelonMockModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DelonMockModule });
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: DelonMockModule, decorators: [{
|
|
283
|
+
type: NgModule,
|
|
284
|
+
args: [{}]
|
|
285
|
+
}] });
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Generated bundle index. Do not edit.
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
export { DelonMockModule, MockInterceptor, MockOptions, MockService, MockStatusError };
|
|
292
|
+
//# sourceMappingURL=mock.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.mjs","sources":["../../../../packages/mock/src/interface.ts","../../../../packages/mock/src/status.error.ts","../../../../packages/mock/src/mock.config.ts","../../../../packages/mock/src/mock.service.ts","../../../../packages/mock/src/mock.interceptor.ts","../../../../packages/mock/src/mock.module.ts","../../../../packages/mock/mock.ts"],"sourcesContent":["import { HttpRequest } from '@angular/common/http';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport class MockOptions {\n data?: NzSafeAny;\n}\n\nexport interface MockCachedRule {\n [key: string]: NzSafeAny;\n\n method: string;\n\n url: string;\n\n martcher: RegExp | null;\n\n segments: string[];\n\n callback(req: MockRequest): NzSafeAny;\n}\n\nexport interface MockRule {\n [key: string]: NzSafeAny;\n\n method: string;\n\n url: string;\n\n /** 路由参数 */\n params?: NzSafeAny;\n\n callback(req: MockRequest): NzSafeAny;\n}\n\nexport interface MockRequest {\n /** 路由参数 */\n params?: NzSafeAny;\n /** URL参数 */\n queryString?: NzSafeAny;\n headers?: NzSafeAny;\n body?: NzSafeAny;\n /** 原始 `HttpRequest` */\n original: HttpRequest<NzSafeAny>;\n}\n","import type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport class MockStatusError {\n statusText?: string;\n\n constructor(public status: number, public error?: NzSafeAny) {}\n}\n","import { AlainMockConfig } from '@delon/util/config';\n\nexport const MOCK_DEFULAT_CONFIG: AlainMockConfig = {\n delay: 300,\n force: false,\n log: true,\n executeOtherInterceptors: true\n};\n","import { Injectable, OnDestroy } from '@angular/core';\n\nimport { AlainConfigService, AlainMockConfig } from '@delon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { MockCachedRule, MockOptions, MockRule } from './interface';\nimport { MOCK_DEFULAT_CONFIG } from './mock.config';\n\n@Injectable({ providedIn: 'root' })\nexport class MockService implements OnDestroy {\n private cached: MockCachedRule[] = [];\n readonly config: AlainMockConfig;\n\n constructor(cogSrv: AlainConfigService, options: MockOptions) {\n this.config = cogSrv.merge('mock', MOCK_DEFULAT_CONFIG)!;\n this.setData(options?.data);\n }\n\n /**\n * Reset request data\n *\n * 重新设置请求数据\n */\n setData(data: NzSafeAny): void {\n this.applyMock(data);\n }\n\n // #region parse rule\n\n private applyMock(data: NzSafeAny): void {\n this.cached = [];\n try {\n this.realApplyMock(data);\n } catch (e) {\n this.outputError(e);\n }\n }\n\n private realApplyMock(data: NzSafeAny): void {\n if (!data) return;\n Object.keys(data).forEach((key: string) => {\n const rules = data[key];\n if (!rules) return;\n Object.keys(rules).forEach((ruleKey: string) => {\n const value = rules[ruleKey];\n if (!(typeof value === 'function' || typeof value === 'object' || typeof value === 'string')) {\n throw Error(\n `mock value of [${key}-${ruleKey}] should be function or object or string, but got ${typeof value}`\n );\n }\n const rule = this.genRule(ruleKey, value);\n if (['GET', 'POST', 'PUT', 'HEAD', 'DELETE', 'PATCH', 'OPTIONS'].indexOf(rule.method) === -1) {\n throw Error(`method of ${key}-${ruleKey} is not valid`);\n }\n const item = this.cached.find(w => w.url === rule.url && w.method === rule.method);\n if (item) {\n item.callback = rule.callback;\n } else {\n this.cached.push(rule);\n }\n });\n });\n // regular ordering\n this.cached.sort((a, b) => (b.martcher || '').toString().length - (a.martcher || '').toString().length);\n }\n\n private genRule(key: string, callback: NzSafeAny): MockCachedRule {\n let method = 'GET';\n let url = key;\n\n if (key.indexOf(' ') > -1) {\n const splited = key.split(' ');\n method = splited[0].toLowerCase();\n url = splited[1];\n }\n\n let martcher: RegExp | null = null;\n let segments: string[] = [];\n if (~url.indexOf(':')) {\n segments = url!\n .split('/')\n .filter(segment => segment.startsWith(':'))\n .map(v => v.substring(1));\n const reStr = url!\n .split('/')\n .map(segment => (segment.startsWith(':') ? `([^/]+)` : segment))\n .join('/');\n martcher = new RegExp(`^${reStr}`, 'i');\n } else if (/(\\([^)]+\\))/i.test(url)) {\n martcher = new RegExp(url, 'i');\n }\n\n return {\n url,\n martcher,\n segments,\n callback,\n method: method.toUpperCase()\n };\n }\n\n private outputError(error: NzSafeAny): void {\n const filePath = error.message.split(': ')[0];\n const errors = (error.stack as string)\n .split('\\n')\n .filter(line => line.trim().indexOf('at ') !== 0)\n .map(line => line.replace(`${filePath}: `, ''));\n errors.splice(1, 0, '');\n\n console.group();\n console.warn(`==========Failed to parse mock config.==========`);\n console.log(errors.join('\\n'));\n console.groupEnd();\n\n throw error;\n }\n\n // #endregion\n\n getRule(method: string, url: string): MockRule | null {\n method = (method || 'GET').toUpperCase();\n const params: NzSafeAny = {};\n const list = this.cached.filter(w => w.method === method && (w.martcher ? w.martcher.test(url) : w.url === url));\n if (list.length === 0) return null;\n const ret = list.find(w => w.url === url) || list[0];\n if (ret.martcher) {\n const execArr = ret.martcher.exec(url);\n execArr!.slice(1).map((value: string, index: number) => {\n params[ret.segments[index]] = value;\n });\n }\n return {\n url,\n method: ret.method,\n params,\n callback: ret.callback\n };\n }\n\n clearCache(): void {\n this.cached = [];\n }\n\n get rules(): MockCachedRule[] {\n return this.cached;\n }\n\n ngOnDestroy(): void {\n this.clearCache();\n }\n}\n","import {\n HttpBackend,\n HttpErrorResponse,\n HttpEvent,\n HttpHandler,\n HttpInterceptor,\n HttpRequest,\n HttpResponse,\n HttpResponseBase,\n HTTP_INTERCEPTORS\n} from '@angular/common/http';\nimport { Injectable, Injector } from '@angular/core';\nimport { Observable, of, throwError } from 'rxjs';\nimport { delay } from 'rxjs/operators';\n\nimport { deepCopy } from '@delon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { MockRequest } from './interface';\nimport { MockService } from './mock.service';\nimport { MockStatusError } from './status.error';\n\nclass HttpMockInterceptorHandler implements HttpHandler {\n constructor(private next: HttpHandler, private interceptor: HttpInterceptor) {}\n\n handle(req: HttpRequest<NzSafeAny>): Observable<HttpEvent<NzSafeAny>> {\n return this.interceptor.intercept(req, this.next);\n }\n}\n\n@Injectable()\nexport class MockInterceptor implements HttpInterceptor {\n constructor(private injector: Injector) {}\n\n intercept(req: HttpRequest<NzSafeAny>, next: HttpHandler): Observable<HttpEvent<NzSafeAny>> {\n const src = this.injector.get(MockService);\n const config = src.config;\n const rule = src.getRule(req.method, req.url.split('?')[0]);\n if (!rule && !config.force) {\n return next.handle(req);\n }\n\n let res: NzSafeAny;\n switch (typeof rule!.callback) {\n case 'function':\n const mockRequest: MockRequest = {\n original: req,\n body: req.body,\n queryString: {},\n headers: {},\n params: rule!.params\n };\n const urlParams = req.url.split('?');\n if (urlParams.length > 1) {\n urlParams[1].split('&').forEach(item => {\n const itemArr = item.split('=');\n const key = itemArr[0];\n const value = itemArr[1];\n // is array\n if (Object.keys(mockRequest.queryString).includes(key)) {\n if (!Array.isArray(mockRequest.queryString[key])) {\n mockRequest.queryString[key] = [mockRequest.queryString[key]];\n }\n mockRequest.queryString[key].push(value);\n } else {\n mockRequest.queryString[key] = value;\n }\n });\n }\n req.params.keys().forEach(key => (mockRequest.queryString[key] = req.params.get(key)));\n req.headers.keys().forEach(key => (mockRequest.headers[key] = req.headers.get(key)));\n\n try {\n res = rule!.callback.call(this, mockRequest);\n } catch (e: NzSafeAny) {\n res = new HttpErrorResponse({\n url: req.url,\n headers: req.headers,\n status: e instanceof MockStatusError ? e.status : 400,\n statusText: e.statusText || 'Unknown Error',\n error: e.error\n });\n }\n break;\n default:\n res = rule!.callback;\n break;\n }\n\n if (!(res instanceof HttpResponseBase)) {\n res = new HttpResponse({\n status: 200,\n url: req.url,\n body: res\n });\n }\n\n if (res.body) {\n res.body = deepCopy(res.body);\n }\n\n if (config.log) {\n console.log(`%c👽${req.method}->${req.urlWithParams}->request`, 'background:#000;color:#bada55', req);\n console.log(`%c👽${req.method}->${req.urlWithParams}->response`, 'background:#000;color:#bada55', res);\n }\n\n const res$ = res instanceof HttpErrorResponse ? throwError(() => res) : of(res);\n\n if (config.executeOtherInterceptors) {\n const interceptors = this.injector.get(HTTP_INTERCEPTORS, []);\n const lastInterceptors = interceptors.slice(interceptors.indexOf(this) + 1);\n if (lastInterceptors.length > 0) {\n const chain = lastInterceptors.reduceRight(\n (_next, _interceptor) => new HttpMockInterceptorHandler(_next, _interceptor),\n {\n handle: () => res$\n } as HttpBackend\n );\n return chain.handle(req).pipe(delay(config.delay!));\n }\n }\n\n return res$.pipe(delay(config.delay!));\n }\n}\n","import { HTTP_INTERCEPTORS } from '@angular/common/http';\nimport { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport { MockOptions } from './interface';\nimport { MockInterceptor } from './mock.interceptor';\n\n@NgModule({})\nexport class DelonMockModule {\n static forRoot(options?: MockOptions): ModuleWithProviders<DelonMockModule> {\n return {\n ngModule: DelonMockModule,\n providers: [\n { provide: MockOptions, useValue: options },\n { provide: HTTP_INTERCEPTORS, useClass: MockInterceptor, multi: true }\n ]\n };\n }\n\n static forChild(): ModuleWithProviders<DelonMockModule> {\n return {\n ngModule: DelonMockModule,\n providers: [{ provide: HTTP_INTERCEPTORS, useClass: MockInterceptor, multi: true }]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;MAIa,WAAW;;;MCFX,eAAe;IAG1B,YAAmB,MAAc,EAAS,KAAiB;QAAxC,WAAM,GAAN,MAAM,CAAQ;QAAS,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C3C,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE;aACvE;SACF,CAAC;KACH;IAED,OAAO,QAAQ;QACb,OAAO;YACL,QAAQ,EAAE,eAAe;YACzB,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SACpF,CAAC;KACH;;4GAhBU,eAAe;6GAAf,eAAe;6GAAf,eAAe;2FAAf,eAAe;kBAD3B,QAAQ;mBAAC,EAAE;;;ACNZ;;;;;;"}
|
package/mock.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delon/mock",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-beta.1",
|
|
4
4
|
"author": "cipchk<cipchk@qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,15 +28,27 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"mockjs": "^1.1.0",
|
|
30
30
|
"@types/mockjs": "^1.0.4",
|
|
31
|
-
"@delon/util": "^
|
|
32
|
-
"tslib": "^2.
|
|
31
|
+
"@delon/util": "^13.0.0-beta.1",
|
|
32
|
+
"tslib": "^2.3.0"
|
|
33
33
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"fesm2015": "fesm2015/mock.
|
|
34
|
+
"module": "fesm2015/mock.mjs",
|
|
35
|
+
"es2020": "fesm2020/mock.mjs",
|
|
36
|
+
"esm2020": "esm2020/mock.mjs",
|
|
37
|
+
"fesm2020": "fesm2020/mock.mjs",
|
|
38
|
+
"fesm2015": "fesm2015/mock.mjs",
|
|
39
39
|
"typings": "mock.d.ts",
|
|
40
|
-
"
|
|
40
|
+
"exports": {
|
|
41
|
+
"./package.json": {
|
|
42
|
+
"default": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./mock.d.ts",
|
|
46
|
+
"esm2020": "./esm2020/mock.mjs",
|
|
47
|
+
"es2020": "./fesm2020/mock.mjs",
|
|
48
|
+
"es2015": "./fesm2015/mock.mjs",
|
|
49
|
+
"node": "./fesm2015/mock.mjs",
|
|
50
|
+
"default": "./fesm2020/mock.mjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
41
53
|
"sideEffects": false
|
|
42
54
|
}
|
|
@@ -2,8 +2,11 @@ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/c
|
|
|
2
2
|
import { Injector } from '@angular/core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
5
6
|
export declare class MockInterceptor implements HttpInterceptor {
|
|
6
7
|
private injector;
|
|
7
8
|
constructor(injector: Injector);
|
|
8
9
|
intercept(req: HttpRequest<NzSafeAny>, next: HttpHandler): Observable<HttpEvent<NzSafeAny>>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MockInterceptor, never>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MockInterceptor>;
|
|
9
12
|
}
|
package/src/mock.module.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import { MockOptions } from './interface';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
3
4
|
export declare class DelonMockModule {
|
|
4
5
|
static forRoot(options?: MockOptions): ModuleWithProviders<DelonMockModule>;
|
|
5
6
|
static forChild(): ModuleWithProviders<DelonMockModule>;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DelonMockModule, never>;
|
|
8
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<DelonMockModule, never, never, never>;
|
|
9
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<DelonMockModule>;
|
|
6
10
|
}
|
package/src/mock.service.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { OnDestroy } from '@angular/core';
|
|
|
2
2
|
import { AlainConfigService, AlainMockConfig } from '@delon/util/config';
|
|
3
3
|
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
|
|
4
4
|
import { MockCachedRule, MockOptions, MockRule } from './interface';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
5
6
|
export declare class MockService implements OnDestroy {
|
|
6
7
|
private cached;
|
|
7
8
|
readonly config: AlainMockConfig;
|
|
@@ -20,4 +21,6 @@ export declare class MockService implements OnDestroy {
|
|
|
20
21
|
clearCache(): void;
|
|
21
22
|
get rules(): MockCachedRule[];
|
|
22
23
|
ngOnDestroy(): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MockService, never>;
|
|
25
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MockService>;
|
|
23
26
|
}
|