@crosspost/sdk 0.2.5 → 0.2.6
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/index.cjs +26 -3
- package/dist/index.js +26 -3
- package/package.json +1 -1
- package/src/api/activity.ts +44 -6
package/dist/index.cjs
CHANGED
@@ -372,6 +372,29 @@ async function makeRequest(method, path, options, data, query) {
|
|
372
372
|
}
|
373
373
|
|
374
374
|
// src/api/activity.ts
|
375
|
+
function createFilterQuery(query) {
|
376
|
+
if (!query) return {};
|
377
|
+
const queryObj = query;
|
378
|
+
const result = {};
|
379
|
+
Object.keys(queryObj).forEach((key) => {
|
380
|
+
if (key !== "filter") {
|
381
|
+
result[key] = queryObj[key];
|
382
|
+
}
|
383
|
+
});
|
384
|
+
if (queryObj.filter) {
|
385
|
+
const filter = queryObj.filter;
|
386
|
+
if (filter.platforms && Array.isArray(filter.platforms)) {
|
387
|
+
result.platforms = filter.platforms.join(",");
|
388
|
+
}
|
389
|
+
if (filter.types && Array.isArray(filter.types)) {
|
390
|
+
result.types = filter.types.join(",");
|
391
|
+
}
|
392
|
+
if (filter.timeframe) {
|
393
|
+
result.timeframe = filter.timeframe;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
return result;
|
397
|
+
}
|
375
398
|
var ActivityApi = class {
|
376
399
|
/**
|
377
400
|
* Creates an instance of ActivityApi
|
@@ -391,7 +414,7 @@ var ActivityApi = class {
|
|
391
414
|
"/api/activity",
|
392
415
|
this.options,
|
393
416
|
void 0,
|
394
|
-
query
|
417
|
+
createFilterQuery(query)
|
395
418
|
);
|
396
419
|
}
|
397
420
|
/**
|
@@ -406,7 +429,7 @@ var ActivityApi = class {
|
|
406
429
|
`/api/activity/${signerId}`,
|
407
430
|
this.options,
|
408
431
|
void 0,
|
409
|
-
query
|
432
|
+
createFilterQuery(query)
|
410
433
|
);
|
411
434
|
}
|
412
435
|
/**
|
@@ -421,7 +444,7 @@ var ActivityApi = class {
|
|
421
444
|
`/api/activity/${signerId}/posts`,
|
422
445
|
this.options,
|
423
446
|
void 0,
|
424
|
-
query
|
447
|
+
createFilterQuery(query)
|
425
448
|
);
|
426
449
|
}
|
427
450
|
};
|
package/dist/index.js
CHANGED
@@ -326,6 +326,29 @@ async function makeRequest(method, path, options, data, query) {
|
|
326
326
|
}
|
327
327
|
|
328
328
|
// src/api/activity.ts
|
329
|
+
function createFilterQuery(query) {
|
330
|
+
if (!query) return {};
|
331
|
+
const queryObj = query;
|
332
|
+
const result = {};
|
333
|
+
Object.keys(queryObj).forEach((key) => {
|
334
|
+
if (key !== "filter") {
|
335
|
+
result[key] = queryObj[key];
|
336
|
+
}
|
337
|
+
});
|
338
|
+
if (queryObj.filter) {
|
339
|
+
const filter = queryObj.filter;
|
340
|
+
if (filter.platforms && Array.isArray(filter.platforms)) {
|
341
|
+
result.platforms = filter.platforms.join(",");
|
342
|
+
}
|
343
|
+
if (filter.types && Array.isArray(filter.types)) {
|
344
|
+
result.types = filter.types.join(",");
|
345
|
+
}
|
346
|
+
if (filter.timeframe) {
|
347
|
+
result.timeframe = filter.timeframe;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
return result;
|
351
|
+
}
|
329
352
|
var ActivityApi = class {
|
330
353
|
/**
|
331
354
|
* Creates an instance of ActivityApi
|
@@ -345,7 +368,7 @@ var ActivityApi = class {
|
|
345
368
|
"/api/activity",
|
346
369
|
this.options,
|
347
370
|
void 0,
|
348
|
-
query
|
371
|
+
createFilterQuery(query)
|
349
372
|
);
|
350
373
|
}
|
351
374
|
/**
|
@@ -360,7 +383,7 @@ var ActivityApi = class {
|
|
360
383
|
`/api/activity/${signerId}`,
|
361
384
|
this.options,
|
362
385
|
void 0,
|
363
|
-
query
|
386
|
+
createFilterQuery(query)
|
364
387
|
);
|
365
388
|
}
|
366
389
|
/**
|
@@ -375,7 +398,7 @@ var ActivityApi = class {
|
|
375
398
|
`/api/activity/${signerId}/posts`,
|
376
399
|
this.options,
|
377
400
|
void 0,
|
378
|
-
query
|
401
|
+
createFilterQuery(query)
|
379
402
|
);
|
380
403
|
}
|
381
404
|
};
|
package/package.json
CHANGED
package/src/api/activity.ts
CHANGED
@@ -9,6 +9,44 @@ import type {
|
|
9
9
|
} from '@crosspost/types';
|
10
10
|
import { makeRequest, type RequestOptions } from '../core/request.ts';
|
11
11
|
|
12
|
+
/**
|
13
|
+
* Creates a modified query object with filter properties flattened
|
14
|
+
* @param query The original query object
|
15
|
+
* @returns A new query object with filter properties flattened
|
16
|
+
*/
|
17
|
+
function createFilterQuery<T>(query?: T): Record<string, unknown> {
|
18
|
+
if (!query) return {};
|
19
|
+
|
20
|
+
const queryObj = query as Record<string, any>;
|
21
|
+
const result: Record<string, unknown> = {};
|
22
|
+
|
23
|
+
// Copy non-filter properties
|
24
|
+
Object.keys(queryObj).forEach((key) => {
|
25
|
+
if (key !== 'filter') {
|
26
|
+
result[key] = queryObj[key];
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
// Extract and flatten filter properties if they exist
|
31
|
+
if (queryObj.filter) {
|
32
|
+
const filter = queryObj.filter;
|
33
|
+
|
34
|
+
if (filter.platforms && Array.isArray(filter.platforms)) {
|
35
|
+
result.platforms = filter.platforms.join(',');
|
36
|
+
}
|
37
|
+
|
38
|
+
if (filter.types && Array.isArray(filter.types)) {
|
39
|
+
result.types = filter.types.join(',');
|
40
|
+
}
|
41
|
+
|
42
|
+
if (filter.timeframe) {
|
43
|
+
result.timeframe = filter.timeframe;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
return result;
|
48
|
+
}
|
49
|
+
|
12
50
|
/**
|
13
51
|
* Activity-related API operations
|
14
52
|
*/
|
@@ -31,12 +69,12 @@ export class ActivityApi {
|
|
31
69
|
async getLeaderboard(
|
32
70
|
query?: ActivityLeaderboardQuery,
|
33
71
|
): Promise<ApiResponse<ActivityLeaderboardResponse>> {
|
34
|
-
return makeRequest<ActivityLeaderboardResponse, never,
|
72
|
+
return makeRequest<ActivityLeaderboardResponse, never, Record<string, unknown>>(
|
35
73
|
'GET',
|
36
74
|
'/api/activity',
|
37
75
|
this.options,
|
38
76
|
undefined,
|
39
|
-
query,
|
77
|
+
createFilterQuery(query),
|
40
78
|
);
|
41
79
|
}
|
42
80
|
|
@@ -50,12 +88,12 @@ export class ActivityApi {
|
|
50
88
|
signerId: string,
|
51
89
|
query?: AccountActivityQuery,
|
52
90
|
): Promise<ApiResponse<AccountActivityResponse>> {
|
53
|
-
return makeRequest<AccountActivityResponse, never,
|
91
|
+
return makeRequest<AccountActivityResponse, never, Record<string, unknown>>(
|
54
92
|
'GET',
|
55
93
|
`/api/activity/${signerId}`,
|
56
94
|
this.options,
|
57
95
|
undefined,
|
58
|
-
query,
|
96
|
+
createFilterQuery(query),
|
59
97
|
);
|
60
98
|
}
|
61
99
|
|
@@ -69,12 +107,12 @@ export class ActivityApi {
|
|
69
107
|
signerId: string,
|
70
108
|
query?: AccountPostsQuery,
|
71
109
|
): Promise<ApiResponse<AccountPostsResponse>> {
|
72
|
-
return makeRequest<AccountPostsResponse, never,
|
110
|
+
return makeRequest<AccountPostsResponse, never, Record<string, unknown>>(
|
73
111
|
'GET',
|
74
112
|
`/api/activity/${signerId}/posts`,
|
75
113
|
this.options,
|
76
114
|
undefined,
|
77
|
-
query,
|
115
|
+
createFilterQuery(query),
|
78
116
|
);
|
79
117
|
}
|
80
118
|
}
|