@stonyx/orm 0.3.2-beta.67 → 0.3.2-beta.68
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.
|
@@ -12,10 +12,12 @@ export interface DynamoDBConfig {
|
|
|
12
12
|
export type DocumentClient = {
|
|
13
13
|
send(command: unknown): Promise<unknown>;
|
|
14
14
|
};
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export type
|
|
15
|
+
export type DynamoDBClientConstructor = new (options: unknown) => {
|
|
16
|
+
config: unknown;
|
|
17
|
+
};
|
|
18
|
+
export type DocumentClientFromFn = {
|
|
19
|
+
from(client: unknown): DocumentClient;
|
|
20
|
+
};
|
|
19
21
|
/**
|
|
20
22
|
* Create a DynamoDBDocumentClient from the given config.
|
|
21
23
|
* Uses dynamic import so @aws-sdk/* are optional peer deps.
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
* Uses dynamic import so @aws-sdk/* are optional peer deps.
|
|
10
10
|
*/
|
|
11
11
|
export async function createDocumentClient(dbConfig) {
|
|
12
|
-
const {
|
|
13
|
-
const {
|
|
12
|
+
const { DynamoDBClient } = await import('@aws-sdk/client-dynamodb');
|
|
13
|
+
const { DynamoDBDocumentClient } = await import('@aws-sdk/lib-dynamodb');
|
|
14
14
|
const clientOptions = {};
|
|
15
15
|
if (dbConfig.region)
|
|
16
16
|
clientOptions.region = dbConfig.region;
|
|
17
17
|
if (dbConfig.endpoint)
|
|
18
18
|
clientOptions.endpoint = dbConfig.endpoint;
|
|
19
|
-
const rawClient = new
|
|
20
|
-
return
|
|
19
|
+
const rawClient = new DynamoDBClient(clientOptions);
|
|
20
|
+
return DynamoDBDocumentClient.from(rawClient);
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Nullify the document client reference (DynamoDB connections are HTTP-based
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"stonyx-async",
|
|
5
5
|
"stonyx-module"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.3.2-beta.
|
|
7
|
+
"version": "0.3.2-beta.68",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"type": "module",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"scripts": {
|
|
104
104
|
"build": "tsc",
|
|
105
105
|
"build:test": "tsc -p tsconfig.test.json",
|
|
106
|
-
"test": "pnpm build && NODE_ENV=test node --import tsx/esm --import ./test/setup.ts node_modules/qunit/bin/qunit.js 'test/**/*-test.ts'"
|
|
106
|
+
"test": "pnpm build && NODE_ENV=test node --import tsx/esm --import ./test/setup.ts node_modules/qunit/bin/qunit.js 'test/**/*-test.ts'",
|
|
107
|
+
"test:dynamodb": "pnpm build && node --import tsx/esm --import ./test/integration/dynamodb/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/dynamodb/**/*-test.ts'"
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -17,27 +17,27 @@ export type DocumentClient = {
|
|
|
17
17
|
send(command: unknown): Promise<unknown>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type
|
|
21
|
-
export type
|
|
20
|
+
export type DynamoDBClientConstructor = new (options: unknown) => { config: unknown };
|
|
21
|
+
export type DocumentClientFromFn = { from(client: unknown): DocumentClient };
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create a DynamoDBDocumentClient from the given config.
|
|
25
25
|
* Uses dynamic import so @aws-sdk/* are optional peer deps.
|
|
26
26
|
*/
|
|
27
27
|
export async function createDocumentClient(dbConfig: DynamoDBConfig): Promise<DocumentClient> {
|
|
28
|
-
const {
|
|
29
|
-
|
|
28
|
+
const { DynamoDBClient } = await import('@aws-sdk/client-dynamodb' as string) as {
|
|
29
|
+
DynamoDBClient: DynamoDBClientConstructor;
|
|
30
30
|
};
|
|
31
|
-
const {
|
|
32
|
-
|
|
31
|
+
const { DynamoDBDocumentClient } = await import('@aws-sdk/lib-dynamodb' as string) as {
|
|
32
|
+
DynamoDBDocumentClient: DocumentClientFromFn;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const clientOptions: Record<string, unknown> = {};
|
|
36
36
|
if (dbConfig.region) clientOptions.region = dbConfig.region;
|
|
37
37
|
if (dbConfig.endpoint) clientOptions.endpoint = dbConfig.endpoint;
|
|
38
38
|
|
|
39
|
-
const rawClient = new
|
|
40
|
-
return
|
|
39
|
+
const rawClient = new DynamoDBClient(clientOptions);
|
|
40
|
+
return DynamoDBDocumentClient.from(rawClient);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|