@openpeepshq/core 0.1.34 → 0.2.0
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/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +13 -8
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +1 -2
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +116 -135
- package/dist/analytics/report.d.ts +2 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +13 -16
- package/dist/backups/metadata.js +1 -1
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/community.js +1 -0
- package/dist/config/defaults/core.js +13 -8
- package/dist/config/defaults/logs.d.ts +4 -0
- package/dist/config/defaults/logs.js +5 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.js +9 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.js +15 -5
- package/dist/db/migration/importCollections.js +15 -18
- package/dist/db/migration/shared.js +15 -35
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +2 -0
- package/dist/db/pg/filters/posts.js +3 -1
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +8 -8
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +56 -21
- package/dist/db/pg/map/registry.js +87 -50
- package/dist/db/pg/map/relations.js +67 -63
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.js +2 -3
- package/dist/db/pg/queries/activity.js +2 -2
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/schema/documents.js +119 -18
- package/dist/db/pg/schema/edges.js +7 -1
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/_journal.json +8 -1
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +7 -4
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.js +1 -2
- package/dist/groups/finders.d.ts +2 -2
- package/dist/groups/helpers.d.ts +6 -6
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mapping.d.ts +4 -4
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.js +2 -2
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.js +5 -7
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +6 -4
- package/dist/jams/health.js +15 -11
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.d.ts +2 -2
- package/dist/jams/livekit.js +8 -8
- package/dist/jams/mapping.d.ts +10 -10
- package/dist/jams/mutations.d.ts +2 -2
- package/dist/jams/recording.js +1 -1
- package/dist/jams/token.js +13 -17
- package/dist/jobs/index.js +7 -6
- package/dist/jobs/jobDetail.js +5 -6
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +14 -29
- package/dist/log/retention.d.ts +9 -0
- package/dist/log/retention.js +83 -0
- package/dist/log/retentionJobs.d.ts +17 -0
- package/dist/log/retentionJobs.js +50 -0
- package/dist/media/index.js +127 -4
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +7 -4
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/mediaAttachments/mapping.d.ts +1 -1
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/jamModerator/index.js +27 -20
- package/dist/notifications/defaultNotifications/jamModerator/recipients.d.ts +2 -0
- package/dist/notifications/defaultNotifications/jamModerator/recipients.js +5 -0
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
- package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
- package/dist/notifications/defaultNotifications/mention/index.js +20 -24
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +9 -10
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.d.ts +5 -0
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.js +23 -0
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
- package/dist/notifications/eventIcsAttachment.d.ts +6 -0
- package/dist/notifications/eventIcsAttachment.js +32 -0
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.d.ts +11 -1
- package/dist/notifications/helpers.js +38 -9
- package/dist/notifications/jobs.js +16 -7
- package/dist/notifications/mutations.js +13 -2
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/install.js +31 -17
- package/dist/plugins/pluginAuth.js +3 -4
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.d.ts +1 -1
- package/dist/posts/activity.js +2 -3
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +12 -7
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +46 -6
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +170 -18
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +616 -84
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +85 -9
- package/dist/posts/mutations.js +47 -34
- package/dist/posts/pollEnd.js +3 -6
- package/dist/posts/rsvpConfirmationEmail.js +18 -8
- package/dist/posts/threadPreview.js +1 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +1 -2
- package/dist/profileSettings/mapping.d.ts +1 -0
- package/dist/profiles/activitySummary.js +23 -28
- package/dist/profiles/cache.js +15 -8
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.js +7 -5
- package/dist/profiles/mapping.d.ts +10 -10
- package/dist/profiles/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- package/dist/reports/mapping.d.ts +1 -1
- package/dist/roles/mutations.js +20 -21
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +16 -11
- package/dist/server/status.js +6 -7
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.js +13 -4
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +43 -5
- package/dist/stats/mapping.js +9 -2
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -6
- package/LICENSE +0 -674
|
@@ -3,21 +3,17 @@ import { applyDateRangeToEdgeSql, applyLimit, applyPostFilters, applySqlLimit, a
|
|
|
3
3
|
import { isSqlFilter } from '../filters/index.js';
|
|
4
4
|
import { asTable, documentIdColumn, edgeRegistry, getTableForCollection, rowToDocument, } from './registry.js';
|
|
5
5
|
import { normalizeComputedDatetime } from '../mappers.js';
|
|
6
|
-
const buildComputedSelect = (mapData, tableRef) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}),
|
|
15
|
-
]));
|
|
16
|
-
};
|
|
6
|
+
const buildComputedSelect = (mapData, tableRef) => Object.fromEntries((mapData.computedFields ?? []).map((field) => [
|
|
7
|
+
field.alias,
|
|
8
|
+
field.expr({
|
|
9
|
+
table: tableRef,
|
|
10
|
+
collection: mapData.collection,
|
|
11
|
+
activityWindow: mapData.activityWindow,
|
|
12
|
+
}),
|
|
13
|
+
]));
|
|
17
14
|
const mapRowToDoc = (mapData, row) => {
|
|
18
|
-
var _a;
|
|
19
15
|
const doc = rowToDocument(mapData.collection, row);
|
|
20
|
-
for (const field of
|
|
16
|
+
for (const field of mapData.computedFields ?? []) {
|
|
21
17
|
if (field.alias in row) {
|
|
22
18
|
const value = row[field.alias];
|
|
23
19
|
doc[field.alias] =
|
|
@@ -27,11 +23,11 @@ const mapRowToDoc = (mapData, row) => {
|
|
|
27
23
|
return doc;
|
|
28
24
|
};
|
|
29
25
|
const vertexCollectionFor = (relation) => {
|
|
30
|
-
var _a, _b, _c;
|
|
31
26
|
const edgeName = typeof relation.edgeCollection === 'string'
|
|
32
27
|
? relation.edgeCollection
|
|
33
28
|
: relation.edgeCollection.name;
|
|
34
|
-
return (
|
|
29
|
+
return (relation.mapping?.collection ??
|
|
30
|
+
edgeRegistry[edgeName]?.[relation.direction === 'INBOUND' ? 'fromCollection' : 'toCollection']);
|
|
35
31
|
};
|
|
36
32
|
const edgeCollectionName = (edge) => typeof edge === 'string' ? edge : edge.name;
|
|
37
33
|
const parentEdgeColumn = (relation) => relation.direction === 'INBOUND' ? 'toId' : 'fromId';
|
|
@@ -73,7 +69,7 @@ export const fetchFilteredRowsByIds = async (db, mapData, ids) => {
|
|
|
73
69
|
const columns = getTableColumns(tableRef);
|
|
74
70
|
const computedSelect = buildComputedSelect(mapData, tableRef);
|
|
75
71
|
let query = db
|
|
76
|
-
.select(
|
|
72
|
+
.select({ ...columns, ...computedSelect })
|
|
77
73
|
.from(tableRef)
|
|
78
74
|
.where(and(...conditions))
|
|
79
75
|
.$dynamic();
|
|
@@ -88,56 +84,65 @@ export const fetchFilteredRowsByIds = async (db, mapData, ids) => {
|
|
|
88
84
|
return { docs, postFilters };
|
|
89
85
|
};
|
|
90
86
|
const hydrateDocuments = async (db, collection, mapData, rows, postFilters) => {
|
|
91
|
-
var _a, _b, _c, _d;
|
|
92
87
|
let docs = rows;
|
|
93
|
-
for (const relation of
|
|
88
|
+
for (const relation of mapData.relations ?? []) {
|
|
94
89
|
docs = await attachRelation(db, collection, docs, relation);
|
|
95
90
|
}
|
|
96
|
-
for (const fkr of
|
|
91
|
+
for (const fkr of mapData.foreignKeyRelations ?? []) {
|
|
97
92
|
docs = await attachForeignKeyRelation(db, docs, fkr);
|
|
98
93
|
}
|
|
99
94
|
docs = await attachDerivedProperties(db, docs, mapData.derivedProperties);
|
|
100
|
-
docs = applyPostFilters(docs, postFilters
|
|
95
|
+
docs = applyPostFilters(docs, postFilters ?? mapData.filters, postFilters ? undefined : mapData.defaultFilter);
|
|
101
96
|
docs = applySort(docs, mapData.sort);
|
|
102
|
-
for (const relation of
|
|
97
|
+
for (const relation of mapData.postFilterRelations ?? []) {
|
|
103
98
|
docs = await attachRelation(db, collection, docs, relation);
|
|
104
99
|
}
|
|
105
|
-
for (const fkr of
|
|
100
|
+
for (const fkr of mapData.postFilterForeignKeyRelations ?? []) {
|
|
106
101
|
docs = await attachForeignKeyRelation(db, docs, fkr);
|
|
107
102
|
}
|
|
108
103
|
docs = await attachDerivedProperties(db, docs, mapData.postFilterDerivedProperties);
|
|
109
104
|
return docs;
|
|
110
105
|
};
|
|
111
106
|
const attachDerivedProperties = async (db, docs, derivedProperties) => {
|
|
112
|
-
if (!
|
|
107
|
+
if (!derivedProperties?.length)
|
|
113
108
|
return docs;
|
|
114
109
|
let result = docs;
|
|
115
110
|
for (const dp of derivedProperties) {
|
|
116
111
|
if (dp.batchResolve) {
|
|
117
112
|
const values = await dp.batchResolve(db, result);
|
|
118
|
-
result = result.map((doc) => (
|
|
113
|
+
result = result.map((doc) => ({
|
|
114
|
+
...doc,
|
|
115
|
+
[String(dp.alias)]: values.get(doc.id),
|
|
116
|
+
}));
|
|
119
117
|
continue;
|
|
120
118
|
}
|
|
121
|
-
result = await Promise.all(result.map(async (doc) => (
|
|
119
|
+
result = await Promise.all(result.map(async (doc) => ({
|
|
120
|
+
...doc,
|
|
121
|
+
[String(dp.alias)]: await evaluateDerived(db, doc, dp),
|
|
122
|
+
})));
|
|
122
123
|
}
|
|
123
124
|
return result;
|
|
124
125
|
};
|
|
125
126
|
export const hydrateMapData = async (db, mapData, rows, postFilters) => hydrateDocuments(db, mapData.collection, mapData, rows, postFilters);
|
|
126
127
|
const attachForeignKeyRelation = async (db, docs, fkr) => Promise.all(docs.map(async (doc) => {
|
|
127
|
-
var _a, _b;
|
|
128
128
|
const raw = doc[fkr.foreignKeyProperty];
|
|
129
129
|
const ids = fkr.cardinality === 'many'
|
|
130
|
-
? (
|
|
130
|
+
? (raw ?? [])
|
|
131
131
|
: raw
|
|
132
132
|
? [raw]
|
|
133
133
|
: [];
|
|
134
134
|
const loaded = (await Promise.all(ids.map((id) => executeFind(db, fkr.mapping.collection, fkr.mapping, id)))).filter(Boolean);
|
|
135
|
-
return
|
|
135
|
+
return {
|
|
136
|
+
...doc,
|
|
137
|
+
[fkr.alias]: fkr.cardinality === 'many' ? loaded : (loaded[0] ?? undefined),
|
|
138
|
+
};
|
|
136
139
|
}));
|
|
137
140
|
const attachRelation = async (db, _parentCollection, docs, relation) => {
|
|
138
|
-
var _a, _b;
|
|
139
141
|
if (relation.maxDepth && relation.maxDepth > 1) {
|
|
140
|
-
return Promise.all(docs.map(async (doc) => (
|
|
142
|
+
return Promise.all(docs.map(async (doc) => ({
|
|
143
|
+
...doc,
|
|
144
|
+
[relation.alias]: await traverseRelation(db, doc.id, relation),
|
|
145
|
+
})));
|
|
141
146
|
}
|
|
142
147
|
const edgeTableRef = getEdgeTable(edgeCollectionName(relation.edgeCollection));
|
|
143
148
|
const edgeTable = asTable(edgeTableRef);
|
|
@@ -160,12 +165,12 @@ const attachRelation = async (db, _parentCollection, docs, relation) => {
|
|
|
160
165
|
const grouped = new Map();
|
|
161
166
|
for (const edge of edgeRows) {
|
|
162
167
|
const parentId = edge[parentEdgeColumn(relation)];
|
|
163
|
-
const list =
|
|
168
|
+
const list = grouped.get(parentId) ?? [];
|
|
164
169
|
list.push(edge);
|
|
165
170
|
grouped.set(parentId, list);
|
|
166
171
|
}
|
|
167
172
|
const vertexCol = vertexEdgeColumn(relation);
|
|
168
|
-
const edgesFor = (doc) =>
|
|
173
|
+
const edgesFor = (doc) => grouped.get(doc.id) ?? [];
|
|
169
174
|
const edgeVertexIdsFor = (doc) => edgesFor(doc).map((edge) => edge[vertexCol]);
|
|
170
175
|
// Vertices are fetched and hydrated once for the whole batch. Doing it per
|
|
171
176
|
// parent row cost a query per row per relation, so one feed page ran
|
|
@@ -174,19 +179,28 @@ const attachRelation = async (db, _parentCollection, docs, relation) => {
|
|
|
174
179
|
...new Set(docs.flatMap(idsFor)),
|
|
175
180
|
];
|
|
176
181
|
if (relation.count) {
|
|
177
|
-
if (!
|
|
178
|
-
return docs.map((doc) => (
|
|
182
|
+
if (!relation.mapping?.collection) {
|
|
183
|
+
return docs.map((doc) => ({
|
|
184
|
+
...doc,
|
|
185
|
+
[relation.alias]: edgesFor(doc).length,
|
|
186
|
+
}));
|
|
179
187
|
}
|
|
180
188
|
const rows = await fetchRowsByIds(db, relation.mapping.collection, batchIdsFrom(edgeVertexIdsFor), relation.mapping.softDelete);
|
|
181
189
|
const counted = new Set(applyPostFilters(rows, relation.mapping.filters, relation.mapping.defaultFilter).map((row) => row.id));
|
|
182
|
-
return docs.map((doc) => (
|
|
190
|
+
return docs.map((doc) => ({
|
|
191
|
+
...doc,
|
|
192
|
+
[relation.alias]: [...new Set(edgeVertexIdsFor(doc))].filter((id) => counted.has(id)).length,
|
|
193
|
+
}));
|
|
183
194
|
}
|
|
184
195
|
const vertexIdsFor = (doc) => capVertexIds(edgeVertexIdsFor(doc), relation);
|
|
185
196
|
const vertexCollection = vertexCollectionFor(relation);
|
|
186
197
|
const lookup = vertexCollection
|
|
187
198
|
? await fetchVertexLookup(db, vertexCollection, batchIdsFrom(vertexIdsFor), relation)
|
|
188
199
|
: emptyVertexLookup;
|
|
189
|
-
return docs.map((doc) => (
|
|
200
|
+
return docs.map((doc) => ({
|
|
201
|
+
...doc,
|
|
202
|
+
[relation.alias]: relationValueFrom(edgesFor(doc), relation, vertexIdsFor(doc), lookup),
|
|
203
|
+
}));
|
|
190
204
|
};
|
|
191
205
|
const nodeCapFromLimit = (limit) => {
|
|
192
206
|
if (limit == null)
|
|
@@ -200,8 +214,7 @@ const nodeCapFromLimit = (limit) => {
|
|
|
200
214
|
* row data to sort on.
|
|
201
215
|
*/
|
|
202
216
|
const capVertexIds = (vertexIds, relation) => {
|
|
203
|
-
|
|
204
|
-
const nodeCap = nodeCapFromLimit((_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.limit);
|
|
217
|
+
const nodeCap = nodeCapFromLimit(relation.mapping?.limit);
|
|
205
218
|
if (nodeCap === undefined || relation.cardinality !== 'many') {
|
|
206
219
|
return vertexIds;
|
|
207
220
|
}
|
|
@@ -214,8 +227,7 @@ const emptyVertexLookup = {
|
|
|
214
227
|
rank: () => 0,
|
|
215
228
|
};
|
|
216
229
|
const fetchVertexLookup = async (db, vertexCollection, vertexIds, relation) => {
|
|
217
|
-
|
|
218
|
-
const rows = await fetchRowsByIds(db, vertexCollection, vertexIds, (_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.softDelete);
|
|
230
|
+
const rows = await fetchRowsByIds(db, vertexCollection, vertexIds, relation.mapping?.softDelete);
|
|
219
231
|
const vertices = relation.mapping
|
|
220
232
|
? await hydrateMapData(db, relation.mapping, rows)
|
|
221
233
|
: rows;
|
|
@@ -223,15 +235,11 @@ const fetchVertexLookup = async (db, vertexCollection, vertexIds, relation) => {
|
|
|
223
235
|
const ranks = new Map(vertices.map((vertex, index) => [vertex.id, index]));
|
|
224
236
|
return {
|
|
225
237
|
get: (id) => byId.get(id),
|
|
226
|
-
rank: (id) =>
|
|
238
|
+
rank: (id) => ranks.get(id) ?? Number.MAX_SAFE_INTEGER,
|
|
227
239
|
};
|
|
228
240
|
};
|
|
229
241
|
const relationValueFrom = (edgeRows, relation, vertexIds, lookup) => {
|
|
230
|
-
|
|
231
|
-
const toEdgeDoc = (edge) => {
|
|
232
|
-
var _a;
|
|
233
|
-
return rowToDocument(edgeCollectionName(relation.edgeCollection), edge, (_a = relation.mapping) === null || _a === void 0 ? void 0 : _a.keepMetadata);
|
|
234
|
-
};
|
|
242
|
+
const toEdgeDoc = (edge) => rowToDocument(edgeCollectionName(relation.edgeCollection), edge, relation.mapping?.keepMetadata);
|
|
235
243
|
if (!vertexCollectionFor(relation)) {
|
|
236
244
|
const items = edgeRows.map(toEdgeDoc);
|
|
237
245
|
return relation.cardinality === 'one' ? items[0] : items;
|
|
@@ -243,7 +251,7 @@ const relationValueFrom = (edgeRows, relation, vertexIds, lookup) => {
|
|
|
243
251
|
.filter((vertex) => !!vertex);
|
|
244
252
|
if (relation.cardinality === 'one')
|
|
245
253
|
return vertices[0];
|
|
246
|
-
return applyLimit(applySort(vertices,
|
|
254
|
+
return applyLimit(applySort(vertices, relation.mapping?.sort), relation.mapping?.limit);
|
|
247
255
|
}
|
|
248
256
|
const vertexCol = vertexEdgeColumn(relation);
|
|
249
257
|
const capped = new Set(vertexIds);
|
|
@@ -255,9 +263,9 @@ const relationValueFrom = (edgeRows, relation, vertexIds, lookup) => {
|
|
|
255
263
|
return undefined;
|
|
256
264
|
const edgeDoc = toEdgeDoc(edge);
|
|
257
265
|
if (relation.vertexAlias) {
|
|
258
|
-
return
|
|
266
|
+
return { ...edgeDoc, [relation.vertexAlias]: vertex };
|
|
259
267
|
}
|
|
260
|
-
return
|
|
268
|
+
return { ...edgeDoc, ...vertex };
|
|
261
269
|
})
|
|
262
270
|
.filter(Boolean);
|
|
263
271
|
return relation.cardinality === 'one' ? items[0] : items;
|
|
@@ -271,9 +279,8 @@ const resolveRelationValue = async (db, edgeRows, relation) => {
|
|
|
271
279
|
return relationValueFrom(edgeRows, relation, vertexIds, lookup);
|
|
272
280
|
};
|
|
273
281
|
const traverseRelation = async (db, startId, relation) => {
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
const nodeCap = nodeCapFromLimit((_b = relation.mapping) === null || _b === void 0 ? void 0 : _b.limit);
|
|
282
|
+
const maxDepth = relation.maxDepth ?? 1;
|
|
283
|
+
const nodeCap = nodeCapFromLimit(relation.mapping?.limit);
|
|
277
284
|
const edgeTableRef = getEdgeTable(edgeCollectionName(relation.edgeCollection));
|
|
278
285
|
const edgeTable = asTable(edgeTableRef);
|
|
279
286
|
const collected = [];
|
|
@@ -307,7 +314,7 @@ const traverseRelation = async (db, startId, relation) => {
|
|
|
307
314
|
const vertexCollection = vertexCollectionFor(relation);
|
|
308
315
|
if (!vertexCollection)
|
|
309
316
|
break;
|
|
310
|
-
let vertices = await fetchRowsByIds(db, vertexCollection, vertexIds,
|
|
317
|
+
let vertices = await fetchRowsByIds(db, vertexCollection, vertexIds, relation.mapping?.softDelete);
|
|
311
318
|
if (relation.mapping) {
|
|
312
319
|
vertices = await hydrateMapData(db, relation.mapping, vertices);
|
|
313
320
|
}
|
|
@@ -315,7 +322,7 @@ const traverseRelation = async (db, startId, relation) => {
|
|
|
315
322
|
frontier = vertexIds;
|
|
316
323
|
}
|
|
317
324
|
// BFS is nearest-first; conversation roots need mapping sort (e.g. id ASC).
|
|
318
|
-
return applyLimit(applySort(collected,
|
|
325
|
+
return applyLimit(applySort(collected, relation.mapping?.sort), relation.mapping?.limit);
|
|
319
326
|
};
|
|
320
327
|
export const executeFind = async (db, collection, mapData, id, ignoreSoftDelete = false) => {
|
|
321
328
|
if (!id)
|
|
@@ -329,7 +336,7 @@ export const executeFind = async (db, collection, mapData, id, ignoreSoftDelete
|
|
|
329
336
|
conditions.push(sql `${table.deletedAt} IS NULL`);
|
|
330
337
|
}
|
|
331
338
|
const rows = await db
|
|
332
|
-
.select(
|
|
339
|
+
.select({ ...columns, ...computedSelect })
|
|
333
340
|
.from(tableRef)
|
|
334
341
|
.where(and(...conditions))
|
|
335
342
|
.limit(1);
|
|
@@ -342,16 +349,15 @@ export const executeFind = async (db, collection, mapData, id, ignoreSoftDelete
|
|
|
342
349
|
return hydrated[0];
|
|
343
350
|
};
|
|
344
351
|
export const executeAll = async (db, mapData) => {
|
|
345
|
-
var _a;
|
|
346
352
|
const tableRef = getTableForCollection(mapData.collection);
|
|
347
353
|
const table = asTable(tableRef);
|
|
348
354
|
const { sqlWhere, postFilters } = partitionFilters(mapData.collection, table, mapData.filters, mapData.defaultFilter, mapData.softDelete);
|
|
349
355
|
const orderBy = sortToSqlOrderBy(mapData.collection, tableRef, mapData.sort, mapData.activityWindow);
|
|
350
|
-
const canSqlPaginate = postFilters.length === 0 && (!
|
|
356
|
+
const canSqlPaginate = postFilters.length === 0 && (!mapData.sort?.length || !!orderBy);
|
|
351
357
|
const columns = getTableColumns(tableRef);
|
|
352
358
|
const computedSelect = buildComputedSelect(mapData, tableRef);
|
|
353
359
|
let query = db
|
|
354
|
-
.select(
|
|
360
|
+
.select({ ...columns, ...computedSelect })
|
|
355
361
|
.from(tableRef)
|
|
356
362
|
.$dynamic();
|
|
357
363
|
if (sqlWhere)
|
|
@@ -373,7 +379,6 @@ export const executeAll = async (db, mapData) => {
|
|
|
373
379
|
return docs;
|
|
374
380
|
};
|
|
375
381
|
export const executeCount = async (db, mapData) => {
|
|
376
|
-
var _a, _b;
|
|
377
382
|
const table = getTableForCollection(mapData.collection);
|
|
378
383
|
const { sqlWhere, postFilters } = partitionFilters(mapData.collection, table, mapData.filters, mapData.defaultFilter, mapData.softDelete);
|
|
379
384
|
if (!postFilters.length) {
|
|
@@ -381,9 +386,9 @@ export const executeCount = async (db, mapData) => {
|
|
|
381
386
|
.select({ value: sql `count(*)::int` })
|
|
382
387
|
.from(table)
|
|
383
388
|
.where(sqlWhere));
|
|
384
|
-
return Number(
|
|
389
|
+
return Number(rows[0]?.value ?? 0);
|
|
385
390
|
}
|
|
386
|
-
const docs = await executeAll(db,
|
|
391
|
+
const docs = await executeAll(db, { ...mapData, limit: undefined });
|
|
387
392
|
return docs.length;
|
|
388
393
|
};
|
|
389
394
|
export const executeFirst = async (db, mapData) => {
|
|
@@ -391,7 +396,6 @@ export const executeFirst = async (db, mapData) => {
|
|
|
391
396
|
return limited[0];
|
|
392
397
|
};
|
|
393
398
|
export const relationsFrom = async (db, start, _parentCollection, relation) => {
|
|
394
|
-
var _a;
|
|
395
399
|
// Match attachRelation: honor maxDepth via BFS traversal. Without this,
|
|
396
400
|
// callers like getConversationByStart only see direct (depth-1) replies.
|
|
397
401
|
if (relation.maxDepth && relation.maxDepth > 1) {
|
|
@@ -423,7 +427,7 @@ export const relationsFrom = async (db, start, _parentCollection, relation) => {
|
|
|
423
427
|
if (relation.cardinality === 'one') {
|
|
424
428
|
return value ? [value] : [];
|
|
425
429
|
}
|
|
426
|
-
return
|
|
430
|
+
return value ?? [];
|
|
427
431
|
};
|
|
428
432
|
export const evaluateDerived = async (db, doc, derived) => derived.resolve(db, doc);
|
|
429
433
|
export const deleteRelationsFor = async (db, startId, relation) => {
|
package/dist/db/pg/map/search.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
2
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
3
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
5
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
6
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
7
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
8
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
9
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
10
|
-
function fulfill(value) { resume("next", value); }
|
|
11
|
-
function reject(value) { resume("throw", value); }
|
|
12
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
13
|
-
};
|
|
14
1
|
import { and, sql } from 'drizzle-orm';
|
|
15
2
|
import { applyLimit, applyPostFilters, applySort, applySqlLimit, partitionFilters, } from './filters.js';
|
|
16
3
|
import { hydrateMapData } from './relations.js';
|
|
@@ -44,13 +31,12 @@ const fieldToSql = (collection, field) => {
|
|
|
44
31
|
const scalars = scalarFields[collection];
|
|
45
32
|
const path = normalizeSearchPath(collection, field);
|
|
46
33
|
const top = path.split('.')[0];
|
|
47
|
-
if (scalars
|
|
34
|
+
if (scalars?.[top]) {
|
|
48
35
|
return sql.raw(`"${scalars[top]}"`);
|
|
49
36
|
}
|
|
50
37
|
return jsonBodyTextExpr(path);
|
|
51
38
|
};
|
|
52
39
|
const fieldMatchesQuery = (collection, field, query, mode = 'substring') => {
|
|
53
|
-
var _a;
|
|
54
40
|
const like = mode === 'prefix' ? `${query}%` : `%${query}%`;
|
|
55
41
|
const scalarFields = {
|
|
56
42
|
profiles: { handle: 'handle' },
|
|
@@ -59,7 +45,7 @@ const fieldMatchesQuery = (collection, field, query, mode = 'substring') => {
|
|
|
59
45
|
};
|
|
60
46
|
const path = normalizeSearchPath(collection, field);
|
|
61
47
|
const top = path.split('.')[0];
|
|
62
|
-
if (
|
|
48
|
+
if (scalarFields[collection]?.[top]) {
|
|
63
49
|
return sql `${fieldToSql(collection, field)} ILIKE ${like}`;
|
|
64
50
|
}
|
|
65
51
|
const parts = path.split('.');
|
|
@@ -102,10 +88,8 @@ const buildSearchWhere = (collection, fields, query, table) => {
|
|
|
102
88
|
return sql `(${tsvectorExpr} @@ ${tsQuery} OR ${sql.join(ilikeParts, sql ` OR `)})`;
|
|
103
89
|
};
|
|
104
90
|
export const buildSearchResult = (mapData, searchDefinition) => {
|
|
105
|
-
|
|
106
|
-
const collection = (_a = searchViewCollections[searchDefinition.view]) !== null && _a !== void 0 ? _a : mapData.collection;
|
|
91
|
+
const collection = searchViewCollections[searchDefinition.view] ?? mapData.collection;
|
|
107
92
|
const runSearch = async (db) => {
|
|
108
|
-
var _a;
|
|
109
93
|
const tableRef = getTableForCollection(collection);
|
|
110
94
|
const table = asTable(tableRef);
|
|
111
95
|
const { sqlWhere, postFilters } = collection === mapData.collection
|
|
@@ -117,7 +101,7 @@ export const buildSearchResult = (mapData, searchDefinition) => {
|
|
|
117
101
|
const rank = searchableCollections.has(collection)
|
|
118
102
|
? sql `ts_rank(${searchVectorExpr(table)}, ${tsQuery})`
|
|
119
103
|
: sql `ts_rank(to_tsvector('english', coalesce(${table.body}::text, '')), ${tsQuery})`;
|
|
120
|
-
const pageLimit =
|
|
104
|
+
const pageLimit = searchDefinition.limit ?? mapData.limit;
|
|
121
105
|
// When post-filters must run in JS, fetch the full match set; otherwise
|
|
122
106
|
// page in SQL so we only hydrate the requested window.
|
|
123
107
|
let selectQuery = db
|
|
@@ -135,17 +119,14 @@ export const buildSearchResult = (mapData, searchDefinition) => {
|
|
|
135
119
|
const rows = await selectQuery;
|
|
136
120
|
let docs = rows.map(({ row, score }) => ({
|
|
137
121
|
data: rowToDocument(collection, row),
|
|
138
|
-
score: score
|
|
122
|
+
score: score ?? 0,
|
|
139
123
|
}));
|
|
140
124
|
if (collection === mapData.collection && docs.length) {
|
|
141
125
|
const hydrated = await hydrateMapData(db, mapData, docs.map((d) => d.data), postFilters);
|
|
142
|
-
docs = hydrated.map((data, i) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
score: (_b = (_a = docs[i]) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : 0,
|
|
147
|
-
});
|
|
148
|
-
});
|
|
126
|
+
docs = hydrated.map((data, i) => ({
|
|
127
|
+
data: data,
|
|
128
|
+
score: docs[i]?.score ?? 0,
|
|
129
|
+
}));
|
|
149
130
|
if (postFilters.length) {
|
|
150
131
|
const kept = new Set(applyPostFilters(docs.map((d) => d.data), postFilters));
|
|
151
132
|
docs = docs.filter((d) => kept.has(d.data));
|
|
@@ -155,7 +136,6 @@ export const buildSearchResult = (mapData, searchDefinition) => {
|
|
|
155
136
|
return applyLimit(docs, pageLimit);
|
|
156
137
|
};
|
|
157
138
|
const runCount = async (db) => {
|
|
158
|
-
var _a, _b;
|
|
159
139
|
const tableRef = getTableForCollection(collection);
|
|
160
140
|
const { sqlWhere, postFilters } = collection === mapData.collection
|
|
161
141
|
? partitionFilters(mapData.collection, tableRef, mapData.filters, mapData.defaultFilter, mapData.softDelete)
|
|
@@ -167,7 +147,7 @@ export const buildSearchResult = (mapData, searchDefinition) => {
|
|
|
167
147
|
.select({ value: sql `count(*)::int` })
|
|
168
148
|
.from(tableRef)
|
|
169
149
|
.where(where));
|
|
170
|
-
return Number(
|
|
150
|
+
return Number(rows[0]?.value ?? 0);
|
|
171
151
|
}
|
|
172
152
|
return runSearch(db).then((rows) => rows.length);
|
|
173
153
|
};
|
|
@@ -175,16 +155,14 @@ export const buildSearchResult = (mapData, searchDefinition) => {
|
|
|
175
155
|
all: (db) => runSearch(db),
|
|
176
156
|
count: (db) => runCount(db),
|
|
177
157
|
first: (db) => runSearch(db).then((rows) => rows[0]),
|
|
178
|
-
limit: (limit) => buildSearchResult(
|
|
158
|
+
limit: (limit) => buildSearchResult({ ...mapData, limit: limit }, searchDefinition),
|
|
179
159
|
query: () => {
|
|
180
160
|
throw new Error('query() is not supported for Postgres fulltextSearch');
|
|
181
161
|
},
|
|
182
|
-
cursor: function (db) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
});
|
|
162
|
+
cursor: async function* (db) {
|
|
163
|
+
for (const row of await runSearch(db)) {
|
|
164
|
+
yield row;
|
|
165
|
+
}
|
|
188
166
|
},
|
|
189
167
|
};
|
|
190
168
|
};
|
package/dist/db/pg/mappers.js
CHANGED
|
@@ -13,9 +13,15 @@ export const normalizeComputedDatetime = (value) => {
|
|
|
13
13
|
return normalizeIsoDatetime(value);
|
|
14
14
|
return null;
|
|
15
15
|
};
|
|
16
|
-
export const rowToModel = (id, data, timestamps) => (
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export const rowToModel = (id, data, timestamps) => ({
|
|
17
|
+
id,
|
|
18
|
+
...data,
|
|
19
|
+
createdAt: normalizeIsoDatetime(timestamps.createdAt),
|
|
20
|
+
updatedAt: normalizeIsoDatetime(timestamps.updatedAt),
|
|
21
|
+
...(timestamps.deletedAt
|
|
22
|
+
? { deletedAt: normalizeIsoDatetime(timestamps.deletedAt) }
|
|
23
|
+
: {}),
|
|
24
|
+
});
|
|
19
25
|
export const modelTimestampsFromRow = (row) => ({
|
|
20
26
|
createdAt: normalizeIsoDatetime(row.createdAt),
|
|
21
27
|
updatedAt: normalizeIsoDatetime(row.updatedAt),
|
|
@@ -23,7 +29,7 @@ export const modelTimestampsFromRow = (row) => ({
|
|
|
23
29
|
});
|
|
24
30
|
export const notDeleted = (row) => !row.deletedAt;
|
|
25
31
|
export const nowIso = () => new Date().toISOString();
|
|
26
|
-
export const mergeDocumentBody = (row, scalars = {}) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
32
|
+
export const mergeDocumentBody = (row, scalars = {}) => ({
|
|
33
|
+
...(row.body ?? {}),
|
|
34
|
+
...scalars,
|
|
35
|
+
});
|
package/dist/db/pg/migrate.js
CHANGED
|
@@ -72,7 +72,7 @@ const buildMigrationsFolderUpTo = async (tag) => {
|
|
|
72
72
|
const entries = journal.entries.slice(0, endIdx + 1);
|
|
73
73
|
const folder = await mkdtemp(join(tmpdir(), 'op-migrate-'));
|
|
74
74
|
await mkdir(join(folder, 'meta'), { recursive: true });
|
|
75
|
-
await writeFile(join(folder, 'meta', '_journal.json'), `${JSON.stringify(
|
|
75
|
+
await writeFile(join(folder, 'meta', '_journal.json'), `${JSON.stringify({ ...journal, entries }, null, 2)}\n`);
|
|
76
76
|
for (const entry of entries) {
|
|
77
77
|
copyFileSync(join(migrationsFolder, `${entry.tag}.sql`), join(folder, `${entry.tag}.sql`));
|
|
78
78
|
}
|
|
@@ -104,10 +104,9 @@ const APP_TABLE_NAMES = [
|
|
|
104
104
|
...EDGE_IMPORT_ORDER.map((collection) => getTableName(getTableForCollection(collection))),
|
|
105
105
|
];
|
|
106
106
|
const tableExists = async (tableName) => {
|
|
107
|
-
var _a;
|
|
108
107
|
const db = pgDb();
|
|
109
108
|
const result = await db.execute(sql.raw(`SELECT to_regclass('public.${tableName}')::text AS regclass`));
|
|
110
|
-
return
|
|
109
|
+
return result.rows[0]?.regclass != null;
|
|
111
110
|
};
|
|
112
111
|
const missingAppTables = async () => {
|
|
113
112
|
const missing = [];
|
|
@@ -9,10 +9,10 @@ const edgeOutboundCount = (edgeTable, outerTable, window) => {
|
|
|
9
9
|
const conditions = [
|
|
10
10
|
sql `${edgeTable.fromId} = ${outerIdText(outerTable)}`,
|
|
11
11
|
];
|
|
12
|
-
if (window
|
|
12
|
+
if (window?.start) {
|
|
13
13
|
conditions.push(gte(edgeTable.createdAt, window.start.toISOString()));
|
|
14
14
|
}
|
|
15
|
-
if (window
|
|
15
|
+
if (window?.end) {
|
|
16
16
|
conditions.push(lt(edgeTable.createdAt, window.end.toISOString()));
|
|
17
17
|
}
|
|
18
18
|
return sql `(SELECT count(*)::int FROM ${edgeTable} WHERE ${and(...conditions)})`;
|
|
@@ -12,16 +12,14 @@ const maxIso = (values) => {
|
|
|
12
12
|
};
|
|
13
13
|
export const profileDerived = {
|
|
14
14
|
postsCount: async (db, doc) => {
|
|
15
|
-
var _a, _b;
|
|
16
15
|
const postsTable = asTable(posts);
|
|
17
16
|
const rows = await db
|
|
18
17
|
.select({ count: sql `count(*)::int` })
|
|
19
18
|
.from(posts)
|
|
20
19
|
.where(and(eq(postsTable.creatorId, doc.id), sql `${postsTable.deletedAt} IS NULL`));
|
|
21
|
-
return
|
|
20
|
+
return rows[0]?.count ?? 0;
|
|
22
21
|
},
|
|
23
22
|
lastSeen: async (db, doc) => {
|
|
24
|
-
var _a, _b;
|
|
25
23
|
const profileId = doc.id;
|
|
26
24
|
const entriesTable = asTable(entries);
|
|
27
25
|
const postSeenTable = asTable(postSeen);
|
|
@@ -36,8 +34,8 @@ export const profileDerived = {
|
|
|
36
34
|
.where(eq(postSeenTable.fromId, profileId)),
|
|
37
35
|
]);
|
|
38
36
|
return maxIso([
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
entryRows[0]?.max,
|
|
38
|
+
seenRows[0]?.max,
|
|
41
39
|
]);
|
|
42
40
|
},
|
|
43
41
|
profileStats: (_db, doc) => ({
|
|
@@ -46,7 +44,6 @@ export const profileDerived = {
|
|
|
46
44
|
}),
|
|
47
45
|
/** Counts without loading follower/following trees. */
|
|
48
46
|
profileStatsCounts: async (db, doc) => {
|
|
49
|
-
var _a, _b, _c, _d;
|
|
50
47
|
const edgeTableRef = getEdgeTable('follows');
|
|
51
48
|
const edgeTable = asTable(edgeTableRef);
|
|
52
49
|
const profileId = doc.id;
|
|
@@ -61,8 +58,8 @@ export const profileDerived = {
|
|
|
61
58
|
.where(eq(edgeTable.fromId, profileId)),
|
|
62
59
|
]);
|
|
63
60
|
return {
|
|
64
|
-
followersCount:
|
|
65
|
-
followingCount:
|
|
61
|
+
followersCount: followersRows[0]?.count ?? 0,
|
|
62
|
+
followingCount: followingRows[0]?.count ?? 0,
|
|
66
63
|
};
|
|
67
64
|
},
|
|
68
65
|
};
|
|
@@ -103,19 +100,18 @@ export const postDerived = {
|
|
|
103
100
|
return values;
|
|
104
101
|
},
|
|
105
102
|
}),
|
|
106
|
-
inReplyToId: (_db, doc) =>
|
|
107
|
-
groupId: (_db, doc) =>
|
|
103
|
+
inReplyToId: (_db, doc) => doc.replyTo?.id,
|
|
104
|
+
groupId: (_db, doc) => doc.group?.id,
|
|
108
105
|
};
|
|
109
106
|
export const groupDerived = {
|
|
110
107
|
lastPostAt: async (db, doc) => {
|
|
111
|
-
var _a;
|
|
112
108
|
const edgeTableRef = getEdgeTable('postGroups');
|
|
113
109
|
const edgeTable = asTable(edgeTableRef);
|
|
114
110
|
const rows = await db
|
|
115
111
|
.select({ max: sql `max(${edgeTable.createdAt})` })
|
|
116
112
|
.from(edgeTableRef)
|
|
117
113
|
.where(eq(edgeTable.toId, doc.id));
|
|
118
|
-
const value =
|
|
114
|
+
const value = rows[0]?.max;
|
|
119
115
|
return value ? normalizeIsoDatetime(value) : null;
|
|
120
116
|
},
|
|
121
117
|
};
|