import { rawRows, rawTable, type ReadContext, type TimestampRange, type TimestampWindowState } from '@chkit/plugin-sync' import { createLinearClient } from '../client.js' import type { LinearConfig } from '../config.js' import { linearId } from './common.js' const query = `query Users($after: String, $from: DateTimeOrDuration!, $to: DateTimeOrDuration!) { users(first: 100, after: $after, includeArchived: true, includeDisabled: true, orderBy: updatedAt, filter: { updatedAt: { gte: $from, lte: $to } }) { nodes { id name displayName email description title avatarUrl url timezone active admin owner guest app disableReason createdAt updatedAt archivedAt organization { id } } pageInfo { hasNextPage endCursor } } }` export const linear_usersRaw = rawTable({ database: 'default', name: 'linear_users_raw' }) export async function* readUsers(context: ReadContext, config: LinearConfig) { const client = createLinearClient(context, config) for await (const page of client.connection({ query, path: ['users'], label: 'users', window: context.selection, variables: { from: context.selection.from.toISOString(), to: context.selection.to.toISOString() }, })) yield { rows: rawRows(page.items, linearId) } }