@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
|
@@ -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.js";
|
|
5
5
|
import type { SessionStrategy } from "./session.js";
|
|
6
|
-
import type { BaseNixxieTypeInfo,
|
|
6
|
+
import type { BaseNixxieTypeInfo, BaseCollectionTypeInfo } from "./type-info.js";
|
|
7
7
|
import type { MaybePromise } from "./utils.js";
|
|
8
8
|
export type NixxieEmailRecipient = string | {
|
|
9
9
|
name?: string;
|
|
@@ -84,14 +84,29 @@ export type NixxieEmailService = {
|
|
|
84
84
|
/** Gracefully shut down the service and close transport connections. */
|
|
85
85
|
close(): Promise<void>;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Optional lifecycle hook for runtime services. When a service object exposes `init`,
|
|
89
|
+
* core calls it once with a sudo context after the database connects — this is how
|
|
90
|
+
* database-backed service stores (audit, versioning, workflow, jobs history, webhook
|
|
91
|
+
* subscriptions) get access to `context.prisma` without a circular boot dependency.
|
|
92
|
+
*/
|
|
93
|
+
export type NixxieInitableService = {
|
|
94
|
+
init?(context: NixxieContext): MaybePromise<void>;
|
|
95
|
+
};
|
|
87
96
|
export type NixxieJobDefinition = {
|
|
88
97
|
name: string;
|
|
89
|
-
/**
|
|
90
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Cron expression or interval in milliseconds.
|
|
100
|
+
* Omit when `runAt` is set (one-time job). One of `schedule` or `runAt` is required.
|
|
101
|
+
*/
|
|
102
|
+
schedule?: string | number;
|
|
103
|
+
/** Run once at this time instead of on a schedule. Times in the past run immediately. */
|
|
104
|
+
runAt?: Date;
|
|
91
105
|
/** Handler function invoked on each tick */
|
|
92
106
|
handler: (ctx: {
|
|
93
107
|
jobId: string;
|
|
94
108
|
scheduledAt: Date;
|
|
109
|
+
attempt: number;
|
|
95
110
|
}) => Promise<void> | void;
|
|
96
111
|
/** Immediately run the job once on registration */
|
|
97
112
|
runImmediately?: boolean;
|
|
@@ -99,6 +114,10 @@ export type NixxieJobDefinition = {
|
|
|
99
114
|
enabled?: boolean;
|
|
100
115
|
/** Milliseconds before a running job is considered stuck */
|
|
101
116
|
timeout?: number;
|
|
117
|
+
/** Number of retry attempts after a failed run (0 = no retries) */
|
|
118
|
+
retries?: number;
|
|
119
|
+
/** Base delay in milliseconds between retries (doubles each attempt) */
|
|
120
|
+
retryDelay?: number;
|
|
102
121
|
};
|
|
103
122
|
export type NixxieJobStatus = 'idle' | 'running' | 'error' | 'disabled';
|
|
104
123
|
export type NixxieJobInfo = {
|
|
@@ -109,7 +128,7 @@ export type NixxieJobInfo = {
|
|
|
109
128
|
nextRun?: Date;
|
|
110
129
|
runs: number;
|
|
111
130
|
};
|
|
112
|
-
export type NixxieJobsService = {
|
|
131
|
+
export type NixxieJobsService = NixxieInitableService & {
|
|
113
132
|
/** Register a job definition. Call before start() or at any time for hot-registration. */
|
|
114
133
|
define(job: NixxieJobDefinition): void;
|
|
115
134
|
/** Remove a registered job by name. */
|
|
@@ -188,7 +207,7 @@ export type NixxieAuditRecord = NixxieAuditEntry & {
|
|
|
188
207
|
id: string;
|
|
189
208
|
timestamp: Date;
|
|
190
209
|
};
|
|
191
|
-
export type NixxieAuditService = {
|
|
210
|
+
export type NixxieAuditService = NixxieInitableService & {
|
|
192
211
|
/** Log an audit event. */
|
|
193
212
|
log(entry: NixxieAuditEntry): Promise<NixxieAuditRecord>;
|
|
194
213
|
/** Query the audit log. */
|
|
@@ -228,7 +247,7 @@ export type NixxieWebhookSubscribeOptions = {
|
|
|
228
247
|
/** Max delivery retries (default: 3) */
|
|
229
248
|
retries?: number;
|
|
230
249
|
};
|
|
231
|
-
export type NixxieWebhooksService = {
|
|
250
|
+
export type NixxieWebhooksService = NixxieInitableService & {
|
|
232
251
|
/** Register a webhook endpoint for an event. Returns the subscription ID. */
|
|
233
252
|
subscribe(event: string, url: string, options?: NixxieWebhookSubscribeOptions): Promise<NixxieWebhookSubscription>;
|
|
234
253
|
/** Remove a subscription by ID. */
|
|
@@ -470,9 +489,444 @@ export type NixxieAiService = {
|
|
|
470
489
|
/** Produce embedding vectors for many strings in one call. */
|
|
471
490
|
embedMany(texts: string[]): Promise<number[][]>;
|
|
472
491
|
};
|
|
492
|
+
/** A source document stored in the knowledge base that the assistant is trained on. */
|
|
493
|
+
export type NixxieRagDocumentInput = {
|
|
494
|
+
/** Short title/label for the document. */
|
|
495
|
+
title?: string;
|
|
496
|
+
/** The body the assistant learns from. */
|
|
497
|
+
content: string;
|
|
498
|
+
/** Origin of the content (URL, filename, list:itemId, …) — shown in citations. */
|
|
499
|
+
source?: string;
|
|
500
|
+
/** Free-form tags used to scope retrieval (e.g. ['billing', 'public']). */
|
|
501
|
+
tags?: string[];
|
|
502
|
+
/** Arbitrary structured metadata returned alongside citations. */
|
|
503
|
+
metadata?: Record<string, unknown>;
|
|
504
|
+
};
|
|
505
|
+
export type NixxieRagDocument = NixxieRagDocumentInput & {
|
|
506
|
+
id: string;
|
|
507
|
+
/** Indexing lifecycle of the document's chunks. */
|
|
508
|
+
status: 'pending' | 'indexing' | 'indexed' | 'error' | 'disabled';
|
|
509
|
+
/** Number of chunks currently indexed for this document. */
|
|
510
|
+
chunkCount: number;
|
|
511
|
+
/** Last error encountered while indexing, if any. */
|
|
512
|
+
error?: string;
|
|
513
|
+
createdAt: Date;
|
|
514
|
+
updatedAt: Date;
|
|
515
|
+
indexedAt?: Date;
|
|
516
|
+
};
|
|
517
|
+
export type NixxieRagDocumentQuery = {
|
|
518
|
+
take?: number;
|
|
519
|
+
skip?: number;
|
|
520
|
+
/** Only return documents matching ALL of these tags. */
|
|
521
|
+
tags?: string[];
|
|
522
|
+
status?: NixxieRagDocument['status'];
|
|
523
|
+
/** Substring match against title/content/source. */
|
|
524
|
+
search?: string;
|
|
525
|
+
};
|
|
526
|
+
/** A retrieved chunk with its similarity score, used to ground answers. */
|
|
527
|
+
export type NixxieRagChunk = {
|
|
528
|
+
id: string;
|
|
529
|
+
documentId: string;
|
|
530
|
+
title?: string;
|
|
531
|
+
source?: string;
|
|
532
|
+
/** The chunk text. */
|
|
533
|
+
content: string;
|
|
534
|
+
/** Cosine similarity to the query in [0, 1] (higher is more relevant). */
|
|
535
|
+
score: number;
|
|
536
|
+
tags?: string[];
|
|
537
|
+
metadata?: Record<string, unknown>;
|
|
538
|
+
};
|
|
539
|
+
export type NixxieRagRetrieveOptions = {
|
|
540
|
+
/** Number of chunks to return. Defaults to the configured `retrieval.topK`. */
|
|
541
|
+
topK?: number;
|
|
542
|
+
/** Drop chunks scoring below this threshold. Defaults to `retrieval.minScore`. */
|
|
543
|
+
minScore?: number;
|
|
544
|
+
/** Restrict retrieval to documents carrying ALL of these tags. */
|
|
545
|
+
tags?: string[];
|
|
546
|
+
};
|
|
547
|
+
/** A single source the answer was grounded on. */
|
|
548
|
+
export type NixxieRagCitation = {
|
|
549
|
+
documentId: string;
|
|
550
|
+
chunkId: string;
|
|
551
|
+
title?: string;
|
|
552
|
+
source?: string;
|
|
553
|
+
score: number;
|
|
554
|
+
/** Short excerpt of the cited chunk. */
|
|
555
|
+
snippet: string;
|
|
556
|
+
};
|
|
557
|
+
export type NixxieRagAskOptions = NixxieRagRetrieveOptions & {
|
|
558
|
+
/** Override the generation model for this call. */
|
|
559
|
+
model?: string;
|
|
560
|
+
/** Override sampling temperature for this call. */
|
|
561
|
+
temperature?: number;
|
|
562
|
+
/** Override max output tokens for this call. */
|
|
563
|
+
maxTokens?: number;
|
|
564
|
+
/** Append an extra instruction to the system prompt for this call. */
|
|
565
|
+
systemSuffix?: string;
|
|
566
|
+
/** Pre-retrieved chunks to use instead of running retrieval (advanced). */
|
|
567
|
+
context?: NixxieRagChunk[];
|
|
568
|
+
/** Per-call override of the hallucination guard. */
|
|
569
|
+
guard?: boolean;
|
|
570
|
+
};
|
|
571
|
+
/** The grounded answer returned by `ask`/`chat`. */
|
|
572
|
+
export type NixxieRagAnswer = {
|
|
573
|
+
/** The assistant's answer text. */
|
|
574
|
+
text: string;
|
|
575
|
+
/** The sources the answer was grounded on. */
|
|
576
|
+
sources: NixxieRagCitation[];
|
|
577
|
+
/** Whether the answer passed the grounding/hallucination check. */
|
|
578
|
+
grounded: boolean;
|
|
579
|
+
/** True when the assistant refused because no relevant context was found. */
|
|
580
|
+
refused: boolean;
|
|
581
|
+
model: string;
|
|
582
|
+
usage?: {
|
|
583
|
+
inputTokens?: number;
|
|
584
|
+
outputTokens?: number;
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
/** A streamed token or lifecycle event from `stream`. */
|
|
588
|
+
export type NixxieRagStreamEvent = {
|
|
589
|
+
type: 'sources';
|
|
590
|
+
sources: NixxieRagCitation[];
|
|
591
|
+
} | {
|
|
592
|
+
type: 'token';
|
|
593
|
+
token: string;
|
|
594
|
+
} | {
|
|
595
|
+
type: 'done';
|
|
596
|
+
answer: NixxieRagAnswer;
|
|
597
|
+
} | {
|
|
598
|
+
type: 'error';
|
|
599
|
+
error: string;
|
|
600
|
+
};
|
|
601
|
+
export type NixxieRagIndexStats = {
|
|
602
|
+
/** Documents processed this run. */
|
|
603
|
+
documents: number;
|
|
604
|
+
/** Chunks (re)embedded this run. */
|
|
605
|
+
chunks: number;
|
|
606
|
+
/** Documents that failed to index. */
|
|
607
|
+
errors: number;
|
|
608
|
+
/** Wall-clock duration in milliseconds. */
|
|
609
|
+
durationMs: number;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* A custom, RAG-trained assistant backed by a knowledge-base collection.
|
|
613
|
+
* Implemented by @nixxie-cms/ai-rag. Add/remove/retrieve KB content, (re)index it
|
|
614
|
+
* into embeddings, and ask grounded, citation-backed questions with hallucination guarding.
|
|
615
|
+
*/
|
|
616
|
+
export type NixxieAiRagService = NixxieInitableService & {
|
|
617
|
+
/** Add a document to the knowledge base (queued for indexing). */
|
|
618
|
+
addDocument(doc: NixxieRagDocumentInput): Promise<NixxieRagDocument>;
|
|
619
|
+
/** Add many documents in one call. */
|
|
620
|
+
addDocuments(docs: NixxieRagDocumentInput[]): Promise<NixxieRagDocument[]>;
|
|
621
|
+
/** Fetch a single document by id. */
|
|
622
|
+
getDocument(id: string): Promise<NixxieRagDocument | undefined>;
|
|
623
|
+
/** List documents in the knowledge base. */
|
|
624
|
+
listDocuments(query?: NixxieRagDocumentQuery): Promise<NixxieRagDocument[]>;
|
|
625
|
+
/** Patch a document's content/metadata (re-queues it for indexing). */
|
|
626
|
+
updateDocument(id: string, patch: Partial<NixxieRagDocumentInput>): Promise<NixxieRagDocument>;
|
|
627
|
+
/** Remove a document and all of its indexed chunks. */
|
|
628
|
+
removeDocument(id: string): Promise<void>;
|
|
629
|
+
/** (Re)index a single document now. */
|
|
630
|
+
index(documentId: string): Promise<void>;
|
|
631
|
+
/** (Re)index documents. Pass `{ force: true }` to rebuild already-indexed docs. */
|
|
632
|
+
reindex(options?: {
|
|
633
|
+
force?: boolean;
|
|
634
|
+
tags?: string[];
|
|
635
|
+
}): Promise<NixxieRagIndexStats>;
|
|
636
|
+
/** Index every document still pending/changed. */
|
|
637
|
+
indexPending(): Promise<NixxieRagIndexStats>;
|
|
638
|
+
/** Return the most relevant chunks for a query (no generation). */
|
|
639
|
+
retrieve(query: string, options?: NixxieRagRetrieveOptions): Promise<NixxieRagChunk[]>;
|
|
640
|
+
/** Ask a one-shot question and get a grounded, cited answer. */
|
|
641
|
+
ask(question: string, options?: NixxieRagAskOptions): Promise<NixxieRagAnswer>;
|
|
642
|
+
/** Multi-turn chat; the latest user turn drives retrieval. */
|
|
643
|
+
chat(messages: NixxieAiMessage[], options?: NixxieRagAskOptions): Promise<NixxieRagAnswer>;
|
|
644
|
+
/** Streamed variant of `chat`, yielding sources, then tokens, then the final answer. */
|
|
645
|
+
stream(messages: NixxieAiMessage[], options?: NixxieRagAskOptions): AsyncIterable<NixxieRagStreamEvent>;
|
|
646
|
+
/** Gracefully stop background indexing and flush pending work. */
|
|
647
|
+
close(): Promise<void>;
|
|
648
|
+
};
|
|
649
|
+
export type NixxieVersionEntry = {
|
|
650
|
+
/** Collection name (e.g. 'Post') */
|
|
651
|
+
resource: string;
|
|
652
|
+
/** ID of the item this snapshot belongs to */
|
|
653
|
+
resourceId: string;
|
|
654
|
+
/** Snapshot of the item's data at this point in time */
|
|
655
|
+
data: Record<string, unknown>;
|
|
656
|
+
/** Optional human label (e.g. 'before publish') */
|
|
657
|
+
label?: string;
|
|
658
|
+
/** Who created the snapshot */
|
|
659
|
+
actor?: {
|
|
660
|
+
id?: string;
|
|
661
|
+
label?: string;
|
|
662
|
+
};
|
|
663
|
+
/** Arbitrary extra context */
|
|
664
|
+
meta?: Record<string, unknown>;
|
|
665
|
+
};
|
|
666
|
+
export type NixxieVersionRecord = NixxieVersionEntry & {
|
|
667
|
+
id: string;
|
|
668
|
+
/** Monotonically increasing version number, scoped to resource + resourceId (starts at 1). */
|
|
669
|
+
version: number;
|
|
670
|
+
createdAt: Date;
|
|
671
|
+
};
|
|
672
|
+
export type NixxieVersionQuery = {
|
|
673
|
+
take?: number;
|
|
674
|
+
skip?: number;
|
|
675
|
+
};
|
|
676
|
+
export type NixxieVersionDiff = {
|
|
677
|
+
fromVersion: number;
|
|
678
|
+
toVersion: number;
|
|
679
|
+
/** Per-field differences between the two versions. */
|
|
680
|
+
changes: Record<string, {
|
|
681
|
+
from: unknown;
|
|
682
|
+
to: unknown;
|
|
683
|
+
}>;
|
|
684
|
+
};
|
|
685
|
+
/** Content revision history. Implemented by @nixxie-cms/versioning. */
|
|
686
|
+
export type NixxieVersioningService = NixxieInitableService & {
|
|
687
|
+
/** Record a new snapshot of an item's data. Returns the created version record. */
|
|
688
|
+
snapshot(entry: NixxieVersionEntry): Promise<NixxieVersionRecord>;
|
|
689
|
+
/** List versions for an item, newest first. */
|
|
690
|
+
list(resource: string, resourceId: string, query?: NixxieVersionQuery): Promise<NixxieVersionRecord[]>;
|
|
691
|
+
/** Fetch a single version by its ID. */
|
|
692
|
+
get(versionId: string): Promise<NixxieVersionRecord | undefined>;
|
|
693
|
+
/** Get the most recent version for an item. */
|
|
694
|
+
latest(resource: string, resourceId: string): Promise<NixxieVersionRecord | undefined>;
|
|
695
|
+
/**
|
|
696
|
+
* Restore an older version: copies its data into a brand-new snapshot
|
|
697
|
+
* (so history is never lost) and returns that new record. The caller is
|
|
698
|
+
* responsible for writing `record.data` back to the live item.
|
|
699
|
+
*/
|
|
700
|
+
restore(versionId: string): Promise<NixxieVersionRecord>;
|
|
701
|
+
/** Compute a field-level diff between two versions of the same item. */
|
|
702
|
+
diff(fromVersionId: string, toVersionId: string): Promise<NixxieVersionDiff>;
|
|
703
|
+
/** Keep only the newest `keep` versions of an item, deleting the rest. Returns the number deleted. */
|
|
704
|
+
prune(resource: string, resourceId: string, keep: number): Promise<number>;
|
|
705
|
+
/** Gracefully shut down (flush pending writes). */
|
|
706
|
+
close(): Promise<void>;
|
|
707
|
+
};
|
|
708
|
+
export type NixxieWorkflowState = string;
|
|
709
|
+
export type NixxieWorkflowTransition = {
|
|
710
|
+
/** The state(s) this transition can start from. */
|
|
711
|
+
from: NixxieWorkflowState | NixxieWorkflowState[];
|
|
712
|
+
/** The state this transition moves to. */
|
|
713
|
+
to: NixxieWorkflowState;
|
|
714
|
+
/** Optional action name (e.g. 'submit', 'approve', 'reject'). */
|
|
715
|
+
name?: string;
|
|
716
|
+
/**
|
|
717
|
+
* Optional guard evaluated before the transition is recorded.
|
|
718
|
+
* Return `false` to block it, or a string to block it with a custom error message.
|
|
719
|
+
*/
|
|
720
|
+
when?: (args: {
|
|
721
|
+
resource: string;
|
|
722
|
+
resourceId: string;
|
|
723
|
+
from: NixxieWorkflowState;
|
|
724
|
+
to: NixxieWorkflowState;
|
|
725
|
+
actor?: NixxieWorkflowActor;
|
|
726
|
+
meta?: Record<string, unknown>;
|
|
727
|
+
}) => MaybePromise<boolean | string>;
|
|
728
|
+
};
|
|
729
|
+
export type NixxieWorkflowDefinition = {
|
|
730
|
+
name: string;
|
|
731
|
+
/** State assigned to items that have no recorded state yet. */
|
|
732
|
+
initial: NixxieWorkflowState;
|
|
733
|
+
/** All valid states. */
|
|
734
|
+
states: NixxieWorkflowState[];
|
|
735
|
+
/** Allowed transitions between states. */
|
|
736
|
+
transitions: NixxieWorkflowTransition[];
|
|
737
|
+
};
|
|
738
|
+
export type NixxieWorkflowActor = {
|
|
739
|
+
id?: string;
|
|
740
|
+
label?: string;
|
|
741
|
+
};
|
|
742
|
+
export type NixxieWorkflowTransitionInput = {
|
|
743
|
+
actor?: NixxieWorkflowActor;
|
|
744
|
+
meta?: Record<string, unknown>;
|
|
745
|
+
};
|
|
746
|
+
export type NixxieWorkflowHistoryEntry = {
|
|
747
|
+
id: string;
|
|
748
|
+
resource: string;
|
|
749
|
+
resourceId: string;
|
|
750
|
+
/** Previous state, or null for the first transition. */
|
|
751
|
+
from: NixxieWorkflowState | null;
|
|
752
|
+
to: NixxieWorkflowState;
|
|
753
|
+
actor?: NixxieWorkflowActor;
|
|
754
|
+
meta?: Record<string, unknown>;
|
|
755
|
+
at: Date;
|
|
756
|
+
};
|
|
757
|
+
/** Editorial state machine (draft → review → published, etc). Implemented by @nixxie-cms/workflow. */
|
|
758
|
+
export type NixxieWorkflowService = NixxieInitableService & {
|
|
759
|
+
/** The workflow definition this service enforces. */
|
|
760
|
+
definition(): NixxieWorkflowDefinition;
|
|
761
|
+
/** Current state of an item (returns the initial state if none recorded). */
|
|
762
|
+
getState(resource: string, resourceId: string): Promise<NixxieWorkflowState>;
|
|
763
|
+
/**
|
|
764
|
+
* Move an item to `to`, enforcing that a transition from its current state is allowed.
|
|
765
|
+
* Throws if the transition is not permitted.
|
|
766
|
+
*/
|
|
767
|
+
transition(resource: string, resourceId: string, to: NixxieWorkflowState, input?: NixxieWorkflowTransitionInput): Promise<NixxieWorkflowHistoryEntry>;
|
|
768
|
+
/** Force a state without checking transition rules (e.g. migrations / admin override). */
|
|
769
|
+
setState(resource: string, resourceId: string, to: NixxieWorkflowState, input?: NixxieWorkflowTransitionInput): Promise<NixxieWorkflowHistoryEntry>;
|
|
770
|
+
/** Whether a direct transition from `from` to `to` is allowed. */
|
|
771
|
+
can(from: NixxieWorkflowState, to: NixxieWorkflowState): boolean;
|
|
772
|
+
/** States reachable from `from` in a single transition. */
|
|
773
|
+
available(from: NixxieWorkflowState): NixxieWorkflowState[];
|
|
774
|
+
/** Transition history for an item, newest first. */
|
|
775
|
+
history(resource: string, resourceId: string, take?: number): Promise<NixxieWorkflowHistoryEntry[]>;
|
|
776
|
+
/** Gracefully shut down (flush pending writes). */
|
|
777
|
+
close(): Promise<void>;
|
|
778
|
+
};
|
|
779
|
+
export type NixxieApiKeyIssueOptions = {
|
|
780
|
+
/** Human-friendly name for the key. */
|
|
781
|
+
name: string;
|
|
782
|
+
/** Permission scopes granted to the key. */
|
|
783
|
+
scopes?: string[];
|
|
784
|
+
/** Optional expiry. Omit for a non-expiring key. */
|
|
785
|
+
expiresAt?: Date;
|
|
786
|
+
/** Arbitrary extra context. */
|
|
787
|
+
meta?: Record<string, unknown>;
|
|
788
|
+
};
|
|
789
|
+
export type NixxieApiKeyRecord = {
|
|
790
|
+
id: string;
|
|
791
|
+
name: string;
|
|
792
|
+
scopes: string[];
|
|
793
|
+
/** Short, non-secret prefix used to identify the key in UIs and logs. */
|
|
794
|
+
prefix: string;
|
|
795
|
+
createdAt: Date;
|
|
796
|
+
expiresAt?: Date;
|
|
797
|
+
lastUsedAt?: Date;
|
|
798
|
+
revokedAt?: Date;
|
|
799
|
+
meta?: Record<string, unknown>;
|
|
800
|
+
};
|
|
801
|
+
export type NixxieApiKeyIssued = {
|
|
802
|
+
record: NixxieApiKeyRecord;
|
|
803
|
+
/** The full plaintext key. Shown ONCE at issue time — only its hash is stored. */
|
|
804
|
+
key: string;
|
|
805
|
+
};
|
|
806
|
+
export type NixxieApiKeyVerifyResult = {
|
|
807
|
+
valid: true;
|
|
808
|
+
record: NixxieApiKeyRecord;
|
|
809
|
+
} | {
|
|
810
|
+
valid: false;
|
|
811
|
+
reason: 'not-found' | 'revoked' | 'expired' | 'missing-scope';
|
|
812
|
+
};
|
|
813
|
+
/** Scoped, revocable machine-to-machine access tokens. Implemented by @nixxie-cms/api-keys. */
|
|
814
|
+
export type NixxieApiKeysService = {
|
|
815
|
+
/** Issue a new key. The plaintext value is returned once and never stored. */
|
|
816
|
+
issue(options: NixxieApiKeyIssueOptions): Promise<NixxieApiKeyIssued>;
|
|
817
|
+
/** Verify a plaintext key, checking revocation and expiry. Updates `lastUsedAt` on success. */
|
|
818
|
+
verify(key: string): Promise<NixxieApiKeyVerifyResult>;
|
|
819
|
+
/** Verify a key and require that it holds every one of `scopes`. */
|
|
820
|
+
authorize(key: string, scopes: string[]): Promise<NixxieApiKeyVerifyResult>;
|
|
821
|
+
/** Revoke a key by ID. */
|
|
822
|
+
revoke(id: string): Promise<void>;
|
|
823
|
+
/** List all key records (never includes the plaintext key). */
|
|
824
|
+
list(): Promise<NixxieApiKeyRecord[]>;
|
|
825
|
+
/** Fetch a single key record by ID. */
|
|
826
|
+
get(id: string): Promise<NixxieApiKeyRecord | undefined>;
|
|
827
|
+
/** Gracefully shut down (flush pending writes). */
|
|
828
|
+
close(): Promise<void>;
|
|
829
|
+
};
|
|
830
|
+
export type NixxieLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
831
|
+
export type NixxieLogFields = Record<string, unknown>;
|
|
832
|
+
export type NixxieLogRecord = {
|
|
833
|
+
level: NixxieLogLevel;
|
|
834
|
+
message: string;
|
|
835
|
+
/** ISO-8601 timestamp. */
|
|
836
|
+
time: string;
|
|
837
|
+
/** Bound + per-call structured fields merged together. */
|
|
838
|
+
fields: NixxieLogFields;
|
|
839
|
+
};
|
|
840
|
+
/** Receives every emitted log record (e.g. console JSON, a file, an external sink). */
|
|
841
|
+
export type NixxieLogSink = (record: NixxieLogRecord) => void;
|
|
842
|
+
/** Structured, level-aware logging with bound child loggers. Implemented by @nixxie-cms/logger. */
|
|
843
|
+
export type NixxieLoggerService = {
|
|
844
|
+
debug(message: string, fields?: NixxieLogFields): void;
|
|
845
|
+
info(message: string, fields?: NixxieLogFields): void;
|
|
846
|
+
warn(message: string, fields?: NixxieLogFields): void;
|
|
847
|
+
error(message: string, fields?: NixxieLogFields): void;
|
|
848
|
+
fatal(message: string, fields?: NixxieLogFields): void;
|
|
849
|
+
/** Emit at an explicit level. */
|
|
850
|
+
log(level: NixxieLogLevel, message: string, fields?: NixxieLogFields): void;
|
|
851
|
+
/**
|
|
852
|
+
* Create a child logger that always includes the given bound fields
|
|
853
|
+
* (e.g. `{ requestId }`). Children inherit the parent's level and sinks.
|
|
854
|
+
*/
|
|
855
|
+
child(bindings: NixxieLogFields): NixxieLoggerService;
|
|
856
|
+
/** The current minimum level; records below it are dropped. */
|
|
857
|
+
readonly level: NixxieLogLevel;
|
|
858
|
+
};
|
|
859
|
+
export type NixxieBackupFormat = 'json' | 'ndjson';
|
|
860
|
+
export type NixxieBackupCollection = {
|
|
861
|
+
collection: string;
|
|
862
|
+
items: Record<string, unknown>[];
|
|
863
|
+
};
|
|
864
|
+
export type NixxieBackupArchive = {
|
|
865
|
+
version: 1;
|
|
866
|
+
createdAt: string;
|
|
867
|
+
collections: NixxieBackupCollection[];
|
|
868
|
+
};
|
|
869
|
+
export type NixxieBackupExportOptions = {
|
|
870
|
+
/** Collections to include. Omit to export every collection the data source exposes. */
|
|
871
|
+
collections?: string[];
|
|
872
|
+
};
|
|
873
|
+
export type NixxieBackupImportMode = 'create' | 'upsert';
|
|
874
|
+
export type NixxieBackupImportOptions = {
|
|
875
|
+
/** 'create' (default) always inserts; 'upsert' updates existing items by id. */
|
|
876
|
+
mode?: NixxieBackupImportMode;
|
|
877
|
+
/** Restrict the import to these collections. */
|
|
878
|
+
collections?: string[];
|
|
879
|
+
/** Continue past individual item failures instead of throwing. */
|
|
880
|
+
continueOnError?: boolean;
|
|
881
|
+
};
|
|
882
|
+
export type NixxieBackupImportResult = {
|
|
883
|
+
created: number;
|
|
884
|
+
updated: number;
|
|
885
|
+
skipped: number;
|
|
886
|
+
errors: {
|
|
887
|
+
collection: string;
|
|
888
|
+
id?: string;
|
|
889
|
+
error: string;
|
|
890
|
+
}[];
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* Abstraction over the live data store, supplied by the host app (typically built
|
|
894
|
+
* from a NixxieContext). Lets the backup service read and write content without
|
|
895
|
+
* being coupled to Prisma or the GraphQL layer.
|
|
896
|
+
*/
|
|
897
|
+
export type NixxieBackupDataSource = {
|
|
898
|
+
/** Names of the collections available for export/import. */
|
|
899
|
+
collections(): string[] | Promise<string[]>;
|
|
900
|
+
/** Read every item of a collection. */
|
|
901
|
+
read(collection: string): Promise<Record<string, unknown>[]>;
|
|
902
|
+
/** Write items into a collection, honouring the requested mode. */
|
|
903
|
+
write(collection: string, items: Record<string, unknown>[], mode: NixxieBackupImportMode): Promise<Omit<NixxieBackupImportResult, 'errors'> & {
|
|
904
|
+
errors: {
|
|
905
|
+
id?: string;
|
|
906
|
+
error: string;
|
|
907
|
+
}[];
|
|
908
|
+
}>;
|
|
909
|
+
/** Count items in a collection (used by `seed` to detect non-empty targets). */
|
|
910
|
+
count(collection: string): Promise<number>;
|
|
911
|
+
};
|
|
912
|
+
/** Content export / import / seed. Implemented by @nixxie-cms/backup. */
|
|
913
|
+
export type NixxieBackupService = {
|
|
914
|
+
/** Read the data source into an in-memory archive. */
|
|
915
|
+
export(options?: NixxieBackupExportOptions): Promise<NixxieBackupArchive>;
|
|
916
|
+
/** Serialize an archive to a string in the given format (default 'json'). */
|
|
917
|
+
serialize(archive: NixxieBackupArchive, format?: NixxieBackupFormat): string;
|
|
918
|
+
/** Parse a serialized archive back into structured form. */
|
|
919
|
+
parse(text: string, format?: NixxieBackupFormat): NixxieBackupArchive;
|
|
920
|
+
/** Write an archive into the data source. */
|
|
921
|
+
import(archive: NixxieBackupArchive, options?: NixxieBackupImportOptions): Promise<NixxieBackupImportResult>;
|
|
922
|
+
/** Import an archive, but only into collections that are currently empty. */
|
|
923
|
+
seed(archive: NixxieBackupArchive): Promise<NixxieBackupImportResult>;
|
|
924
|
+
/** Gracefully shut down. */
|
|
925
|
+
close(): Promise<void>;
|
|
926
|
+
};
|
|
473
927
|
export type NixxieContext<TypeInfo extends BaseNixxieTypeInfo = BaseNixxieTypeInfo> = {
|
|
474
928
|
db: NixxieDbAPI<TypeInfo['lists']>;
|
|
475
|
-
query:
|
|
929
|
+
query: NixxieCollectionsAPI<TypeInfo['lists']>;
|
|
476
930
|
graphql: NixxieGraphQLAPI;
|
|
477
931
|
prisma: TypeInfo['prisma'];
|
|
478
932
|
/** Runtime services configured in nixxie.ts — available everywhere context is available */
|
|
@@ -488,6 +942,12 @@ export type NixxieContext<TypeInfo extends BaseNixxieTypeInfo = BaseNixxieTypeIn
|
|
|
488
942
|
search: NixxieSearchService | null;
|
|
489
943
|
notifications: NixxieNotificationsService | null;
|
|
490
944
|
ai: NixxieAiService | null;
|
|
945
|
+
aiRag: NixxieAiRagService | null;
|
|
946
|
+
versioning: NixxieVersioningService | null;
|
|
947
|
+
workflow: NixxieWorkflowService | null;
|
|
948
|
+
apiKeys: NixxieApiKeysService | null;
|
|
949
|
+
logger: NixxieLoggerService | null;
|
|
950
|
+
backup: NixxieBackupService | null;
|
|
491
951
|
};
|
|
492
952
|
transaction: <T>(f: (context: NixxieContext<TypeInfo>) => MaybePromise<T>, options?: {
|
|
493
953
|
maxWait?: number;
|
|
@@ -516,44 +976,44 @@ export type NixxieContext<TypeInfo extends BaseNixxieTypeInfo = BaseNixxieTypeIn
|
|
|
516
976
|
};
|
|
517
977
|
};
|
|
518
978
|
};
|
|
519
|
-
type UniqueWhereInput<
|
|
520
|
-
readonly where:
|
|
979
|
+
type UniqueWhereInput<CollectionTypeInfo extends BaseCollectionTypeInfo> = false extends CollectionTypeInfo['isSingleton'] ? {
|
|
980
|
+
readonly where: CollectionTypeInfo['inputs']['uniqueWhere'];
|
|
521
981
|
} : {
|
|
522
|
-
readonly where?:
|
|
982
|
+
readonly where?: CollectionTypeInfo['inputs']['uniqueWhere'];
|
|
523
983
|
};
|
|
524
|
-
type
|
|
984
|
+
type CollectionAPI<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
525
985
|
findMany(args?: {
|
|
526
|
-
readonly where?:
|
|
986
|
+
readonly where?: CollectionTypeInfo['inputs']['where'];
|
|
527
987
|
readonly take?: number;
|
|
528
988
|
readonly skip?: number;
|
|
529
|
-
readonly orderBy?:
|
|
530
|
-
readonly cursor?:
|
|
989
|
+
readonly orderBy?: CollectionTypeInfo['inputs']['orderBy'] | readonly CollectionTypeInfo['inputs']['orderBy'][];
|
|
990
|
+
readonly cursor?: CollectionTypeInfo['inputs']['uniqueWhere'];
|
|
531
991
|
} & ResolveFields): Promise<readonly Record<string, any>[]>;
|
|
532
|
-
findOne(args: UniqueWhereInput<
|
|
992
|
+
findOne(args: UniqueWhereInput<CollectionTypeInfo> & ResolveFields): Promise<Record<string, any>>;
|
|
533
993
|
count(args?: {
|
|
534
|
-
readonly where?:
|
|
994
|
+
readonly where?: CollectionTypeInfo['inputs']['where'];
|
|
535
995
|
}): Promise<number>;
|
|
536
|
-
updateOne(args: UniqueWhereInput<
|
|
537
|
-
readonly data:
|
|
996
|
+
updateOne(args: UniqueWhereInput<CollectionTypeInfo> & {
|
|
997
|
+
readonly data: CollectionTypeInfo['inputs']['update'];
|
|
538
998
|
} & ResolveFields): Promise<Record<string, any>>;
|
|
539
999
|
updateMany(args: {
|
|
540
|
-
readonly data: readonly (UniqueWhereInput<
|
|
541
|
-
readonly data:
|
|
1000
|
+
readonly data: readonly (UniqueWhereInput<CollectionTypeInfo> & {
|
|
1001
|
+
readonly data: CollectionTypeInfo['inputs']['update'];
|
|
542
1002
|
})[];
|
|
543
1003
|
} & ResolveFields): Promise<Record<string, any>[]>;
|
|
544
1004
|
createOne(args: {
|
|
545
|
-
readonly data:
|
|
1005
|
+
readonly data: CollectionTypeInfo['inputs']['create'];
|
|
546
1006
|
} & ResolveFields): Promise<Record<string, any>>;
|
|
547
1007
|
createMany(args: {
|
|
548
|
-
readonly data: readonly
|
|
1008
|
+
readonly data: readonly CollectionTypeInfo['inputs']['create'][];
|
|
549
1009
|
} & ResolveFields): Promise<Record<string, any>[]>;
|
|
550
|
-
deleteOne(args: UniqueWhereInput<
|
|
1010
|
+
deleteOne(args: UniqueWhereInput<CollectionTypeInfo> & ResolveFields): Promise<Record<string, any> | null>;
|
|
551
1011
|
deleteMany(args: {
|
|
552
|
-
readonly where: readonly
|
|
1012
|
+
readonly where: readonly CollectionTypeInfo['inputs']['uniqueWhere'][];
|
|
553
1013
|
} & ResolveFields): Promise<Record<string, any>[]>;
|
|
554
1014
|
};
|
|
555
|
-
export type
|
|
556
|
-
[Key in keyof ListsTypeInfo]:
|
|
1015
|
+
export type NixxieCollectionsAPI<ListsTypeInfo extends Record<string, BaseCollectionTypeInfo>> = {
|
|
1016
|
+
[Key in keyof ListsTypeInfo]: CollectionAPI<ListsTypeInfo[Key]>;
|
|
557
1017
|
};
|
|
558
1018
|
type ResolveFields = {
|
|
559
1019
|
/**
|
|
@@ -561,38 +1021,38 @@ type ResolveFields = {
|
|
|
561
1021
|
*/
|
|
562
1022
|
readonly query?: string;
|
|
563
1023
|
};
|
|
564
|
-
type DbAPI<
|
|
1024
|
+
type DbAPI<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
565
1025
|
findMany(args?: {
|
|
566
|
-
readonly where?:
|
|
1026
|
+
readonly where?: CollectionTypeInfo['inputs']['where'];
|
|
567
1027
|
readonly take?: number;
|
|
568
1028
|
readonly skip?: number;
|
|
569
|
-
readonly orderBy?:
|
|
570
|
-
readonly cursor?:
|
|
571
|
-
}): Promise<readonly
|
|
572
|
-
findOne(args: UniqueWhereInput<
|
|
1029
|
+
readonly orderBy?: CollectionTypeInfo['inputs']['orderBy'] | readonly CollectionTypeInfo['inputs']['orderBy'][];
|
|
1030
|
+
readonly cursor?: CollectionTypeInfo['inputs']['uniqueWhere'];
|
|
1031
|
+
}): Promise<readonly CollectionTypeInfo['item'][]>;
|
|
1032
|
+
findOne(args: UniqueWhereInput<CollectionTypeInfo>): Promise<CollectionTypeInfo['item'] | null>;
|
|
573
1033
|
count(args?: {
|
|
574
|
-
readonly where?:
|
|
1034
|
+
readonly where?: CollectionTypeInfo['inputs']['where'];
|
|
575
1035
|
}): Promise<number>;
|
|
576
|
-
updateOne(args: UniqueWhereInput<
|
|
577
|
-
readonly data:
|
|
578
|
-
}): Promise<
|
|
1036
|
+
updateOne(args: UniqueWhereInput<CollectionTypeInfo> & {
|
|
1037
|
+
readonly data: CollectionTypeInfo['inputs']['update'];
|
|
1038
|
+
}): Promise<CollectionTypeInfo['item']>;
|
|
579
1039
|
updateMany(args: {
|
|
580
|
-
readonly data: readonly (UniqueWhereInput<
|
|
581
|
-
readonly data:
|
|
1040
|
+
readonly data: readonly (UniqueWhereInput<CollectionTypeInfo> & {
|
|
1041
|
+
readonly data: CollectionTypeInfo['inputs']['update'];
|
|
582
1042
|
})[];
|
|
583
|
-
}): Promise<
|
|
1043
|
+
}): Promise<CollectionTypeInfo['item'][]>;
|
|
584
1044
|
createOne(args: {
|
|
585
|
-
readonly data:
|
|
586
|
-
}): Promise<
|
|
1045
|
+
readonly data: CollectionTypeInfo['inputs']['create'];
|
|
1046
|
+
}): Promise<CollectionTypeInfo['item']>;
|
|
587
1047
|
createMany(args: {
|
|
588
|
-
readonly data: readonly
|
|
589
|
-
}): Promise<
|
|
590
|
-
deleteOne(args: UniqueWhereInput<
|
|
1048
|
+
readonly data: readonly CollectionTypeInfo['inputs']['create'][];
|
|
1049
|
+
}): Promise<CollectionTypeInfo['item'][]>;
|
|
1050
|
+
deleteOne(args: UniqueWhereInput<CollectionTypeInfo>): Promise<CollectionTypeInfo['item']>;
|
|
591
1051
|
deleteMany(args: {
|
|
592
|
-
readonly where: readonly
|
|
593
|
-
}): Promise<
|
|
1052
|
+
readonly where: readonly CollectionTypeInfo['inputs']['uniqueWhere'][];
|
|
1053
|
+
}): Promise<CollectionTypeInfo['item'][]>;
|
|
594
1054
|
};
|
|
595
|
-
export type NixxieDbAPI<ListsTypeInfo extends Record<string,
|
|
1055
|
+
export type NixxieDbAPI<ListsTypeInfo extends Record<string, BaseCollectionTypeInfo>> = {
|
|
596
1056
|
[Key in keyof ListsTypeInfo]: DbAPI<ListsTypeInfo[Key]>;
|
|
597
1057
|
};
|
|
598
1058
|
export type NixxieGraphQLAPI = {
|