UNPKG

@lxlib/theme

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

360 lines 27.3 kB
/** * @fileoverview added by tsickle * Generated from: src/services/http/http.decorator.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Inject, Injector } from '@angular/core'; import { ACLService } from '@lxlib/acl'; import { throwError } from 'rxjs'; import { _HttpClient } from './http.client'; /** * @abstract */ export class BaseApi { /** * @param {?} injector */ constructor(injector) { this.injector = injector; } } /** @nocollapse */ BaseApi.ctorParameters = () => [ { type: Injector, decorators: [{ type: Inject, args: [Injector,] }] } ]; if (false) { /** * @type {?} * @protected */ BaseApi.prototype.injector; } /** * @record */ export function HttpOptions() { } if (false) { /** * ACL配置,若导入 `\@lxlib/acl` 时自动有效,等同于 `ACLService.can(roleOrAbility: ACLCanType)` 参数值 * @type {?|undefined} */ HttpOptions.prototype.acl; /** @type {?|undefined} */ HttpOptions.prototype.observe; /** @type {?|undefined} */ HttpOptions.prototype.responseType; /** @type {?|undefined} */ HttpOptions.prototype.reportProgress; /** @type {?|undefined} */ HttpOptions.prototype.withCredentials; } /** * @record */ function ParamType() { } if (false) { /** @type {?} */ ParamType.prototype.key; /** @type {?} */ ParamType.prototype.index; /* Skipping unhandled member: [key: string]: any;*/ /* Skipping unhandled member: [key: number]: any;*/ } /** @type {?} */ const paramKey = `__api_params`; /** * @param {?} target * @param {?=} key * @return {?} */ function setParam(target, key = paramKey) { /** @type {?} */ let params = target[key]; if (typeof params === 'undefined') { params = target[key] = {}; } return params; } /** * 默认基准URL * - 有效范围:类 * @param {?} url * @return {?} */ export function BaseUrl(url) { return (/** * @template TClass * @param {?} target * @return {?} */ function (target) { /** @type {?} */ const params = setParam(target.prototype); params.baseUrl = url; return target; }); } /** * 默认 `headers` * - 有效范围:类 * @param {?} headers * @return {?} */ export function BaseHeaders(headers) { return (/** * @template TClass * @param {?} target * @return {?} */ function (target) { /** @type {?} */ const params = setParam(target.prototype); params.baseHeaders = headers; return target; }); } /** * @param {?} paramName * @return {?} */ function makeParam(paramName) { return (/** * @param {?=} key * @return {?} */ function (key) { return (/** * @param {?} target * @param {?} propertyKey * @param {?} index * @return {?} */ function (target, propertyKey, index) { /** @type {?} */ const params = setParam(setParam(target), propertyKey); /** @type {?} */ let tParams = params[paramName]; if (typeof tParams === 'undefined') { tParams = params[paramName] = []; } tParams.push({ key, index, }); }); }); } /** * URL路由参数 * - 有效范围:方法参数 * @type {?} */ export const Path = makeParam('path'); /** * URL 参数 `QueryString` * - 有效范围:方法参数 * @type {?} */ export const Query = makeParam('query'); /** * 参数 `Body` * - 有效范围:方法参数 * @type {?} */ export const Body = makeParam('body')(); /** * 参数 `headers` * - 有效范围:方法参数 * - 合并 `BaseHeaders` * @type {?} */ export const Headers = makeParam('headers'); /** * Request Payload * - Supported body (like`POST`, `PUT`) as a body data, equivalent to `\@Body` * - Not supported body (like `GET`, `DELETE` etc) as a `QueryString` * @type {?} */ export const Payload = makeParam('payload')(); /** * @param {?} data * @param {?} key * @param {?} args * @return {?} */ function getValidArgs(data, key, args) { if (!data[key] || !Array.isArray(data[key]) || data[key].length <= 0) { return undefined; } return args[data[key][0].index]; } /** * @param {?=} data * @param {?=} payload * @return {?} */ function genBody(data, payload) { if (Array.isArray(data) || Array.isArray(payload)) { // tslint:disable-next-line:prefer-object-spread return Object.assign([], data, payload); } // tslint:disable-next-line:prefer-object-spread return Object.assign({}, data, payload); } /** * @param {?} method * @return {?} */ function makeMethod(method) { return (/** * @param {?=} url * @param {?=} options * @return {?} */ function (url = '', options) { return (/** * @param {?} _target * @param {?=} targetKey * @param {?=} descriptor * @return {?} */ (_target, targetKey, descriptor) => { (/** @type {?} */ (descriptor)).value = (/** * @param {...?} args * @return {?} */ function (...args) { options = options || {}; /** @type {?} */ const injector = (/** @type {?} */ (((/** @type {?} */ (this))).injector)); /** @type {?} */ const http = (/** @type {?} */ (injector.get(_HttpClient, null))); if (http == null) { throw new TypeError(`Not found '_HttpClient', You can import 'LxlibThemeModule' && 'HttpClientModule' in your root module.`); } /** @type {?} */ const baseData = setParam(this); /** @type {?} */ const data = setParam(baseData, targetKey); /** @type {?} */ let requestUrl = url || ''; requestUrl = [baseData.baseUrl || '', requestUrl.startsWith('/') ? requestUrl.substr(1) : requestUrl].join('/'); // fix last split if (requestUrl.length > 1 && requestUrl.endsWith('/')) { requestUrl = requestUrl.substr(0, requestUrl.length - 1); } if (options.acl) { /** @type {?} */ const aclSrv = injector.get(ACLService, null); if (aclSrv && !aclSrv.can(options.acl)) { return throwError({ url: requestUrl, status: 401, statusText: `From Http Decorator`, }); } delete options.acl; } requestUrl = requestUrl.replace(/::/g, '^^'); (((/** @type {?} */ (data.path))) || []) .filter((/** * @param {?} w * @return {?} */ w => typeof args[w.index] !== 'undefined')) .forEach((/** * @param {?} i * @return {?} */ (i) => { requestUrl = requestUrl.replace(new RegExp(`:${i.key}`, 'g'), encodeURIComponent(args[i.index])); })); requestUrl = requestUrl.replace(/\^\^/g, `:`); /** @type {?} */ const params = (data.query || []).reduce((/** * @param {?} p * @param {?} i * @return {?} */ (p, i) => { p[i.key] = args[i.index]; return p; }), {}); /** @type {?} */ const headers = (data.headers || []).reduce((/** * @param {?} p * @param {?} i * @return {?} */ (p, i) => { p[i.key] = args[i.index]; return p; }), {}); if (method === 'FORM') { headers['content-type'] = 'application/x-www-form-urlencoded'; } /** @type {?} */ const payload = getValidArgs(data, 'payload', args); /** @type {?} */ const supportedBody = method === 'POST' || method === 'PUT'; return http.request(method, requestUrl, Object.assign({ body: supportedBody ? genBody(getValidArgs(data, 'body', args), payload) : null, params: !supportedBody ? Object.assign(Object.assign({}, params), payload) : params, headers: Object.assign(Object.assign({}, baseData.baseHeaders), headers) }, options)); }); return descriptor; }); }); } /** * `OPTIONS` 请求 * - 有效范围:方法 * @type {?} */ export const OPTIONS = makeMethod('OPTIONS'); /** * `GET` 请求 * - 有效范围:方法 * @type {?} */ export const GET = makeMethod('GET'); /** * `POST` 请求 * - 有效范围:方法 * @type {?} */ export const POST = makeMethod('POST'); /** * `DELETE` 请求 * - 有效范围:方法 * @type {?} */ export const DELETE = makeMethod('DELETE'); /** * `PUT` 请求 * - 有效范围:方法 * @type {?} */ export const PUT = makeMethod('PUT'); /** * `HEAD` 请求 * - 有效范围:方法 * @type {?} */ export const HEAD = makeMethod('HEAD'); /** * `PATCH` 请求 * - 有效范围:方法 * @type {?} */ export const PATCH = makeMethod('PATCH'); /** * `JSONP` 请求 * - 有效范围:方法 * @type {?} */ export const JSONP = makeMethod('JSONP'); /** * `FORM` 请求 * - 有效范围:方法 * @type {?} */ export const FORM = makeMethod('FORM'); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5kZWNvcmF0b3IuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbHhsaWIvdGhlbWUvIiwic291cmNlcyI6WyJzcmMvc2VydmljZXMvaHR0cC9odHRwLmRlY29yYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLE9BQU8sRUFBRSxNQUFNLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ2pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFFeEMsT0FBTyxFQUFjLFVBQVUsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUM5QyxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sZUFBZSxDQUFDOzs7O0FBRTVDLE1BQU0sT0FBZ0IsT0FBTzs7OztJQUMzQixZQUF3QyxRQUFrQjtRQUFsQixhQUFRLEdBQVIsUUFBUSxDQUFVO0lBQUcsQ0FBQzs7OztZQVAvQyxRQUFRLHVCQU9WLE1BQU0sU0FBQyxRQUFROzs7Ozs7O0lBQWhCLDJCQUE4Qzs7Ozs7QUFHNUQsaUNBT0M7Ozs7OztJQUxDLDBCQUFVOztJQUNWLDhCQUF5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