@merkl/api 0.17.27 → 0.17.29

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.
@@ -362,6 +362,21 @@ declare const app: Elysia<"", false, {
362
362
  address: string;
363
363
  creatorId: string | null;
364
364
  };
365
+ Opportunity: {
366
+ name: string;
367
+ type: string;
368
+ id: string;
369
+ status: import("../database/api/.generated").$Enums.Status;
370
+ tags: string[];
371
+ identifier: string;
372
+ chainId: number;
373
+ action: import("../database/api/.generated").$Enums.OpportunityAction;
374
+ depositUrl: string | null;
375
+ mainProtocolId: string | null;
376
+ tvl: number;
377
+ apr: number;
378
+ dailyRewards: number;
379
+ };
365
380
  type: string;
366
381
  id: string;
367
382
  subType: number | null;
@@ -566,6 +581,7 @@ declare const app: Elysia<"", false, {
566
581
  params: {};
567
582
  query: {
568
583
  type?: string | undefined;
584
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
569
585
  items?: number | undefined;
570
586
  subType?: number | undefined;
571
587
  page?: number | undefined;
@@ -573,6 +589,7 @@ declare const app: Elysia<"", false, {
573
589
  startTimestamp?: string | undefined;
574
590
  endTimestamp?: string | undefined;
575
591
  tokenAddress?: string | undefined;
592
+ types?: string[] | undefined;
576
593
  campaignId?: string | undefined;
577
594
  opportunityId?: string | undefined;
578
595
  creatorAddress?: string | undefined;
@@ -580,7 +597,9 @@ declare const app: Elysia<"", false, {
580
597
  mainParameter?: string | undefined;
581
598
  test?: boolean | undefined;
582
599
  creatorTag?: string | undefined;
600
+ distributionChainIds?: number[] | undefined;
583
601
  tokenSymbol?: string | undefined;
602
+ withOpportunity?: boolean | undefined;
584
603
  };
585
604
  headers: unknown;
586
605
  response: {
@@ -1208,6 +1227,7 @@ declare const app: Elysia<"", false, {
1208
1227
  params: {};
1209
1228
  query: {
1210
1229
  type?: string | undefined;
1230
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1211
1231
  items?: number | undefined;
1212
1232
  subType?: number | undefined;
1213
1233
  page?: number | undefined;
@@ -1215,6 +1235,7 @@ declare const app: Elysia<"", false, {
1215
1235
  startTimestamp?: string | undefined;
1216
1236
  endTimestamp?: string | undefined;
1217
1237
  tokenAddress?: string | undefined;
1238
+ types?: string[] | undefined;
1218
1239
  campaignId?: string | undefined;
1219
1240
  opportunityId?: string | undefined;
1220
1241
  creatorAddress?: string | undefined;
@@ -1222,7 +1243,9 @@ declare const app: Elysia<"", false, {
1222
1243
  mainParameter?: string | undefined;
1223
1244
  test?: boolean | undefined;
1224
1245
  creatorTag?: string | undefined;
1246
+ distributionChainIds?: number[] | undefined;
1225
1247
  tokenSymbol?: string | undefined;
1248
+ withOpportunity?: boolean | undefined;
1226
1249
  };
1227
1250
  headers: unknown;
1228
1251
  response: {
@@ -1267,6 +1290,21 @@ declare const app: Elysia<"", false, {
1267
1290
  address: string;
1268
1291
  creatorId: string | null;
1269
1292
  };
1293
+ Opportunity: {
1294
+ name: string;
1295
+ type: string;
1296
+ id: string;
1297
+ status: import("../database/api/.generated").$Enums.Status;
1298
+ tags: string[];
1299
+ identifier: string;
1300
+ chainId: number;
1301
+ action: import("../database/api/.generated").$Enums.OpportunityAction;
1302
+ depositUrl: string | null;
1303
+ mainProtocolId: string | null;
1304
+ tvl: number;
1305
+ apr: number;
1306
+ dailyRewards: number;
1307
+ };
1270
1308
  type: string;
1271
1309
  id: string;
1272
1310
  subType: number | null;
@@ -1332,6 +1370,21 @@ declare const app: Elysia<"", false, {
1332
1370
  address: string;
1333
1371
  creatorId: string | null;
1334
1372
  };
1373
+ Opportunity: {
1374
+ name: string;
1375
+ type: string;
1376
+ id: string;
1377
+ status: import("../database/api/.generated").$Enums.Status;
1378
+ tags: string[];
1379
+ identifier: string;
1380
+ chainId: number;
1381
+ action: import("../database/api/.generated").$Enums.OpportunityAction;
1382
+ depositUrl: string | null;
1383
+ mainProtocolId: string | null;
1384
+ tvl: number;
1385
+ apr: number;
1386
+ dailyRewards: number;
1387
+ };
1335
1388
  type: string;
1336
1389
  id: string;
1337
1390
  subType: number | null;
@@ -1353,6 +1406,7 @@ declare const app: Elysia<"", false, {
1353
1406
  params: {};
1354
1407
  query: {
1355
1408
  type?: string | undefined;
1409
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1356
1410
  items?: number | undefined;
1357
1411
  subType?: number | undefined;
1358
1412
  page?: number | undefined;
@@ -1360,6 +1414,7 @@ declare const app: Elysia<"", false, {
1360
1414
  startTimestamp?: string | undefined;
1361
1415
  endTimestamp?: string | undefined;
1362
1416
  tokenAddress?: string | undefined;
1417
+ types?: string[] | undefined;
1363
1418
  campaignId?: string | undefined;
1364
1419
  opportunityId?: string | undefined;
1365
1420
  creatorAddress?: string | undefined;
@@ -1367,7 +1422,9 @@ declare const app: Elysia<"", false, {
1367
1422
  mainParameter?: string | undefined;
1368
1423
  test?: boolean | undefined;
1369
1424
  creatorTag?: string | undefined;
1425
+ distributionChainIds?: number[] | undefined;
1370
1426
  tokenSymbol?: string | undefined;
1427
+ withOpportunity?: boolean | undefined;
1371
1428
  };
1372
1429
  headers: unknown;
1373
1430
  response: {
@@ -3615,7 +3672,7 @@ declare const app: Elysia<"", false, {
3615
3672
  headers: unknown;
3616
3673
  response: {
3617
3674
  200: (import("./modules/v4/claims").ClaimModel & {
3618
- token?: Token;
3675
+ token?: import("./modules/v4/token/token.model").Token["model"];
3619
3676
  })[];
3620
3677
  };
3621
3678
  };
@@ -63,6 +63,8 @@ const extract = async () => {
63
63
  };
64
64
  // ─── Transform & Load ────────────────────────────────────────────────────────
65
65
  const load = async (pendings) => {
66
+ if (pendings.length === 0)
67
+ return { updated: 0, created: 0 };
66
68
  log.info(`pushing ${pendings.length} pendings for token ${pendings[0].rewardToken} on ${NETWORK_LABELS[chainId]}`);
67
69
  const { updated, created } = await updatePendings({
68
70
  distributionChainId: chainId,
@@ -168,6 +168,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
168
168
  params: {};
169
169
  query: {
170
170
  type?: string | undefined;
171
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
171
172
  items?: number | undefined;
172
173
  subType?: number | undefined;
173
174
  page?: number | undefined;
@@ -175,6 +176,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
175
176
  startTimestamp?: string | undefined;
176
177
  endTimestamp?: string | undefined;
177
178
  tokenAddress?: string | undefined;
179
+ types?: string[] | undefined;
178
180
  campaignId?: string | undefined;
179
181
  opportunityId?: string | undefined;
180
182
  creatorAddress?: string | undefined;
@@ -182,7 +184,9 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
182
184
  mainParameter?: string | undefined;
183
185
  test?: boolean | undefined;
184
186
  creatorTag?: string | undefined;
187
+ distributionChainIds?: number[] | undefined;
185
188
  tokenSymbol?: string | undefined;
189
+ withOpportunity?: boolean | undefined;
186
190
  };
187
191
  headers: unknown;
188
192
  response: {
@@ -227,6 +231,21 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
227
231
  address: string;
228
232
  creatorId: string | null;
229
233
  };
234
+ Opportunity: {
235
+ name: string;
236
+ type: string;
237
+ id: string;
238
+ status: import("../../../../database/api/.generated").$Enums.Status;
239
+ tags: string[];
240
+ identifier: string;
241
+ chainId: number;
242
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
243
+ depositUrl: string | null;
244
+ mainProtocolId: string | null;
245
+ tvl: number;
246
+ apr: number;
247
+ dailyRewards: number;
248
+ };
230
249
  type: string;
231
250
  id: string;
232
251
  subType: number | null;
@@ -292,6 +311,21 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
292
311
  address: string;
293
312
  creatorId: string | null;
294
313
  };
314
+ Opportunity: {
315
+ name: string;
316
+ type: string;
317
+ id: string;
318
+ status: import("../../../../database/api/.generated").$Enums.Status;
319
+ tags: string[];
320
+ identifier: string;
321
+ chainId: number;
322
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
323
+ depositUrl: string | null;
324
+ mainProtocolId: string | null;
325
+ tvl: number;
326
+ apr: number;
327
+ dailyRewards: number;
328
+ };
295
329
  type: string;
296
330
  id: string;
297
331
  subType: number | null;
@@ -313,6 +347,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
313
347
  params: {};
314
348
  query: {
315
349
  type?: string | undefined;
350
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
316
351
  items?: number | undefined;
317
352
  subType?: number | undefined;
318
353
  page?: number | undefined;
@@ -320,6 +355,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
320
355
  startTimestamp?: string | undefined;
321
356
  endTimestamp?: string | undefined;
322
357
  tokenAddress?: string | undefined;
358
+ types?: string[] | undefined;
323
359
  campaignId?: string | undefined;
324
360
  opportunityId?: string | undefined;
325
361
  creatorAddress?: string | undefined;
@@ -327,7 +363,9 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
327
363
  mainParameter?: string | undefined;
328
364
  test?: boolean | undefined;
329
365
  creatorTag?: string | undefined;
366
+ distributionChainIds?: number[] | undefined;
330
367
  tokenSymbol?: string | undefined;
368
+ withOpportunity?: boolean | undefined;
331
369
  };
332
370
  headers: unknown;
333
371
  response: {
@@ -2,7 +2,7 @@ import type { Resource } from "../prisma";
2
2
  import { type Token } from "../token/token.model";
3
3
  import type { Campaign as CampaignEnum, CampaignParameters } from "@sdk";
4
4
  import { type Chain } from "../chain/chain.model";
5
- import { type Status } from "../status/status.model";
5
+ import { type Status as StatusModel } from "../status/status.model";
6
6
  /**
7
7
  * Campaign
8
8
  * @description Target description of rewards campaigns
@@ -12,7 +12,7 @@ export type Campaign = Resource<"Campaign", "opportunityId" | "rewardTokenId", {
12
12
  chain: Chain["model"];
13
13
  rewardToken: Token["model"];
14
14
  distributionChain?: Chain["model"];
15
- campaignStatus?: Status["model"];
15
+ campaignStatus?: StatusModel["model"];
16
16
  creator?: {
17
17
  address: string;
18
18
  tags?: string[];
@@ -122,7 +122,9 @@ export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
122
122
  creatorAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
123
123
  creatorId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
124
124
  chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
125
+ distributionChainIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>>;
125
126
  type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
127
+ types: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
126
128
  subType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
127
129
  campaignId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
128
130
  mainParameter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -130,8 +132,15 @@ export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
130
132
  tokenAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
131
133
  test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
132
134
  opportunityId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
135
+ status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
136
+ NONE: "NONE";
137
+ PAST: "PAST";
138
+ LIVE: "LIVE";
139
+ SOON: "SOON";
140
+ }>>;
133
141
  startTimestamp: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
134
142
  endTimestamp: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
143
+ withOpportunity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
135
144
  page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
136
145
  items: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
137
146
  }>;
@@ -1,5 +1,5 @@
1
1
  import { TokenResourceDto } from "../token/token.model";
2
- import { CampaignManualOverride } from "../../../../database/api/.generated";
2
+ import { CampaignManualOverride, Status } from "../../../../database/api/.generated";
3
3
  import { t } from "elysia";
4
4
  import { ChainResourceDto } from "../chain/chain.model";
5
5
  import { CampaignStatusResourceDto } from "../status/status.model";
@@ -73,9 +73,13 @@ export const GetCampaignQueryDto = t.Object({
73
73
  creatorAddress: t.Optional(t.String()),
74
74
  creatorId: t.Optional(t.String({ description: "Filter campaigns created by a user who is registered as a merkl creator" })),
75
75
  chainId: t.Optional(t.Numeric({
76
- description: "Filter by chain.<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
76
+ description: "Filter by compute chain.<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
77
77
  })),
78
+ distributionChainIds: t.Optional(t.Array(t.Numeric({
79
+ description: "Filter by distribution chain.<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
80
+ }))),
78
81
  type: t.Optional(t.String({ description: "Filter by type of campaign" })),
82
+ types: t.Optional(t.Array(t.String({ description: "Filter by type of campaign using an array. The `type` entry has priority." }))),
79
83
  subType: t.Optional(t.Number({
80
84
  description: "Silo, Radiant, Morpho, Dolomite, Compound, Ajna and Euler campaigns have a subtype attribute you can filter on",
81
85
  })),
@@ -93,8 +97,14 @@ export const GetCampaignQueryDto = t.Object({
93
97
  opportunityId: t.Optional(t.String({
94
98
  description: "Filter by opportunity. You can find opportunity ids by calling [GET /v4/opportunities](#tag/opportunities/GET/v4/opportunities)",
95
99
  })),
100
+ status: t.Optional(t.Enum(Status, {
101
+ description: "Get only live, past or future campaigns. Has precendence over timestamp filters",
102
+ })),
96
103
  startTimestamp: t.Optional(t.String({ pattern: "[0-9]*", description: "Returns campaigns starting *after* the given unix timestamp" })),
97
104
  endTimestamp: t.Optional(t.String({ pattern: "[0-9]*", description: "Returns campaigns ending *after* the given unix timestamp" })),
105
+ withOpportunity: t.Optional(t.Boolean({
106
+ description: "Include opportunity data. Will slow down the request. Default: false",
107
+ })),
98
108
  page: t.Optional(t.Numeric({ description: "0-indexed page number", default: 0 })),
99
109
  items: t.Optional(t.Numeric({ description: "Number of items returned by page", default: 20 })), // items per page
100
110
  });
@@ -4,20 +4,228 @@ import { type ChainId } from "@sdk";
4
4
  export declare abstract class CampaignRepository {
5
5
  static transformQueryToPrismaFilters(query: GetCampaignQueryModel): {
6
6
  where: {
7
- computeChainId: number | undefined;
8
7
  endTimestamp: {
9
8
  gte: number;
9
+ lt?: undefined;
10
+ };
11
+ startTimestamp: {
12
+ lte: number;
13
+ gt?: undefined;
14
+ gte?: undefined;
15
+ };
16
+ distributionChainId: {
17
+ in: number[];
10
18
  } | undefined;
19
+ computeChainId: number | undefined;
11
20
  opportunityId: string | undefined;
12
21
  campaignId: string | undefined;
13
22
  Opportunity: {
14
23
  identifier: string | undefined;
15
24
  };
25
+ subType: number | undefined;
26
+ type: string | {
27
+ in: string[];
28
+ } | undefined;
29
+ creatorAddress: string | undefined;
30
+ RewardToken: {
31
+ address: string | undefined;
32
+ symbol: string | undefined;
33
+ OR: ({
34
+ symbol: {
35
+ equals: string;
36
+ mode: "insensitive";
37
+ };
38
+ displaySymbol?: undefined;
39
+ } | {
40
+ displaySymbol: {
41
+ equals: string;
42
+ mode: "insensitive";
43
+ };
44
+ symbol?: undefined;
45
+ })[] | undefined;
46
+ isTest: false | undefined;
47
+ };
48
+ Creator: {
49
+ OR: ({
50
+ Creator: {
51
+ id: string;
52
+ };
53
+ tags?: undefined;
54
+ } | {
55
+ tags: {
56
+ has: string;
57
+ };
58
+ Creator?: undefined;
59
+ })[];
60
+ Creator?: undefined;
61
+ tags?: undefined;
62
+ } | {
63
+ Creator: {
64
+ id: string;
65
+ };
66
+ OR?: undefined;
67
+ tags?: undefined;
68
+ } | {
69
+ tags: {
70
+ has: string;
71
+ };
72
+ OR?: undefined;
73
+ Creator?: undefined;
74
+ } | undefined;
75
+ } | {
76
+ endTimestamp: {
77
+ lt: number;
78
+ gte?: undefined;
79
+ };
80
+ startTimestamp?: undefined;
81
+ distributionChainId: {
82
+ in: number[];
83
+ } | undefined;
84
+ computeChainId: number | undefined;
85
+ opportunityId: string | undefined;
86
+ campaignId: string | undefined;
87
+ Opportunity: {
88
+ identifier: string | undefined;
89
+ };
90
+ subType: number | undefined;
91
+ type: string | {
92
+ in: string[];
93
+ } | undefined;
94
+ creatorAddress: string | undefined;
95
+ RewardToken: {
96
+ address: string | undefined;
97
+ symbol: string | undefined;
98
+ OR: ({
99
+ symbol: {
100
+ equals: string;
101
+ mode: "insensitive";
102
+ };
103
+ displaySymbol?: undefined;
104
+ } | {
105
+ displaySymbol: {
106
+ equals: string;
107
+ mode: "insensitive";
108
+ };
109
+ symbol?: undefined;
110
+ })[] | undefined;
111
+ isTest: false | undefined;
112
+ };
113
+ Creator: {
114
+ OR: ({
115
+ Creator: {
116
+ id: string;
117
+ };
118
+ tags?: undefined;
119
+ } | {
120
+ tags: {
121
+ has: string;
122
+ };
123
+ Creator?: undefined;
124
+ })[];
125
+ Creator?: undefined;
126
+ tags?: undefined;
127
+ } | {
128
+ Creator: {
129
+ id: string;
130
+ };
131
+ OR?: undefined;
132
+ tags?: undefined;
133
+ } | {
134
+ tags: {
135
+ has: string;
136
+ };
137
+ OR?: undefined;
138
+ Creator?: undefined;
139
+ } | undefined;
140
+ } | {
141
+ startTimestamp: {
142
+ gt: number;
143
+ lte?: undefined;
144
+ gte?: undefined;
145
+ };
146
+ endTimestamp?: undefined;
147
+ distributionChainId: {
148
+ in: number[];
149
+ } | undefined;
150
+ computeChainId: number | undefined;
151
+ opportunityId: string | undefined;
152
+ campaignId: string | undefined;
153
+ Opportunity: {
154
+ identifier: string | undefined;
155
+ };
156
+ subType: number | undefined;
157
+ type: string | {
158
+ in: string[];
159
+ } | undefined;
160
+ creatorAddress: string | undefined;
161
+ RewardToken: {
162
+ address: string | undefined;
163
+ symbol: string | undefined;
164
+ OR: ({
165
+ symbol: {
166
+ equals: string;
167
+ mode: "insensitive";
168
+ };
169
+ displaySymbol?: undefined;
170
+ } | {
171
+ displaySymbol: {
172
+ equals: string;
173
+ mode: "insensitive";
174
+ };
175
+ symbol?: undefined;
176
+ })[] | undefined;
177
+ isTest: false | undefined;
178
+ };
179
+ Creator: {
180
+ OR: ({
181
+ Creator: {
182
+ id: string;
183
+ };
184
+ tags?: undefined;
185
+ } | {
186
+ tags: {
187
+ has: string;
188
+ };
189
+ Creator?: undefined;
190
+ })[];
191
+ Creator?: undefined;
192
+ tags?: undefined;
193
+ } | {
194
+ Creator: {
195
+ id: string;
196
+ };
197
+ OR?: undefined;
198
+ tags?: undefined;
199
+ } | {
200
+ tags: {
201
+ has: string;
202
+ };
203
+ OR?: undefined;
204
+ Creator?: undefined;
205
+ } | undefined;
206
+ } | {
207
+ endTimestamp: {
208
+ gte: number;
209
+ lt?: undefined;
210
+ } | undefined;
16
211
  startTimestamp: {
17
212
  gte: number;
213
+ lte?: undefined;
214
+ gt?: undefined;
215
+ } | undefined;
216
+ distributionChainId: {
217
+ in: number[];
18
218
  } | undefined;
219
+ computeChainId: number | undefined;
220
+ opportunityId: string | undefined;
221
+ campaignId: string | undefined;
222
+ Opportunity: {
223
+ identifier: string | undefined;
224
+ };
19
225
  subType: number | undefined;
20
- type: string | undefined;
226
+ type: string | {
227
+ in: string[];
228
+ } | undefined;
21
229
  creatorAddress: string | undefined;
22
230
  RewardToken: {
23
231
  address: string | undefined;
@@ -413,6 +621,21 @@ export declare abstract class CampaignRepository {
413
621
  isTest: boolean;
414
622
  price: number | null;
415
623
  };
624
+ Opportunity: {
625
+ name: string;
626
+ type: string;
627
+ id: string;
628
+ status: import("../../../../database/api/.generated").$Enums.Status;
629
+ tags: string[];
630
+ identifier: string;
631
+ chainId: number;
632
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
633
+ depositUrl: string | null;
634
+ mainProtocolId: string | null;
635
+ tvl: number;
636
+ apr: number;
637
+ dailyRewards: number;
638
+ };
416
639
  Creator: {
417
640
  tags: string[];
418
641
  address: string;
@@ -8,7 +8,7 @@ import moment from "moment";
8
8
  import { OpportunityService } from "../opportunity";
9
9
  export class CampaignRepository {
10
10
  static transformQueryToPrismaFilters(query) {
11
- const { creatorTag, creatorId, creatorAddress, chainId, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, subType, type, tokenAddress, tokenSymbol, test, } = query;
11
+ const { creatorTag, creatorId, creatorAddress, chainId, distributionChainIds, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, status, subType, type, types, tokenAddress, tokenSymbol, test, } = query;
12
12
  const getTagFilter = () => {
13
13
  if (creatorTag && creatorId)
14
14
  return {
@@ -19,18 +19,39 @@ export class CampaignRepository {
19
19
  if (creatorTag)
20
20
  return { tags: { has: creatorTag } };
21
21
  };
22
+ const now = moment().unix();
23
+ const timeFilter = status === "LIVE"
24
+ ? {
25
+ endTimestamp: { gte: now },
26
+ startTimestamp: { lte: now },
27
+ }
28
+ : status === "PAST"
29
+ ? {
30
+ endTimestamp: { lt: now },
31
+ }
32
+ : status === "SOON"
33
+ ? {
34
+ startTimestamp: { gt: now },
35
+ }
36
+ : {
37
+ endTimestamp: endTimestamp ? { gte: +endTimestamp } : undefined,
38
+ startTimestamp: startTimestamp ? { gte: +startTimestamp } : undefined,
39
+ };
22
40
  return {
23
41
  where: {
42
+ distributionChainId: !!distributionChainIds
43
+ ? {
44
+ in: distributionChainIds,
45
+ }
46
+ : undefined,
24
47
  computeChainId: chainId,
25
- endTimestamp: endTimestamp ? { gte: +endTimestamp } : undefined,
26
48
  opportunityId,
27
49
  campaignId,
28
50
  Opportunity: {
29
51
  identifier: mainParameter,
30
52
  },
31
- startTimestamp: startTimestamp ? { gte: +startTimestamp } : undefined,
32
53
  subType,
33
- type,
54
+ type: type ? type : types ? { in: types } : undefined,
34
55
  creatorAddress,
35
56
  RewardToken: {
36
57
  address: tokenAddress ? tokenAddress : undefined,
@@ -44,6 +65,7 @@ export class CampaignRepository {
44
65
  isTest: !test ? false : undefined,
45
66
  },
46
67
  Creator: getTagFilter(),
68
+ ...timeFilter,
47
69
  },
48
70
  };
49
71
  }
@@ -343,6 +365,7 @@ export class CampaignRepository {
343
365
  RewardToken: true,
344
366
  CampaignStatus: true,
345
367
  Creator: true,
368
+ Opportunity: query.withOpportunity,
346
369
  },
347
370
  orderBy: {
348
371
  endTimestamp: "desc",