Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 3x 1x 1x 2x 2x 1x | /**
* Browse-or-search for the platform-admin "all users" / "all flows" lists.
*
* No search text → the newest-first browse (platformStatsIndex, see
* platformAdminList.js); with search text → the trigram directory index (see
* directorySearchIndex.js). Neither path scans the table, and both return an
* opaque `nextCursor` — a GSI key when browsing, a candidate offset when searching.
*
* @implements UC-ADMIN-006.1
*/
const { listByCreatedAt, encodeOffsetCursor } = require('./platformAdminList')
const { searchDirectory } = require('./directorySearchIndex')
/**
* @param {import('@aws-sdk/lib-dynamodb').DynamoDBDocumentClient} docClient
* @param {object} params
* @param {string} params.subjectsTableName
* @param {string} params.gsiPkValue 'USER' / 'FLOW'
* @param {string[]} params.namespaces directory namespaces searchable by this list
* @param {(subject: object, normalizedQuery: string) => boolean} params.verify
* @param {{ search: string | null, limit: number, cursor?: object, offset: number }} params.list
* as returned by parseListParams
* @returns {Promise<{ items: object[], nextCursor: string | null, truncated: boolean }>}
*/
async function listPlatformDirectory(
docClient,
{ subjectsTableName, gsiPkValue, namespaces, verify, list }
) {
if (!list.search) {
const page = await listByCreatedAt({
tableName: subjectsTableName,
gsiPkValue,
limit: list.limit,
cursor: list.cursor
})
return { ...page, truncated: false }
}
const { items, nextOffset, truncated } = await searchDirectory(docClient, {
indexTableName: process.env.FIELD_VALUE_INDEX_TABLE_NAME,
subjectsTableName,
namespaces,
searchValue: list.search,
verify,
limit: list.limit,
offset: list.offset
})
return { items, nextCursor: encodeOffsetCursor(nextOffset), truncated }
}
module.exports = { listPlatformDirectory }
|