@autonoma-ai/sdk-prisma 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/dist/index.d.ts +20 -0
- package/dist/index.js +220 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OrmAdapter } from '@autonoma-ai/sdk';
|
|
2
|
+
|
|
3
|
+
interface PrismaAdapterConfig {
|
|
4
|
+
scopeField: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a Prisma ORM adapter for the Autonoma SDK.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { prismaAdapter } from '@autonoma-ai/sdk-prisma'
|
|
13
|
+
* import { prisma } from './db'
|
|
14
|
+
*
|
|
15
|
+
* const adapter = prismaAdapter(prisma, { scopeField: 'organizationId' })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function prismaAdapter(prisma: any, config: PrismaAdapterConfig): OrmAdapter;
|
|
19
|
+
|
|
20
|
+
export { type PrismaAdapterConfig, prismaAdapter };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// src/introspect.ts
|
|
2
|
+
function introspectPrisma(prisma, config) {
|
|
3
|
+
const dmmfModels = getDMMFModels(prisma);
|
|
4
|
+
const models = [];
|
|
5
|
+
const edges = [];
|
|
6
|
+
const relations = [];
|
|
7
|
+
for (const model of dmmfModels) {
|
|
8
|
+
const fields = [];
|
|
9
|
+
for (const field of model.fields) {
|
|
10
|
+
if (field.kind === "object") {
|
|
11
|
+
if (field.relationFromFields?.length) {
|
|
12
|
+
const localField = field.relationFromFields[0];
|
|
13
|
+
const foreignField = field.relationToFields?.[0] ?? "id";
|
|
14
|
+
edges.push({
|
|
15
|
+
from: model.name,
|
|
16
|
+
to: field.type,
|
|
17
|
+
localField,
|
|
18
|
+
foreignField,
|
|
19
|
+
nullable: !field.isRequired
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (field.kind === "enum" || field.kind === "scalar") {
|
|
25
|
+
fields.push({
|
|
26
|
+
name: field.name,
|
|
27
|
+
type: field.type,
|
|
28
|
+
isRequired: field.isRequired,
|
|
29
|
+
isId: field.isId,
|
|
30
|
+
hasDefault: field.hasDefaultValue || !!field.isUpdatedAt || !!field.isGenerated
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
models.push({ name: model.name, fields });
|
|
35
|
+
}
|
|
36
|
+
for (const model of dmmfModels) {
|
|
37
|
+
for (const field of model.fields) {
|
|
38
|
+
if (field.kind === "object" && !field.relationFromFields?.length) {
|
|
39
|
+
const childEdge = edges.find(
|
|
40
|
+
(e) => e.from === field.type && e.to === model.name && e.foreignField === "id"
|
|
41
|
+
);
|
|
42
|
+
const childEdgeByRelation = !childEdge ? edges.find((e) => {
|
|
43
|
+
if (e.from !== field.type || e.to !== model.name) return false;
|
|
44
|
+
const childModel = dmmfModels.find((m) => m.name === field.type);
|
|
45
|
+
if (!childModel) return false;
|
|
46
|
+
const childField = childModel.fields.find(
|
|
47
|
+
(f) => f.kind === "object" && f.relationName === field.relationName && f.relationFromFields?.length
|
|
48
|
+
);
|
|
49
|
+
return childField?.relationFromFields?.[0] === e.localField;
|
|
50
|
+
}) : null;
|
|
51
|
+
const edge = childEdge ?? childEdgeByRelation;
|
|
52
|
+
if (edge) {
|
|
53
|
+
relations.push({
|
|
54
|
+
parentModel: model.name,
|
|
55
|
+
childModel: field.type,
|
|
56
|
+
parentField: field.name,
|
|
57
|
+
childField: edge.localField
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const model of dmmfModels) {
|
|
64
|
+
for (const field of model.fields) {
|
|
65
|
+
if (field.kind === "object" && !field.isList && field.relationFromFields?.length) {
|
|
66
|
+
const localField = field.relationFromFields[0];
|
|
67
|
+
const alreadyCovered = relations.some(
|
|
68
|
+
(r) => r.parentModel === model.name && r.parentField === field.name
|
|
69
|
+
);
|
|
70
|
+
if (!alreadyCovered) {
|
|
71
|
+
relations.push({
|
|
72
|
+
parentModel: model.name,
|
|
73
|
+
childModel: field.type,
|
|
74
|
+
parentField: field.name,
|
|
75
|
+
childField: localField
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { models, edges, relations, scopeField: config.scopeField };
|
|
82
|
+
}
|
|
83
|
+
function getDMMFModels(prisma) {
|
|
84
|
+
if (prisma._runtimeDataModel?.models) {
|
|
85
|
+
return Object.entries(prisma._runtimeDataModel.models).map(
|
|
86
|
+
([name, model]) => ({ ...model, name })
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
if (prisma._baseDmmf?.datamodel?.models) {
|
|
90
|
+
return prisma._baseDmmf.datamodel.models;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(
|
|
93
|
+
"Cannot introspect Prisma schema. Ensure @prisma/client is generated."
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/create.ts
|
|
98
|
+
async function createEntities(prisma, spec, _context) {
|
|
99
|
+
const results = {};
|
|
100
|
+
await prisma.$transaction(async (tx) => {
|
|
101
|
+
for (const [model, entitySpec] of Object.entries(spec)) {
|
|
102
|
+
const delegate = tx[camelCase(model)];
|
|
103
|
+
if (!delegate) {
|
|
104
|
+
throw new Error(`Prisma model '${model}' not found. Check model name casing.`);
|
|
105
|
+
}
|
|
106
|
+
if (entitySpec.batch) {
|
|
107
|
+
await delegate.createMany({ data: entitySpec.fields });
|
|
108
|
+
results[model] = [];
|
|
109
|
+
} else {
|
|
110
|
+
const created = [];
|
|
111
|
+
for (const fields of entitySpec.fields) {
|
|
112
|
+
const record = await delegate.create({ data: fields });
|
|
113
|
+
created.push(record);
|
|
114
|
+
}
|
|
115
|
+
results[model] = created;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
function camelCase(str) {
|
|
122
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/teardown.ts
|
|
126
|
+
import { topoSort, findDeferrableEdge } from "@autonoma-ai/sdk";
|
|
127
|
+
async function teardown(prisma, schema, scopeValue, refs) {
|
|
128
|
+
let scopeRootModel = null;
|
|
129
|
+
for (const edge of schema.edges) {
|
|
130
|
+
if (edge.localField.toLowerCase() === schema.scopeField.toLowerCase() && edge.to !== edge.from) {
|
|
131
|
+
scopeRootModel = edge.to;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const scopeFieldByModel = /* @__PURE__ */ new Map();
|
|
136
|
+
if (scopeRootModel) {
|
|
137
|
+
for (const edge of schema.edges) {
|
|
138
|
+
if (edge.to === scopeRootModel && edge.from !== scopeRootModel) {
|
|
139
|
+
scopeFieldByModel.set(edge.from, edge.localField);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const modelNames = schema.models.map((m) => m.name);
|
|
144
|
+
const { sorted, cycles } = topoSort(modelNames, schema.edges);
|
|
145
|
+
await prisma.$transaction(async (tx) => {
|
|
146
|
+
for (const cycle of cycles) {
|
|
147
|
+
const edge = findDeferrableEdge(cycle, schema.edges);
|
|
148
|
+
if (edge) {
|
|
149
|
+
const scopeFK = scopeFieldByModel.get(edge.from);
|
|
150
|
+
if (scopeFK) {
|
|
151
|
+
const delegate = tx[camelCase2(edge.from)];
|
|
152
|
+
if (delegate) {
|
|
153
|
+
await delegate.updateMany({
|
|
154
|
+
where: { [scopeFK]: scopeValue },
|
|
155
|
+
data: { [edge.localField]: null }
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const cycle of cycles) {
|
|
162
|
+
for (const model of cycle) {
|
|
163
|
+
await deleteModel(tx, model, scopeValue, scopeFieldByModel, refs);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const reversed = [...sorted].reverse();
|
|
167
|
+
for (const model of reversed) {
|
|
168
|
+
if (model === scopeRootModel) continue;
|
|
169
|
+
await deleteModel(tx, model, scopeValue, scopeFieldByModel, refs);
|
|
170
|
+
}
|
|
171
|
+
if (scopeRootModel) {
|
|
172
|
+
const delegate = tx[camelCase2(scopeRootModel)];
|
|
173
|
+
if (delegate) {
|
|
174
|
+
await delegate.deleteMany({ where: { id: scopeValue } });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
async function deleteModel(tx, model, scopeValue, scopeFieldByModel, refs) {
|
|
180
|
+
const delegate = tx[camelCase2(model)];
|
|
181
|
+
if (!delegate) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const scopeFK = scopeFieldByModel.get(model);
|
|
185
|
+
if (scopeFK) {
|
|
186
|
+
await delegate.deleteMany({ where: { [scopeFK]: scopeValue } });
|
|
187
|
+
} else if (refs?.[model]) {
|
|
188
|
+
const ids = refs[model].map((r) => r.id).filter((id) => typeof id === "string");
|
|
189
|
+
if (ids.length > 0) {
|
|
190
|
+
await delegate.deleteMany({ where: { id: { in: ids } } });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function camelCase2(str) {
|
|
195
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/index.ts
|
|
199
|
+
function prismaAdapter(prisma, config) {
|
|
200
|
+
let cachedSchema = null;
|
|
201
|
+
return {
|
|
202
|
+
getSchema() {
|
|
203
|
+
if (!cachedSchema) {
|
|
204
|
+
cachedSchema = introspectPrisma(prisma, config);
|
|
205
|
+
}
|
|
206
|
+
return cachedSchema;
|
|
207
|
+
},
|
|
208
|
+
async createEntities(spec, context) {
|
|
209
|
+
return createEntities(prisma, spec, context);
|
|
210
|
+
},
|
|
211
|
+
async teardown(scopeValue, refs) {
|
|
212
|
+
const schema = this.getSchema();
|
|
213
|
+
return teardown(prisma, schema, scopeValue, refs);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
export {
|
|
218
|
+
prismaAdapter
|
|
219
|
+
};
|
|
220
|
+
//# 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, ModelInfo, FieldInfo, FKEdge, SchemaRelation } from '@autonoma-ai/sdk'\n\ninterface PrismaClient {\n _runtimeDataModel?: { models: Record<string, DMMFModel> }\n _baseDmmf?: { datamodel: { models: DMMFModel[] } }\n}\n\ninterface DMMFModel {\n name: string\n fields: DMMFField[]\n}\n\ninterface DMMFField {\n name: string\n type: string\n kind: string\n isList?: boolean\n isRequired: boolean\n isId: boolean\n hasDefaultValue: boolean\n isUpdatedAt?: boolean\n isGenerated?: boolean\n relationFromFields?: string[]\n relationToFields?: string[]\n relationName?: string\n}\n\nexport interface PrismaAdapterConfig {\n scopeField: string\n}\n\n/**\n * Introspect Prisma DMMF to extract schema metadata.\n */\nexport function introspectPrisma(\n prisma: PrismaClient,\n config: PrismaAdapterConfig,\n): SchemaInfo {\n const dmmfModels = getDMMFModels(prisma)\n const models: ModelInfo[] = []\n const edges: FKEdge[] = []\n const relations: SchemaRelation[] = []\n\n // First pass: extract scalar fields and FK edges\n for (const model of dmmfModels) {\n const fields: FieldInfo[] = []\n\n for (const field of model.fields) {\n if (field.kind === 'object') {\n // FK edge: this model holds a FK pointing to another model\n if (field.relationFromFields?.length) {\n const localField = field.relationFromFields[0]!\n const foreignField = field.relationToFields?.[0] ?? 'id'\n edges.push({\n from: model.name,\n to: field.type,\n localField,\n foreignField,\n nullable: !field.isRequired,\n })\n }\n continue\n }\n\n if (field.kind === 'enum' || field.kind === 'scalar') {\n fields.push({\n name: field.name,\n type: field.type,\n isRequired: field.isRequired,\n isId: field.isId,\n hasDefault: field.hasDefaultValue || !!field.isUpdatedAt || !!field.isGenerated,\n })\n }\n }\n\n models.push({ name: model.name, fields })\n }\n\n // Second pass: extract relation names (parent → child list mappings)\n // A relation field that is a list and has NO relationFromFields means it's the parent side\n for (const model of dmmfModels) {\n for (const field of model.fields) {\n if (field.kind === 'object' && !field.relationFromFields?.length) {\n // This is the parent side of a relation (no FK here):\n // - isList: true → one-to-many (Organization.members → Member[])\n // - isList: false → one-to-one (Application.webApplicationData → WebApplicationData)\n // This is the parent side: e.g. Organization.applications → Application[]\n // Find the corresponding FK edge on the child\n const childEdge = edges.find(\n (e) => e.from === field.type && e.to === model.name && e.foreignField === 'id',\n )\n // Also try matching by relationName\n const childEdgeByRelation = !childEdge\n ? edges.find((e) => {\n if (e.from !== field.type || e.to !== model.name) return false\n // Match via DMMF relation name\n const childModel = dmmfModels.find((m) => m.name === field.type)\n if (!childModel) return false\n const childField = childModel.fields.find(\n (f) => f.kind === 'object' && f.relationName === field.relationName && f.relationFromFields?.length,\n )\n return childField?.relationFromFields?.[0] === e.localField\n })\n : null\n\n const edge = childEdge ?? childEdgeByRelation\n if (edge) {\n relations.push({\n parentModel: model.name,\n childModel: field.type,\n parentField: field.name,\n childField: edge.localField,\n })\n }\n }\n }\n }\n\n // Third pass: extract singular relations where the FK is on the current model\n // e.g. Member.user → User (Member holds userId FK, user is not a list)\n for (const model of dmmfModels) {\n for (const field of model.fields) {\n if (field.kind === 'object' && !field.isList && field.relationFromFields?.length) {\n const localField = field.relationFromFields[0]!\n // Check this isn't already covered by a list relation\n const alreadyCovered = relations.some(\n (r) => r.parentModel === model.name && r.parentField === field.name,\n )\n if (!alreadyCovered) {\n relations.push({\n parentModel: model.name,\n childModel: field.type,\n parentField: field.name,\n childField: localField,\n })\n }\n }\n }\n }\n\n return { models, edges, relations, scopeField: config.scopeField }\n}\n\nfunction getDMMFModels(prisma: PrismaClient): DMMFModel[] {\n if (prisma._runtimeDataModel?.models) {\n return Object.entries(prisma._runtimeDataModel.models).map(\n ([name, model]) => ({ ...model, name }),\n )\n }\n\n if (prisma._baseDmmf?.datamodel?.models) {\n return prisma._baseDmmf.datamodel.models\n }\n\n throw new Error(\n 'Cannot introspect Prisma schema. Ensure @prisma/client is generated.',\n )\n}\n","import type { ResolvedEntitySpec, CreateContext } from '@autonoma-ai/sdk'\n\ntype PrismaClient = Record<string, any>\n\n/**\n * Create entities using Prisma client.\n *\n * - Normal mode: individual create() calls, returns all created records (available in refs)\n * - Batch mode: single createMany() call, much faster for large counts but returns empty array\n */\nexport async function createEntities(\n prisma: PrismaClient,\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 await prisma.$transaction(async (tx: PrismaClient) => {\n for (const [model, entitySpec] of Object.entries(spec)) {\n const delegate = tx[camelCase(model)]\n if (!delegate) {\n throw new Error(`Prisma model '${model}' not found. Check model name casing.`)\n }\n\n if (entitySpec.batch) {\n // Batch: single createMany call — fast, but no records returned\n await delegate.createMany({ data: entitySpec.fields })\n results[model] = []\n } else {\n // Normal: individual creates — returns records for refs\n const created: Record<string, unknown>[] = []\n for (const fields of entitySpec.fields) {\n const record = await delegate.create({ data: fields })\n created.push(record)\n }\n results[model] = created\n }\n }\n })\n\n return results\n}\n\nfunction camelCase(str: string): string {\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import type { SchemaInfo, FKEdge } from '@autonoma-ai/sdk'\nimport { topoSort, findDeferrableEdge } from '@autonoma-ai/sdk'\n\ntype PrismaClient = Record<string, any>\n\n/**\n * Tear down all data scoped to a value, in reverse topological order.\n *\n * Strategy:\n * 1. Find the scope root model (e.g. Organization) from FK edges\n * 2. Any model with a FK pointing to the scope root is a \"scoped model\"\n * 3. Delete scoped models by their FK = scopeValue (regardless of field name casing)\n * 4. Delete non-scoped models by their record IDs from refs\n * 5. Delete the scope root entity last by id = scopeValue\n */\nexport async function teardown(\n prisma: PrismaClient,\n schema: SchemaInfo,\n scopeValue: string,\n refs?: Record<string, Record<string, unknown>[]>,\n): Promise<void> {\n // Find scope root: the model that the scopeField FK points TO\n // e.g. scopeField = \"organizationID\", edges have { to: \"Organization\" } → root is Organization\n let scopeRootModel: string | null = null\n for (const edge of schema.edges) {\n if (edge.localField.toLowerCase() === schema.scopeField.toLowerCase() && edge.to !== edge.from) {\n scopeRootModel = edge.to\n break\n }\n }\n\n // Build map: model → FK field name that points to the scope root\n // Handles mixed casing (organizationId vs organizationID)\n const scopeFieldByModel = new Map<string, string>()\n if (scopeRootModel) {\n for (const edge of schema.edges) {\n if (edge.to === scopeRootModel && edge.from !== scopeRootModel) {\n scopeFieldByModel.set(edge.from, edge.localField)\n }\n }\n }\n\n const modelNames = schema.models.map((m) => m.name)\n const { sorted, cycles } = topoSort(modelNames, schema.edges)\n\n await prisma.$transaction(async (tx: PrismaClient) => {\n // Break cycles\n for (const cycle of cycles) {\n const edge = findDeferrableEdge(cycle, schema.edges)\n if (edge) {\n const scopeFK = scopeFieldByModel.get(edge.from)\n if (scopeFK) {\n const delegate = tx[camelCase(edge.from)]\n if (delegate) {\n await delegate.updateMany({\n where: { [scopeFK]: scopeValue },\n data: { [edge.localField]: null },\n })\n }\n }\n }\n }\n\n // Delete cycle nodes\n for (const cycle of cycles) {\n for (const model of cycle) {\n await deleteModel(tx, model, scopeValue, scopeFieldByModel, refs)\n }\n }\n\n // Delete in reverse topo order (dependents first)\n const reversed = [...sorted].reverse()\n for (const model of reversed) {\n if (model === scopeRootModel) continue // deleted last\n await deleteModel(tx, model, scopeValue, scopeFieldByModel, refs)\n }\n\n // Delete the scope root entity last\n if (scopeRootModel) {\n const delegate = tx[camelCase(scopeRootModel)]\n if (delegate) {\n await delegate.deleteMany({ where: { id: scopeValue } })\n }\n }\n })\n}\n\nasync function deleteModel(\n tx: PrismaClient,\n model: string,\n scopeValue: string,\n scopeFieldByModel: Map<string, string>,\n refs?: Record<string, Record<string, unknown>[]>,\n): Promise<void> {\n const delegate = tx[camelCase(model)]\n if (!delegate) {\n return\n }\n\n const scopeFK = scopeFieldByModel.get(model)\n if (scopeFK) {\n // Has FK to scope root → delete by that FK\n await delegate.deleteMany({ where: { [scopeFK]: scopeValue } })\n } else if (refs?.[model]) {\n // No FK to scope root, but we created records → delete by IDs\n const ids = refs[model]\n .map((r) => r.id)\n .filter((id): id is string => typeof id === 'string')\n if (ids.length > 0) {\n await delegate.deleteMany({ where: { id: { in: ids } } })\n }\n }\n}\n\nfunction camelCase(str: string): string {\n return str.charAt(0).toLowerCase() + str.slice(1)\n}\n","import type { OrmAdapter, SchemaInfo, ResolvedEntitySpec, CreateContext } from '@autonoma-ai/sdk'\nimport { introspectPrisma, type PrismaAdapterConfig } from './introspect'\nimport { createEntities } from './create'\nimport { teardown } from './teardown'\n\nexport type { PrismaAdapterConfig }\n\n/**\n * Create a Prisma ORM adapter for the Autonoma SDK.\n *\n * @example\n * ```ts\n * import { prismaAdapter } from '@autonoma-ai/sdk-prisma'\n * import { prisma } from './db'\n *\n * const adapter = prismaAdapter(prisma, { scopeField: 'organizationId' })\n * ```\n */\nexport function prismaAdapter(\n prisma: any,\n config: PrismaAdapterConfig,\n): OrmAdapter {\n let cachedSchema: SchemaInfo | null = null\n\n return {\n getSchema() {\n if (!cachedSchema) {\n cachedSchema = introspectPrisma(prisma, config)\n }\n return cachedSchema\n },\n\n async createEntities(\n spec: Record<string, ResolvedEntitySpec>,\n context: CreateContext,\n ) {\n return createEntities(prisma, spec, context)\n },\n\n async teardown(scopeValue: string, refs?: Record<string, Record<string, unknown>[]>) {\n const schema = this.getSchema()\n return teardown(prisma, schema, scopeValue, refs)\n },\n }\n}\n"],"mappings":";AAkCO,SAAS,iB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f,QAAM,WAAW,GAAGA,WAAU,KAAK,CAAC;AACpC,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,QAAM,UAAU,kBAAkB,IAAI,KAAK;AAC3C,MAAI,SAAS;AAEX,UAAM,SAAS,WAAW,EAAE,OAAO,EAAE,CAAC,OAAO,GAAG,WAAW,EAAE,CAAC;AAAA,EAChE,WAAW,OAAO,KAAK,GAAG;AAExB,UAAM,MAAM,KAAK,KAAK,EACnB,IAAI,CAAC,MAAM,EAAE,EAAE,EACf,OAAO,CAAC,OAAqB,OAAO,OAAO,QAAQ;AACtD,QAAI,IAAI,SAAS,GAAG;AAClB,YAAM,SAAS,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;AAEA,SAASA,WAAU,KAAqB;AACtC,SAAO,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAClD;;;AClGO,SAAS,cACd,QACA,QACY;AACZ,MAAI,eAAkC;AAEtC,SAAO;AAAA,IACL,YAAY;AACV,UAAI,CAAC,cAAc;AACjB,uBAAe,iBAAiB,QAAQ,MAAM;AAAA,MAChD;AACA,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,eACJ,MACA,SACA;AACA,aAAO,eAAe,QAAQ,MAAM,OAAO;AAAA,IAC7C;AAAA,IAEA,MAAM,SAAS,YAAoB,MAAkD;AACnF,YAAM,SAAS,KAAK,UAAU;AAC9B,aAAO,SAAS,QAAQ,QAAQ,YAAY,IAAI;AAAA,IAClD;AAAA,EACF;AACF;","names":["camelCase"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autonoma-ai/sdk-prisma",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Prisma 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
|
+
"@prisma/client": ">=5.0.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependenciesMeta": {
|
|
25
|
+
"@prisma/client": {
|
|
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",
|
|
38
|
+
"test:unit": "vitest run",
|
|
39
|
+
"clean": "rm -rf dist"
|
|
40
|
+
}
|
|
41
|
+
}
|