@fedify/postgres 0.3.0-dev.22 → 0.4.0-dev.30
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/.github/FUNDING.yaml +2 -0
- package/.github/workflows/main.yaml +100 -0
- package/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +33 -0
- package/.zed/settings.json +30 -0
- package/README.md +5 -1
- package/deno.json +34 -0
- package/deno.json.tmp +34 -0
- package/deno.lock +767 -0
- package/mod.ts +1 -0
- package/package.json +31 -42
- package/src/kv.test.ts +137 -0
- package/src/kv.ts +146 -0
- package/src/mod.ts +2 -0
- package/src/mq.test.ts +114 -0
- package/src/mq.ts +261 -0
- package/src/utils.ts +7 -0
- package/tsdown.config.ts +12 -0
- package/esm/_dnt.shims.js +0 -64
- package/esm/mod.js +0 -1
- package/esm/package.json +0 -3
- package/esm/src/kv.js +0 -125
- package/esm/src/mod.js +0 -2
- package/esm/src/mq.js +0 -225
- package/esm/src/utils.js +0 -5
- package/script/_dnt.shims.js +0 -69
- package/script/mod.js +0 -17
- package/script/package.json +0 -3
- package/script/src/kv.js +0 -129
- package/script/src/mod.js +0 -18
- package/script/src/mq.js +0 -255
- package/script/src/utils.js +0 -8
- package/types/_dnt.shims.d.ts +0 -9
- package/types/_dnt.shims.d.ts.map +0 -1
- package/types/mod.d.ts +0 -2
- package/types/mod.d.ts.map +0 -1
- package/types/src/kv.d.ts +0 -56
- package/types/src/kv.d.ts.map +0 -1
- package/types/src/mod.d.ts +0 -3
- package/types/src/mod.d.ts.map +0 -1
- package/types/src/mq.d.ts +0 -63
- package/types/src/mq.d.ts.map +0 -1
- package/types/src/utils.d.ts +0 -3
- package/types/src/utils.d.ts.map +0 -1
package/script/src/mq.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
-
};
|
|
31
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
32
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
var _PostgresMessageQueue_instances, _PostgresMessageQueue_sql, _PostgresMessageQueue_tableName, _PostgresMessageQueue_channelName, _PostgresMessageQueue_pollIntervalMs, _PostgresMessageQueue_initialized, _PostgresMessageQueue_driverSerializesJson, _PostgresMessageQueue_json;
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.PostgresMessageQueue = void 0;
|
|
42
|
-
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
43
|
-
const logtape_1 = require("@logtape/logtape");
|
|
44
|
-
const postgres_1 = __importDefault(require("postgres"));
|
|
45
|
-
const utils_js_1 = require("./utils.js");
|
|
46
|
-
const logger = (0, logtape_1.getLogger)(["fedify", "postgres", "mq"]);
|
|
47
|
-
/**
|
|
48
|
-
* A message queue that uses PostgreSQL as the underlying storage.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* import { createFederation } from "@fedify/fedify";
|
|
53
|
-
* import { PostgresMessageQueue } from "@fedify/postgres";
|
|
54
|
-
* import postgres from "postgres";
|
|
55
|
-
*
|
|
56
|
-
* const federation = createFederation({
|
|
57
|
-
* // ...
|
|
58
|
-
* queue: new PostgresMessageQueue(
|
|
59
|
-
* postgres("postgres://user:pass@localhost/db")
|
|
60
|
-
* ),
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
class PostgresMessageQueue {
|
|
65
|
-
constructor(
|
|
66
|
-
// deno-lint-ignore ban-types
|
|
67
|
-
sql, options = {}) {
|
|
68
|
-
_PostgresMessageQueue_instances.add(this);
|
|
69
|
-
// deno-lint-ignore ban-types
|
|
70
|
-
_PostgresMessageQueue_sql.set(this, void 0);
|
|
71
|
-
_PostgresMessageQueue_tableName.set(this, void 0);
|
|
72
|
-
_PostgresMessageQueue_channelName.set(this, void 0);
|
|
73
|
-
_PostgresMessageQueue_pollIntervalMs.set(this, void 0);
|
|
74
|
-
_PostgresMessageQueue_initialized.set(this, void 0);
|
|
75
|
-
_PostgresMessageQueue_driverSerializesJson.set(this, false);
|
|
76
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_sql, sql, "f");
|
|
77
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_tableName, options?.tableName ?? "fedify_message_v2", "f");
|
|
78
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_channelName, options?.channelName ?? "fedify_channel", "f");
|
|
79
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_pollIntervalMs, dntShim.Temporal.Duration.from(options?.pollInterval ?? { seconds: 5 }).total("millisecond"), "f");
|
|
80
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_initialized, options?.initialized ?? false, "f");
|
|
81
|
-
}
|
|
82
|
-
async enqueue(
|
|
83
|
-
// deno-lint-ignore no-explicit-any
|
|
84
|
-
message, options) {
|
|
85
|
-
await this.initialize();
|
|
86
|
-
const delay = options?.delay ?? dntShim.Temporal.Duration.from({ seconds: 0 });
|
|
87
|
-
if (options?.delay) {
|
|
88
|
-
logger.debug("Enqueuing a message with a delay of {delay}...", {
|
|
89
|
-
delay,
|
|
90
|
-
message,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
logger.debug("Enqueuing a message...", { message });
|
|
95
|
-
}
|
|
96
|
-
await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").bind(this) `
|
|
97
|
-
INSERT INTO ${__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").call(this, __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"))} (message, delay)
|
|
98
|
-
VALUES (
|
|
99
|
-
${__classPrivateFieldGet(this, _PostgresMessageQueue_instances, "m", _PostgresMessageQueue_json).call(this, message)},
|
|
100
|
-
${delay.toString()}
|
|
101
|
-
);
|
|
102
|
-
`;
|
|
103
|
-
logger.debug("Enqueued a message.", { message });
|
|
104
|
-
await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").notify(__classPrivateFieldGet(this, _PostgresMessageQueue_channelName, "f"), delay.toString());
|
|
105
|
-
logger.debug("Notified the message queue channel {channelName}.", {
|
|
106
|
-
channelName: __classPrivateFieldGet(this, _PostgresMessageQueue_channelName, "f"),
|
|
107
|
-
message,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
async enqueueMany(
|
|
111
|
-
// deno-lint-ignore no-explicit-any
|
|
112
|
-
messages, options) {
|
|
113
|
-
if (messages.length === 0)
|
|
114
|
-
return;
|
|
115
|
-
await this.initialize();
|
|
116
|
-
const delay = options?.delay ?? dntShim.Temporal.Duration.from({ seconds: 0 });
|
|
117
|
-
if (options?.delay) {
|
|
118
|
-
logger.debug("Enqueuing messages with a delay of {delay}...", {
|
|
119
|
-
delay,
|
|
120
|
-
messages,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
logger.debug("Enqueuing messages...", { messages });
|
|
125
|
-
}
|
|
126
|
-
for (const message of messages) {
|
|
127
|
-
await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").bind(this) `
|
|
128
|
-
INSERT INTO ${__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").call(this, __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"))} (message, delay)
|
|
129
|
-
VALUES (
|
|
130
|
-
${__classPrivateFieldGet(this, _PostgresMessageQueue_instances, "m", _PostgresMessageQueue_json).call(this, message)},
|
|
131
|
-
${delay.toString()}
|
|
132
|
-
);
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
logger.debug("Enqueued messages.", { messages });
|
|
136
|
-
await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").notify(__classPrivateFieldGet(this, _PostgresMessageQueue_channelName, "f"), delay.toString());
|
|
137
|
-
logger.debug("Notified the message queue channel {channelName}.", {
|
|
138
|
-
channelName: __classPrivateFieldGet(this, _PostgresMessageQueue_channelName, "f"),
|
|
139
|
-
messages,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async listen(
|
|
143
|
-
// deno-lint-ignore no-explicit-any
|
|
144
|
-
handler, options = {}) {
|
|
145
|
-
await this.initialize();
|
|
146
|
-
const { signal } = options;
|
|
147
|
-
const poll = async () => {
|
|
148
|
-
while (!signal?.aborted) {
|
|
149
|
-
const query = __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").bind(this) `
|
|
150
|
-
DELETE FROM ${__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").call(this, __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"))}
|
|
151
|
-
WHERE id = (
|
|
152
|
-
SELECT id
|
|
153
|
-
FROM ${__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").call(this, __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"))}
|
|
154
|
-
WHERE created + delay < CURRENT_TIMESTAMP
|
|
155
|
-
ORDER BY created
|
|
156
|
-
LIMIT 1
|
|
157
|
-
)
|
|
158
|
-
RETURNING message;
|
|
159
|
-
`.execute();
|
|
160
|
-
const cancel = query.cancel.bind(query);
|
|
161
|
-
signal?.addEventListener("abort", cancel);
|
|
162
|
-
let i = 0;
|
|
163
|
-
for (const message of await query) {
|
|
164
|
-
if (signal?.aborted)
|
|
165
|
-
return;
|
|
166
|
-
await handler(message.message);
|
|
167
|
-
i++;
|
|
168
|
-
}
|
|
169
|
-
signal?.removeEventListener("abort", cancel);
|
|
170
|
-
if (i < 1)
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
const timeouts = new Set();
|
|
175
|
-
const listen = await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").listen(__classPrivateFieldGet(this, _PostgresMessageQueue_channelName, "f"), async (delay) => {
|
|
176
|
-
const duration = dntShim.Temporal.Duration.from(delay);
|
|
177
|
-
const durationMs = duration.total("millisecond");
|
|
178
|
-
if (durationMs < 1)
|
|
179
|
-
await poll();
|
|
180
|
-
else
|
|
181
|
-
timeouts.add(setTimeout(poll, durationMs));
|
|
182
|
-
}, poll);
|
|
183
|
-
signal?.addEventListener("abort", () => {
|
|
184
|
-
listen.unlisten();
|
|
185
|
-
for (const timeout of timeouts)
|
|
186
|
-
clearTimeout(timeout);
|
|
187
|
-
});
|
|
188
|
-
while (!signal?.aborted) {
|
|
189
|
-
let timeout;
|
|
190
|
-
await new Promise((resolve) => {
|
|
191
|
-
signal?.addEventListener("abort", resolve);
|
|
192
|
-
timeout = setTimeout(() => {
|
|
193
|
-
signal?.removeEventListener("abort", resolve);
|
|
194
|
-
resolve(0);
|
|
195
|
-
}, __classPrivateFieldGet(this, _PostgresMessageQueue_pollIntervalMs, "f"));
|
|
196
|
-
timeouts.add(timeout);
|
|
197
|
-
});
|
|
198
|
-
if (timeout != null)
|
|
199
|
-
timeouts.delete(timeout);
|
|
200
|
-
await poll();
|
|
201
|
-
}
|
|
202
|
-
await new Promise((resolve) => {
|
|
203
|
-
signal?.addEventListener("abort", () => resolve());
|
|
204
|
-
if (signal?.aborted)
|
|
205
|
-
return resolve();
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Initializes the message queue table if it does not already exist.
|
|
210
|
-
*/
|
|
211
|
-
async initialize() {
|
|
212
|
-
if (__classPrivateFieldGet(this, _PostgresMessageQueue_initialized, "f"))
|
|
213
|
-
return;
|
|
214
|
-
logger.debug("Initializing the message queue table {tableName}...", {
|
|
215
|
-
tableName: __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"),
|
|
216
|
-
});
|
|
217
|
-
try {
|
|
218
|
-
await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").bind(this) `
|
|
219
|
-
CREATE TABLE IF NOT EXISTS ${__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").call(this, __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"))} (
|
|
220
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
221
|
-
message jsonb NOT NULL,
|
|
222
|
-
delay interval DEFAULT '0 seconds',
|
|
223
|
-
created timestamp with time zone DEFAULT CURRENT_TIMESTAMP
|
|
224
|
-
);
|
|
225
|
-
`;
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
if (!(error instanceof postgres_1.default.PostgresError &&
|
|
229
|
-
error.constraint_name === "pg_type_typname_nsp_index")) {
|
|
230
|
-
logger.error("Failed to initialize the message queue table: {error}", {
|
|
231
|
-
error,
|
|
232
|
-
});
|
|
233
|
-
throw error;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_driverSerializesJson, await (0, utils_js_1.driverSerializesJson)(__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f")), "f");
|
|
237
|
-
__classPrivateFieldSet(this, _PostgresMessageQueue_initialized, true, "f");
|
|
238
|
-
logger.debug("Initialized the message queue table {tableName}.", {
|
|
239
|
-
tableName: __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Drops the message queue table if it exists.
|
|
244
|
-
*/
|
|
245
|
-
async drop() {
|
|
246
|
-
await __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").bind(this) `DROP TABLE IF EXISTS ${__classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").call(this, __classPrivateFieldGet(this, _PostgresMessageQueue_tableName, "f"))};`;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
exports.PostgresMessageQueue = PostgresMessageQueue;
|
|
250
|
-
_PostgresMessageQueue_sql = new WeakMap(), _PostgresMessageQueue_tableName = new WeakMap(), _PostgresMessageQueue_channelName = new WeakMap(), _PostgresMessageQueue_pollIntervalMs = new WeakMap(), _PostgresMessageQueue_initialized = new WeakMap(), _PostgresMessageQueue_driverSerializesJson = new WeakMap(), _PostgresMessageQueue_instances = new WeakSet(), _PostgresMessageQueue_json = function _PostgresMessageQueue_json(value) {
|
|
251
|
-
if (__classPrivateFieldGet(this, _PostgresMessageQueue_driverSerializesJson, "f"))
|
|
252
|
-
return __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").json(value);
|
|
253
|
-
return __classPrivateFieldGet(this, _PostgresMessageQueue_sql, "f").json(JSON.stringify(value));
|
|
254
|
-
};
|
|
255
|
-
// cSpell: ignore typname
|
package/script/src/utils.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.driverSerializesJson = driverSerializesJson;
|
|
4
|
-
// deno-lint-ignore ban-types
|
|
5
|
-
async function driverSerializesJson(sql) {
|
|
6
|
-
const result = await sql `SELECT ${sql.json('{"foo":1}')}::jsonb AS test;`;
|
|
7
|
-
return result[0].test === '{"foo":1}';
|
|
8
|
-
}
|
package/types/_dnt.shims.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Deno } from "@deno/shim-deno";
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
import { Temporal as Temporal } from "@js-temporal/polyfill";
|
|
4
|
-
export { Temporal as Temporal } from "@js-temporal/polyfill";
|
|
5
|
-
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno" | "Temporal"> & {
|
|
6
|
-
Deno: typeof Deno;
|
|
7
|
-
Temporal: typeof Temporal;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAM7D,eAAO,MAAM,aAAa;;;CAA2C,CAAC"}
|
package/types/mod.d.ts
DELETED
package/types/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/types/src/kv.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { KvKey, KvStore, KvStoreSetOptions } from "@fedify/fedify";
|
|
2
|
-
import type { Sql } from "postgres";
|
|
3
|
-
/**
|
|
4
|
-
* Options for the PostgreSQL key-value store.
|
|
5
|
-
*/
|
|
6
|
-
export interface PostgresKvStoreOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The table name to use for the key-value store.
|
|
9
|
-
* `"fedify_kv_v2"` by default.
|
|
10
|
-
* @default `"fedify_kv_v2"`
|
|
11
|
-
*/
|
|
12
|
-
tableName?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Whether the table has been initialized. `false` by default.
|
|
15
|
-
* @default `false`
|
|
16
|
-
*/
|
|
17
|
-
initialized?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A key-value store that uses PostgreSQL as the underlying storage.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { createFederation } from "@fedify/fedify";
|
|
25
|
-
* import { PostgresKvStore } from "@fedify/postgres";
|
|
26
|
-
* import postgres from "postgres";
|
|
27
|
-
*
|
|
28
|
-
* const federation = createFederation({
|
|
29
|
-
* // ...
|
|
30
|
-
* kv: new PostgresKvStore(postgres("postgres://user:pass@localhost/db")),
|
|
31
|
-
* });
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare class PostgresKvStore implements KvStore {
|
|
35
|
-
#private;
|
|
36
|
-
/**
|
|
37
|
-
* Creates a new PostgreSQL key-value store.
|
|
38
|
-
* @param sql The PostgreSQL client to use.
|
|
39
|
-
* @param options The options for the key-value store.
|
|
40
|
-
*/
|
|
41
|
-
constructor(sql: Sql<{}>, options?: PostgresKvStoreOptions);
|
|
42
|
-
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
|
43
|
-
set(key: KvKey, value: unknown, options?: KvStoreSetOptions | undefined): Promise<void>;
|
|
44
|
-
delete(key: KvKey): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Creates the table used by the key-value store if it does not already exist.
|
|
47
|
-
* Does nothing if the table already exists.
|
|
48
|
-
*/
|
|
49
|
-
initialize(): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Drops the table used by the key-value store. Does nothing if the table
|
|
52
|
-
* does not exist.
|
|
53
|
-
*/
|
|
54
|
-
drop(): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=kv.d.ts.map
|
package/types/src/kv.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kv.d.ts","sourceRoot":"","sources":["../../src/src/kv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EAAwB,GAAG,EAAE,MAAM,UAAU,CAAC;AAK1D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAgB,YAAW,OAAO;;IAO7C;;;;OAIG;gBAGD,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EACZ,OAAO,GAAE,sBAA2B;IAchC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAWpD,GAAG,CACP,GAAG,EAAE,KAAK,EACV,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,iBAAiB,GAAG,SAAS,GACtC,OAAO,CAAC,IAAI,CAAC;IAgBV,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IASvC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBjC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
package/types/src/mod.d.ts
DELETED
package/types/src/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
package/types/src/mq.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import type { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
|
|
3
|
-
import type { Sql } from "postgres";
|
|
4
|
-
/**
|
|
5
|
-
* Options for the PostgreSQL message queue.
|
|
6
|
-
*/
|
|
7
|
-
export interface PostgresMessageQueueOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The table name to use for the message queue.
|
|
10
|
-
* `"fedify_message_v2"` by default.
|
|
11
|
-
* @default `"fedify_message_v2"`
|
|
12
|
-
*/
|
|
13
|
-
tableName?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The channel name to use for the message queue.
|
|
16
|
-
* `"fedify_channel"` by default.
|
|
17
|
-
* @default `"fedify_channel"`
|
|
18
|
-
*/
|
|
19
|
-
channelName?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Whether the table has been initialized. `false` by default.
|
|
22
|
-
* @default `false`
|
|
23
|
-
*/
|
|
24
|
-
initialized?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* The poll interval for the message queue. 5 seconds by default.
|
|
27
|
-
* @default `{ seconds: 5 }`
|
|
28
|
-
*/
|
|
29
|
-
pollInterval?: dntShim.Temporal.Duration | dntShim.Temporal.DurationLike;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* A message queue that uses PostgreSQL as the underlying storage.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { createFederation } from "@fedify/fedify";
|
|
37
|
-
* import { PostgresMessageQueue } from "@fedify/postgres";
|
|
38
|
-
* import postgres from "postgres";
|
|
39
|
-
*
|
|
40
|
-
* const federation = createFederation({
|
|
41
|
-
* // ...
|
|
42
|
-
* queue: new PostgresMessageQueue(
|
|
43
|
-
* postgres("postgres://user:pass@localhost/db")
|
|
44
|
-
* ),
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare class PostgresMessageQueue implements MessageQueue {
|
|
49
|
-
#private;
|
|
50
|
-
constructor(sql: Sql<{}>, options?: PostgresMessageQueueOptions);
|
|
51
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
52
|
-
enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
53
|
-
listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Initializes the message queue table if it does not already exist.
|
|
56
|
-
*/
|
|
57
|
-
initialize(): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Drops the message queue table if it exists.
|
|
60
|
-
*/
|
|
61
|
-
drop(): Promise<void>;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=mq.d.ts.map
|
package/types/src/mq.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../src/src/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAwB,GAAG,EAAE,MAAM,UAAU,CAAC;AAM1D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;CAC1E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAqB,YAAW,YAAY;;gBAWrD,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EACZ,OAAO,GAAE,2BAAgC;IAWrC,OAAO,CAEX,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,IAAI,CAAC;IA0BV,WAAW,CAEf,QAAQ,EAAE,GAAG,EAAE,EACf,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,IAAI,CAAC;IA6BV,MAAM,CAEV,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/C,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,IAAI,CAAC;IA8DhB;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCjC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
package/types/src/utils.d.ts
DELETED
package/types/src/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAGzE"}
|