@atproto/bsync 0.0.0-spaces-alpha-20260818021221
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 +339 -0
- package/LICENSE.txt +7 -0
- package/README.md +15 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +12 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +45 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +25 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +21 -0
- package/dist/context.js.map +1 -0
- package/dist/db/index.d.ts +32 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +150 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations/20240108T220751294Z-init.d.ts +4 -0
- package/dist/db/migrations/20240108T220751294Z-init.d.ts.map +1 -0
- package/dist/db/migrations/20240108T220751294Z-init.js +23 -0
- package/dist/db/migrations/20240108T220751294Z-init.js.map +1 -0
- package/dist/db/migrations/20240717T224303472Z-notif-ops.d.ts +4 -0
- package/dist/db/migrations/20240717T224303472Z-notif-ops.d.ts.map +1 -0
- package/dist/db/migrations/20240717T224303472Z-notif-ops.js +21 -0
- package/dist/db/migrations/20240717T224303472Z-notif-ops.js.map +1 -0
- package/dist/db/migrations/20250527T022203400Z-add-operation.d.ts +4 -0
- package/dist/db/migrations/20250527T022203400Z-add-operation.d.ts.map +1 -0
- package/dist/db/migrations/20250527T022203400Z-add-operation.js +17 -0
- package/dist/db/migrations/20250527T022203400Z-add-operation.js.map +1 -0
- package/dist/db/migrations/20250603T163446567Z-alter-operation.d.ts +4 -0
- package/dist/db/migrations/20250603T163446567Z-alter-operation.d.ts.map +1 -0
- package/dist/db/migrations/20250603T163446567Z-alter-operation.js +15 -0
- package/dist/db/migrations/20250603T163446567Z-alter-operation.js.map +1 -0
- package/dist/db/migrations/20260618T200000000Z-add-mute-scope.d.ts +4 -0
- package/dist/db/migrations/20260618T200000000Z-add-mute-scope.d.ts.map +1 -0
- package/dist/db/migrations/20260618T200000000Z-add-mute-scope.js +27 -0
- package/dist/db/migrations/20260618T200000000Z-add-mute-scope.js.map +1 -0
- package/dist/db/migrations/index.d.ts +6 -0
- package/dist/db/migrations/index.d.ts.map +1 -0
- package/dist/db/migrations/index.js +9 -0
- package/dist/db/migrations/index.js.map +1 -0
- package/dist/db/migrations/provider.d.ts +7 -0
- package/dist/db/migrations/provider.d.ts.map +1 -0
- package/dist/db/migrations/provider.js +9 -0
- package/dist/db/migrations/provider.js.map +1 -0
- package/dist/db/schema/index.d.ts +9 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema/index.js +2 -0
- package/dist/db/schema/index.js.map +1 -0
- package/dist/db/schema/mute_item.d.ts +14 -0
- package/dist/db/schema/mute_item.d.ts.map +1 -0
- package/dist/db/schema/mute_item.js +2 -0
- package/dist/db/schema/mute_item.js.map +1 -0
- package/dist/db/schema/mute_op.d.ts +18 -0
- package/dist/db/schema/mute_op.d.ts.map +1 -0
- package/dist/db/schema/mute_op.js +3 -0
- package/dist/db/schema/mute_op.js.map +1 -0
- package/dist/db/schema/notif_item.d.ts +12 -0
- package/dist/db/schema/notif_item.d.ts.map +1 -0
- package/dist/db/schema/notif_item.js +2 -0
- package/dist/db/schema/notif_item.js.map +1 -0
- package/dist/db/schema/notif_op.d.ts +14 -0
- package/dist/db/schema/notif_op.d.ts.map +1 -0
- package/dist/db/schema/notif_op.js +3 -0
- package/dist/db/schema/notif_op.js.map +1 -0
- package/dist/db/schema/operation.d.ts +18 -0
- package/dist/db/schema/operation.d.ts.map +1 -0
- package/dist/db/schema/operation.js +3 -0
- package/dist/db/schema/operation.js.map +1 -0
- package/dist/db/types.d.ts +15 -0
- package/dist/db/types.d.ts.map +1 -0
- package/dist/db/types.js +2 -0
- package/dist/db/types.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +6 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +22 -0
- package/dist/logger.js.map +1 -0
- package/dist/proto/bsync_connect.d.ts +87 -0
- package/dist/proto/bsync_connect.d.ts.map +1 -0
- package/dist/proto/bsync_connect.js +91 -0
- package/dist/proto/bsync_connect.js.map +1 -0
- package/dist/proto/bsync_pb.d.ts +481 -0
- package/dist/proto/bsync_pb.d.ts.map +1 -0
- package/dist/proto/bsync_pb.js +751 -0
- package/dist/proto/bsync_pb.js.map +1 -0
- package/dist/routes/add-mute-operation.d.ts +6 -0
- package/dist/routes/add-mute-operation.d.ts.map +1 -0
- package/dist/routes/add-mute-operation.js +128 -0
- package/dist/routes/add-mute-operation.js.map +1 -0
- package/dist/routes/add-notif-operation.d.ts +6 -0
- package/dist/routes/add-notif-operation.d.ts.map +1 -0
- package/dist/routes/add-notif-operation.js +61 -0
- package/dist/routes/add-notif-operation.js.map +1 -0
- package/dist/routes/auth.d.ts +4 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +13 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/delete-operations.d.ts +6 -0
- package/dist/routes/delete-operations.d.ts.map +1 -0
- package/dist/routes/delete-operations.js +36 -0
- package/dist/routes/delete-operations.js.map +1 -0
- package/dist/routes/index.d.ts +5 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +26 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/put-operation.d.ts +6 -0
- package/dist/routes/put-operation.d.ts.map +1 -0
- package/dist/routes/put-operation.js +78 -0
- package/dist/routes/put-operation.js.map +1 -0
- package/dist/routes/scan-mute-operations.d.ts +6 -0
- package/dist/routes/scan-mute-operations.d.ts.map +1 -0
- package/dist/routes/scan-mute-operations.js +57 -0
- package/dist/routes/scan-mute-operations.js.map +1 -0
- package/dist/routes/scan-notif-operations.d.ts +6 -0
- package/dist/routes/scan-notif-operations.d.ts.map +1 -0
- package/dist/routes/scan-notif-operations.js +54 -0
- package/dist/routes/scan-notif-operations.js.map +1 -0
- package/dist/routes/scan-operations.d.ts +6 -0
- package/dist/routes/scan-operations.d.ts.map +1 -0
- package/dist/routes/scan-operations.js +57 -0
- package/dist/routes/scan-operations.js.map +1 -0
- package/dist/routes/util.d.ts +6 -0
- package/dist/routes/util.d.ts.map +1 -0
- package/dist/routes/util.js +58 -0
- package/dist/routes/util.js.map +1 -0
- package/package.json +61 -0
package/dist/db/index.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { Kysely, PostgresDialect, } from 'kysely';
|
|
4
|
+
import { Migrator } from 'kysely/migration';
|
|
5
|
+
import pg from 'pg';
|
|
6
|
+
const { Pool: PgPool, types: pgTypes } = pg;
|
|
7
|
+
import { dbLogger } from '../logger.js';
|
|
8
|
+
import * as migrations from './migrations/index.js';
|
|
9
|
+
import { DbMigrationProvider } from './migrations/provider.js';
|
|
10
|
+
export class Database {
|
|
11
|
+
constructor(opts, instances) {
|
|
12
|
+
this.opts = opts;
|
|
13
|
+
this.txEvt = new EventEmitter();
|
|
14
|
+
this.destroyed = false;
|
|
15
|
+
// if instances are provided, use those
|
|
16
|
+
if (instances) {
|
|
17
|
+
this.db = instances.db;
|
|
18
|
+
this.pool = instances.pool;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// else create a pool & connect
|
|
22
|
+
const { schema, url } = opts;
|
|
23
|
+
const pool = opts.pool ??
|
|
24
|
+
new PgPool({
|
|
25
|
+
connectionString: url,
|
|
26
|
+
max: opts.poolSize,
|
|
27
|
+
maxUses: opts.poolMaxUses,
|
|
28
|
+
idleTimeoutMillis: opts.poolIdleTimeoutMs,
|
|
29
|
+
});
|
|
30
|
+
// Select count(*) and other pg bigints as js integer
|
|
31
|
+
pgTypes.setTypeParser(pgTypes.builtins.INT8, (n) => parseInt(n, 10));
|
|
32
|
+
// Setup schema usage, primarily for test parallelism (each test suite runs in its own pg schema)
|
|
33
|
+
if (schema && !/^[a-z_]+$/i.test(schema)) {
|
|
34
|
+
throw new Error(`Postgres schema must only contain [A-Za-z_]: ${schema}`);
|
|
35
|
+
}
|
|
36
|
+
pool.on('error', onPoolError);
|
|
37
|
+
pool.on('connect', (client) => {
|
|
38
|
+
client.on('error', onClientError);
|
|
39
|
+
if (schema) {
|
|
40
|
+
// Shared objects such as extensions will go in the public schema
|
|
41
|
+
client.query(`SET search_path TO "${schema}",public;`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.pool = pool;
|
|
45
|
+
this.db = new Kysely({
|
|
46
|
+
dialect: new PostgresDialect({ pool }),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
this.migrator = new Migrator({
|
|
50
|
+
db: this.db,
|
|
51
|
+
migrationTableSchema: opts.schema,
|
|
52
|
+
provider: new DbMigrationProvider(migrations),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
get schema() {
|
|
56
|
+
return this.opts.schema;
|
|
57
|
+
}
|
|
58
|
+
get isTransaction() {
|
|
59
|
+
return this.db.isTransaction;
|
|
60
|
+
}
|
|
61
|
+
assertTransaction() {
|
|
62
|
+
assert(this.isTransaction, 'Transaction required');
|
|
63
|
+
}
|
|
64
|
+
assertNotTransaction() {
|
|
65
|
+
assert(!this.isTransaction, 'Cannot be in a transaction');
|
|
66
|
+
}
|
|
67
|
+
async transaction(fn) {
|
|
68
|
+
const leakyTxPlugin = new LeakyTxPlugin();
|
|
69
|
+
const { dbTxn, txRes } = await this.db
|
|
70
|
+
.withPlugin(leakyTxPlugin)
|
|
71
|
+
.transaction()
|
|
72
|
+
.execute(async (txn) => {
|
|
73
|
+
const dbTxn = new Database(this.opts, {
|
|
74
|
+
db: txn,
|
|
75
|
+
pool: this.pool,
|
|
76
|
+
});
|
|
77
|
+
const txRes = await fn(dbTxn)
|
|
78
|
+
.catch(async (err) => {
|
|
79
|
+
leakyTxPlugin.endTx();
|
|
80
|
+
// ensure that all in-flight queries are flushed & the connection is open
|
|
81
|
+
await dbTxn.db.getExecutor().provideConnection(noopAsync);
|
|
82
|
+
throw err;
|
|
83
|
+
})
|
|
84
|
+
.finally(() => leakyTxPlugin.endTx());
|
|
85
|
+
return { dbTxn, txRes };
|
|
86
|
+
});
|
|
87
|
+
dbTxn?.txEvt.emit('commit');
|
|
88
|
+
return txRes;
|
|
89
|
+
}
|
|
90
|
+
onCommit(fn) {
|
|
91
|
+
this.assertTransaction();
|
|
92
|
+
this.txEvt.once('commit', fn);
|
|
93
|
+
}
|
|
94
|
+
async close() {
|
|
95
|
+
if (this.destroyed)
|
|
96
|
+
return;
|
|
97
|
+
await this.db.destroy();
|
|
98
|
+
this.destroyed = true;
|
|
99
|
+
}
|
|
100
|
+
async migrateToOrThrow(migration) {
|
|
101
|
+
if (this.schema) {
|
|
102
|
+
await this.db.schema.createSchema(this.schema).ifNotExists().execute();
|
|
103
|
+
}
|
|
104
|
+
const { error, results } = await this.migrator.migrateTo(migration);
|
|
105
|
+
if (error) {
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
if (!results) {
|
|
109
|
+
throw new Error('An unknown failure occurred while migrating');
|
|
110
|
+
}
|
|
111
|
+
return results;
|
|
112
|
+
}
|
|
113
|
+
async migrateToLatestOrThrow() {
|
|
114
|
+
if (this.schema) {
|
|
115
|
+
await this.db.schema.createSchema(this.schema).ifNotExists().execute();
|
|
116
|
+
}
|
|
117
|
+
const { error, results } = await this.migrator.migrateToLatest();
|
|
118
|
+
if (error) {
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
if (!results) {
|
|
122
|
+
throw new Error('An unknown failure occurred while migrating');
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export default Database;
|
|
128
|
+
const onPoolError = (err) => dbLogger.error({ err }, 'db pool error');
|
|
129
|
+
const onClientError = (err) => dbLogger.error({ err }, 'db client error');
|
|
130
|
+
// utils
|
|
131
|
+
// -------
|
|
132
|
+
class LeakyTxPlugin {
|
|
133
|
+
constructor() {
|
|
134
|
+
this.txOver = false;
|
|
135
|
+
}
|
|
136
|
+
endTx() {
|
|
137
|
+
this.txOver = true;
|
|
138
|
+
}
|
|
139
|
+
transformQuery(args) {
|
|
140
|
+
if (this.txOver) {
|
|
141
|
+
throw new Error('tx already failed');
|
|
142
|
+
}
|
|
143
|
+
return args.node;
|
|
144
|
+
}
|
|
145
|
+
async transformResult(args) {
|
|
146
|
+
return args.result;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const noopAsync = async () => { };
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAI9D,MAAM,OAAO,QAAQ;IAOnB,YACS,IAAe,EACtB,SAAgD;QADzC,SAAI,GAAJ,IAAI,CAAW;QAJxB,UAAK,GAAG,IAAI,YAAY,EAAa,CAAA;QACrC,cAAS,GAAG,KAAK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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 { DbMigrationProvider } from './migrations/provider.js'\nimport type { DatabaseSchema, DatabaseSchemaType } from './schema/index.js'\nimport type { PgOptions } from './types.js'\n\nexport class Database {\n pool: PgPool\n db: DatabaseSchema\n migrator: Migrator\n txEvt = new EventEmitter<TxnEvents>()\n destroyed = 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 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 DbMigrationProvider(migrations),\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20240108T220751294Z-init.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20240108T220751294Z-init.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,CAkB3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.createTable('mute_op')
|
|
5
|
+
.addColumn('id', 'bigserial', (col) => col.primaryKey())
|
|
6
|
+
.addColumn('type', 'int2', (col) => col.notNull()) // integer enum: 0->add, 1->remove, 2->clear
|
|
7
|
+
.addColumn('actorDid', 'varchar', (col) => col.notNull())
|
|
8
|
+
.addColumn('subject', 'varchar', (col) => col.notNull())
|
|
9
|
+
.addColumn('createdAt', 'timestamptz', (col) => col.notNull().defaultTo(sql `CURRENT_TIMESTAMP`))
|
|
10
|
+
.execute();
|
|
11
|
+
await db.schema
|
|
12
|
+
.createTable('mute_item')
|
|
13
|
+
.addColumn('actorDid', 'varchar', (col) => col.notNull())
|
|
14
|
+
.addColumn('subject', 'varchar', (col) => col.notNull())
|
|
15
|
+
.addColumn('fromId', 'bigint', (col) => col.notNull())
|
|
16
|
+
.addPrimaryKeyConstraint('mute_item_pkey', ['actorDid', 'subject'])
|
|
17
|
+
.execute();
|
|
18
|
+
}
|
|
19
|
+
export async function down(db) {
|
|
20
|
+
await db.schema.dropTable('mute_item').execute();
|
|
21
|
+
await db.schema.dropTable('mute_op').execute();
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=20240108T220751294Z-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20240108T220751294Z-init.js","sourceRoot":"","sources":["../../../src/db/migrations/20240108T220751294Z-init.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,WAAW,CAAC,SAAS,CAAC;SACtB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACvD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,4CAA4C;SAC9F,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACvD,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,mBAAmB,CAAC,CAChD;SACA,OAAO,EAAE,CAAA;IACZ,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,WAAW,CAAC;SACxB,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACvD,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACrD,uBAAuB,CAAC,gBAAgB,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;SAClE,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAA;IAChD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAA;AAChD,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .createTable('mute_op')\n .addColumn('id', 'bigserial', (col) => col.primaryKey())\n .addColumn('type', 'int2', (col) => col.notNull()) // integer enum: 0->add, 1->remove, 2->clear\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('subject', 'varchar', (col) => col.notNull())\n .addColumn('createdAt', 'timestamptz', (col) =>\n col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`),\n )\n .execute()\n await db.schema\n .createTable('mute_item')\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('subject', 'varchar', (col) => col.notNull())\n .addColumn('fromId', 'bigint', (col) => col.notNull())\n .addPrimaryKeyConstraint('mute_item_pkey', ['actorDid', 'subject'])\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropTable('mute_item').execute()\n await db.schema.dropTable('mute_op').execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20240717T224303472Z-notif-ops.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20240717T224303472Z-notif-ops.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,CAgB3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.createTable('notif_op')
|
|
5
|
+
.addColumn('id', 'bigserial', (col) => col.primaryKey())
|
|
6
|
+
.addColumn('actorDid', 'varchar', (col) => col.notNull())
|
|
7
|
+
.addColumn('priority', 'boolean')
|
|
8
|
+
.addColumn('createdAt', 'timestamptz', (col) => col.notNull().defaultTo(sql `CURRENT_TIMESTAMP`))
|
|
9
|
+
.execute();
|
|
10
|
+
await db.schema
|
|
11
|
+
.createTable('notif_item')
|
|
12
|
+
.addColumn('actorDid', 'varchar', (col) => col.primaryKey())
|
|
13
|
+
.addColumn('priority', 'boolean', (col) => col.notNull())
|
|
14
|
+
.addColumn('fromId', 'bigint', (col) => col.notNull())
|
|
15
|
+
.execute();
|
|
16
|
+
}
|
|
17
|
+
export async function down(db) {
|
|
18
|
+
await db.schema.dropTable('notif_item').execute();
|
|
19
|
+
await db.schema.dropTable('notif_op').execute();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=20240717T224303472Z-notif-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20240717T224303472Z-notif-ops.js","sourceRoot":"","sources":["../../../src/db/migrations/20240717T224303472Z-notif-ops.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,WAAW,CAAC,UAAU,CAAC;SACvB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACvD,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC;SAChC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,mBAAmB,CAAC,CAChD;SACA,OAAO,EAAE,CAAA;IACZ,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,YAAY,CAAC;SACzB,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SAC3D,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACrD,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAA;IACjD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAA;AACjD,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .createTable('notif_op')\n .addColumn('id', 'bigserial', (col) => col.primaryKey())\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('priority', 'boolean')\n .addColumn('createdAt', 'timestamptz', (col) =>\n col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`),\n )\n .execute()\n await db.schema\n .createTable('notif_item')\n .addColumn('actorDid', 'varchar', (col) => col.primaryKey())\n .addColumn('priority', 'boolean', (col) => col.notNull())\n .addColumn('fromId', 'bigint', (col) => col.notNull())\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropTable('notif_item').execute()\n await db.schema.dropTable('notif_op').execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20250527T022203400Z-add-operation.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.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,CAa3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.createTable('operation')
|
|
5
|
+
.addColumn('id', 'bigserial', (col) => col.primaryKey())
|
|
6
|
+
.addColumn('collection', 'varchar', (col) => col.notNull())
|
|
7
|
+
.addColumn('actorDid', 'varchar', (col) => col.notNull())
|
|
8
|
+
.addColumn('rkey', 'varchar', (col) => col.notNull())
|
|
9
|
+
.addColumn('method', 'int2', (col) => col.notNull())
|
|
10
|
+
.addColumn('payload', sql `bytea`)
|
|
11
|
+
.addColumn('createdAt', 'timestamptz', (col) => col.notNull().defaultTo(sql `CURRENT_TIMESTAMP`))
|
|
12
|
+
.execute();
|
|
13
|
+
}
|
|
14
|
+
export async function down(db) {
|
|
15
|
+
await db.schema.dropTable('operation').execute();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=20250527T022203400Z-add-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20250527T022203400Z-add-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.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,WAAW,CAAC,WAAW,CAAC;SACxB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACvD,SAAS,CAAC,YAAY,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SAC1D,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACpD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACnD,SAAS,CAAC,SAAS,EAAE,GAAG,CAAA,OAAO,CAAC;SAChC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,mBAAmB,CAAC,CAChD;SACA,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAA;AAClD,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .createTable('operation')\n .addColumn('id', 'bigserial', (col) => col.primaryKey())\n .addColumn('collection', 'varchar', (col) => col.notNull())\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('rkey', 'varchar', (col) => col.notNull())\n .addColumn('method', 'int2', (col) => col.notNull())\n .addColumn('payload', sql`bytea`)\n .addColumn('createdAt', 'timestamptz', (col) =>\n col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`),\n )\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropTable('operation').execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20250603T163446567Z-alter-operation.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,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,CAO7D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export async function up(db) {
|
|
2
|
+
await db.schema
|
|
3
|
+
.alterTable('operation')
|
|
4
|
+
.renameColumn('collection', 'namespace')
|
|
5
|
+
.execute();
|
|
6
|
+
await db.schema.alterTable('operation').renameColumn('rkey', 'key').execute();
|
|
7
|
+
}
|
|
8
|
+
export async function down(db) {
|
|
9
|
+
await db.schema
|
|
10
|
+
.alterTable('operation')
|
|
11
|
+
.renameColumn('namespace', 'collection')
|
|
12
|
+
.execute();
|
|
13
|
+
await db.schema.alterTable('operation').renameColumn('key', 'rkey').execute();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=20250603T163446567Z-alter-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20250603T163446567Z-alter-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC;SACvC,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC;SACvC,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/E,CAAC","sourcesContent":["import type { Kysely } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('operation')\n .renameColumn('collection', 'namespace')\n .execute()\n\n await db.schema.alterTable('operation').renameColumn('rkey', 'key').execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('operation')\n .renameColumn('namespace', 'collection')\n .execute()\n\n await db.schema.alterTable('operation').renameColumn('key', 'rkey').execute()\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260618T200000000Z-add-mute-scope.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20260618T200000000Z-add-mute-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAW7D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// scope restrictions: when any is set, just the scoped content is muted;
|
|
2
|
+
// when none are set, the subject is fully muted
|
|
3
|
+
export async function up(db) {
|
|
4
|
+
await db.schema
|
|
5
|
+
.alterTable('mute_op')
|
|
6
|
+
.addColumn('onlyReposts', 'boolean', (col) => col.notNull().defaultTo(false))
|
|
7
|
+
.addColumn('onlyQuoteposts', 'boolean', (col) => col.notNull().defaultTo(false))
|
|
8
|
+
.execute();
|
|
9
|
+
await db.schema
|
|
10
|
+
.alterTable('mute_item')
|
|
11
|
+
.addColumn('onlyReposts', 'boolean', (col) => col.notNull().defaultTo(false))
|
|
12
|
+
.addColumn('onlyQuoteposts', 'boolean', (col) => col.notNull().defaultTo(false))
|
|
13
|
+
.execute();
|
|
14
|
+
}
|
|
15
|
+
export async function down(db) {
|
|
16
|
+
await db.schema
|
|
17
|
+
.alterTable('mute_item')
|
|
18
|
+
.dropColumn('onlyReposts')
|
|
19
|
+
.dropColumn('onlyQuoteposts')
|
|
20
|
+
.execute();
|
|
21
|
+
await db.schema
|
|
22
|
+
.alterTable('mute_op')
|
|
23
|
+
.dropColumn('onlyReposts')
|
|
24
|
+
.dropColumn('onlyQuoteposts')
|
|
25
|
+
.execute();
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=20260618T200000000Z-add-mute-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20260618T200000000Z-add-mute-scope.js","sourceRoot":"","sources":["../../../src/db/migrations/20260618T200000000Z-add-mute-scope.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,gDAAgD;AAChD,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,SAAS,CAAC;SACrB,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAC3C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAC/B;SACA,SAAS,CAAC,gBAAgB,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAC9C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAC/B;SACA,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAC3C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAC/B;SACA,SAAS,CAAC,gBAAgB,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAC9C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAC/B;SACA,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,UAAU,CAAC,aAAa,CAAC;SACzB,UAAU,CAAC,gBAAgB,CAAC;SAC5B,OAAO,EAAE,CAAA;IACZ,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,SAAS,CAAC;SACrB,UAAU,CAAC,aAAa,CAAC;SACzB,UAAU,CAAC,gBAAgB,CAAC;SAC5B,OAAO,EAAE,CAAA;AACd,CAAC","sourcesContent":["import type { Kysely } from 'kysely'\n\n// scope restrictions: when any is set, just the scoped content is muted;\n// when none are set, the subject is fully muted\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('mute_op')\n .addColumn('onlyReposts', 'boolean', (col) =>\n col.notNull().defaultTo(false),\n )\n .addColumn('onlyQuoteposts', 'boolean', (col) =>\n col.notNull().defaultTo(false),\n )\n .execute()\n\n await db.schema\n .alterTable('mute_item')\n .addColumn('onlyReposts', 'boolean', (col) =>\n col.notNull().defaultTo(false),\n )\n .addColumn('onlyQuoteposts', 'boolean', (col) =>\n col.notNull().defaultTo(false),\n )\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('mute_item')\n .dropColumn('onlyReposts')\n .dropColumn('onlyQuoteposts')\n .execute()\n await db.schema\n .alterTable('mute_op')\n .dropColumn('onlyReposts')\n .dropColumn('onlyQuoteposts')\n .execute()\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as _20240108T220751294Z from './20240108T220751294Z-init.js';
|
|
2
|
+
export * as _20240717T224303472Z from './20240717T224303472Z-notif-ops.js';
|
|
3
|
+
export * as _20250527T022203400Z from './20250527T022203400Z-add-operation.js';
|
|
4
|
+
export * as _20250603T163446567Z from './20250603T163446567Z-alter-operation.js';
|
|
5
|
+
export * as _20260618T200000000Z from './20260618T200000000Z-add-mute-scope.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,oCAAoC,CAAA;AAC1E,OAAO,KAAK,oBAAoB,MAAM,wCAAwC,CAAA;AAC9E,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.
|
|
2
|
+
// It's important that every migration is exported from here with the proper name. We'd simplify
|
|
3
|
+
// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.
|
|
4
|
+
export * as _20240108T220751294Z from './20240108T220751294Z-init.js';
|
|
5
|
+
export * as _20240717T224303472Z from './20240717T224303472Z-notif-ops.js';
|
|
6
|
+
export * as _20250527T022203400Z from './20250527T022203400Z-add-operation.js';
|
|
7
|
+
export * as _20250603T163446567Z from './20250603T163446567Z-alter-operation.js';
|
|
8
|
+
export * as _20260618T200000000Z from './20260618T200000000Z-add-mute-scope.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,oCAAoC,CAAA;AAC1E,OAAO,KAAK,oBAAoB,MAAM,wCAAwC,CAAA;AAC9E,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA;AAChF,OAAO,KAAK,oBAAoB,MAAM,yCAAyC,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 _20240108T220751294Z from './20240108T220751294Z-init.js'\nexport * as _20240717T224303472Z from './20240717T224303472Z-notif-ops.js'\nexport * as _20250527T022203400Z from './20250527T022203400Z-add-operation.js'\nexport * as _20250603T163446567Z from './20250603T163446567Z-alter-operation.js'\nexport * as _20260618T200000000Z from './20260618T200000000Z-add-mute-scope.js'\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Migration, MigrationProvider } from 'kysely/migration';
|
|
2
|
+
export declare class DbMigrationProvider implements MigrationProvider {
|
|
3
|
+
private migrations;
|
|
4
|
+
constructor(migrations: Record<string, Migration>);
|
|
5
|
+
getMigrations(): Promise<Record<string, Migration>>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC/C,OAAO,CAAC,UAAU;IAA9B,YAAoB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAI;IACvD,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAExD;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,UAAqC;0BAArC,UAAU;IAA8B,CAAC;IAC7D,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF","sourcesContent":["import type { Migration, MigrationProvider } from 'kysely/migration'\n\nexport class DbMigrationProvider implements MigrationProvider {\n constructor(private migrations: Record<string, Migration>) {}\n async getMigrations(): Promise<Record<string, Migration>> {\n return this.migrations\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import type * as muteItem from './mute_item.js';
|
|
3
|
+
import type * as muteOp from './mute_op.js';
|
|
4
|
+
import type * as notifItem from './notif_item.js';
|
|
5
|
+
import type * as notifOp from './notif_op.js';
|
|
6
|
+
import type * as op from './operation.js';
|
|
7
|
+
export type DatabaseSchemaType = muteItem.PartialDB & muteOp.PartialDB & notifItem.PartialDB & notifOp.PartialDB & op.PartialDB;
|
|
8
|
+
export type DatabaseSchema = Kysely<DatabaseSchemaType>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,SAAS,GACjD,MAAM,CAAC,SAAS,GAChB,SAAS,CAAC,SAAS,GACnB,OAAO,CAAC,SAAS,GACjB,EAAE,CAAC,SAAS,CAAA;AAEd,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { Kysely } from 'kysely'\nimport type * as muteItem from './mute_item.js'\nimport type * as muteOp from './mute_op.js'\nimport type * as notifItem from './notif_item.js'\nimport type * as notifOp from './notif_op.js'\nimport type * as op from './operation.js'\n\nexport type DatabaseSchemaType = muteItem.PartialDB &\n muteOp.PartialDB &\n notifItem.PartialDB &\n notifOp.PartialDB &\n op.PartialDB\n\nexport type DatabaseSchema = Kysely<DatabaseSchemaType>\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Selectable } from 'kysely';
|
|
2
|
+
export interface MuteItem {
|
|
3
|
+
actorDid: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
fromId: number;
|
|
6
|
+
onlyReposts: boolean;
|
|
7
|
+
onlyQuoteposts: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type MuteItemEntry = Selectable<MuteItem>;
|
|
10
|
+
export declare const tableName = "mute_item";
|
|
11
|
+
export type PartialDB = {
|
|
12
|
+
[tableName]: MuteItem;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=mute_item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mute_item.d.ts","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IAGd,WAAW,EAAE,OAAO,CAAA;IACpB,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;AAEhD,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mute_item.js","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA","sourcesContent":["import type { Selectable } from 'kysely'\n\nexport interface MuteItem {\n actorDid: string\n subject: string // did or aturi for list\n fromId: number\n // scope restrictions: when any is set, just the scoped content is muted;\n // when none are set, the subject is fully muted\n onlyReposts: boolean\n onlyQuoteposts: boolean\n}\n\nexport type MuteItemEntry = Selectable<MuteItem>\n\nexport const tableName = 'mute_item'\n\nexport type PartialDB = { [tableName]: MuteItem }\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GeneratedAlways, Selectable } from 'kysely';
|
|
2
|
+
import type { MuteOperation_Type } from '../../proto/bsync_pb.js';
|
|
3
|
+
export interface MuteOp {
|
|
4
|
+
id: GeneratedAlways<number>;
|
|
5
|
+
type: MuteOperation_Type;
|
|
6
|
+
actorDid: string;
|
|
7
|
+
subject: string;
|
|
8
|
+
onlyReposts: boolean;
|
|
9
|
+
onlyQuoteposts: boolean;
|
|
10
|
+
createdAt: GeneratedAlways<Date>;
|
|
11
|
+
}
|
|
12
|
+
export type MuteOpEntry = Selectable<MuteOp>;
|
|
13
|
+
export declare const tableName = "mute_op";
|
|
14
|
+
export type PartialDB = {
|
|
15
|
+
[tableName]: MuteOp;
|
|
16
|
+
};
|
|
17
|
+
export declare const createMuteOpChannel = "mute_op_create";
|
|
18
|
+
//# sourceMappingURL=mute_op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mute_op.d.ts","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,kBAAkB,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IAGf,WAAW,EAAE,OAAO,CAAA;IACpB,cAAc,EAAE,OAAO,CAAA;IACvB,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;CACjC;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;AAE5C,eAAO,MAAM,SAAS,YAAY,CAAA;AAElC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/C,eAAO,MAAM,mBAAmB,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mute_op.js","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AAIlC,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA,CAAC,0BAA0B","sourcesContent":["import type { GeneratedAlways, Selectable } from 'kysely'\nimport type { MuteOperation_Type } from '../../proto/bsync_pb.js'\n\nexport interface MuteOp {\n id: GeneratedAlways<number>\n type: MuteOperation_Type // integer enum: 0->add, 1->remove, 2->clear\n actorDid: string\n subject: string // did or aturi for list\n // scope restrictions: when any is set, just the scoped content is muted;\n // when none are set, the subject is fully muted\n onlyReposts: boolean\n onlyQuoteposts: boolean\n createdAt: GeneratedAlways<Date>\n}\n\nexport type MuteOpEntry = Selectable<MuteOp>\n\nexport const tableName = 'mute_op'\n\nexport type PartialDB = { [tableName]: MuteOp }\n\nexport const createMuteOpChannel = 'mute_op_create' // used with listen/notify\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Selectable } from 'kysely';
|
|
2
|
+
export interface NotifItem {
|
|
3
|
+
actorDid: string;
|
|
4
|
+
priority: boolean;
|
|
5
|
+
fromId: number;
|
|
6
|
+
}
|
|
7
|
+
export type NotifItemEntry = Selectable<NotifItem>;
|
|
8
|
+
export declare const tableName = "notif_item";
|
|
9
|
+
export type PartialDB = {
|
|
10
|
+
[tableName]: NotifItem;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=notif_item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notif_item.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;AAElD,eAAO,MAAM,SAAS,eAAe,CAAA;AAErC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notif_item.js","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA","sourcesContent":["import type { Selectable } from 'kysely'\n\nexport interface NotifItem {\n actorDid: string\n priority: boolean\n fromId: number\n}\n\nexport type NotifItemEntry = Selectable<NotifItem>\n\nexport const tableName = 'notif_item'\n\nexport type PartialDB = { [tableName]: NotifItem }\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GeneratedAlways, Selectable } from 'kysely';
|
|
2
|
+
export interface NotifOp {
|
|
3
|
+
id: GeneratedAlways<number>;
|
|
4
|
+
actorDid: string;
|
|
5
|
+
priority: boolean | null;
|
|
6
|
+
createdAt: GeneratedAlways<Date>;
|
|
7
|
+
}
|
|
8
|
+
export type NotifOpEntry = Selectable<NotifOp>;
|
|
9
|
+
export declare const tableName = "notif_op";
|
|
10
|
+
export type PartialDB = {
|
|
11
|
+
[tableName]: NotifOp;
|
|
12
|
+
};
|
|
13
|
+
export declare const createNotifOpChannel = "notif_op_create";
|
|
14
|
+
//# sourceMappingURL=notif_op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notif_op.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEzD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;CACjC;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAE9C,eAAO,MAAM,SAAS,aAAa,CAAA;AAEnC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEhD,eAAO,MAAM,oBAAoB,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notif_op.js","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAA;AAInC,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAA,CAAC,0BAA0B","sourcesContent":["import type { GeneratedAlways, Selectable } from 'kysely'\n\nexport interface NotifOp {\n id: GeneratedAlways<number>\n actorDid: string\n priority: boolean | null\n createdAt: GeneratedAlways<Date>\n}\n\nexport type NotifOpEntry = Selectable<NotifOp>\n\nexport const tableName = 'notif_op'\n\nexport type PartialDB = { [tableName]: NotifOp }\n\nexport const createNotifOpChannel = 'notif_op_create' // used with listen/notify\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GeneratedAlways } from 'kysely';
|
|
2
|
+
import type { Method } from '../../proto/bsync_pb.js';
|
|
3
|
+
export type OperationMethod = Method.CREATE | Method.UPDATE | Method.DELETE;
|
|
4
|
+
export interface Operation {
|
|
5
|
+
id: GeneratedAlways<number>;
|
|
6
|
+
actorDid: string;
|
|
7
|
+
namespace: string;
|
|
8
|
+
key: string;
|
|
9
|
+
method: OperationMethod;
|
|
10
|
+
payload: Uint8Array<ArrayBuffer>;
|
|
11
|
+
createdAt: GeneratedAlways<Date>;
|
|
12
|
+
}
|
|
13
|
+
export declare const tableName = "operation";
|
|
14
|
+
export type PartialDB = {
|
|
15
|
+
[tableName]: Operation;
|
|
16
|
+
};
|
|
17
|
+
export declare const createOperationChannel = "operation_create";
|
|
18
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;AAE3E,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAChC,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;CACjC;AAED,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAA;AAElD,eAAO,MAAM,sBAAsB,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAIpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAA,CAAC,0BAA0B","sourcesContent":["import type { GeneratedAlways } from 'kysely'\nimport type { Method } from '../../proto/bsync_pb.js'\n\nexport type OperationMethod = Method.CREATE | Method.UPDATE | Method.DELETE\n\nexport interface Operation {\n id: GeneratedAlways<number>\n actorDid: string\n namespace: string\n key: string\n method: OperationMethod\n payload: Uint8Array<ArrayBuffer>\n createdAt: GeneratedAlways<Date>\n}\n\nexport const tableName = 'operation'\n\nexport type PartialDB = { [tableName]: Operation }\n\nexport const createOperationChannel = 'operation_create' // used with listen/notify\n"]}
|