@stonyx/orm 0.3.2-beta.7 → 0.3.2-beta.71
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/README.md +35 -2
- package/config/environment.js +8 -0
- package/dist/commands.js +34 -0
- package/dist/dynamodb/connection.d.ts +30 -0
- package/dist/dynamodb/connection.js +28 -0
- package/dist/dynamodb/dynamodb-db.d.ts +131 -0
- package/dist/dynamodb/dynamodb-db.js +556 -0
- package/dist/dynamodb/operation-builder.d.ts +76 -0
- package/dist/dynamodb/operation-builder.js +109 -0
- package/dist/dynamodb/type-map.d.ts +31 -0
- package/dist/dynamodb/type-map.js +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/main.d.ts +16 -0
- package/dist/main.js +36 -0
- package/dist/manage-record.js +45 -6
- package/dist/postgres/connection.d.ts +1 -0
- package/dist/postgres/connection.js +8 -6
- package/dist/serializer.js +27 -2
- package/dist/store.js +6 -1
- package/dist/types/orm-types.d.ts +8 -0
- package/package.json +17 -7
- package/src/commands.ts +43 -0
- package/src/dynamodb/connection.ts +49 -0
- package/src/dynamodb/dynamodb-db.ts +768 -0
- package/src/dynamodb/operation-builder.ts +188 -0
- package/src/dynamodb/type-map.ts +54 -0
- package/src/index.ts +1 -0
- package/src/main.ts +45 -0
- package/src/manage-record.ts +46 -7
- package/src/postgres/connection.ts +10 -6
- package/src/serializer.ts +27 -2
- package/src/store.ts +6 -1
- package/src/types/orm-types.ts +9 -0
- package/src/types/stonyx.d.ts +7 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamoDB connection factory.
|
|
3
|
+
*
|
|
4
|
+
* Dynamically imports @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb
|
|
5
|
+
* so these are optional peerDependencies (matching the pg/mysql2 pattern).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface DynamoDBConfig {
|
|
9
|
+
region?: string;
|
|
10
|
+
endpoint?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Type aliases — declared loose so we don't need to import the real SDK types
|
|
15
|
+
// at compile time (they're optional peer deps).
|
|
16
|
+
export type DocumentClient = {
|
|
17
|
+
send(command: unknown): Promise<unknown>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type DynamoDBClientConstructor = new (options: unknown) => { config: unknown };
|
|
21
|
+
export type DocumentClientFromFn = { from(client: unknown): DocumentClient };
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a DynamoDBDocumentClient from the given config.
|
|
25
|
+
* Uses dynamic import so @aws-sdk/* are optional peer deps.
|
|
26
|
+
*/
|
|
27
|
+
export async function createDocumentClient(dbConfig: DynamoDBConfig): Promise<DocumentClient> {
|
|
28
|
+
const { DynamoDBClient } = await import('@aws-sdk/client-dynamodb' as string) as {
|
|
29
|
+
DynamoDBClient: DynamoDBClientConstructor;
|
|
30
|
+
};
|
|
31
|
+
const { DynamoDBDocumentClient } = await import('@aws-sdk/lib-dynamodb' as string) as {
|
|
32
|
+
DynamoDBDocumentClient: DocumentClientFromFn;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const clientOptions: Record<string, unknown> = {};
|
|
36
|
+
if (dbConfig.region) clientOptions.region = dbConfig.region;
|
|
37
|
+
if (dbConfig.endpoint) clientOptions.endpoint = dbConfig.endpoint;
|
|
38
|
+
|
|
39
|
+
const rawClient = new DynamoDBClient(clientOptions);
|
|
40
|
+
return DynamoDBDocumentClient.from(rawClient);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Nullify the document client reference (DynamoDB connections are HTTP-based
|
|
45
|
+
* and stateless — no explicit pool close needed, but we clear the reference).
|
|
46
|
+
*/
|
|
47
|
+
export function destroyDocumentClient(_client: DocumentClient | null): null {
|
|
48
|
+
return null;
|
|
49
|
+
}
|