mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 19:08:33 +01:00
Move provider operations into channel folders and shared chat work into named interaction, setup, admission, delivery and publication workflows. Consolidate reviewed PRs #16085, #16089, #16096 and #16105. Preserve upstream execution-default and recovery behavior. The main service is 7,917 lines. All 55 current-head CI checks pass, with two optional Storybook skips. Greptile is 5/5 with no findings. All 1,294 current chat integration cases, repository-wide typecheck and build pass locally. Broad local tool-route timing/socket failures are recorded in the PR. Co-Authored-By: Paperclip <noreply@paperclip.ing>
37 lines
796 B
TypeScript
37 lines
796 B
TypeScript
import {
|
|
and,
|
|
eq,
|
|
lt,
|
|
or,
|
|
sql,
|
|
} from "drizzle-orm";
|
|
import { type AnyPgColumn } from "drizzle-orm/pg-core";
|
|
|
|
type PublicationOrderTable = {
|
|
createdAt: AnyPgColumn;
|
|
id: AnyPgColumn;
|
|
payload: AnyPgColumn;
|
|
};
|
|
|
|
function publicationTransportOrderKey(table: PublicationOrderTable) {
|
|
return sql<string>`coalesce(${table.payload}->'transportPart'->>'orderKey', ${table.id}::text)`;
|
|
}
|
|
|
|
function publicationPrecedes(
|
|
earlier: PublicationOrderTable,
|
|
later: PublicationOrderTable,
|
|
) {
|
|
return or(
|
|
lt(earlier.createdAt, later.createdAt),
|
|
and(
|
|
eq(earlier.createdAt, later.createdAt),
|
|
lt(
|
|
publicationTransportOrderKey(earlier),
|
|
publicationTransportOrderKey(later),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
export { publicationTransportOrderKey, publicationPrecedes };
|