ai-database 2.0.2 → 2.1.1

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 (88) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/actions.d.ts +247 -0
  3. package/dist/actions.d.ts.map +1 -0
  4. package/dist/actions.js +260 -0
  5. package/dist/actions.js.map +1 -0
  6. package/dist/ai-promise-db.d.ts +34 -2
  7. package/dist/ai-promise-db.d.ts.map +1 -1
  8. package/dist/ai-promise-db.js +511 -66
  9. package/dist/ai-promise-db.js.map +1 -1
  10. package/dist/constants.d.ts +16 -0
  11. package/dist/constants.d.ts.map +1 -0
  12. package/dist/constants.js +16 -0
  13. package/dist/constants.js.map +1 -0
  14. package/dist/events.d.ts +153 -0
  15. package/dist/events.d.ts.map +1 -0
  16. package/dist/events.js +154 -0
  17. package/dist/events.js.map +1 -0
  18. package/dist/index.d.ts +8 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +13 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/memory-provider.d.ts +144 -2
  23. package/dist/memory-provider.d.ts.map +1 -1
  24. package/dist/memory-provider.js +569 -13
  25. package/dist/memory-provider.js.map +1 -1
  26. package/dist/schema/cascade.d.ts +96 -0
  27. package/dist/schema/cascade.d.ts.map +1 -0
  28. package/dist/schema/cascade.js +528 -0
  29. package/dist/schema/cascade.js.map +1 -0
  30. package/dist/schema/index.d.ts +197 -0
  31. package/dist/schema/index.d.ts.map +1 -0
  32. package/dist/schema/index.js +1211 -0
  33. package/dist/schema/index.js.map +1 -0
  34. package/dist/schema/parse.d.ts +225 -0
  35. package/dist/schema/parse.d.ts.map +1 -0
  36. package/dist/schema/parse.js +732 -0
  37. package/dist/schema/parse.js.map +1 -0
  38. package/dist/schema/provider.d.ts +176 -0
  39. package/dist/schema/provider.d.ts.map +1 -0
  40. package/dist/schema/provider.js +258 -0
  41. package/dist/schema/provider.js.map +1 -0
  42. package/dist/schema/resolve.d.ts +87 -0
  43. package/dist/schema/resolve.d.ts.map +1 -0
  44. package/dist/schema/resolve.js +474 -0
  45. package/dist/schema/resolve.js.map +1 -0
  46. package/dist/schema/semantic.d.ts +53 -0
  47. package/dist/schema/semantic.d.ts.map +1 -0
  48. package/dist/schema/semantic.js +247 -0
  49. package/dist/schema/semantic.js.map +1 -0
  50. package/dist/schema/types.d.ts +528 -0
  51. package/dist/schema/types.d.ts.map +1 -0
  52. package/dist/schema/types.js +9 -0
  53. package/dist/schema/types.js.map +1 -0
  54. package/dist/schema.d.ts +24 -867
  55. package/dist/schema.d.ts.map +1 -1
  56. package/dist/schema.js +41 -1124
  57. package/dist/schema.js.map +1 -1
  58. package/dist/semantic.d.ts +175 -0
  59. package/dist/semantic.d.ts.map +1 -0
  60. package/dist/semantic.js +338 -0
  61. package/dist/semantic.js.map +1 -0
  62. package/dist/types.d.ts +14 -0
  63. package/dist/types.d.ts.map +1 -1
  64. package/dist/types.js.map +1 -1
  65. package/package.json +13 -4
  66. package/.turbo/turbo-build.log +0 -5
  67. package/TESTING.md +0 -410
  68. package/TEST_SUMMARY.md +0 -250
  69. package/TODO.md +0 -128
  70. package/src/ai-promise-db.ts +0 -1243
  71. package/src/authorization.ts +0 -1102
  72. package/src/durable-clickhouse.ts +0 -596
  73. package/src/durable-promise.ts +0 -582
  74. package/src/execution-queue.ts +0 -608
  75. package/src/index.test.ts +0 -868
  76. package/src/index.ts +0 -337
  77. package/src/linguistic.ts +0 -404
  78. package/src/memory-provider.test.ts +0 -1036
  79. package/src/memory-provider.ts +0 -1119
  80. package/src/schema.test.ts +0 -1254
  81. package/src/schema.ts +0 -2296
  82. package/src/tests.ts +0 -725
  83. package/src/types.ts +0 -1177
  84. package/test/README.md +0 -153
  85. package/test/edge-cases.test.ts +0 -646
  86. package/test/provider-resolution.test.ts +0 -402
  87. package/tsconfig.json +0 -9
  88. package/vitest.config.ts +0 -19
package/src/index.ts DELETED
@@ -1,337 +0,0 @@
1
- /**
2
- * ai-database - Schema-first database with promise pipelining
3
- *
4
- * Supports both direct and destructured usage:
5
- *
6
- * @example Direct usage - everything on one object
7
- * ```ts
8
- * const { db } = DB({
9
- * Lead: {
10
- * name: 'string',
11
- * company: 'Company.leads',
12
- * },
13
- * Company: {
14
- * name: 'string',
15
- * }
16
- * })
17
- *
18
- * // Chain without await
19
- * const leads = db.Lead.list()
20
- * const qualified = await leads.filter(l => l.score > 80)
21
- *
22
- * // Batch relationship loading
23
- * const withCompanies = await leads.map(l => ({
24
- * name: l.name,
25
- * company: l.company, // Batch loaded!
26
- * }))
27
- *
28
- * // Natural language queries
29
- * const results = await db.Lead`who closed deals this month?`
30
- * ```
31
- *
32
- * Provider is resolved transparently from environment (DATABASE_URL).
33
- *
34
- * @packageDocumentation
35
- */
36
-
37
- export { DB } from './schema.js'
38
- export type {
39
- // Thing types (mdxld-based)
40
- ThingFlat,
41
- ThingExpanded,
42
- // Schema types
43
- DatabaseSchema,
44
- EntitySchema,
45
- FieldDefinition,
46
- PrimitiveType,
47
- ParsedSchema,
48
- ParsedEntity,
49
- ParsedField,
50
- TypedDB,
51
- EntityOperations,
52
- PipelineEntityOperations,
53
- DBProvider,
54
- ListOptions,
55
- SearchOptions,
56
- InferEntity,
57
- GenerateOptions,
58
- // DB Result type
59
- DBResult,
60
- // Noun & Verb semantic types
61
- Noun,
62
- NounProperty,
63
- NounRelationship,
64
- Verb,
65
- TypeMeta,
66
- // API types
67
- EventsAPI,
68
- ActionsAPI,
69
- ArtifactsAPI,
70
- NounsAPI,
71
- VerbsAPI,
72
- // Event types
73
- DBEvent,
74
- ActorData,
75
- CreateEventOptions as DBCreateEventOptions,
76
- // Action types
77
- DBAction,
78
- CreateActionOptions as DBCreateActionOptions,
79
- // Artifact types
80
- DBArtifact,
81
- // Natural Language Query types
82
- NLQueryResult,
83
- NLQueryFn,
84
- NLQueryGenerator,
85
- NLQueryContext,
86
- NLQueryPlan,
87
- // Graph Database Types (for @mdxdb adapters)
88
- EntityId,
89
- Thing,
90
- Relationship,
91
- // Query Types
92
- QueryOptions,
93
- ThingSearchOptions,
94
- CreateOptions,
95
- UpdateOptions,
96
- RelateOptions,
97
- // Event/Action/Artifact Option Types
98
- StoreArtifactOptions,
99
- EventQueryOptions,
100
- ActionQueryOptions,
101
- ActionStatus,
102
- ArtifactType,
103
- // Client Interfaces
104
- DBClient,
105
- DBClientExtended,
106
- } from './schema.js'
107
-
108
- // Export CreateEventOptions and CreateActionOptions from types.ts
109
- // (the schema.js versions are for EventsAPI/ActionsAPI, these are for DBClientExtended)
110
- export type {
111
- CreateEventOptions,
112
- CreateActionOptions,
113
- } from './types.js'
114
-
115
- export {
116
- // Thing conversion utilities
117
- toExpanded,
118
- toFlat,
119
- // Configuration
120
- setProvider,
121
- setNLQueryGenerator,
122
- // Schema parsing
123
- parseSchema,
124
- // Schema Definition
125
- defineNoun,
126
- defineVerb,
127
- nounToSchema,
128
- Verbs,
129
- // AI Inference
130
- conjugate,
131
- pluralize,
132
- singularize,
133
- inferNoun,
134
- Type,
135
- // URL utilities
136
- resolveUrl,
137
- resolveShortUrl,
138
- parseUrl,
139
- } from './schema.js'
140
-
141
- export {
142
- MemoryProvider,
143
- createMemoryProvider,
144
- Semaphore,
145
- } from './memory-provider.js'
146
-
147
- export type {
148
- // Note: Event, Action, Artifact now exported from schema.js (types.ts)
149
- // memory-provider has different Event/Action/Artifact types (ActivityStreams style)
150
- Event as MemoryEvent,
151
- Action as MemoryAction,
152
- Artifact as MemoryArtifact,
153
- MemoryProviderOptions,
154
- } from './memory-provider.js'
155
-
156
- // Event/Action/Artifact types for @mdxdb adapters (simple event sourcing style)
157
- export type { Event, Action, Artifact } from './schema.js'
158
-
159
- // Promise pipelining exports
160
- export {
161
- DBPromise,
162
- isDBPromise,
163
- getRawDBPromise,
164
- createListPromise,
165
- createEntityPromise,
166
- createSearchPromise,
167
- wrapEntityOperations,
168
- DB_PROMISE_SYMBOL,
169
- RAW_DB_PROMISE_SYMBOL,
170
- } from './ai-promise-db.js'
171
-
172
- export type {
173
- DBPromiseOptions,
174
- ForEachOptions,
175
- ForEachResult,
176
- ForEachProgress,
177
- ForEachErrorAction,
178
- } from './ai-promise-db.js'
179
-
180
- // Authorization (FGA/RBAC) exports
181
- export type {
182
- // Core primitives
183
- Subject,
184
- SubjectType,
185
- Resource,
186
- ResourceRef,
187
- ResourceType,
188
-
189
- // Role & Permission
190
- Permission,
191
- Role,
192
- RoleLevel,
193
-
194
- // Assignment
195
- Assignment,
196
- AssignmentInput,
197
-
198
- // Authorization checks
199
- AuthzCheckRequest,
200
- AuthzCheckResult,
201
- AuthzBatchCheckRequest,
202
- AuthzBatchCheckResult,
203
-
204
- // Hierarchy
205
- ResourceHierarchy,
206
-
207
- // Schema integration
208
- AuthorizedNoun,
209
-
210
- // Business roles
211
- BusinessRole,
212
-
213
- // Engine interface
214
- AuthorizationEngine,
215
- } from './authorization.js'
216
-
217
- export {
218
- // Standard definitions
219
- StandardHierarchies,
220
- StandardPermissions,
221
- CRUDPermissions,
222
- createStandardRoles,
223
-
224
- // Verb-scoped permissions
225
- verbPermission,
226
- nounPermissions,
227
- matchesPermission,
228
-
229
- // Helper functions
230
- parseSubject,
231
- formatSubject,
232
- parseResource,
233
- formatResource,
234
- subjectMatches,
235
- resourceMatches,
236
-
237
- // Schema integration
238
- authorizeNoun,
239
- linkBusinessRole,
240
-
241
- // In-memory engine
242
- InMemoryAuthorizationEngine,
243
-
244
- // Nouns
245
- RoleNoun,
246
- AssignmentNoun,
247
- PermissionNoun,
248
- AuthorizationNouns,
249
- } from './authorization.js'
250
-
251
- // Document Database Types (for @mdxdb adapters)
252
- // These are environment-agnostic types that work in any runtime
253
- export type {
254
- // Document types
255
- Document,
256
- DocWithScore,
257
- // List/Search options and results
258
- DocListOptions,
259
- DocListResult,
260
- DocSearchOptions,
261
- DocSearchResult,
262
- // CRUD options and results
263
- DocGetOptions,
264
- DocSetOptions,
265
- DocSetResult,
266
- DocDeleteOptions,
267
- DocDeleteResult,
268
- // Database interfaces
269
- DocumentDatabase,
270
- DocumentDatabaseConfig,
271
- CreateDocumentDatabase,
272
- DocumentDatabaseWithViews,
273
- // View types
274
- ViewEntityItem,
275
- ViewComponent,
276
- ViewDocument,
277
- ViewContext,
278
- ViewRenderResult,
279
- ViewRelationshipMutation,
280
- ViewSyncResult,
281
- ViewManager,
282
- } from './types.js'
283
-
284
- // =============================================================================
285
- // Durable Promise - Time-agnostic execution
286
- // =============================================================================
287
-
288
- // Core durable promise exports
289
- export {
290
- DurablePromise,
291
- isDurablePromise,
292
- durable,
293
- DURABLE_PROMISE_SYMBOL,
294
- // Context management
295
- getCurrentContext,
296
- withContext,
297
- setDefaultContext,
298
- // Batch scheduler
299
- getBatchScheduler,
300
- setBatchScheduler,
301
- } from './durable-promise.js'
302
-
303
- export type {
304
- ExecutionPriority,
305
- DurablePromiseOptions,
306
- DurablePromiseResult,
307
- BatchScheduler,
308
- } from './durable-promise.js'
309
-
310
- // Execution queue for priority-based scheduling
311
- export {
312
- ExecutionQueue,
313
- createExecutionQueue,
314
- getDefaultQueue,
315
- setDefaultQueue,
316
- } from './execution-queue.js'
317
-
318
- export type {
319
- ExecutionQueueOptions,
320
- QueueStats,
321
- BatchSubmission,
322
- BatchProvider,
323
- BatchRequest,
324
- BatchStatus,
325
- BatchResult,
326
- } from './execution-queue.js'
327
-
328
- // ClickHouse-backed durable provider
329
- export {
330
- ClickHouseDurableProvider,
331
- createClickHouseDurableProvider,
332
- } from './durable-clickhouse.js'
333
-
334
- export type {
335
- ClickHouseExecutor,
336
- ClickHouseDurableConfig,
337
- } from './durable-clickhouse.js'