@crosspost/sdk 0.2.8 → 0.2.9
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 +17 -16
- package/dist/index.js +17 -16
- package/package.json +1 -1
- package/src/api/activity.ts +30 -26
package/dist/index.cjs
CHANGED
@@ -371,23 +371,24 @@ async function makeRequest(method, path, options, data, query) {
|
|
371
371
|
// src/api/activity.ts
|
372
372
|
function createFilterQuery(query) {
|
373
373
|
if (!query) return {};
|
374
|
-
const queryObj = query;
|
375
374
|
const result = {};
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
375
|
+
if (query.limit !== void 0) {
|
376
|
+
result.limit = query.limit;
|
377
|
+
}
|
378
|
+
if (query.offset !== void 0) {
|
379
|
+
result.offset = query.offset;
|
380
|
+
}
|
381
|
+
if (query.filter) {
|
382
|
+
const filterParams = query.filter;
|
383
|
+
for (const filterKey in filterParams) {
|
384
|
+
if (Object.prototype.hasOwnProperty.call(filterParams, filterKey) && filterParams[filterKey] !== void 0) {
|
385
|
+
const value = filterParams[filterKey];
|
386
|
+
if (Array.isArray(value)) {
|
387
|
+
result[`filter[${filterKey}]`] = value.join(",");
|
388
|
+
} else {
|
389
|
+
result[`filter[${filterKey}]`] = String(value);
|
390
|
+
}
|
391
|
+
}
|
391
392
|
}
|
392
393
|
}
|
393
394
|
return result;
|
package/dist/index.js
CHANGED
@@ -328,23 +328,24 @@ async function makeRequest(method, path, options, data, query) {
|
|
328
328
|
// src/api/activity.ts
|
329
329
|
function createFilterQuery(query) {
|
330
330
|
if (!query) return {};
|
331
|
-
const queryObj = query;
|
332
331
|
const result = {};
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
332
|
+
if (query.limit !== void 0) {
|
333
|
+
result.limit = query.limit;
|
334
|
+
}
|
335
|
+
if (query.offset !== void 0) {
|
336
|
+
result.offset = query.offset;
|
337
|
+
}
|
338
|
+
if (query.filter) {
|
339
|
+
const filterParams = query.filter;
|
340
|
+
for (const filterKey in filterParams) {
|
341
|
+
if (Object.prototype.hasOwnProperty.call(filterParams, filterKey) && filterParams[filterKey] !== void 0) {
|
342
|
+
const value = filterParams[filterKey];
|
343
|
+
if (Array.isArray(value)) {
|
344
|
+
result[`filter[${filterKey}]`] = value.join(",");
|
345
|
+
} else {
|
346
|
+
result[`filter[${filterKey}]`] = String(value);
|
347
|
+
}
|
348
|
+
}
|
348
349
|
}
|
349
350
|
}
|
350
351
|
return result;
|
package/package.json
CHANGED
package/src/api/activity.ts
CHANGED
@@ -10,40 +10,44 @@ import type {
|
|
10
10
|
import { makeRequest, type RequestOptions } from '../core/request.ts';
|
11
11
|
|
12
12
|
/**
|
13
|
-
* Creates a modified query object with filter properties
|
13
|
+
* Creates a modified query object with filter properties
|
14
14
|
* @param query The original query object
|
15
|
-
* @returns A new query object with filter properties
|
15
|
+
* @returns A new query object with filter properties formatted as filter[key]=value.
|
16
16
|
*/
|
17
|
-
function createFilterQuery<
|
17
|
+
function createFilterQuery<
|
18
|
+
T extends { filter?: Record<string, any>; limit?: number; offset?: number },
|
19
|
+
>(
|
20
|
+
query?: T,
|
21
|
+
): Record<string, string | number | boolean> {
|
18
22
|
if (!query) return {};
|
19
23
|
|
20
|
-
const
|
21
|
-
const result: Record<string, unknown> = {};
|
24
|
+
const result: Record<string, string | number | boolean> = {};
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
}
|
26
|
+
if (query.limit !== undefined) {
|
27
|
+
result.limit = query.limit;
|
28
|
+
}
|
29
|
+
if (query.offset !== undefined) {
|
30
|
+
result.offset = query.offset;
|
31
|
+
}
|
41
32
|
|
42
|
-
|
43
|
-
|
33
|
+
// e.g., query.filter = { timeframe: 'month', platforms: ['twitter'] }
|
34
|
+
// becomes result['filter[timeframe]'] = 'month', result['filter[platforms]'] = 'twitter'
|
35
|
+
if (query.filter) {
|
36
|
+
const filterParams = query.filter;
|
37
|
+
for (const filterKey in filterParams) {
|
38
|
+
if (
|
39
|
+
Object.prototype.hasOwnProperty.call(filterParams, filterKey) &&
|
40
|
+
filterParams[filterKey] !== undefined
|
41
|
+
) {
|
42
|
+
const value = filterParams[filterKey];
|
43
|
+
if (Array.isArray(value)) {
|
44
|
+
result[`filter[${filterKey}]`] = value.join(',');
|
45
|
+
} else {
|
46
|
+
result[`filter[${filterKey}]`] = String(value);
|
47
|
+
}
|
48
|
+
}
|
44
49
|
}
|
45
50
|
}
|
46
|
-
|
47
51
|
return result;
|
48
52
|
}
|
49
53
|
|