@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.
Files changed (203) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CHANGES-1.1.md +134 -0
  3. package/context/dist/nixxie-cms-core-context.cjs.js +4 -3
  4. package/context/dist/nixxie-cms-core-context.esm.js +3 -2
  5. package/dist/declarations/src/access.d.ts +2 -2
  6. package/dist/declarations/src/access.d.ts.map +1 -1
  7. package/dist/declarations/src/admin-ui/components/Navigation.d.ts +2 -2
  8. package/dist/declarations/src/admin-ui/components/Navigation.d.ts.map +1 -1
  9. package/dist/declarations/src/admin-ui/context.d.ts +6 -6
  10. package/dist/declarations/src/admin-ui/context.d.ts.map +1 -1
  11. package/dist/declarations/src/admin-ui/utils/Fields.d.ts +3 -3
  12. package/dist/declarations/src/admin-ui/utils/Fields.d.ts.map +1 -1
  13. package/dist/declarations/src/admin-ui/utils/filters.d.ts +5 -5
  14. package/dist/declarations/src/admin-ui/utils/filters.d.ts.map +1 -1
  15. package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts +3 -3
  16. package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts.map +1 -1
  17. package/dist/declarations/src/admin-ui/utils/utils.d.ts +2 -2
  18. package/dist/declarations/src/admin-ui/utils/utils.d.ts.map +1 -1
  19. package/dist/declarations/src/context.d.ts +1 -1
  20. package/dist/declarations/src/context.d.ts.map +1 -1
  21. package/dist/declarations/src/fields/types/bigInt/index.d.ts +3 -3
  22. package/dist/declarations/src/fields/types/bigInt/index.d.ts.map +1 -1
  23. package/dist/declarations/src/fields/types/bytes/index.d.ts +3 -3
  24. package/dist/declarations/src/fields/types/bytes/index.d.ts.map +1 -1
  25. package/dist/declarations/src/fields/types/calendarDay/index.d.ts +3 -3
  26. package/dist/declarations/src/fields/types/calendarDay/index.d.ts.map +1 -1
  27. package/dist/declarations/src/fields/types/checkbox/index.d.ts +3 -3
  28. package/dist/declarations/src/fields/types/checkbox/index.d.ts.map +1 -1
  29. package/dist/declarations/src/fields/types/decimal/index.d.ts +3 -3
  30. package/dist/declarations/src/fields/types/decimal/index.d.ts.map +1 -1
  31. package/dist/declarations/src/fields/types/file/index.d.ts +4 -4
  32. package/dist/declarations/src/fields/types/file/index.d.ts.map +1 -1
  33. package/dist/declarations/src/fields/types/float/index.d.ts +3 -3
  34. package/dist/declarations/src/fields/types/float/index.d.ts.map +1 -1
  35. package/dist/declarations/src/fields/types/image/index.d.ts +4 -4
  36. package/dist/declarations/src/fields/types/image/index.d.ts.map +1 -1
  37. package/dist/declarations/src/fields/types/integer/index.d.ts +3 -3
  38. package/dist/declarations/src/fields/types/integer/index.d.ts.map +1 -1
  39. package/dist/declarations/src/fields/types/json/index.d.ts +3 -3
  40. package/dist/declarations/src/fields/types/json/index.d.ts.map +1 -1
  41. package/dist/declarations/src/fields/types/multiselect/index.d.ts +3 -3
  42. package/dist/declarations/src/fields/types/multiselect/index.d.ts.map +1 -1
  43. package/dist/declarations/src/fields/types/multiselect/views/index.d.ts.map +1 -1
  44. package/dist/declarations/src/fields/types/password/index.d.ts +3 -3
  45. package/dist/declarations/src/fields/types/password/index.d.ts.map +1 -1
  46. package/dist/declarations/src/fields/types/relationship/index.d.ts +8 -8
  47. package/dist/declarations/src/fields/types/relationship/index.d.ts.map +1 -1
  48. package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts +3 -3
  49. package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts.map +1 -1
  50. package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts +3 -3
  51. package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts.map +1 -1
  52. package/dist/declarations/src/fields/types/relationship/views/index.d.ts +3 -3
  53. package/dist/declarations/src/fields/types/relationship/views/index.d.ts.map +1 -1
  54. package/dist/declarations/src/fields/types/relationship/views/types.d.ts +3 -3
  55. package/dist/declarations/src/fields/types/relationship/views/types.d.ts.map +1 -1
  56. package/dist/declarations/src/fields/types/select/index.d.ts +3 -3
  57. package/dist/declarations/src/fields/types/select/index.d.ts.map +1 -1
  58. package/dist/declarations/src/fields/types/text/index.d.ts +3 -3
  59. package/dist/declarations/src/fields/types/text/index.d.ts.map +1 -1
  60. package/dist/declarations/src/fields/types/timestamp/index.d.ts +3 -3
  61. package/dist/declarations/src/fields/types/timestamp/index.d.ts.map +1 -1
  62. package/dist/declarations/src/fields/types/virtual/index.d.ts +7 -7
  63. package/dist/declarations/src/fields/types/virtual/index.d.ts.map +1 -1
  64. package/dist/declarations/src/helpers.d.ts +249 -13
  65. package/dist/declarations/src/helpers.d.ts.map +1 -1
  66. package/dist/declarations/src/index.d.ts +9 -4
  67. package/dist/declarations/src/index.d.ts.map +1 -1
  68. package/dist/declarations/src/internal-unstable/admin-ui/pages/ListPage/index.d.ts.map +1 -1
  69. package/dist/declarations/src/lib/admin-meta.d.ts +11 -11
  70. package/dist/declarations/src/lib/admin-meta.d.ts.map +1 -1
  71. package/dist/declarations/src/lib/core/access-control.d.ts +18 -18
  72. package/dist/declarations/src/lib/core/access-control.d.ts.map +1 -1
  73. package/dist/declarations/src/lib/core/cascade.d.ts +47 -0
  74. package/dist/declarations/src/lib/core/cascade.d.ts.map +1 -0
  75. package/dist/declarations/src/lib/core/initialise-lists.d.ts +27 -24
  76. package/dist/declarations/src/lib/core/initialise-lists.d.ts.map +1 -1
  77. package/dist/declarations/src/lib/env.d.ts +9 -0
  78. package/dist/declarations/src/lib/env.d.ts.map +1 -0
  79. package/dist/declarations/src/lib/system.d.ts +1 -1
  80. package/dist/declarations/src/lib/system.d.ts.map +1 -1
  81. package/dist/declarations/src/list-features.d.ts +162 -0
  82. package/dist/declarations/src/list-features.d.ts.map +1 -0
  83. package/dist/declarations/src/schema.d.ts +24 -23
  84. package/dist/declarations/src/schema.d.ts.map +1 -1
  85. package/dist/declarations/src/session.d.ts +75 -0
  86. package/dist/declarations/src/session.d.ts.map +1 -1
  87. package/dist/declarations/src/types/admin-meta.d.ts +11 -11
  88. package/dist/declarations/src/types/admin-meta.d.ts.map +1 -1
  89. package/dist/declarations/src/types/config/access-control.d.ts +42 -42
  90. package/dist/declarations/src/types/config/access-control.d.ts.map +1 -1
  91. package/dist/declarations/src/types/config/fields.d.ts +19 -19
  92. package/dist/declarations/src/types/config/fields.d.ts.map +1 -1
  93. package/dist/declarations/src/types/config/hooks.d.ts +131 -131
  94. package/dist/declarations/src/types/config/hooks.d.ts.map +1 -1
  95. package/dist/declarations/src/types/config/index.d.ts +190 -8
  96. package/dist/declarations/src/types/config/index.d.ts.map +1 -1
  97. package/dist/declarations/src/types/config/lists.d.ts +146 -108
  98. package/dist/declarations/src/types/config/lists.d.ts.map +1 -1
  99. package/dist/declarations/src/types/context.d.ts +507 -47
  100. package/dist/declarations/src/types/context.d.ts.map +1 -1
  101. package/dist/declarations/src/types/next-fields.d.ts +28 -28
  102. package/dist/declarations/src/types/next-fields.d.ts.map +1 -1
  103. package/dist/declarations/src/types/type-info.d.ts +3 -3
  104. package/dist/declarations/src/types/type-info.d.ts.map +1 -1
  105. package/dist/{express-455ae20c.cjs.js → express-84d534c2.cjs.js} +6 -6
  106. package/dist/{express-7559ca2d.esm.js → express-d0a4ce99.esm.js} +6 -6
  107. package/dist/{index-15c8f81e.esm.js → index-5d8b0b4e.esm.js} +363 -183
  108. package/dist/index-6055753b.cjs.js +393 -0
  109. package/dist/{index-42045902.cjs.js → index-ac29f382.cjs.js} +363 -185
  110. package/dist/index-f1703b7b.esm.js +386 -0
  111. package/dist/nixxie-cms-core.cjs.js +1388 -30
  112. package/dist/nixxie-cms-core.esm.js +1362 -24
  113. package/dist/{non-null-graphql-add6bb3d.cjs.js → non-null-graphql-4a44c122.cjs.js} +1 -1
  114. package/dist/{non-null-graphql-a84ed64d.esm.js → non-null-graphql-8c5feaae.esm.js} +1 -1
  115. package/dist/{resolve-hooks-165a9ce2.cjs.js → resolve-hooks-10a5f84c.cjs.js} +240 -6
  116. package/dist/{resolve-hooks-6813a045.esm.js → resolve-hooks-9e676794.esm.js} +238 -7
  117. package/dist/{system-a321642d.cjs.js → system-6b37a5f8.cjs.js} +33 -7
  118. package/dist/{system-03e49e4f.esm.js → system-e591d821.esm.js} +33 -7
  119. package/fields/dist/nixxie-cms-core-fields.cjs.js +29 -576
  120. package/fields/dist/nixxie-cms-core-fields.esm.js +18 -565
  121. package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js +4 -2
  122. package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.esm.js +4 -2
  123. package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.cjs.js +1 -6
  124. package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.esm.js +1 -6
  125. package/fields/types/password/dist/nixxie-cms-core-fields-types-password.cjs.js +4 -2
  126. package/fields/types/password/dist/nixxie-cms-core-fields-types-password.esm.js +4 -2
  127. package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.cjs.js +4 -3
  128. package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.esm.js +4 -3
  129. package/package.json +4 -4
  130. package/scripts/cli/dist/nixxie-cms-core-scripts-cli.cjs.js +4 -3
  131. package/scripts/cli/dist/nixxie-cms-core-scripts-cli.esm.js +4 -3
  132. package/scripts/dist/nixxie-cms-core-scripts.cjs.js +4 -3
  133. package/scripts/dist/nixxie-cms-core-scripts.esm.js +4 -3
  134. package/session/dist/nixxie-cms-core-session.cjs.js +286 -0
  135. package/session/dist/nixxie-cms-core-session.esm.js +279 -1
  136. package/src/access.ts +25 -25
  137. package/src/admin-ui/admin-meta-graphql.ts +5 -5
  138. package/src/admin-ui/components/CreateButtonLink.tsx +46 -46
  139. package/src/admin-ui/components/Navigation.tsx +3 -3
  140. package/src/admin-ui/context.tsx +6 -6
  141. package/src/admin-ui/utils/Fields.tsx +241 -241
  142. package/src/admin-ui/utils/actionData.ts +36 -36
  143. package/src/admin-ui/utils/filters.ts +148 -148
  144. package/src/admin-ui/utils/useCreateItem.ts +171 -171
  145. package/src/admin-ui/utils/utils.tsx +127 -127
  146. package/src/context.ts +1 -1
  147. package/src/fields/non-null-graphql.ts +115 -115
  148. package/src/fields/types/bigInt/index.ts +6 -6
  149. package/src/fields/types/bytes/index.ts +6 -6
  150. package/src/fields/types/calendarDay/index.ts +18 -19
  151. package/src/fields/types/checkbox/index.ts +6 -6
  152. package/src/fields/types/decimal/index.ts +6 -6
  153. package/src/fields/types/file/index.ts +8 -8
  154. package/src/fields/types/float/index.ts +6 -6
  155. package/src/fields/types/image/index.ts +8 -8
  156. package/src/fields/types/integer/index.ts +6 -6
  157. package/src/fields/types/json/index.ts +5 -5
  158. package/src/fields/types/multiselect/index.ts +7 -7
  159. package/src/fields/types/multiselect/views/index.tsx +149 -151
  160. package/src/fields/types/password/index.ts +6 -6
  161. package/src/fields/types/relationship/index.ts +13 -13
  162. package/src/fields/types/relationship/views/ComboboxMany.tsx +110 -110
  163. package/src/fields/types/relationship/views/ComboboxSingle.tsx +115 -115
  164. package/src/fields/types/relationship/views/ContextualActions.tsx +139 -139
  165. package/src/fields/types/relationship/views/index.tsx +492 -492
  166. package/src/fields/types/relationship/views/types.ts +46 -46
  167. package/src/fields/types/relationship/views/useApolloQuery.ts +185 -185
  168. package/src/fields/types/relationship/views/useFilter.tsx +109 -109
  169. package/src/fields/types/select/index.ts +6 -6
  170. package/src/fields/types/text/index.ts +6 -6
  171. package/src/fields/types/timestamp/index.ts +23 -21
  172. package/src/fields/types/virtual/index.ts +11 -11
  173. package/src/helpers.ts +773 -42
  174. package/src/index.ts +66 -24
  175. package/src/internal-unstable/admin-ui/pages/ItemPage/common.tsx +4 -4
  176. package/src/internal-unstable/admin-ui/pages/ItemPage/index.tsx +5 -5
  177. package/src/internal-unstable/admin-ui/pages/ListPage/index.tsx +8 -8
  178. package/src/lib/admin-meta.ts +369 -369
  179. package/src/lib/context/createContext.ts +6 -0
  180. package/src/lib/core/access-control.ts +434 -434
  181. package/src/lib/core/cascade.ts +236 -0
  182. package/src/lib/core/initialise-lists.ts +49 -33
  183. package/src/lib/core/mutations/index.ts +7 -0
  184. package/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +145 -145
  185. package/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +71 -71
  186. package/src/lib/core/queries/output-field.ts +178 -178
  187. package/src/lib/env.ts +50 -0
  188. package/src/lib/id-field.ts +2 -2
  189. package/src/lib/system.ts +221 -207
  190. package/src/lib/typescript-schema-printer.ts +227 -227
  191. package/src/list-features.ts +476 -0
  192. package/src/schema.ts +92 -22
  193. package/src/session.ts +225 -0
  194. package/src/types/admin-meta.ts +218 -218
  195. package/src/types/config/access-control.ts +186 -186
  196. package/src/types/config/fields.ts +96 -96
  197. package/src/types/config/hooks.ts +529 -529
  198. package/src/types/config/index.ts +206 -7
  199. package/src/types/config/lists.ts +606 -565
  200. package/src/types/context.ts +592 -55
  201. package/src/types/next-fields.ts +31 -31
  202. package/src/types/type-info.ts +38 -38
  203. 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'
5
5
  import type { SessionStrategy } from './session'
6
- import type { BaseNixxieTypeInfo, BaseListTypeInfo } from './type-info'
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
- /** Cron expression or interval in milliseconds */
102
- schedule: string | number
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(event: string, url: string, options?: NixxieWebhookSubscribeOptions): Promise<NixxieWebhookSubscription>
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<{ ok: boolean; message?: string; details?: unknown }>
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(key: string, data: Buffer | Uint8Array | string, options?: NixxiePutOptions): Promise<NixxieStoredFile>
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>(indexName: string, query: NixxieSearchQuery): Promise<NixxieSearchResults<T>>
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: NixxieListsAPI<TypeInfo['lists']>
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<ListTypeInfo extends BaseListTypeInfo> =
588
- false extends ListTypeInfo['isSingleton']
589
- ? { readonly where: ListTypeInfo['inputs']['uniqueWhere'] }
590
- : { readonly where?: ListTypeInfo['inputs']['uniqueWhere'] }
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 ListAPI<ListTypeInfo extends BaseListTypeInfo> = {
1129
+ type CollectionAPI<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
593
1130
  findMany(
594
1131
  args?: {
595
- readonly where?: ListTypeInfo['inputs']['where']
1132
+ readonly where?: CollectionTypeInfo['inputs']['where']
596
1133
  readonly take?: number
597
1134
  readonly skip?: number
598
1135
  readonly orderBy?:
599
- | ListTypeInfo['inputs']['orderBy']
600
- | readonly ListTypeInfo['inputs']['orderBy'][]
601
- readonly cursor?: ListTypeInfo['inputs']['uniqueWhere']
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<ListTypeInfo> & ResolveFields): Promise<Record<string, any>>
605
- count(args?: { readonly where?: ListTypeInfo['inputs']['where'] }): Promise<number>
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<ListTypeInfo> & {
608
- readonly data: ListTypeInfo['inputs']['update']
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<ListTypeInfo> & {
614
- readonly data: ListTypeInfo['inputs']['update']
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: ListTypeInfo['inputs']['create'] } & ResolveFields
1156
+ args: { readonly data: CollectionTypeInfo['inputs']['create'] } & ResolveFields
620
1157
  ): Promise<Record<string, any>>
621
1158
  createMany(
622
1159
  args: {
623
- readonly data: readonly ListTypeInfo['inputs']['create'][]
1160
+ readonly data: readonly CollectionTypeInfo['inputs']['create'][]
624
1161
  } & ResolveFields
625
1162
  ): Promise<Record<string, any>[]>
626
1163
  deleteOne(
627
- args: UniqueWhereInput<ListTypeInfo> & ResolveFields
1164
+ args: UniqueWhereInput<CollectionTypeInfo> & ResolveFields
628
1165
  ): Promise<Record<string, any> | null>
629
1166
  deleteMany(
630
1167
  args: {
631
- readonly where: readonly ListTypeInfo['inputs']['uniqueWhere'][]
1168
+ readonly where: readonly CollectionTypeInfo['inputs']['uniqueWhere'][]
632
1169
  } & ResolveFields
633
1170
  ): Promise<Record<string, any>[]>
634
1171
  }
635
1172
 
636
- export type NixxieListsAPI<ListsTypeInfo extends Record<string, BaseListTypeInfo>> = {
637
- [Key in keyof ListsTypeInfo]: ListAPI<ListsTypeInfo[Key]>
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<ListTypeInfo extends BaseListTypeInfo> = {
1184
+ type DbAPI<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
648
1185
  findMany(args?: {
649
- readonly where?: ListTypeInfo['inputs']['where']
1186
+ readonly where?: CollectionTypeInfo['inputs']['where']
650
1187
  readonly take?: number
651
1188
  readonly skip?: number
652
1189
  readonly orderBy?:
653
- | ListTypeInfo['inputs']['orderBy']
654
- | readonly ListTypeInfo['inputs']['orderBy'][]
655
- readonly cursor?: ListTypeInfo['inputs']['uniqueWhere']
656
- }): Promise<readonly ListTypeInfo['item'][]>
657
- findOne(args: UniqueWhereInput<ListTypeInfo>): Promise<ListTypeInfo['item'] | null>
658
- count(args?: { readonly where?: ListTypeInfo['inputs']['where'] }): Promise<number>
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<ListTypeInfo> & {
661
- readonly data: ListTypeInfo['inputs']['update']
1197
+ args: UniqueWhereInput<CollectionTypeInfo> & {
1198
+ readonly data: CollectionTypeInfo['inputs']['update']
662
1199
  }
663
- ): Promise<ListTypeInfo['item']>
1200
+ ): Promise<CollectionTypeInfo['item']>
664
1201
  updateMany(args: {
665
- readonly data: readonly (UniqueWhereInput<ListTypeInfo> & {
666
- readonly data: ListTypeInfo['inputs']['update']
1202
+ readonly data: readonly (UniqueWhereInput<CollectionTypeInfo> & {
1203
+ readonly data: CollectionTypeInfo['inputs']['update']
667
1204
  })[]
668
- }): Promise<ListTypeInfo['item'][]>
1205
+ }): Promise<CollectionTypeInfo['item'][]>
669
1206
  createOne(args: {
670
- readonly data: ListTypeInfo['inputs']['create']
671
- }): Promise<ListTypeInfo['item']>
1207
+ readonly data: CollectionTypeInfo['inputs']['create']
1208
+ }): Promise<CollectionTypeInfo['item']>
672
1209
  createMany(args: {
673
- readonly data: readonly ListTypeInfo['inputs']['create'][]
674
- }): Promise<ListTypeInfo['item'][]>
675
- deleteOne(args: UniqueWhereInput<ListTypeInfo>): Promise<ListTypeInfo['item']>
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 ListTypeInfo['inputs']['uniqueWhere'][]
678
- }): Promise<ListTypeInfo['item'][]>
1214
+ readonly where: readonly CollectionTypeInfo['inputs']['uniqueWhere'][]
1215
+ }): Promise<CollectionTypeInfo['item'][]>
679
1216
  }
680
1217
 
681
- export type NixxieDbAPI<ListsTypeInfo extends Record<string, BaseListTypeInfo>> = {
1218
+ export type NixxieDbAPI<ListsTypeInfo extends Record<string, BaseCollectionTypeInfo>> = {
682
1219
  [Key in keyof ListsTypeInfo]: DbAPI<ListsTypeInfo[Key]>
683
1220
  }
684
1221