@atproto/ozone 0.2.23 → 0.2.25
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/CHANGELOG.md +37 -0
- package/dist/api/queue/createQueue.d.ts.map +1 -1
- package/dist/api/queue/createQueue.js +3 -1
- package/dist/api/queue/createQueue.js.map +1 -1
- package/dist/api/queue/updateQueue.d.ts.map +1 -1
- package/dist/api/queue/updateQueue.js +8 -3
- package/dist/api/queue/updateQueue.js.map +1 -1
- package/dist/api/report/createReport.js +7 -5
- package/dist/api/report/createReport.js.map +1 -1
- package/dist/api/util.d.ts.map +1 -1
- package/dist/api/util.js.map +1 -1
- package/dist/assignment/index.d.ts +1 -0
- package/dist/assignment/index.d.ts.map +1 -1
- package/dist/assignment/index.js +5 -0
- package/dist/assignment/index.js.map +1 -1
- package/dist/db/index.d.ts +3 -4
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +0 -2
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.d.ts +4 -0
- package/dist/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.d.ts.map +1 -0
- package/dist/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.js +14 -0
- package/dist/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.js.map +1 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +1 -0
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/schema/report_queue.d.ts +1 -0
- package/dist/db/schema/report_queue.d.ts.map +1 -1
- package/dist/db/schema/report_queue.js.map +1 -1
- package/dist/db/types.d.ts.map +1 -1
- package/dist/db/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/jetstream/service.d.ts +4 -3
- package/dist/jetstream/service.d.ts.map +1 -1
- package/dist/jetstream/service.js +46 -22
- package/dist/jetstream/service.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +118 -10
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +62 -5
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +5 -0
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/ageassurance/begin.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/ageassurance/begin.js.map +1 -1
- package/dist/lexicon/types/app/bsky/ageassurance/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/ageassurance/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/draft/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/draft/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/muteActor.d.ts +4 -0
- package/dist/lexicon/types/app/bsky/graph/muteActor.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/muteActor.js.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts +5 -1
- package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/defs.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/defs.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/defs.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/group/createGroup.d.ts +1 -0
- package/dist/lexicon/types/chat/bsky/group/createGroup.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/group/createGroup.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/group/enableJoinLink.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/group/enableJoinLink.js.map +1 -1
- package/dist/lexicon/types/com/atproto/repo/applyWrites.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/repo/applyWrites.js.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/defs.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/defs.js.map +1 -1
- package/dist/lexicon/types/com/atproto/temp/checkHandleAvailability.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/temp/checkHandleAvailability.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/queryEvents.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/queryEvents.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/queryStatuses.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/queryStatuses.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/createQueue.d.ts +3 -1
- package/dist/lexicon/types/tools/ozone/queue/createQueue.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/createQueue.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/defs.d.ts +2 -0
- package/dist/lexicon/types/tools/ozone/queue/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.d.ts +3 -0
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/queryReports.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/queryReports.js.map +1 -1
- package/dist/mod-service/index.d.ts +0 -39
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +0 -11
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/subject.d.ts.map +1 -1
- package/dist/mod-service/subject.js.map +1 -1
- package/dist/mod-service/types.d.ts.map +1 -1
- package/dist/mod-service/types.js.map +1 -1
- package/dist/mod-service/views.d.ts.map +1 -1
- package/dist/mod-service/views.js.map +1 -1
- package/dist/queue/service.d.ts +4 -1
- package/dist/queue/service.d.ts.map +1 -1
- package/dist/queue/service.js +27 -2
- package/dist/queue/service.js.map +1 -1
- package/dist/report/stats.js +3 -3
- package/dist/report/stats.js.map +1 -1
- package/dist/sequencer/sequencer.d.ts +5 -6
- package/dist/sequencer/sequencer.d.ts.map +1 -1
- package/dist/sequencer/sequencer.js.map +1 -1
- package/package.json +12 -13
package/dist/db/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
1
2
|
import { Migrator } from 'kysely/migration';
|
|
2
3
|
declare const PgPool: typeof import("pg").Pool;
|
|
3
4
|
type PgPool = InstanceType<typeof PgPool>;
|
|
4
|
-
import type TypedEmitter from 'typed-emitter';
|
|
5
5
|
import type { DatabaseSchema } from './schema/index.js';
|
|
6
6
|
import type { PgOptions } from './types.js';
|
|
7
7
|
export declare const STATS_COMPUTER_LOCK_ID = 7239401;
|
|
@@ -11,7 +11,7 @@ export declare class Database {
|
|
|
11
11
|
pool: PgPool;
|
|
12
12
|
db: DatabaseSchema;
|
|
13
13
|
migrator: Migrator;
|
|
14
|
-
txEvt:
|
|
14
|
+
txEvt: EventEmitter<TxnEvents>;
|
|
15
15
|
destroyed: boolean;
|
|
16
16
|
isPrimary: boolean;
|
|
17
17
|
constructor(opts: PgOptions, instances?: {
|
|
@@ -29,8 +29,7 @@ export declare class Database {
|
|
|
29
29
|
migrateToLatestOrThrow(): Promise<import("kysely/migration").MigrationResult[]>;
|
|
30
30
|
}
|
|
31
31
|
export default Database;
|
|
32
|
-
type TxnEmitter = TypedEmitter.default<TxnEvents>;
|
|
33
32
|
type TxnEvents = {
|
|
34
|
-
commit:
|
|
33
|
+
commit: [];
|
|
35
34
|
};
|
|
36
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/db/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAW1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,QAAA,MAAc,MAAM,0BAAuB,CAAA;AAC3C,KAAK,MAAM,GAAG,YAAY,CAAC,OAAO,MAAM,CAAC,CAAA;AAIzC,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,mBAAmB,CAAA;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI3C,eAAO,MAAM,sBAAsB,UAAY,CAAA;AAC/C,eAAO,MAAM,iCAAiC,UAAY,CAAA;AAE1D,qBAAa,QAAQ;IASV,IAAI,EAAE,SAAS;IARxB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,cAAc,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,0BAAgC;IACrC,SAAS,UAAQ;IACjB,SAAS,UAAQ;IAEjB,YACS,IAAI,EAAE,SAAS,EACtB,SAAS,CAAC,EAAE;QAAE,EAAE,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAkDjD;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,aAAa,YAEhB;IAED,iBAAiB,SAEhB;IAED,oBAAoB,SAEnB;IAEK,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsBjE;IAED,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,QAGtB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAEK,gBAAgB,CAAC,SAAS,EAAE,MAAM,yDAYvC;IAEK,sBAAsB,0DAY3B;CACF;eAEc,QAAQ;AA6BvB,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,EAAE,CAAA;CACX,CAAA"}
|
package/dist/db/index.js
CHANGED
|
@@ -2,9 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { Kysely, PostgresDialect, } from 'kysely';
|
|
4
4
|
import { Migrator } from 'kysely/migration';
|
|
5
|
-
// eslint-disable-next-line import/default
|
|
6
5
|
import pg from 'pg';
|
|
7
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
8
6
|
const { Pool: PgPool, types: pgTypes } = pg;
|
|
9
7
|
import { dbLogger } from '../logger.js';
|
|
10
8
|
import * as migrations from './migrations/index.js';
|
package/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,MAAM,EAIN,eAAe,GAIhB,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,0CAA0C;AAC1C,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,6DAA6D;AAC7D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;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,WAAM,GAAG,KAAK,CAAA;IAkBxB,CAAC;IAhBC,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;IAED,cAAc,CAAC,IAA8B;QAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAQD,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC,CAAA","sourcesContent":["import assert from 'node:assert'\nimport { EventEmitter } from 'node:events'\nimport {\n Kysely,\n type KyselyPlugin,\n type PluginTransformQueryArgs,\n type PluginTransformResultArgs,\n PostgresDialect,\n type QueryResult,\n type RootOperationNode,\n type UnknownRow,\n} from 'kysely'\nimport { Migrator } from 'kysely/migration'\n// eslint-disable-next-line import/default\nimport pg from 'pg'\n// eslint-disable-next-line import/no-named-as-default-member\nconst { Pool: PgPool, types: pgTypes } = pg\ntype PgPool = InstanceType<typeof PgPool>\nimport type TypedEmitter from 'typed-emitter'\nimport { dbLogger } from '../logger.js'\nimport * as migrations from './migrations/index.js'\nimport { CtxMigrationProvider } from './migrations/provider.js'\nimport type { DatabaseSchema, DatabaseSchemaType } from './schema/index.js'\nimport type { PgOptions } from './types.js'\n\n// Stable pg advisory lock IDs used to coordinate daemon work across\n// instances. Centralized here so IDs can never silently collide.\nexport const STATS_COMPUTER_LOCK_ID = 7_239_401\nexport const MATERIALIZED_VIEW_REFRESH_LOCK_ID = 7_239_402\n\nexport class Database {\n pool: PgPool\n db: DatabaseSchema\n migrator: Migrator\n txEvt = new EventEmitter() as TxnEmitter\n destroyed = false\n isPrimary = false\n\n constructor(\n public opts: PgOptions,\n instances?: { db: DatabaseSchema; pool: PgPool },\n ) {\n // if instances are provided, use those\n if (instances) {\n this.db = instances.db\n this.pool = instances.pool\n } else {\n // else create a pool & connect\n const { schema, url } = opts\n const pool =\n opts.pool ??\n new PgPool({\n connectionString: url,\n max: opts.poolSize,\n maxUses: opts.poolMaxUses,\n idleTimeoutMillis: opts.poolIdleTimeoutMs,\n })\n\n // Select count(*) and other pg bigints as js integer\n pgTypes.setTypeParser(pgTypes.builtins.INT8, (n) => parseInt(n, 10))\n\n // Setup schema usage, primarily for test parallelism (each test suite runs in its own pg schema)\n if (schema && !/^[a-z_]+$/i.test(schema)) {\n throw new Error(\n `Postgres schema must only contain [A-Za-z_]: ${schema}`,\n )\n }\n\n pool.on('error', onPoolError)\n pool.on('connect', (client) => {\n client.on('error', onClientError)\n // Used for trigram indexes, e.g. on actor search\n client.query('SET pg_trgm.word_similarity_threshold TO .4;')\n if (schema) {\n // Shared objects such as extensions will go in the public schema\n client.query(`SET search_path TO \"${schema}\",public;`)\n }\n })\n\n this.pool = pool\n this.db = new Kysely<DatabaseSchemaType>({\n dialect: new PostgresDialect({ pool }),\n })\n }\n\n this.migrator = new Migrator({\n db: this.db,\n migrationTableSchema: opts.schema,\n provider: new CtxMigrationProvider(migrations, 'pg'),\n })\n }\n\n get schema(): string | undefined {\n return this.opts.schema\n }\n\n get isTransaction() {\n return this.db.isTransaction\n }\n\n assertTransaction() {\n assert(this.isTransaction, 'Transaction required')\n }\n\n assertNotTransaction() {\n assert(!this.isTransaction, 'Cannot be in a transaction')\n }\n\n async transaction<T>(fn: (db: Database) => Promise<T>): Promise<T> {\n const leakyTxPlugin = new LeakyTxPlugin()\n const { dbTxn, txRes } = await this.db\n .withPlugin(leakyTxPlugin)\n .transaction()\n .execute(async (txn) => {\n const dbTxn = new Database(this.opts, {\n db: txn,\n pool: this.pool,\n })\n const txRes = await fn(dbTxn)\n .catch(async (err) => {\n leakyTxPlugin.endTx()\n // ensure that all in-flight queries are flushed & the connection is open\n await dbTxn.db.getExecutor().provideConnection(noopAsync)\n throw err\n })\n .finally(() => leakyTxPlugin.endTx())\n return { dbTxn, txRes }\n })\n dbTxn?.txEvt.emit('commit')\n return txRes\n }\n\n onCommit(fn: () => void) {\n this.assertTransaction()\n this.txEvt.once('commit', fn)\n }\n\n async close(): Promise<void> {\n if (this.destroyed) return\n await this.db.destroy()\n this.destroyed = true\n }\n\n async migrateToOrThrow(migration: string) {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateTo(migration)\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n\n async migrateToLatestOrThrow() {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateToLatest()\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n}\n\nexport default Database\n\nconst onPoolError = (err: Error) => dbLogger.error({ err }, 'db pool error')\nconst onClientError = (err: Error) => dbLogger.error({ err }, 'db client error')\n\n// utils\n// -------\n\nclass LeakyTxPlugin implements KyselyPlugin {\n private txOver = false\n\n endTx() {\n this.txOver = true\n }\n\n transformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n if (this.txOver) {\n throw new Error('tx already failed')\n }\n return args.node\n }\n\n async transformResult(\n args: PluginTransformResultArgs,\n ): Promise<QueryResult<UnknownRow>> {\n return args.result\n }\n}\n\ntype TxnEmitter = TypedEmitter.default<TxnEvents>\n\ntype TxnEvents = {\n commit: () => void\n}\n\nconst noopAsync = async () => {}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,MAAM,EAIN,eAAe,GAIhB,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,kBA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AAC,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,CAAA;AAC5E,MAAM,aAAa,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAA;AAEhF,QAAQ;AACR,UAAU;AAEV,MAAM,aAAa;IAAnB;QACU,WAAM,GAAG,KAAK,CAAA;IAkBxB,CAAC;IAhBC,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;IAED,cAAc,CAAC,IAA8B;QAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAMD,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC,CAAA","sourcesContent":["import assert from 'node:assert'\nimport { EventEmitter } from 'node:events'\nimport {\n Kysely,\n type KyselyPlugin,\n type PluginTransformQueryArgs,\n type PluginTransformResultArgs,\n PostgresDialect,\n type QueryResult,\n type RootOperationNode,\n type UnknownRow,\n} from 'kysely'\nimport { Migrator } from 'kysely/migration'\nimport pg from 'pg'\nconst { Pool: PgPool, types: pgTypes } = pg\ntype PgPool = InstanceType<typeof PgPool>\nimport { dbLogger } from '../logger.js'\nimport * as migrations from './migrations/index.js'\nimport { CtxMigrationProvider } from './migrations/provider.js'\nimport type { DatabaseSchema, DatabaseSchemaType } from './schema/index.js'\nimport type { PgOptions } from './types.js'\n\n// Stable pg advisory lock IDs used to coordinate daemon work across\n// instances. Centralized here so IDs can never silently collide.\nexport const STATS_COMPUTER_LOCK_ID = 7_239_401\nexport const MATERIALIZED_VIEW_REFRESH_LOCK_ID = 7_239_402\n\nexport class Database {\n pool: PgPool\n db: DatabaseSchema\n migrator: Migrator\n txEvt = new EventEmitter<TxnEvents>()\n destroyed = false\n isPrimary = false\n\n constructor(\n public opts: PgOptions,\n instances?: { db: DatabaseSchema; pool: PgPool },\n ) {\n // if instances are provided, use those\n if (instances) {\n this.db = instances.db\n this.pool = instances.pool\n } else {\n // else create a pool & connect\n const { schema, url } = opts\n const pool =\n opts.pool ??\n new PgPool({\n connectionString: url,\n max: opts.poolSize,\n maxUses: opts.poolMaxUses,\n idleTimeoutMillis: opts.poolIdleTimeoutMs,\n })\n\n // Select count(*) and other pg bigints as js integer\n pgTypes.setTypeParser(pgTypes.builtins.INT8, (n) => parseInt(n, 10))\n\n // Setup schema usage, primarily for test parallelism (each test suite runs in its own pg schema)\n if (schema && !/^[a-z_]+$/i.test(schema)) {\n throw new Error(\n `Postgres schema must only contain [A-Za-z_]: ${schema}`,\n )\n }\n\n pool.on('error', onPoolError)\n pool.on('connect', (client) => {\n client.on('error', onClientError)\n // Used for trigram indexes, e.g. on actor search\n client.query('SET pg_trgm.word_similarity_threshold TO .4;')\n if (schema) {\n // Shared objects such as extensions will go in the public schema\n client.query(`SET search_path TO \"${schema}\",public;`)\n }\n })\n\n this.pool = pool\n this.db = new Kysely<DatabaseSchemaType>({\n dialect: new PostgresDialect({ pool }),\n })\n }\n\n this.migrator = new Migrator({\n db: this.db,\n migrationTableSchema: opts.schema,\n provider: new CtxMigrationProvider(migrations, 'pg'),\n })\n }\n\n get schema(): string | undefined {\n return this.opts.schema\n }\n\n get isTransaction() {\n return this.db.isTransaction\n }\n\n assertTransaction() {\n assert(this.isTransaction, 'Transaction required')\n }\n\n assertNotTransaction() {\n assert(!this.isTransaction, 'Cannot be in a transaction')\n }\n\n async transaction<T>(fn: (db: Database) => Promise<T>): Promise<T> {\n const leakyTxPlugin = new LeakyTxPlugin()\n const { dbTxn, txRes } = await this.db\n .withPlugin(leakyTxPlugin)\n .transaction()\n .execute(async (txn) => {\n const dbTxn = new Database(this.opts, {\n db: txn,\n pool: this.pool,\n })\n const txRes = await fn(dbTxn)\n .catch(async (err) => {\n leakyTxPlugin.endTx()\n // ensure that all in-flight queries are flushed & the connection is open\n await dbTxn.db.getExecutor().provideConnection(noopAsync)\n throw err\n })\n .finally(() => leakyTxPlugin.endTx())\n return { dbTxn, txRes }\n })\n dbTxn?.txEvt.emit('commit')\n return txRes\n }\n\n onCommit(fn: () => void) {\n this.assertTransaction()\n this.txEvt.once('commit', fn)\n }\n\n async close(): Promise<void> {\n if (this.destroyed) return\n await this.db.destroy()\n this.destroyed = true\n }\n\n async migrateToOrThrow(migration: string) {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateTo(migration)\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n\n async migrateToLatestOrThrow() {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateToLatest()\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n}\n\nexport default Database\n\nconst onPoolError = (err: Error) => dbLogger.error({ err }, 'db pool error')\nconst onClientError = (err: Error) => dbLogger.error({ err }, 'db client error')\n\n// utils\n// -------\n\nclass LeakyTxPlugin implements KyselyPlugin {\n private txOver = false\n\n endTx() {\n this.txOver = true\n }\n\n transformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n if (this.txOver) {\n throw new Error('tx already failed')\n }\n return args.node\n }\n\n async transformResult(\n args: PluginTransformResultArgs,\n ): Promise<QueryResult<UnknownRow>> {\n return args.result\n }\n}\n\ntype TxnEvents = {\n commit: []\n}\n\nconst noopAsync = async () => {}\n"]}
|
package/dist/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260731T000000000Z-add-recommended-policies-to-report-queue.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAO,MAAM,QAAQ,CAAA;AAEzC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAK7D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.alterTable('report_queue')
|
|
5
|
+
.addColumn('recommendedPolicies', 'jsonb', (col) => col.notNull().defaultTo(sql `'[]'::jsonb`))
|
|
6
|
+
.execute();
|
|
7
|
+
}
|
|
8
|
+
export async function down(db) {
|
|
9
|
+
await db.schema
|
|
10
|
+
.alterTable('report_queue')
|
|
11
|
+
.dropColumn('recommendedPolicies')
|
|
12
|
+
.execute();
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=20260731T000000000Z-add-recommended-policies-to-report-queue.js.map
|
package/dist/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260731T000000000Z-add-recommended-policies-to-report-queue.js","sourceRoot":"","sources":["../../../src/db/migrations/20260731T000000000Z-add-recommended-policies-to-report-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,QAAQ,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,cAAc,CAAC;SAC1B,SAAS,CAAC,qBAAqB,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CACjD,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,aAAa,CAAC,CAC1C;SACA,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,cAAc,CAAC;SAC1B,UAAU,CAAC,qBAAqB,CAAC;SACjC,OAAO,EAAE,CAAA;AACd,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('report_queue')\n .addColumn('recommendedPolicies', 'jsonb', (col) =>\n col.notNull().defaultTo(sql`'[]'::jsonb`),\n )\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('report_queue')\n .dropColumn('recommendedPolicies')\n .execute()\n}\n"]}
|
|
@@ -40,4 +40,5 @@ export * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-i
|
|
|
40
40
|
export * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js';
|
|
41
41
|
export * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js';
|
|
42
42
|
export * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js';
|
|
43
|
+
export * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js';
|
|
43
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,gEAAgE,CAAA;AACtG,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,CAAA;AAC/E,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,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,mEAAmE,CAAA"}
|
|
@@ -43,4 +43,5 @@ export * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-i
|
|
|
43
43
|
export * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js';
|
|
44
44
|
export * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js';
|
|
45
45
|
export * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js';
|
|
46
|
+
export * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js';
|
|
46
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,gGAAgG;AAChG,+FAA+F;AAE/F,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,gEAAgE,CAAA;AACtG,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAClF,OAAO,KAAK,oBAAoB,MAAM,gDAAgD,CAAA;AACtF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK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AAoB,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA","sourcesContent":["// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.\n// It's important that every migration is exported from here with the proper name. We'd simplify\n// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.\n\nexport * as _20231219T205730722Z from './20231219T205730722Z-init.js'\nexport * as _20240116T085607200Z from './20240116T085607200Z-communication-template.js'\nexport * as _20240201T051104136Z from './20240201T051104136Z-mod-event-blobs.js'\nexport * as _20240208T213404429Z from './20240208T213404429Z-add-tags-column-to-moderation-subject.js'\nexport * as _20240228T003647759Z from './20240228T003647759Z-add-label-sigs.js'\nexport * as _20240408T192432676Z from './20240408T192432676Z-mute-reporting.js'\nexport * as _20240506T225055595Z from './20240506T225055595Z-message-subject.js'\nexport * as _20240430T211332580Z from './20240521T211332580Z-member.js'\nexport * as _20240814T003647759Z from './20240814T003647759Z-event-created-at-index.js'\nexport * as _20240903T205730722Z from './20240903T205730722Z-add-template-lang.js'\nexport * as _20240904T205730722Z from './20240904T205730722Z-add-subject-did-index.js'\nexport * as _20241001T205730722Z from './20241001T205730722Z-subject-status-review-state-index.js'\nexport * as _20241008T205730722Z from './20241008T205730722Z-sets.js'\nexport * as _20241018T205730722Z from './20241018T205730722Z-setting.js'\nexport * as _20241026T205730722Z from './20241026T205730722Z-add-hosting-status-to-subject-status.js'\nexport * as _20241220T144630860Z from './20241220T144630860Z-stats-materialized-views.js'\nexport * as _20250204T003647759Z from './20250204T003647759Z-add-subject-priority-score.js'\nexport * as _20250211T003647759Z from './20250211T003647759Z-add-reporter-stats-index.js'\nexport * as _20250211T132135150Z from './20250211T132135150Z-moderation-event-message-partial-idx.js'\nexport * as _20250221T132135150Z from './20250221T132135150Z-member-details.js'\nexport * as _20250404T201720309Z from './20250404T201720309Z-subject-status-sort-idxs.js'\nexport * as _20250415T201720309Z from './20250415T201720309Z-verification.js'\nexport * as _20250417T201720309Z from './20250417T201720309Z-firehose-cursor.js'\nexport * as _20250609T110704000Z from './20250609T110704000Z-safelink.js'\nexport * as _20250618T180246000Z from './20250618T180246000Z-add-mod-tool-to-moderation-event.js'\nexport * as _20250701T000000000Z from './20250701T000000000Z-add-age-assurance-state.js'\nexport * as _20250715T000000000Z from './20250715T000000000Z-add-mod-event-external-id.js'\nexport * as _20250718T150931000Z from './20250718T150931000Z-update-appeal-reason-stats.js'\nexport * as _20250813T000000000Z from './20250813T000000000Z-mod-tool-batch-id-index.js'\nexport * as _20250923T000000000Z from './20250923T000000000Z-scheduled-actions.js'\nexport * as _20251008T120000000Z from './20251008T120000000Z-add-strike-system.js'\nexport * as _20260210T154806448Z from './20260210T154806448Z-mod-event-created-by-indexes.js'\nexport * as _20260219T164523000Z from './20260219T164523000Z-create-report-table.js'\nexport * as _20260219T165302248Z from './20260219T165302248Z-moderator-assignment.js'\nexport * as _20260225T000000000Z from './20260225T000000000Z-add-report-queue-table.js'\nexport * as _20260313T000000000Z from './20260313T000000000Z-add-report-activity-table.js'\nexport * as _20260318T152058935Z from './20260318T152058935Z-add-report-stat.js'\nexport * as _20260428T000000000Z from './20260428T000000000Z-add-expiring-tag-table.js'\nexport * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-id.js'\nexport * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js'\nexport * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js'\nexport * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,gGAAgG;AAChG,+FAA+F;AAE/F,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,iDA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CAAA;AAC3F,OAAO,KAAK,oBAAoB,MAAM,kDAAkD,CAAA;AACxF,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAClF,OAAO,KAAK,oBAAoB,MAAM,4CAA4C,CAAA;AAClF,OAAO,KAAK,oBAAoB,MAAM,uDAAuD,CAAA;AAC7F,OAAO,KAAK,oBAAoB,MAAM,8CAA8C,CAAA;AACpF,OAAO,KAAK,oBAAoB,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,oDAAoD,CAAA;AAC1F,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,+CAA+C,CAAA;AACrF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,iDAAiD,CAAA;AACvF,OAAO,KAAK,oBAAoB,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,oBAAoB,MAAM,mEAAmE,CAAA","sourcesContent":["// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.\n// It's important that every migration is exported from here with the proper name. We'd simplify\n// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.\n\nexport * as _20231219T205730722Z from './20231219T205730722Z-init.js'\nexport * as _20240116T085607200Z from './20240116T085607200Z-communication-template.js'\nexport * as _20240201T051104136Z from './20240201T051104136Z-mod-event-blobs.js'\nexport * as _20240208T213404429Z from './20240208T213404429Z-add-tags-column-to-moderation-subject.js'\nexport * as _20240228T003647759Z from './20240228T003647759Z-add-label-sigs.js'\nexport * as _20240408T192432676Z from './20240408T192432676Z-mute-reporting.js'\nexport * as _20240506T225055595Z from './20240506T225055595Z-message-subject.js'\nexport * as _20240430T211332580Z from './20240521T211332580Z-member.js'\nexport * as _20240814T003647759Z from './20240814T003647759Z-event-created-at-index.js'\nexport * as _20240903T205730722Z from './20240903T205730722Z-add-template-lang.js'\nexport * as _20240904T205730722Z from './20240904T205730722Z-add-subject-did-index.js'\nexport * as _20241001T205730722Z from './20241001T205730722Z-subject-status-review-state-index.js'\nexport * as _20241008T205730722Z from './20241008T205730722Z-sets.js'\nexport * as _20241018T205730722Z from './20241018T205730722Z-setting.js'\nexport * as _20241026T205730722Z from './20241026T205730722Z-add-hosting-status-to-subject-status.js'\nexport * as _20241220T144630860Z from './20241220T144630860Z-stats-materialized-views.js'\nexport * as _20250204T003647759Z from './20250204T003647759Z-add-subject-priority-score.js'\nexport * as _20250211T003647759Z from './20250211T003647759Z-add-reporter-stats-index.js'\nexport * as _20250211T132135150Z from './20250211T132135150Z-moderation-event-message-partial-idx.js'\nexport * as _20250221T132135150Z from './20250221T132135150Z-member-details.js'\nexport * as _20250404T201720309Z from './20250404T201720309Z-subject-status-sort-idxs.js'\nexport * as _20250415T201720309Z from './20250415T201720309Z-verification.js'\nexport * as _20250417T201720309Z from './20250417T201720309Z-firehose-cursor.js'\nexport * as _20250609T110704000Z from './20250609T110704000Z-safelink.js'\nexport * as _20250618T180246000Z from './20250618T180246000Z-add-mod-tool-to-moderation-event.js'\nexport * as _20250701T000000000Z from './20250701T000000000Z-add-age-assurance-state.js'\nexport * as _20250715T000000000Z from './20250715T000000000Z-add-mod-event-external-id.js'\nexport * as _20250718T150931000Z from './20250718T150931000Z-update-appeal-reason-stats.js'\nexport * as _20250813T000000000Z from './20250813T000000000Z-mod-tool-batch-id-index.js'\nexport * as _20250923T000000000Z from './20250923T000000000Z-scheduled-actions.js'\nexport * as _20251008T120000000Z from './20251008T120000000Z-add-strike-system.js'\nexport * as _20260210T154806448Z from './20260210T154806448Z-mod-event-created-by-indexes.js'\nexport * as _20260219T164523000Z from './20260219T164523000Z-create-report-table.js'\nexport * as _20260219T165302248Z from './20260219T165302248Z-moderator-assignment.js'\nexport * as _20260225T000000000Z from './20260225T000000000Z-add-report-queue-table.js'\nexport * as _20260313T000000000Z from './20260313T000000000Z-add-report-activity-table.js'\nexport * as _20260318T152058935Z from './20260318T152058935Z-add-report-stat.js'\nexport * as _20260428T000000000Z from './20260428T000000000Z-add-expiring-tag-table.js'\nexport * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-id.js'\nexport * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js'\nexport * as _20260617T210022765Z from './20260617T210022765Z-add-report-isautomated.js'\nexport * as _20260720T000000000Z from './20260720T000000000Z-add-convo-subjects-to-stats-views.js'\nexport * as _20260731T000000000Z from './20260731T000000000Z-add-recommended-policies-to-report-queue.js'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_queue.d.ts","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAA;CACpC,CAAA"}
|
|
1
|
+
{"version":3,"file":"report_queue.d.ts","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAA;CACpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_queue.js","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA","sourcesContent":["import type { Generated } from 'kysely'\n\nexport const reportQueueTableName = 'report_queue'\n\nexport interface ReportQueue {\n id: Generated<number>\n name: string\n subjectTypes: string[] // ['account'] or ['record'] or ['account', 'record']\n collection: string | null // Collection name (e.g., 'app.bsky.feed.post'), NULL for accounts\n reportTypes: string[] // Array of report reason types (fully qualified NSIDs)\n description: string | null // Optional description of the queue\n createdBy: string // DID of moderator who created this queue\n createdAt: string\n updatedAt: string\n enabled: boolean\n deletedAt: string | null // NULL = active, timestamp = soft-deleted\n}\n\nexport type PartialDB = {\n [reportQueueTableName]: ReportQueue\n}\n"]}
|
|
1
|
+
{"version":3,"file":"report_queue.js","sourceRoot":"","sources":["../../../src/db/schema/report_queue.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA","sourcesContent":["import type { Generated } from 'kysely'\n\nexport const reportQueueTableName = 'report_queue'\n\nexport interface ReportQueue {\n id: Generated<number>\n name: string\n subjectTypes: string[] // ['account'] or ['record'] or ['account', 'record']\n collection: string | null // Collection name (e.g., 'app.bsky.feed.post'), NULL for accounts\n reportTypes: string[] // Array of report reason types (fully qualified NSIDs)\n description: string | null // Optional description of the queue\n recommendedPolicies: string[] // Policy keys recommended for reports in this queue\n createdBy: string // DID of moderator who created this queue\n createdAt: string\n updatedAt: string\n enabled: boolean\n deletedAt: string | null // NULL = active, timestamp = soft-deleted\n}\n\nexport type PartialDB = {\n [reportQueueTableName]: ReportQueue\n}\n"]}
|
package/dist/db/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,kBAAkB,EAExB,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,kBAAkB,EAExB,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,KAAK,MAAM,GAAG,EAAE,CAAC,IAAI,CAAA;AAErB,MAAM,MAAM,KAAK,GACf,UAAU,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAEjE,MAAM,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAErD,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,CAAC,OAAO,CAAC,kBAG9B,CAAA"}
|
package/dist/db/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,GACJ,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,GACJ,MAAM,QAAQ,CAAA;AAkBf,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,GAAM,EAAE,EAAE;IACjC,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAG,MAAM,CAAA;IACrC,OAAO,GAAG,CAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAA;AAC9C,CAAC,CAAA","sourcesContent":["import {\n type DynamicModule,\n type RawBuilder,\n type SelectQueryBuilder,\n sql,\n} from 'kysely'\nimport type pg from 'pg'\ntype PgPool = pg.Pool\n\nexport type DbRef =\n RawBuilder<unknown> | ReturnType<DynamicModule<unknown>['ref']>\n\nexport type AnyQb = SelectQueryBuilder<any, any, any>\n\nexport type PgOptions = {\n url: string\n pool?: PgPool\n schema?: string\n poolSize?: number\n poolMaxUses?: number\n poolIdleTimeoutMs?: number\n}\n\nexport const jsonb = <T>(val: T) => {\n if (val === null) return sql<T>`null`\n return sql<T>`${JSON.stringify(val)}::jsonb`\n}\n"]}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRo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AAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAgClC;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB7B;CACF;eAEc,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,7 @@ import events from 'node:events';
|
|
|
2
2
|
import compression from 'compression';
|
|
3
3
|
import cors from 'cors';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
|
|
6
|
-
import httpTerminator from 'http-terminator';
|
|
5
|
+
import { createHttpTerminator } from 'http-terminator';
|
|
7
6
|
import { DAY, SECOND } from '@atproto/common';
|
|
8
7
|
import API, { health, wellKnown } from './api/index.js';
|
|
9
8
|
import { AppContext } from './context.js';
|
|
@@ -84,7 +83,7 @@ export class OzoneService {
|
|
|
84
83
|
const server = this.app.listen(this.ctx.cfg.service.port);
|
|
85
84
|
this.server = server;
|
|
86
85
|
server.keepAliveTimeout = 90000;
|
|
87
|
-
this.terminator =
|
|
86
|
+
this.terminator = createHttpTerminator({ server });
|
|
88
87
|
await events.once(server, 'listening');
|
|
89
88
|
const { port } = server.address();
|
|
90
89
|
this.ctx.assignPort(port);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAGhC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAGhC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAuB,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3E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CAAC,KAAK,EAAE,CAAA;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,MAAM,CAAC,gBAAgB,GAAG,KAAK,CAAA;QAC/B,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAClD,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QACtC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAA;QAChD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACzB,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,OAAO;QACX,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACnC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAA;QAEhC,6EAA6E;QAC7E,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,CAAA;QACpC,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;YAC1C,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;gBACpC,CAAC;wBAAS,CAAC;oBACT,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,eAAe,YAAY,CAAA","sourcesContent":["import events from 'node:events'\nimport type http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport compression from 'compression'\nimport cors from 'cors'\nimport express from 'express'\nimport { type HttpTerminator, createHttpTerminator } from 'http-terminator'\nimport { DAY, SECOND } from '@atproto/common'\nimport API, { health, wellKnown } from './api/index.js'\nimport type { OzoneConfig, OzoneSecrets } from './config/index.js'\nimport { AppContext, type AppContextOptions } from './context.js'\nimport type { Member } from './db/schema/member.js'\nimport * as error from './error.js'\nimport { createServer } from './lexicon/index.js'\nimport { dbLogger, loggerMiddleware } from './logger.js'\n\nexport * from './config/index.js'\nexport { type ImageInvalidator } from './image-invalidator.js'\nexport { Database } from './db/index.js'\nexport { EventPusher, EventReverser, OzoneDaemon } from './daemon/index.js'\nexport { AppContext } from './context.js'\nexport { httpLogger } from './logger.js'\n\nexport class OzoneService {\n public ctx: AppContext\n public app: express.Application\n public server?: http.Server\n private terminator?: HttpTerminator\n private dbStatsInterval?: NodeJS.Timeout\n\n constructor(opts: { ctx: AppContext; app: express.Application }) {\n this.ctx = opts.ctx\n this.app = opts.app\n }\n\n static async create(\n cfg: OzoneConfig,\n secrets: OzoneSecrets,\n overrides?: Partial<AppContextOptions>,\n ): Promise<OzoneService> {\n const app = express()\n app.set('trust proxy', true)\n app.use(cors({ maxAge: DAY / SECOND }))\n app.use(loggerMiddleware)\n app.use(compression())\n\n const ctx = await AppContext.fromConfig(cfg, secrets, overrides)\n\n let server = createServer({\n validateResponse: false,\n payload: {\n jsonLimit: 100 * 1024, // 100kb\n textLimit: 100 * 1024, // 100kb\n blobLimit: 5 * 1024 * 1024, // 5mb\n },\n })\n\n server = API(server, ctx)\n\n app.use(health.createRouter(ctx))\n app.use(wellKnown.createRouter(ctx))\n app.use(server.xrpc.router)\n app.use(error.handler)\n\n return new OzoneService({ ctx, app })\n }\n\n async seedInitialMembers() {\n const members: Array<{ role: Member['role']; did: string }> = []\n this.ctx.cfg.access.admins.forEach((did) =>\n members.push({\n role: 'tools.ozone.team.defs#roleAdmin',\n did,\n }),\n )\n this.ctx.cfg.access.triage.forEach((did) =>\n members.push({\n role: 'tools.ozone.team.defs#roleTriage',\n did,\n }),\n )\n this.ctx.cfg.access.moderators.forEach((did) =>\n members.push({\n role: 'tools.ozone.team.defs#roleModerator',\n did,\n }),\n )\n\n for (const member of members) {\n const service = this.ctx.teamService(this.ctx.db)\n await service.upsert({\n ...member,\n lastUpdatedBy: this.ctx.cfg.service.did,\n })\n }\n }\n\n async start(): Promise<http.Server> {\n if (this.dbStatsInterval) {\n throw new Error(`${this.constructor.name} already started`)\n }\n\n // Any moderator that are configured via env var may not exist in the database\n // so we need to sync them from env var to the database\n await this.seedInitialMembers()\n\n this.dbStatsInterval = setInterval(() => {\n dbLogger.info(\n {\n idleCount: this.ctx.db.pool.idleCount,\n totalCount: this.ctx.db.pool.totalCount,\n waitingCount: this.ctx.db.pool.waitingCount,\n },\n 'db pool stats',\n )\n dbLogger.info(\n this.ctx.backgroundQueue.getStats(),\n 'background queue stats',\n )\n }, 10000)\n await this.ctx.sequencer.start()\n const server = this.app.listen(this.ctx.cfg.service.port)\n this.server = server\n server.keepAliveTimeout = 90000\n this.terminator = createHttpTerminator({ server })\n await events.once(server, 'listening')\n const { port } = server.address() as AddressInfo\n this.ctx.assignPort(port)\n return server\n }\n\n async destroy(): Promise<void> {\n clearInterval(this.dbStatsInterval)\n this.dbStatsInterval = undefined\n\n // @TODO Use a disposable stack when Node24 becomes the min supported version\n try {\n await this.terminator?.terminate()\n } finally {\n try {\n await this.ctx.backgroundQueue.destroy()\n } finally {\n try {\n await this.ctx.sequencer.destroy()\n } finally {\n await this.ctx.db.close()\n }\n }\n }\n }\n}\n\nexport default OzoneService\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WebSocketKeepAlive } from '@atproto/ws-client';
|
|
2
1
|
type JetstreamRecord = Record<string, unknown>;
|
|
3
2
|
type OnCreateCallback<T extends JetstreamRecord> = (e: CommitCreateEvent<T>) => Promise<void>;
|
|
4
3
|
export type JetstreamOptions = {
|
|
@@ -42,7 +41,7 @@ export interface CommitDeleteEvent extends EventBase {
|
|
|
42
41
|
} & CommitBase;
|
|
43
42
|
}
|
|
44
43
|
export declare class Jetstream {
|
|
45
|
-
|
|
44
|
+
#private;
|
|
46
45
|
url: URL;
|
|
47
46
|
/** The current cursor. */
|
|
48
47
|
cursor?: number;
|
|
@@ -52,7 +51,9 @@ export declare class Jetstream {
|
|
|
52
51
|
onDelete?: Record<string, (e: CommitDeleteEvent) => Promise<void>>;
|
|
53
52
|
}): Promise<void>;
|
|
54
53
|
/**
|
|
55
|
-
*
|
|
54
|
+
* Ends the stream and closes the connection, resolving once it has closed: the
|
|
55
|
+
* abort tears the socket down, and the stream's own unwind is what tells us
|
|
56
|
+
* that finished. A close() before start() is an inert no-op.
|
|
56
57
|
*/
|
|
57
58
|
close(): Promise<void>;
|
|
58
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/jetstream/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/jetstream/service.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC9C,KAAK,gBAAgB,CAAC,CAAC,SAAS,eAAe,IAAI,CACjD,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,KACpB,OAAO,CAAC,IAAI,CAAC,CAAA;AAElB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AACD,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IAEf,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AACD,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AACD,MAAM,WAAW,iBAAiB,CAChC,UAAU,SAAS,eAAe,CAClC,SAAQ,SAAS;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE;QACN,SAAS,EAAE,QAAQ,CAAA;QACnB,MAAM,EAAE,UAAU,CAAA;KACnB,GAAG,UAAU,CAAA;CACf;AAED,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE;QACN,SAAS,EAAE,QAAQ,CAAA;KACpB,GAAG,UAAU,CAAA;CACf;AASD,qBAAa,SAAS;;IACb,GAAG,EAAE,GAAG,CAAA;IAIf,0BAA0B;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IAEtB,YAAY,IAAI,EAAE,gBAAgB,EASjC;IAEK,KAAK,CAAC,OAAO,EAAE;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAA;QAChD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;KACnE,iBAQA;IAqCD;;;;OAIG;IACG,KAAK,kBAGV;CACF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CloseCode, CloseError, websocket } from '@atproto/ws-client';
|
|
2
|
+
// The abort reason close() uses. Any abort closes the socket politely; a
|
|
3
|
+
// `CloseError` rather than a bare sentinel because the reason picks the close
|
|
4
|
+
// code sent to the peer — a CloseError names its own (1000 here), anything else
|
|
5
|
+
// defaults to 1000 anyway, so this spells the intent out. Its identity is also
|
|
6
|
+
// how start() tells our own shutdown from a real failure.
|
|
7
|
+
const STOPPED = new CloseError(CloseCode.Normal, 'jetstream stopped', true);
|
|
2
8
|
export class Jetstream {
|
|
9
|
+
#abort = new AbortController();
|
|
10
|
+
/** The `start()` run in flight, so `close()` can await its unwind. */
|
|
11
|
+
#running;
|
|
3
12
|
constructor(opts) {
|
|
4
13
|
this.url = new URL(opts.endpoint);
|
|
5
14
|
opts.wantedCollections?.forEach((collection) => {
|
|
@@ -12,34 +21,49 @@ export class Jetstream {
|
|
|
12
21
|
this.cursor = opts.cursor;
|
|
13
22
|
}
|
|
14
23
|
async start(options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
// Retained so close() resolves only once the stream has unwound, and with it
|
|
25
|
+
// the connection. Swallows its own outcome: a caller awaiting close() is
|
|
26
|
+
// asking about shutdown, not about how the stream ended — that's what the
|
|
27
|
+
// promise start() returns is for.
|
|
28
|
+
const running = this.#consume(options);
|
|
29
|
+
this.#running = running.catch(() => { });
|
|
30
|
+
return running;
|
|
31
|
+
}
|
|
32
|
+
async #consume(options) {
|
|
33
|
+
const ws = websocket(() => {
|
|
34
|
+
if (this.cursor)
|
|
35
|
+
this.url.searchParams.set('cursor', this.cursor.toString());
|
|
36
|
+
return this.url.toString();
|
|
37
|
+
}, { dataMode: 'text', signal: this.#abort.signal });
|
|
38
|
+
try {
|
|
39
|
+
for await (const message of ws) {
|
|
40
|
+
const parsedMessage = JSON.parse(message);
|
|
41
|
+
if (parsedMessage.kind === 'commit') {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- `record` is used via `typeof record` below
|
|
43
|
+
const { collection, operation, record } = parsedMessage.commit || {};
|
|
44
|
+
if (operation === 'create') {
|
|
45
|
+
options.onCreate?.[collection]?.(parsedMessage);
|
|
46
|
+
}
|
|
47
|
+
else if (operation === 'delete') {
|
|
48
|
+
options.onDelete?.[collection]?.(parsedMessage);
|
|
49
|
+
}
|
|
32
50
|
}
|
|
33
51
|
}
|
|
34
52
|
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
// Our own close() is not a failure; anything else is.
|
|
55
|
+
if (err !== STOPPED)
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
35
58
|
}
|
|
36
59
|
/**
|
|
37
|
-
*
|
|
60
|
+
* Ends the stream and closes the connection, resolving once it has closed: the
|
|
61
|
+
* abort tears the socket down, and the stream's own unwind is what tells us
|
|
62
|
+
* that finished. A close() before start() is an inert no-op.
|
|
38
63
|
*/
|
|
39
64
|
async close() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.ws?.ws?.close();
|
|
65
|
+
this.#abort.abort(STOPPED);
|
|
66
|
+
await this.#running;
|
|
43
67
|
}
|
|
44
68
|
}
|
|
45
69
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/jetstream/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/jetstream/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAqDrE,yEAAyE;AACzE,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,0DAA0D;AAC1D,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAA;AAE3E,MAAM,OAAO,SAAS;IAEX,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACvC,sEAAsE;IACtE,QAAQ,CAAgB;IAIxB,YAAY,IAAsB;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAA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/B,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBACzC,IAAI,aAAa,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACpC,2GAA2G;oBAC3G,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,MAAM,IAAI,EAAE,CAAA;oBAEpE,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;wBAC3B,OAAO,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,CAC9B,aAAiD,CAClD,CAAA;oBACH,CAAC;yBAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;wBAClC,OAAO,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,aAAkC,CAAC,CAAA;oBACtE,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,sDAAsD;YACtD,IAAI,GAAG,KAAK,OAAO;gBAAE,MAAM,GAAG,CAAA;QAChC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { CloseCode, CloseError, websocket } from '@atproto/ws-client'\n\ntype JetstreamRecord = Record<string, unknown>\ntype OnCreateCallback<T extends JetstreamRecord> = (\n e: CommitCreateEvent<T>,\n) => Promise<void>\n\nexport type JetstreamOptions = {\n endpoint: string\n /**\n * The record collections that you want to receive updates for.\n * Leave this empty to receive updates for all record collections.\n */\n wantedCollections?: string[]\n /**\n * The DIDs that you want to receive updates for.\n * Leave this empty to receive updates for all DIDs.\n */\n wantedDids?: string[]\n\n /**\n * The Unix timestamp in microseconds that you want to receive updates from.\n */\n cursor?: number\n}\nexport type EventBase = {\n did: string\n time_us: number\n // @TODO: Limited to just commit events for now\n kind: 'commit'\n}\nexport type CommitBase = {\n collection: string\n rkey: string\n cid: string\n}\nexport interface CommitCreateEvent<\n RecordType extends JetstreamRecord,\n> extends EventBase {\n kind: 'commit'\n commit: {\n operation: 'create'\n record: RecordType\n } & CommitBase\n}\n\nexport interface CommitDeleteEvent extends EventBase {\n kind: 'commit'\n commit: {\n operation: 'delete'\n } & CommitBase\n}\n\n// The abort reason close() uses. Any abort closes the socket politely; a\n// `CloseError` rather than a bare sentinel because the reason picks the close\n// code sent to the peer — a CloseError names its own (1000 here), anything else\n// defaults to 1000 anyway, so this spells the intent out. Its identity is also\n// how start() tells our own shutdown from a real failure.\nconst STOPPED = new CloseError(CloseCode.Normal, 'jetstream stopped', true)\n\nexport class Jetstream {\n public url: URL\n readonly #abort = new AbortController()\n /** The `start()` run in flight, so `close()` can await its unwind. */\n #running?: Promise<void>\n /** The current cursor. */\n public cursor?: number\n\n constructor(opts: JetstreamOptions) {\n this.url = new URL(opts.endpoint)\n opts.wantedCollections?.forEach((collection) => {\n this.url.searchParams.append('wantedCollections', collection)\n })\n opts.wantedDids?.forEach((did) => {\n this.url.searchParams.append('wantedDids', did)\n })\n if (opts.cursor) this.cursor = opts.cursor\n }\n\n async start(options: {\n onCreate?: Record<string, OnCreateCallback<any>>\n onDelete?: Record<string, (e: CommitDeleteEvent) => Promise<void>>\n }) {\n // Retained so close() resolves only once the stream has unwound, and with it\n // the connection. Swallows its own outcome: a caller awaiting close() is\n // asking about shutdown, not about how the stream ended — that's what the\n // promise start() returns is for.\n const running = this.#consume(options)\n this.#running = running.catch(() => {})\n return running\n }\n\n async #consume(options: {\n onCreate?: Record<string, OnCreateCallback<any>>\n onDelete?: Record<string, (e: CommitDeleteEvent) => Promise<void>>\n }) {\n const ws = websocket(\n () => {\n if (this.cursor)\n this.url.searchParams.set('cursor', this.cursor.toString())\n return this.url.toString()\n },\n { dataMode: 'text', signal: this.#abort.signal },\n )\n\n try {\n for await (const message of ws) {\n const parsedMessage = JSON.parse(message)\n if (parsedMessage.kind === 'commit') {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- `record` is used via `typeof record` below\n const { collection, operation, record } = parsedMessage.commit || {}\n\n if (operation === 'create') {\n options.onCreate?.[collection]?.(\n parsedMessage as CommitCreateEvent<typeof record>,\n )\n } else if (operation === 'delete') {\n options.onDelete?.[collection]?.(parsedMessage as CommitDeleteEvent)\n }\n }\n }\n } catch (err) {\n // Our own close() is not a failure; anything else is.\n if (err !== STOPPED) throw err\n }\n }\n\n /**\n * Ends the stream and closes the connection, resolving once it has closed: the\n * abort tears the socket down, and the stream's own unwind is what tells us\n * that finished. A close() before start() is an inert no-op.\n */\n async close() {\n this.#abort.abort(STOPPED)\n await this.#running\n }\n}\n"]}
|