@klerick/json-api-nestjs-sdk 10.0.0-beta.2
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/CHANGELOG.md +58 -0
- package/README.md +154 -0
- package/cjs/package.json +55 -0
- package/cjs/src/index.d.ts +5 -0
- package/cjs/src/index.js +14 -0
- package/cjs/src/index.js.map +1 -0
- package/cjs/src/lib/constants/index.d.ts +1 -0
- package/cjs/src/lib/constants/index.js +5 -0
- package/cjs/src/lib/constants/index.js.map +1 -0
- package/cjs/src/lib/json-api-angular.d.ts +21 -0
- package/cjs/src/lib/json-api-angular.js +40 -0
- package/cjs/src/lib/json-api-angular.js.map +1 -0
- package/cjs/src/lib/json-api-js.d.ts +15 -0
- package/cjs/src/lib/json-api-js.js +48 -0
- package/cjs/src/lib/json-api-js.js.map +1 -0
- package/cjs/src/lib/service/atomic-operations.service.d.ts +22 -0
- package/cjs/src/lib/service/atomic-operations.service.js +86 -0
- package/cjs/src/lib/service/atomic-operations.service.js.map +1 -0
- package/cjs/src/lib/service/fetch-inner-client.d.ts +20 -0
- package/cjs/src/lib/service/fetch-inner-client.js +48 -0
- package/cjs/src/lib/service/fetch-inner-client.js.map +1 -0
- package/cjs/src/lib/service/index.d.ts +3 -0
- package/cjs/src/lib/service/index.js +7 -0
- package/cjs/src/lib/service/index.js.map +1 -0
- package/cjs/src/lib/service/json-api-sdk.service.d.ts +21 -0
- package/cjs/src/lib/service/json-api-sdk.service.js +168 -0
- package/cjs/src/lib/service/json-api-sdk.service.js.map +1 -0
- package/cjs/src/lib/service/json-api-utils.service.d.ts +28 -0
- package/cjs/src/lib/service/json-api-utils.service.js +245 -0
- package/cjs/src/lib/service/json-api-utils.service.js.map +1 -0
- package/cjs/src/lib/token/index.d.ts +4 -0
- package/cjs/src/lib/token/index.js +7 -0
- package/cjs/src/lib/token/index.js.map +1 -0
- package/cjs/src/lib/types/atomic-operation.d.ts +33 -0
- package/cjs/src/lib/types/atomic-operation.js +3 -0
- package/cjs/src/lib/types/atomic-operation.js.map +1 -0
- package/cjs/src/lib/types/atomic-type.d.ts +23 -0
- package/cjs/src/lib/types/atomic-type.js +4 -0
- package/cjs/src/lib/types/atomic-type.js.map +1 -0
- package/cjs/src/lib/types/config.d.ts +14 -0
- package/cjs/src/lib/types/config.js +3 -0
- package/cjs/src/lib/types/config.js.map +1 -0
- package/cjs/src/lib/types/filter-operand.d.ts +10 -0
- package/cjs/src/lib/types/filter-operand.js +4 -0
- package/cjs/src/lib/types/filter-operand.js.map +1 -0
- package/cjs/src/lib/types/http-inner-client.d.ts +19 -0
- package/cjs/src/lib/types/http-inner-client.js +3 -0
- package/cjs/src/lib/types/http-inner-client.js.map +1 -0
- package/cjs/src/lib/types/http-request-params.d.ts +20 -0
- package/cjs/src/lib/types/http-request-params.js +3 -0
- package/cjs/src/lib/types/http-request-params.js.map +1 -0
- package/cjs/src/lib/types/index.d.ts +9 -0
- package/cjs/src/lib/types/index.js +13 -0
- package/cjs/src/lib/types/index.js.map +1 -0
- package/cjs/src/lib/types/promise-json-api-sdk.d.ts +16 -0
- package/cjs/src/lib/types/promise-json-api-sdk.js +3 -0
- package/cjs/src/lib/types/promise-json-api-sdk.js.map +1 -0
- package/cjs/src/lib/types/query-params.d.ts +47 -0
- package/cjs/src/lib/types/query-params.js +4 -0
- package/cjs/src/lib/types/query-params.js.map +1 -0
- package/cjs/src/lib/types/utils.d.ts +6 -0
- package/cjs/src/lib/types/utils.js +3 -0
- package/cjs/src/lib/types/utils.js.map +1 -0
- package/cjs/src/lib/utils/adapter-for-axios.d.ts +3 -0
- package/cjs/src/lib/utils/adapter-for-axios.js +56 -0
- package/cjs/src/lib/utils/adapter-for-axios.js.map +1 -0
- package/cjs/src/lib/utils/entity-array.d.ts +9 -0
- package/cjs/src/lib/utils/entity-array.js +28 -0
- package/cjs/src/lib/utils/entity-array.js.map +1 -0
- package/cjs/src/lib/utils/generate-atomic-body.d.ts +22 -0
- package/cjs/src/lib/utils/generate-atomic-body.js +75 -0
- package/cjs/src/lib/utils/generate-atomic-body.js.map +1 -0
- package/cjs/src/lib/utils/http-params.d.ts +154 -0
- package/cjs/src/lib/utils/http-params.js +303 -0
- package/cjs/src/lib/utils/http-params.js.map +1 -0
- package/cjs/src/lib/utils/index.d.ts +5 -0
- package/cjs/src/lib/utils/index.js +9 -0
- package/cjs/src/lib/utils/index.js.map +1 -0
- package/cjs/src/lib/utils/utils.d.ts +4 -0
- package/cjs/src/lib/utils/utils.js +24 -0
- package/cjs/src/lib/utils/utils.js.map +1 -0
- package/cjs/src/ngModule.d.ts +4 -0
- package/cjs/src/ngModule.js +14 -0
- package/cjs/src/ngModule.js.map +1 -0
- package/mjs/package.json +57 -0
- package/mjs/src/index.d.ts +5 -0
- package/mjs/src/index.js +5 -0
- package/mjs/src/index.js.map +1 -0
- package/mjs/src/lib/constants/index.d.ts +1 -0
- package/mjs/src/lib/constants/index.js +2 -0
- package/mjs/src/lib/constants/index.js.map +1 -0
- package/mjs/src/lib/json-api-angular.d.ts +21 -0
- package/mjs/src/lib/json-api-angular.js +33 -0
- package/mjs/src/lib/json-api-angular.js.map +1 -0
- package/mjs/src/lib/json-api-js.d.ts +15 -0
- package/mjs/src/lib/json-api-js.js +44 -0
- package/mjs/src/lib/json-api-js.js.map +1 -0
- package/mjs/src/lib/service/atomic-operations.service.d.ts +22 -0
- package/mjs/src/lib/service/atomic-operations.service.js +85 -0
- package/mjs/src/lib/service/atomic-operations.service.js.map +1 -0
- package/mjs/src/lib/service/fetch-inner-client.d.ts +20 -0
- package/mjs/src/lib/service/fetch-inner-client.js +50 -0
- package/mjs/src/lib/service/fetch-inner-client.js.map +1 -0
- package/mjs/src/lib/service/index.d.ts +3 -0
- package/mjs/src/lib/service/index.js +4 -0
- package/mjs/src/lib/service/index.js.map +1 -0
- package/mjs/src/lib/service/json-api-sdk.service.d.ts +21 -0
- package/mjs/src/lib/service/json-api-sdk.service.js +174 -0
- package/mjs/src/lib/service/json-api-sdk.service.js.map +1 -0
- package/mjs/src/lib/service/json-api-utils.service.d.ts +28 -0
- package/mjs/src/lib/service/json-api-utils.service.js +253 -0
- package/mjs/src/lib/service/json-api-utils.service.js.map +1 -0
- package/mjs/src/lib/token/index.d.ts +4 -0
- package/mjs/src/lib/token/index.js +4 -0
- package/mjs/src/lib/token/index.js.map +1 -0
- package/mjs/src/lib/types/atomic-operation.d.ts +33 -0
- package/mjs/src/lib/types/atomic-operation.js +2 -0
- package/mjs/src/lib/types/atomic-operation.js.map +1 -0
- package/mjs/src/lib/types/atomic-type.d.ts +23 -0
- package/mjs/src/lib/types/atomic-type.js +2 -0
- package/mjs/src/lib/types/atomic-type.js.map +1 -0
- package/mjs/src/lib/types/config.d.ts +14 -0
- package/mjs/src/lib/types/config.js +2 -0
- package/mjs/src/lib/types/config.js.map +1 -0
- package/mjs/src/lib/types/filter-operand.d.ts +10 -0
- package/mjs/src/lib/types/filter-operand.js +2 -0
- package/mjs/src/lib/types/filter-operand.js.map +1 -0
- package/mjs/src/lib/types/http-inner-client.d.ts +19 -0
- package/mjs/src/lib/types/http-inner-client.js +2 -0
- package/mjs/src/lib/types/http-inner-client.js.map +1 -0
- package/mjs/src/lib/types/http-request-params.d.ts +20 -0
- package/mjs/src/lib/types/http-request-params.js +2 -0
- package/mjs/src/lib/types/http-request-params.js.map +1 -0
- package/mjs/src/lib/types/index.d.ts +9 -0
- package/mjs/src/lib/types/index.js +10 -0
- package/mjs/src/lib/types/index.js.map +1 -0
- package/mjs/src/lib/types/promise-json-api-sdk.d.ts +16 -0
- package/mjs/src/lib/types/promise-json-api-sdk.js +2 -0
- package/mjs/src/lib/types/promise-json-api-sdk.js.map +1 -0
- package/mjs/src/lib/types/query-params.d.ts +47 -0
- package/mjs/src/lib/types/query-params.js +2 -0
- package/mjs/src/lib/types/query-params.js.map +1 -0
- package/mjs/src/lib/types/utils.d.ts +6 -0
- package/mjs/src/lib/types/utils.js +2 -0
- package/mjs/src/lib/types/utils.js.map +1 -0
- package/mjs/src/lib/utils/adapter-for-axios.d.ts +3 -0
- package/mjs/src/lib/utils/adapter-for-axios.js +54 -0
- package/mjs/src/lib/utils/adapter-for-axios.js.map +1 -0
- package/mjs/src/lib/utils/entity-array.d.ts +9 -0
- package/mjs/src/lib/utils/entity-array.js +25 -0
- package/mjs/src/lib/utils/entity-array.js.map +1 -0
- package/mjs/src/lib/utils/generate-atomic-body.d.ts +22 -0
- package/mjs/src/lib/utils/generate-atomic-body.js +83 -0
- package/mjs/src/lib/utils/generate-atomic-body.js.map +1 -0
- package/mjs/src/lib/utils/http-params.d.ts +154 -0
- package/mjs/src/lib/utils/http-params.js +300 -0
- package/mjs/src/lib/utils/http-params.js.map +1 -0
- package/mjs/src/lib/utils/index.d.ts +5 -0
- package/mjs/src/lib/utils/index.js +6 -0
- package/mjs/src/lib/utils/index.js.map +1 -0
- package/mjs/src/lib/utils/utils.d.ts +4 -0
- package/mjs/src/lib/utils/utils.js +24 -0
- package/mjs/src/lib/utils/utils.js.map +1 -0
- package/mjs/src/ngModule.d.ts +4 -0
- package/mjs/src/ngModule.js +4 -0
- package/mjs/src/ngModule.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FilterOperand } from '@klerick/json-api-nestjs-shared';
|
|
2
|
+
export type FilterOperandForString = Exclude<FilterOperand, FilterOperand.in | FilterOperand.nin | FilterOperand.some>;
|
|
3
|
+
export type Operands = {
|
|
4
|
+
[P in FilterOperand]?: P extends FilterOperandForString ? string : string[];
|
|
5
|
+
};
|
|
6
|
+
export type OperandsRelation = {
|
|
7
|
+
[FilterOperand.eq]: null;
|
|
8
|
+
} | {
|
|
9
|
+
[FilterOperand.ne]: null;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-operand.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/filter-operand.ts"],"names":[],"mappings":";;AAAA,4EAAgE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { RelationKeys, ResourceObject, ResourceObjectRelationships } from '@klerick/json-api-nestjs-shared';
|
|
3
|
+
import { ParamObject } from '../utils';
|
|
4
|
+
import { PostData, PatchData, RelationBodyData } from './http-request-params';
|
|
5
|
+
import { AtomicBody, AtomicResponse } from './atomic-type';
|
|
6
|
+
export interface HttpInnerClient {
|
|
7
|
+
get<T extends object, R extends 'object' | 'array' = 'object', IdKey extends string = string>(url: string, params?: {
|
|
8
|
+
params: ParamObject;
|
|
9
|
+
}): Observable<ResourceObject<T, R, null, IdKey>>;
|
|
10
|
+
get<T extends object, IdKey extends string, Rel extends RelationKeys<T, IdKey>>(url: string, params?: {
|
|
11
|
+
params: ParamObject;
|
|
12
|
+
}): Observable<ResourceObjectRelationships<T, IdKey, Rel>>;
|
|
13
|
+
post<T extends object>(url: string, body: PostData<T>): Observable<ResourceObject<T>>;
|
|
14
|
+
post<T extends unknown[]>(url: string, body: AtomicBody): Observable<AtomicResponse<T>>;
|
|
15
|
+
post<T extends object, IdKey extends string, Rel extends RelationKeys<T, IdKey>>(url: string, body: RelationBodyData | RelationBodyData[]): Observable<ResourceObjectRelationships<T, IdKey, Rel>>;
|
|
16
|
+
patch<T extends object>(url: string, body: PatchData<T>): Observable<ResourceObject<T>>;
|
|
17
|
+
patch<T extends object, IdKey extends string, Rel extends RelationKeys<T, IdKey>>(url: string, body: RelationBodyData | RelationBodyData[]): Observable<ResourceObjectRelationships<T, IdKey, Rel>>;
|
|
18
|
+
delete(url: string, body?: RelationBodyData | RelationBodyData[]): Observable<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-inner-client.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/http-inner-client.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MainData, BaseAttribute, RelationKeys, BaseMainData } from '@klerick/json-api-nestjs-shared';
|
|
2
|
+
export type Relationships<Entity extends object, IdKey extends string = 'id'> = {
|
|
3
|
+
[P in RelationKeys<Entity, IdKey>]?: BaseMainData<Entity, IdKey, P>;
|
|
4
|
+
};
|
|
5
|
+
export type BaseRelationships<Entity extends object, IdKey extends string = 'id'> = {
|
|
6
|
+
relationships?: Relationships<Entity, IdKey>;
|
|
7
|
+
};
|
|
8
|
+
type PostMainData<T = string> = Omit<MainData<T>, 'id'> & {
|
|
9
|
+
id?: string;
|
|
10
|
+
};
|
|
11
|
+
export type PostData<T extends object, IdKey extends string = 'id'> = {
|
|
12
|
+
data: PostMainData & BaseAttribute<T, IdKey> & BaseRelationships<T, IdKey>;
|
|
13
|
+
};
|
|
14
|
+
export type PatchData<T extends object, IdKey extends string = 'id'> = {
|
|
15
|
+
data: MainData & BaseAttribute<T, IdKey> & BaseRelationships<T, IdKey>;
|
|
16
|
+
};
|
|
17
|
+
export type RelationBodyData = {
|
|
18
|
+
data: MainData | MainData[];
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-request-params.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/http-request-params.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './http-inner-client';
|
|
2
|
+
export * from './http-request-params';
|
|
3
|
+
export * from './atomic-type';
|
|
4
|
+
export * from './atomic-operation';
|
|
5
|
+
export * from './utils';
|
|
6
|
+
export * from './config';
|
|
7
|
+
export * from './query-params';
|
|
8
|
+
export * from './promise-json-api-sdk';
|
|
9
|
+
export * from './filter-operand';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./http-inner-client"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./http-request-params"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./atomic-type"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./atomic-operation"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./config"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./query-params"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./promise-json-api-sdk"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./filter-operand"), exports);
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,gEAAsC;AACtC,wDAA8B;AAC9B,6DAAmC;AACnC,kDAAwB;AACxB,mDAAyB;AACzB,yDAA+B;AAC/B,iEAAuC;AACvC,2DAAiC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EntityClass, RelationKeys } from '@klerick/json-api-nestjs-shared';
|
|
2
|
+
import { QueryParams, QueryParamsForOneItem } from './query-params';
|
|
3
|
+
import { EntityArray } from '../utils';
|
|
4
|
+
import { ReturnIfArray } from './utils';
|
|
5
|
+
export interface PromiseJsonApiSdkService {
|
|
6
|
+
getList<Entity extends object>(entity: EntityClass<Entity>, params?: QueryParams<Entity>): Promise<EntityArray<Entity>>;
|
|
7
|
+
getAll<Entity extends object>(entity: EntityClass<Entity>, params?: QueryParams<Entity>): Promise<EntityArray<Entity>>;
|
|
8
|
+
getOne<Entity extends object>(entity: EntityClass<Entity>, id: string | number, params?: QueryParamsForOneItem<Entity>): Promise<Entity>;
|
|
9
|
+
postOne<Entity extends object>(entity: Entity): Promise<Entity>;
|
|
10
|
+
patchOne<Entity extends object>(entity: Entity): Promise<Entity>;
|
|
11
|
+
deleteOne<Entity extends object>(entity: Entity): Promise<void>;
|
|
12
|
+
getRelationships<Entity extends object, IdKey extends string = 'id', Rel extends RelationKeys<Entity, IdKey> = RelationKeys<Entity, IdKey>>(entity: Entity, relationType: Rel): Promise<ReturnIfArray<Entity[Rel], string>>;
|
|
13
|
+
patchRelationships<Entity extends object, IdKey extends string = 'id', Rel extends RelationKeys<Entity, IdKey> = RelationKeys<Entity, IdKey>>(entity: Entity, relationType: Rel): Promise<ReturnIfArray<Entity[Rel], string>>;
|
|
14
|
+
postRelationships<Entity extends object, IdKey extends string = 'id', Rel extends RelationKeys<Entity, IdKey> = RelationKeys<Entity, IdKey>>(entity: Entity, relationType: Rel): Promise<ReturnIfArray<Entity[Rel], string>>;
|
|
15
|
+
deleteRelationships<Entity extends object, IdKey extends string = 'id', Rel extends RelationKeys<Entity, IdKey> = RelationKeys<Entity, IdKey>>(entity: Entity, relationType: Rel): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-json-api-sdk.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/promise-json-api-sdk.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { QueryField, RelationKeys, PropertyKeys, TypeOfArray } from '@klerick/json-api-nestjs-shared';
|
|
2
|
+
import { Operands, OperandsRelation } from './filter-operand';
|
|
3
|
+
export type SortType = 'ASC' | 'DESC';
|
|
4
|
+
export type Includes<T> = RelationKeys<T>[];
|
|
5
|
+
type TargetField<E> = {
|
|
6
|
+
target?: PropertyKeys<E>[];
|
|
7
|
+
};
|
|
8
|
+
type RelationField<E> = {
|
|
9
|
+
[K in RelationKeys<E>]?: PropertyKeys<TypeOfArray<E[K]>>[];
|
|
10
|
+
};
|
|
11
|
+
type SortForEntity<E> = {
|
|
12
|
+
[K in PropertyKeys<E>]?: SortType;
|
|
13
|
+
};
|
|
14
|
+
type TargetSort<E> = {
|
|
15
|
+
target?: SortForEntity<E>;
|
|
16
|
+
};
|
|
17
|
+
type RelationSort<E> = {
|
|
18
|
+
[K in RelationKeys<E>]?: SortForEntity<TypeOfArray<E[K]>>;
|
|
19
|
+
};
|
|
20
|
+
type Sort<E> = TargetSort<E> & RelationSort<E>;
|
|
21
|
+
type Fields<E> = TargetField<E> & RelationField<E>;
|
|
22
|
+
export type Pagination = {
|
|
23
|
+
number: number;
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
26
|
+
type TargetRelationFilter<E> = {
|
|
27
|
+
[P in RelationKeys<E>]?: OperandsRelation;
|
|
28
|
+
};
|
|
29
|
+
type EntityFilter<E> = {
|
|
30
|
+
[K in PropertyKeys<E>]?: Operands;
|
|
31
|
+
};
|
|
32
|
+
type TargetFilter<E> = {
|
|
33
|
+
target: EntityFilter<E> & TargetRelationFilter<E>;
|
|
34
|
+
};
|
|
35
|
+
type RelationFilter<E> = {
|
|
36
|
+
[K in RelationKeys<E>]?: EntityFilter<TypeOfArray<E[K]>>;
|
|
37
|
+
};
|
|
38
|
+
export type Filter<T> = TargetFilter<T> & RelationFilter<T>;
|
|
39
|
+
export type QueryParams<E> = {
|
|
40
|
+
[QueryField.filter]?: Filter<E>;
|
|
41
|
+
[QueryField.include]?: Includes<E>;
|
|
42
|
+
[QueryField.sort]?: Sort<E>;
|
|
43
|
+
[QueryField.page]?: Pagination;
|
|
44
|
+
[QueryField.fields]?: Fields<E>;
|
|
45
|
+
};
|
|
46
|
+
export type QueryParamsForOneItem<T> = Pick<QueryParams<T>, QueryField.include | QueryField.filter | QueryField.fields>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-params.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/query-params.ts"],"names":[],"mappings":";;AAAA,4EAKyC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ReturnIfArray<I, O> = I extends unknown[] ? O[] : O;
|
|
2
|
+
export type PartialByKeys<E, K extends keyof E> = Omit<E, K> & Partial<Pick<E, K>>;
|
|
3
|
+
export type FunctionProperty<T, K extends keyof T> = T[K] extends (...args: any) => any ? T[K] : never;
|
|
4
|
+
export type FunctionPropertyNames<T> = {
|
|
5
|
+
[K in keyof T]: T[K] extends (...args: any) => any ? K : never;
|
|
6
|
+
}[keyof T];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/types/utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adapterForAxios = adapterForAxios;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
class AxiosHttpClient {
|
|
7
|
+
constructor(axios) {
|
|
8
|
+
this.axios = axios;
|
|
9
|
+
}
|
|
10
|
+
observify(makeRequest, controller) {
|
|
11
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
12
|
+
makeRequest()
|
|
13
|
+
.then((response) => subscriber.next(response))
|
|
14
|
+
.catch((error) => subscriber.error(error))
|
|
15
|
+
.finally(() => subscriber.complete());
|
|
16
|
+
return { unsubscribe: () => controller.abort() };
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
makeCancellable() {
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
const signal = controller.signal;
|
|
22
|
+
return {
|
|
23
|
+
controller,
|
|
24
|
+
signal,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
delete(url, body) {
|
|
28
|
+
if (body) {
|
|
29
|
+
return this.request(url, 'DELETE', body);
|
|
30
|
+
}
|
|
31
|
+
return this.request(url, 'DELETE');
|
|
32
|
+
}
|
|
33
|
+
get(url, params) {
|
|
34
|
+
return this.request(url, 'GET', undefined, params ? params.params : undefined);
|
|
35
|
+
}
|
|
36
|
+
patch(url, body) {
|
|
37
|
+
return this.request(url, 'PATCH', body);
|
|
38
|
+
}
|
|
39
|
+
post(url, body) {
|
|
40
|
+
return this.request(url, 'POST', body);
|
|
41
|
+
}
|
|
42
|
+
request(url, method, data, params) {
|
|
43
|
+
const { controller, signal } = this.makeCancellable();
|
|
44
|
+
return this.observify(() => this.axios.request({
|
|
45
|
+
url,
|
|
46
|
+
method,
|
|
47
|
+
data,
|
|
48
|
+
signal,
|
|
49
|
+
params,
|
|
50
|
+
}), controller).pipe((0, operators_1.map)((r) => r.data));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function adapterForAxios(axios) {
|
|
54
|
+
return new AxiosHttpClient(axios);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=adapter-for-axios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-for-axios.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/utils/adapter-for-axios.ts"],"names":[],"mappings":";;AAsKA,0CAEC;AAlKD,+BAAkC;AAClC,8CAAqC;AAYrC,MAAM,eAAe;IACnB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAE5B,SAAS,CACf,WAA6B,EAC7B,UAA2B;QAE3B,OAAO,IAAI,iBAAU,CAAC,CAAC,UAAU,EAAE,EAAE;YACnC,WAAW,EAAE;iBACV,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC7C,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBAClD,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;YAExC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC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AAC,IAAI,CAAC,IAAA,eAAG,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,SAAgB,eAAe,CAAC,KAAY;IAC1C,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PageProps } from '@klerick/json-api-nestjs-shared';
|
|
2
|
+
export declare class EntityArray<T> extends Array<T> {
|
|
3
|
+
private pageProps;
|
|
4
|
+
constructor(items: T[], pageProps: PageProps);
|
|
5
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
6
|
+
get totalItems(): number;
|
|
7
|
+
get pageSize(): number;
|
|
8
|
+
get pageNumber(): number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityArray = void 0;
|
|
4
|
+
class EntityArray extends Array {
|
|
5
|
+
constructor(items, pageProps) {
|
|
6
|
+
super(...items);
|
|
7
|
+
this.pageProps = pageProps;
|
|
8
|
+
Object.defineProperty(this, 'pageProps', {
|
|
9
|
+
writable: false,
|
|
10
|
+
enumerable: false,
|
|
11
|
+
value: pageProps,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
static get [Symbol.species]() {
|
|
15
|
+
return Array;
|
|
16
|
+
}
|
|
17
|
+
get totalItems() {
|
|
18
|
+
return this.pageProps.totalItems;
|
|
19
|
+
}
|
|
20
|
+
get pageSize() {
|
|
21
|
+
return this.pageProps.pageSize;
|
|
22
|
+
}
|
|
23
|
+
get pageNumber() {
|
|
24
|
+
return this.pageProps.pageNumber;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.EntityArray = EntityArray;
|
|
28
|
+
//# sourceMappingURL=entity-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-array.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/utils/entity-array.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAe,SAAQ,KAAQ;IAC1C,YAAY,KAAU,EAAU,SAAoB;QAClD,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;QADc,cAAS,GAAT,SAAS,CAAW;QAElD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE;YACvC,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IACnC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IACnC,CAAC;CACF;AAzBD,kCAyBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RelationKeys } from '@klerick/json-api-nestjs-shared';
|
|
2
|
+
import { AtomicMainOperations, JsonApiSdkConfig, BodyType } from '../types';
|
|
3
|
+
import { JsonApiUtilsService } from '../service';
|
|
4
|
+
export type AtomicVoidOperation = {
|
|
5
|
+
[K in keyof AtomicMainOperations<[]>]: (...arg: any) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare class GenerateAtomicBody<Entity extends object = any, Rel extends RelationKeys<Entity> = any> implements AtomicVoidOperation {
|
|
8
|
+
private jsonApiUtilsService;
|
|
9
|
+
private jsonApiSdkConfig;
|
|
10
|
+
constructor(jsonApiUtilsService: JsonApiUtilsService, jsonApiSdkConfig: JsonApiSdkConfig);
|
|
11
|
+
private bodyData;
|
|
12
|
+
private skipEmpty;
|
|
13
|
+
get isSkipEmpty(): boolean;
|
|
14
|
+
private setToBody;
|
|
15
|
+
getBody(): BodyType;
|
|
16
|
+
postOne(entity: Entity): void;
|
|
17
|
+
patchOne(entity: Entity): void;
|
|
18
|
+
deleteOne(entity: Entity, skipEmpty: boolean): void;
|
|
19
|
+
patchRelationships(entity: Entity, relationType: Rel): void;
|
|
20
|
+
postRelationships(entity: Entity, relationType: Rel): void;
|
|
21
|
+
deleteRelationships(entity: Entity, relationType: Rel): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenerateAtomicBody = void 0;
|
|
4
|
+
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
class GenerateAtomicBody {
|
|
7
|
+
constructor(jsonApiUtilsService, jsonApiSdkConfig) {
|
|
8
|
+
this.jsonApiUtilsService = jsonApiUtilsService;
|
|
9
|
+
this.jsonApiSdkConfig = jsonApiSdkConfig;
|
|
10
|
+
this.skipEmpty = true;
|
|
11
|
+
}
|
|
12
|
+
get isSkipEmpty() {
|
|
13
|
+
return this.skipEmpty;
|
|
14
|
+
}
|
|
15
|
+
setToBody(op, entity, relationType) {
|
|
16
|
+
const type = (0, utils_1.getTypeForReq)(entity.constructor.name);
|
|
17
|
+
const { relationships, attributes } = this.jsonApiUtilsService.generateBody(entity);
|
|
18
|
+
const id = Reflect.get(entity, this.jsonApiSdkConfig.idKey);
|
|
19
|
+
const idObj = op === 'add' && !relationType ? {} : { id: String(id) };
|
|
20
|
+
const data = relationType
|
|
21
|
+
? this.jsonApiUtilsService.generateRelationshipsBody(entity[relationType])
|
|
22
|
+
: Object.assign(Object.assign({ type: (0, utils_1.getTypeForReq)(entity.constructor.name), attributes }, (Object.keys(relationships).length > 0 ? { relationships } : {})), idObj);
|
|
23
|
+
const rel = relationType ? { relationship: String(relationType) } : {};
|
|
24
|
+
const tmpId = op === 'add' && id && !relationType ? { tmpId: String(id) } : {};
|
|
25
|
+
this.bodyData = Object.assign({ op, ref: Object.assign(Object.assign(Object.assign({ type }, idObj), rel), tmpId) }, (op === 'remove' && !relationType ? {} : { data }));
|
|
26
|
+
}
|
|
27
|
+
getBody() {
|
|
28
|
+
return this.bodyData;
|
|
29
|
+
}
|
|
30
|
+
postOne(entity) {
|
|
31
|
+
this.setToBody(json_api_nestjs_shared_1.Operation.add, entity);
|
|
32
|
+
}
|
|
33
|
+
patchOne(entity) {
|
|
34
|
+
if (Reflect.get(entity, this.jsonApiSdkConfig.idKey) === undefined) {
|
|
35
|
+
throw new Error('Resource params should be instance of resource with id params');
|
|
36
|
+
}
|
|
37
|
+
this.setToBody(json_api_nestjs_shared_1.Operation.update, entity);
|
|
38
|
+
}
|
|
39
|
+
deleteOne(entity, skipEmpty) {
|
|
40
|
+
if (!Reflect.get(entity, this.jsonApiSdkConfig.idKey)) {
|
|
41
|
+
throw new Error('Resource params should be instance of resource with id params');
|
|
42
|
+
}
|
|
43
|
+
this.skipEmpty = skipEmpty;
|
|
44
|
+
this.setToBody(json_api_nestjs_shared_1.Operation.remove, entity);
|
|
45
|
+
}
|
|
46
|
+
patchRelationships(entity, relationType) {
|
|
47
|
+
if (!Reflect.get(entity, this.jsonApiSdkConfig.idKey)) {
|
|
48
|
+
throw new Error('Resource params should be instance of resource with id params');
|
|
49
|
+
}
|
|
50
|
+
if (entity[relationType] === undefined) {
|
|
51
|
+
new Error(`${relationType.toString()} should not be undefined in entity`);
|
|
52
|
+
}
|
|
53
|
+
this.setToBody(json_api_nestjs_shared_1.Operation.update, entity, relationType);
|
|
54
|
+
}
|
|
55
|
+
postRelationships(entity, relationType) {
|
|
56
|
+
if (!Reflect.get(entity, this.jsonApiSdkConfig.idKey)) {
|
|
57
|
+
throw new Error('Resource params should be instance of resource with id params');
|
|
58
|
+
}
|
|
59
|
+
if (entity[relationType] === undefined) {
|
|
60
|
+
throw new Error(`${relationType.toString()} should not be undefined in entity`);
|
|
61
|
+
}
|
|
62
|
+
this.setToBody(json_api_nestjs_shared_1.Operation.add, entity, relationType);
|
|
63
|
+
}
|
|
64
|
+
deleteRelationships(entity, relationType) {
|
|
65
|
+
if (!Reflect.get(entity, this.jsonApiSdkConfig.idKey)) {
|
|
66
|
+
throw new Error('Resource params should be instance of resource with id params');
|
|
67
|
+
}
|
|
68
|
+
if (entity[relationType] === undefined) {
|
|
69
|
+
throw new Error(`${relationType.toString()} should not be undefined in entity`);
|
|
70
|
+
}
|
|
71
|
+
this.setToBody(json_api_nestjs_shared_1.Operation.remove, entity, relationType);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GenerateAtomicBody = GenerateAtomicBody;
|
|
75
|
+
//# sourceMappingURL=generate-atomic-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-atomic-body.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs-sdk/src/lib/utils/generate-atomic-body.ts"],"names":[],"mappings":";;;AAAA,4EAA0E;AAG1E,mCAAwC;AAOxC,MAAa,kBAAkB;IAK7B,YACU,mBAAwC,EACxC,gBAAkC;QADlC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAGpC,cAAS,GAAG,IAAI,CAAC;IAFtB,CAAC;IAIJ,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEO,SAAS,CAAC,EAAa,EAAE,MAAc,EAAE,YAAkB;QACjE,MAAM,IAAI,GAAG,IAAA,qBAAa,EAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAEpD,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GACjC,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,EAAE,GAAG,OAAO,CAAC,GAA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C,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CACb,GAAG,YAAY,CAAC,QAAQ,EAAE,oCAAoC,CAC/D,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,kCAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;IACD,mBAAmB,CAAC,MAAc,EAAE,YAAiB;QACnD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CACb,GAAG,YAAY,CAAC,QAAQ,EAAE,oCAAoC,CAC/D,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,kCAAS,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;CACF;AA9GD,gDA8GC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A codec for encoding and decoding parameters in URLs.
|
|
10
|
+
*
|
|
11
|
+
* Used by `HttpParams`.
|
|
12
|
+
*
|
|
13
|
+
* @publicApi
|
|
14
|
+
**/
|
|
15
|
+
export interface HttpParameterCodec {
|
|
16
|
+
encodeKey(key: string): string;
|
|
17
|
+
encodeValue(value: string): string;
|
|
18
|
+
decodeKey(key: string): string;
|
|
19
|
+
decodeValue(value: string): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Provides encoding and decoding of URL parameter and query-string values.
|
|
23
|
+
*
|
|
24
|
+
* Serializes and parses URL parameter keys and values to encode and decode them.
|
|
25
|
+
* If you pass URL query parameters without encoding,
|
|
26
|
+
* the query parameters can be misinterpreted at the receiving end.
|
|
27
|
+
*
|
|
28
|
+
*
|
|
29
|
+
* @publicApi
|
|
30
|
+
*/
|
|
31
|
+
export declare class HttpUrlEncodingCodec implements HttpParameterCodec {
|
|
32
|
+
/**
|
|
33
|
+
* Encodes a key name for a URL parameter or query-string.
|
|
34
|
+
* @param key The key name.
|
|
35
|
+
* @returns The encoded key name.
|
|
36
|
+
*/
|
|
37
|
+
encodeKey(key: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Encodes the value of a URL parameter or query-string.
|
|
40
|
+
* @param value The value.
|
|
41
|
+
* @returns The encoded value.
|
|
42
|
+
*/
|
|
43
|
+
encodeValue(value: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Decodes an encoded URL parameter or query-string key.
|
|
46
|
+
* @param key The encoded key name.
|
|
47
|
+
* @returns The decoded key name.
|
|
48
|
+
*/
|
|
49
|
+
decodeKey(key: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Decodes an encoded URL parameter or query-string value.
|
|
52
|
+
* @param value The encoded value.
|
|
53
|
+
* @returns The decoded value.
|
|
54
|
+
*/
|
|
55
|
+
decodeValue(value: string): string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options used to construct an `HttpParams` instance.
|
|
59
|
+
*
|
|
60
|
+
* @publicApi
|
|
61
|
+
*/
|
|
62
|
+
export interface HttpParamsOptions {
|
|
63
|
+
/**
|
|
64
|
+
* String representation of the HTTP parameters in URL-query-string format.
|
|
65
|
+
* Mutually exclusive with `fromObject`.
|
|
66
|
+
*/
|
|
67
|
+
fromString?: string;
|
|
68
|
+
/** Object map of the HTTP parameters. Mutually exclusive with `fromString`. */
|
|
69
|
+
fromObject?: ParamObject;
|
|
70
|
+
/** Encoding codec used to parse and serialize the parameters. */
|
|
71
|
+
encoder?: HttpParameterCodec;
|
|
72
|
+
}
|
|
73
|
+
export type ParamObject = {
|
|
74
|
+
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* An HTTP request/response body that represents serialized parameters,
|
|
78
|
+
* per the MIME type `application/x-www-form-urlencoded`.
|
|
79
|
+
*
|
|
80
|
+
* This class is immutable; all mutation operations return a new instance.
|
|
81
|
+
*
|
|
82
|
+
* @publicApi
|
|
83
|
+
*/
|
|
84
|
+
export declare class HttpParams {
|
|
85
|
+
private map;
|
|
86
|
+
private encoder;
|
|
87
|
+
private updates;
|
|
88
|
+
private cloneFrom;
|
|
89
|
+
constructor(options?: HttpParamsOptions);
|
|
90
|
+
/**
|
|
91
|
+
* Reports whether the body includes one or more values for a given parameter.
|
|
92
|
+
* @param param The parameter name.
|
|
93
|
+
* @returns True if the parameter has one or more values,
|
|
94
|
+
* false if it has no value or is not present.
|
|
95
|
+
*/
|
|
96
|
+
has(param: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves the first value for a parameter.
|
|
99
|
+
* @param param The parameter name.
|
|
100
|
+
* @returns The first value of the given parameter,
|
|
101
|
+
* or `null` if the parameter is not present.
|
|
102
|
+
*/
|
|
103
|
+
get(param: string): string | null;
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves all values for a parameter.
|
|
106
|
+
* @param param The parameter name.
|
|
107
|
+
* @returns All values in a string array,
|
|
108
|
+
* or `null` if the parameter not present.
|
|
109
|
+
*/
|
|
110
|
+
getAll(param: string): string[] | null;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves all the parameters for this body.
|
|
113
|
+
* @returns The parameter names in a string array.
|
|
114
|
+
*/
|
|
115
|
+
keys(): string[];
|
|
116
|
+
/**
|
|
117
|
+
* Appends a new value to existing values for a parameter.
|
|
118
|
+
* @param param The parameter name.
|
|
119
|
+
* @param value The new value to add.
|
|
120
|
+
* @return A new body with the appended value.
|
|
121
|
+
*/
|
|
122
|
+
append(param: string, value: string | number | boolean): HttpParams;
|
|
123
|
+
/**
|
|
124
|
+
* Constructs a new body with appended values for the given parameter name.
|
|
125
|
+
* @param params parameters and values
|
|
126
|
+
* @return A new body with the new value.
|
|
127
|
+
*/
|
|
128
|
+
appendAll(params: {
|
|
129
|
+
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
130
|
+
}): HttpParams;
|
|
131
|
+
/**
|
|
132
|
+
* Replaces the value for a parameter.
|
|
133
|
+
* @param param The parameter name.
|
|
134
|
+
* @param value The new value.
|
|
135
|
+
* @return A new body with the new value.
|
|
136
|
+
*/
|
|
137
|
+
set(param: string, value: string | number | boolean): HttpParams;
|
|
138
|
+
/**
|
|
139
|
+
* Removes a given value or all values from a parameter.
|
|
140
|
+
* @param param The parameter name.
|
|
141
|
+
* @param value The value to remove, if provided.
|
|
142
|
+
* @return A new body with the given value removed, or with all values
|
|
143
|
+
* removed if no value is specified.
|
|
144
|
+
*/
|
|
145
|
+
delete(param: string, value?: string | number | boolean): HttpParams;
|
|
146
|
+
/**
|
|
147
|
+
* Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
|
|
148
|
+
* separated by `&`s.
|
|
149
|
+
*/
|
|
150
|
+
toString(): string;
|
|
151
|
+
toObject(): ParamObject;
|
|
152
|
+
private clone;
|
|
153
|
+
private init;
|
|
154
|
+
}
|