@shipfox/api-projects 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +117 -0
- package/LICENSE +21 -0
- package/dist/core/entities/index.d.ts +2 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/project.d.ts +10 -0
- package/dist/core/entities/project.d.ts.map +1 -0
- package/dist/core/entities/project.js +3 -0
- package/dist/core/entities/project.js.map +1 -0
- package/dist/core/errors.d.ts +13 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +20 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/projects.d.ts +12 -0
- package/dist/core/projects.d.ts.map +1 -0
- package/dist/core/projects.js +62 -0
- package/dist/core/projects.js.map +1 -0
- package/dist/db/db.d.ts +763 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +22 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/index.d.ts +8 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/integration-event-dedup.d.ts +17 -0
- package/dist/db/integration-event-dedup.d.ts.map +1 -0
- package/dist/db/integration-event-dedup.js +27 -0
- package/dist/db/integration-event-dedup.js.map +1 -0
- package/dist/db/projects.d.ts +36 -0
- package/dist/db/projects.d.ts.map +1 -0
- package/dist/db/projects.js +84 -0
- package/dist/db/projects.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/integration-event-dedup.d.ts +59 -0
- package/dist/db/schema/integration-event-dedup.d.ts.map +1 -0
- package/dist/db/schema/integration-event-dedup.js +19 -0
- package/dist/db/schema/integration-event-dedup.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/projects.d.ts +131 -0
- package/dist/db/schema/projects.d.ts.map +1 -0
- package/dist/db/schema/projects.js +32 -0
- package/dist/db/schema/projects.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +3 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +4 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +4 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +25 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +15 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/auth/require-project-access.d.ts +12 -0
- package/dist/presentation/auth/require-project-access.d.ts.map +1 -0
- package/dist/presentation/auth/require-project-access.js +25 -0
- package/dist/presentation/auth/require-project-access.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +2 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +3 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/dto/project.d.ts +13 -0
- package/dist/presentation/dto/project.d.ts.map +1 -0
- package/dist/presentation/dto/project.js +15 -0
- package/dist/presentation/dto/project.js.map +1 -0
- package/dist/presentation/e2eRoutes/create-project.d.ts +2 -0
- package/dist/presentation/e2eRoutes/create-project.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/create-project.js +45 -0
- package/dist/presentation/e2eRoutes/create-project.js.map +1 -0
- package/dist/presentation/e2eRoutes/index.d.ts +3 -0
- package/dist/presentation/e2eRoutes/index.d.ts.map +1 -0
- package/dist/presentation/e2eRoutes/index.js +9 -0
- package/dist/presentation/e2eRoutes/index.js.map +1 -0
- package/dist/presentation/index.d.ts +3 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +4 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/create-project.d.ts +3 -0
- package/dist/presentation/routes/create-project.d.ts.map +1 -0
- package/dist/presentation/routes/create-project.js +94 -0
- package/dist/presentation/routes/create-project.js.map +1 -0
- package/dist/presentation/routes/cursor.d.ts +2 -0
- package/dist/presentation/routes/cursor.d.ts.map +1 -0
- package/dist/presentation/routes/cursor.js +3 -0
- package/dist/presentation/routes/cursor.js.map +1 -0
- package/dist/presentation/routes/get-project.d.ts +2 -0
- package/dist/presentation/routes/get-project.d.ts.map +1 -0
- package/dist/presentation/routes/get-project.js +30 -0
- package/dist/presentation/routes/get-project.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +4 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +17 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/list-projects.d.ts +2 -0
- package/dist/presentation/routes/list-projects.d.ts.map +1 -0
- package/dist/presentation/routes/list-projects.js +43 -0
- package/dist/presentation/routes/list-projects.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +2 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +3 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-source-commit-pushed.d.ts +4 -0
- package/dist/presentation/subscribers/on-source-commit-pushed.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-source-commit-pushed.js +54 -0
- package/dist/presentation/subscribers/on-source-commit-pushed.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +5 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +8 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/prune-integration-event-dedup.d.ts +4 -0
- package/dist/temporal/activities/prune-integration-event-dedup.d.ts.map +1 -0
- package/dist/temporal/activities/prune-integration-event-dedup.js +11 -0
- package/dist/temporal/activities/prune-integration-event-dedup.js.map +1 -0
- package/dist/temporal/constants.d.ts +3 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +4 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +2 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +3 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/prune-integration-event-dedup-cron.d.ts +2 -0
- package/dist/temporal/workflows/prune-integration-event-dedup-cron.d.ts.map +1 -0
- package/dist/temporal/workflows/prune-integration-event-dedup-cron.js +14 -0
- package/dist/temporal/workflows/prune-integration-event-dedup-cron.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +37 -0
- package/drizzle/meta/0000_snapshot.json +307 -0
- package/drizzle/meta/_journal.json +13 -0
- package/drizzle.config.ts +7 -0
- package/package.json +76 -0
- package/src/core/entities/index.ts +1 -0
- package/src/core/entities/project.ts +9 -0
- package/src/core/errors.ts +26 -0
- package/src/core/index.ts +8 -0
- package/src/core/projects.test.ts +142 -0
- package/src/core/projects.ts +97 -0
- package/src/db/db.ts +22 -0
- package/src/db/index.ts +26 -0
- package/src/db/integration-event-dedup.ts +45 -0
- package/src/db/projects.test.ts +22 -0
- package/src/db/projects.ts +158 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/integration-event-dedup.ts +15 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/projects.ts +39 -0
- package/src/index.ts +71 -0
- package/src/metrics/index.ts +2 -0
- package/src/metrics/instance.ts +34 -0
- package/src/metrics/service.ts +17 -0
- package/src/presentation/auth/require-project-access.ts +29 -0
- package/src/presentation/dto/index.ts +1 -0
- package/src/presentation/dto/project.ts +15 -0
- package/src/presentation/e2eRoutes/create-project.test.ts +119 -0
- package/src/presentation/e2eRoutes/create-project.ts +50 -0
- package/src/presentation/e2eRoutes/index.ts +7 -0
- package/src/presentation/index.ts +2 -0
- package/src/presentation/routes/create-project.ts +102 -0
- package/src/presentation/routes/cursor.ts +5 -0
- package/src/presentation/routes/get-project.ts +24 -0
- package/src/presentation/routes/index.ts +14 -0
- package/src/presentation/routes/list-projects.ts +34 -0
- package/src/presentation/routes/projects.test.ts +266 -0
- package/src/presentation/subscribers/index.ts +1 -0
- package/src/presentation/subscribers/on-source-commit-pushed.test.ts +149 -0
- package/src/presentation/subscribers/on-source-commit-pushed.ts +64 -0
- package/src/temporal/activities/index.ts +7 -0
- package/src/temporal/activities/prune-integration-event-dedup.test.ts +50 -0
- package/src/temporal/activities/prune-integration-event-dedup.ts +9 -0
- package/src/temporal/constants.ts +3 -0
- package/src/temporal/workflows/index.ts +1 -0
- package/src/temporal/workflows/prune-integration-event-dedup-cron.ts +15 -0
- package/test/env.ts +14 -0
- package/test/factories/project.ts +24 -0
- package/test/globalSetup.ts +17 -0
- package/test/index.ts +1 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/db/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAMnE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIlB,CAAC;AAIF,wBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGjB;AAED,wBAAgB,OAAO,IAAI,IAAI,CAE9B"}
|
package/dist/db/db.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { drizzle } from '@shipfox/node-drizzle';
|
|
2
|
+
import { pgClient } from '@shipfox/node-postgres';
|
|
3
|
+
import { projectsIntegrationEventDedup } from './schema/integration-event-dedup.js';
|
|
4
|
+
import { projectsOutbox } from './schema/outbox.js';
|
|
5
|
+
import { projects } from './schema/projects.js';
|
|
6
|
+
export const schema = {
|
|
7
|
+
projects,
|
|
8
|
+
projectsOutbox,
|
|
9
|
+
projectsIntegrationEventDedup
|
|
10
|
+
};
|
|
11
|
+
let _db;
|
|
12
|
+
export function db() {
|
|
13
|
+
if (!_db) _db = drizzle(pgClient(), {
|
|
14
|
+
schema
|
|
15
|
+
});
|
|
16
|
+
return _db;
|
|
17
|
+
}
|
|
18
|
+
export function closeDb() {
|
|
19
|
+
_db = undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/db/db.ts"],"sourcesContent":["import {drizzle, type NodePgDatabase} from '@shipfox/node-drizzle';\nimport {pgClient} from '@shipfox/node-postgres';\nimport {projectsIntegrationEventDedup} from './schema/integration-event-dedup.js';\nimport {projectsOutbox} from './schema/outbox.js';\nimport {projects} from './schema/projects.js';\n\nexport const schema = {\n projects,\n projectsOutbox,\n projectsIntegrationEventDedup,\n};\n\nlet _db: NodePgDatabase<typeof schema> | undefined;\n\nexport function db() {\n if (!_db) _db = drizzle(pgClient(), {schema});\n return _db;\n}\n\nexport function closeDb(): void {\n _db = undefined;\n}\n"],"names":["drizzle","pgClient","projectsIntegrationEventDedup","projectsOutbox","projects","schema","_db","db","closeDb","undefined"],"mappings":"AAAA,SAAQA,OAAO,QAA4B,wBAAwB;AACnE,SAAQC,QAAQ,QAAO,yBAAyB;AAChD,SAAQC,6BAA6B,QAAO,sCAAsC;AAClF,SAAQC,cAAc,QAAO,qBAAqB;AAClD,SAAQC,QAAQ,QAAO,uBAAuB;AAE9C,OAAO,MAAMC,SAAS;IACpBD;IACAD;IACAD;AACF,EAAE;AAEF,IAAII;AAEJ,OAAO,SAASC;IACd,IAAI,CAACD,KAAKA,MAAMN,QAAQC,YAAY;QAACI;IAAM;IAC3C,OAAOC;AACT;AAEA,OAAO,SAASE;IACdF,MAAMG;AACR"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { closeDb, db, schema } from './db.js';
|
|
2
|
+
export { pruneIntegrationEventDedup, recordIntegrationEventForProject, } from './integration-event-dedup.js';
|
|
3
|
+
export type { CreateProjectParams, GetProjectBySourceParams, ListProjectsParams, ListProjectsResult, } from './projects.js';
|
|
4
|
+
export { createProject, getProjectById, getProjectBySource, getProjectCount, listProjects, requireProjectForWorkspace, } from './projects.js';
|
|
5
|
+
export { projectsIntegrationEventDedup } from './schema/integration-event-dedup.js';
|
|
6
|
+
export { projectsOutbox } from './schema/outbox.js';
|
|
7
|
+
export declare const migrationsPath: string;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,6BAA6B,EAAC,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,cAAc,QAAoE,CAAC"}
|
package/dist/db/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
export { closeDb, db, schema } from './db.js';
|
|
4
|
+
export { pruneIntegrationEventDedup, recordIntegrationEventForProject } from './integration-event-dedup.js';
|
|
5
|
+
export { createProject, getProjectById, getProjectBySource, getProjectCount, listProjects, requireProjectForWorkspace } from './projects.js';
|
|
6
|
+
export { projectsIntegrationEventDedup } from './schema/integration-event-dedup.js';
|
|
7
|
+
export { projectsOutbox } from './schema/outbox.js';
|
|
8
|
+
export const migrationsPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../drizzle');
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/db/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\n\nexport {closeDb, db, schema} from './db.js';\nexport {\n pruneIntegrationEventDedup,\n recordIntegrationEventForProject,\n} from './integration-event-dedup.js';\nexport type {\n CreateProjectParams,\n GetProjectBySourceParams,\n ListProjectsParams,\n ListProjectsResult,\n} from './projects.js';\nexport {\n createProject,\n getProjectById,\n getProjectBySource,\n getProjectCount,\n listProjects,\n requireProjectForWorkspace,\n} from './projects.js';\nexport {projectsIntegrationEventDedup} from './schema/integration-event-dedup.js';\nexport {projectsOutbox} from './schema/outbox.js';\n\nexport const migrationsPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../drizzle');\n"],"names":["dirname","resolve","fileURLToPath","closeDb","db","schema","pruneIntegrationEventDedup","recordIntegrationEventForProject","createProject","getProjectById","getProjectBySource","getProjectCount","listProjects","requireProjectForWorkspace","projectsIntegrationEventDedup","projectsOutbox","migrationsPath","url"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,SAAQC,OAAO,EAAEC,EAAE,EAAEC,MAAM,QAAO,UAAU;AAC5C,SACEC,0BAA0B,EAC1BC,gCAAgC,QAC3B,+BAA+B;AAOtC,SACEC,aAAa,EACbC,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfC,YAAY,EACZC,0BAA0B,QACrB,gBAAgB;AACvB,SAAQC,6BAA6B,QAAO,sCAAsC;AAClF,SAAQC,cAAc,QAAO,qBAAqB;AAElD,OAAO,MAAMC,iBAAiBf,QAAQD,QAAQE,cAAc,YAAYe,GAAG,IAAI,iBAAiB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type DrizzleTxLike = any;
|
|
2
|
+
export interface RecordIntegrationEventForProjectParams {
|
|
3
|
+
tx: DrizzleTxLike;
|
|
4
|
+
integrationEventId: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function recordIntegrationEventForProject(params: RecordIntegrationEventForProjectParams): Promise<{
|
|
8
|
+
firstSeen: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export interface PruneIntegrationEventDedupParams {
|
|
11
|
+
olderThan: Date;
|
|
12
|
+
}
|
|
13
|
+
export declare function pruneIntegrationEventDedup(params: PruneIntegrationEventDedupParams): Promise<{
|
|
14
|
+
deleted: number;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=integration-event-dedup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-event-dedup.d.ts","sourceRoot":"","sources":["../../src/db/integration-event-dedup.ts"],"names":[],"mappings":"AAKA,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,MAAM,WAAW,sCAAsC;IACrD,EAAE,EAAE,aAAa,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,sCAAsC,GAC7C,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAC,CAAC,CAgB/B;AAED,MAAM,WAAW,gCAAgC;IAC/C,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gCAAgC,GACvC,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAK5B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { lt } from 'drizzle-orm';
|
|
2
|
+
import { db } from './db.js';
|
|
3
|
+
import { projectsIntegrationEventDedup } from './schema/integration-event-dedup.js';
|
|
4
|
+
export async function recordIntegrationEventForProject(params) {
|
|
5
|
+
const inserted = await params.tx.insert(projectsIntegrationEventDedup).values({
|
|
6
|
+
integrationEventId: params.integrationEventId,
|
|
7
|
+
projectId: params.projectId
|
|
8
|
+
}).onConflictDoNothing({
|
|
9
|
+
target: [
|
|
10
|
+
projectsIntegrationEventDedup.integrationEventId,
|
|
11
|
+
projectsIntegrationEventDedup.projectId
|
|
12
|
+
]
|
|
13
|
+
}).returning({
|
|
14
|
+
projectId: projectsIntegrationEventDedup.projectId
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
firstSeen: inserted.length > 0
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export async function pruneIntegrationEventDedup(params) {
|
|
21
|
+
const result = await db().delete(projectsIntegrationEventDedup).where(lt(projectsIntegrationEventDedup.receivedAt, params.olderThan));
|
|
22
|
+
return {
|
|
23
|
+
deleted: result.rowCount ?? 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=integration-event-dedup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/db/integration-event-dedup.ts"],"sourcesContent":["import {lt} from 'drizzle-orm';\nimport {db} from './db.js';\nimport {projectsIntegrationEventDedup} from './schema/integration-event-dedup.js';\n\n// biome-ignore lint/suspicious/noExplicitAny: cross-module drizzle tx without a portable exported type\ntype DrizzleTxLike = any;\n\nexport interface RecordIntegrationEventForProjectParams {\n tx: DrizzleTxLike;\n integrationEventId: string;\n projectId: string;\n}\n\nexport async function recordIntegrationEventForProject(\n params: RecordIntegrationEventForProjectParams,\n): Promise<{firstSeen: boolean}> {\n const inserted = await params.tx\n .insert(projectsIntegrationEventDedup)\n .values({\n integrationEventId: params.integrationEventId,\n projectId: params.projectId,\n })\n .onConflictDoNothing({\n target: [\n projectsIntegrationEventDedup.integrationEventId,\n projectsIntegrationEventDedup.projectId,\n ],\n })\n .returning({projectId: projectsIntegrationEventDedup.projectId});\n\n return {firstSeen: inserted.length > 0};\n}\n\nexport interface PruneIntegrationEventDedupParams {\n olderThan: Date;\n}\n\nexport async function pruneIntegrationEventDedup(\n params: PruneIntegrationEventDedupParams,\n): Promise<{deleted: number}> {\n const result = await db()\n .delete(projectsIntegrationEventDedup)\n .where(lt(projectsIntegrationEventDedup.receivedAt, params.olderThan));\n return {deleted: result.rowCount ?? 0};\n}\n"],"names":["lt","db","projectsIntegrationEventDedup","recordIntegrationEventForProject","params","inserted","tx","insert","values","integrationEventId","projectId","onConflictDoNothing","target","returning","firstSeen","length","pruneIntegrationEventDedup","result","delete","where","receivedAt","olderThan","deleted","rowCount"],"mappings":"AAAA,SAAQA,EAAE,QAAO,cAAc;AAC/B,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,6BAA6B,QAAO,sCAAsC;AAWlF,OAAO,eAAeC,iCACpBC,MAA8C;IAE9C,MAAMC,WAAW,MAAMD,OAAOE,EAAE,CAC7BC,MAAM,CAACL,+BACPM,MAAM,CAAC;QACNC,oBAAoBL,OAAOK,kBAAkB;QAC7CC,WAAWN,OAAOM,SAAS;IAC7B,GACCC,mBAAmB,CAAC;QACnBC,QAAQ;YACNV,8BAA8BO,kBAAkB;YAChDP,8BAA8BQ,SAAS;SACxC;IACH,GACCG,SAAS,CAAC;QAACH,WAAWR,8BAA8BQ,SAAS;IAAA;IAEhE,OAAO;QAACI,WAAWT,SAASU,MAAM,GAAG;IAAC;AACxC;AAMA,OAAO,eAAeC,2BACpBZ,MAAwC;IAExC,MAAMa,SAAS,MAAMhB,KAClBiB,MAAM,CAAChB,+BACPiB,KAAK,CAACnB,GAAGE,8BAA8BkB,UAAU,EAAEhB,OAAOiB,SAAS;IACtE,OAAO;QAACC,SAASL,OAAOM,QAAQ,IAAI;IAAC;AACvC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Project } from '#core/entities/project.js';
|
|
2
|
+
export interface CreateProjectParams {
|
|
3
|
+
workspaceId: string;
|
|
4
|
+
sourceConnectionId: string;
|
|
5
|
+
sourceExternalRepositoryId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ProjectCursor {
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ListProjectsParams {
|
|
13
|
+
workspaceId: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
cursor?: ProjectCursor | undefined;
|
|
16
|
+
search?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface ListProjectsResult {
|
|
19
|
+
projects: Project[];
|
|
20
|
+
nextCursor: ProjectCursor | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function createProject(params: CreateProjectParams): Promise<Project>;
|
|
23
|
+
export declare function getProjectById(id: string): Promise<Project | undefined>;
|
|
24
|
+
export interface GetProjectBySourceParams {
|
|
25
|
+
workspaceId: string;
|
|
26
|
+
sourceConnectionId: string;
|
|
27
|
+
sourceExternalRepositoryId: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function getProjectBySource(params: GetProjectBySourceParams): Promise<Project | undefined>;
|
|
30
|
+
export declare function requireProjectForWorkspace(params: {
|
|
31
|
+
projectId: string;
|
|
32
|
+
workspaceId: string;
|
|
33
|
+
}): Promise<Project>;
|
|
34
|
+
export declare function listProjects(params: ListProjectsParams): Promise<ListProjectsResult>;
|
|
35
|
+
export declare function getProjectCount(): Promise<number>;
|
|
36
|
+
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/db/projects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAMvD,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACp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q, ilike, lt, or } from 'drizzle-orm';
|
|
2
|
+
import { ProjectAlreadyExistsError, ProjectNotFoundError } from '#core/errors.js';
|
|
3
|
+
import { recordProjectCreated } from '#metrics/instance.js';
|
|
4
|
+
import { db } from './db.js';
|
|
5
|
+
import { projects, toProject } from './schema/projects.js';
|
|
6
|
+
function escapeIlikePattern(value) {
|
|
7
|
+
return value.replace(/[\\%_]/g, (char)=>`\\${char}`);
|
|
8
|
+
}
|
|
9
|
+
function cursorWhere(params) {
|
|
10
|
+
if (!params.cursor) return undefined;
|
|
11
|
+
return or(lt(projects.createdAt, params.cursor.createdAt), and(eq(projects.createdAt, params.cursor.createdAt), lt(projects.id, params.cursor.id)));
|
|
12
|
+
}
|
|
13
|
+
export async function createProject(params) {
|
|
14
|
+
const project = await db().transaction(async (tx)=>{
|
|
15
|
+
const [projectRow] = await tx.insert(projects).values({
|
|
16
|
+
workspaceId: params.workspaceId,
|
|
17
|
+
sourceConnectionId: params.sourceConnectionId,
|
|
18
|
+
sourceExternalRepositoryId: params.sourceExternalRepositoryId,
|
|
19
|
+
name: params.name
|
|
20
|
+
}).onConflictDoNothing({
|
|
21
|
+
target: [
|
|
22
|
+
projects.sourceConnectionId,
|
|
23
|
+
projects.sourceExternalRepositoryId
|
|
24
|
+
]
|
|
25
|
+
}).returning();
|
|
26
|
+
if (!projectRow) {
|
|
27
|
+
const [conflict] = await tx.select().from(projects).where(and(eq(projects.sourceConnectionId, params.sourceConnectionId), eq(projects.sourceExternalRepositoryId, params.sourceExternalRepositoryId))).limit(1);
|
|
28
|
+
if (conflict) {
|
|
29
|
+
throw new ProjectAlreadyExistsError(conflict.id, params.sourceConnectionId, params.sourceExternalRepositoryId);
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Insert returned no rows');
|
|
32
|
+
}
|
|
33
|
+
return toProject(projectRow);
|
|
34
|
+
});
|
|
35
|
+
recordProjectCreated();
|
|
36
|
+
return project;
|
|
37
|
+
}
|
|
38
|
+
export async function getProjectById(id) {
|
|
39
|
+
const rows = await db().select().from(projects).where(eq(projects.id, id)).limit(1);
|
|
40
|
+
const row = rows[0];
|
|
41
|
+
if (!row) return undefined;
|
|
42
|
+
return toProject(row);
|
|
43
|
+
}
|
|
44
|
+
export async function getProjectBySource(params) {
|
|
45
|
+
const rows = await db().select().from(projects).where(and(eq(projects.workspaceId, params.workspaceId), eq(projects.sourceConnectionId, params.sourceConnectionId), eq(projects.sourceExternalRepositoryId, params.sourceExternalRepositoryId))).limit(1);
|
|
46
|
+
const row = rows[0];
|
|
47
|
+
if (!row) return undefined;
|
|
48
|
+
return toProject(row);
|
|
49
|
+
}
|
|
50
|
+
export async function requireProjectForWorkspace(params) {
|
|
51
|
+
const project = await getProjectById(params.projectId);
|
|
52
|
+
if (!project) throw new ProjectNotFoundError(params.projectId);
|
|
53
|
+
if (project.workspaceId !== params.workspaceId) throw new ProjectNotFoundError(params.projectId);
|
|
54
|
+
return project;
|
|
55
|
+
}
|
|
56
|
+
export async function listProjects(params) {
|
|
57
|
+
const conditions = [
|
|
58
|
+
eq(projects.workspaceId, params.workspaceId)
|
|
59
|
+
];
|
|
60
|
+
const cursorCondition = cursorWhere(params);
|
|
61
|
+
if (cursorCondition) conditions.push(cursorCondition);
|
|
62
|
+
if (params.search) {
|
|
63
|
+
conditions.push(ilike(projects.name, `%${escapeIlikePattern(params.search)}%`));
|
|
64
|
+
}
|
|
65
|
+
const rows = await db().select().from(projects).where(and(...conditions)).orderBy(desc(projects.createdAt), desc(projects.id)).limit(params.limit + 1);
|
|
66
|
+
const hasMore = rows.length > params.limit;
|
|
67
|
+
const pageRows = hasMore ? rows.slice(0, params.limit) : rows;
|
|
68
|
+
const last = pageRows.at(-1);
|
|
69
|
+
return {
|
|
70
|
+
projects: pageRows.map(toProject),
|
|
71
|
+
nextCursor: hasMore && last ? {
|
|
72
|
+
createdAt: last.createdAt,
|
|
73
|
+
id: last.id
|
|
74
|
+
} : null
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export async function getProjectCount() {
|
|
78
|
+
const [row] = await db().select({
|
|
79
|
+
value: count()
|
|
80
|
+
}).from(projects);
|
|
81
|
+
return row?.value ?? 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/db/projects.ts"],"sourcesContent":["import {and, count, desc, eq, ilike, lt, or, type SQL} from 'drizzle-orm';\nimport type {Project} from '#core/entities/project.js';\nimport {ProjectAlreadyExistsError, ProjectNotFoundError} from '#core/errors.js';\nimport {recordProjectCreated} from '#metrics/instance.js';\nimport {db} from './db.js';\nimport {projects, toProject} from './schema/projects.js';\n\nexport interface CreateProjectParams {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n name: string;\n}\n\nexport interface ProjectCursor {\n createdAt: Date;\n id: string;\n}\n\nexport interface ListProjectsParams {\n workspaceId: string;\n limit: number;\n cursor?: ProjectCursor | undefined;\n search?: string | undefined;\n}\n\nfunction escapeIlikePattern(value: string): string {\n return value.replace(/[\\\\%_]/g, (char) => `\\\\${char}`);\n}\n\nexport interface ListProjectsResult {\n projects: Project[];\n nextCursor: ProjectCursor | null;\n}\n\nfunction cursorWhere(params: ListProjectsParams): SQL | undefined {\n if (!params.cursor) return undefined;\n return or(\n lt(projects.createdAt, params.cursor.createdAt),\n and(eq(projects.createdAt, params.cursor.createdAt), lt(projects.id, params.cursor.id)),\n );\n}\n\nexport async function createProject(params: CreateProjectParams): Promise<Project> {\n const project = await db().transaction(async (tx) => {\n const [projectRow] = await tx\n .insert(projects)\n .values({\n workspaceId: params.workspaceId,\n sourceConnectionId: params.sourceConnectionId,\n sourceExternalRepositoryId: params.sourceExternalRepositoryId,\n name: params.name,\n })\n .onConflictDoNothing({\n target: [projects.sourceConnectionId, projects.sourceExternalRepositoryId],\n })\n .returning();\n\n if (!projectRow) {\n const [conflict] = await tx\n .select()\n .from(projects)\n .where(\n and(\n eq(projects.sourceConnectionId, params.sourceConnectionId),\n eq(projects.sourceExternalRepositoryId, params.sourceExternalRepositoryId),\n ),\n )\n .limit(1);\n if (conflict) {\n throw new ProjectAlreadyExistsError(\n conflict.id,\n params.sourceConnectionId,\n params.sourceExternalRepositoryId,\n );\n }\n throw new Error('Insert returned no rows');\n }\n\n return toProject(projectRow);\n });\n recordProjectCreated();\n return project;\n}\n\nexport async function getProjectById(id: string): Promise<Project | undefined> {\n const rows = await db().select().from(projects).where(eq(projects.id, id)).limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toProject(row);\n}\n\nexport interface GetProjectBySourceParams {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n}\n\nexport async function getProjectBySource(\n params: GetProjectBySourceParams,\n): Promise<Project | undefined> {\n const rows = await db()\n .select()\n .from(projects)\n .where(\n and(\n eq(projects.workspaceId, params.workspaceId),\n eq(projects.sourceConnectionId, params.sourceConnectionId),\n eq(projects.sourceExternalRepositoryId, params.sourceExternalRepositoryId),\n ),\n )\n .limit(1);\n\n const row = rows[0];\n if (!row) return undefined;\n return toProject(row);\n}\n\nexport async function requireProjectForWorkspace(params: {\n projectId: string;\n workspaceId: string;\n}): Promise<Project> {\n const project = await getProjectById(params.projectId);\n if (!project) throw new ProjectNotFoundError(params.projectId);\n if (project.workspaceId !== params.workspaceId) throw new ProjectNotFoundError(params.projectId);\n return project;\n}\n\nexport async function listProjects(params: ListProjectsParams): Promise<ListProjectsResult> {\n const conditions = [eq(projects.workspaceId, params.workspaceId)];\n const cursorCondition = cursorWhere(params);\n if (cursorCondition) conditions.push(cursorCondition);\n if (params.search) {\n conditions.push(ilike(projects.name, `%${escapeIlikePattern(params.search)}%`));\n }\n\n const rows = await db()\n .select()\n .from(projects)\n .where(and(...conditions))\n .orderBy(desc(projects.createdAt), desc(projects.id))\n .limit(params.limit + 1);\n\n const hasMore = rows.length > params.limit;\n const pageRows = hasMore ? rows.slice(0, params.limit) : rows;\n const last = pageRows.at(-1);\n\n return {\n projects: pageRows.map(toProject),\n nextCursor: hasMore && last ? {createdAt: last.createdAt, id: last.id} : null,\n };\n}\n\nexport async function getProjectCount(): Promise<number> {\n const [row] = await db().select({value: count()}).from(projects);\n return row?.value ?? 0;\n}\n"],"names":["and","count","desc","eq","ilike","lt","or","ProjectAlreadyExistsError","ProjectNotFoundError","recordProjectCreated","db","projects","toProject","escapeIlikePattern","value","replace","char","cursorWhere","params","cursor","undefined","createdAt","id","createProject","project","transaction","tx","projectRow","insert","values","workspaceId","sourceConnectionId","sourceExternalRepositoryId","name","onConflictDoNothing","target","returning","conflict","select","from","where","limit","Error","getProjectById","rows","row","getProjectBySource","requireProjectForWorkspace","projectId","listProjects","conditions","cursorCondition","push","search","orderBy","hasMore","length","pageRows","slice","last","at","map","nextCursor","getProjectCount"],"mappings":"AAAA,SAAQA,GAAG,EAAEC,KAAK,EAAEC,IAAI,EAAEC,EAAE,EAAEC,KAAK,EAAEC,EAAE,EAAEC,EAAE,QAAiB,cAAc;AAE1E,SAAQC,yBAAyB,EAAEC,oBAAoB,QAAO,kBAAkB;AAChF,SAAQC,oBAAoB,QAAO,uBAAuB;AAC1D,SAAQC,EAAE,QAAO,UAAU;AAC3B,SAAQC,QAAQ,EAAEC,SAAS,QAAO,uBAAuB;AAqBzD,SAASC,mBAAmBC,KAAa;IACvC,OAAOA,MAAMC,OAAO,CAAC,WAAW,CAACC,OAAS,CAAC,EAAE,EAAEA,MAAM;AACvD;AAOA,SAASC,YAAYC,MAA0B;IAC7C,IAAI,CAACA,OAAOC,MAAM,EAAE,OAAOC;IAC3B,OAAOd,GACLD,GAAGM,SAASU,SAAS,EAAEH,OAAOC,MAAM,CAACE,SAAS,GAC9CrB,IAAIG,GAAGQ,SAASU,SAAS,EAAEH,OAAOC,MAAM,CAACE,SAAS,GAAGhB,GAAGM,SAASW,EAAE,EAAEJ,OAAOC,MAAM,CAACG,EAAE;AAEzF;AAEA,OAAO,eAAeC,cAAcL,MAA2B;IA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C,CAAC;IAE1B,OAAO;QACLjD,UAAU8C,SAASI,GAAG,CAACjD;QACvBkD,YAAYP,WAAWI,OAAO;YAACtC,WAAWsC,KAAKtC,SAAS;YAAEC,IAAIqC,KAAKrC,EAAE;QAAA,IAAI;IAC3E;AACF;AAEA,OAAO,eAAeyC;IACpB,MAAM,CAAClB,IAAI,GAAG,MAAMnC,KAAK4B,MAAM,CAAC;QAACxB,OAAOb;IAAO,GAAGsC,IAAI,CAAC5B;IACvD,OAAOkC,KAAK/B,SAAS;AACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/db/schema/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,oDAA+C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/common.ts"],"sourcesContent":["import {pgTableCreator} from 'drizzle-orm/pg-core';\n\nexport const pgTable = pgTableCreator((name) => `projects_${name}`);\n"],"names":["pgTableCreator","pgTable","name"],"mappings":"AAAA,SAAQA,cAAc,QAAO,sBAAsB;AAEnD,OAAO,MAAMC,UAAUD,eAAe,CAACE,OAAS,CAAC,SAAS,EAAEA,MAAM,EAAE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const projectsIntegrationEventDedup: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "integration_event_dedup";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
integrationEventId: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "integration_event_id";
|
|
7
|
+
tableName: "integration_event_dedup";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "PgUUID";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
projectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "project_id";
|
|
24
|
+
tableName: "integration_event_dedup";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "PgUUID";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
receivedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "received_at";
|
|
41
|
+
tableName: "integration_event_dedup";
|
|
42
|
+
dataType: "date";
|
|
43
|
+
columnType: "PgTimestamp";
|
|
44
|
+
data: Date;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: true;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: undefined;
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
};
|
|
57
|
+
dialect: "pg";
|
|
58
|
+
}>;
|
|
59
|
+
//# sourceMappingURL=integration-event-dedup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-event-dedup.d.ts","sourceRoot":"","sources":["../../../src/db/schema/integration-event-dedup.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWzC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { index, primaryKey, timestamp, uuid } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { pgTable } from './common.js';
|
|
3
|
+
export const projectsIntegrationEventDedup = pgTable('integration_event_dedup', {
|
|
4
|
+
integrationEventId: uuid('integration_event_id').notNull(),
|
|
5
|
+
projectId: uuid('project_id').notNull(),
|
|
6
|
+
receivedAt: timestamp('received_at', {
|
|
7
|
+
withTimezone: true
|
|
8
|
+
}).notNull().defaultNow()
|
|
9
|
+
}, (table)=>[
|
|
10
|
+
primaryKey({
|
|
11
|
+
columns: [
|
|
12
|
+
table.integrationEventId,
|
|
13
|
+
table.projectId
|
|
14
|
+
]
|
|
15
|
+
}),
|
|
16
|
+
index('projects_integration_event_dedup_received_at_idx').on(table.receivedAt)
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=integration-event-dedup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/integration-event-dedup.ts"],"sourcesContent":["import {index, primaryKey, timestamp, uuid} from 'drizzle-orm/pg-core';\nimport {pgTable} from './common.js';\n\nexport const projectsIntegrationEventDedup = pgTable(\n 'integration_event_dedup',\n {\n integrationEventId: uuid('integration_event_id').notNull(),\n projectId: uuid('project_id').notNull(),\n receivedAt: timestamp('received_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n primaryKey({columns: [table.integrationEventId, table.projectId]}),\n index('projects_integration_event_dedup_received_at_idx').on(table.receivedAt),\n ],\n);\n"],"names":["index","primaryKey","timestamp","uuid","pgTable","projectsIntegrationEventDedup","integrationEventId","notNull","projectId","receivedAt","withTimezone","defaultNow","table","columns","on"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,UAAU,EAAEC,SAAS,EAAEC,IAAI,QAAO,sBAAsB;AACvE,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,gCAAgCD,QAC3C,2BACA;IACEE,oBAAoBH,KAAK,wBAAwBI,OAAO;IACxDC,WAAWL,KAAK,cAAcI,OAAO;IACrCE,YAAYP,UAAU,eAAe;QAACQ,cAAc;IAAI,GAAGH,OAAO,GAAGI,UAAU;AACjF,GACA,CAACC,QAAU;QACTX,WAAW;YAACY,SAAS;gBAACD,MAAMN,kBAAkB;gBAAEM,MAAMJ,SAAS;aAAC;QAAA;QAChER,MAAM,oDAAoDc,EAAE,CAACF,MAAMH,UAAU;KAC9E,EACD"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export declare const projectsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "outbox";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "outbox";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "PgUUID";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
eventType: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "event_type";
|
|
24
|
+
tableName: "outbox";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "PgText";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
orderingKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "ordering_key";
|
|
41
|
+
tableName: "outbox";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgText";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: false;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
payload: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "payload";
|
|
58
|
+
tableName: "outbox";
|
|
59
|
+
dataType: "json";
|
|
60
|
+
columnType: "PgJsonb";
|
|
61
|
+
data: unknown;
|
|
62
|
+
driverParam: unknown;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: undefined;
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "created_at";
|
|
75
|
+
tableName: "outbox";
|
|
76
|
+
dataType: "date";
|
|
77
|
+
columnType: "PgTimestamp";
|
|
78
|
+
data: Date;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: true;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: undefined;
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
dispatchedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "dispatched_at";
|
|
92
|
+
tableName: "outbox";
|
|
93
|
+
dataType: "date";
|
|
94
|
+
columnType: "PgTimestamp";
|
|
95
|
+
data: Date;
|
|
96
|
+
driverParam: string;
|
|
97
|
+
notNull: false;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: undefined;
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
dispatchAttempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "dispatch_attempts";
|
|
109
|
+
tableName: "outbox";
|
|
110
|
+
dataType: "number";
|
|
111
|
+
columnType: "PgInteger";
|
|
112
|
+
data: number;
|
|
113
|
+
driverParam: string | number;
|
|
114
|
+
notNull: true;
|
|
115
|
+
hasDefault: true;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: undefined;
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
nextDispatchAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "next_dispatch_at";
|
|
126
|
+
tableName: "outbox";
|
|
127
|
+
dataType: "date";
|
|
128
|
+
columnType: "PgTimestamp";
|
|
129
|
+
data: Date;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: true;
|
|
132
|
+
hasDefault: true;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: undefined;
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
lastDispatchError: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
+
name: "last_dispatch_error";
|
|
143
|
+
tableName: "outbox";
|
|
144
|
+
dataType: "json";
|
|
145
|
+
columnType: "PgJsonb";
|
|
146
|
+
data: unknown;
|
|
147
|
+
driverParam: unknown;
|
|
148
|
+
notNull: false;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: undefined;
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
lastDispatchFailedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
+
name: "last_dispatch_failed_at";
|
|
160
|
+
tableName: "outbox";
|
|
161
|
+
dataType: "date";
|
|
162
|
+
columnType: "PgTimestamp";
|
|
163
|
+
data: Date;
|
|
164
|
+
driverParam: string;
|
|
165
|
+
notNull: false;
|
|
166
|
+
hasDefault: false;
|
|
167
|
+
isPrimaryKey: false;
|
|
168
|
+
isAutoincrement: false;
|
|
169
|
+
hasRuntimeDefault: false;
|
|
170
|
+
enumValues: undefined;
|
|
171
|
+
baseColumn: never;
|
|
172
|
+
identity: undefined;
|
|
173
|
+
generated: undefined;
|
|
174
|
+
}, {}, {}>;
|
|
175
|
+
deadLetteredAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
176
|
+
name: "dead_lettered_at";
|
|
177
|
+
tableName: "outbox";
|
|
178
|
+
dataType: "date";
|
|
179
|
+
columnType: "PgTimestamp";
|
|
180
|
+
data: Date;
|
|
181
|
+
driverParam: string;
|
|
182
|
+
notNull: false;
|
|
183
|
+
hasDefault: false;
|
|
184
|
+
isPrimaryKey: false;
|
|
185
|
+
isAutoincrement: false;
|
|
186
|
+
hasRuntimeDefault: false;
|
|
187
|
+
enumValues: undefined;
|
|
188
|
+
baseColumn: never;
|
|
189
|
+
identity: undefined;
|
|
190
|
+
generated: undefined;
|
|
191
|
+
}, {}, {}>;
|
|
192
|
+
};
|
|
193
|
+
dialect: "pg";
|
|
194
|
+
}>;
|
|
195
|
+
//# sourceMappingURL=outbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../../src/db/schema/outbox.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/outbox.ts"],"sourcesContent":["import {createOutboxTable} from '@shipfox/node-outbox';\nimport {pgTable} from './common.js';\n\nexport const projectsOutbox = createOutboxTable(pgTable);\n"],"names":["createOutboxTable","pgTable","projectsOutbox"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,iBAAiBF,kBAAkBC,SAAS"}
|