Files
Francesco Di Lorenzo e7a05b9049 Update Typefully skill for recent API v2 features (#19)
## Summary
- add `analytics:followers:get` for X follower counts with optional date
filters
- support X content disclosure flags on draft create/update
- document publishing quota awareness via `social-sets:get` and refresh
the skill changelog/date

## Validation
- `node --check skills/typefully/scripts/typefully.js`
- `./skills/typefully/scripts/typefully.js --help`
- `npm test -- tests/analytics.test.js tests/drafts.test.js
tests/social-sets.test.js`
- `npm test -- tests/*.test.js`
2026-04-24 14:26:42 +01:00

71 lines
2.1 KiB
JavaScript

const {
describe,
it,
assert,
withCliHarness,
authAssertFactory,
expectCliOk,
expectCliError,
} = require('./typefully-cli.test-helpers');
function queryParams(req) {
return new URL(`http://x${req.path}${req.search}`).searchParams;
}
describe('analytics:followers:get', () => {
it('fetches X follower analytics with optional date range', withCliHarness(async ({ server, apiKey, run }) => {
server.expect('GET', '/v2/social-sets/9/analytics/x/followers', {
assert: (req) => {
authAssertFactory(apiKey)(req);
const q = queryParams(req);
assert.equal(q.get('start_date'), '2026-03-01');
assert.equal(q.get('end_date'), '2026-03-31');
},
json: {
platform: 'x',
current_followers_count: 1500,
data: [{ date: '2026-03-31', followers_count: 1500 }],
},
});
const result = await run([
'analytics:followers:get',
'9',
'--start-date',
'2026-03-01',
'--end-date',
'2026-03-31',
]);
expectCliOk(result, {
platform: 'x',
current_followers_count: 1500,
data: [{ date: '2026-03-31', followers_count: 1500 }],
});
}));
it('omits date query params when default range is requested', withCliHarness(async ({ server, apiKey, run }) => {
server.expect('GET', '/v2/social-sets/9/analytics/x/followers', {
assert: (req) => {
authAssertFactory(apiKey)(req);
assert.equal(req.search, '');
},
json: { platform: 'x', current_followers_count: null, data: [] },
});
const result = await run(['analytics:followers:get', '9']);
expectCliOk(result, { platform: 'x', current_followers_count: null, data: [] });
}));
it('rejects unsupported analytics platforms before making requests', withCliHarness(async ({ server, run }) => {
const result = await run(['analytics:followers:get', '9', '--platform', 'linkedin']);
expectCliError(result, {
error: 'Only X analytics are currently supported by the Typefully API',
provided_platform: 'linkedin',
hint: 'Use --platform x or omit the flag',
});
assert.equal(server.requests.length, 0);
}));
});