@48nauts/adapter-drizzle 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+ @48nauts/agent-core (NautCore)
4
+ Copyright (C) 2026 48Nauts (Andre / hello@48nauts.com)
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+
19
+ ---
20
+
21
+ NOTE: This file is the SPDX header + short notice. Before this repo is made
22
+ public, replace the section below with the full AGPL-3.0 license text from
23
+ https://www.gnu.org/licenses/agpl-3.0.txt (or run `curl -o LICENSE.full https://www.gnu.org/licenses/agpl-3.0.txt`).
24
+ The SPDX header above is the legally-binding identifier; the long text is the
25
+ canonical reference required for public distribution.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @48nauts/adapter-drizzle
2
+
3
+ `DbAdapter` implementation backed by Drizzle ORM. Postgres-first (matches the 48Nauts default stack).
4
+
5
+ Consumers pass their `drizzle()` instance; this package wires it to the adapter shape `@48nauts/tools-crud` expects.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @48nauts/adapter-drizzle
3
+ *
4
+ * DbAdapter backed by Drizzle ORM (Postgres). Hosts pass in their own table
5
+ * references + a scope ({ orgId, actorUserId }), and the adapter translates
6
+ * the canonical CRUD calls from @48nauts/tools-crud into Drizzle queries.
7
+ *
8
+ * Why scoped: AgenticKMU-shape schemas have NOT NULL orgId + ownerId on
9
+ * projects, and NOT NULL orgId + authorUserId on notes. The scope is the only
10
+ * place the agent's tenancy lives — tools never see it.
11
+ */
12
+ import type { PgDatabase, PgTable } from 'drizzle-orm/pg-core';
13
+ import type { DbAdapter } from '@48nauts/agent-core';
14
+ export declare const VERSION = "0.1.0";
15
+ export interface DrizzleAdapterScope {
16
+ /** Org / tenant ID. Inserted on create, filtered on list/search. */
17
+ orgId: string;
18
+ /** User the agent acts as — inserted as owner / author on create. */
19
+ actorUserId: string;
20
+ }
21
+ type AnyTable = PgTable<any>;
22
+ export interface DrizzleAdapterTables {
23
+ /** `projects` table. Expected columns: id, name, description, orgId, ownerId, createdAt, updatedAt. */
24
+ projects: AnyTable;
25
+ /** `tasks` table. Expected: id, projectId, title, description, status, priority, dueDate, createdAt. */
26
+ tasks: AnyTable;
27
+ /** `notes` table. Expected: id, projectId, orgId, authorUserId, createdAt + one body column (see `noteBodyColumn`). */
28
+ notes: AnyTable;
29
+ }
30
+ export interface DrizzleAdapterOptions {
31
+ /**
32
+ * Column name in the `notes` table that holds the body text.
33
+ * AgenticKMU uses `body`; canonical default is `content`.
34
+ */
35
+ noteBodyColumn?: string;
36
+ /**
37
+ * Skip orgId scoping on projects / notes. Single-tenant hosts (Engram-OSS)
38
+ * use this. Tasks are always scoped by projectId, never orgId.
39
+ */
40
+ skipOrgScoping?: boolean;
41
+ /** Cap on unbounded list operations. Default 100. */
42
+ defaultListLimit?: number;
43
+ }
44
+ export interface CreateDrizzleAdapterInput {
45
+ db: PgDatabase<any, any, any>;
46
+ tables: DrizzleAdapterTables;
47
+ scope: DrizzleAdapterScope;
48
+ options?: DrizzleAdapterOptions;
49
+ }
50
+ /**
51
+ * Build a DbAdapter wired to the host's Drizzle setup. Construct one per
52
+ * agent session — `scope` is captured at construction time.
53
+ *
54
+ * import { createDrizzleAdapter } from '@48nauts/adapter-drizzle'
55
+ * import { projects, tasks, notes } from '@your-app/shared/schema'
56
+ * import { db } from '@/lib/db'
57
+ *
58
+ * const adapter = createDrizzleAdapter({
59
+ * db,
60
+ * tables: { projects, tasks, notes },
61
+ * scope: { orgId: session.orgId, actorUserId: session.userId },
62
+ * options: { noteBodyColumn: 'body' }, // AgenticKMU's schema
63
+ * })
64
+ */
65
+ export declare function createDrizzleAdapter(input: CreateDrizzleAdapterInput): DbAdapter;
66
+ export type { DbAdapter, ProjectsRepo, TasksRepo, NotesRepo, ProjectRecord, TaskRecord, NoteRecord, } from '@48nauts/agent-core';
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EACV,SAAS,EASV,MAAM,qBAAqB,CAAA;AAE5B,eAAO,MAAM,OAAO,UAAU,CAAA;AAE9B,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAA;CACpB;AAID,KAAK,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;AAE5B,MAAM,WAAW,oBAAoB;IACnC,uGAAuG;IACvG,QAAQ,EAAE,QAAQ,CAAA;IAClB,wGAAwG;IACxG,KAAK,EAAE,QAAQ,CAAA;IACf,uHAAuH;IACvH,KAAK,EAAE,QAAQ,CAAA;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,yBAAyB;IAExC,EAAE,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC7B,MAAM,EAAE,oBAAoB,CAAA;IAC5B,KAAK,EAAE,mBAAmB,CAAA;IAC1B,OAAO,CAAC,EAAE,qBAAqB,CAAA;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,SAAS,CAWhF;AAsPD,YAAY,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,252 @@
1
+ /**
2
+ * @48nauts/adapter-drizzle
3
+ *
4
+ * DbAdapter backed by Drizzle ORM (Postgres). Hosts pass in their own table
5
+ * references + a scope ({ orgId, actorUserId }), and the adapter translates
6
+ * the canonical CRUD calls from @48nauts/tools-crud into Drizzle queries.
7
+ *
8
+ * Why scoped: AgenticKMU-shape schemas have NOT NULL orgId + ownerId on
9
+ * projects, and NOT NULL orgId + authorUserId on notes. The scope is the only
10
+ * place the agent's tenancy lives — tools never see it.
11
+ */
12
+ import { and, eq, ilike } from 'drizzle-orm';
13
+ export const VERSION = '0.1.0';
14
+ /**
15
+ * Build a DbAdapter wired to the host's Drizzle setup. Construct one per
16
+ * agent session — `scope` is captured at construction time.
17
+ *
18
+ * import { createDrizzleAdapter } from '@48nauts/adapter-drizzle'
19
+ * import { projects, tasks, notes } from '@your-app/shared/schema'
20
+ * import { db } from '@/lib/db'
21
+ *
22
+ * const adapter = createDrizzleAdapter({
23
+ * db,
24
+ * tables: { projects, tasks, notes },
25
+ * scope: { orgId: session.orgId, actorUserId: session.userId },
26
+ * options: { noteBodyColumn: 'body' }, // AgenticKMU's schema
27
+ * })
28
+ */
29
+ export function createDrizzleAdapter(input) {
30
+ const { db, tables, scope, options } = input;
31
+ const noteBodyColumn = options?.noteBodyColumn ?? 'content';
32
+ const skipOrgScoping = options?.skipOrgScoping ?? false;
33
+ const listLimit = options?.defaultListLimit ?? 100;
34
+ return {
35
+ projects: buildProjectsRepo(db, tables.projects, scope, skipOrgScoping, listLimit),
36
+ tasks: buildTasksRepo(db, tables.tasks, listLimit),
37
+ notes: buildNotesRepo(db, tables.notes, scope, skipOrgScoping, noteBodyColumn),
38
+ };
39
+ }
40
+ // ──────────────────────────────────────────────────────────────────────
41
+ // projects
42
+ // ──────────────────────────────────────────────────────────────────────
43
+ function buildProjectsRepo(
44
+ // biome-ignore lint/suspicious/noExplicitAny: see file-level note
45
+ db, table, scope, skipOrgScoping, listLimit) {
46
+ const idCol = col(table, 'id');
47
+ const nameCol = col(table, 'name');
48
+ const orgCol = skipOrgScoping ? null : col(table, 'orgId');
49
+ const orgFilter = orgCol ? eq(orgCol, scope.orgId) : undefined;
50
+ return {
51
+ async get(id) {
52
+ const rows = await db
53
+ .select()
54
+ .from(table)
55
+ .where(orgFilter ? and(eq(idCol, id), orgFilter) : eq(idCol, id))
56
+ .limit(1);
57
+ return rows[0] ? toProjectRecord(rows[0]) : null;
58
+ },
59
+ async list() {
60
+ const q = db.select().from(table);
61
+ const rows = orgFilter
62
+ ? await q.where(orgFilter).limit(listLimit)
63
+ : await q.limit(listLimit);
64
+ return rows.map(toProjectRecord);
65
+ },
66
+ async search(query, limit) {
67
+ const nameMatch = ilike(nameCol, `%${query}%`);
68
+ const rows = await db
69
+ .select()
70
+ .from(table)
71
+ .where(orgFilter ? and(nameMatch, orgFilter) : nameMatch)
72
+ .limit(limit ?? 10);
73
+ return rows.map(toProjectRecord);
74
+ },
75
+ async create(input) {
76
+ const values = {
77
+ name: input.name,
78
+ description: input.description || null,
79
+ };
80
+ if (!skipOrgScoping) {
81
+ values.orgId = scope.orgId;
82
+ values.ownerId = scope.actorUserId;
83
+ }
84
+ const [row] = await db.insert(table).values(values).returning();
85
+ if (!row)
86
+ throw new Error('createDrizzleAdapter.projects.create: insert returned no row');
87
+ return toProjectRecord(row);
88
+ },
89
+ async update(id, patch) {
90
+ const values = { ...patch, updatedAt: new Date() };
91
+ const [row] = await db
92
+ .update(table)
93
+ .set(values)
94
+ .where(orgFilter ? and(eq(idCol, id), orgFilter) : eq(idCol, id))
95
+ .returning();
96
+ if (!row)
97
+ throw new Error(`createDrizzleAdapter.projects.update: ${id} not found`);
98
+ return toProjectRecord(row);
99
+ },
100
+ };
101
+ }
102
+ function toProjectRecord(row) {
103
+ return {
104
+ id: String(row.id),
105
+ name: String(row.name ?? ''),
106
+ description: stringOrEmpty(row.description),
107
+ createdAt: toEpoch(row.createdAt),
108
+ updatedAt: toEpoch(row.updatedAt ?? row.createdAt),
109
+ };
110
+ }
111
+ // ──────────────────────────────────────────────────────────────────────
112
+ // tasks
113
+ // ──────────────────────────────────────────────────────────────────────
114
+ function buildTasksRepo(
115
+ // biome-ignore lint/suspicious/noExplicitAny: see file-level note
116
+ db, table, listLimit) {
117
+ const idCol = col(table, 'id');
118
+ const projectIdCol = col(table, 'projectId');
119
+ const statusCol = col(table, 'status');
120
+ return {
121
+ async get(id) {
122
+ const rows = await db.select().from(table).where(eq(idCol, id)).limit(1);
123
+ return rows[0] ? toTaskRecord(rows[0]) : null;
124
+ },
125
+ async listByProject(projectId, filter) {
126
+ const projectMatch = eq(projectIdCol, projectId);
127
+ const where = filter?.status !== undefined
128
+ ? and(projectMatch, eq(statusCol, filter.status))
129
+ : projectMatch;
130
+ const rows = await db.select().from(table).where(where).limit(listLimit);
131
+ return rows.map(toTaskRecord);
132
+ },
133
+ async create(input) {
134
+ const values = {
135
+ projectId: input.projectId,
136
+ title: input.title,
137
+ description: input.description || null,
138
+ status: input.status,
139
+ priority: input.priority,
140
+ };
141
+ if (input.dueDate !== undefined)
142
+ values.dueDate = input.dueDate;
143
+ const [row] = await db.insert(table).values(values).returning();
144
+ if (!row)
145
+ throw new Error('createDrizzleAdapter.tasks.create: insert returned no row');
146
+ return toTaskRecord(row);
147
+ },
148
+ async update(id, patch) {
149
+ const values = { ...patch, updatedAt: new Date() };
150
+ const [row] = await db.update(table).set(values).where(eq(idCol, id)).returning();
151
+ if (!row)
152
+ throw new Error(`createDrizzleAdapter.tasks.update: ${id} not found`);
153
+ return toTaskRecord(row);
154
+ },
155
+ };
156
+ }
157
+ function toTaskRecord(row) {
158
+ const rec = {
159
+ id: String(row.id),
160
+ projectId: String(row.projectId),
161
+ title: String(row.title ?? ''),
162
+ description: stringOrEmpty(row.description),
163
+ status: row.status ?? 'todo',
164
+ priority: row.priority ?? 'medium',
165
+ createdAt: toEpoch(row.createdAt),
166
+ };
167
+ if (row.dueDate != null) {
168
+ // Drizzle returns `date` columns as strings already (YYYY-MM-DD); pass through.
169
+ rec.dueDate = row.dueDate instanceof Date ? row.dueDate.toISOString().slice(0, 10) : String(row.dueDate);
170
+ }
171
+ return rec;
172
+ }
173
+ // ──────────────────────────────────────────────────────────────────────
174
+ // notes
175
+ // ──────────────────────────────────────────────────────────────────────
176
+ function buildNotesRepo(
177
+ // biome-ignore lint/suspicious/noExplicitAny: see file-level note
178
+ db, table, scope, skipOrgScoping, bodyColumn) {
179
+ const projectIdCol = col(table, 'projectId');
180
+ // Validate the body column exists — fail at construction, not at first call.
181
+ col(table, bodyColumn);
182
+ const hasTitleColumn = optionalCol(table, 'title') !== null;
183
+ return {
184
+ async listByProject(projectId) {
185
+ const rows = await db.select().from(table).where(eq(projectIdCol, projectId));
186
+ return rows.map((row) => toNoteRecord(row, bodyColumn));
187
+ },
188
+ async create(input) {
189
+ const values = {
190
+ projectId: input.projectId,
191
+ [bodyColumn]: input.content,
192
+ };
193
+ // The canonical NoteRecord has a `title` field, but AgenticKMU's notes
194
+ // table does not. Only set it when the host's table has the column.
195
+ if (hasTitleColumn)
196
+ values.title = input.title;
197
+ if (!skipOrgScoping) {
198
+ values.orgId = scope.orgId;
199
+ values.authorUserId = scope.actorUserId;
200
+ }
201
+ const [row] = await db.insert(table).values(values).returning();
202
+ if (!row)
203
+ throw new Error('createDrizzleAdapter.notes.create: insert returned no row');
204
+ return toNoteRecord(row, bodyColumn);
205
+ },
206
+ };
207
+ }
208
+ function toNoteRecord(row, bodyColumn) {
209
+ return {
210
+ id: String(row.id),
211
+ projectId: String(row.projectId),
212
+ title: stringOrEmpty(row.title),
213
+ content: stringOrEmpty(row[bodyColumn]),
214
+ createdAt: toEpoch(row.createdAt),
215
+ };
216
+ }
217
+ // ──────────────────────────────────────────────────────────────────────
218
+ // helpers
219
+ // ──────────────────────────────────────────────────────────────────────
220
+ /** Look up a column by name. Throws if missing — call at construction time so
221
+ * adapters fail loudly on schema mismatch, not at first query. */
222
+ function col(table, name) {
223
+ const c = table[name];
224
+ if (!c) {
225
+ throw new Error(`createDrizzleAdapter: table is missing required column '${name}'. ` +
226
+ `Check the schema you passed matches the canonical projects/tasks/notes shape.`);
227
+ }
228
+ return c;
229
+ }
230
+ function optionalCol(table, name) {
231
+ const c = table[name];
232
+ return c ?? null;
233
+ }
234
+ function toEpoch(v) {
235
+ if (v == null)
236
+ return 0;
237
+ if (v instanceof Date)
238
+ return v.getTime();
239
+ if (typeof v === 'number')
240
+ return v;
241
+ if (typeof v === 'string') {
242
+ const t = Date.parse(v);
243
+ return Number.isNaN(t) ? 0 : t;
244
+ }
245
+ return 0;
246
+ }
247
+ function stringOrEmpty(v) {
248
+ if (v == null)
249
+ return '';
250
+ return typeof v === 'string' ? v : String(v);
251
+ }
252
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAkB,MAAM,aAAa,CAAA;AAc5D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AA6C9B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IAC5C,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,SAAS,CAAA;IAC3D,MAAM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drizzle",
3
+ "version": "0.1.0",
4
+ "description": "DbAdapter implementation backed by Drizzle ORM (Postgres-first).",
5
+ "license": "AGPL-3.0-or-later",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "@48nauts/agent-core": "0.1.0"
17
+ },
18
+ "peerDependencies": {
19
+ "drizzle-orm": ">=0.30.0"
20
+ },
21
+ "devDependencies": {
22
+ "typescript": "^5.5.0"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "scripts": {
31
+ "typecheck": "tsc --noEmit",
32
+ "build": "tsc"
33
+ }
34
+ }