@crombolo/server 0.47.0 → 0.48.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/package.json +13 -13
- package/src/adapters/documents.ts +60 -10
- package/src/adapters/elements.ts +20 -3
- package/src/adapters/health.ts +36 -0
- package/src/config.ts +21 -1
- package/src/database.ts +29 -0
- package/src/jobs.ts +22 -0
- package/src/server.ts +2 -2
- package/src/site-search.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The crombolo HTTP server: routing, configuration, media stores and background jobs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@crombolo/api-delivery": "0.
|
|
35
|
-
"@crombolo/api-management": "0.
|
|
36
|
-
"@crombolo/auth": "0.
|
|
37
|
-
"@crombolo/backoffice-host": "0.
|
|
38
|
-
"@crombolo/common": "0.
|
|
39
|
-
"@crombolo/content": "0.
|
|
40
|
-
"@crombolo/contracts": "0.
|
|
41
|
-
"@crombolo/core": "0.
|
|
42
|
-
"@crombolo/data": "0.
|
|
43
|
-
"@crombolo/render": "0.
|
|
44
|
-
"@crombolo/schema": "0.
|
|
45
|
-
"@crombolo/transfer": "0.
|
|
34
|
+
"@crombolo/api-delivery": "0.48.0",
|
|
35
|
+
"@crombolo/api-management": "0.48.0",
|
|
36
|
+
"@crombolo/auth": "0.48.0",
|
|
37
|
+
"@crombolo/backoffice-host": "0.48.0",
|
|
38
|
+
"@crombolo/common": "0.48.0",
|
|
39
|
+
"@crombolo/content": "0.48.0",
|
|
40
|
+
"@crombolo/contracts": "0.48.0",
|
|
41
|
+
"@crombolo/core": "0.48.0",
|
|
42
|
+
"@crombolo/data": "0.48.0",
|
|
43
|
+
"@crombolo/render": "0.48.0",
|
|
44
|
+
"@crombolo/schema": "0.48.0",
|
|
45
|
+
"@crombolo/transfer": "0.48.0",
|
|
46
46
|
"@logtape/logtape": "^2.3.8",
|
|
47
47
|
"@opentelemetry/api": "1.10.0",
|
|
48
48
|
"@opentelemetry/context-async-hooks": "3.0.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Adapters binding the document repository to the API port and the renderer. */
|
|
2
2
|
import type {
|
|
3
|
+
DocumentCollectionItem,
|
|
3
4
|
DocumentPort,
|
|
4
5
|
PortFailure,
|
|
5
6
|
Principal,
|
|
@@ -7,7 +8,6 @@ import type {
|
|
|
7
8
|
SkipTake,
|
|
8
9
|
} from '@crombolo/api-management/domain'
|
|
9
10
|
import {
|
|
10
|
-
type DocumentAggregate,
|
|
11
11
|
normaliseUuid,
|
|
12
12
|
ObjectTypes,
|
|
13
13
|
type Page,
|
|
@@ -19,8 +19,10 @@ import {
|
|
|
19
19
|
ContentTypeRepository,
|
|
20
20
|
type Db,
|
|
21
21
|
DictionaryRepository,
|
|
22
|
+
DocumentListingRepository,
|
|
22
23
|
DocumentRepository,
|
|
23
24
|
type DocumentRepositoryOptions,
|
|
25
|
+
type DocumentSortField,
|
|
24
26
|
DomainRepository,
|
|
25
27
|
InvalidParentError,
|
|
26
28
|
LanguageRepository,
|
|
@@ -74,6 +76,17 @@ async function toTreeItems(
|
|
|
74
76
|
return items
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
/** The list view's built-in columns, by the alias the client sends; any other is a property. */
|
|
80
|
+
const COLLECTION_SORTS: Record<string, DocumentSortField> = {
|
|
81
|
+
name: 'name',
|
|
82
|
+
createDate: 'createDate',
|
|
83
|
+
updateDate: 'updateDate',
|
|
84
|
+
sortOrder: 'sortOrder',
|
|
85
|
+
creator: 'creator',
|
|
86
|
+
owner: 'creator',
|
|
87
|
+
updater: 'updater',
|
|
88
|
+
}
|
|
89
|
+
|
|
77
90
|
export function createDocumentPort(
|
|
78
91
|
db: Db,
|
|
79
92
|
cache: PublishedCache,
|
|
@@ -477,16 +490,53 @@ export function createDocumentPort(
|
|
|
477
490
|
return toTreeItems(repo, await repo.nodes.byKeys(keys))
|
|
478
491
|
},
|
|
479
492
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
)
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
493
|
+
/**
|
|
494
|
+
* The list view (story 269): searched, sorted and paged in the database, so
|
|
495
|
+
* a large folder costs a page; then only the page's items are loaded.
|
|
496
|
+
*/
|
|
497
|
+
async collection(parentKey, query, excludeKeys = []) {
|
|
498
|
+
const parent = parentKey ? await repo.nodes.byKey(parentKey) : undefined
|
|
499
|
+
if (parentKey && !parent) return { total: 0, items: [] }
|
|
500
|
+
const listing = new DocumentListingRepository(db)
|
|
501
|
+
const filter = query.filter?.trim()
|
|
502
|
+
const page = await listing.children({
|
|
503
|
+
parentId: parent?.id ?? -1,
|
|
504
|
+
names: filter ? [filter] : [],
|
|
505
|
+
// Anything but a built-in column is a property the list view shows (story 276).
|
|
506
|
+
sort: {
|
|
507
|
+
...(COLLECTION_SORTS[query.orderBy ?? '']
|
|
508
|
+
? { field: COLLECTION_SORTS[query.orderBy ?? ''] as DocumentSortField }
|
|
509
|
+
: query.orderBy
|
|
510
|
+
? { property: query.orderBy }
|
|
511
|
+
: { field: 'sortOrder' as const }),
|
|
512
|
+
ascending: query.orderDirection !== 'Descending',
|
|
513
|
+
},
|
|
514
|
+
culture: query.orderCulture ?? null,
|
|
515
|
+
excludeKeys,
|
|
516
|
+
skip: query.skip,
|
|
517
|
+
take: query.take,
|
|
518
|
+
})
|
|
519
|
+
const found = new Map((await repo.nodes.byKeys(page.keys)).map((row) => [row.key, row]))
|
|
520
|
+
const rows = page.keys.flatMap((key) => found.get(key) ?? [])
|
|
521
|
+
const [guarded, people, counts] = await Promise.all([
|
|
522
|
+
repo.protectedKeys(rows),
|
|
523
|
+
listing.people(page.keys),
|
|
524
|
+
repo.nodes.childCounts(
|
|
525
|
+
rows.map((row) => row.id),
|
|
526
|
+
ObjectTypes.Document,
|
|
527
|
+
),
|
|
528
|
+
])
|
|
529
|
+
const items: DocumentCollectionItem[] = []
|
|
530
|
+
for (const row of rows) {
|
|
488
531
|
const aggregate = await repo.load(row)
|
|
489
|
-
if (aggregate)
|
|
532
|
+
if (!aggregate) continue
|
|
533
|
+
items.push({
|
|
534
|
+
...aggregate,
|
|
535
|
+
isProtected: guarded.has(row.key),
|
|
536
|
+
hasChildren: (counts.get(row.id) ?? 0) > 0,
|
|
537
|
+
creator: people.get(row.key)?.creator ?? null,
|
|
538
|
+
updater: people.get(row.key)?.updater ?? null,
|
|
539
|
+
})
|
|
490
540
|
}
|
|
491
541
|
return { total: page.total, items }
|
|
492
542
|
},
|
package/src/adapters/elements.ts
CHANGED
|
@@ -267,12 +267,29 @@ export function createElementPort(
|
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
269
|
|
|
270
|
-
async publish(key, cultures) {
|
|
270
|
+
async publish(key, cultures, schedules = []) {
|
|
271
|
+
const now = Date.now()
|
|
272
|
+
const later = (s: { publishTime: Date | null }) =>
|
|
273
|
+
s.publishTime !== null && s.publishTime.getTime() > now
|
|
274
|
+
const immediate = schedules.filter((s) => !later(s))
|
|
275
|
+
const scheduledOnly = schedules.length > 0 && immediate.length === 0
|
|
276
|
+
const publishing = immediate.some((s) => s.culture !== null)
|
|
277
|
+
? immediate.flatMap((s) => (s.culture === null ? [] : [s.culture]))
|
|
278
|
+
: cultures
|
|
271
279
|
try {
|
|
272
|
-
|
|
280
|
+
// The schedule and the publish are one change: neither lands without the other.
|
|
281
|
+
const published = await repo.atomically(async (tx) => {
|
|
282
|
+
if (schedules.length > 0)
|
|
283
|
+
await tx.setSchedule(
|
|
284
|
+
key,
|
|
285
|
+
schedules.map((s) => ({ ...s, publishTime: later(s) ? s.publishTime : null })),
|
|
286
|
+
)
|
|
287
|
+
if (scheduledOnly) return true
|
|
288
|
+
return tx.publish(key, publishing)
|
|
289
|
+
})
|
|
273
290
|
if (!published) return notFound()
|
|
274
291
|
await changed()
|
|
275
|
-
return { ok: true as const }
|
|
292
|
+
return { ok: true as const, scheduledOnly }
|
|
276
293
|
} catch (error) {
|
|
277
294
|
return failure(error)
|
|
278
295
|
}
|
package/src/adapters/health.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type QueueCounts,
|
|
23
23
|
queueCounts,
|
|
24
24
|
RemoteTrustRepository,
|
|
25
|
+
searchProvidersOf,
|
|
25
26
|
sql,
|
|
26
27
|
UserGroupRepository,
|
|
27
28
|
UserRepository,
|
|
@@ -49,6 +50,7 @@ const CHECKS = {
|
|
|
49
50
|
routes: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000007', name: 'Routes and pages' },
|
|
50
51
|
settings: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000008', name: 'Site settings' },
|
|
51
52
|
code: { id: '6f1d4a8e-0047-4c1a-9e7d-000000000009', name: 'Installing code' },
|
|
53
|
+
search: { id: '6f1d4a8e-0047-4c1a-9e7d-00000000000a', name: 'Search providers' },
|
|
52
54
|
} as const
|
|
53
55
|
|
|
54
56
|
/** Waiting longer than this means nothing is sending: no server is running its jobs, or one is stuck. */
|
|
@@ -87,6 +89,15 @@ const GROUPS: HealthCheckGroup[] = [
|
|
|
87
89
|
},
|
|
88
90
|
],
|
|
89
91
|
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Search',
|
|
94
|
+
checks: [
|
|
95
|
+
{
|
|
96
|
+
...CHECKS.search,
|
|
97
|
+
description: 'Which search the back office and the site use, and whether each answers.',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
90
101
|
{
|
|
91
102
|
name: 'Site',
|
|
92
103
|
checks: [
|
|
@@ -386,6 +397,29 @@ export function createDiagnosticsPort(options: HealthCheckOptions): DiagnosticsP
|
|
|
386
397
|
),
|
|
387
398
|
)
|
|
388
399
|
},
|
|
400
|
+
[CHECKS.search.id]: async () => {
|
|
401
|
+
const { backoffice, site } = searchProvidersOf(db)
|
|
402
|
+
const checked = async (
|
|
403
|
+
what: string,
|
|
404
|
+
provider: { name: string; health?(): Promise<{ ok: boolean; detail?: string }> },
|
|
405
|
+
) => {
|
|
406
|
+
try {
|
|
407
|
+
const health = (await provider.health?.()) ?? { ok: true }
|
|
408
|
+
return health.ok
|
|
409
|
+
? result('Success', `${what} uses ${provider.name}, which is answering.`)
|
|
410
|
+
: result(
|
|
411
|
+
'Error',
|
|
412
|
+
`${what} uses ${provider.name}, which is not answering${health.detail ? `: ${health.detail}` : '.'}`,
|
|
413
|
+
)
|
|
414
|
+
} catch (error) {
|
|
415
|
+
return result(
|
|
416
|
+
'Error',
|
|
417
|
+
`${what} uses ${provider.name}, which is not answering: ${failure(error)}`,
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return [await checked('Back-office search', backoffice), await checked('Site search', site)]
|
|
422
|
+
},
|
|
389
423
|
[CHECKS.code.id]: async () => {
|
|
390
424
|
const results: HealthCheckResult[] = []
|
|
391
425
|
const verb = RemotePermissions.InstallCode
|
|
@@ -476,6 +510,8 @@ export function createDiagnosticsPort(options: HealthCheckOptions): DiagnosticsP
|
|
|
476
510
|
'E-mail',
|
|
477
511
|
availability.available ? (availability.description ?? undefined) : 'Not configured',
|
|
478
512
|
],
|
|
513
|
+
['Back-office search', searchProvidersOf(db).backoffice.name],
|
|
514
|
+
['Site search', searchProvidersOf(db).site.name],
|
|
479
515
|
['Log level', config.logLevel],
|
|
480
516
|
['Telemetry', describeTelemetry(telemetryStatus())],
|
|
481
517
|
['Time zone', Intl.DateTimeFormat().resolvedOptions().timeZone],
|
package/src/config.ts
CHANGED
|
@@ -3,10 +3,13 @@ import { join, resolve } from 'node:path'
|
|
|
3
3
|
import type { DeliveryApiOptions } from '@crombolo/api-delivery'
|
|
4
4
|
import type { MiddlewareChain, SiteRoute } from '@crombolo/common'
|
|
5
5
|
import {
|
|
6
|
+
type BackofficeSearchProvider,
|
|
6
7
|
DEFAULT_BACKOFFICE_PATH,
|
|
7
8
|
DEFAULT_PASSWORD_CONFIGURATION,
|
|
8
9
|
isValidPassword,
|
|
10
|
+
type SiteSearchProvider,
|
|
9
11
|
} from '@crombolo/core'
|
|
12
|
+
import type { Db } from '@crombolo/data'
|
|
10
13
|
import {
|
|
11
14
|
type CacheOptions,
|
|
12
15
|
DEFAULT_RENDER_TIMEOUT_MS,
|
|
@@ -138,6 +141,15 @@ export function listeningBodyLimit(config: CromboloConfig): number {
|
|
|
138
141
|
: config.maxRequestBodyBytes
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
/** Makes a search provider for a database; called once, when the database is opened. */
|
|
145
|
+
export type SearchProviderFactory<P> = (context: { db: Db }) => P
|
|
146
|
+
|
|
147
|
+
export interface SearchConfig {
|
|
148
|
+
backoffice?: SearchProviderFactory<BackofficeSearchProvider>
|
|
149
|
+
site?: SearchProviderFactory<SiteSearchProvider>
|
|
150
|
+
matchLimit?: number
|
|
151
|
+
}
|
|
152
|
+
|
|
141
153
|
export interface CromboloConfig {
|
|
142
154
|
port: number
|
|
143
155
|
/** The largest request body the server will read, media uploads included. */
|
|
@@ -348,6 +360,13 @@ export interface CromboloConfig {
|
|
|
348
360
|
* A site swaps in blob storage with `s3MediaStore` or `azureMediaStore`.
|
|
349
361
|
*/
|
|
350
362
|
mediaStore: MediaStore | undefined
|
|
363
|
+
/**
|
|
364
|
+
* The search providers (story 273): backoffice search and site search, each
|
|
365
|
+
* a factory given the database, the database's own when unset. `matchLimit`
|
|
366
|
+
* caps the matches a provider outside the database gives a query that
|
|
367
|
+
* filters with them in SQL. docs/search.md, "Providers".
|
|
368
|
+
*/
|
|
369
|
+
search: SearchConfig
|
|
351
370
|
/** Where log files are written, and read by the backoffice's log viewer. */
|
|
352
371
|
logsDir: string
|
|
353
372
|
/** The least severe level logged: trace, debug, info, warning, error or fatal. */
|
|
@@ -828,6 +847,7 @@ export function loadConfig(
|
|
|
828
847
|
DEFAULTS.mediaCacheMegabytes,
|
|
829
848
|
),
|
|
830
849
|
mediaStore: undefined,
|
|
850
|
+
search: {},
|
|
831
851
|
logsDir: setting('CROMBOLO_LOGS_DIR') ?? DEFAULTS.logsDir,
|
|
832
852
|
logLevel: parseLogLevel(setting('CROMBOLO_LOG_LEVEL')),
|
|
833
853
|
logToConsole: setting('CROMBOLO_LOG_TO_CONSOLE') !== 'false',
|
|
@@ -1066,7 +1086,7 @@ export function describeDatabase(
|
|
|
1066
1086
|
}
|
|
1067
1087
|
}
|
|
1068
1088
|
|
|
1069
|
-
export const VERSION = '0.
|
|
1089
|
+
export const VERSION = '0.48.0'
|
|
1070
1090
|
|
|
1071
1091
|
/** A whole number of seconds from the environment; undefined when unset or not one. */
|
|
1072
1092
|
/** A positive number from a setting, else the default. */
|
package/src/database.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
connect,
|
|
10
10
|
cromboloPlan,
|
|
11
11
|
type Db,
|
|
12
|
+
DEFAULT_MATCH_LIMIT,
|
|
12
13
|
ensureBuiltInDataTypes,
|
|
13
14
|
ensureSystemContentTypes,
|
|
14
15
|
ensureSystemMemberTypes,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
readState,
|
|
20
21
|
seedContent,
|
|
21
22
|
seedIdentity,
|
|
23
|
+
useSearchProviders,
|
|
22
24
|
} from '@crombolo/data'
|
|
23
25
|
import { ensureApiClient } from './api-client.ts'
|
|
24
26
|
import { type CromboloConfig, runsOnLocalhost } from './config.ts'
|
|
@@ -87,9 +89,35 @@ export async function attachDatabase(
|
|
|
87
89
|
await db.close()
|
|
88
90
|
throw error
|
|
89
91
|
}
|
|
92
|
+
useSiteSearchProviders(db, config)
|
|
90
93
|
return { db, seededAdminPassword: undefined }
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Registers the site's search providers on `db` (story 273), so every reader
|
|
98
|
+
* of it, the indexer and the CLI among them, finds them. Without a factory,
|
|
99
|
+
* the database's own.
|
|
100
|
+
*/
|
|
101
|
+
export function useSiteSearchProviders(db: Db, config: Pick<CromboloConfig, 'search'>): void {
|
|
102
|
+
const search = config.search ?? {}
|
|
103
|
+
const log = logger('search')
|
|
104
|
+
useSearchProviders(db, {
|
|
105
|
+
backoffice: search.backoffice?.({ db }),
|
|
106
|
+
site: search.site?.({ db }),
|
|
107
|
+
matchLimit: search.matchLimit,
|
|
108
|
+
onError: (error, context) =>
|
|
109
|
+
log.warning('The search provider {provider} failed; the item stays queued', {
|
|
110
|
+
provider: context.provider,
|
|
111
|
+
key: context.key,
|
|
112
|
+
error,
|
|
113
|
+
}),
|
|
114
|
+
onCapped: () =>
|
|
115
|
+
log.warning('A search took {limit} matches from the provider, so its total may be capped', {
|
|
116
|
+
limit: search.matchLimit ?? DEFAULT_MATCH_LIMIT,
|
|
117
|
+
}),
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
93
121
|
/**
|
|
94
122
|
* `chains` are the custom tables: the site's and the wired bundles'. Their
|
|
95
123
|
* steps pending in production refuse the boot just as core's do, and a
|
|
@@ -118,6 +146,7 @@ export async function bootstrapDatabase(
|
|
|
118
146
|
await db.close()
|
|
119
147
|
throw error
|
|
120
148
|
}
|
|
149
|
+
useSiteSearchProviders(db, config)
|
|
121
150
|
return { db, seededAdminPassword: await installDatabase(db, config, chains) }
|
|
122
151
|
}
|
|
123
152
|
|
package/src/jobs.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from '@crombolo/data'
|
|
22
22
|
import type { PublishedCache } from '@crombolo/render'
|
|
23
23
|
import { auditRetainedSince } from './adapters/audit.ts'
|
|
24
|
+
import { createElementPort } from './adapters/elements.ts'
|
|
24
25
|
import type { Approvals } from './approvals.ts'
|
|
25
26
|
import type { ContentDispatcher } from './content-dispatch.ts'
|
|
26
27
|
import type {
|
|
@@ -122,6 +123,16 @@ export function createBackgroundJobs(options: JobsOptions): BackgroundJobs {
|
|
|
122
123
|
nodeState: options.nodeState,
|
|
123
124
|
nodeId: options.nodeId,
|
|
124
125
|
})
|
|
126
|
+
const elementRows = new DocumentRepository(options.db, {
|
|
127
|
+
nodeState: options.nodeState,
|
|
128
|
+
nodeId: options.nodeId,
|
|
129
|
+
kind: 'element',
|
|
130
|
+
})
|
|
131
|
+
const elements = createElementPort(options.db, {
|
|
132
|
+
nodeState: options.nodeState,
|
|
133
|
+
nodeId: options.nodeId,
|
|
134
|
+
onChange: () => options.cache.invalidate(),
|
|
135
|
+
})
|
|
125
136
|
const timers: Array<ReturnType<typeof setInterval>> = []
|
|
126
137
|
const search = new SearchIndex(options.db)
|
|
127
138
|
let indexing: Promise<number> | undefined
|
|
@@ -155,6 +166,17 @@ export function createBackgroundJobs(options: JobsOptions): BackgroundJobs {
|
|
|
155
166
|
result.ok ? { ok: true } : { ok: false, reason: result.reason },
|
|
156
167
|
)
|
|
157
168
|
}
|
|
169
|
+
// Library elements: no approvals and no redirects, so the port publishes them directly.
|
|
170
|
+
for (const due of await elementRows.dueSchedules(now)) {
|
|
171
|
+
if (!(await elementRows.claimSchedule(due.id))) continue
|
|
172
|
+
const cultures = due.culture ? [due.culture] : null
|
|
173
|
+
const result =
|
|
174
|
+
due.action === 'Release'
|
|
175
|
+
? await elements.publish(due.key, cultures)
|
|
176
|
+
: await elements.unpublish(due.key, cultures)
|
|
177
|
+
if (result.ok) (due.action === 'Release' ? run.published : run.unpublished).push(due.key)
|
|
178
|
+
else run.failed.push({ key: due.key, reason: result.reason })
|
|
179
|
+
}
|
|
158
180
|
await options.approvals?.sweepScheduled(now.getTime())
|
|
159
181
|
// The operations recorded, announced and refreshed what they did themselves.
|
|
160
182
|
return run
|
package/src/server.ts
CHANGED
|
@@ -97,7 +97,7 @@ import {
|
|
|
97
97
|
readLedger,
|
|
98
98
|
readReport,
|
|
99
99
|
readUrlOptions,
|
|
100
|
-
|
|
100
|
+
searchProvidersOf,
|
|
101
101
|
TransferRunRepository,
|
|
102
102
|
type WritesPaused,
|
|
103
103
|
} from '@crombolo/data'
|
|
@@ -1109,7 +1109,7 @@ export async function createServer(
|
|
|
1109
1109
|
mediaRules: () => new MediaAccessRepository(db).allRules(),
|
|
1110
1110
|
media: createDeliveryMediaPort(db, mediaCache),
|
|
1111
1111
|
security: (request, action) => deliveryMembers.handle(request, action),
|
|
1112
|
-
search: (term, options) =>
|
|
1112
|
+
search: (term, options) => searchProvidersOf(db).site.query(term, options),
|
|
1113
1113
|
})
|
|
1114
1114
|
for (const problem of deliveryApi?.problems ?? [])
|
|
1115
1115
|
log.warning('Delivery API: {problem}', { problem })
|
package/src/site-search.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* so a page unpublished since it was indexed is never shown. docs/search.md.
|
|
5
5
|
*/
|
|
6
6
|
import { branchAccess } from '@crombolo/core'
|
|
7
|
-
import { type Db, PublicAccessRepository,
|
|
7
|
+
import { type Db, PublicAccessRepository, searchProvidersOf } from '@crombolo/data'
|
|
8
8
|
import {
|
|
9
9
|
excerpt,
|
|
10
10
|
type PublishedCache,
|
|
@@ -26,7 +26,7 @@ export function siteSearchFor(
|
|
|
26
26
|
member ? { username: member.username, groups: member.roles } : undefined,
|
|
27
27
|
)
|
|
28
28
|
const culture = options.culture ?? (await cache.defaultCulture())
|
|
29
|
-
const hits = await
|
|
29
|
+
const hits = await searchProvidersOf(db).site.query(query, {
|
|
30
30
|
culture: culture ?? '',
|
|
31
31
|
types: options.types,
|
|
32
32
|
skip: options.skip,
|