@oino-ts/nosql-aws 1.0.2 → 1.0.4
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.
|
@@ -129,6 +129,12 @@ class OINONoSqlAwsDynamo extends nosql_1.OINONoSql {
|
|
|
129
129
|
_hashKeyAttr = "partitionKey";
|
|
130
130
|
/** Actual DynamoDB RANGE key attribute name, discovered during validate(). */
|
|
131
131
|
_rangeKeyAttr = "rowKey";
|
|
132
|
+
constructor(params) {
|
|
133
|
+
super(params);
|
|
134
|
+
if (!this.nosqlParams.credentials?.region || !this.nosqlParams.credentials?.accessKeyId || !this.nosqlParams.credentials?.secretAccessKey) {
|
|
135
|
+
throw new Error("OINONoSqlAwsDynamo: missing or invalid credentials (provide credentials.region, credentials.accessKeyId, credentials.secretAccessKey)");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
132
138
|
// ── FilterExpression translation ──────────────────────────────────────
|
|
133
139
|
/**
|
|
134
140
|
* Walk the `OINOQueryFilter` tree and attempt to build a DynamoDB
|
|
@@ -248,41 +254,16 @@ class OINONoSqlAwsDynamo extends nosql_1.OINONoSql {
|
|
|
248
254
|
* `connectionStr`. Does not perform any network call.
|
|
249
255
|
*/
|
|
250
256
|
async connect() {
|
|
251
|
-
if (!this.nosqlParams.connectionStr) {
|
|
252
|
-
return new common_1.OINOResult({
|
|
253
|
-
success: false,
|
|
254
|
-
status: 400,
|
|
255
|
-
statusText: "OINONoSqlAwsDynamoDB: params.connectionStr is required (JSON with region, accessKeyId, secretAccessKey)"
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
let creds;
|
|
259
|
-
try {
|
|
260
|
-
creds = JSON.parse(this.nosqlParams.connectionStr);
|
|
261
|
-
}
|
|
262
|
-
catch {
|
|
263
|
-
return new common_1.OINOResult({
|
|
264
|
-
success: false,
|
|
265
|
-
status: 400,
|
|
266
|
-
statusText: "OINONoSqlAwsDynamoDB: params.connectionStr must be valid JSON"
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
if (!creds.region || !creds.accessKeyId || !creds.secretAccessKey) {
|
|
270
|
-
return new common_1.OINOResult({
|
|
271
|
-
success: false,
|
|
272
|
-
status: 400,
|
|
273
|
-
statusText: "OINONoSqlAwsDynamoDB: connectionStr must contain region, accessKeyId, and secretAccessKey"
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
257
|
try {
|
|
277
258
|
const client_config = {
|
|
278
|
-
region:
|
|
259
|
+
region: this.nosqlParams.credentials.region,
|
|
279
260
|
credentials: {
|
|
280
|
-
accessKeyId:
|
|
281
|
-
secretAccessKey:
|
|
261
|
+
accessKeyId: this.nosqlParams.credentials.accessKeyId,
|
|
262
|
+
secretAccessKey: this.nosqlParams.credentials.secretAccessKey
|
|
282
263
|
}
|
|
283
264
|
};
|
|
284
|
-
if (this.nosqlParams.url) {
|
|
285
|
-
client_config.endpoint = this.nosqlParams.url;
|
|
265
|
+
if (this.nosqlParams.credentials.url) {
|
|
266
|
+
client_config.endpoint = this.nosqlParams.credentials.url;
|
|
286
267
|
}
|
|
287
268
|
const raw_client = new client_dynamodb_1.DynamoDBClient(client_config);
|
|
288
269
|
this._rawClient = raw_client;
|
|
@@ -126,6 +126,12 @@ export class OINONoSqlAwsDynamo extends OINONoSql {
|
|
|
126
126
|
_hashKeyAttr = "partitionKey";
|
|
127
127
|
/** Actual DynamoDB RANGE key attribute name, discovered during validate(). */
|
|
128
128
|
_rangeKeyAttr = "rowKey";
|
|
129
|
+
constructor(params) {
|
|
130
|
+
super(params);
|
|
131
|
+
if (!this.nosqlParams.credentials?.region || !this.nosqlParams.credentials?.accessKeyId || !this.nosqlParams.credentials?.secretAccessKey) {
|
|
132
|
+
throw new Error("OINONoSqlAwsDynamo: missing or invalid credentials (provide credentials.region, credentials.accessKeyId, credentials.secretAccessKey)");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
129
135
|
// ── FilterExpression translation ──────────────────────────────────────
|
|
130
136
|
/**
|
|
131
137
|
* Walk the `OINOQueryFilter` tree and attempt to build a DynamoDB
|
|
@@ -245,41 +251,16 @@ export class OINONoSqlAwsDynamo extends OINONoSql {
|
|
|
245
251
|
* `connectionStr`. Does not perform any network call.
|
|
246
252
|
*/
|
|
247
253
|
async connect() {
|
|
248
|
-
if (!this.nosqlParams.connectionStr) {
|
|
249
|
-
return new OINOResult({
|
|
250
|
-
success: false,
|
|
251
|
-
status: 400,
|
|
252
|
-
statusText: "OINONoSqlAwsDynamoDB: params.connectionStr is required (JSON with region, accessKeyId, secretAccessKey)"
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
let creds;
|
|
256
|
-
try {
|
|
257
|
-
creds = JSON.parse(this.nosqlParams.connectionStr);
|
|
258
|
-
}
|
|
259
|
-
catch {
|
|
260
|
-
return new OINOResult({
|
|
261
|
-
success: false,
|
|
262
|
-
status: 400,
|
|
263
|
-
statusText: "OINONoSqlAwsDynamoDB: params.connectionStr must be valid JSON"
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
if (!creds.region || !creds.accessKeyId || !creds.secretAccessKey) {
|
|
267
|
-
return new OINOResult({
|
|
268
|
-
success: false,
|
|
269
|
-
status: 400,
|
|
270
|
-
statusText: "OINONoSqlAwsDynamoDB: connectionStr must contain region, accessKeyId, and secretAccessKey"
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
254
|
try {
|
|
274
255
|
const client_config = {
|
|
275
|
-
region:
|
|
256
|
+
region: this.nosqlParams.credentials.region,
|
|
276
257
|
credentials: {
|
|
277
|
-
accessKeyId:
|
|
278
|
-
secretAccessKey:
|
|
258
|
+
accessKeyId: this.nosqlParams.credentials.accessKeyId,
|
|
259
|
+
secretAccessKey: this.nosqlParams.credentials.secretAccessKey
|
|
279
260
|
}
|
|
280
261
|
};
|
|
281
|
-
if (this.nosqlParams.url) {
|
|
282
|
-
client_config.endpoint = this.nosqlParams.url;
|
|
262
|
+
if (this.nosqlParams.credentials.url) {
|
|
263
|
+
client_config.endpoint = this.nosqlParams.credentials.url;
|
|
283
264
|
}
|
|
284
265
|
const raw_client = new DynamoDBClient(client_config);
|
|
285
266
|
this._rawClient = raw_client;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OINOApi, OINOResult, OINOQueryFilter } from "@oino-ts/common";
|
|
2
|
-
import { OINONoSql } from "@oino-ts/nosql";
|
|
2
|
+
import { OINONoSql, OINONoSqlParams } from "@oino-ts/nosql";
|
|
3
3
|
import { type OINONoSqlEntry } from "@oino-ts/nosql";
|
|
4
4
|
/**
|
|
5
5
|
* Mutable accumulator used while building a DynamoDB expression string.
|
|
@@ -96,6 +96,7 @@ export declare class OINONoSqlAwsDynamo extends OINONoSql {
|
|
|
96
96
|
private _hashKeyAttr;
|
|
97
97
|
/** Actual DynamoDB RANGE key attribute name, discovered during validate(). */
|
|
98
98
|
private _rangeKeyAttr;
|
|
99
|
+
constructor(params: OINONoSqlParams);
|
|
99
100
|
/**
|
|
100
101
|
* Walk the `OINOQueryFilter` tree and attempt to build a DynamoDB
|
|
101
102
|
* `FilterExpression` string, accumulating placeholder names and values
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/nosql-aws",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "OINO TS package for using AWS DynamoDB as a REST API.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@aws-sdk/client-dynamodb": "^3.0.0",
|
|
25
25
|
"@aws-sdk/lib-dynamodb": "^3.0.0",
|
|
26
|
-
"@oino-ts/nosql": "1.0.
|
|
27
|
-
"@oino-ts/common": "1.0.
|
|
26
|
+
"@oino-ts/nosql": "1.0.4",
|
|
27
|
+
"@oino-ts/common": "1.0.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@oino-ts/types": "1.0.
|
|
30
|
+
"@oino-ts/types": "1.0.4",
|
|
31
31
|
"@types/bun": "^1.1.14",
|
|
32
32
|
"@types/node": "^22.0.00",
|
|
33
33
|
"typescript": "~5.9.0"
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "@aws-sdk/lib-dynamodb"
|
|
23
23
|
|
|
24
24
|
import { OINOApi, OINOResult, OINOQueryFilter, OINOQueryBooleanOperation, OINOQueryComparison, OINOQueryNullCheck, OINOStringDataField, OINODatetimeDataField, type OINODataFieldParams } from "@oino-ts/common"
|
|
25
|
-
import { OINONoSql, OINONoSqlDataModel, OINONoSqlApi } from "@oino-ts/nosql"
|
|
25
|
+
import { OINONoSql, OINONoSqlDataModel, OINONoSqlApi, OINONoSqlParams } from "@oino-ts/nosql"
|
|
26
26
|
import { type OINONoSqlEntry } from "@oino-ts/nosql"
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -159,6 +159,13 @@ export class OINONoSqlAwsDynamo extends OINONoSql {
|
|
|
159
159
|
/** Actual DynamoDB RANGE key attribute name, discovered during validate(). */
|
|
160
160
|
private _rangeKeyAttr: string = "rowKey"
|
|
161
161
|
|
|
162
|
+
constructor(params: OINONoSqlParams) {
|
|
163
|
+
super(params)
|
|
164
|
+
if (!this.nosqlParams.credentials?.region || !this.nosqlParams.credentials?.accessKeyId || !this.nosqlParams.credentials?.secretAccessKey) {
|
|
165
|
+
throw new Error("OINONoSqlAwsDynamo: missing or invalid credentials (provide credentials.region, credentials.accessKeyId, credentials.secretAccessKey)")
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
162
169
|
// ── FilterExpression translation ──────────────────────────────────────
|
|
163
170
|
|
|
164
171
|
/**
|
|
@@ -281,43 +288,16 @@ export class OINONoSqlAwsDynamo extends OINONoSql {
|
|
|
281
288
|
* `connectionStr`. Does not perform any network call.
|
|
282
289
|
*/
|
|
283
290
|
async connect(): Promise<OINOResult> {
|
|
284
|
-
if (!this.nosqlParams.connectionStr) {
|
|
285
|
-
return new OINOResult({
|
|
286
|
-
success: false,
|
|
287
|
-
status: 400,
|
|
288
|
-
statusText: "OINONoSqlAwsDynamoDB: params.connectionStr is required (JSON with region, accessKeyId, secretAccessKey)"
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
let creds: { region: string; accessKeyId: string; secretAccessKey: string }
|
|
293
|
-
try {
|
|
294
|
-
creds = JSON.parse(this.nosqlParams.connectionStr) as { region: string; accessKeyId: string; secretAccessKey: string }
|
|
295
|
-
} catch {
|
|
296
|
-
return new OINOResult({
|
|
297
|
-
success: false,
|
|
298
|
-
status: 400,
|
|
299
|
-
statusText: "OINONoSqlAwsDynamoDB: params.connectionStr must be valid JSON"
|
|
300
|
-
})
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (!creds.region || !creds.accessKeyId || !creds.secretAccessKey) {
|
|
304
|
-
return new OINOResult({
|
|
305
|
-
success: false,
|
|
306
|
-
status: 400,
|
|
307
|
-
statusText: "OINONoSqlAwsDynamoDB: connectionStr must contain region, accessKeyId, and secretAccessKey"
|
|
308
|
-
})
|
|
309
|
-
}
|
|
310
|
-
|
|
311
291
|
try {
|
|
312
292
|
const client_config: ConstructorParameters<typeof DynamoDBClient>[0] = {
|
|
313
|
-
region:
|
|
293
|
+
region: this.nosqlParams.credentials.region,
|
|
314
294
|
credentials: {
|
|
315
|
-
accessKeyId:
|
|
316
|
-
secretAccessKey:
|
|
295
|
+
accessKeyId: this.nosqlParams.credentials.accessKeyId,
|
|
296
|
+
secretAccessKey: this.nosqlParams.credentials.secretAccessKey
|
|
317
297
|
}
|
|
318
298
|
}
|
|
319
|
-
if (this.nosqlParams.url) {
|
|
320
|
-
client_config.endpoint = this.nosqlParams.url
|
|
299
|
+
if (this.nosqlParams.credentials.url) {
|
|
300
|
+
client_config.endpoint = this.nosqlParams.credentials.url
|
|
321
301
|
}
|
|
322
302
|
const raw_client = new DynamoDBClient(client_config)
|
|
323
303
|
this._rawClient = raw_client
|