@openpeepshq/core 0.2.0 → 0.2.1
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/LICENSE +674 -0
- package/dist/accounts/mutations.js +9 -0
- package/dist/config/index.d.ts +3 -336
- package/dist/db/explorer/index.d.ts +1 -1
- package/dist/db/explorer/index.js +1 -1
- package/dist/db/pg/map/registry.js +3 -2
- package/dist/jams/export.d.ts +2 -0
- package/dist/jams/export.js +5 -0
- package/dist/jams/finders.d.ts +1 -0
- package/dist/jams/finders.js +1 -0
- package/dist/jams/health.d.ts +23 -0
- package/dist/jams/health.js +79 -7
- package/dist/jams/index.d.ts +1 -1
- package/dist/jams/index.js +10 -3
- package/dist/jams/token.js +6 -2
- package/dist/jams/waitingRoom.js +3 -1
- package/dist/media/garbageCollection.d.ts +109 -0
- package/dist/media/garbageCollection.js +603 -0
- package/dist/media/garbageCollectionJobs.d.ts +14 -0
- package/dist/media/garbageCollectionJobs.js +55 -0
- package/dist/media/index.d.ts +2 -0
- package/dist/media/index.js +4 -2
- package/dist/media/streaming.d.ts +2 -0
- package/dist/media/streaming.js +8 -0
- package/dist/notifications/defaultNotifications/index.js +2 -0
- package/dist/notifications/defaultNotifications/jamStarted/index.d.ts +1 -0
- package/dist/notifications/defaultNotifications/jamStarted/index.js +61 -13
- package/dist/notifications/defaultNotifications/waitlistOffer/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/waitlistOffer/index.js +40 -0
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/plugins/pluginAuth.js +1 -0
- package/dist/posts/conversationQueries.d.ts +31 -0
- package/dist/posts/conversationQueries.js +150 -24
- package/dist/posts/finders.d.ts +9 -0
- package/dist/posts/finders.js +23 -3
- package/dist/posts/helpers/index.d.ts +10 -2
- package/dist/posts/helpers/index.js +6 -0
- package/dist/posts/index.d.ts +3 -1
- package/dist/posts/index.js +3 -1
- package/dist/posts/mapping.d.ts +14 -0
- package/dist/posts/mutations.d.ts +12 -6
- package/dist/posts/mutations.js +220 -68
- package/dist/posts/rsvpExport.d.ts +47 -0
- package/dist/posts/rsvpExport.js +178 -0
- package/dist/posts/unseenCounts.d.ts +6 -0
- package/dist/posts/unseenCounts.js +51 -1
- package/dist/posts/waitlist.d.ts +13 -0
- package/dist/posts/waitlist.js +75 -0
- package/dist/posts/waitlistOfferJobs.d.ts +10 -0
- package/dist/posts/waitlistOfferJobs.js +91 -0
- package/dist/profiles/index.js +6 -1
- package/dist/reports/mapping.d.ts +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/stats/mapping.d.ts +1 -0
- package/dist/stripe/connection.js +1 -1
- package/dist/stripe/helpers.js +7 -3
- package/package.json +10 -9
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { StoredMediaFile, StoredMediaStatus } from '@openpeepshq/common/types';
|
|
2
|
+
/**
|
|
3
|
+
* How long a file must stay unreferenced before it is deleted. The clock
|
|
4
|
+
* starts the first time a collection run sees the file with no live link, so
|
|
5
|
+
* the run that ships this job only records files — it does not delete them.
|
|
6
|
+
* In-progress uploads (stored, not yet saved onto a post or recording) survive
|
|
7
|
+
* the same window.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MEDIA_GC_GRACE_MS: number;
|
|
10
|
+
/** Type alias for the stream-active check, overridable in tests. */
|
|
11
|
+
export type StreamActiveChecker = (storageId: string, now: number) => Promise<boolean>;
|
|
12
|
+
/** SHA-256 digest, base64url, no padding. */
|
|
13
|
+
export declare const STORAGE_ID_LENGTH = 43;
|
|
14
|
+
/**
|
|
15
|
+
* POSIX regex (no lookahead) shared with the SQL scan. Matches
|
|
16
|
+
* `/storage/allpeep/<id>/<file>` and `/media/streaming/<id>/...`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const STORAGE_URL_SOURCE = "/(?:allpeep|media/streaming)/([A-Za-z0-9_-]{43})(?:[^A-Za-z0-9_-]|$)";
|
|
19
|
+
/**
|
|
20
|
+
* Live content that can embed a media URL. The scan also covers every other
|
|
21
|
+
* public jsonb column, so a new page or plugin table is included without a
|
|
22
|
+
* code change. These are the ones GC refuses to run without.
|
|
23
|
+
*/
|
|
24
|
+
export declare const REFERENCE_TABLES: readonly ["posts", "profiles", "groups", "configs", "jam_recordings"];
|
|
25
|
+
/**
|
|
26
|
+
* Rows that store a media URL but are not a live link:
|
|
27
|
+
* - `media_attachments` is the upload registry. It keeps a copy of every file
|
|
28
|
+
* URL, including files whose post or recording is already gone.
|
|
29
|
+
* - `entries` snapshots the post at create and edit time. After the post is
|
|
30
|
+
* deleted those snapshots are the only remaining copy, so counting them
|
|
31
|
+
* would keep the file forever. The rendered post is the post row itself.
|
|
32
|
+
*/
|
|
33
|
+
export declare const EXCLUDED_REFERENCE_TABLES: readonly ["media_attachments", "entries"];
|
|
34
|
+
export declare const isStorageId: (value: string) => boolean;
|
|
35
|
+
/** Quick existence check for the stored source file (without the HLS dir). */
|
|
36
|
+
export declare const mediaFileExists: (storageId: string) => Promise<boolean>;
|
|
37
|
+
export declare const quoteIdent: (name: string) => string;
|
|
38
|
+
export declare const extractStorageIds: (text: string) => string[];
|
|
39
|
+
export interface JsonbColumn {
|
|
40
|
+
tableName: string;
|
|
41
|
+
columnName: string;
|
|
42
|
+
}
|
|
43
|
+
export declare const buildReferenceScanSql: (columns: JsonbColumn[], tablesWithDeletedAt: ReadonlySet<string>) => string | null;
|
|
44
|
+
export interface SqlExecutor {
|
|
45
|
+
execute: (query: string) => Promise<{
|
|
46
|
+
rows: Record<string, unknown>[];
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export declare const loadReferencedStorageIds: (executor: SqlExecutor) => Promise<Set<string>>;
|
|
50
|
+
export interface AttachmentBody {
|
|
51
|
+
id: string;
|
|
52
|
+
body: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Attachment rows whose local files are all gone. Rows that still point at a
|
|
56
|
+
* file on disk (referenced, or inside the grace window) stay so an in-progress
|
|
57
|
+
* upload can finish.
|
|
58
|
+
*/
|
|
59
|
+
export declare const danglingMediaAttachmentIds: (rows: AttachmentBody[], filesOnDisk: ReadonlySet<string>) => string[];
|
|
60
|
+
export interface SweepOptions {
|
|
61
|
+
filesDir: string;
|
|
62
|
+
hlsRoot: string;
|
|
63
|
+
statePath: string;
|
|
64
|
+
referencedIds: ReadonlySet<string>;
|
|
65
|
+
now?: number;
|
|
66
|
+
graceMs?: number;
|
|
67
|
+
/** Override the recent-access check (default: Redis-backed). */
|
|
68
|
+
streamActiveChecker?: StreamActiveChecker;
|
|
69
|
+
}
|
|
70
|
+
export interface SweepResult {
|
|
71
|
+
deleted: string[];
|
|
72
|
+
marked: number;
|
|
73
|
+
kept: number;
|
|
74
|
+
skipped: string[];
|
|
75
|
+
remainingIds: string[];
|
|
76
|
+
tempDeleted: number;
|
|
77
|
+
storageMissing: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Delete stored files with no live reference, once they have stayed that way
|
|
81
|
+
* for the grace period. Also drops HLS directories for those files, stale
|
|
82
|
+
* upload temps, and HLS directories whose source file is already gone.
|
|
83
|
+
*/
|
|
84
|
+
export declare const sweepUnreferencedMedia: (options: SweepOptions) => Promise<SweepResult>;
|
|
85
|
+
export declare const deleteMediaAttachmentRows: (ids: string[]) => Promise<number>;
|
|
86
|
+
export interface MediaGarbageCollectionResult extends SweepResult {
|
|
87
|
+
referenced: number;
|
|
88
|
+
attachmentsDeleted: number;
|
|
89
|
+
}
|
|
90
|
+
export declare const collectUnreferencedMedia: (graceMs?: number) => Promise<MediaGarbageCollectionResult>;
|
|
91
|
+
interface ClassifiedMedia {
|
|
92
|
+
status: StoredMediaStatus;
|
|
93
|
+
unreferencedSince: string | null;
|
|
94
|
+
deletesAt: string | null;
|
|
95
|
+
}
|
|
96
|
+
/** How garbage collection treats one file, given the live link set and clock. */
|
|
97
|
+
export declare const classifyMediaFile: (storageId: string, referencedIds: ReadonlySet<string>, unreferencedSinceMs: number | undefined, now: number, graceMs?: number) => ClassifiedMedia;
|
|
98
|
+
export declare const listStoredMedia: () => Promise<{
|
|
99
|
+
files: StoredMediaFile[];
|
|
100
|
+
graceMs: number;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Remove one stored file immediately. The garbage-collection clock and
|
|
104
|
+
* dangling attachment rows are cleaned up too. Live links are left in place
|
|
105
|
+
* and will 404. The HLS cache is preserved if the stream was accessed within
|
|
106
|
+
* the recent-access window; it will be reclaimed by the streaming-cleanup cron.
|
|
107
|
+
*/
|
|
108
|
+
export declare const deleteStoredMediaNow: (storageId: string) => Promise<boolean>;
|
|
109
|
+
export {};
|