@clioplaylists/clio 0.1.0 → 0.1.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.
Files changed (148) hide show
  1. package/dist/.env +1 -1
  2. package/dist/api/com/clioplaylists/alpha/actor/getProfile.d.ts +0 -0
  3. package/dist/api/com/clioplaylists/alpha/feed/getSongs.d.ts +0 -0
  4. package/dist/api/health.d.ts +3 -0
  5. package/dist/api/index.d.ts +4 -0
  6. package/dist/api/util.d.ts +9 -0
  7. package/dist/auth-verifier.d.ts +92 -0
  8. package/dist/client.d.ts +9 -0
  9. package/dist/config.d.ts +21 -0
  10. package/dist/context.d.ts +11 -0
  11. package/dist/dataplane/client.d.ts +27 -0
  12. package/dist/dataplane/index.d.ts +2 -0
  13. package/dist/dataplane/server/background.d.ts +13 -0
  14. package/dist/dataplane/server/db/database-schema.d.ts +13 -0
  15. package/dist/dataplane/server/db/db.d.ts +32 -0
  16. package/dist/dataplane/server/db/index.d.ts +1 -0
  17. package/dist/dataplane/server/db/migrations/20230309T045948368Z-init.d.ts +3 -0
  18. package/dist/dataplane/server/db/migrations/20230420T211446071Z-did-cache.d.ts +3 -0
  19. package/dist/dataplane/server/db/migrations/index.d.ts +2 -0
  20. package/dist/dataplane/server/db/migrations/provider.d.ts +11 -0
  21. package/dist/dataplane/server/db/pagination.d.ts +86 -0
  22. package/dist/dataplane/server/db/tables/actor-sync.d.ts +9 -0
  23. package/dist/dataplane/server/db/tables/actor.d.ts +11 -0
  24. package/dist/dataplane/server/db/tables/artist-list-item.d.ts +11 -0
  25. package/dist/dataplane/server/db/tables/artist.d.ts +10 -0
  26. package/dist/dataplane/server/db/tables/playlist-idea.d.ts +14 -0
  27. package/dist/dataplane/server/db/tables/playlist-item.d.ts +11 -0
  28. package/dist/dataplane/server/db/tables/playlist.d.ts +10 -0
  29. package/dist/dataplane/server/db/tables/profile.d.ts +15 -0
  30. package/dist/dataplane/server/db/tables/record.d.ts +12 -0
  31. package/dist/dataplane/server/db/tables/song.d.ts +12 -0
  32. package/dist/dataplane/server/db/types.d.ts +9 -0
  33. package/dist/dataplane/server/db/util.d.ts +20 -0
  34. package/dist/dataplane/server/index.d.ts +11 -0
  35. package/dist/dataplane/server/indexing/index.d.ts +32 -0
  36. package/dist/dataplane/server/indexing/plugins/playlist-idea.d.ts +14 -0
  37. package/dist/dataplane/server/indexing/plugins/profile.d.ts +8 -0
  38. package/dist/dataplane/server/indexing/processor.d.ts +22 -0
  39. package/dist/dataplane/server/routes/identity.d.ts +6 -0
  40. package/dist/dataplane/server/routes/index.d.ts +5 -0
  41. package/dist/dataplane/server/routes/profile.d.ts +5 -0
  42. package/dist/dataplane/server/routes/records.d.ts +11 -0
  43. package/dist/dataplane/server/routes/sync.d.ts +5 -0
  44. package/dist/dataplane/server/subscription.d.ts +25 -0
  45. package/dist/error.d.ts +2 -0
  46. package/dist/index.d.ts +20 -0
  47. package/dist/lexicons/index.d.ts +278 -0
  48. package/dist/lexicons/lexicons.d.ts +8466 -0
  49. package/dist/lexicons/types/com/atproto/admin/defs.d.ts +50 -0
  50. package/dist/lexicons/types/com/atproto/admin/deleteAccount.d.ts +29 -0
  51. package/dist/lexicons/types/com/atproto/admin/disableAccountInvites.d.ts +31 -0
  52. package/dist/lexicons/types/com/atproto/admin/disableInviteCodes.d.ts +30 -0
  53. package/dist/lexicons/types/com/atproto/admin/enableAccountInvites.d.ts +31 -0
  54. package/dist/lexicons/types/com/atproto/admin/getAccountInfo.d.ts +33 -0
  55. package/dist/lexicons/types/com/atproto/admin/getAccountInfos.d.ts +36 -0
  56. package/dist/lexicons/types/com/atproto/admin/getInviteCodes.d.ts +39 -0
  57. package/dist/lexicons/types/com/atproto/admin/getSubjectStatus.d.ts +44 -0
  58. package/dist/lexicons/types/com/atproto/admin/searchAccounts.d.ts +39 -0
  59. package/dist/lexicons/types/com/atproto/admin/sendEmail.d.ts +45 -0
  60. package/dist/lexicons/types/com/atproto/admin/updateAccountEmail.d.ts +31 -0
  61. package/dist/lexicons/types/com/atproto/admin/updateAccountHandle.d.ts +30 -0
  62. package/dist/lexicons/types/com/atproto/admin/updateAccountPassword.d.ts +30 -0
  63. package/dist/lexicons/types/com/atproto/admin/updateSubjectStatus.d.ts +51 -0
  64. package/dist/lexicons/types/com/atproto/identity/defs.d.ts +14 -0
  65. package/dist/lexicons/types/com/atproto/identity/getRecommendedDidCredentials.d.ts +38 -0
  66. package/dist/lexicons/types/com/atproto/identity/refreshIdentity.d.ts +39 -0
  67. package/dist/lexicons/types/com/atproto/identity/requestPlcOperationSignature.d.ts +23 -0
  68. package/dist/lexicons/types/com/atproto/identity/resolveDid.d.ts +38 -0
  69. package/dist/lexicons/types/com/atproto/identity/resolveHandle.d.ts +37 -0
  70. package/dist/lexicons/types/com/atproto/identity/resolveIdentity.d.ts +35 -0
  71. package/dist/lexicons/types/com/atproto/identity/signPlcOperation.d.ts +46 -0
  72. package/dist/lexicons/types/com/atproto/identity/submitPlcOperation.d.ts +29 -0
  73. package/dist/lexicons/types/com/atproto/identity/updateHandle.d.ts +30 -0
  74. package/dist/lexicons/types/com/atproto/label/defs.d.ts +73 -0
  75. package/dist/lexicons/types/com/atproto/label/queryLabels.d.ts +42 -0
  76. package/dist/lexicons/types/com/atproto/label/subscribeLabels.d.ts +38 -0
  77. package/dist/lexicons/types/com/atproto/lexicon/schema.d.ts +11 -0
  78. package/dist/lexicons/types/com/atproto/moderation/createReport.d.ts +57 -0
  79. package/dist/lexicons/types/com/atproto/moderation/defs.d.ts +20 -0
  80. package/dist/lexicons/types/com/atproto/repo/applyWrites.d.ts +98 -0
  81. package/dist/lexicons/types/com/atproto/repo/createRecord.d.ts +56 -0
  82. package/dist/lexicons/types/com/atproto/repo/defs.d.ts +11 -0
  83. package/dist/lexicons/types/com/atproto/repo/deleteRecord.d.ts +51 -0
  84. package/dist/lexicons/types/com/atproto/repo/describeRepo.d.ts +43 -0
  85. package/dist/lexicons/types/com/atproto/repo/getRecord.d.ts +45 -0
  86. package/dist/lexicons/types/com/atproto/repo/importRepo.d.ts +27 -0
  87. package/dist/lexicons/types/com/atproto/repo/listMissingBlobs.d.ts +45 -0
  88. package/dist/lexicons/types/com/atproto/repo/listRecords.d.ts +53 -0
  89. package/dist/lexicons/types/com/atproto/repo/putRecord.d.ts +58 -0
  90. package/dist/lexicons/types/com/atproto/repo/strongRef.d.ts +11 -0
  91. package/dist/lexicons/types/com/atproto/repo/uploadBlob.d.ts +39 -0
  92. package/dist/lexicons/types/com/atproto/server/activateAccount.d.ts +23 -0
  93. package/dist/lexicons/types/com/atproto/server/checkAccountStatus.d.ts +42 -0
  94. package/dist/lexicons/types/com/atproto/server/confirmEmail.d.ts +31 -0
  95. package/dist/lexicons/types/com/atproto/server/createAccount.d.ts +61 -0
  96. package/dist/lexicons/types/com/atproto/server/createAppPassword.d.ts +51 -0
  97. package/dist/lexicons/types/com/atproto/server/createInviteCode.d.ts +41 -0
  98. package/dist/lexicons/types/com/atproto/server/createInviteCodes.d.ts +50 -0
  99. package/dist/lexicons/types/com/atproto/server/createSession.d.ts +56 -0
  100. package/dist/lexicons/types/com/atproto/server/deactivateAccount.d.ts +30 -0
  101. package/dist/lexicons/types/com/atproto/server/defs.d.ts +23 -0
  102. package/dist/lexicons/types/com/atproto/server/deleteAccount.d.ts +32 -0
  103. package/dist/lexicons/types/com/atproto/server/deleteSession.d.ts +23 -0
  104. package/dist/lexicons/types/com/atproto/server/describeServer.d.ts +56 -0
  105. package/dist/lexicons/types/com/atproto/server/getAccountInviteCodes.d.ts +39 -0
  106. package/dist/lexicons/types/com/atproto/server/getServiceAuth.d.ts +41 -0
  107. package/dist/lexicons/types/com/atproto/server/getSession.d.ts +42 -0
  108. package/dist/lexicons/types/com/atproto/server/listAppPasswords.d.ts +44 -0
  109. package/dist/lexicons/types/com/atproto/server/refreshSession.d.ts +42 -0
  110. package/dist/lexicons/types/com/atproto/server/requestAccountDelete.d.ts +23 -0
  111. package/dist/lexicons/types/com/atproto/server/requestEmailConfirmation.d.ts +23 -0
  112. package/dist/lexicons/types/com/atproto/server/requestEmailUpdate.d.ts +34 -0
  113. package/dist/lexicons/types/com/atproto/server/requestPasswordReset.d.ts +29 -0
  114. package/dist/lexicons/types/com/atproto/server/reserveSigningKey.d.ts +42 -0
  115. package/dist/lexicons/types/com/atproto/server/resetPassword.d.ts +31 -0
  116. package/dist/lexicons/types/com/atproto/server/revokeAppPassword.d.ts +29 -0
  117. package/dist/lexicons/types/com/atproto/server/updateEmail.d.ts +33 -0
  118. package/dist/lexicons/types/com/atproto/sync/getBlob.d.ts +36 -0
  119. package/dist/lexicons/types/com/atproto/sync/getBlocks.d.ts +35 -0
  120. package/dist/lexicons/types/com/atproto/sync/getCheckout.d.ts +33 -0
  121. package/dist/lexicons/types/com/atproto/sync/getHead.d.ts +37 -0
  122. package/dist/lexicons/types/com/atproto/sync/getLatestCommit.d.ts +38 -0
  123. package/dist/lexicons/types/com/atproto/sync/getRecord.d.ts +37 -0
  124. package/dist/lexicons/types/com/atproto/sync/getRepo.d.ts +36 -0
  125. package/dist/lexicons/types/com/atproto/sync/getRepoStatus.d.ts +42 -0
  126. package/dist/lexicons/types/com/atproto/sync/listBlobs.d.ts +42 -0
  127. package/dist/lexicons/types/com/atproto/sync/listRepos.d.ts +50 -0
  128. package/dist/lexicons/types/com/atproto/sync/listReposByCollection.d.ts +46 -0
  129. package/dist/lexicons/types/com/atproto/sync/notifyOfUpdate.d.ts +30 -0
  130. package/dist/lexicons/types/com/atproto/sync/requestCrawl.d.ts +30 -0
  131. package/dist/lexicons/types/com/atproto/sync/subscribeRepos.d.ts +111 -0
  132. package/dist/lexicons/types/com/atproto/temp/addReservedHandle.d.ts +39 -0
  133. package/dist/lexicons/types/com/atproto/temp/checkSignupQueue.d.ts +36 -0
  134. package/dist/lexicons/types/com/atproto/temp/fetchLabels.d.ts +37 -0
  135. package/dist/lexicons/types/com/atproto/temp/requestPhoneVerification.d.ts +29 -0
  136. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.d.ts +19 -0
  137. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.d.ts +32 -0
  138. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getSongs.d.ts +37 -0
  139. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.d.ts +32 -0
  140. package/dist/lexicons/util.d.ts +5 -0
  141. package/dist/logger.d.ts +6 -0
  142. package/dist/rpc/clio_connect.d.ts +103 -0
  143. package/dist/rpc/clio_pb.d.ts +457 -0
  144. package/dist/start.d.ts +1 -0
  145. package/dist/util/retry.d.ts +2 -0
  146. package/dist/util/uris.d.ts +1 -0
  147. package/dist/util.d.ts +23 -0
  148. package/package.json +2 -1
package/dist/.env CHANGED
@@ -1,5 +1,5 @@
1
1
  NODE_ENV='development'
2
- CLIO_VERSION=v0.0.1
2
+ CLIO_VERSION=v0.1.0
3
3
  CLIO_PORT=8000
4
4
  DID_PLC_URL='https://plc.directory'
5
5
  LOG_ENABLED=true
@@ -0,0 +1,3 @@
1
+ import express from 'express';
2
+ import AppContext from '../context';
3
+ export declare const createRouter: (ctx: AppContext) => express.Router;
@@ -0,0 +1,4 @@
1
+ import AppContext from '../context';
2
+ import { Server } from '../lexicons';
3
+ export * as health from './health';
4
+ export default function (server: Server, ctx: AppContext): Server;
@@ -0,0 +1,9 @@
1
+ import { ParsedLabelers } from '../util';
2
+ export declare const ATPROTO_CONTENT_LABELERS = "Atproto-Content-Labelers";
3
+ export declare const ATPROTO_REPO_REV = "Atproto-Repo-Rev";
4
+ type ResHeaderOpts = {
5
+ labelers: ParsedLabelers;
6
+ repoRev: string | null;
7
+ };
8
+ export declare const resHeaders: (opts: Partial<ResHeaderOpts>) => Record<string, string>;
9
+ export {};
@@ -0,0 +1,92 @@
1
+ import { VerifySignatureWithKeyFn } from '@atproto/xrpc-server';
2
+ import express from 'express';
3
+ import { KeyObject } from 'node:crypto';
4
+ import { DataPlaneClient } from './client';
5
+ type ReqCtx = {
6
+ req: express.Request;
7
+ };
8
+ type StandardAuthOpts = {
9
+ skipAudCheck?: boolean;
10
+ lxmCheck?: (method?: string) => boolean;
11
+ };
12
+ export declare enum RoleStatus {
13
+ Valid = 0,
14
+ Invalid = 1,
15
+ Missing = 2
16
+ }
17
+ type NullOutput = {
18
+ credentials: {
19
+ type: 'none';
20
+ iss: null;
21
+ };
22
+ };
23
+ type StandardOutput = {
24
+ credentials: {
25
+ type: 'standard';
26
+ aud: string;
27
+ iss: string;
28
+ };
29
+ };
30
+ type RoleOutput = {
31
+ credentials: {
32
+ type: 'role';
33
+ admin: boolean;
34
+ };
35
+ };
36
+ type ModServiceOutput = {
37
+ credentials: {
38
+ type: 'mod_service';
39
+ aud: string;
40
+ iss: string;
41
+ };
42
+ };
43
+ export type AuthVerifierOpts = {
44
+ ownDid: string;
45
+ alternateAudienceDids: string[];
46
+ modServiceDid: string;
47
+ adminPasses: string[];
48
+ entrywayJwtPublicKey?: KeyObject;
49
+ };
50
+ export declare class AuthVerifier {
51
+ dataplane: DataPlaneClient;
52
+ ownDid: string;
53
+ standardAudienceDids: Set<string>;
54
+ modServiceDid: string;
55
+ private adminPasses;
56
+ private entrywayJwtPublicKey?;
57
+ constructor(dataplane: DataPlaneClient, opts: AuthVerifierOpts);
58
+ standardOptionalParameterized: (opts: StandardAuthOpts) => (ctx: ReqCtx) => Promise<StandardOutput | NullOutput>;
59
+ standardOptional: (ctx: ReqCtx) => Promise<StandardOutput | NullOutput>;
60
+ standard: (ctx: ReqCtx) => Promise<StandardOutput>;
61
+ role: (ctx: ReqCtx) => RoleOutput;
62
+ standardOrRole: (ctx: ReqCtx) => Promise<StandardOutput | RoleOutput>;
63
+ optionalStandardOrRole: (ctx: ReqCtx) => Promise<StandardOutput | RoleOutput | NullOutput>;
64
+ entrywaySession: (reqCtx: ReqCtx) => Promise<StandardOutput>;
65
+ parseRoleCreds(req: express.Request): {
66
+ status: RoleStatus;
67
+ admin: boolean;
68
+ moderator: boolean;
69
+ triage: boolean;
70
+ } | {
71
+ status: RoleStatus;
72
+ admin: boolean;
73
+ moderator?: undefined;
74
+ triage?: undefined;
75
+ };
76
+ isModService(iss: string): boolean;
77
+ nullCreds(): NullOutput;
78
+ parseCreds(creds: StandardOutput | RoleOutput | ModServiceOutput | NullOutput): {
79
+ viewer: string | null;
80
+ includeTakedowns: boolean;
81
+ include3pBlocks: boolean;
82
+ canPerformTakedown: boolean;
83
+ };
84
+ }
85
+ export declare const parseBasicAuth: (token: string) => {
86
+ username: string;
87
+ password: string;
88
+ } | null;
89
+ export declare const buildBasicAuth: (username: string, password: string) => string;
90
+ export declare const createPublicKeyObject: (publicKeyHex: string) => KeyObject;
91
+ export declare const verifySignatureWithKey: VerifySignatureWithKeyFn;
92
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Client } from '@connectrpc/connect';
2
+ import { ClioService } from './rpc/clio_connect';
3
+ export type DataPlaneClient = Client<typeof ClioService>;
4
+ type HttpVersion = '1.1' | '2';
5
+ export declare const createBaseClient: (baseUrl: string, opts: {
6
+ httpVersion?: HttpVersion;
7
+ rejectUnauthorized?: boolean;
8
+ }) => DataPlaneClient;
9
+ export {};
@@ -0,0 +1,21 @@
1
+ export interface ServerConfigValues {
2
+ version?: string;
3
+ debugMode?: boolean;
4
+ port?: number;
5
+ serverDid: string;
6
+ didPlcUrl: string;
7
+ handleResolverNameservers?: string[];
8
+ }
9
+ export declare class ServerConfig {
10
+ private cfg;
11
+ private assignedPort?;
12
+ constructor(cfg: ServerConfigValues);
13
+ static readEnv(overrides?: Partial<ServerConfigValues>): ServerConfig;
14
+ assignPort(port: number): void;
15
+ get version(): string | undefined;
16
+ get debugMode(): boolean;
17
+ get port(): number | undefined;
18
+ get localUrl(): string;
19
+ get serverDid(): string;
20
+ get didPlcUrl(): string;
21
+ }
@@ -0,0 +1,11 @@
1
+ import { DataPlaneClient } from './client';
2
+ import { ServerConfig } from './config';
3
+ export default class AppContext {
4
+ private opts;
5
+ constructor(opts: {
6
+ cfg: ServerConfig;
7
+ dataplane: DataPlaneClient;
8
+ });
9
+ get cfg(): ServerConfig;
10
+ get dataplane(): DataPlaneClient;
11
+ }
@@ -0,0 +1,27 @@
1
+ import { Client, Code, ConnectError } from '@connectrpc/connect';
2
+ import { ClioService } from '../rpc/clio_connect';
3
+ export type DataPlaneClient = Client<typeof ClioService>;
4
+ type HttpVersion = '1.1' | '2';
5
+ export declare const createDataPlaneClient: (baseUrls: string[], opts: {
6
+ httpVersion?: HttpVersion;
7
+ rejectUnauthorized?: boolean;
8
+ }) => DataPlaneClient;
9
+ export { Code };
10
+ export declare const isDataplaneError: (err: unknown, code?: Code) => err is ConnectError;
11
+ export declare const unpackIdentityServices: (servicesBytes: Uint8Array) => UnpackedServices;
12
+ export declare const unpackIdentityKeys: (keysBytes: Uint8Array) => UnpackedKeys;
13
+ export declare const getServiceEndpoint: (services: UnpackedServices, opts: {
14
+ id: string;
15
+ type: string;
16
+ }) => string | undefined;
17
+ export declare const getKeyAsDidKey: (keys: UnpackedKeys, opts: {
18
+ id: string;
19
+ }) => string | undefined;
20
+ type UnpackedServices = Record<string, {
21
+ Type: string;
22
+ URL: string;
23
+ }>;
24
+ type UnpackedKeys = Record<string, {
25
+ Type: string;
26
+ PublicKeyMultibase: string;
27
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ export * from './server';
@@ -0,0 +1,13 @@
1
+ import PQueue from 'p-queue';
2
+ import { Database } from './db';
3
+ export declare class BackgroundQueue {
4
+ db: Database;
5
+ queue: PQueue<import("p-queue/dist/priority-queue").default, import("p-queue").DefaultAddOptions>;
6
+ destroyed: boolean;
7
+ constructor(db: Database);
8
+ add(task: Task): void;
9
+ processAll(): Promise<void>;
10
+ destroy(): Promise<void>;
11
+ }
12
+ type Task = (db: Database) => Promise<void>;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Kysely } from 'kysely';
2
+ import * as actorTable from './tables/actor';
3
+ import * as actorSyncTable from './tables/actor-sync';
4
+ import * as artistTable from './tables/artist';
5
+ import * as artistListItemTable from './tables/artist-list-item';
6
+ import * as playlistTable from './tables/playlist';
7
+ import * as playlistIdeaTable from './tables/playlist-idea';
8
+ import * as playlistItemTable from './tables/playlist-item';
9
+ import * as profileTable from './tables/profile';
10
+ import * as recordTable from './tables/record';
11
+ import * as songTable from './tables/song';
12
+ export type DatabaseSchemaType = actorTable.PartialDB & actorSyncTable.PartialDB & artistTable.PartialDB & artistListItemTable.PartialDB & playlistTable.PartialDB & playlistIdeaTable.PartialDB & playlistItemTable.PartialDB & profileTable.PartialDB & recordTable.PartialDB & songTable.PartialDB;
13
+ export type DatabaseSchema = Kysely<DatabaseSchemaType>;
@@ -0,0 +1,32 @@
1
+ import { Migrator } from 'kysely';
2
+ import { Pool as PgPool } from 'pg';
3
+ import TypedEmitter from 'typed-emitter';
4
+ import { DatabaseSchema } from './database-schema';
5
+ import { PgOptions } from './types';
6
+ export declare class Database {
7
+ opts: PgOptions;
8
+ pool: PgPool;
9
+ db: DatabaseSchema;
10
+ migrator: Migrator;
11
+ txEvt: TxnEmitter;
12
+ destroyed: boolean;
13
+ constructor(opts: PgOptions, instances?: {
14
+ db: DatabaseSchema;
15
+ pool: PgPool;
16
+ migrator: Migrator;
17
+ });
18
+ get schema(): string | undefined;
19
+ transaction<T>(fn: (db: Database) => Promise<T>): Promise<T>;
20
+ get isTransaction(): boolean;
21
+ assertTransaction(): void;
22
+ assertNotTransaction(): void;
23
+ onCommit(fn: () => void): void;
24
+ migrateToOrThrow(migration: string): Promise<import("kysely").MigrationResult[]>;
25
+ migrateToLatestOrThrow(): Promise<import("kysely").MigrationResult[]>;
26
+ close(): Promise<void>;
27
+ }
28
+ export default Database;
29
+ type TxnEmitter = TypedEmitter<TxnEvents>;
30
+ type TxnEvents = {
31
+ commit: () => void;
32
+ };
@@ -0,0 +1 @@
1
+ export * from './db';
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<unknown>): Promise<void>;
3
+ export declare function down(db: Kysely<unknown>): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<unknown>): Promise<void>;
3
+ export declare function down(db: Kysely<unknown>): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export * as _20230309T045948368Z from './20230309T045948368Z-init';
2
+ export * as _20230420T211446071Z from './20230420T211446071Z-did-cache';
@@ -0,0 +1,11 @@
1
+ import { Kysely, Migration, MigrationProvider } from 'kysely';
2
+ export declare class CtxMigrationProvider<T> implements MigrationProvider {
3
+ private migrations;
4
+ private ctx;
5
+ constructor(migrations: Record<string, CtxMigration<T>>, ctx: T);
6
+ getMigrations(): Promise<Record<string, Migration>>;
7
+ }
8
+ export interface CtxMigration<T> {
9
+ up(db: Kysely<unknown>, ctx: T): Promise<void>;
10
+ down?(db: Kysely<unknown>, ctx: T): Promise<void>;
11
+ }
@@ -0,0 +1,86 @@
1
+ import { AnyQb, DbRef } from './util';
2
+ export type Cursor = {
3
+ primary: string;
4
+ secondary: string;
5
+ };
6
+ export type LabeledResult = {
7
+ primary: string | number;
8
+ secondary: string | number;
9
+ };
10
+ /**
11
+ * The GenericKeyset is an abstract class that sets-up the interface and partial implementation
12
+ * of a keyset-paginated cursor with two parts. There are three types involved:
13
+ * - Result: a raw result (i.e. a row from the db) containing data that will make-up a cursor.
14
+ * - E.g. { createdAt: '2022-01-01T12:00:00Z', cid: 'bafyx' }
15
+ * - LabeledResult: a Result processed such that the "primary" and "secondary" parts of the cursor are labeled.
16
+ * - E.g. { primary: '2022-01-01T12:00:00Z', secondary: 'bafyx' }
17
+ * - Cursor: the two string parts that make-up the packed/string cursor.
18
+ * - E.g. packed cursor '1641038400000__bafyx' in parts { primary: '1641038400000', secondary: 'bafyx' }
19
+ *
20
+ * These types relate as such. Implementers define the relations marked with a *:
21
+ * Result -*-> LabeledResult <-*-> Cursor <--> packed/string cursor
22
+ * ↳ SQL Condition
23
+ */
24
+ export declare abstract class GenericKeyset<R, LR extends LabeledResult> {
25
+ primary: DbRef;
26
+ secondary: DbRef;
27
+ constructor(primary: DbRef, secondary: DbRef);
28
+ abstract labelResult(result: R): LR;
29
+ abstract labeledResultToCursor(labeled: LR): Cursor;
30
+ abstract cursorToLabeledResult(cursor: Cursor): LR;
31
+ packFromResult(results: R | R[]): string | undefined;
32
+ pack(labeled?: LR): string | undefined;
33
+ unpack(cursorStr?: string): LR | undefined;
34
+ packCursor(cursor?: Cursor): string | undefined;
35
+ unpackCursor(cursorStr?: string): Cursor | undefined;
36
+ getSql(labeled?: LR, direction?: 'asc' | 'desc', tryIndex?: boolean): import("kysely").RawBuilder<unknown> | undefined;
37
+ }
38
+ type SortAtCidResult = {
39
+ sortAt: string;
40
+ cid: string;
41
+ };
42
+ type TimeCidLabeledResult = Cursor;
43
+ export declare class TimeCidKeyset<TimeCidResult = SortAtCidResult> extends GenericKeyset<TimeCidResult, TimeCidLabeledResult> {
44
+ labelResult(result: TimeCidResult): TimeCidLabeledResult;
45
+ labeledResultToCursor(labeled: TimeCidLabeledResult): {
46
+ primary: string;
47
+ secondary: string;
48
+ };
49
+ cursorToLabeledResult(cursor: Cursor): {
50
+ primary: string;
51
+ secondary: string;
52
+ };
53
+ }
54
+ export declare class CreatedAtDidKeyset extends TimeCidKeyset<{
55
+ createdAt: string;
56
+ did: string;
57
+ }> {
58
+ labelResult(result: {
59
+ createdAt: string;
60
+ did: string;
61
+ }): {
62
+ primary: string;
63
+ secondary: string;
64
+ };
65
+ }
66
+ export declare class IndexedAtDidKeyset extends TimeCidKeyset<{
67
+ indexedAt: string;
68
+ did: string;
69
+ }> {
70
+ labelResult(result: {
71
+ indexedAt: string;
72
+ did: string;
73
+ }): {
74
+ primary: string;
75
+ secondary: string;
76
+ };
77
+ }
78
+ export declare const paginate: <QB extends AnyQb, K extends GenericKeyset<unknown, any>>(qb: QB, opts: {
79
+ limit?: number;
80
+ cursor?: string;
81
+ direction?: "asc" | "desc";
82
+ keyset: K;
83
+ tryIndex?: boolean;
84
+ nullsLast?: boolean;
85
+ }) => QB;
86
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const tableName = "actor_sync";
2
+ export interface ActorSync {
3
+ did: string;
4
+ commitCid: string;
5
+ repoRev: string | null;
6
+ }
7
+ export type PartialDB = {
8
+ [tableName]: ActorSync;
9
+ };
@@ -0,0 +1,11 @@
1
+ export declare const tableName = "actor";
2
+ export interface ActorTable {
3
+ did: string;
4
+ handle?: string | null;
5
+ indexed_at: string;
6
+ takedownRef?: string | null;
7
+ upstreamStatus?: string | null;
8
+ }
9
+ export type PartialDB = {
10
+ [tableName]: ActorTable;
11
+ };
@@ -0,0 +1,11 @@
1
+ import { Generated } from 'kysely';
2
+ export declare const tableName = "artist_list_item";
3
+ export interface ArtistListItemTable {
4
+ id: Generated<number>;
5
+ song_id: number;
6
+ seq_num: number;
7
+ artist_id: number;
8
+ }
9
+ export type PartialDB = {
10
+ [tableName]: ArtistListItemTable;
11
+ };
@@ -0,0 +1,10 @@
1
+ import { Generated } from 'kysely';
2
+ export declare const tableName = "artist";
3
+ export interface ArtistTable {
4
+ id: Generated<number>;
5
+ name: string;
6
+ mb_id: string;
7
+ }
8
+ export type PartialDB = {
9
+ [tableName]: ArtistTable;
10
+ };
@@ -0,0 +1,14 @@
1
+ export declare const tableName = "playlist_idea";
2
+ export interface PlaylistIdeaTable {
3
+ uri: string;
4
+ title: string;
5
+ description?: string;
6
+ creator_did: string;
7
+ owner_did: string;
8
+ master_playlist_id?: number;
9
+ recommended_playlist_id?: number;
10
+ created_at: string;
11
+ }
12
+ export type PartialDB = {
13
+ [tableName]: PlaylistIdeaTable;
14
+ };
@@ -0,0 +1,11 @@
1
+ import { Generated } from 'kysely';
2
+ export declare const tableName = "playlist_item";
3
+ export interface PlaylistItemTable {
4
+ id: Generated<number>;
5
+ playlist_id: number;
6
+ song_id: number;
7
+ position: number;
8
+ }
9
+ export type PartialDB = {
10
+ [tableName]: PlaylistItemTable;
11
+ };
@@ -0,0 +1,10 @@
1
+ import { Generated } from 'kysely';
2
+ export declare const tableName = "playlist";
3
+ export interface PlaylistTable {
4
+ id: Generated<number>;
5
+ playlist_idea_uri: string;
6
+ type: string;
7
+ }
8
+ export type PartialDB = {
9
+ [tableName]: PlaylistTable;
10
+ };
@@ -0,0 +1,15 @@
1
+ export declare const tableName = "profile";
2
+ export interface ProfileTable {
3
+ uri: string;
4
+ cid: string;
5
+ creator: string;
6
+ display_name?: string;
7
+ description?: string;
8
+ avatar_cid?: string;
9
+ banner_cid?: string;
10
+ created_at: string;
11
+ indexed_at: string;
12
+ }
13
+ export type PartialDB = {
14
+ [tableName]: ProfileTable;
15
+ };
@@ -0,0 +1,12 @@
1
+ export declare const tableName = "record";
2
+ export interface RecordTable {
3
+ uri: string;
4
+ cid: string;
5
+ did: string;
6
+ json: string;
7
+ indexed_at: string;
8
+ takedown_ref?: string;
9
+ }
10
+ export type PartialDB = {
11
+ [tableName]: RecordTable;
12
+ };
@@ -0,0 +1,12 @@
1
+ import { Generated } from 'kysely';
2
+ export declare const tableName = "song";
3
+ export interface SongTable {
4
+ id: Generated<number>;
5
+ track_name: string;
6
+ track_mb_id: string;
7
+ album_artwork_ref?: string;
8
+ created_at?: string;
9
+ }
10
+ export type PartialDB = {
11
+ [tableName]: SongTable;
12
+ };
@@ -0,0 +1,9 @@
1
+ import { Pool as PgPool } from 'pg';
2
+ export type PgOptions = {
3
+ url: string;
4
+ pool?: PgPool;
5
+ schema?: string;
6
+ poolSize?: number;
7
+ poolMaxUses?: number;
8
+ poolIdleTimeoutMs?: number;
9
+ };
@@ -0,0 +1,20 @@
1
+ import { DummyDriver, DynamicModule, ExpressionBuilder, RawBuilder, SelectQueryBuilder, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from 'kysely';
2
+ import { DatabaseSchema, DatabaseSchemaType } from './database-schema';
3
+ export declare const actorWhereClause: (actor: string) => RawBuilder<0 | 1>;
4
+ export declare const notSoftDeletedClause: (alias: DbRef) => RawBuilder<unknown>;
5
+ export declare const softDeleted: (actorOrRecord: {
6
+ takedownRef: string | null;
7
+ }) => boolean;
8
+ export declare const countAll: RawBuilder<number>;
9
+ export declare const excluded: <T>(db: DatabaseSchema, col: any) => RawBuilder<T>;
10
+ export declare const noMatch: RawBuilder<unknown>;
11
+ export declare const valuesList: (vals: unknown[]) => RawBuilder<unknown>;
12
+ export declare const dummyDialect: {
13
+ createAdapter(): SqliteAdapter;
14
+ createDriver(): DummyDriver;
15
+ createIntrospector(db: any): SqliteIntrospector;
16
+ createQueryCompiler(): SqliteQueryCompiler;
17
+ };
18
+ export type DbRef = RawBuilder | ReturnType<DynamicModule['ref']>;
19
+ export type Subquery = ExpressionBuilder<DatabaseSchemaType, any>;
20
+ export type AnyQb = SelectQueryBuilder<any, any, any>;
@@ -0,0 +1,11 @@
1
+ import { IdResolver } from '@atproto/identity';
2
+ import http from 'node:http';
3
+ import { Database } from './db';
4
+ export { RepoSubscription } from './subscription';
5
+ export declare class DataPlaneServer {
6
+ server: http.Server;
7
+ idResolver: IdResolver;
8
+ constructor(server: http.Server, idResolver: IdResolver);
9
+ static create(db: Database, port: number, plcUrl?: string): Promise<DataPlaneServer>;
10
+ destroy(): Promise<void>;
11
+ }
@@ -0,0 +1,32 @@
1
+ import { IdResolver } from '@atproto/identity';
2
+ import { WriteOpAction } from '@atproto/repo';
3
+ import { AtUri } from '@atproto/syntax';
4
+ import { CID } from 'multiformats/cid';
5
+ import { Database } from '../db';
6
+ import * as PlaylistIdea from './plugins/playlist-idea';
7
+ import * as Profile from './plugins/profile';
8
+ import { RecordProcessor } from './processor';
9
+ export declare class IndexingService {
10
+ db: Database;
11
+ idResolver: IdResolver;
12
+ records: {
13
+ playlistIdea: PlaylistIdea.PluginType;
14
+ profile: Profile.PluginType;
15
+ };
16
+ constructor(db: Database, idResolver: IdResolver);
17
+ transact(txn: Database): IndexingService;
18
+ indexRecord(uri: AtUri, cid: CID, obj: unknown, action: WriteOpAction.Create | WriteOpAction.Update, timestamp: string): Promise<void>;
19
+ deleteRecord(uri: AtUri, cascading?: boolean): Promise<void>;
20
+ indexHandle(did: string, timestamp: string, force?: boolean): Promise<void>;
21
+ indexRepo(did: string, commit?: string): Promise<void>;
22
+ updateActorStatus(did: string, active: boolean, status?: string): Promise<void>;
23
+ setCommitLastSeen(did: string, commit: CID, rev: string): Promise<void>;
24
+ getCurrentRecords(did: string): Promise<Record<string, {
25
+ uri: AtUri;
26
+ cid: CID;
27
+ }>>;
28
+ findIndexerForCollection(collection: string): RecordProcessor<unknown, unknown> | undefined;
29
+ deleteActor(did: string): Promise<void>;
30
+ private getActorIsHosted;
31
+ unindexActor(did: string): Promise<void>;
32
+ }
@@ -0,0 +1,14 @@
1
+ import { Selectable } from 'kysely';
2
+ import { MasterPlaylist, Record as PlaylistIdeaRecord, RecommendedPlaylist } from '../../../../lexicons/types/com/clioplaylists/alpha/feed/playlistIdea';
3
+ import { Database } from '../../db';
4
+ import { DatabaseSchemaType } from '../../db/database-schema';
5
+ import { RecordProcessor } from '../processor';
6
+ type PlaylistIdea = Selectable<DatabaseSchemaType['playlist_idea']>;
7
+ type IndexedPlaylistIdea = {
8
+ playlistIdea: PlaylistIdea;
9
+ masterPlaylist?: MasterPlaylist;
10
+ recommendedPlaylist?: RecommendedPlaylist;
11
+ };
12
+ export type PluginType = RecordProcessor<PlaylistIdeaRecord, IndexedPlaylistIdea>;
13
+ export declare const makePlugin: (db: Database) => PluginType;
14
+ export default makePlugin;
@@ -0,0 +1,8 @@
1
+ import * as Profile from '../../../../lexicons/types/com/clioplaylists/alpha/actor/profile';
2
+ import { Database } from '../../db';
3
+ import { DatabaseSchemaType } from '../../db/database-schema';
4
+ import { RecordProcessor } from '../processor';
5
+ type IndexedProfile = DatabaseSchemaType['profile'];
6
+ export type PluginType = RecordProcessor<Profile.Record, IndexedProfile>;
7
+ export declare const makePlugin: (db: Database) => PluginType;
8
+ export default makePlugin;
@@ -0,0 +1,22 @@
1
+ import { AtUri } from '@atproto/syntax';
2
+ import { CID } from 'multiformats/cid';
3
+ import { Database } from '../db';
4
+ import { DatabaseSchema } from '../db/database-schema';
5
+ type RecordProcessorParams<T, S> = {
6
+ lexId: string;
7
+ insertFn: (db: DatabaseSchema, uri: AtUri, cid: CID, obj: T, timestamp: string) => Promise<S | null>;
8
+ findDuplicate: (db: DatabaseSchema, uri: AtUri, obj: T) => Promise<AtUri | null>;
9
+ deleteFn: (db: DatabaseSchema, uri: AtUri) => Promise<S | null>;
10
+ };
11
+ export declare class RecordProcessor<T, S> {
12
+ private params;
13
+ collection: string;
14
+ db: DatabaseSchema;
15
+ constructor(appDb: Database, params: RecordProcessorParams<T, S>);
16
+ matchesSchema(obj: unknown): obj is T;
17
+ assertValidRecord(obj: unknown): asserts obj is T;
18
+ insertRecord(uri: AtUri, cid: CID, obj: unknown, timestamp: string): Promise<void>;
19
+ updateRecord(uri: AtUri, cid: CID, obj: unknown, timestamp: string): Promise<void>;
20
+ deleteRecord(uri: AtUri, cascading?: boolean): Promise<void>;
21
+ }
22
+ export default RecordProcessor;
@@ -0,0 +1,6 @@
1
+ import { IdResolver } from '@atproto/identity';
2
+ import { ServiceImpl } from '@connectrpc/connect';
3
+ import { ClioService } from '../../../rpc/clio_connect';
4
+ import { Database } from '../db';
5
+ declare const _default: (_db: Database, idResolver: IdResolver) => Partial<ServiceImpl<typeof ClioService>>;
6
+ export default _default;