@clioplaylists/clio 0.1.7 → 0.1.9
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/dist/api/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.d.ts +3 -0
- package/dist/api/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.js +70 -0
- package/dist/api/health.js +10 -3
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +40 -2
- package/dist/api/oauth.d.ts +3 -0
- package/dist/api/oauth.js +63 -0
- package/dist/api/util.d.ts +1 -0
- package/dist/api/util.js +11 -6
- package/dist/api/well-known.d.ts +3 -0
- package/dist/api/well-known.js +35 -0
- package/dist/auth-verifier.d.ts +17 -4
- package/dist/auth-verifier.js +171 -165
- package/dist/client.js +15 -8
- package/dist/config.d.ts +23 -0
- package/dist/config.js +87 -7
- package/dist/context.d.ts +14 -0
- package/dist/context.js +17 -1
- package/dist/dataplane/client/hosts.d.ts +21 -0
- package/dist/dataplane/client/hosts.js +29 -0
- package/dist/dataplane/client/index.d.ts +13 -0
- package/dist/dataplane/client/index.js +120 -0
- package/dist/dataplane/client/util.d.ts +20 -0
- package/dist/dataplane/client/util.js +92 -0
- package/dist/dataplane/index.js +18 -2
- package/dist/dataplane/server/background.d.ts +1 -1
- package/dist/dataplane/server/background.js +12 -5
- package/dist/dataplane/server/db/database-schema.d.ts +5 -1
- package/dist/dataplane/server/db/database-schema.js +2 -1
- package/dist/dataplane/server/db/db.js +60 -20
- package/dist/dataplane/server/db/index.js +17 -1
- package/dist/dataplane/server/db/migrations/20250515T045948368Z-init.d.ts +3 -0
- package/dist/dataplane/server/db/migrations/20250515T045948368Z-init.js +170 -0
- package/dist/dataplane/server/db/migrations/20260119T210000000Z-song-recommendation.d.ts +3 -0
- package/dist/dataplane/server/db/migrations/20260119T210000000Z-song-recommendation.js +36 -0
- package/dist/dataplane/server/db/migrations/20260119T220000000Z-oauth.d.ts +3 -0
- package/dist/dataplane/server/db/migrations/20260119T220000000Z-oauth.js +25 -0
- package/dist/dataplane/server/db/migrations/index.d.ts +3 -2
- package/dist/dataplane/server/db/migrations/index.js +39 -2
- package/dist/dataplane/server/db/migrations/provider.js +5 -1
- package/dist/dataplane/server/db/pagination.d.ts +1 -1
- package/dist/dataplane/server/db/pagination.js +38 -25
- package/dist/dataplane/server/db/tables/actor-sync.d.ts +2 -2
- package/dist/dataplane/server/db/tables/actor-sync.js +4 -1
- package/dist/dataplane/server/db/tables/actor.d.ts +3 -3
- package/dist/dataplane/server/db/tables/actor.js +4 -1
- package/dist/dataplane/server/db/tables/artist-list-item.d.ts +2 -2
- package/dist/dataplane/server/db/tables/artist-list-item.js +4 -1
- package/dist/dataplane/server/db/tables/artist.js +4 -1
- package/dist/dataplane/server/db/tables/oauth-session.d.ts +9 -0
- package/dist/dataplane/server/db/tables/oauth-session.js +4 -0
- package/dist/dataplane/server/db/tables/oauth-state.d.ts +10 -0
- package/dist/dataplane/server/db/tables/oauth-state.js +4 -0
- package/dist/dataplane/server/db/tables/playlist-idea.d.ts +3 -3
- package/dist/dataplane/server/db/tables/playlist-idea.js +4 -1
- package/dist/dataplane/server/db/tables/playlist-item.js +4 -1
- package/dist/dataplane/server/db/tables/playlist.d.ts +1 -0
- package/dist/dataplane/server/db/tables/playlist.js +4 -1
- package/dist/dataplane/server/db/tables/profile.d.ts +5 -5
- package/dist/dataplane/server/db/tables/profile.js +4 -1
- package/dist/dataplane/server/db/tables/record.d.ts +1 -1
- package/dist/dataplane/server/db/tables/record.js +4 -1
- package/dist/dataplane/server/db/tables/song-recommendation.d.ts +17 -0
- package/dist/dataplane/server/db/tables/song-recommendation.js +4 -0
- package/dist/dataplane/server/db/tables/song.d.ts +2 -2
- package/dist/dataplane/server/db/tables/song.js +4 -1
- package/dist/dataplane/server/db/tables/subscription-cursor.d.ts +9 -0
- package/dist/dataplane/server/db/tables/subscription-cursor.js +4 -0
- package/dist/dataplane/server/db/types.js +2 -1
- package/dist/dataplane/server/db/util.d.ts +7 -3
- package/dist/dataplane/server/db/util.js +26 -18
- package/dist/dataplane/server/index.js +21 -13
- package/dist/dataplane/server/indexing/index.d.ts +2 -0
- package/dist/dataplane/server/indexing/index.js +82 -66
- package/dist/dataplane/server/indexing/plugins/playlist-idea.d.ts +1 -2
- package/dist/dataplane/server/indexing/plugins/playlist-idea.js +50 -41
- package/dist/dataplane/server/indexing/plugins/profile.js +45 -12
- package/dist/dataplane/server/indexing/plugins/song-recommendation.d.ts +9 -0
- package/dist/dataplane/server/indexing/plugins/song-recommendation.js +101 -0
- package/dist/dataplane/server/indexing/processor.js +12 -11
- package/dist/dataplane/server/routes/identity.d.ts +19 -0
- package/dist/dataplane/server/routes/identity.js +32 -25
- package/dist/dataplane/server/routes/index.js +15 -10
- package/dist/dataplane/server/routes/profile.js +17 -25
- package/dist/dataplane/server/routes/records.d.ts +18 -0
- package/dist/dataplane/server/routes/records.js +48 -22
- package/dist/dataplane/server/routes/sync.js +5 -3
- package/dist/dataplane/server/storage/subscription-cursor.d.ts +3 -0
- package/dist/dataplane/server/storage/subscription-cursor.js +25 -0
- package/dist/dataplane/server/subscription.d.ts +6 -3
- package/dist/dataplane/server/subscription.js +73 -63
- package/dist/error.js +9 -5
- package/dist/index.d.ts +8 -3
- package/dist/index.js +96 -27
- package/dist/lexicons/index.d.ts +3 -210
- package/dist/lexicons/index.js +26 -403
- package/dist/lexicons/lexicons.d.ts +409 -8107
- package/dist/lexicons/lexicons.js +134 -4276
- package/dist/lexicons/types/com/atproto/repo/strongRef.d.ts +4 -4
- package/dist/lexicons/types/com/atproto/repo/strongRef.js +13 -9
- package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.d.ts +10 -8
- package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.js +13 -9
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.d.ts +20 -11
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.js +29 -14
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.d.ts +36 -0
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/getRecommendedPlaylistsByUser.js +6 -0
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.d.ts +11 -14
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.js +20 -23
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/recommendedPlaylist.d.ts +18 -0
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/recommendedPlaylist.js +15 -0
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/songRecommendation.d.ts +18 -0
- package/dist/lexicons/types/com/clioplaylists/alpha/feed/songRecommendation.js +15 -0
- package/dist/lexicons/util.d.ts +33 -2
- package/dist/lexicons/util.js +32 -4
- package/dist/logger.js +16 -10
- package/dist/oauth/client.d.ts +14 -0
- package/dist/oauth/client.js +126 -0
- package/dist/oauth/pds-agent.d.ts +3 -0
- package/dist/oauth/pds-agent.js +15 -0
- package/dist/rpc/clio_connect.d.ts +101 -11
- package/dist/rpc/clio_connect.js +138 -45
- package/dist/rpc/clio_pb.d.ts +448 -30
- package/dist/rpc/clio_pb.js +967 -272
- package/dist/start.js +9 -1
- package/dist/util/retry.js +10 -9
- package/dist/util/uris.js +6 -3
- package/dist/util.d.ts +0 -1
- package/dist/util.js +61 -20
- package/package.json +26 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Selectable } from 'kysely';
|
|
2
|
-
import { MasterPlaylist, Record as PlaylistIdeaRecord
|
|
2
|
+
import { MasterPlaylist, Record as PlaylistIdeaRecord } from '../../../../lexicons/types/com/clioplaylists/alpha/feed/playlistIdea';
|
|
3
3
|
import { Database } from '../../db';
|
|
4
4
|
import { DatabaseSchemaType } from '../../db/database-schema';
|
|
5
5
|
import { RecordProcessor } from '../processor';
|
|
@@ -7,7 +7,6 @@ type PlaylistIdea = Selectable<DatabaseSchemaType['playlist_idea']>;
|
|
|
7
7
|
type IndexedPlaylistIdea = {
|
|
8
8
|
playlistIdea: PlaylistIdea;
|
|
9
9
|
masterPlaylist?: MasterPlaylist;
|
|
10
|
-
recommendedPlaylist?: RecommendedPlaylist;
|
|
11
10
|
};
|
|
12
11
|
export type PluginType = RecordProcessor<PlaylistIdeaRecord, IndexedPlaylistIdea>;
|
|
13
12
|
export declare const makePlugin: (db: Database) => PluginType;
|
|
@@ -1,16 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.makePlugin = void 0;
|
|
37
|
+
const syntax_1 = require("@atproto/syntax");
|
|
38
|
+
const lex = __importStar(require("../../../../lexicons/lexicons"));
|
|
39
|
+
const processor_1 = require("../processor");
|
|
4
40
|
const lexId = lex.ids.ComClioplaylistsAlphaFeedPlaylistIdea;
|
|
5
41
|
const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
6
42
|
const masterPlaylist = obj.masterPlaylist;
|
|
7
|
-
const recommendedPlaylist = obj.recommendedPlaylist;
|
|
8
|
-
let masterPlaylistId;
|
|
9
|
-
let recommendedPlaylistId;
|
|
10
43
|
if (masterPlaylist) {
|
|
11
44
|
const playlist = {
|
|
12
45
|
playlist_idea_uri: uri.toString(),
|
|
13
46
|
type: 'master',
|
|
47
|
+
name: `${obj.title} (master)`,
|
|
14
48
|
};
|
|
15
49
|
const insertedPlaylistIdResponse = await db
|
|
16
50
|
.insertInto('playlist')
|
|
@@ -22,8 +56,8 @@ const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
|
22
56
|
return {
|
|
23
57
|
track_name: song.trackName,
|
|
24
58
|
track_mb_id: song.trackMbId,
|
|
25
|
-
album_artwork_ref: song.
|
|
26
|
-
|
|
59
|
+
album_artwork_ref: song.albumArtworkRef?.ref.toString(),
|
|
60
|
+
indexed_at: timestamp,
|
|
27
61
|
};
|
|
28
62
|
});
|
|
29
63
|
const insertedSongIdsResponse = await db
|
|
@@ -43,26 +77,13 @@ const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
|
43
77
|
await db.insertInto('playlist_item').values(playlistItems).execute();
|
|
44
78
|
}
|
|
45
79
|
}
|
|
46
|
-
if (recommendedPlaylist) {
|
|
47
|
-
const playlist = {
|
|
48
|
-
playlist_idea_uri: uri.toString(),
|
|
49
|
-
type: 'recommended',
|
|
50
|
-
};
|
|
51
|
-
await db
|
|
52
|
-
.insertInto('playlist')
|
|
53
|
-
.values(playlist)
|
|
54
|
-
.onConflict((oc) => oc.doNothing())
|
|
55
|
-
.execute();
|
|
56
|
-
}
|
|
57
80
|
const playlistIdea = {
|
|
58
81
|
uri: uri.toString(),
|
|
59
82
|
title: obj.title,
|
|
60
83
|
description: obj.description,
|
|
61
84
|
creator_did: obj.creatorDid,
|
|
62
85
|
owner_did: obj.ownerDid,
|
|
63
|
-
|
|
64
|
-
recommended_playlist_id: recommendedPlaylistId,
|
|
65
|
-
created_at: normalizeDatetimeAlways(obj.createdAt),
|
|
86
|
+
created_at: (0, syntax_1.normalizeDatetimeAlways)(obj.createdAt),
|
|
66
87
|
};
|
|
67
88
|
const [insertedPlaylistIdea] = await Promise.all([
|
|
68
89
|
db
|
|
@@ -78,7 +99,6 @@ const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
|
78
99
|
return {
|
|
79
100
|
playlistIdea: insertedPlaylistIdea,
|
|
80
101
|
masterPlaylist: masterPlaylist,
|
|
81
|
-
recommendedPlaylist: recommendedPlaylist,
|
|
82
102
|
};
|
|
83
103
|
};
|
|
84
104
|
const findDuplicate = async () => {
|
|
@@ -87,40 +107,29 @@ const findDuplicate = async () => {
|
|
|
87
107
|
const deleteFn = async (db, uri) => {
|
|
88
108
|
const uriStr = uri.toString();
|
|
89
109
|
const [deletedPlaylistIdea, deletedPlaylists] = await Promise.all([
|
|
90
|
-
db
|
|
91
|
-
|
|
92
|
-
.where('uri', '=', uriStr)
|
|
93
|
-
.returningAll()
|
|
94
|
-
.executeTakeFirst(),
|
|
95
|
-
db
|
|
96
|
-
.deleteFrom('playlist')
|
|
97
|
-
.where('playlist_idea_uri', '=', uriStr)
|
|
98
|
-
.returningAll()
|
|
99
|
-
.execute(),
|
|
110
|
+
db.deleteFrom('playlist_idea').where('uri', '=', uriStr).returningAll().executeTakeFirst(),
|
|
111
|
+
db.deleteFrom('playlist').where('playlist_idea_uri', '=', uriStr).returningAll().execute(),
|
|
100
112
|
]);
|
|
101
113
|
const deletedPlaylistIds = deletedPlaylists.map((deletedPlaylist) => {
|
|
102
114
|
return deletedPlaylist.id;
|
|
103
115
|
});
|
|
104
116
|
if (deletedPlaylists) {
|
|
105
|
-
await db
|
|
106
|
-
.deleteFrom('playlist_item')
|
|
107
|
-
.where('playlist_id', 'in', deletedPlaylistIds)
|
|
108
|
-
.execute();
|
|
117
|
+
await db.deleteFrom('playlist_item').where('playlist_id', 'in', deletedPlaylistIds).execute();
|
|
109
118
|
}
|
|
110
119
|
return deletedPlaylistIdea
|
|
111
120
|
? {
|
|
112
121
|
playlistIdea: deletedPlaylistIdea,
|
|
113
122
|
masterPlaylist: undefined, // TODO: Figure out if this should be undefined
|
|
114
|
-
recommendedPlaylist: undefined, // TODO: Figure out if this should be undefined
|
|
115
123
|
}
|
|
116
124
|
: null;
|
|
117
125
|
};
|
|
118
|
-
|
|
119
|
-
return new RecordProcessor(db, {
|
|
126
|
+
const makePlugin = (db) => {
|
|
127
|
+
return new processor_1.RecordProcessor(db, {
|
|
120
128
|
lexId,
|
|
121
129
|
insertFn,
|
|
122
130
|
findDuplicate,
|
|
123
131
|
deleteFn,
|
|
124
132
|
});
|
|
125
133
|
};
|
|
126
|
-
|
|
134
|
+
exports.makePlugin = makePlugin;
|
|
135
|
+
exports.default = exports.makePlugin;
|
|
@@ -1,5 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.makePlugin = void 0;
|
|
37
|
+
const lex = __importStar(require("../../../../lexicons/lexicons"));
|
|
38
|
+
const processor_1 = require("../processor");
|
|
3
39
|
const lexId = lex.ids.ComClioplaylistsAlphaActorProfile;
|
|
4
40
|
const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
5
41
|
if (uri.rkey !== 'self')
|
|
@@ -9,9 +45,9 @@ const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
|
9
45
|
.values({
|
|
10
46
|
uri: uri.toString(),
|
|
11
47
|
cid: cid.toString(),
|
|
12
|
-
|
|
48
|
+
creator_did: uri.host,
|
|
13
49
|
display_name: obj.displayName,
|
|
14
|
-
description: obj.
|
|
50
|
+
description: obj.bio,
|
|
15
51
|
avatar_cid: obj.avatar?.ref.toString(),
|
|
16
52
|
banner_cid: obj.banner?.ref.toString(),
|
|
17
53
|
created_at: obj.createdAt ?? new Date().toISOString(),
|
|
@@ -26,19 +62,16 @@ const findDuplicate = async () => {
|
|
|
26
62
|
return null;
|
|
27
63
|
};
|
|
28
64
|
const deleteFn = async (db, uri) => {
|
|
29
|
-
const deleted = await db
|
|
30
|
-
.deleteFrom('profile')
|
|
31
|
-
.where('uri', '=', uri.toString())
|
|
32
|
-
.returningAll()
|
|
33
|
-
.executeTakeFirst();
|
|
65
|
+
const deleted = await db.deleteFrom('profile').where('uri', '=', uri.toString()).returningAll().executeTakeFirst();
|
|
34
66
|
return deleted || null;
|
|
35
67
|
};
|
|
36
|
-
|
|
37
|
-
return new RecordProcessor(db, {
|
|
68
|
+
const makePlugin = (db) => {
|
|
69
|
+
return new processor_1.RecordProcessor(db, {
|
|
38
70
|
lexId,
|
|
39
71
|
insertFn,
|
|
40
72
|
findDuplicate,
|
|
41
73
|
deleteFn,
|
|
42
74
|
});
|
|
43
75
|
};
|
|
44
|
-
|
|
76
|
+
exports.makePlugin = makePlugin;
|
|
77
|
+
exports.default = exports.makePlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Selectable } from 'kysely';
|
|
2
|
+
import type { Record as SongRecommendationRecord } from '../../../../lexicons/types/com/clioplaylists/alpha/feed/songRecommendation';
|
|
3
|
+
import { Database } from '../../db';
|
|
4
|
+
import { DatabaseSchemaType } from '../../db/database-schema';
|
|
5
|
+
import { RecordProcessor } from '../processor';
|
|
6
|
+
type IndexedSongRecommendation = Selectable<DatabaseSchemaType['song_recommendation']>;
|
|
7
|
+
export type PluginType = RecordProcessor<SongRecommendationRecord, IndexedSongRecommendation>;
|
|
8
|
+
export declare const makePlugin: (db: Database) => PluginType;
|
|
9
|
+
export default makePlugin;
|
|
@@ -0,0 +1,101 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.makePlugin = void 0;
|
|
37
|
+
const syntax_1 = require("@atproto/syntax");
|
|
38
|
+
const lex = __importStar(require("../../../../lexicons/lexicons"));
|
|
39
|
+
const processor_1 = require("../processor");
|
|
40
|
+
const lexId = lex.ids.ComClioplaylistsAlphaFeedSongRecommendation;
|
|
41
|
+
const insertFn = async (db, uri, cid, obj, timestamp) => {
|
|
42
|
+
const recommenderDid = uri.host;
|
|
43
|
+
const playlistIdeaUri = obj.playlistIdea.uri;
|
|
44
|
+
const playlistIdeaCid = obj.playlistIdea.cid;
|
|
45
|
+
const insertedSong = await db
|
|
46
|
+
.insertInto('song')
|
|
47
|
+
.values({
|
|
48
|
+
track_name: obj.song.trackName,
|
|
49
|
+
track_mb_id: obj.song.trackMbId,
|
|
50
|
+
album_artwork_ref: obj.song.albumArtworkRef?.ref.toString(),
|
|
51
|
+
indexed_at: timestamp,
|
|
52
|
+
})
|
|
53
|
+
.onConflict((oc) => oc.column('track_mb_id').doUpdateSet({
|
|
54
|
+
track_name: obj.song.trackName,
|
|
55
|
+
album_artwork_ref: obj.song.albumArtworkRef?.ref.toString(),
|
|
56
|
+
indexed_at: timestamp,
|
|
57
|
+
}))
|
|
58
|
+
.returning('id')
|
|
59
|
+
.executeTakeFirst();
|
|
60
|
+
if (!insertedSong?.id) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const inserted = await db
|
|
64
|
+
.insertInto('song_recommendation')
|
|
65
|
+
.values({
|
|
66
|
+
uri: uri.toString(),
|
|
67
|
+
cid: cid.toString(),
|
|
68
|
+
recommender_did: recommenderDid,
|
|
69
|
+
playlist_idea_uri: playlistIdeaUri,
|
|
70
|
+
playlist_idea_cid: playlistIdeaCid,
|
|
71
|
+
song_id: insertedSong.id,
|
|
72
|
+
note: obj.note ?? null,
|
|
73
|
+
created_at: (0, syntax_1.normalizeDatetimeAlways)(obj.createdAt),
|
|
74
|
+
indexed_at: timestamp,
|
|
75
|
+
})
|
|
76
|
+
.onConflict((oc) => oc.column('uri').doNothing())
|
|
77
|
+
.returningAll()
|
|
78
|
+
.executeTakeFirst();
|
|
79
|
+
return inserted || null;
|
|
80
|
+
};
|
|
81
|
+
const findDuplicate = async () => {
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
const deleteFn = async (db, uri) => {
|
|
85
|
+
const deleted = await db
|
|
86
|
+
.deleteFrom('song_recommendation')
|
|
87
|
+
.where('uri', '=', uri.toString())
|
|
88
|
+
.returningAll()
|
|
89
|
+
.executeTakeFirst();
|
|
90
|
+
return deleted || null;
|
|
91
|
+
};
|
|
92
|
+
const makePlugin = (db) => {
|
|
93
|
+
return new processor_1.RecordProcessor(db, {
|
|
94
|
+
lexId,
|
|
95
|
+
insertFn,
|
|
96
|
+
findDuplicate,
|
|
97
|
+
deleteFn,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
exports.makePlugin = makePlugin;
|
|
101
|
+
exports.default = exports.makePlugin;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecordProcessor = void 0;
|
|
4
|
+
const lexicon_1 = require("@atproto/lexicon");
|
|
5
|
+
const lexicons_1 = require("../../../lexicons/lexicons");
|
|
6
|
+
class RecordProcessor {
|
|
4
7
|
params;
|
|
5
8
|
collection;
|
|
6
9
|
db;
|
|
@@ -19,7 +22,7 @@ export class RecordProcessor {
|
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
assertValidRecord(obj) {
|
|
22
|
-
lexicons.assertValidRecord(this.params.lexId, obj);
|
|
25
|
+
lexicons_1.lexicons.assertValidRecord(this.params.lexId, obj);
|
|
23
26
|
}
|
|
24
27
|
async insertRecord(uri, cid, obj, timestamp) {
|
|
25
28
|
this.assertValidRecord(obj);
|
|
@@ -29,7 +32,7 @@ export class RecordProcessor {
|
|
|
29
32
|
uri: uri.toString(),
|
|
30
33
|
cid: cid.toString(),
|
|
31
34
|
did: uri.host,
|
|
32
|
-
json: stringifyLex(obj),
|
|
35
|
+
json: (0, lexicon_1.stringifyLex)(obj),
|
|
33
36
|
indexed_at: timestamp,
|
|
34
37
|
})
|
|
35
38
|
.onConflict((oc) => oc.doNothing())
|
|
@@ -47,7 +50,7 @@ export class RecordProcessor {
|
|
|
47
50
|
.where('uri', '=', uri.toString())
|
|
48
51
|
.set({
|
|
49
52
|
cid: cid.toString(),
|
|
50
|
-
json: stringifyLex(obj),
|
|
53
|
+
json: (0, lexicon_1.stringifyLex)(obj),
|
|
51
54
|
indexed_at: timestamp,
|
|
52
55
|
})
|
|
53
56
|
.execute();
|
|
@@ -62,11 +65,9 @@ export class RecordProcessor {
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
async deleteRecord(uri, cascading = false) {
|
|
65
|
-
await this.db
|
|
66
|
-
.deleteFrom('record')
|
|
67
|
-
.where('uri', '=', uri.toString())
|
|
68
|
-
.execute();
|
|
68
|
+
await this.db.deleteFrom('record').where('uri', '=', uri.toString()).execute();
|
|
69
69
|
await this.params.deleteFn(this.db, uri);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
exports.RecordProcessor = RecordProcessor;
|
|
73
|
+
exports.default = RecordProcessor;
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { IdResolver } from '@atproto/identity';
|
|
2
|
+
import { Timestamp } from '@bufbuild/protobuf';
|
|
2
3
|
import { ServiceImpl } from '@connectrpc/connect';
|
|
3
4
|
import { ClioService } from '../../../rpc/clio_connect';
|
|
4
5
|
import { Database } from '../db';
|
|
5
6
|
declare const _default: (_db: Database, idResolver: IdResolver) => Partial<ServiceImpl<typeof ClioService>>;
|
|
6
7
|
export default _default;
|
|
8
|
+
export declare const getIdentityByDid: (_db: Database, idResolver: IdResolver) => (req: {
|
|
9
|
+
did: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
did: string;
|
|
12
|
+
handle: string | undefined;
|
|
13
|
+
keys: Buffer<ArrayBuffer>;
|
|
14
|
+
services: Buffer<ArrayBuffer>;
|
|
15
|
+
updated: Timestamp;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getIdentityByHandle: (_db: Database, idResolver: IdResolver) => (req: {
|
|
18
|
+
handle: string;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
did: string;
|
|
21
|
+
handle: string | undefined;
|
|
22
|
+
keys: Buffer<ArrayBuffer>;
|
|
23
|
+
services: Buffer<ArrayBuffer>;
|
|
24
|
+
updated: Timestamp;
|
|
25
|
+
}>;
|
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return getResultFromDoc(doc);
|
|
11
|
-
},
|
|
12
|
-
async getIdentityByHandle(req) {
|
|
13
|
-
const did = await idResolver.handle.resolve(req.handle);
|
|
14
|
-
if (!did) {
|
|
15
|
-
throw new ConnectError('identity not found', Code.NotFound);
|
|
16
|
-
}
|
|
17
|
-
const doc = await idResolver.did.resolve(did);
|
|
18
|
-
if (!doc || did !== getDid(doc)) {
|
|
19
|
-
throw new ConnectError('identity not found', Code.NotFound);
|
|
20
|
-
}
|
|
21
|
-
return getResultFromDoc(doc);
|
|
22
|
-
},
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIdentityByHandle = exports.getIdentityByDid = void 0;
|
|
4
|
+
const identity_1 = require("@atproto/identity");
|
|
5
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
6
|
+
const connect_1 = require("@connectrpc/connect");
|
|
7
|
+
exports.default = (_db, idResolver) => ({
|
|
8
|
+
getIdentityByDid: (0, exports.getIdentityByDid)(_db, idResolver),
|
|
9
|
+
getIdentityByHandle: (0, exports.getIdentityByHandle)(_db, idResolver),
|
|
23
10
|
});
|
|
11
|
+
const getIdentityByDid = (_db, idResolver) => async (req) => {
|
|
12
|
+
const doc = await idResolver.did.resolve(req.did);
|
|
13
|
+
if (!doc) {
|
|
14
|
+
throw new connect_1.ConnectError('identity not found', connect_1.Code.NotFound);
|
|
15
|
+
}
|
|
16
|
+
return getResultFromDoc(doc);
|
|
17
|
+
};
|
|
18
|
+
exports.getIdentityByDid = getIdentityByDid;
|
|
19
|
+
const getIdentityByHandle = (_db, idResolver) => async (req) => {
|
|
20
|
+
const did = await idResolver.handle.resolve(req.handle);
|
|
21
|
+
if (!did) {
|
|
22
|
+
throw new connect_1.ConnectError('identity not found', connect_1.Code.NotFound);
|
|
23
|
+
}
|
|
24
|
+
const doc = await idResolver.did.resolve(did);
|
|
25
|
+
if (!doc || did !== (0, identity_1.getDid)(doc)) {
|
|
26
|
+
throw new connect_1.ConnectError('identity not found', connect_1.Code.NotFound);
|
|
27
|
+
}
|
|
28
|
+
return getResultFromDoc(doc);
|
|
29
|
+
};
|
|
30
|
+
exports.getIdentityByHandle = getIdentityByHandle;
|
|
24
31
|
const getResultFromDoc = (doc) => {
|
|
25
32
|
const keys = {};
|
|
26
33
|
doc.verificationMethod?.forEach((method) => {
|
|
@@ -45,10 +52,10 @@ const getResultFromDoc = (doc) => {
|
|
|
45
52
|
};
|
|
46
53
|
});
|
|
47
54
|
return {
|
|
48
|
-
did: getDid(doc),
|
|
49
|
-
handle: getHandle(doc),
|
|
55
|
+
did: (0, identity_1.getDid)(doc),
|
|
56
|
+
handle: (0, identity_1.getHandle)(doc),
|
|
50
57
|
keys: Buffer.from(JSON.stringify(keys)),
|
|
51
58
|
services: Buffer.from(JSON.stringify(services)),
|
|
52
|
-
updated: Timestamp.fromDate(new Date()),
|
|
59
|
+
updated: protobuf_1.Timestamp.fromDate(new Date()),
|
|
53
60
|
};
|
|
54
61
|
};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const clio_connect_1 = require("../../../rpc/clio_connect");
|
|
7
|
+
const identity_1 = __importDefault(require("./identity"));
|
|
8
|
+
const profile_1 = __importDefault(require("./profile"));
|
|
9
|
+
const records_1 = __importDefault(require("./records"));
|
|
10
|
+
const sync_1 = __importDefault(require("./sync"));
|
|
11
|
+
exports.default = (db, idResolver) => (router) => router.service(clio_connect_1.ClioService, {
|
|
12
|
+
...(0, identity_1.default)(db, idResolver),
|
|
13
|
+
...(0, profile_1.default)(db),
|
|
14
|
+
...(0, records_1.default)(db),
|
|
15
|
+
...(0, sync_1.default)(db),
|
|
11
16
|
async healthCheck() {
|
|
12
17
|
return {};
|
|
13
18
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@atproto/common");
|
|
4
|
+
const util_1 = require("../../../util");
|
|
5
|
+
const records_1 = require("./records");
|
|
6
|
+
exports.default = (db) => ({
|
|
5
7
|
async getActors(req) {
|
|
6
8
|
const { dids } = req;
|
|
7
9
|
if (dids.length === 0) {
|
|
@@ -11,24 +13,22 @@ export default (db) => ({
|
|
|
11
13
|
const chatDeclarationUris = dids.map((did) => `at://${did}/chat.bsky.actor.declaration/self`);
|
|
12
14
|
const [handlesRes, profiles, chatDeclarations] = await Promise.all([
|
|
13
15
|
db.db.selectFrom('actor').selectAll().execute(),
|
|
14
|
-
getRecords(db)({ uris: profileUris }),
|
|
15
|
-
getRecords(db)({ uris: chatDeclarationUris }),
|
|
16
|
+
(0, records_1.getRecords)(db)({ uris: profileUris }),
|
|
17
|
+
(0, records_1.getRecords)(db)({ uris: chatDeclarationUris }),
|
|
16
18
|
]);
|
|
17
|
-
const byDid = keyBy(handlesRes, 'did');
|
|
19
|
+
const byDid = (0, common_1.keyBy)(handlesRes, 'did');
|
|
18
20
|
const actors = dids.map((did, i) => {
|
|
19
21
|
const row = byDid.get(did);
|
|
20
|
-
const chatDeclaration = parseRecordBytes(chatDeclarations.records[i].record);
|
|
22
|
+
const chatDeclaration = (0, util_1.parseRecordBytes)(chatDeclarations.records[i].record);
|
|
21
23
|
return {
|
|
22
24
|
exists: !!row,
|
|
23
25
|
handle: row?.handle ?? undefined,
|
|
24
26
|
profile: profiles.records[i],
|
|
25
|
-
takenDown: !!row?.
|
|
26
|
-
takedownRef: row?.
|
|
27
|
+
takenDown: !!row?.takedown_ref,
|
|
28
|
+
takedownRef: row?.takedown_ref || undefined,
|
|
27
29
|
tombstonedAt: undefined, // in current implementation, tombstoned actors are deleted
|
|
28
|
-
allowIncomingChatsFrom: typeof chatDeclaration?.['allowIncoming'] === 'string'
|
|
29
|
-
|
|
30
|
-
: undefined,
|
|
31
|
-
upstreamStatus: row?.upstreamStatus ?? '',
|
|
30
|
+
allowIncomingChatsFrom: typeof chatDeclaration?.['allowIncoming'] === 'string' ? chatDeclaration['allowIncoming'] : undefined,
|
|
31
|
+
upstreamStatus: row?.upstream_status ?? '',
|
|
32
32
|
createdAt: profiles.records[i].createdAt, // @NOTE profile creation date not trusted in production
|
|
33
33
|
};
|
|
34
34
|
});
|
|
@@ -39,21 +39,13 @@ export default (db) => ({
|
|
|
39
39
|
if (handles.length === 0) {
|
|
40
40
|
return { dids: [] };
|
|
41
41
|
}
|
|
42
|
-
const res = await db.db
|
|
43
|
-
|
|
44
|
-
.where('handle', 'in', handles)
|
|
45
|
-
.selectAll()
|
|
46
|
-
.execute();
|
|
47
|
-
const byHandle = keyBy(res, 'handle');
|
|
42
|
+
const res = await db.db.selectFrom('actor').where('handle', 'in', handles).selectAll().execute();
|
|
43
|
+
const byHandle = (0, common_1.keyBy)(res, 'handle');
|
|
48
44
|
const dids = handles.map((handle) => byHandle.get(handle)?.did ?? '');
|
|
49
45
|
return { dids };
|
|
50
46
|
},
|
|
51
47
|
async updateActorUpstreamStatus(req) {
|
|
52
48
|
const { actorDid, upstreamStatus } = req;
|
|
53
|
-
await db.db
|
|
54
|
-
.updateTable('actor')
|
|
55
|
-
.set({ upstreamStatus })
|
|
56
|
-
.where('did', '=', actorDid)
|
|
57
|
-
.execute();
|
|
49
|
+
await db.db.updateTable('actor').set({ upstream_status: upstreamStatus }).where('did', '=', actorDid).execute();
|
|
58
50
|
},
|
|
59
51
|
});
|
|
@@ -4,8 +4,26 @@ import { Record } from '../../../rpc/clio_pb';
|
|
|
4
4
|
import { Database } from '../db';
|
|
5
5
|
declare const _default: (db: Database) => Partial<ServiceImpl<typeof ClioService>>;
|
|
6
6
|
export default _default;
|
|
7
|
+
export interface Song {
|
|
8
|
+
id: number;
|
|
9
|
+
track_name: string;
|
|
10
|
+
track_mb_id: string;
|
|
11
|
+
album_artwork_ref: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface Playlist {
|
|
14
|
+
id: number;
|
|
15
|
+
playlistIdeaUri: string;
|
|
16
|
+
type: 'recommended' | 'master';
|
|
17
|
+
name: string;
|
|
18
|
+
songs: Song[];
|
|
19
|
+
}
|
|
7
20
|
export declare const getRecords: (db: Database, collection?: string) => (req: {
|
|
8
21
|
uris: string[];
|
|
9
22
|
}) => Promise<{
|
|
10
23
|
records: Record[];
|
|
11
24
|
}>;
|
|
25
|
+
export declare const getRecommendedPlaylistsForPlaylistIdea: (db: Database) => (req: {
|
|
26
|
+
playlistIdeaUri: string;
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
records: Record[];
|
|
29
|
+
}>;
|