@nixxie-cms/core 1.0.3 → 2.0.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/CHANGELOG.md +36 -0
- package/CHANGES-1.1.md +134 -0
- package/context/dist/nixxie-cms-core-context.cjs.js +4 -3
- package/context/dist/nixxie-cms-core-context.esm.js +3 -2
- package/dist/declarations/src/access.d.ts +2 -2
- package/dist/declarations/src/access.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts +2 -2
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/context.d.ts +6 -6
- package/dist/declarations/src/admin-ui/context.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/filters.d.ts +5 -5
- package/dist/declarations/src/admin-ui/utils/filters.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/utils.d.ts +2 -2
- package/dist/declarations/src/admin-ui/utils/utils.d.ts.map +1 -1
- package/dist/declarations/src/context.d.ts +1 -1
- package/dist/declarations/src/context.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bigInt/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bigInt/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bytes/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bytes/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/checkbox/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/checkbox/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/decimal/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/decimal/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/file/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/file/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/float/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/float/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/image/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/image/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/integer/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/integer/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/json/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/json/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/multiselect/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/password/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/password/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/index.d.ts +8 -8
- package/dist/declarations/src/fields/types/relationship/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/select/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/select/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/text/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/text/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/timestamp/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/timestamp/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/virtual/index.d.ts +7 -7
- package/dist/declarations/src/fields/types/virtual/index.d.ts.map +1 -1
- package/dist/declarations/src/helpers.d.ts +249 -13
- package/dist/declarations/src/helpers.d.ts.map +1 -1
- package/dist/declarations/src/index.d.ts +9 -4
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/internal-unstable/admin-ui/pages/ListPage/index.d.ts.map +1 -1
- package/dist/declarations/src/lib/admin-meta.d.ts +11 -11
- package/dist/declarations/src/lib/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/access-control.d.ts +18 -18
- package/dist/declarations/src/lib/core/access-control.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/cascade.d.ts +47 -0
- package/dist/declarations/src/lib/core/cascade.d.ts.map +1 -0
- package/dist/declarations/src/lib/core/initialise-lists.d.ts +27 -24
- package/dist/declarations/src/lib/core/initialise-lists.d.ts.map +1 -1
- package/dist/declarations/src/lib/env.d.ts +9 -0
- package/dist/declarations/src/lib/env.d.ts.map +1 -0
- package/dist/declarations/src/lib/system.d.ts +1 -1
- package/dist/declarations/src/lib/system.d.ts.map +1 -1
- package/dist/declarations/src/list-features.d.ts +162 -0
- package/dist/declarations/src/list-features.d.ts.map +1 -0
- package/dist/declarations/src/schema.d.ts +24 -23
- package/dist/declarations/src/schema.d.ts.map +1 -1
- package/dist/declarations/src/session.d.ts +75 -0
- package/dist/declarations/src/session.d.ts.map +1 -1
- package/dist/declarations/src/types/admin-meta.d.ts +11 -11
- package/dist/declarations/src/types/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/types/config/access-control.d.ts +42 -42
- package/dist/declarations/src/types/config/access-control.d.ts.map +1 -1
- package/dist/declarations/src/types/config/fields.d.ts +19 -19
- package/dist/declarations/src/types/config/fields.d.ts.map +1 -1
- package/dist/declarations/src/types/config/hooks.d.ts +131 -131
- package/dist/declarations/src/types/config/hooks.d.ts.map +1 -1
- package/dist/declarations/src/types/config/index.d.ts +190 -8
- package/dist/declarations/src/types/config/index.d.ts.map +1 -1
- package/dist/declarations/src/types/config/lists.d.ts +146 -108
- package/dist/declarations/src/types/config/lists.d.ts.map +1 -1
- package/dist/declarations/src/types/context.d.ts +507 -47
- package/dist/declarations/src/types/context.d.ts.map +1 -1
- package/dist/declarations/src/types/next-fields.d.ts +28 -28
- package/dist/declarations/src/types/next-fields.d.ts.map +1 -1
- package/dist/declarations/src/types/type-info.d.ts +3 -3
- package/dist/declarations/src/types/type-info.d.ts.map +1 -1
- package/dist/{express-455ae20c.cjs.js → express-84d534c2.cjs.js} +6 -6
- package/dist/{express-7559ca2d.esm.js → express-d0a4ce99.esm.js} +6 -6
- package/dist/{index-15c8f81e.esm.js → index-5d8b0b4e.esm.js} +363 -183
- package/dist/index-6055753b.cjs.js +393 -0
- package/dist/{index-42045902.cjs.js → index-ac29f382.cjs.js} +363 -185
- package/dist/index-f1703b7b.esm.js +386 -0
- package/dist/nixxie-cms-core.cjs.js +1388 -30
- package/dist/nixxie-cms-core.esm.js +1362 -24
- package/dist/{non-null-graphql-add6bb3d.cjs.js → non-null-graphql-4a44c122.cjs.js} +1 -1
- package/dist/{non-null-graphql-a84ed64d.esm.js → non-null-graphql-8c5feaae.esm.js} +1 -1
- package/dist/{resolve-hooks-165a9ce2.cjs.js → resolve-hooks-10a5f84c.cjs.js} +240 -6
- package/dist/{resolve-hooks-6813a045.esm.js → resolve-hooks-9e676794.esm.js} +238 -7
- package/dist/{system-a321642d.cjs.js → system-6b37a5f8.cjs.js} +33 -7
- package/dist/{system-03e49e4f.esm.js → system-e591d821.esm.js} +33 -7
- package/fields/dist/nixxie-cms-core-fields.cjs.js +29 -576
- package/fields/dist/nixxie-cms-core-fields.esm.js +18 -565
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js +4 -2
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.esm.js +4 -2
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.cjs.js +1 -6
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.esm.js +1 -6
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.cjs.js +4 -2
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.esm.js +4 -2
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.cjs.js +4 -3
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.esm.js +4 -3
- package/package.json +4 -4
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.cjs.js +4 -3
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.esm.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.cjs.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.esm.js +4 -3
- package/session/dist/nixxie-cms-core-session.cjs.js +286 -0
- package/session/dist/nixxie-cms-core-session.esm.js +279 -1
- package/src/access.ts +25 -25
- package/src/admin-ui/admin-meta-graphql.ts +5 -5
- package/src/admin-ui/components/CreateButtonLink.tsx +46 -46
- package/src/admin-ui/components/Navigation.tsx +3 -3
- package/src/admin-ui/context.tsx +6 -6
- package/src/admin-ui/utils/Fields.tsx +241 -241
- package/src/admin-ui/utils/actionData.ts +36 -36
- package/src/admin-ui/utils/filters.ts +148 -148
- package/src/admin-ui/utils/useCreateItem.ts +171 -171
- package/src/admin-ui/utils/utils.tsx +127 -127
- package/src/context.ts +1 -1
- package/src/fields/non-null-graphql.ts +115 -115
- package/src/fields/types/bigInt/index.ts +6 -6
- package/src/fields/types/bytes/index.ts +6 -6
- package/src/fields/types/calendarDay/index.ts +18 -19
- package/src/fields/types/checkbox/index.ts +6 -6
- package/src/fields/types/decimal/index.ts +6 -6
- package/src/fields/types/file/index.ts +8 -8
- package/src/fields/types/float/index.ts +6 -6
- package/src/fields/types/image/index.ts +8 -8
- package/src/fields/types/integer/index.ts +6 -6
- package/src/fields/types/json/index.ts +5 -5
- package/src/fields/types/multiselect/index.ts +7 -7
- package/src/fields/types/multiselect/views/index.tsx +149 -151
- package/src/fields/types/password/index.ts +6 -6
- package/src/fields/types/relationship/index.ts +13 -13
- package/src/fields/types/relationship/views/ComboboxMany.tsx +110 -110
- package/src/fields/types/relationship/views/ComboboxSingle.tsx +115 -115
- package/src/fields/types/relationship/views/ContextualActions.tsx +139 -139
- package/src/fields/types/relationship/views/index.tsx +492 -492
- package/src/fields/types/relationship/views/types.ts +46 -46
- package/src/fields/types/relationship/views/useApolloQuery.ts +185 -185
- package/src/fields/types/relationship/views/useFilter.tsx +109 -109
- package/src/fields/types/select/index.ts +6 -6
- package/src/fields/types/text/index.ts +6 -6
- package/src/fields/types/timestamp/index.ts +23 -21
- package/src/fields/types/virtual/index.ts +11 -11
- package/src/helpers.ts +773 -42
- package/src/index.ts +66 -24
- package/src/internal-unstable/admin-ui/pages/ItemPage/common.tsx +4 -4
- package/src/internal-unstable/admin-ui/pages/ItemPage/index.tsx +5 -5
- package/src/internal-unstable/admin-ui/pages/ListPage/index.tsx +8 -8
- package/src/lib/admin-meta.ts +369 -369
- package/src/lib/context/createContext.ts +6 -0
- package/src/lib/core/access-control.ts +434 -434
- package/src/lib/core/cascade.ts +236 -0
- package/src/lib/core/initialise-lists.ts +49 -33
- package/src/lib/core/mutations/index.ts +7 -0
- package/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +145 -145
- package/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +71 -71
- package/src/lib/core/queries/output-field.ts +178 -178
- package/src/lib/env.ts +50 -0
- package/src/lib/id-field.ts +2 -2
- package/src/lib/system.ts +221 -207
- package/src/lib/typescript-schema-printer.ts +227 -227
- package/src/list-features.ts +476 -0
- package/src/schema.ts +92 -22
- package/src/session.ts +225 -0
- package/src/types/admin-meta.ts +218 -218
- package/src/types/config/access-control.ts +186 -186
- package/src/types/config/fields.ts +96 -96
- package/src/types/config/hooks.ts +529 -529
- package/src/types/config/index.ts +206 -7
- package/src/types/config/lists.ts +606 -565
- package/src/types/context.ts +592 -55
- package/src/types/next-fields.ts +31 -31
- package/src/types/type-info.ts +38 -38
- package/src/types/type-tests.ts +21 -21
package/src/types/context.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { DocumentNode, ExecutionResult, GraphQLSchema } from 'graphql'
|
|
|
3
3
|
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
4
4
|
import type { InitialisedList } from '../lib/core/initialise-lists'
|
|
5
5
|
import type { SessionStrategy } from './session'
|
|
6
|
-
import type { BaseNixxieTypeInfo,
|
|
6
|
+
import type { BaseNixxieTypeInfo, BaseCollectionTypeInfo } from './type-info'
|
|
7
7
|
import type { MaybePromise } from './utils'
|
|
8
8
|
|
|
9
9
|
// ── Email service types (defined here so @nixxie-cms/email can implement without circular deps) ──
|
|
@@ -94,20 +94,41 @@ export type NixxieEmailService = {
|
|
|
94
94
|
close(): Promise<void>
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
// ── Service lifecycle ──
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Optional lifecycle hook for runtime services. When a service object exposes `init`,
|
|
101
|
+
* core calls it once with a sudo context after the database connects — this is how
|
|
102
|
+
* database-backed service stores (audit, versioning, workflow, jobs history, webhook
|
|
103
|
+
* subscriptions) get access to `context.prisma` without a circular boot dependency.
|
|
104
|
+
*/
|
|
105
|
+
export type NixxieInitableService = {
|
|
106
|
+
init?(context: NixxieContext): MaybePromise<void>
|
|
107
|
+
}
|
|
108
|
+
|
|
97
109
|
// ── Jobs service ──
|
|
98
110
|
|
|
99
111
|
export type NixxieJobDefinition = {
|
|
100
112
|
name: string
|
|
101
|
-
/**
|
|
102
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Cron expression or interval in milliseconds.
|
|
115
|
+
* Omit when `runAt` is set (one-time job). One of `schedule` or `runAt` is required.
|
|
116
|
+
*/
|
|
117
|
+
schedule?: string | number
|
|
118
|
+
/** Run once at this time instead of on a schedule. Times in the past run immediately. */
|
|
119
|
+
runAt?: Date
|
|
103
120
|
/** Handler function invoked on each tick */
|
|
104
|
-
handler: (ctx: { jobId: string; scheduledAt: Date }) => Promise<void> | void
|
|
121
|
+
handler: (ctx: { jobId: string; scheduledAt: Date; attempt: number }) => Promise<void> | void
|
|
105
122
|
/** Immediately run the job once on registration */
|
|
106
123
|
runImmediately?: boolean
|
|
107
124
|
/** Disable job without removing the definition */
|
|
108
125
|
enabled?: boolean
|
|
109
126
|
/** Milliseconds before a running job is considered stuck */
|
|
110
127
|
timeout?: number
|
|
128
|
+
/** Number of retry attempts after a failed run (0 = no retries) */
|
|
129
|
+
retries?: number
|
|
130
|
+
/** Base delay in milliseconds between retries (doubles each attempt) */
|
|
131
|
+
retryDelay?: number
|
|
111
132
|
}
|
|
112
133
|
|
|
113
134
|
export type NixxieJobStatus = 'idle' | 'running' | 'error' | 'disabled'
|
|
@@ -121,7 +142,7 @@ export type NixxieJobInfo = {
|
|
|
121
142
|
runs: number
|
|
122
143
|
}
|
|
123
144
|
|
|
124
|
-
export type NixxieJobsService = {
|
|
145
|
+
export type NixxieJobsService = NixxieInitableService & {
|
|
125
146
|
/** Register a job definition. Call before start() or at any time for hot-registration. */
|
|
126
147
|
define(job: NixxieJobDefinition): void
|
|
127
148
|
/** Remove a registered job by name. */
|
|
@@ -215,7 +236,7 @@ export type NixxieAuditRecord = NixxieAuditEntry & {
|
|
|
215
236
|
timestamp: Date
|
|
216
237
|
}
|
|
217
238
|
|
|
218
|
-
export type NixxieAuditService = {
|
|
239
|
+
export type NixxieAuditService = NixxieInitableService & {
|
|
219
240
|
/** Log an audit event. */
|
|
220
241
|
log(entry: NixxieAuditEntry): Promise<NixxieAuditRecord>
|
|
221
242
|
/** Query the audit log. */
|
|
@@ -261,9 +282,13 @@ export type NixxieWebhookSubscribeOptions = {
|
|
|
261
282
|
retries?: number
|
|
262
283
|
}
|
|
263
284
|
|
|
264
|
-
export type NixxieWebhooksService = {
|
|
285
|
+
export type NixxieWebhooksService = NixxieInitableService & {
|
|
265
286
|
/** Register a webhook endpoint for an event. Returns the subscription ID. */
|
|
266
|
-
subscribe(
|
|
287
|
+
subscribe(
|
|
288
|
+
event: string,
|
|
289
|
+
url: string,
|
|
290
|
+
options?: NixxieWebhookSubscribeOptions
|
|
291
|
+
): Promise<NixxieWebhookSubscription>
|
|
267
292
|
/** Remove a subscription by ID. */
|
|
268
293
|
unsubscribe(id: string): Promise<void>
|
|
269
294
|
/** Fire an event, delivering to all matching subscribers. */
|
|
@@ -316,7 +341,11 @@ export type NixxieRateLimitService = {
|
|
|
316
341
|
|
|
317
342
|
// ── Health service ──
|
|
318
343
|
|
|
319
|
-
export type NixxieHealthCheckFn = () => Promise<{
|
|
344
|
+
export type NixxieHealthCheckFn = () => Promise<{
|
|
345
|
+
ok: boolean
|
|
346
|
+
message?: string
|
|
347
|
+
details?: unknown
|
|
348
|
+
}>
|
|
320
349
|
|
|
321
350
|
export type NixxieHealthCheckResult = {
|
|
322
351
|
name: string
|
|
@@ -396,7 +425,11 @@ export type NixxieSignedUrlOptions = {
|
|
|
396
425
|
/** Pluggable blob storage. Implemented by @nixxie-cms/storage (local, S3, GCS, Azure). */
|
|
397
426
|
export type NixxieStorageService = {
|
|
398
427
|
/** Store a file and return its key + URL. */
|
|
399
|
-
put(
|
|
428
|
+
put(
|
|
429
|
+
key: string,
|
|
430
|
+
data: Buffer | Uint8Array | string,
|
|
431
|
+
options?: NixxiePutOptions
|
|
432
|
+
): Promise<NixxieStoredFile>
|
|
400
433
|
/** Read a file's bytes. Resolves undefined when the key does not exist. */
|
|
401
434
|
get(key: string): Promise<Buffer | undefined>
|
|
402
435
|
/** Delete a file. No-op if it does not exist. */
|
|
@@ -449,7 +482,10 @@ export type NixxieSearchService = {
|
|
|
449
482
|
/** Remove a document from an index by id. */
|
|
450
483
|
remove(indexName: string, id: string): Promise<void>
|
|
451
484
|
/** Run a search against an index. */
|
|
452
|
-
search<T = NixxieSearchDocument>(
|
|
485
|
+
search<T = NixxieSearchDocument>(
|
|
486
|
+
indexName: string,
|
|
487
|
+
query: NixxieSearchQuery
|
|
488
|
+
): Promise<NixxieSearchResults<T>>
|
|
453
489
|
/** Delete every document in an index. */
|
|
454
490
|
clear(indexName: string): Promise<void>
|
|
455
491
|
/** Gracefully close any open connections. */
|
|
@@ -526,11 +562,506 @@ export type NixxieAiService = {
|
|
|
526
562
|
embedMany(texts: string[]): Promise<number[][]>
|
|
527
563
|
}
|
|
528
564
|
|
|
565
|
+
// ── AI RAG service (retrieval-augmented knowledge base) ──
|
|
566
|
+
|
|
567
|
+
/** A source document stored in the knowledge base that the assistant is trained on. */
|
|
568
|
+
export type NixxieRagDocumentInput = {
|
|
569
|
+
/** Short title/label for the document. */
|
|
570
|
+
title?: string
|
|
571
|
+
/** The body the assistant learns from. */
|
|
572
|
+
content: string
|
|
573
|
+
/** Origin of the content (URL, filename, list:itemId, …) — shown in citations. */
|
|
574
|
+
source?: string
|
|
575
|
+
/** Free-form tags used to scope retrieval (e.g. ['billing', 'public']). */
|
|
576
|
+
tags?: string[]
|
|
577
|
+
/** Arbitrary structured metadata returned alongside citations. */
|
|
578
|
+
metadata?: Record<string, unknown>
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export type NixxieRagDocument = NixxieRagDocumentInput & {
|
|
582
|
+
id: string
|
|
583
|
+
/** Indexing lifecycle of the document's chunks. */
|
|
584
|
+
status: 'pending' | 'indexing' | 'indexed' | 'error' | 'disabled'
|
|
585
|
+
/** Number of chunks currently indexed for this document. */
|
|
586
|
+
chunkCount: number
|
|
587
|
+
/** Last error encountered while indexing, if any. */
|
|
588
|
+
error?: string
|
|
589
|
+
createdAt: Date
|
|
590
|
+
updatedAt: Date
|
|
591
|
+
indexedAt?: Date
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export type NixxieRagDocumentQuery = {
|
|
595
|
+
take?: number
|
|
596
|
+
skip?: number
|
|
597
|
+
/** Only return documents matching ALL of these tags. */
|
|
598
|
+
tags?: string[]
|
|
599
|
+
status?: NixxieRagDocument['status']
|
|
600
|
+
/** Substring match against title/content/source. */
|
|
601
|
+
search?: string
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** A retrieved chunk with its similarity score, used to ground answers. */
|
|
605
|
+
export type NixxieRagChunk = {
|
|
606
|
+
id: string
|
|
607
|
+
documentId: string
|
|
608
|
+
title?: string
|
|
609
|
+
source?: string
|
|
610
|
+
/** The chunk text. */
|
|
611
|
+
content: string
|
|
612
|
+
/** Cosine similarity to the query in [0, 1] (higher is more relevant). */
|
|
613
|
+
score: number
|
|
614
|
+
tags?: string[]
|
|
615
|
+
metadata?: Record<string, unknown>
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export type NixxieRagRetrieveOptions = {
|
|
619
|
+
/** Number of chunks to return. Defaults to the configured `retrieval.topK`. */
|
|
620
|
+
topK?: number
|
|
621
|
+
/** Drop chunks scoring below this threshold. Defaults to `retrieval.minScore`. */
|
|
622
|
+
minScore?: number
|
|
623
|
+
/** Restrict retrieval to documents carrying ALL of these tags. */
|
|
624
|
+
tags?: string[]
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** A single source the answer was grounded on. */
|
|
628
|
+
export type NixxieRagCitation = {
|
|
629
|
+
documentId: string
|
|
630
|
+
chunkId: string
|
|
631
|
+
title?: string
|
|
632
|
+
source?: string
|
|
633
|
+
score: number
|
|
634
|
+
/** Short excerpt of the cited chunk. */
|
|
635
|
+
snippet: string
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
export type NixxieRagAskOptions = NixxieRagRetrieveOptions & {
|
|
639
|
+
/** Override the generation model for this call. */
|
|
640
|
+
model?: string
|
|
641
|
+
/** Override sampling temperature for this call. */
|
|
642
|
+
temperature?: number
|
|
643
|
+
/** Override max output tokens for this call. */
|
|
644
|
+
maxTokens?: number
|
|
645
|
+
/** Append an extra instruction to the system prompt for this call. */
|
|
646
|
+
systemSuffix?: string
|
|
647
|
+
/** Pre-retrieved chunks to use instead of running retrieval (advanced). */
|
|
648
|
+
context?: NixxieRagChunk[]
|
|
649
|
+
/** Per-call override of the hallucination guard. */
|
|
650
|
+
guard?: boolean
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/** The grounded answer returned by `ask`/`chat`. */
|
|
654
|
+
export type NixxieRagAnswer = {
|
|
655
|
+
/** The assistant's answer text. */
|
|
656
|
+
text: string
|
|
657
|
+
/** The sources the answer was grounded on. */
|
|
658
|
+
sources: NixxieRagCitation[]
|
|
659
|
+
/** Whether the answer passed the grounding/hallucination check. */
|
|
660
|
+
grounded: boolean
|
|
661
|
+
/** True when the assistant refused because no relevant context was found. */
|
|
662
|
+
refused: boolean
|
|
663
|
+
model: string
|
|
664
|
+
usage?: { inputTokens?: number; outputTokens?: number }
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** A streamed token or lifecycle event from `stream`. */
|
|
668
|
+
export type NixxieRagStreamEvent =
|
|
669
|
+
| { type: 'sources'; sources: NixxieRagCitation[] }
|
|
670
|
+
| { type: 'token'; token: string }
|
|
671
|
+
| { type: 'done'; answer: NixxieRagAnswer }
|
|
672
|
+
| { type: 'error'; error: string }
|
|
673
|
+
|
|
674
|
+
export type NixxieRagIndexStats = {
|
|
675
|
+
/** Documents processed this run. */
|
|
676
|
+
documents: number
|
|
677
|
+
/** Chunks (re)embedded this run. */
|
|
678
|
+
chunks: number
|
|
679
|
+
/** Documents that failed to index. */
|
|
680
|
+
errors: number
|
|
681
|
+
/** Wall-clock duration in milliseconds. */
|
|
682
|
+
durationMs: number
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* A custom, RAG-trained assistant backed by a knowledge-base collection.
|
|
687
|
+
* Implemented by @nixxie-cms/ai-rag. Add/remove/retrieve KB content, (re)index it
|
|
688
|
+
* into embeddings, and ask grounded, citation-backed questions with hallucination guarding.
|
|
689
|
+
*/
|
|
690
|
+
export type NixxieAiRagService = NixxieInitableService & {
|
|
691
|
+
// ── Knowledge-base content ──
|
|
692
|
+
/** Add a document to the knowledge base (queued for indexing). */
|
|
693
|
+
addDocument(doc: NixxieRagDocumentInput): Promise<NixxieRagDocument>
|
|
694
|
+
/** Add many documents in one call. */
|
|
695
|
+
addDocuments(docs: NixxieRagDocumentInput[]): Promise<NixxieRagDocument[]>
|
|
696
|
+
/** Fetch a single document by id. */
|
|
697
|
+
getDocument(id: string): Promise<NixxieRagDocument | undefined>
|
|
698
|
+
/** List documents in the knowledge base. */
|
|
699
|
+
listDocuments(query?: NixxieRagDocumentQuery): Promise<NixxieRagDocument[]>
|
|
700
|
+
/** Patch a document's content/metadata (re-queues it for indexing). */
|
|
701
|
+
updateDocument(id: string, patch: Partial<NixxieRagDocumentInput>): Promise<NixxieRagDocument>
|
|
702
|
+
/** Remove a document and all of its indexed chunks. */
|
|
703
|
+
removeDocument(id: string): Promise<void>
|
|
704
|
+
|
|
705
|
+
// ── Indexing ──
|
|
706
|
+
/** (Re)index a single document now. */
|
|
707
|
+
index(documentId: string): Promise<void>
|
|
708
|
+
/** (Re)index documents. Pass `{ force: true }` to rebuild already-indexed docs. */
|
|
709
|
+
reindex(options?: { force?: boolean; tags?: string[] }): Promise<NixxieRagIndexStats>
|
|
710
|
+
/** Index every document still pending/changed. */
|
|
711
|
+
indexPending(): Promise<NixxieRagIndexStats>
|
|
712
|
+
|
|
713
|
+
// ── Retrieval & chat ──
|
|
714
|
+
/** Return the most relevant chunks for a query (no generation). */
|
|
715
|
+
retrieve(query: string, options?: NixxieRagRetrieveOptions): Promise<NixxieRagChunk[]>
|
|
716
|
+
/** Ask a one-shot question and get a grounded, cited answer. */
|
|
717
|
+
ask(question: string, options?: NixxieRagAskOptions): Promise<NixxieRagAnswer>
|
|
718
|
+
/** Multi-turn chat; the latest user turn drives retrieval. */
|
|
719
|
+
chat(messages: NixxieAiMessage[], options?: NixxieRagAskOptions): Promise<NixxieRagAnswer>
|
|
720
|
+
/** Streamed variant of `chat`, yielding sources, then tokens, then the final answer. */
|
|
721
|
+
stream(
|
|
722
|
+
messages: NixxieAiMessage[],
|
|
723
|
+
options?: NixxieRagAskOptions
|
|
724
|
+
): AsyncIterable<NixxieRagStreamEvent>
|
|
725
|
+
|
|
726
|
+
/** Gracefully stop background indexing and flush pending work. */
|
|
727
|
+
close(): Promise<void>
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// ── Versioning service ──
|
|
731
|
+
|
|
732
|
+
export type NixxieVersionEntry = {
|
|
733
|
+
/** Collection name (e.g. 'Post') */
|
|
734
|
+
resource: string
|
|
735
|
+
/** ID of the item this snapshot belongs to */
|
|
736
|
+
resourceId: string
|
|
737
|
+
/** Snapshot of the item's data at this point in time */
|
|
738
|
+
data: Record<string, unknown>
|
|
739
|
+
/** Optional human label (e.g. 'before publish') */
|
|
740
|
+
label?: string
|
|
741
|
+
/** Who created the snapshot */
|
|
742
|
+
actor?: {
|
|
743
|
+
id?: string
|
|
744
|
+
label?: string
|
|
745
|
+
}
|
|
746
|
+
/** Arbitrary extra context */
|
|
747
|
+
meta?: Record<string, unknown>
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
export type NixxieVersionRecord = NixxieVersionEntry & {
|
|
751
|
+
id: string
|
|
752
|
+
/** Monotonically increasing version number, scoped to resource + resourceId (starts at 1). */
|
|
753
|
+
version: number
|
|
754
|
+
createdAt: Date
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
export type NixxieVersionQuery = {
|
|
758
|
+
take?: number
|
|
759
|
+
skip?: number
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export type NixxieVersionDiff = {
|
|
763
|
+
fromVersion: number
|
|
764
|
+
toVersion: number
|
|
765
|
+
/** Per-field differences between the two versions. */
|
|
766
|
+
changes: Record<string, { from: unknown; to: unknown }>
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/** Content revision history. Implemented by @nixxie-cms/versioning. */
|
|
770
|
+
export type NixxieVersioningService = NixxieInitableService & {
|
|
771
|
+
/** Record a new snapshot of an item's data. Returns the created version record. */
|
|
772
|
+
snapshot(entry: NixxieVersionEntry): Promise<NixxieVersionRecord>
|
|
773
|
+
/** List versions for an item, newest first. */
|
|
774
|
+
list(
|
|
775
|
+
resource: string,
|
|
776
|
+
resourceId: string,
|
|
777
|
+
query?: NixxieVersionQuery
|
|
778
|
+
): Promise<NixxieVersionRecord[]>
|
|
779
|
+
/** Fetch a single version by its ID. */
|
|
780
|
+
get(versionId: string): Promise<NixxieVersionRecord | undefined>
|
|
781
|
+
/** Get the most recent version for an item. */
|
|
782
|
+
latest(resource: string, resourceId: string): Promise<NixxieVersionRecord | undefined>
|
|
783
|
+
/**
|
|
784
|
+
* Restore an older version: copies its data into a brand-new snapshot
|
|
785
|
+
* (so history is never lost) and returns that new record. The caller is
|
|
786
|
+
* responsible for writing `record.data` back to the live item.
|
|
787
|
+
*/
|
|
788
|
+
restore(versionId: string): Promise<NixxieVersionRecord>
|
|
789
|
+
/** Compute a field-level diff between two versions of the same item. */
|
|
790
|
+
diff(fromVersionId: string, toVersionId: string): Promise<NixxieVersionDiff>
|
|
791
|
+
/** Keep only the newest `keep` versions of an item, deleting the rest. Returns the number deleted. */
|
|
792
|
+
prune(resource: string, resourceId: string, keep: number): Promise<number>
|
|
793
|
+
/** Gracefully shut down (flush pending writes). */
|
|
794
|
+
close(): Promise<void>
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// ── Workflow service ──
|
|
798
|
+
|
|
799
|
+
export type NixxieWorkflowState = string
|
|
800
|
+
|
|
801
|
+
export type NixxieWorkflowTransition = {
|
|
802
|
+
/** The state(s) this transition can start from. */
|
|
803
|
+
from: NixxieWorkflowState | NixxieWorkflowState[]
|
|
804
|
+
/** The state this transition moves to. */
|
|
805
|
+
to: NixxieWorkflowState
|
|
806
|
+
/** Optional action name (e.g. 'submit', 'approve', 'reject'). */
|
|
807
|
+
name?: string
|
|
808
|
+
/**
|
|
809
|
+
* Optional guard evaluated before the transition is recorded.
|
|
810
|
+
* Return `false` to block it, or a string to block it with a custom error message.
|
|
811
|
+
*/
|
|
812
|
+
when?: (args: {
|
|
813
|
+
resource: string
|
|
814
|
+
resourceId: string
|
|
815
|
+
from: NixxieWorkflowState
|
|
816
|
+
to: NixxieWorkflowState
|
|
817
|
+
actor?: NixxieWorkflowActor
|
|
818
|
+
meta?: Record<string, unknown>
|
|
819
|
+
}) => MaybePromise<boolean | string>
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export type NixxieWorkflowDefinition = {
|
|
823
|
+
name: string
|
|
824
|
+
/** State assigned to items that have no recorded state yet. */
|
|
825
|
+
initial: NixxieWorkflowState
|
|
826
|
+
/** All valid states. */
|
|
827
|
+
states: NixxieWorkflowState[]
|
|
828
|
+
/** Allowed transitions between states. */
|
|
829
|
+
transitions: NixxieWorkflowTransition[]
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
export type NixxieWorkflowActor = {
|
|
833
|
+
id?: string
|
|
834
|
+
label?: string
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
export type NixxieWorkflowTransitionInput = {
|
|
838
|
+
actor?: NixxieWorkflowActor
|
|
839
|
+
meta?: Record<string, unknown>
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export type NixxieWorkflowHistoryEntry = {
|
|
843
|
+
id: string
|
|
844
|
+
resource: string
|
|
845
|
+
resourceId: string
|
|
846
|
+
/** Previous state, or null for the first transition. */
|
|
847
|
+
from: NixxieWorkflowState | null
|
|
848
|
+
to: NixxieWorkflowState
|
|
849
|
+
actor?: NixxieWorkflowActor
|
|
850
|
+
meta?: Record<string, unknown>
|
|
851
|
+
at: Date
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/** Editorial state machine (draft → review → published, etc). Implemented by @nixxie-cms/workflow. */
|
|
855
|
+
export type NixxieWorkflowService = NixxieInitableService & {
|
|
856
|
+
/** The workflow definition this service enforces. */
|
|
857
|
+
definition(): NixxieWorkflowDefinition
|
|
858
|
+
/** Current state of an item (returns the initial state if none recorded). */
|
|
859
|
+
getState(resource: string, resourceId: string): Promise<NixxieWorkflowState>
|
|
860
|
+
/**
|
|
861
|
+
* Move an item to `to`, enforcing that a transition from its current state is allowed.
|
|
862
|
+
* Throws if the transition is not permitted.
|
|
863
|
+
*/
|
|
864
|
+
transition(
|
|
865
|
+
resource: string,
|
|
866
|
+
resourceId: string,
|
|
867
|
+
to: NixxieWorkflowState,
|
|
868
|
+
input?: NixxieWorkflowTransitionInput
|
|
869
|
+
): Promise<NixxieWorkflowHistoryEntry>
|
|
870
|
+
/** Force a state without checking transition rules (e.g. migrations / admin override). */
|
|
871
|
+
setState(
|
|
872
|
+
resource: string,
|
|
873
|
+
resourceId: string,
|
|
874
|
+
to: NixxieWorkflowState,
|
|
875
|
+
input?: NixxieWorkflowTransitionInput
|
|
876
|
+
): Promise<NixxieWorkflowHistoryEntry>
|
|
877
|
+
/** Whether a direct transition from `from` to `to` is allowed. */
|
|
878
|
+
can(from: NixxieWorkflowState, to: NixxieWorkflowState): boolean
|
|
879
|
+
/** States reachable from `from` in a single transition. */
|
|
880
|
+
available(from: NixxieWorkflowState): NixxieWorkflowState[]
|
|
881
|
+
/** Transition history for an item, newest first. */
|
|
882
|
+
history(
|
|
883
|
+
resource: string,
|
|
884
|
+
resourceId: string,
|
|
885
|
+
take?: number
|
|
886
|
+
): Promise<NixxieWorkflowHistoryEntry[]>
|
|
887
|
+
/** Gracefully shut down (flush pending writes). */
|
|
888
|
+
close(): Promise<void>
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// ── API keys service ──
|
|
892
|
+
|
|
893
|
+
export type NixxieApiKeyIssueOptions = {
|
|
894
|
+
/** Human-friendly name for the key. */
|
|
895
|
+
name: string
|
|
896
|
+
/** Permission scopes granted to the key. */
|
|
897
|
+
scopes?: string[]
|
|
898
|
+
/** Optional expiry. Omit for a non-expiring key. */
|
|
899
|
+
expiresAt?: Date
|
|
900
|
+
/** Arbitrary extra context. */
|
|
901
|
+
meta?: Record<string, unknown>
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
export type NixxieApiKeyRecord = {
|
|
905
|
+
id: string
|
|
906
|
+
name: string
|
|
907
|
+
scopes: string[]
|
|
908
|
+
/** Short, non-secret prefix used to identify the key in UIs and logs. */
|
|
909
|
+
prefix: string
|
|
910
|
+
createdAt: Date
|
|
911
|
+
expiresAt?: Date
|
|
912
|
+
lastUsedAt?: Date
|
|
913
|
+
revokedAt?: Date
|
|
914
|
+
meta?: Record<string, unknown>
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export type NixxieApiKeyIssued = {
|
|
918
|
+
record: NixxieApiKeyRecord
|
|
919
|
+
/** The full plaintext key. Shown ONCE at issue time — only its hash is stored. */
|
|
920
|
+
key: string
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
export type NixxieApiKeyVerifyResult =
|
|
924
|
+
| { valid: true; record: NixxieApiKeyRecord }
|
|
925
|
+
| { valid: false; reason: 'not-found' | 'revoked' | 'expired' | 'missing-scope' }
|
|
926
|
+
|
|
927
|
+
/** Scoped, revocable machine-to-machine access tokens. Implemented by @nixxie-cms/api-keys. */
|
|
928
|
+
export type NixxieApiKeysService = {
|
|
929
|
+
/** Issue a new key. The plaintext value is returned once and never stored. */
|
|
930
|
+
issue(options: NixxieApiKeyIssueOptions): Promise<NixxieApiKeyIssued>
|
|
931
|
+
/** Verify a plaintext key, checking revocation and expiry. Updates `lastUsedAt` on success. */
|
|
932
|
+
verify(key: string): Promise<NixxieApiKeyVerifyResult>
|
|
933
|
+
/** Verify a key and require that it holds every one of `scopes`. */
|
|
934
|
+
authorize(key: string, scopes: string[]): Promise<NixxieApiKeyVerifyResult>
|
|
935
|
+
/** Revoke a key by ID. */
|
|
936
|
+
revoke(id: string): Promise<void>
|
|
937
|
+
/** List all key records (never includes the plaintext key). */
|
|
938
|
+
list(): Promise<NixxieApiKeyRecord[]>
|
|
939
|
+
/** Fetch a single key record by ID. */
|
|
940
|
+
get(id: string): Promise<NixxieApiKeyRecord | undefined>
|
|
941
|
+
/** Gracefully shut down (flush pending writes). */
|
|
942
|
+
close(): Promise<void>
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// ── Logger service ──
|
|
946
|
+
|
|
947
|
+
export type NixxieLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal'
|
|
948
|
+
|
|
949
|
+
export type NixxieLogFields = Record<string, unknown>
|
|
950
|
+
|
|
951
|
+
export type NixxieLogRecord = {
|
|
952
|
+
level: NixxieLogLevel
|
|
953
|
+
message: string
|
|
954
|
+
/** ISO-8601 timestamp. */
|
|
955
|
+
time: string
|
|
956
|
+
/** Bound + per-call structured fields merged together. */
|
|
957
|
+
fields: NixxieLogFields
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/** Receives every emitted log record (e.g. console JSON, a file, an external sink). */
|
|
961
|
+
export type NixxieLogSink = (record: NixxieLogRecord) => void
|
|
962
|
+
|
|
963
|
+
/** Structured, level-aware logging with bound child loggers. Implemented by @nixxie-cms/logger. */
|
|
964
|
+
export type NixxieLoggerService = {
|
|
965
|
+
debug(message: string, fields?: NixxieLogFields): void
|
|
966
|
+
info(message: string, fields?: NixxieLogFields): void
|
|
967
|
+
warn(message: string, fields?: NixxieLogFields): void
|
|
968
|
+
error(message: string, fields?: NixxieLogFields): void
|
|
969
|
+
fatal(message: string, fields?: NixxieLogFields): void
|
|
970
|
+
/** Emit at an explicit level. */
|
|
971
|
+
log(level: NixxieLogLevel, message: string, fields?: NixxieLogFields): void
|
|
972
|
+
/**
|
|
973
|
+
* Create a child logger that always includes the given bound fields
|
|
974
|
+
* (e.g. `{ requestId }`). Children inherit the parent's level and sinks.
|
|
975
|
+
*/
|
|
976
|
+
child(bindings: NixxieLogFields): NixxieLoggerService
|
|
977
|
+
/** The current minimum level; records below it are dropped. */
|
|
978
|
+
readonly level: NixxieLogLevel
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// ── Backup service ──
|
|
982
|
+
|
|
983
|
+
export type NixxieBackupFormat = 'json' | 'ndjson'
|
|
984
|
+
|
|
985
|
+
export type NixxieBackupCollection = {
|
|
986
|
+
collection: string
|
|
987
|
+
items: Record<string, unknown>[]
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
export type NixxieBackupArchive = {
|
|
991
|
+
version: 1
|
|
992
|
+
createdAt: string
|
|
993
|
+
collections: NixxieBackupCollection[]
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
export type NixxieBackupExportOptions = {
|
|
997
|
+
/** Collections to include. Omit to export every collection the data source exposes. */
|
|
998
|
+
collections?: string[]
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export type NixxieBackupImportMode = 'create' | 'upsert'
|
|
1002
|
+
|
|
1003
|
+
export type NixxieBackupImportOptions = {
|
|
1004
|
+
/** 'create' (default) always inserts; 'upsert' updates existing items by id. */
|
|
1005
|
+
mode?: NixxieBackupImportMode
|
|
1006
|
+
/** Restrict the import to these collections. */
|
|
1007
|
+
collections?: string[]
|
|
1008
|
+
/** Continue past individual item failures instead of throwing. */
|
|
1009
|
+
continueOnError?: boolean
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
export type NixxieBackupImportResult = {
|
|
1013
|
+
created: number
|
|
1014
|
+
updated: number
|
|
1015
|
+
skipped: number
|
|
1016
|
+
errors: { collection: string; id?: string; error: string }[]
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Abstraction over the live data store, supplied by the host app (typically built
|
|
1021
|
+
* from a NixxieContext). Lets the backup service read and write content without
|
|
1022
|
+
* being coupled to Prisma or the GraphQL layer.
|
|
1023
|
+
*/
|
|
1024
|
+
export type NixxieBackupDataSource = {
|
|
1025
|
+
/** Names of the collections available for export/import. */
|
|
1026
|
+
collections(): string[] | Promise<string[]>
|
|
1027
|
+
/** Read every item of a collection. */
|
|
1028
|
+
read(collection: string): Promise<Record<string, unknown>[]>
|
|
1029
|
+
/** Write items into a collection, honouring the requested mode. */
|
|
1030
|
+
write(
|
|
1031
|
+
collection: string,
|
|
1032
|
+
items: Record<string, unknown>[],
|
|
1033
|
+
mode: NixxieBackupImportMode
|
|
1034
|
+
): Promise<
|
|
1035
|
+
Omit<NixxieBackupImportResult, 'errors'> & { errors: { id?: string; error: string }[] }
|
|
1036
|
+
>
|
|
1037
|
+
/** Count items in a collection (used by `seed` to detect non-empty targets). */
|
|
1038
|
+
count(collection: string): Promise<number>
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/** Content export / import / seed. Implemented by @nixxie-cms/backup. */
|
|
1042
|
+
export type NixxieBackupService = {
|
|
1043
|
+
/** Read the data source into an in-memory archive. */
|
|
1044
|
+
export(options?: NixxieBackupExportOptions): Promise<NixxieBackupArchive>
|
|
1045
|
+
/** Serialize an archive to a string in the given format (default 'json'). */
|
|
1046
|
+
serialize(archive: NixxieBackupArchive, format?: NixxieBackupFormat): string
|
|
1047
|
+
/** Parse a serialized archive back into structured form. */
|
|
1048
|
+
parse(text: string, format?: NixxieBackupFormat): NixxieBackupArchive
|
|
1049
|
+
/** Write an archive into the data source. */
|
|
1050
|
+
import(
|
|
1051
|
+
archive: NixxieBackupArchive,
|
|
1052
|
+
options?: NixxieBackupImportOptions
|
|
1053
|
+
): Promise<NixxieBackupImportResult>
|
|
1054
|
+
/** Import an archive, but only into collections that are currently empty. */
|
|
1055
|
+
seed(archive: NixxieBackupArchive): Promise<NixxieBackupImportResult>
|
|
1056
|
+
/** Gracefully shut down. */
|
|
1057
|
+
close(): Promise<void>
|
|
1058
|
+
}
|
|
1059
|
+
|
|
529
1060
|
// ── Context ──
|
|
530
1061
|
|
|
531
1062
|
export type NixxieContext<TypeInfo extends BaseNixxieTypeInfo = BaseNixxieTypeInfo> = {
|
|
532
1063
|
db: NixxieDbAPI<TypeInfo['lists']>
|
|
533
|
-
query:
|
|
1064
|
+
query: NixxieCollectionsAPI<TypeInfo['lists']>
|
|
534
1065
|
graphql: NixxieGraphQLAPI
|
|
535
1066
|
prisma: TypeInfo['prisma']
|
|
536
1067
|
/** Runtime services configured in nixxie.ts — available everywhere context is available */
|
|
@@ -546,6 +1077,12 @@ export type NixxieContext<TypeInfo extends BaseNixxieTypeInfo = BaseNixxieTypeIn
|
|
|
546
1077
|
search: NixxieSearchService | null
|
|
547
1078
|
notifications: NixxieNotificationsService | null
|
|
548
1079
|
ai: NixxieAiService | null
|
|
1080
|
+
aiRag: NixxieAiRagService | null
|
|
1081
|
+
versioning: NixxieVersioningService | null
|
|
1082
|
+
workflow: NixxieWorkflowService | null
|
|
1083
|
+
apiKeys: NixxieApiKeysService | null
|
|
1084
|
+
logger: NixxieLoggerService | null
|
|
1085
|
+
backup: NixxieBackupService | null
|
|
549
1086
|
}
|
|
550
1087
|
transaction: <T>(
|
|
551
1088
|
f: (context: NixxieContext<TypeInfo>) => MaybePromise<T>,
|
|
@@ -584,57 +1121,57 @@ export type NixxieContext<TypeInfo extends BaseNixxieTypeInfo = BaseNixxieTypeIn
|
|
|
584
1121
|
|
|
585
1122
|
// List item API
|
|
586
1123
|
|
|
587
|
-
type UniqueWhereInput<
|
|
588
|
-
false extends
|
|
589
|
-
? { readonly where:
|
|
590
|
-
: { readonly where?:
|
|
1124
|
+
type UniqueWhereInput<CollectionTypeInfo extends BaseCollectionTypeInfo> =
|
|
1125
|
+
false extends CollectionTypeInfo['isSingleton']
|
|
1126
|
+
? { readonly where: CollectionTypeInfo['inputs']['uniqueWhere'] }
|
|
1127
|
+
: { readonly where?: CollectionTypeInfo['inputs']['uniqueWhere'] }
|
|
591
1128
|
|
|
592
|
-
type
|
|
1129
|
+
type CollectionAPI<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
593
1130
|
findMany(
|
|
594
1131
|
args?: {
|
|
595
|
-
readonly where?:
|
|
1132
|
+
readonly where?: CollectionTypeInfo['inputs']['where']
|
|
596
1133
|
readonly take?: number
|
|
597
1134
|
readonly skip?: number
|
|
598
1135
|
readonly orderBy?:
|
|
599
|
-
|
|
|
600
|
-
| readonly
|
|
601
|
-
readonly cursor?:
|
|
1136
|
+
| CollectionTypeInfo['inputs']['orderBy']
|
|
1137
|
+
| readonly CollectionTypeInfo['inputs']['orderBy'][]
|
|
1138
|
+
readonly cursor?: CollectionTypeInfo['inputs']['uniqueWhere']
|
|
602
1139
|
} & ResolveFields
|
|
603
1140
|
): Promise<readonly Record<string, any>[]>
|
|
604
|
-
findOne(args: UniqueWhereInput<
|
|
605
|
-
count(args?: { readonly where?:
|
|
1141
|
+
findOne(args: UniqueWhereInput<CollectionTypeInfo> & ResolveFields): Promise<Record<string, any>>
|
|
1142
|
+
count(args?: { readonly where?: CollectionTypeInfo['inputs']['where'] }): Promise<number>
|
|
606
1143
|
updateOne(
|
|
607
|
-
args: UniqueWhereInput<
|
|
608
|
-
readonly data:
|
|
1144
|
+
args: UniqueWhereInput<CollectionTypeInfo> & {
|
|
1145
|
+
readonly data: CollectionTypeInfo['inputs']['update']
|
|
609
1146
|
} & ResolveFields
|
|
610
1147
|
): Promise<Record<string, any>>
|
|
611
1148
|
updateMany(
|
|
612
1149
|
args: {
|
|
613
|
-
readonly data: readonly (UniqueWhereInput<
|
|
614
|
-
readonly data:
|
|
1150
|
+
readonly data: readonly (UniqueWhereInput<CollectionTypeInfo> & {
|
|
1151
|
+
readonly data: CollectionTypeInfo['inputs']['update']
|
|
615
1152
|
})[]
|
|
616
1153
|
} & ResolveFields
|
|
617
1154
|
): Promise<Record<string, any>[]>
|
|
618
1155
|
createOne(
|
|
619
|
-
args: { readonly data:
|
|
1156
|
+
args: { readonly data: CollectionTypeInfo['inputs']['create'] } & ResolveFields
|
|
620
1157
|
): Promise<Record<string, any>>
|
|
621
1158
|
createMany(
|
|
622
1159
|
args: {
|
|
623
|
-
readonly data: readonly
|
|
1160
|
+
readonly data: readonly CollectionTypeInfo['inputs']['create'][]
|
|
624
1161
|
} & ResolveFields
|
|
625
1162
|
): Promise<Record<string, any>[]>
|
|
626
1163
|
deleteOne(
|
|
627
|
-
args: UniqueWhereInput<
|
|
1164
|
+
args: UniqueWhereInput<CollectionTypeInfo> & ResolveFields
|
|
628
1165
|
): Promise<Record<string, any> | null>
|
|
629
1166
|
deleteMany(
|
|
630
1167
|
args: {
|
|
631
|
-
readonly where: readonly
|
|
1168
|
+
readonly where: readonly CollectionTypeInfo['inputs']['uniqueWhere'][]
|
|
632
1169
|
} & ResolveFields
|
|
633
1170
|
): Promise<Record<string, any>[]>
|
|
634
1171
|
}
|
|
635
1172
|
|
|
636
|
-
export type
|
|
637
|
-
[Key in keyof ListsTypeInfo]:
|
|
1173
|
+
export type NixxieCollectionsAPI<ListsTypeInfo extends Record<string, BaseCollectionTypeInfo>> = {
|
|
1174
|
+
[Key in keyof ListsTypeInfo]: CollectionAPI<ListsTypeInfo[Key]>
|
|
638
1175
|
}
|
|
639
1176
|
|
|
640
1177
|
type ResolveFields = {
|
|
@@ -644,41 +1181,41 @@ type ResolveFields = {
|
|
|
644
1181
|
readonly query?: string
|
|
645
1182
|
}
|
|
646
1183
|
|
|
647
|
-
type DbAPI<
|
|
1184
|
+
type DbAPI<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
648
1185
|
findMany(args?: {
|
|
649
|
-
readonly where?:
|
|
1186
|
+
readonly where?: CollectionTypeInfo['inputs']['where']
|
|
650
1187
|
readonly take?: number
|
|
651
1188
|
readonly skip?: number
|
|
652
1189
|
readonly orderBy?:
|
|
653
|
-
|
|
|
654
|
-
| readonly
|
|
655
|
-
readonly cursor?:
|
|
656
|
-
}): Promise<readonly
|
|
657
|
-
findOne(args: UniqueWhereInput<
|
|
658
|
-
count(args?: { readonly where?:
|
|
1190
|
+
| CollectionTypeInfo['inputs']['orderBy']
|
|
1191
|
+
| readonly CollectionTypeInfo['inputs']['orderBy'][]
|
|
1192
|
+
readonly cursor?: CollectionTypeInfo['inputs']['uniqueWhere']
|
|
1193
|
+
}): Promise<readonly CollectionTypeInfo['item'][]>
|
|
1194
|
+
findOne(args: UniqueWhereInput<CollectionTypeInfo>): Promise<CollectionTypeInfo['item'] | null>
|
|
1195
|
+
count(args?: { readonly where?: CollectionTypeInfo['inputs']['where'] }): Promise<number>
|
|
659
1196
|
updateOne(
|
|
660
|
-
args: UniqueWhereInput<
|
|
661
|
-
readonly data:
|
|
1197
|
+
args: UniqueWhereInput<CollectionTypeInfo> & {
|
|
1198
|
+
readonly data: CollectionTypeInfo['inputs']['update']
|
|
662
1199
|
}
|
|
663
|
-
): Promise<
|
|
1200
|
+
): Promise<CollectionTypeInfo['item']>
|
|
664
1201
|
updateMany(args: {
|
|
665
|
-
readonly data: readonly (UniqueWhereInput<
|
|
666
|
-
readonly data:
|
|
1202
|
+
readonly data: readonly (UniqueWhereInput<CollectionTypeInfo> & {
|
|
1203
|
+
readonly data: CollectionTypeInfo['inputs']['update']
|
|
667
1204
|
})[]
|
|
668
|
-
}): Promise<
|
|
1205
|
+
}): Promise<CollectionTypeInfo['item'][]>
|
|
669
1206
|
createOne(args: {
|
|
670
|
-
readonly data:
|
|
671
|
-
}): Promise<
|
|
1207
|
+
readonly data: CollectionTypeInfo['inputs']['create']
|
|
1208
|
+
}): Promise<CollectionTypeInfo['item']>
|
|
672
1209
|
createMany(args: {
|
|
673
|
-
readonly data: readonly
|
|
674
|
-
}): Promise<
|
|
675
|
-
deleteOne(args: UniqueWhereInput<
|
|
1210
|
+
readonly data: readonly CollectionTypeInfo['inputs']['create'][]
|
|
1211
|
+
}): Promise<CollectionTypeInfo['item'][]>
|
|
1212
|
+
deleteOne(args: UniqueWhereInput<CollectionTypeInfo>): Promise<CollectionTypeInfo['item']>
|
|
676
1213
|
deleteMany(args: {
|
|
677
|
-
readonly where: readonly
|
|
678
|
-
}): Promise<
|
|
1214
|
+
readonly where: readonly CollectionTypeInfo['inputs']['uniqueWhere'][]
|
|
1215
|
+
}): Promise<CollectionTypeInfo['item'][]>
|
|
679
1216
|
}
|
|
680
1217
|
|
|
681
|
-
export type NixxieDbAPI<ListsTypeInfo extends Record<string,
|
|
1218
|
+
export type NixxieDbAPI<ListsTypeInfo extends Record<string, BaseCollectionTypeInfo>> = {
|
|
682
1219
|
[Key in keyof ListsTypeInfo]: DbAPI<ListsTypeInfo[Key]>
|
|
683
1220
|
}
|
|
684
1221
|
|