@tokens-studio/sdk
Version:
The official SDK for Tokens Studio
29 lines • 898 B
JavaScript
import { tasks } from '@tokens-studio/cli-kit';
import { error } from '../utils/messages.js';
import { getSets } from '../utils/queries.js';
import { fetchPaginatedData } from '../utils/fetch-paginated-data.js';
export async function fetchSets(client, config) {
let sets = [];
await tasks({
start: 'Fetching token data',
end: 'Done!',
}, [
{
pending: 'tokens',
start: 'Getting tokensets',
end: 'Fetched tokensets',
while: async () => {
sets = await fetchPaginatedData(client, getSets, { ...config });
},
onError(e) {
error(e);
throw e;
},
},
]);
return sets.map(({ name, raw }) => ({
name: `${name}.json`,
contents: JSON.stringify(raw, null, '\t'),
}));
}
//# sourceMappingURL=fetch-sets.js.map