Files
twenty/packages/twenty-front/src/modules/apollo/utils/encodeCursor.ts
T
Félix Malfait 464a480043 Continue ESLINT9 Migration (#13795)
Might already fix #13793
2025-08-10 23:25:58 +02:00

21 lines
520 B
TypeScript

import { type ObjectRecord } from '@/object-record/types/ObjectRecord';
import { Buffer } from 'buffer';
import { isDefined } from 'twenty-shared/utils';
export const encodeCursor = (record: ObjectRecord) => {
if (!('id' in record) || !isDefined(record.id)) {
throw new Error('Record does not have an id');
}
const payload: {
id: string;
position?: number;
} = {
position: record.position,
id: record.id,
};
return Buffer.from(JSON.stringify(payload), 'utf-8').toString('base64');
};