@autonoma-ai/sdk-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.
@@ -0,0 +1,21 @@
1
+ import { OrmAdapter } from '@autonoma-ai/sdk';
2
+
3
+ interface DrizzleAdapterConfig {
4
+ scopeField: string;
5
+ }
6
+
7
+ /**
8
+ * Create a Drizzle ORM adapter for the Autonoma SDK.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { drizzleAdapter } from '@autonoma-ai/sdk-drizzle'
13
+ * import { db } from '~/db'
14
+ * import * as schema from '~/db/schema'
15
+ *
16
+ * const adapter = drizzleAdapter(db, schema, { scopeField: 'organizationId' })
17
+ * ```
18
+ */
19
+ declare function drizzleAdapter(db: any, schema: Record<string, unknown>, config: DrizzleAdapterConfig): OrmAdapter;
20
+
21
+ export { type DrizzleAdapterConfig, drizzleAdapter };
package/dist/index.js ADDED
@@ -0,0 +1,178 @@
1
+ // src/introspect.ts
2
+ function introspectDrizzle(schema, config) {
3
+ const models = [];
4
+ const edges = [];
5
+ const tables = /* @__PURE__ */ new Map();
6
+ for (const [key, value] of Object.entries(schema)) {
7
+ if (isTable(value)) {
8
+ tables.set(key, value);
9
+ }
10
+ }
11
+ for (const [key, table] of tables) {
12
+ const tableName = getTableName(table, key);
13
+ const columns = getTableColumns(table);
14
+ const fields = [];
15
+ for (const [colName, col] of Object.entries(columns)) {
16
+ fields.push({
17
+ name: colName,
18
+ type: col.dataType,
19
+ isRequired: col.notNull,
20
+ isId: col.primary,
21
+ hasDefault: col.hasDefault
22
+ });
23
+ }
24
+ models.push({ name: tableName, fields });
25
+ }
26
+ for (const [key, value] of Object.entries(schema)) {
27
+ if (isRelations(value)) {
28
+ const rels = extractRelations(value);
29
+ for (const rel of rels) {
30
+ if (rel.columns?.length && rel.foreignColumns?.length) {
31
+ edges.push({
32
+ from: getRelationSourceTable(key, tables),
33
+ to: rel.referencedTableName,
34
+ localField: rel.columns[0].name,
35
+ foreignField: rel.foreignColumns[0].name,
36
+ nullable: !rel.isNullable
37
+ });
38
+ }
39
+ }
40
+ }
41
+ }
42
+ return { models, edges, relations: [], scopeField: config.scopeField };
43
+ }
44
+ function isTable(value) {
45
+ if (!value || typeof value !== "object") return false;
46
+ const v = value;
47
+ return /* @__PURE__ */ Symbol.for("drizzle:Name") in v || v._ != null && typeof v._ === "object" && "columns" in v._;
48
+ }
49
+ function isRelations(value) {
50
+ if (!value || typeof value !== "object") return false;
51
+ const v = value;
52
+ return v.dbName != null || v.table != null;
53
+ }
54
+ function getTableName(table, fallback) {
55
+ const sym = /* @__PURE__ */ Symbol.for("drizzle:Name");
56
+ if (sym in table) return table[sym];
57
+ if (table._?.name) return table._.name;
58
+ return fallback;
59
+ }
60
+ function getTableColumns(table) {
61
+ if (table._?.columns) return table._.columns;
62
+ const cols = {};
63
+ for (const [key, val] of Object.entries(table)) {
64
+ if (val && typeof val === "object" && "dataType" in val) {
65
+ cols[key] = val;
66
+ }
67
+ }
68
+ return cols;
69
+ }
70
+ function extractRelations(_value) {
71
+ return [];
72
+ }
73
+ function getRelationSourceTable(key, tables) {
74
+ const match = key.match(/^(.+?)Relations$/);
75
+ if (match) {
76
+ const tableName = match[1];
77
+ if (tables.has(tableName)) return getTableName(tables.get(tableName), tableName);
78
+ }
79
+ return key;
80
+ }
81
+
82
+ // src/create.ts
83
+ async function createEntities(db, tableMap, spec, _context) {
84
+ const results = {};
85
+ for (const [model, entitySpec] of Object.entries(spec)) {
86
+ const table = tableMap.get(model);
87
+ if (!table) {
88
+ throw new Error(`Drizzle table '${model}' not found in schema.`);
89
+ }
90
+ const created = [];
91
+ for (const fields of entitySpec.fields) {
92
+ const [record] = await db.insert(table).values(fields).returning();
93
+ if (record) created.push(record);
94
+ }
95
+ results[model] = created;
96
+ }
97
+ return results;
98
+ }
99
+
100
+ // src/teardown.ts
101
+ import { topoSort, findDeferrableEdge } from "@autonoma-ai/sdk";
102
+ async function teardown(db, tableMap, schema, scopeValue, eq) {
103
+ const modelNames = schema.models.map((m) => m.name);
104
+ const { sorted, cycles } = topoSort(modelNames, schema.edges);
105
+ for (const cycle of cycles) {
106
+ const edge = findDeferrableEdge(cycle, schema.edges);
107
+ if (edge) {
108
+ const table = tableMap.get(edge.from);
109
+ if (table) {
110
+ await db.update(table).set({ [edge.localField]: null }).where(eq(table[schema.scopeField], scopeValue));
111
+ }
112
+ }
113
+ }
114
+ for (const cycle of cycles) {
115
+ for (const model of cycle) {
116
+ await deleteModel(db, tableMap, model, schema.scopeField, scopeValue, eq);
117
+ }
118
+ }
119
+ const reversed = [...sorted].reverse();
120
+ for (const model of reversed) {
121
+ await deleteModel(db, tableMap, model, schema.scopeField, scopeValue, eq);
122
+ }
123
+ }
124
+ async function deleteModel(db, tableMap, model, scopeField, scopeValue, eq) {
125
+ const table = tableMap.get(model);
126
+ if (!table) return;
127
+ await db.delete(table).where(eq(table[scopeField], scopeValue));
128
+ }
129
+
130
+ // src/index.ts
131
+ function drizzleAdapter(db, schema, config) {
132
+ let cachedSchema = null;
133
+ const tableMap = buildTableMap(schema);
134
+ return {
135
+ getSchema() {
136
+ if (!cachedSchema) {
137
+ cachedSchema = introspectDrizzle(schema, config);
138
+ }
139
+ return cachedSchema;
140
+ },
141
+ async createEntities(spec, context) {
142
+ return createEntities(db, tableMap, spec, context);
143
+ },
144
+ async teardown(scopeValue) {
145
+ const schemaInfo = this.getSchema();
146
+ const { eq } = await import("drizzle-orm");
147
+ return teardown(db, tableMap, schemaInfo, scopeValue, eq);
148
+ }
149
+ };
150
+ }
151
+ function buildTableMap(schema) {
152
+ const map = /* @__PURE__ */ new Map();
153
+ for (const [key, value] of Object.entries(schema)) {
154
+ if (isTable2(value)) {
155
+ const name = getTableName2(value, key);
156
+ map.set(name, value);
157
+ }
158
+ }
159
+ return map;
160
+ }
161
+ function isTable2(value) {
162
+ if (!value || typeof value !== "object") return false;
163
+ const v = value;
164
+ return /* @__PURE__ */ Symbol.for("drizzle:Name") in v || v._ != null && typeof v._ === "object" && "columns" in v._;
165
+ }
166
+ function getTableName2(table, fallback) {
167
+ const sym = /* @__PURE__ */ Symbol.for("drizzle:Name");
168
+ if (table && typeof table === "object" && sym in table) {
169
+ return table[sym];
170
+ }
171
+ const t = table;
172
+ if (t._?.name) return t._.name;
173
+ return fallback;
174
+ }
175
+ export {
176
+ drizzleAdapter
177
+ };
178
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/introspect.ts","../src/create.ts","../src/teardown.ts","../src/index.ts"],"sourcesContent":["import type { SchemaInfo, SchemaRelation, ModelInfo, FieldInfo, FKEdge } from '@autonoma-ai/sdk'\n\nexport interface DrizzleAdapterConfig {\n scopeField: string\n}\n\n// DrizzleTable is accessed dynamically — Symbol.for('drizzle:Name') can't be in an interface\ntype DrizzleTable = Record<string | symbol, unknown> & {\n _?: { name: string; columns: Record<string, DrizzleColumn> }\n}\n\ninterface DrizzleColumn {\n name: string\n dataType: string\n notNull: boolean\n primary: boolean\n hasDefault: boolean\n}\n\ninterface DrizzleRelation {\n fieldName: string\n referencedTableName: string\n columns?: Array<{ name: string }>\n foreignColumns?: Array<{ name: string }>\n isNullable?: boolean\n}\n\n/**\n * Introspect a Drizzle schema to extract schema metadata.\n */\nexport function introspectDrizzle(\n schema: Record<string, unknown>,\n config: DrizzleAdapterConfig,\n): SchemaInfo {\n const models: ModelInfo[] = []\n const edges: FKEdge[] = []\n const tables = new Map<string, DrizzleTable>()\n\n // Find all table objects in the schema export\n for (const [key, value] of Object.entries(schema)) {\n if (isTable(value)) {\n tables.set(key, value as DrizzleTable)\n }\n }\n\n for (const [key, table] of tables) {\n const tableName = getTableName(table, key)\n const columns = getTableColumns(table)\n const fields: FieldInfo[] = []\n\n for (const [colName, col] of Object.entries(columns)) {\n fields.push({\n name: colName,\n type: col.dataType,\n isRequired: col.notNull,\n isId: col.primary,\n hasDefault: col.hasDefault,\n })\n }\n\n models.push({ name: tableName, fields })\n }\n\n // Extract relations from the schema\n for (const [key, value] of Object.entries(schema)) {\n if (isRelations(value)) {\n const rels = extractRelations(value)\n for (const rel of rels) {\n if (rel.columns?.length && rel.foreignColumns?.length) {\n edges.push({\n from: getRelationSourceTable(key, tables),\n to: rel.referencedTableName,\n localField: rel.columns[0]!.name,\n foreignField: rel.foreignColumns[0]!.name,\n nullable: !rel.isNullable,\n })\n }\n }\n }\n }\n\n return { models, edges, relations: [], scopeField: config.scopeField }\n}\n\nfunction isTable(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false\n const v = value as Record<string | symbol, unknown>\n // Drizzle tables have a Symbol.for('drizzle:Name') or a _ property with columns\n return (\n Symbol.for('drizzle:Name') in v ||\n (v._ != null && typeof v._ === 'object' && 'columns' in (v._ as object))\n )\n}\n\nfunction isRelations(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false\n // Relations objects have a specific structure\n const v = value as Record<string, unknown>\n return v.dbName != null || v.table != null\n}\n\nfunction getTableName(table: DrizzleTable, fallback: string): string {\n const sym = Symbol.for('drizzle:Name')\n if (sym in table) return (table as any)[sym] as string\n if (table._?.name) return table._.name\n return fallback\n}\n\nfunction getTableColumns(table: DrizzleTable): Record<string, DrizzleColumn> {\n if (table._?.columns) return table._.columns\n // Fallback: inspect own properties that look like columns\n const cols: Record<string, DrizzleColumn> = {}\n for (const [key, val] of Object.entries(table)) {\n if (val && typeof val === 'object' && 'dataType' in val) {\n cols[key] = val as DrizzleColumn\n }\n }\n return cols\n}\n\nfunction extractRelations(_value: unknown): DrizzleRelation[] {\n // Drizzle relations are complex — for the prototype, return empty\n // Real implementation would traverse the relations() call tree\n return []\n}\n\nfunction getRelationSourceTable(\n key: string,\n tables: Map<string, DrizzleTable>,\n): string {\n // Convention: relations are named like `usersRelations` → `users`\n const match = key.match(/^(.+?)Relations$/)\n if (match) {\n const tableName = match[1]!\n if (tables.has(tableName)) return getTableName(tables.get(tableName)!, tableName)\n }\n return key\n}\n","import type { ResolvedEntitySpec, CreateContext } from '@autonoma-ai/sdk'\n\ntype DrizzleDB = Record<string, any> & {\n insert(table: any): { values(data: any): { returning(): Promise<any[]> } }\n}\n\n/**\n * Create entities using Drizzle ORM.\n */\nexport async function createEntities(\n db: DrizzleDB,\n tableMap: Map<string, unknown>,\n spec: Record<string, ResolvedEntitySpec>,\n _context: CreateContext,\n): Promise<Record<string, Record<string, unknown>[]>> {\n const results: Record<string, Record<string, unknown>[]> = {}\n\n for (const [model, entitySpec] of Object.entries(spec)) {\n const table = tableMap.get(model)\n if (!table) {\n throw new Error(`Drizzle table '${model}' not found in schema.`)\n }\n\n const created: Record<string, unknown>[] = []\n for (const fields of entitySpec.fields) {\n const [record] = await db.insert(table).values(fields).returning()\n if (record) created.push(record)\n }\n results[model] = created\n }\n\n return results\n}\n","import type { SchemaInfo } from '@autonoma-ai/sdk'\nimport { topoSort, findDeferrableEdge } from '@autonoma-ai/sdk'\n\ntype DrizzleDB = Record<string, any> & {\n delete(table: any): { where(condition: any): Promise<void> }\n update(table: any): { set(data: any): { where(condition: any): Promise<void> } }\n}\n\n/**\n * Tear down all data scoped to a value using Drizzle ORM.\n */\nexport async function teardown(\n db: DrizzleDB,\n tableMap: Map<string, unknown>,\n schema: SchemaInfo,\n scopeValue: string,\n eq: (col: any, val: any) => any,\n): Promise<void> {\n const modelNames = schema.models.map((m) => m.name)\n const { sorted, cycles } = topoSort(modelNames, schema.edges)\n\n // Break cycles by nullifying deferrable FKs\n for (const cycle of cycles) {\n const edge = findDeferrableEdge(cycle, schema.edges)\n if (edge) {\n const table = tableMap.get(edge.from)\n if (table) {\n await db\n .update(table)\n .set({ [edge.localField]: null })\n .where(eq((table as any)[schema.scopeField], scopeValue))\n }\n }\n }\n\n // Delete cycle nodes\n for (const cycle of cycles) {\n for (const model of cycle) {\n await deleteModel(db, tableMap, model, schema.scopeField, scopeValue, eq)\n }\n }\n\n // Delete in reverse topo order\n const reversed = [...sorted].reverse()\n for (const model of reversed) {\n await deleteModel(db, tableMap, model, schema.scopeField, scopeValue, eq)\n }\n}\n\nasync function deleteModel(\n db: DrizzleDB,\n tableMap: Map<string, unknown>,\n model: string,\n scopeField: string,\n scopeValue: string,\n eq: (col: any, val: any) => any,\n): Promise<void> {\n const table = tableMap.get(model)\n if (!table) return\n\n await db.delete(table).where(eq((table as any)[scopeField], scopeValue))\n}\n","import type { OrmAdapter, SchemaInfo, ResolvedEntitySpec, CreateContext } from '@autonoma-ai/sdk'\nimport { introspectDrizzle, type DrizzleAdapterConfig } from './introspect'\nimport { createEntities } from './create'\nimport { teardown } from './teardown'\n\nexport type { DrizzleAdapterConfig }\n\n/**\n * Create a Drizzle ORM adapter for the Autonoma SDK.\n *\n * @example\n * ```ts\n * import { drizzleAdapter } from '@autonoma-ai/sdk-drizzle'\n * import { db } from '~/db'\n * import * as schema from '~/db/schema'\n *\n * const adapter = drizzleAdapter(db, schema, { scopeField: 'organizationId' })\n * ```\n */\nexport function drizzleAdapter(\n db: any,\n schema: Record<string, unknown>,\n config: DrizzleAdapterConfig,\n): OrmAdapter {\n let cachedSchema: SchemaInfo | null = null\n const tableMap = buildTableMap(schema)\n\n return {\n getSchema() {\n if (!cachedSchema) {\n cachedSchema = introspectDrizzle(schema, config)\n }\n return cachedSchema\n },\n\n async createEntities(\n spec: Record<string, ResolvedEntitySpec>,\n context: CreateContext,\n ) {\n return createEntities(db, tableMap, spec, context)\n },\n\n async teardown(scopeValue: string) {\n const schemaInfo = this.getSchema()\n // Import eq from drizzle-orm dynamically\n const { eq } = await import('drizzle-orm')\n return teardown(db, tableMap, schemaInfo, scopeValue, eq)\n },\n }\n}\n\nfunction buildTableMap(schema: Record<string, unknown>): Map<string, unknown> {\n const map = new Map<string, unknown>()\n for (const [key, value] of Object.entries(schema)) {\n if (isTable(value)) {\n // Use the Drizzle table name or the export key\n const name = getTableName(value, key)\n map.set(name, value)\n }\n }\n return map\n}\n\nfunction isTable(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false\n const v = value as Record<string | symbol, unknown>\n return (\n Symbol.for('drizzle:Name') in v ||\n (v._ != null && typeof v._ === 'object' && 'columns' in (v._ as object))\n )\n}\n\nfunction getTableName(table: unknown, fallback: string): string {\n const sym = Symbol.for('drizzle:Name')\n if (table && typeof table === 'object' && sym in table) {\n return (table as any)[sym] as string\n }\n const t = table as any\n if (t._?.name) return t._.name\n return fallback\n}\n"],"mappings":";AA8BO,SAAS,kBACd,QACA,QACY;AACZ,QAAM,SAAsB,CAAC;AAC7B,QAAM,QAAkB,CAAC;AACzB,QAAM,SAAS,oBAAI,IAA0B;AAG7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO,IAAI,KAAK,KAAqB;AAAA,IACvC;AAAA,EACF;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,QAAQ;AACjC,UAAM,YAAY,aAAa,OAAO,GAAG;AACzC,UAAM,UAAU,gBAAgB,KAAK;AACrC,UAAM,SAAsB,CAAC;AAE7B,eAAW,CAAC,SAAS,GAAG,KAAK,OAAO,QAAQ,OAAO,GAAG;AACpD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,MAAM,IAAI;AAAA,QACV,YAAY,IAAI;AAAA,QAChB,MAAM,IAAI;AAAA,QACV,YAAY,IAAI;AAAA,MAClB,CAAC;AAAA,IACH;AAEA,WAAO,KAAK,EAAE,MAAM,WAAW,OAAO,CAAC;AAAA,EACzC;AAGA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,YAAY,KAAK,GAAG;AACtB,YAAM,OAAO,iBAAiB,KAAK;AACnC,iBAAW,OAAO,MAAM;AACtB,YAAI,IAAI,SAAS,UAAU,IAAI,gBAAgB,QAAQ;AACrD,gBAAM,KAAK;AAAA,YACT,MAAM,uBAAuB,KAAK,MAAM;AAAA,YACxC,IAAI,IAAI;AAAA,YACR,YAAY,IAAI,QAAQ,CAAC,EAAG;AAAA,YAC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A,SAASC,cAAa,OAAgB,UAA0B;AAC9D,QAAM,MAAM,uBAAO,IAAI,cAAc;AACrC,MAAI,SAAS,OAAO,UAAU,YAAY,OAAO,OAAO;AACtD,WAAQ,MAAc,GAAG;AAAA,EAC3B;AACA,QAAM,IAAI;AACV,MAAI,EAAE,GAAG,KAAM,QAAO,EAAE,EAAE;AAC1B,SAAO;AACT;","names":["isTable","getTableName"]}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@autonoma-ai/sdk-drizzle",
3
+ "version": "0.1.0",
4
+ "description": "Drizzle adapter for Autonoma SDK",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./dist/index.d.ts"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "dependencies": {
19
+ "@autonoma-ai/sdk": "0.1.0"
20
+ },
21
+ "peerDependencies": {
22
+ "drizzle-orm": ">=0.30.0"
23
+ },
24
+ "peerDependenciesMeta": {
25
+ "drizzle-orm": {
26
+ "optional": false
27
+ }
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "typescript": "^5.7.0",
32
+ "vitest": "^3.0.0",
33
+ "tsup": "^8.4.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "test": "vitest run --passWithNoTests",
38
+ "test:unit": "vitest run",
39
+ "clean": "rm -rf dist"
40
+ }
41
+ }