@stackbone/sdk 0.1.0-alpha.3 → 0.1.0-alpha.4

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/rag/schema.d.ts CHANGED
@@ -1,446 +1 @@
1
- import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
2
-
3
- type RagJobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
4
- interface RagJobProgress {
5
- totalChunks: number;
6
- processedChunks: number;
7
- currentDocument?: {
8
- source: string;
9
- ordinal: number;
10
- };
11
- }
12
- /** Embedding vector dimension — atado a `openai/text-embedding-3-small` (ADR §D2). */
13
- declare const RAG_EMBEDDING_DIMENSIONS = 1536;
14
- /** Schema major version. Bumped only on breaking change (ADR §D4). */
15
- declare const STACKBONE_RAG_SCHEMA_VERSION = "v1";
16
- declare const stackboneRagCollections: drizzle_orm_pg_core.PgTableWithColumns<{
17
- name: "stackbone_rag_collections";
18
- schema: undefined;
19
- columns: {
20
- id: drizzle_orm_pg_core.PgColumn<{
21
- name: "id";
22
- tableName: "stackbone_rag_collections";
23
- dataType: "string";
24
- columnType: "PgUUID";
25
- data: string;
26
- driverParam: string;
27
- notNull: true;
28
- hasDefault: true;
29
- isPrimaryKey: true;
30
- isAutoincrement: false;
31
- hasRuntimeDefault: false;
32
- enumValues: undefined;
33
- baseColumn: never;
34
- identity: undefined;
35
- generated: undefined;
36
- }, {}, {}>;
37
- name: drizzle_orm_pg_core.PgColumn<{
38
- name: "name";
39
- tableName: "stackbone_rag_collections";
40
- dataType: "string";
41
- columnType: "PgText";
42
- data: string;
43
- driverParam: string;
44
- notNull: true;
45
- hasDefault: false;
46
- isPrimaryKey: false;
47
- isAutoincrement: false;
48
- hasRuntimeDefault: false;
49
- enumValues: [string, ...string[]];
50
- baseColumn: never;
51
- identity: undefined;
52
- generated: undefined;
53
- }, {}, {}>;
54
- metadata: drizzle_orm_pg_core.PgColumn<{
55
- name: "metadata";
56
- tableName: "stackbone_rag_collections";
57
- dataType: "json";
58
- columnType: "PgJsonb";
59
- data: Record<string, unknown>;
60
- driverParam: unknown;
61
- notNull: true;
62
- hasDefault: true;
63
- isPrimaryKey: false;
64
- isAutoincrement: false;
65
- hasRuntimeDefault: false;
66
- enumValues: undefined;
67
- baseColumn: never;
68
- identity: undefined;
69
- generated: undefined;
70
- }, {}, {
71
- $type: Record<string, unknown>;
72
- }>;
73
- createdAt: drizzle_orm_pg_core.PgColumn<{
74
- name: "created_at";
75
- tableName: "stackbone_rag_collections";
76
- dataType: "date";
77
- columnType: "PgTimestamp";
78
- data: Date;
79
- driverParam: string;
80
- notNull: true;
81
- hasDefault: true;
82
- isPrimaryKey: false;
83
- isAutoincrement: false;
84
- hasRuntimeDefault: false;
85
- enumValues: undefined;
86
- baseColumn: never;
87
- identity: undefined;
88
- generated: undefined;
89
- }, {}, {}>;
90
- };
91
- dialect: "pg";
92
- }>;
93
- declare const stackboneRagDocuments: drizzle_orm_pg_core.PgTableWithColumns<{
94
- name: "stackbone_rag_documents";
95
- schema: undefined;
96
- columns: {
97
- id: drizzle_orm_pg_core.PgColumn<{
98
- name: "id";
99
- tableName: "stackbone_rag_documents";
100
- dataType: "string";
101
- columnType: "PgUUID";
102
- data: string;
103
- driverParam: string;
104
- notNull: true;
105
- hasDefault: true;
106
- isPrimaryKey: true;
107
- isAutoincrement: false;
108
- hasRuntimeDefault: false;
109
- enumValues: undefined;
110
- baseColumn: never;
111
- identity: undefined;
112
- generated: undefined;
113
- }, {}, {}>;
114
- collectionId: drizzle_orm_pg_core.PgColumn<{
115
- name: "collection_id";
116
- tableName: "stackbone_rag_documents";
117
- dataType: "string";
118
- columnType: "PgUUID";
119
- data: string;
120
- driverParam: string;
121
- notNull: true;
122
- hasDefault: false;
123
- isPrimaryKey: false;
124
- isAutoincrement: false;
125
- hasRuntimeDefault: false;
126
- enumValues: undefined;
127
- baseColumn: never;
128
- identity: undefined;
129
- generated: undefined;
130
- }, {}, {}>;
131
- source: drizzle_orm_pg_core.PgColumn<{
132
- name: "source";
133
- tableName: "stackbone_rag_documents";
134
- dataType: "string";
135
- columnType: "PgText";
136
- data: string;
137
- driverParam: string;
138
- notNull: true;
139
- hasDefault: false;
140
- isPrimaryKey: false;
141
- isAutoincrement: false;
142
- hasRuntimeDefault: false;
143
- enumValues: [string, ...string[]];
144
- baseColumn: never;
145
- identity: undefined;
146
- generated: undefined;
147
- }, {}, {}>;
148
- contentHash: drizzle_orm_pg_core.PgColumn<{
149
- name: "content_hash";
150
- tableName: "stackbone_rag_documents";
151
- dataType: "string";
152
- columnType: "PgText";
153
- data: string;
154
- driverParam: string;
155
- notNull: true;
156
- hasDefault: false;
157
- isPrimaryKey: false;
158
- isAutoincrement: false;
159
- hasRuntimeDefault: false;
160
- enumValues: [string, ...string[]];
161
- baseColumn: never;
162
- identity: undefined;
163
- generated: undefined;
164
- }, {}, {}>;
165
- metadata: drizzle_orm_pg_core.PgColumn<{
166
- name: "metadata";
167
- tableName: "stackbone_rag_documents";
168
- dataType: "json";
169
- columnType: "PgJsonb";
170
- data: Record<string, unknown>;
171
- driverParam: unknown;
172
- notNull: true;
173
- hasDefault: true;
174
- isPrimaryKey: false;
175
- isAutoincrement: false;
176
- hasRuntimeDefault: false;
177
- enumValues: undefined;
178
- baseColumn: never;
179
- identity: undefined;
180
- generated: undefined;
181
- }, {}, {
182
- $type: Record<string, unknown>;
183
- }>;
184
- createdAt: drizzle_orm_pg_core.PgColumn<{
185
- name: "created_at";
186
- tableName: "stackbone_rag_documents";
187
- dataType: "date";
188
- columnType: "PgTimestamp";
189
- data: Date;
190
- driverParam: string;
191
- notNull: true;
192
- hasDefault: true;
193
- isPrimaryKey: false;
194
- isAutoincrement: false;
195
- hasRuntimeDefault: false;
196
- enumValues: undefined;
197
- baseColumn: never;
198
- identity: undefined;
199
- generated: undefined;
200
- }, {}, {}>;
201
- };
202
- dialect: "pg";
203
- }>;
204
- declare const stackboneRagChunks: drizzle_orm_pg_core.PgTableWithColumns<{
205
- name: "stackbone_rag_chunks";
206
- schema: undefined;
207
- columns: {
208
- id: drizzle_orm_pg_core.PgColumn<{
209
- name: "id";
210
- tableName: "stackbone_rag_chunks";
211
- dataType: "string";
212
- columnType: "PgUUID";
213
- data: string;
214
- driverParam: string;
215
- notNull: true;
216
- hasDefault: true;
217
- isPrimaryKey: true;
218
- isAutoincrement: false;
219
- hasRuntimeDefault: false;
220
- enumValues: undefined;
221
- baseColumn: never;
222
- identity: undefined;
223
- generated: undefined;
224
- }, {}, {}>;
225
- documentId: drizzle_orm_pg_core.PgColumn<{
226
- name: "document_id";
227
- tableName: "stackbone_rag_chunks";
228
- dataType: "string";
229
- columnType: "PgUUID";
230
- data: string;
231
- driverParam: string;
232
- notNull: true;
233
- hasDefault: false;
234
- isPrimaryKey: false;
235
- isAutoincrement: false;
236
- hasRuntimeDefault: false;
237
- enumValues: undefined;
238
- baseColumn: never;
239
- identity: undefined;
240
- generated: undefined;
241
- }, {}, {}>;
242
- ordinal: drizzle_orm_pg_core.PgColumn<{
243
- name: "ordinal";
244
- tableName: "stackbone_rag_chunks";
245
- dataType: "number";
246
- columnType: "PgInteger";
247
- data: number;
248
- driverParam: string | number;
249
- notNull: true;
250
- hasDefault: false;
251
- isPrimaryKey: false;
252
- isAutoincrement: false;
253
- hasRuntimeDefault: false;
254
- enumValues: undefined;
255
- baseColumn: never;
256
- identity: undefined;
257
- generated: undefined;
258
- }, {}, {}>;
259
- content: drizzle_orm_pg_core.PgColumn<{
260
- name: "content";
261
- tableName: "stackbone_rag_chunks";
262
- dataType: "string";
263
- columnType: "PgText";
264
- data: string;
265
- driverParam: string;
266
- notNull: true;
267
- hasDefault: false;
268
- isPrimaryKey: false;
269
- isAutoincrement: false;
270
- hasRuntimeDefault: false;
271
- enumValues: [string, ...string[]];
272
- baseColumn: never;
273
- identity: undefined;
274
- generated: undefined;
275
- }, {}, {}>;
276
- embedding: drizzle_orm_pg_core.PgColumn<{
277
- name: "embedding";
278
- tableName: "stackbone_rag_chunks";
279
- dataType: "array";
280
- columnType: "PgVector";
281
- data: number[];
282
- driverParam: string;
283
- notNull: true;
284
- hasDefault: false;
285
- isPrimaryKey: false;
286
- isAutoincrement: false;
287
- hasRuntimeDefault: false;
288
- enumValues: undefined;
289
- baseColumn: never;
290
- identity: undefined;
291
- generated: undefined;
292
- }, {}, {
293
- dimensions: 1536;
294
- }>;
295
- metadata: drizzle_orm_pg_core.PgColumn<{
296
- name: "metadata";
297
- tableName: "stackbone_rag_chunks";
298
- dataType: "json";
299
- columnType: "PgJsonb";
300
- data: Record<string, unknown>;
301
- driverParam: unknown;
302
- notNull: true;
303
- hasDefault: true;
304
- isPrimaryKey: false;
305
- isAutoincrement: false;
306
- hasRuntimeDefault: false;
307
- enumValues: undefined;
308
- baseColumn: never;
309
- identity: undefined;
310
- generated: undefined;
311
- }, {}, {
312
- $type: Record<string, unknown>;
313
- }>;
314
- };
315
- dialect: "pg";
316
- }>;
317
- declare const stackboneRagJobs: drizzle_orm_pg_core.PgTableWithColumns<{
318
- name: "stackbone_rag_jobs";
319
- schema: undefined;
320
- columns: {
321
- id: drizzle_orm_pg_core.PgColumn<{
322
- name: "id";
323
- tableName: "stackbone_rag_jobs";
324
- dataType: "string";
325
- columnType: "PgUUID";
326
- data: string;
327
- driverParam: string;
328
- notNull: true;
329
- hasDefault: true;
330
- isPrimaryKey: true;
331
- isAutoincrement: false;
332
- hasRuntimeDefault: false;
333
- enumValues: undefined;
334
- baseColumn: never;
335
- identity: undefined;
336
- generated: undefined;
337
- }, {}, {}>;
338
- collectionId: drizzle_orm_pg_core.PgColumn<{
339
- name: "collection_id";
340
- tableName: "stackbone_rag_jobs";
341
- dataType: "string";
342
- columnType: "PgUUID";
343
- data: string;
344
- driverParam: string;
345
- notNull: true;
346
- hasDefault: false;
347
- isPrimaryKey: false;
348
- isAutoincrement: false;
349
- hasRuntimeDefault: false;
350
- enumValues: undefined;
351
- baseColumn: never;
352
- identity: undefined;
353
- generated: undefined;
354
- }, {}, {}>;
355
- status: drizzle_orm_pg_core.PgColumn<{
356
- name: "status";
357
- tableName: "stackbone_rag_jobs";
358
- dataType: "string";
359
- columnType: "PgText";
360
- data: "queued" | "running" | "succeeded" | "failed" | "cancelled";
361
- driverParam: string;
362
- notNull: true;
363
- hasDefault: true;
364
- isPrimaryKey: false;
365
- isAutoincrement: false;
366
- hasRuntimeDefault: false;
367
- enumValues: ["queued", "running", "succeeded", "failed", "cancelled"];
368
- baseColumn: never;
369
- identity: undefined;
370
- generated: undefined;
371
- }, {}, {}>;
372
- progress: drizzle_orm_pg_core.PgColumn<{
373
- name: "progress";
374
- tableName: "stackbone_rag_jobs";
375
- dataType: "json";
376
- columnType: "PgJsonb";
377
- data: RagJobProgress;
378
- driverParam: unknown;
379
- notNull: true;
380
- hasDefault: true;
381
- isPrimaryKey: false;
382
- isAutoincrement: false;
383
- hasRuntimeDefault: false;
384
- enumValues: undefined;
385
- baseColumn: never;
386
- identity: undefined;
387
- generated: undefined;
388
- }, {}, {
389
- $type: RagJobProgress;
390
- }>;
391
- error: drizzle_orm_pg_core.PgColumn<{
392
- name: "error";
393
- tableName: "stackbone_rag_jobs";
394
- dataType: "string";
395
- columnType: "PgText";
396
- data: string;
397
- driverParam: string;
398
- notNull: false;
399
- hasDefault: false;
400
- isPrimaryKey: false;
401
- isAutoincrement: false;
402
- hasRuntimeDefault: false;
403
- enumValues: [string, ...string[]];
404
- baseColumn: never;
405
- identity: undefined;
406
- generated: undefined;
407
- }, {}, {}>;
408
- createdAt: drizzle_orm_pg_core.PgColumn<{
409
- name: "created_at";
410
- tableName: "stackbone_rag_jobs";
411
- dataType: "date";
412
- columnType: "PgTimestamp";
413
- data: Date;
414
- driverParam: string;
415
- notNull: true;
416
- hasDefault: true;
417
- isPrimaryKey: false;
418
- isAutoincrement: false;
419
- hasRuntimeDefault: false;
420
- enumValues: undefined;
421
- baseColumn: never;
422
- identity: undefined;
423
- generated: undefined;
424
- }, {}, {}>;
425
- updatedAt: drizzle_orm_pg_core.PgColumn<{
426
- name: "updated_at";
427
- tableName: "stackbone_rag_jobs";
428
- dataType: "date";
429
- columnType: "PgTimestamp";
430
- data: Date;
431
- driverParam: string;
432
- notNull: true;
433
- hasDefault: true;
434
- isPrimaryKey: false;
435
- isAutoincrement: false;
436
- hasRuntimeDefault: false;
437
- enumValues: undefined;
438
- baseColumn: never;
439
- identity: undefined;
440
- generated: undefined;
441
- }, {}, {}>;
442
- };
443
- dialect: "pg";
444
- }>;
445
-
446
- export { RAG_EMBEDDING_DIMENSIONS, type RagJobProgress, type RagJobStatus, STACKBONE_RAG_SCHEMA_VERSION, stackboneRagChunks, stackboneRagCollections, stackboneRagDocuments, stackboneRagJobs };
1
+ export { RAG_EMBEDDING_DIMENSIONS, RagJobProgress, RagJobStatus, STACKBONE_RAG_SCHEMA_VERSION, stackboneRagChunks, stackboneRagCollections, stackboneRagDocuments, stackboneRagJobs } from '@stackbone/rag-core/schema';
package/rag/schema.js CHANGED
@@ -1,72 +1,53 @@
1
- import * as drizzle_orm_star from 'drizzle-orm';
2
- import * as pg_core_star from 'drizzle-orm/pg-core';
1
+ import { pgSchema, timestamp, jsonb, text, uuid, index, vector, integer } from 'drizzle-orm/pg-core';
3
2
 
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
17
-
18
- // src/db/index.ts
19
- var db_exports = {};
20
- __reExport(db_exports, drizzle_orm_star);
21
- __reExport(db_exports, pg_core_star);
22
-
23
- // src/surfaces/agent-local/rag/schema.ts
3
+ // ../shared/rag-core/src/lib/schema/schema.ts
4
+ var stackbonePlatform = pgSchema("stackbone_platform");
24
5
  var RAG_EMBEDDING_DIMENSIONS = 1536;
25
6
  var STACKBONE_RAG_SCHEMA_VERSION = "v1";
26
- var stackboneRagCollections = (0, db_exports.pgTable)("stackbone_rag_collections", {
27
- id: (0, db_exports.uuid)("id").defaultRandom().primaryKey(),
28
- name: (0, db_exports.text)("name").notNull().unique(),
29
- metadata: (0, db_exports.jsonb)("metadata").$type().notNull().default({}),
30
- createdAt: (0, db_exports.timestamp)("created_at", {
7
+ var stackboneRagCollections = stackbonePlatform.table("rag_collections", {
8
+ id: uuid("id").defaultRandom().primaryKey(),
9
+ name: text("name").notNull().unique(),
10
+ metadata: jsonb("metadata").$type().notNull().default({}),
11
+ createdAt: timestamp("created_at", {
31
12
  withTimezone: true
32
13
  }).notNull().defaultNow()
33
14
  });
34
- var stackboneRagDocuments = (0, db_exports.pgTable)("stackbone_rag_documents", {
35
- id: (0, db_exports.uuid)("id").defaultRandom().primaryKey(),
36
- collectionId: (0, db_exports.uuid)("collection_id").notNull().references(() => stackboneRagCollections.id, {
15
+ var stackboneRagDocuments = stackbonePlatform.table("rag_documents", {
16
+ id: uuid("id").defaultRandom().primaryKey(),
17
+ collectionId: uuid("collection_id").notNull().references(() => stackboneRagCollections.id, {
37
18
  onDelete: "cascade"
38
19
  }),
39
- source: (0, db_exports.text)("source").notNull(),
40
- contentHash: (0, db_exports.text)("content_hash").notNull(),
41
- metadata: (0, db_exports.jsonb)("metadata").$type().notNull().default({}),
42
- createdAt: (0, db_exports.timestamp)("created_at", {
20
+ source: text("source").notNull(),
21
+ contentHash: text("content_hash").notNull(),
22
+ metadata: jsonb("metadata").$type().notNull().default({}),
23
+ createdAt: timestamp("created_at", {
43
24
  withTimezone: true
44
25
  }).notNull().defaultNow()
45
- }, (t) => ({
46
- byCollection: (0, db_exports.index)("stackbone_rag_documents_collection_idx").on(t.collectionId),
47
- byHash: (0, db_exports.index)("stackbone_rag_documents_hash_idx").on(t.collectionId, t.contentHash)
48
- }));
49
- var stackboneRagChunks = (0, db_exports.pgTable)("stackbone_rag_chunks", {
50
- id: (0, db_exports.uuid)("id").defaultRandom().primaryKey(),
51
- documentId: (0, db_exports.uuid)("document_id").notNull().references(() => stackboneRagDocuments.id, {
26
+ }, (t) => [
27
+ index("rag_documents_collection_idx").on(t.collectionId),
28
+ index("rag_documents_hash_idx").on(t.collectionId, t.contentHash)
29
+ ]);
30
+ var stackboneRagChunks = stackbonePlatform.table("rag_chunks", {
31
+ id: uuid("id").defaultRandom().primaryKey(),
32
+ documentId: uuid("document_id").notNull().references(() => stackboneRagDocuments.id, {
52
33
  onDelete: "cascade"
53
34
  }),
54
- ordinal: (0, db_exports.integer)("ordinal").notNull(),
55
- content: (0, db_exports.text)("content").notNull(),
56
- embedding: (0, db_exports.vector)("embedding", {
35
+ ordinal: integer("ordinal").notNull(),
36
+ content: text("content").notNull(),
37
+ embedding: vector("embedding", {
57
38
  dimensions: RAG_EMBEDDING_DIMENSIONS
58
39
  }).notNull(),
59
- metadata: (0, db_exports.jsonb)("metadata").$type().notNull().default({})
60
- }, (t) => ({
61
- byDocument: (0, db_exports.index)("stackbone_rag_chunks_document_idx").on(t.documentId),
62
- ann: (0, db_exports.index)("stackbone_rag_chunks_embedding_hnsw").using("hnsw", t.embedding.op("vector_cosine_ops"))
63
- }));
64
- var stackboneRagJobs = (0, db_exports.pgTable)("stackbone_rag_jobs", {
65
- id: (0, db_exports.uuid)("id").defaultRandom().primaryKey(),
66
- collectionId: (0, db_exports.uuid)("collection_id").notNull().references(() => stackboneRagCollections.id, {
40
+ metadata: jsonb("metadata").$type().notNull().default({})
41
+ }, (t) => [
42
+ index("rag_chunks_document_idx").on(t.documentId),
43
+ index("rag_chunks_embedding_hnsw").using("hnsw", t.embedding.op("vector_cosine_ops"))
44
+ ]);
45
+ var stackboneRagJobs = stackbonePlatform.table("rag_jobs", {
46
+ id: uuid("id").defaultRandom().primaryKey(),
47
+ collectionId: uuid("collection_id").notNull().references(() => stackboneRagCollections.id, {
67
48
  onDelete: "cascade"
68
49
  }),
69
- status: (0, db_exports.text)("status", {
50
+ status: text("status", {
70
51
  enum: [
71
52
  "queued",
72
53
  "running",
@@ -75,21 +56,21 @@ var stackboneRagJobs = (0, db_exports.pgTable)("stackbone_rag_jobs", {
75
56
  "cancelled"
76
57
  ]
77
58
  }).notNull().default("queued"),
78
- progress: (0, db_exports.jsonb)("progress").$type().notNull().default({
59
+ progress: jsonb("progress").$type().notNull().default({
79
60
  totalChunks: 0,
80
61
  processedChunks: 0
81
62
  }),
82
- error: (0, db_exports.text)("error"),
83
- createdAt: (0, db_exports.timestamp)("created_at", {
63
+ error: text("error"),
64
+ createdAt: timestamp("created_at", {
84
65
  withTimezone: true
85
66
  }).notNull().defaultNow(),
86
- updatedAt: (0, db_exports.timestamp)("updated_at", {
67
+ updatedAt: timestamp("updated_at", {
87
68
  withTimezone: true
88
69
  }).notNull().defaultNow()
89
- }, (t) => ({
90
- byCollection: (0, db_exports.index)("stackbone_rag_jobs_collection_idx").on(t.collectionId),
91
- byStatus: (0, db_exports.index)("stackbone_rag_jobs_status_idx").on(t.status)
92
- }));
70
+ }, (t) => [
71
+ index("rag_jobs_collection_idx").on(t.collectionId),
72
+ index("rag_jobs_status_idx").on(t.status)
73
+ ]);
93
74
 
94
75
  export { RAG_EMBEDDING_DIMENSIONS, STACKBONE_RAG_SCHEMA_VERSION, stackboneRagChunks, stackboneRagCollections, stackboneRagDocuments, stackboneRagJobs };
95
76
  //# sourceMappingURL=schema.js.map
package/rag/schema.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../libs/sdk/src/db/index.ts","../../../../libs/sdk/src/surfaces/agent-local/rag/schema.ts"],"names":["RAG_EMBEDDING_DIMENSIONS","STACKBONE_RAG_SCHEMA_VERSION","stackboneRagCollections","pgTable","id","uuid","defaultRandom","primaryKey","name","text","notNull","unique","metadata","jsonb","$type","default","createdAt","timestamp","withTimezone","defaultNow","stackboneRagDocuments","collectionId","references","onDelete","source","contentHash","t","byCollection","index","on","byHash","stackboneRagChunks","documentId","ordinal","integer","content","embedding","vector","dimensions","byDocument","ann","using","op","stackboneRagJobs","status","enum","progress","totalChunks","processedChunks","error","updatedAt","byStatus"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAA,UAAA,GAAA,EAAA;AAMA,UAAA,CAAA,UAAA,EAAA,gBAAA,CAAA;AACA,UAAA,CAAA,UAAA,EAAA,YAAA,CAAA;;;ACoBO,IAAMA,wBAAAA,GAA2B;AAGjC,IAAMC,4BAAAA,GAA+B;AAErC,IAAMC,uBAAAA,GAAAA,IAA0BC,oBAAQ,2BAAA,EAA6B;AAC1EC,EAAAA,EAAAA,EAAAA,IAAIC,UAAAA,CAAAA,IAAAA,EAAK,IAAA,CAAA,CAAMC,aAAAA,GAAgBC,UAAAA,EAAU;AACzCC,EAAAA,IAAAA,EAAAA,IAAMC,UAAAA,CAAAA,IAAAA,EAAK,MAAA,CAAA,CAAQC,OAAAA,GAAUC,MAAAA,EAAM;EACnCC,QAAAA,EAAAA,IAAUC,UAAAA,CAAAA,KAAAA,EAAM,UAAA,CAAA,CAAYC,KAAAA,GAAiCJ,OAAAA,EAAO,CAAGK,OAAAA,CAAQ,EAAC,CAAA;AAChFC,EAAAA,SAAAA,EAAAA,IAAWC,sBAAU,YAAA,EAAc;IAAEC,YAAAA,EAAc;GAAK,CAAA,CAAGR,OAAAA,EAAO,CAAGS,UAAAA;AACvE,CAAA;AAEO,IAAMC,qBAAAA,GAAAA,IAAwBjB,oBACnC,yBAAA,EACA;AACEC,EAAAA,EAAAA,EAAAA,IAAIC,UAAAA,CAAAA,IAAAA,EAAK,IAAA,CAAA,CAAMC,aAAAA,GAAgBC,UAAAA,EAAU;EACzCc,YAAAA,EAAAA,IAAchB,UAAAA,CAAAA,IAAAA,EAAK,eAAA,CAAA,CAChBK,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AA,CAAQ,QAAA,CAAA;AACX+B,EAAAA,QAAAA,EAAAA,IAAUjC,kBAAM,UAAA,CAAA,CACbC,OAAK,CACLJ,OAAAA,GACAK,OAAAA,CAAQ;IAAEgC,WAAAA,EAAa,CAAA;IAAGC,eAAAA,EAAiB;GAAE,CAAA;AAChDC,EAAAA,KAAAA,EAAAA,IAAOxC,iBAAK,OAAA,CAAA;AACZO,EAAAA,SAAAA,EAAAA,IAAWC,sBAAU,YAAA,EAAc;IAAEC,YAAAA,EAAc;GAAK,CAAA,CAAGR,OAAAA,EAAO,CAAGS,UAAAA,EAAU;AAC/E+B,EAAAA,SAAAA,EAAAA,IAAWjC,sBAAU,YAAA,EAAc;IAAEC,YAAAA,EAAc;GAAK,CAAA,CAAGR,OAAAA,EAAO,CAAGS,UAAAA;AACvE,CAAA,EACA,CAACO,CAAAA,MAAO;AACNC,EAAAA,YAAAA,EAAAA,IAAcC,UAAAA,CAAAA,KAAAA,EAAM,mCAAA,CAAA,CAAqCC,EAAAA,CAAGH,EAAEL,YAAY,CAAA;AAC1E8B,EAAAA,QAAAA,EAAAA,IAAUvB,UAAAA,CAAAA,KAAAA,EAAM,+BAAA,CAAA,CAAiCC,EAAAA,CAAGH,EAAEkB,MAAM;AAC9D,CAAA,CAAA","file":"schema.js","sourcesContent":["// Public surface for `@stackbone/sdk/db`. We re-export drizzle-orm wholesale\n// so creators can `import { eq, sql, and, ... } from '@stackbone/sdk/db'`\n// without learning two import paths. Enumerating every drizzle symbol by hand\n// is infeasible (drizzle ships dozens of helpers and types and adds more each\n// release), so this is the one place in the repo where `export *` is allowed\n// (carved out in eslint.config.mjs).\nexport * from 'drizzle-orm';\nexport * from 'drizzle-orm/pg-core';\n\n// Re-exporting both `drizzle-orm` and `drizzle-orm/pg-core` produces TS2308\n// (ambiguous re-export) for the type names below, since both barrels expose\n// them. Pinning them to the pg-core variant — the one creators write Postgres\n// schemas against — resolves the ambiguity.\nexport type {\n ColumnsWithTable,\n SelectedFields,\n SelectedFieldsFlat,\n SelectedFieldsOrdered,\n TableConfig,\n} from 'drizzle-orm/pg-core';\n","// Single source of truth for the RAG tables installed by `stackbone db\n// migrate add-rag`. This module is **internal** never re-exported from\n// `@stackbone/sdk`'s public barrel. Only the SDK's own RAG pipeline (slices\n// F03–F07) and the CLI (this slice) read from it.\n//\n// The bundled SQL migration in `./migrations/stackbone_rag_v1.sql` is the\n// snapshot generated from the Drizzle definitions below via\n// `drizzle-kit generate`. The two MUST stay in sync; the snapshot test in\n// `schema.spec.ts` pins the expected table/column shape so a drift in the\n// hand-maintained SQL is caught at CI.\n//\n// Column helpers come from `@stackbone/sdk/db` (its public re-export of\n// `drizzle-orm/pg-core`) so creators and the SDK use the exact same `vector`\n// implementation. Importing directly from `drizzle-orm/pg-core` here would\n// fork the chain; routing through the SDK's barrel is the canonical path\n// locked in ADR 2026-05-10 §D1.\nimport { index, integer, jsonb, pgTable, text, timestamp, uuid, vector } from '../../../db';\n\nexport type RagJobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';\n\nexport interface RagJobProgress {\n totalChunks: number;\n processedChunks: number;\n currentDocument?: { source: string; ordinal: number };\n}\n\n/** Embedding vector dimension atado a `openai/text-embedding-3-small` (ADR §D2). */\nexport const RAG_EMBEDDING_DIMENSIONS = 1536;\n\n/** Schema major version. Bumped only on breaking change (ADR §D4). */\nexport const STACKBONE_RAG_SCHEMA_VERSION = 'v1';\n\nexport const stackboneRagCollections = pgTable('stackbone_rag_collections', {\n id: uuid('id').defaultRandom().primaryKey(),\n name: text('name').notNull().unique(),\n metadata: jsonb('metadata').$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n});\n\nexport const stackboneRagDocuments = pgTable(\n 'stackbone_rag_documents',\n {\n id: uuid('id').defaultRandom().primaryKey(),\n collectionId: uuid('collection_id')\n .notNull()\n .references(() => stackboneRagCollections.id, { onDelete: 'cascade' }),\n source: text('source').notNull(),\n contentHash: text('content_hash').notNull(),\n metadata: jsonb('metadata').$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n },\n (t) => ({\n byCollection: index('stackbone_rag_documents_collection_idx').on(t.collectionId),\n byHash: index('stackbone_rag_documents_hash_idx').on(t.collectionId, t.contentHash),\n }),\n);\n\nexport const stackboneRagChunks = pgTable(\n 'stackbone_rag_chunks',\n {\n id: uuid('id').defaultRandom().primaryKey(),\n documentId: uuid('document_id')\n .notNull()\n .references(() => stackboneRagDocuments.id, { onDelete: 'cascade' }),\n ordinal: integer('ordinal').notNull(),\n content: text('content').notNull(),\n embedding: vector('embedding', { dimensions: RAG_EMBEDDING_DIMENSIONS }).notNull(),\n metadata: jsonb('metadata').$type<Record<string, unknown>>().notNull().default({}),\n },\n (t) => ({\n byDocument: index('stackbone_rag_chunks_document_idx').on(t.documentId),\n ann: index('stackbone_rag_chunks_embedding_hnsw').using(\n 'hnsw',\n t.embedding.op('vector_cosine_ops'),\n ),\n }),\n);\n\nexport const stackboneRagJobs = pgTable(\n 'stackbone_rag_jobs',\n {\n id: uuid('id').defaultRandom().primaryKey(),\n collectionId: uuid('collection_id')\n .notNull()\n .references(() => stackboneRagCollections.id, { onDelete: 'cascade' }),\n status: text('status', {\n enum: ['queued', 'running', 'succeeded', 'failed', 'cancelled'],\n })\n .notNull()\n .default('queued'),\n progress: jsonb('progress')\n .$type<RagJobProgress>()\n .notNull()\n .default({ totalChunks: 0, processedChunks: 0 }),\n error: text('error'),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),\n },\n (t) => ({\n byCollection: index('stackbone_rag_jobs_collection_idx').on(t.collectionId),\n byStatus: index('stackbone_rag_jobs_status_idx').on(t.status),\n }),\n);\n"]}
1
+ {"version":3,"sources":["../../../../libs/shared/rag-core/src/lib/schema/schema.ts"],"names":["stackbonePlatform","pgSchema","RAG_EMBEDDING_DIMENSIONS","STACKBONE_RAG_SCHEMA_VERSION","stackboneRagCollections","table","id","uuid","defaultRandom","primaryKey","name","text","notNull","unique","metadata","jsonb","$type","default","createdAt","timestamp","withTimezone","defaultNow","stackboneRagDocuments","collectionId","references","onDelete","source","contentHash","t","index","on","stackboneRagChunks","documentId","ordinal","integer","content","embedding","vector","dimensions","using","op","stackboneRagJobs","status","enum","progress","totalChunks","processedChunks","error","updatedAt"],"mappings":";;;AAiCO,IAAMA,iBAAAA,GAAoBC,SAAS,oBAAA,CAAA;AAiBnC,IAAMC,wBAAAA,GAA2B;AAGjC,IAAMC,4BAAAA,GAA+B;AAErC,IAAMC,uBAAAA,GAA0BJ,iBAAAA,CAAkBK,KAAAA,CAAM,iBAAA,EAAmB;AAChFC,EAAAA,EAAAA,EAAIC,IAAAA,CAAK,IAAA,CAAA,CAAMC,aAAAA,GAAgBC,UAAAA,EAAU;AACzCC,EAAAA,IAAAA,EAAMC,IAAAA,CAAK,MAAA,CAAA,CAAQC,OAAAA,GAAUC,MAAAA,EAAM;EACnCC,QAAAA,EAAUC,KAAAA,CAAM,UAAA,CAAA,CAAYC,KAAAA,GAAiCJ,OAAAA,EAAO,CAAGK,OAAAA,CAAQ,EAAC,CAAA;AAChFC,EAAAA,SAAAA,EAAWC,UAAU,YAAA,EAAc;IAAEC,YAAAA,EAAc;GAAK,CAAA,CAAGR,OAAAA,EAAO,CAAGS,UAAAA;AACvE,CAAA;AAEO,IAAMC,qBAAAA,GAAwBtB,iBAAAA,CAAkBK,KAAAA,CACrD,eAAA,EACA;AACEC,EAAAA,EAAAA,EAAIC,IAAAA,CAAK,IAAA,CAAA,CAAMC,aAAAA,GAAgBC,UAAAA,EAAU;EACzCc,YAAAA,EAAchB,IAAAA,CAAK,eAAA,CAAA,CAChBK,OAAAA,GACAY,UAAAA,CAAW,MAAMpB,wBAAwBE,EAAAA,EAAI;IAAEmB,QAAAA,EAAU;GAAU,CAAA;EACtEC,MAAAA,EAAQf,IAAAA,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UAAAA;AACvE,CAAA,EACA,CAACO,CAAAA,KAAM;AACLC,EAAAA,KAAAA,CAAM,yBAAA,CAAA,CAA2BC,EAAAA,CAAGF,CAAAA,CAAEL,YAAY,CAAA;AAClDM,EAAAA,KAAAA,CAAM,qBAAA,CAAA,CAAuBC,EAAAA,CAAGF,CAAAA,CAAEc,MAAM;AACzC,CAAA","file":"schema.js","sourcesContent":["// Single source of truth for the RAG tables. These live in the\n// `stackbone_platform` schema alongside every other platform-owned feature\n// (runs, approvals, secrets, prompts, agent_config, queue jobs): the schema is\n// provisioned by the platform migrator (`@stackbone/platform-schema`,\n// migration `0014_rag.sql`), not by the creator's `.stackbone/migrations/`.\n// The SDK re-exports these definitions as `@stackbone/sdk/rag/schema`; the\n// canonical home is this `@stackbone/rag-core` leaf.\n//\n// The physical tables are `stackbone_platform.rag_collections` /\n// `rag_documents` / `rag_chunks` / `rag_jobs` — the `stackbone_platform` schema\n// already namespaces them, so the bare `rag_` prefix is enough. The JS\n// identifiers keep the `stackboneRag*` names so every Drizzle consumer (cloud\n// Studio, emulator) is untouched and gets the schema-qualified table for free.\n//\n// Column helpers come directly from `drizzle-orm/pg-core` an external npm\n// package, so this `scope:shared` leaf stays free of any cross-scope import.\n// The `vector` helper is the exact same implementation the SDK re-exports\n// through `@stackbone/sdk/db`, so creators and the core share one `vector`.\nimport {\n index,\n integer,\n jsonb,\n pgSchema,\n text,\n timestamp,\n uuid,\n vector,\n} from 'drizzle-orm/pg-core';\n\n/**\n * The platform-owned Postgres schema. Every Stackbone-managed table lives here,\n * walled off from the creator's own tables in `public`.\n */\nexport const stackbonePlatform = pgSchema('stackbone_platform');\n\nexport type RagJobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';\n\nexport interface RagJobProgress {\n totalChunks: number;\n processedChunks: number;\n currentDocument?: { source: string; ordinal: number };\n}\n\n/**\n * Embedding vector dimension. The chunks table pins `vector(1536)` because the\n * managed ingest path embeds with `openai/text-embedding-3-small`. This is an\n * ASSUMPTION baked into the column type: a non-1536 model is NOT validated at\n * publish or ingest — a dimension mismatch surfaces only as a raw INSERT error\n * from Postgres, which is acceptable for the MVP.\n */\nexport const RAG_EMBEDDING_DIMENSIONS = 1536;\n\n/** Schema major version. Bumped only on breaking change (ADR §D4). */\nexport const STACKBONE_RAG_SCHEMA_VERSION = 'v1';\n\nexport const stackboneRagCollections = stackbonePlatform.table('rag_collections', {\n id: uuid('id').defaultRandom().primaryKey(),\n name: text('name').notNull().unique(),\n metadata: jsonb('metadata').$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n});\n\nexport const stackboneRagDocuments = stackbonePlatform.table(\n 'rag_documents',\n {\n id: uuid('id').defaultRandom().primaryKey(),\n collectionId: uuid('collection_id')\n .notNull()\n .references(() => stackboneRagCollections.id, { onDelete: 'cascade' }),\n source: text('source').notNull(),\n contentHash: text('content_hash').notNull(),\n metadata: jsonb('metadata').$type<Record<string, unknown>>().notNull().default({}),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n },\n (t) => [\n index('rag_documents_collection_idx').on(t.collectionId),\n index('rag_documents_hash_idx').on(t.collectionId, t.contentHash),\n ],\n);\n\nexport const stackboneRagChunks = stackbonePlatform.table(\n 'rag_chunks',\n {\n id: uuid('id').defaultRandom().primaryKey(),\n documentId: uuid('document_id')\n .notNull()\n .references(() => stackboneRagDocuments.id, { onDelete: 'cascade' }),\n ordinal: integer('ordinal').notNull(),\n content: text('content').notNull(),\n embedding: vector('embedding', { dimensions: RAG_EMBEDDING_DIMENSIONS }).notNull(),\n metadata: jsonb('metadata').$type<Record<string, unknown>>().notNull().default({}),\n },\n (t) => [\n index('rag_chunks_document_idx').on(t.documentId),\n index('rag_chunks_embedding_hnsw').using('hnsw', t.embedding.op('vector_cosine_ops')),\n ],\n);\n\nexport const stackboneRagJobs = stackbonePlatform.table(\n 'rag_jobs',\n {\n id: uuid('id').defaultRandom().primaryKey(),\n collectionId: uuid('collection_id')\n .notNull()\n .references(() => stackboneRagCollections.id, { onDelete: 'cascade' }),\n status: text('status', {\n enum: ['queued', 'running', 'succeeded', 'failed', 'cancelled'],\n })\n .notNull()\n .default('queued'),\n progress: jsonb('progress')\n .$type<RagJobProgress>()\n .notNull()\n .default({ totalChunks: 0, processedChunks: 0 }),\n error: text('error'),\n createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),\n },\n (t) => [\n index('rag_jobs_collection_idx').on(t.collectionId),\n index('rag_jobs_status_idx').on(t.status),\n ],\n);\n"]}
Binary file