ad2app-lib 1.0.2 → 1.0.3
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/dist/api/apiDriver.d.ts +25 -6
- package/dist/api/apiDriver.js +15 -7
- package/dist/types/I_Agency.d.ts +2 -2
- package/dist/types/I_Collaboration.d.ts +35 -0
- package/dist/types/I_Collaboration.js +15 -0
- package/dist/types/I_Media.d.ts +16 -1
- package/dist/types/I_Media.js +11 -8
- package/dist/types/I_Offer.d.ts +1 -0
- package/dist/types/I_Offer.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +1 -1
- package/src/api/apiDriver.ts +31 -15
- package/src/types/I_Agency.ts +2 -2
- package/src/types/I_Collaboration.ts +47 -0
- package/src/types/I_Media.ts +19 -1
- package/src/types/I_Offer.ts +2 -0
- package/src/types/index.ts +1 -0
package/dist/api/apiDriver.d.ts
CHANGED
|
@@ -5,12 +5,31 @@ interface DriverConfig {
|
|
|
5
5
|
getHeaders?: () => HeadersInit;
|
|
6
6
|
}
|
|
7
7
|
export declare function configureApiDriver(config: DriverConfig): void;
|
|
8
|
-
|
|
8
|
+
type FetchCallArgs<Q> = [
|
|
9
|
+
path: string,
|
|
10
|
+
params?: FetchParams<Q>,
|
|
11
|
+
method?: HttpMethod,
|
|
12
|
+
headers?: HeadersInit,
|
|
13
|
+
transformers?: {
|
|
14
|
+
body?: (body: any) => BodyInit;
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
export declare function fetchCall<T, Q>(...args: FetchCallArgs<Q>): Promise<T>;
|
|
9
18
|
export declare function apiDriver(): {
|
|
10
|
-
get: <T, Q>(path: string, params?: FetchParams<Q
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
get: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
20
|
+
body?: (body: any) => BodyInit;
|
|
21
|
+
}) => Promise<T>;
|
|
22
|
+
post: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
23
|
+
body?: (body: any) => BodyInit;
|
|
24
|
+
}) => Promise<T>;
|
|
25
|
+
put: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
26
|
+
body?: (body: any) => BodyInit;
|
|
27
|
+
}) => Promise<T>;
|
|
28
|
+
patch: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
29
|
+
body?: (body: any) => BodyInit;
|
|
30
|
+
}) => Promise<T>;
|
|
31
|
+
delete: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
32
|
+
body?: (body: any) => BodyInit;
|
|
33
|
+
}) => Promise<T>;
|
|
15
34
|
};
|
|
16
35
|
export {};
|
package/dist/api/apiDriver.js
CHANGED
|
@@ -8,8 +8,12 @@ let CONFIG;
|
|
|
8
8
|
function configureApiDriver(config) {
|
|
9
9
|
CONFIG = config;
|
|
10
10
|
}
|
|
11
|
-
async function fetchCall(
|
|
12
|
-
|
|
11
|
+
async function fetchCall(...args) {
|
|
12
|
+
let [path, fetchParams, method, headers, transformers] = args;
|
|
13
|
+
headers = {
|
|
14
|
+
...CONFIG.getHeaders?.(),
|
|
15
|
+
...headers,
|
|
16
|
+
};
|
|
13
17
|
const query = {};
|
|
14
18
|
Object.entries(fetchParams?.query || {}).forEach(([key, val]) => {
|
|
15
19
|
query[key] = Array.isArray(val) ? JSON.stringify(val) : val;
|
|
@@ -21,7 +25,11 @@ async function fetchCall(path, fetchParams, method = 'get') {
|
|
|
21
25
|
headers,
|
|
22
26
|
};
|
|
23
27
|
if (fetchParams?.body) {
|
|
28
|
+
// if (transformers?.body) {
|
|
29
|
+
// init.body = transformers.body(fetchParams.body);
|
|
30
|
+
// } else {
|
|
24
31
|
init.body = JSON.stringify(fetchParams.body);
|
|
32
|
+
// }
|
|
25
33
|
headers['Content-Type'] = 'application/json';
|
|
26
34
|
}
|
|
27
35
|
const res = await fetch(fullPath, init);
|
|
@@ -31,10 +39,10 @@ async function fetchCall(path, fetchParams, method = 'get') {
|
|
|
31
39
|
}
|
|
32
40
|
function apiDriver() {
|
|
33
41
|
return {
|
|
34
|
-
get: (
|
|
35
|
-
post: (
|
|
36
|
-
put: (
|
|
37
|
-
patch: (
|
|
38
|
-
delete: (
|
|
42
|
+
get: (...args) => fetchCall(args[0], args[1], 'get', args[3], args[4]),
|
|
43
|
+
post: (...args) => fetchCall(args[0], args[1], 'post', args[3], args[4]),
|
|
44
|
+
put: (...args) => fetchCall(args[0], args[1], 'put', args[3], args[4]),
|
|
45
|
+
patch: (...args) => fetchCall(args[0], args[1], 'patch', args[3], args[4]),
|
|
46
|
+
delete: (...args) => fetchCall(args[0], args[1], 'delete', args[3], args[4]),
|
|
39
47
|
};
|
|
40
48
|
}
|
package/dist/types/I_Agency.d.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { I_Offer } from './I_Offer';
|
|
2
|
+
export declare class I_Collaboration {
|
|
3
|
+
id: string;
|
|
4
|
+
offer: I_Offer;
|
|
5
|
+
media: [];
|
|
6
|
+
}
|
|
7
|
+
export declare class I_GetCampaignCollaborationsDTO {
|
|
8
|
+
campaignId: string;
|
|
9
|
+
constructor(data?: Partial<I_GetCampaignCollaborationsDTO>);
|
|
10
|
+
}
|
|
11
|
+
export declare class I_GetCollaborationDTO {
|
|
12
|
+
collaborationId: string;
|
|
13
|
+
constructor(data?: Partial<I_GetCollaborationDTO>);
|
|
14
|
+
}
|
|
15
|
+
export declare class I_GetCollaborationByOfferDTO {
|
|
16
|
+
offerId: string;
|
|
17
|
+
constructor(data?: Partial<I_GetCollaborationByOfferDTO>);
|
|
18
|
+
}
|
|
19
|
+
export declare class I_GetCollaborationsDTO {
|
|
20
|
+
userId: string;
|
|
21
|
+
constructor(data?: Partial<I_GetCollaborationsDTO>);
|
|
22
|
+
}
|
|
23
|
+
export declare class I_FindUserCollaborationsDTO {
|
|
24
|
+
userId: string;
|
|
25
|
+
constructor(data?: Partial<I_FindUserCollaborationsDTO>);
|
|
26
|
+
}
|
|
27
|
+
export declare class I_CreateCollaborationDTO {
|
|
28
|
+
offerId: string;
|
|
29
|
+
constructor(data?: Partial<I_CreateCollaborationDTO>);
|
|
30
|
+
}
|
|
31
|
+
export declare class I_UploadFirstMediaVersionDTO {
|
|
32
|
+
collaborationId: string;
|
|
33
|
+
file: string;
|
|
34
|
+
fileName: string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.I_UploadFirstMediaVersionDTO = exports.I_CreateCollaborationDTO = exports.I_Collaboration = void 0;
|
|
4
|
+
class I_Collaboration {
|
|
5
|
+
}
|
|
6
|
+
exports.I_Collaboration = I_Collaboration;
|
|
7
|
+
class I_CreateCollaborationDTO {
|
|
8
|
+
constructor(data) {
|
|
9
|
+
this.offerId = data?.offerId ?? null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.I_CreateCollaborationDTO = I_CreateCollaborationDTO;
|
|
13
|
+
class I_UploadFirstMediaVersionDTO {
|
|
14
|
+
}
|
|
15
|
+
exports.I_UploadFirstMediaVersionDTO = I_UploadFirstMediaVersionDTO;
|
package/dist/types/I_Media.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum I_MediaStage {
|
|
2
2
|
UPLOADED = "uploaded",
|
|
3
3
|
ADJUSTMENT_REQUIRED = "adjustmentRequired",
|
|
4
4
|
REJECTED = "rejected",
|
|
5
5
|
ACCEPTED = "accepted"
|
|
6
6
|
}
|
|
7
|
+
export declare class I_Media {
|
|
8
|
+
id: string;
|
|
9
|
+
url: string;
|
|
10
|
+
fileName: string;
|
|
11
|
+
type: I_MediaStage;
|
|
12
|
+
}
|
|
13
|
+
export declare class I_GetCollaborationMediaDTO {
|
|
14
|
+
collaborationId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class I_CreateMediaDTO {
|
|
17
|
+
collaborationId: string;
|
|
18
|
+
fileName: string;
|
|
19
|
+
type: I_MediaStage;
|
|
20
|
+
file: string;
|
|
21
|
+
}
|
package/dist/types/I_Media.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(
|
|
3
|
+
exports.I_Media = exports.I_MediaStage = void 0;
|
|
4
|
+
var I_MediaStage;
|
|
5
|
+
(function (I_MediaStage) {
|
|
6
|
+
I_MediaStage["UPLOADED"] = "uploaded";
|
|
7
|
+
I_MediaStage["ADJUSTMENT_REQUIRED"] = "adjustmentRequired";
|
|
8
|
+
I_MediaStage["REJECTED"] = "rejected";
|
|
9
|
+
I_MediaStage["ACCEPTED"] = "accepted";
|
|
10
|
+
})(I_MediaStage || (exports.I_MediaStage = I_MediaStage = {}));
|
|
11
|
+
class I_Media {
|
|
12
|
+
}
|
|
13
|
+
exports.I_Media = I_Media;
|
package/dist/types/I_Offer.d.ts
CHANGED
package/dist/types/I_Offer.js
CHANGED
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/package.json
CHANGED
package/src/api/apiDriver.ts
CHANGED
|
@@ -14,12 +14,23 @@ export function configureApiDriver(config: DriverConfig) {
|
|
|
14
14
|
CONFIG = config;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
type FetchCallArgs<Q> = [
|
|
18
18
|
path: string,
|
|
19
|
-
|
|
20
|
-
method
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
params?: FetchParams<Q>,
|
|
20
|
+
method?: HttpMethod,
|
|
21
|
+
headers?: HeadersInit,
|
|
22
|
+
transformers?: {
|
|
23
|
+
body?: (body: any) => BodyInit;
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export async function fetchCall<T, Q>(...args: FetchCallArgs<Q>): Promise<T> {
|
|
28
|
+
let [path, fetchParams, method, headers, transformers] = args;
|
|
29
|
+
|
|
30
|
+
headers = {
|
|
31
|
+
...CONFIG.getHeaders?.(),
|
|
32
|
+
...headers,
|
|
33
|
+
};
|
|
23
34
|
|
|
24
35
|
const query: Q = {} as Q;
|
|
25
36
|
Object.entries(fetchParams?.query || {}).forEach(([key, val]) => {
|
|
@@ -38,7 +49,12 @@ export async function fetchCall<T, Q>(
|
|
|
38
49
|
};
|
|
39
50
|
|
|
40
51
|
if (fetchParams?.body) {
|
|
52
|
+
// if (transformers?.body) {
|
|
53
|
+
// init.body = transformers.body(fetchParams.body);
|
|
54
|
+
// } else {
|
|
41
55
|
init.body = JSON.stringify(fetchParams.body);
|
|
56
|
+
// }
|
|
57
|
+
|
|
42
58
|
headers['Content-Type'] = 'application/json';
|
|
43
59
|
}
|
|
44
60
|
|
|
@@ -51,15 +67,15 @@ export async function fetchCall<T, Q>(
|
|
|
51
67
|
|
|
52
68
|
export function apiDriver() {
|
|
53
69
|
return {
|
|
54
|
-
get: <T, Q>(
|
|
55
|
-
fetchCall<T, Q>(
|
|
56
|
-
post: <T, Q>(
|
|
57
|
-
fetchCall<T, Q>(
|
|
58
|
-
put: <T, Q>(
|
|
59
|
-
fetchCall<T, Q>(
|
|
60
|
-
patch: <T, Q>(
|
|
61
|
-
fetchCall<T, Q>(
|
|
62
|
-
delete: <T, Q>(
|
|
63
|
-
fetchCall<T, Q>(
|
|
70
|
+
get: <T, Q>(...args: FetchCallArgs<Q>) =>
|
|
71
|
+
fetchCall<T, Q>(args[0], args[1], 'get', args[3], args[4]),
|
|
72
|
+
post: <T, Q>(...args: FetchCallArgs<Q>) =>
|
|
73
|
+
fetchCall<T, Q>(args[0], args[1], 'post', args[3], args[4]),
|
|
74
|
+
put: <T, Q>(...args: FetchCallArgs<Q>) =>
|
|
75
|
+
fetchCall<T, Q>(args[0], args[1], 'put', args[3], args[4]),
|
|
76
|
+
patch: <T, Q>(...args: FetchCallArgs<Q>) =>
|
|
77
|
+
fetchCall<T, Q>(args[0], args[1], 'patch', args[3], args[4]),
|
|
78
|
+
delete: <T, Q>(...args: FetchCallArgs<Q>) =>
|
|
79
|
+
fetchCall<T, Q>(args[0], args[1], 'delete', args[3], args[4]),
|
|
64
80
|
};
|
|
65
81
|
}
|
package/src/types/I_Agency.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { I_Media } from './I_Media';
|
|
2
|
+
import { I_Offer } from './I_Offer';
|
|
3
|
+
|
|
4
|
+
export class I_Collaboration {
|
|
5
|
+
id: string;
|
|
6
|
+
offer: I_Offer;
|
|
7
|
+
media: [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare class I_GetCampaignCollaborationsDTO {
|
|
11
|
+
campaignId: string;
|
|
12
|
+
constructor(data?: Partial<I_GetCampaignCollaborationsDTO>);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class I_GetCollaborationDTO {
|
|
16
|
+
collaborationId: string;
|
|
17
|
+
constructor(data?: Partial<I_GetCollaborationDTO>);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare class I_GetCollaborationByOfferDTO {
|
|
21
|
+
offerId: string;
|
|
22
|
+
constructor(data?: Partial<I_GetCollaborationByOfferDTO>);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare class I_GetCollaborationsDTO {
|
|
26
|
+
userId: string;
|
|
27
|
+
constructor(data?: Partial<I_GetCollaborationsDTO>);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare class I_FindUserCollaborationsDTO {
|
|
31
|
+
userId: string;
|
|
32
|
+
constructor(data?: Partial<I_FindUserCollaborationsDTO>);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class I_CreateCollaborationDTO {
|
|
36
|
+
offerId: string;
|
|
37
|
+
|
|
38
|
+
constructor(data?: Partial<I_CreateCollaborationDTO>) {
|
|
39
|
+
this.offerId = data?.offerId ?? null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class I_UploadFirstMediaVersionDTO {
|
|
44
|
+
collaborationId: string;
|
|
45
|
+
file: string;
|
|
46
|
+
fileName: string;
|
|
47
|
+
}
|
package/src/types/I_Media.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
export enum
|
|
1
|
+
export enum I_MediaStage {
|
|
2
2
|
UPLOADED = 'uploaded',
|
|
3
3
|
ADJUSTMENT_REQUIRED = 'adjustmentRequired',
|
|
4
4
|
REJECTED = 'rejected',
|
|
5
5
|
ACCEPTED = 'accepted',
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export class I_Media {
|
|
9
|
+
id: string;
|
|
10
|
+
url: string;
|
|
11
|
+
fileName: string;
|
|
12
|
+
type: I_MediaStage;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class I_GetCollaborationMediaDTO {
|
|
16
|
+
collaborationId: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare class I_CreateMediaDTO {
|
|
20
|
+
collaborationId: string;
|
|
21
|
+
fileName: string;
|
|
22
|
+
type: I_MediaStage;
|
|
23
|
+
file: string;
|
|
24
|
+
}
|
package/src/types/I_Offer.ts
CHANGED
|
@@ -10,6 +10,7 @@ export class I_Offer {
|
|
|
10
10
|
price?: number;
|
|
11
11
|
status?: I_OfferStatus;
|
|
12
12
|
action?: OfferActions;
|
|
13
|
+
campaign: I_Campaign;
|
|
13
14
|
|
|
14
15
|
constructor(data?: I_Offer) {
|
|
15
16
|
this.agency = data?.agency ?? null;
|
|
@@ -18,6 +19,7 @@ export class I_Offer {
|
|
|
18
19
|
this.price = data?.price ?? null;
|
|
19
20
|
this.status = data?.status ?? null;
|
|
20
21
|
this.action = data?.action ?? null;
|
|
22
|
+
this.campaign = data?.campaign ?? null;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
package/src/types/index.ts
CHANGED