uranio 0.1.57 → 0.1.58

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.
Files changed (47) hide show
  1. package/.uranio/dist/atom/dynamo.d.ts +43 -0
  2. package/.uranio/dist/atom/dynamo.js +135 -0
  3. package/.uranio/dist/atom/dynamo.js.map +1 -0
  4. package/.uranio/dist/atom/dynamodb.d.ts +85 -0
  5. package/.uranio/dist/atom/dynamodb.js +280 -0
  6. package/.uranio/dist/atom/dynamodb.js.map +1 -0
  7. package/.uranio/dist/atom/mongo.d.ts +43 -0
  8. package/.uranio/dist/atom/mongo.js +135 -0
  9. package/.uranio/dist/atom/mongo.js.map +1 -0
  10. package/.uranio/dist/client/dynamodb.d.ts +17 -0
  11. package/.uranio/dist/client/dynamodb.js +19 -0
  12. package/.uranio/dist/client/dynamodb.js.map +1 -0
  13. package/.uranio/dist/client/mysql.d.ts +1 -1
  14. package/.uranio/dist/client.d.ts +4 -0
  15. package/.uranio/dist/client.js +8 -1
  16. package/.uranio/dist/client.js.map +1 -1
  17. package/.uranio/dist/index.d.ts +2 -0
  18. package/.uranio/dist/index.js +3 -1
  19. package/.uranio/dist/index.js.map +1 -1
  20. package/.uranio/dist/types/atom.d.ts +2 -0
  21. package/.uranio/dist/types/atom.js.map +1 -1
  22. package/.uranio/dist/types/dynamodb.d.ts +8 -0
  23. package/.uranio/dist/types/dynamodb.js +9 -0
  24. package/.uranio/dist/types/dynamodb.js.map +1 -0
  25. package/.uranio/package.json +1 -1
  26. package/.uranio/src/atom/dynamodb.ts +500 -0
  27. package/.uranio/src/client/dynamodb.ts +25 -0
  28. package/.uranio/src/client/mysql.ts +3 -1
  29. package/.uranio/src/client.ts +7 -0
  30. package/.uranio/src/index.ts +3 -0
  31. package/.uranio/src/types/atom.ts +2 -0
  32. package/.uranio/src/types/dynamodb.ts +27 -0
  33. package/dist/cli/args/index.js +1 -2
  34. package/dist/cli/args/index.js.map +1 -1
  35. package/dist/cli/common/index.js +6 -7
  36. package/dist/cli/common/index.js.map +1 -1
  37. package/dist/cli/generate/index.js +1 -2
  38. package/dist/cli/generate/index.js.map +1 -1
  39. package/dist/cli/init/index.js +1 -2
  40. package/dist/cli/init/index.js.map +1 -1
  41. package/dist/cli/utils/object.js +2 -3
  42. package/dist/cli/utils/valid.js +6 -7
  43. package/dist/cli/utils/valid.js.map +1 -1
  44. package/dist/cli/version/index.js +1 -2
  45. package/dist/cli/version/index.js.map +1 -1
  46. package/package.json +5 -3
  47. package/dist/cli/utils/object.js.map +0 -1
@@ -0,0 +1,43 @@
1
+ /**
2
+ *
3
+ * MongoDB Atom client module
4
+ *
5
+ */
6
+ import mongodb from 'mongodb';
7
+ import * as atom_types from '../types/atom';
8
+ import * as sql_types from '../types/sql';
9
+ import * as where_types from '../types/where';
10
+ export declare class MongoDBAtomClient<S extends atom_types.mongodb_atom> {
11
+ private db;
12
+ name: string;
13
+ collection: mongodb.Collection<S>;
14
+ constructor(db: mongodb.Db, name: string);
15
+ get_atom({ where, order, }: {
16
+ where?: where_types.Where<S>;
17
+ order?: sql_types.OrderBy;
18
+ }): Promise<S | null>;
19
+ get_atoms({ where, order, limit, }: {
20
+ where?: where_types.Where<S>;
21
+ order?: sql_types.OrderBy;
22
+ limit?: number;
23
+ }): Promise<S[]>;
24
+ put_atom(atom: Partial<S>): Promise<mongodb.InsertOneResult>;
25
+ put_atoms(atoms: Partial<S>[]): Promise<mongodb.InsertManyResult>;
26
+ update_atom({ where, atom, }: {
27
+ where?: where_types.Where<S>;
28
+ atom: Partial<S>;
29
+ }): Promise<mongodb.UpdateResult>;
30
+ update_atoms({ where, atom, }: {
31
+ where?: where_types.Where<S>;
32
+ atom: Partial<S>;
33
+ }): Promise<mongodb.UpdateResult>;
34
+ delete_atom({ where, }: {
35
+ where?: where_types.Where<S>;
36
+ }): Promise<mongodb.DeleteResult>;
37
+ delete_atoms({ where, }: {
38
+ where?: where_types.Where<S>;
39
+ }): Promise<mongodb.DeleteResult>;
40
+ get_random_atom({ where }: {
41
+ where?: where_types.Where<S>;
42
+ }): Promise<S | null>;
43
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * MongoDB Atom client module
5
+ *
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.MongoDBAtomClient = void 0;
9
+ const mongodb_1 = require("mongodb");
10
+ class MongoDBAtomClient {
11
+ constructor(db, name) {
12
+ this.db = db;
13
+ this.name = name;
14
+ this.collection = this.db.collection(name);
15
+ }
16
+ async get_atom({ where, order, }) {
17
+ where = _instance_object_id(where);
18
+ let item = await this.collection.findOne(where, {
19
+ sort: order,
20
+ });
21
+ if (!item) {
22
+ return null;
23
+ }
24
+ // item = _string_id(item) as S;
25
+ return item;
26
+ }
27
+ async get_atoms({ where, order, limit, }) {
28
+ where = _instance_object_id(where);
29
+ let items = await this.collection
30
+ .find(where, { sort: order, limit })
31
+ .toArray();
32
+ // for (let item of items) {
33
+ // item = _string_id(item) as S;
34
+ // }
35
+ return items;
36
+ }
37
+ async put_atom(atom) {
38
+ // shape = _remove_id(shape as Partial<S>);
39
+ atom = _replace_string_id_to_object_id(atom);
40
+ const respone_insert = await this.collection.insertOne(atom);
41
+ return respone_insert;
42
+ }
43
+ async put_atoms(atoms) {
44
+ const atoms_no_ids = [];
45
+ for (const atom of atoms) {
46
+ // const atom_no_id = _remove_id(
47
+ // atom as Partial<S>
48
+ // ) as mongodb.OptionalUnlessRequiredId<S>;
49
+ const atom_no_id = _replace_string_id_to_object_id(atom);
50
+ atoms_no_ids.push(atom_no_id);
51
+ }
52
+ let items = await this.collection.insertMany(atoms_no_ids);
53
+ return items;
54
+ }
55
+ async update_atom({ where, atom, }) {
56
+ where = _instance_object_id(where);
57
+ // atom = _remove_id(atom) as Partial<S>;
58
+ atom = _replace_string_id_to_object_id(atom);
59
+ const response_update = await this.collection.updateOne(where, { $set: atom });
60
+ return response_update;
61
+ }
62
+ async update_atoms({ where, atom, }) {
63
+ where = _instance_object_id(where);
64
+ // atom = _remove_id(atom) as Partial<S>;
65
+ atom = _replace_string_id_to_object_id(atom);
66
+ const response_update = await this.collection.updateMany(where, { $set: atom });
67
+ return response_update;
68
+ }
69
+ async delete_atom({ where, }) {
70
+ where = _instance_object_id(where);
71
+ const response_delete = await this.collection.deleteOne(where);
72
+ return response_delete;
73
+ }
74
+ async delete_atoms({ where, }) {
75
+ where = _instance_object_id(where);
76
+ const response_delete = await this.collection.deleteMany(where);
77
+ return response_delete;
78
+ }
79
+ async get_random_atom({ where }) {
80
+ // https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/
81
+ const sample_stage = { $sample: { size: 1 } };
82
+ const stages = [];
83
+ where = _instance_object_id(where);
84
+ if (where && Object.keys(where).length > 0) {
85
+ stages.push({ $match: where });
86
+ }
87
+ stages.push(sample_stage);
88
+ const cursor = this.collection.aggregate(stages);
89
+ const [response] = await cursor.toArray();
90
+ if (!response) {
91
+ return null;
92
+ }
93
+ return response;
94
+ }
95
+ }
96
+ exports.MongoDBAtomClient = MongoDBAtomClient;
97
+ // type StringId<T extends unknown> = T extends {_id: any}
98
+ // ? Omit<T, '_id'> & {_id: string}
99
+ // : T;
100
+ // function _string_id<T extends unknown>(item: T): StringId<T> {
101
+ // if (item && typeof item === 'object' && '_id' in item) {
102
+ // if (item._id?.toString) {
103
+ // item._id = item._id.toString();
104
+ // }
105
+ // item._id = String(item._id);
106
+ // }
107
+ // return item as StringId<T>;
108
+ // }
109
+ // function _remove_id<A extends atom_types.mongodb_atom>(
110
+ // atom: Partial<A>
111
+ // ): atom_types.Shape<A> {
112
+ // delete (atom as any)._id;
113
+ // return atom as atom_types.Shape<A>;
114
+ // }
115
+ function _replace_string_id_to_object_id(atom) {
116
+ if (atom._id && typeof atom._id === 'string') {
117
+ atom._id = new mongodb_1.ObjectId(atom._id);
118
+ }
119
+ return atom;
120
+ }
121
+ function _instance_object_id(where) {
122
+ if (!where) {
123
+ return where;
124
+ }
125
+ for (let [key, value] of Object.entries(where)) {
126
+ if (key === '_id' && typeof value === 'string') {
127
+ where['_id'] = new mongodb_1.ObjectId(value);
128
+ }
129
+ if (value && typeof value === 'object') {
130
+ value = _instance_object_id(value);
131
+ }
132
+ }
133
+ return where;
134
+ }
135
+ //# sourceMappingURL=dynamo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.js","sourceRoot":"","sources":["../../src/atom/dynamo.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,qCAA0C;AAM1C,MAAa,iBAAiB;IAG5B,YACU,EAAc,EACf,IAAY;QADX,OAAE,GAAF,EAAE,CAAY;QACf,SAAI,GAAJ,IAAI,CAAQ;QAEnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAI,IAAI,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EACpB,KAAK,EACL,KAAK,GAIN;QACC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAI,KAA0B,EAAE;YACtE,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gCAAgC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,EACrB,KAAK,EACL,KAAK,EACL,KAAK,GAKN;QACC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU;aAC9B,IAAI,CAAI,KAA0B,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC;aACzD,OAAO,EAAE,CAAC;QACb,4BAA4B;QAC5B,kCAAkC;QAClC,IAAI;QACJ,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,KAAK,CA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AmJC;AAED,0DAA0D;AAC1D,qCAAqC;AACrC,SAAS;AAET,iEAAiE;AACjE,6DAA6D;AAC7D,gCAAgC;AAChC,wCAAwC;AACxC,QAAQ;AACR,mCAAmC;AACnC,MAAM;AACN,gCAAgC;AAChC,IAAI;AAEJ,0DAA0D;AAC1D,qBAAqB;AACrB,2BAA2B;AAC3B,8BAA8B;AAC9B,wCAAwC;AACxC,IAAI;AAEJ,SAAS,+BAA+B,CACtC,IAAgB;IAEhB,IAAI,IAAI,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAQ,CAAC,IAAI,CAAC,GAAG,CAAQ,CAAC;IAC3C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,mBAAmB,CAC1B,KAA4B;IAE5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,IAAI,GAAG,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/C,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,kBAAQ,CAAC,KAAK,CAAQ,CAAC;QAC5C,CAAC;QACD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ *
3
+ * DynamoDB Atom client module
4
+ *
5
+ */
6
+ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
7
+ import * as atom_types from '../types/atom';
8
+ import * as dynamodb_types from '../types/dynamodb';
9
+ export declare class DynamoDBAtomClient<S extends atom_types.dynamodb_atom> {
10
+ client: DynamoDBClient;
11
+ name: string;
12
+ constructor(client: DynamoDBClient, name: string);
13
+ get_atom_by_primary_index<I extends dynamodb_types.AttrType>({ attribute_name, attribute_type, attribute_value, }: {
14
+ attribute_name: string;
15
+ attribute_type: I;
16
+ attribute_value: dynamodb_types.AttrValue<I>;
17
+ }): Promise<S | null>;
18
+ get_atom_by_global_secondary_index<I extends dynamodb_types.AttrType>({ index_name, attribute_name, attribute_type, attribute_value, }: {
19
+ index_name: string;
20
+ attribute_name: string;
21
+ attribute_type: I;
22
+ attribute_value: dynamodb_types.AttrValue<I>;
23
+ }): Promise<S | null>;
24
+ put_atom(shape: Partial<S>): Promise<import("@aws-sdk/client-dynamodb").PutItemCommandOutput>;
25
+ update_atom_by_primary_index<I extends dynamodb_types.AttrType>({ attribute_name, attribute_type, attribute_value, item, }: {
26
+ attribute_name: string;
27
+ attribute_type: I;
28
+ attribute_value: dynamodb_types.AttrValue<I>;
29
+ item: Record<string, any>;
30
+ }): Promise<import("@aws-sdk/client-dynamodb").UpdateItemCommandOutput>;
31
+ delete_atom_by_primary_index<I extends dynamodb_types.AttrType>({ attribute_name, attribute_type, attribute_value, }: {
32
+ attribute_name: string;
33
+ attribute_type: I;
34
+ attribute_value: dynamodb_types.AttrValue<I>;
35
+ }): Promise<import("@aws-sdk/client-dynamodb").DeleteItemCommandOutput>;
36
+ is_primary_index_value_unique<I extends dynamodb_types.AttrType>({ attribute_name, attribute_type, attribute_value, }: {
37
+ attribute_name: string;
38
+ attribute_type: I;
39
+ attribute_value: dynamodb_types.AttrValue<I>;
40
+ }): Promise<boolean>;
41
+ is_secondary_global_index_value_unique<I extends dynamodb_types.AttrType>({ index_name, attribute_name, attribute_type, attribute_value, }: {
42
+ index_name: string;
43
+ attribute_name: string;
44
+ attribute_type: I;
45
+ attribute_value: dynamodb_types.AttrValue<I>;
46
+ }): Promise<boolean>;
47
+ get_by_partition_key<I extends dynamodb_types.AttrType>({ attribute_name, attribute_type, attribute_value, }: {
48
+ attribute_name: string;
49
+ attribute_type: I;
50
+ attribute_value: dynamodb_types.AttrValue<I>;
51
+ }): Promise<S[]>;
52
+ }
53
+ export declare class DynamoDBAtomWithIdClient<T extends Record<string, any>> extends DynamoDBAtomClient<T> {
54
+ get_atom_by_id(id: string): Promise<T | null>;
55
+ update_atom_by_id(id: string, item: Record<string, any>): Promise<import("@aws-sdk/client-dynamodb").UpdateItemCommandOutput>;
56
+ delete_by_id(id: string): Promise<import("@aws-sdk/client-dynamodb").DeleteItemCommandOutput>;
57
+ is_id_unique(id: string): Promise<boolean>;
58
+ }
59
+ export declare class DynamoDBAtomWithCompositePrimaryKeyClient<T extends Record<string, any>> extends DynamoDBAtomClient<T> {
60
+ get_atom_by_composite_primary_key<P extends dynamodb_types.AttrType, S extends dynamodb_types.AttrType>({ partition_key_name, partition_key_type, partition_key_value, sort_key_name, sort_key_type, sort_key_value, }: {
61
+ partition_key_name: string;
62
+ partition_key_type: P;
63
+ partition_key_value: dynamodb_types.AttrValue<P>;
64
+ sort_key_name: string;
65
+ sort_key_type: S;
66
+ sort_key_value: dynamodb_types.AttrValue<S>;
67
+ }): Promise<T | null>;
68
+ update_by_composite_primary_index<P extends dynamodb_types.AttrType, S extends dynamodb_types.AttrType>({ partition_key_name, partition_key_type, partition_key_value, sort_key_name, sort_key_type, sort_key_value, item, }: {
69
+ partition_key_name: string;
70
+ partition_key_type: P;
71
+ partition_key_value: dynamodb_types.AttrValue<P>;
72
+ sort_key_name: string;
73
+ sort_key_type: S;
74
+ sort_key_value: dynamodb_types.AttrValue<S>;
75
+ item: Record<string, any>;
76
+ }): Promise<import("@aws-sdk/client-dynamodb").UpdateItemCommandOutput>;
77
+ delete_by_composite_key<P extends dynamodb_types.AttrType, S extends dynamodb_types.AttrType>({ partition_key_name, partition_key_type, partition_key_value, sort_key_name, sort_key_type, sort_key_value, }: {
78
+ partition_key_name: string;
79
+ partition_key_type: P;
80
+ partition_key_value: dynamodb_types.AttrValue<P>;
81
+ sort_key_name: string;
82
+ sort_key_type: S;
83
+ sort_key_value: dynamodb_types.AttrValue<S>;
84
+ }): Promise<import("@aws-sdk/client-dynamodb").DeleteItemCommandOutput>;
85
+ }
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * DynamoDB Atom client module
5
+ *
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DynamoDBAtomWithCompositePrimaryKeyClient = exports.DynamoDBAtomWithIdClient = exports.DynamoDBAtomClient = void 0;
9
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
10
+ const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
11
+ class DynamoDBAtomClient {
12
+ constructor(client, name) {
13
+ this.client = client;
14
+ this.name = name;
15
+ }
16
+ async get_atom_by_primary_index({ attribute_name, attribute_type, attribute_value, }) {
17
+ const params = {
18
+ TableName: this.name,
19
+ Key: {
20
+ [attribute_name]: { [attribute_type]: attribute_value },
21
+ },
22
+ };
23
+ // log.trace(`GET ITEM BY PRIMARY INDEX PARAMS: `, params);
24
+ const command = new client_dynamodb_1.GetItemCommand(params);
25
+ const response = await this.client.send(command);
26
+ // log.trace(`GET ITEM BY PRIMARY INDEX RESPONSE: `, response);
27
+ if (!response.Item) {
28
+ return null;
29
+ }
30
+ const unmarshalled = (0, util_dynamodb_1.unmarshall)(response.Item);
31
+ return unmarshalled;
32
+ }
33
+ async get_atom_by_global_secondary_index({ index_name, attribute_name, attribute_type, attribute_value, }) {
34
+ const params = {
35
+ TableName: this.name,
36
+ IndexName: index_name,
37
+ KeyConditionExpression: `${attribute_name} = :value`,
38
+ ExpressionAttributeValues: {
39
+ ':value': { [attribute_type]: attribute_value },
40
+ },
41
+ };
42
+ // log.trace(`GET ITEM BY GLOBAL SECONDARY INDEX PARAMS: `, params);
43
+ const command = new client_dynamodb_1.QueryCommand(params);
44
+ const response = await this.client.send(command);
45
+ // log.trace(`GET ITEM BY GLOBAL SECONDARY INDEX RESPONSE: `, response);
46
+ if (!response.Items || !Array.isArray(response.Items)) {
47
+ throw new Error(`Invalid QueryCommand response`);
48
+ }
49
+ if (response.Items.length === 0) {
50
+ return null;
51
+ }
52
+ const unmarshalled = (0, util_dynamodb_1.unmarshall)(response.Items[0]);
53
+ return unmarshalled;
54
+ }
55
+ async put_atom(shape) {
56
+ const dynamo_item = {};
57
+ for (const [key, value] of Object.entries(shape)) {
58
+ switch (typeof value) {
59
+ case 'string':
60
+ dynamo_item[key] = { S: value };
61
+ break;
62
+ case 'number':
63
+ dynamo_item[key] = { N: value.toString() };
64
+ break;
65
+ case 'boolean':
66
+ dynamo_item[key] = { BOOL: value };
67
+ break;
68
+ default:
69
+ throw new Error(`Unsupported attribute type '${typeof value}' for` +
70
+ ` attribute name '${key}'`);
71
+ }
72
+ }
73
+ const params = {
74
+ TableName: this.name,
75
+ Item: dynamo_item,
76
+ };
77
+ // log.trace(`PUT PARAMS: `, params);
78
+ const putItemCommand = new client_dynamodb_1.PutItemCommand(params);
79
+ const response = await this.client.send(putItemCommand);
80
+ // log.trace(`PUT RESPONSE: `, response);
81
+ return response;
82
+ }
83
+ async update_atom_by_primary_index({ attribute_name, attribute_type, attribute_value, item, }) {
84
+ const updateExpression = Object.keys(item)
85
+ .map((key) => `SET ${key} = :${key}`)
86
+ .join(', ');
87
+ const params = {
88
+ TableName: this.name,
89
+ Key: {
90
+ [attribute_name]: {
91
+ [attribute_type]: attribute_value,
92
+ },
93
+ },
94
+ UpdateExpression: updateExpression,
95
+ ExpressionAttributeValues: Object.entries(item).reduce((acc, [key, value]) => ({
96
+ ...acc,
97
+ [`:${key}`]: { [_dynamo_attribute_type_for(key, value)]: value },
98
+ }), {}),
99
+ };
100
+ // log.trace(`UPDATE BY PRIMARY INDEX PARAMS: `, params);
101
+ const command = new client_dynamodb_1.UpdateItemCommand(params);
102
+ const respone = await this.client.send(command);
103
+ // log.trace(`UPDATE BY PRIMARY INDEX RESPONSE: `, respone);
104
+ return respone;
105
+ }
106
+ async delete_atom_by_primary_index({ attribute_name, attribute_type, attribute_value, }) {
107
+ const params = {
108
+ TableName: this.name,
109
+ Key: {
110
+ [attribute_name]: { [attribute_type]: attribute_value },
111
+ },
112
+ };
113
+ // log.trace(`DELETE BY PRIMARY INDEX PARAMS: `, params);
114
+ const command = new client_dynamodb_1.DeleteItemCommand(params);
115
+ const response = await this.client.send(command);
116
+ // log.trace(`DELETE BY PRIMARY INDEX RESPONSE: `, params);
117
+ return response;
118
+ }
119
+ async is_primary_index_value_unique({ attribute_name, attribute_type, attribute_value, }) {
120
+ const item = await this.get_atom_by_primary_index({
121
+ attribute_name,
122
+ attribute_type,
123
+ attribute_value,
124
+ });
125
+ if (item !== null) {
126
+ return false;
127
+ }
128
+ return true;
129
+ }
130
+ async is_secondary_global_index_value_unique({ index_name, attribute_name, attribute_type, attribute_value, }) {
131
+ const item = await this.get_atom_by_global_secondary_index({
132
+ index_name,
133
+ attribute_name,
134
+ attribute_type,
135
+ attribute_value,
136
+ });
137
+ if (item !== null) {
138
+ return false;
139
+ }
140
+ return true;
141
+ }
142
+ async get_by_partition_key({ attribute_name, attribute_type, attribute_value, }) {
143
+ const params = {
144
+ TableName: this.name,
145
+ KeyConditionExpression: `${attribute_name} = :pk`,
146
+ ExpressionAttributeValues: {
147
+ ':pk': { [attribute_type]: attribute_value },
148
+ },
149
+ ScanIndexForward: true, // Set to true for ascending order, false for descending order
150
+ };
151
+ // log.trace(`GET BY PARTITION KEY PARAMS: `, params);
152
+ const command = new client_dynamodb_1.QueryCommand(params);
153
+ const response = await this.client.send(command);
154
+ // log.trace(`GET BY PARTITION KEY RESPONSE: `, response);
155
+ if (!response.Items) {
156
+ return [];
157
+ }
158
+ const response_items = [];
159
+ for (const item of response.Items) {
160
+ const unmarshalled = (0, util_dynamodb_1.unmarshall)(item);
161
+ response_items.push(unmarshalled);
162
+ }
163
+ return response_items;
164
+ }
165
+ }
166
+ exports.DynamoDBAtomClient = DynamoDBAtomClient;
167
+ class DynamoDBAtomWithIdClient extends DynamoDBAtomClient {
168
+ async get_atom_by_id(id) {
169
+ return this.get_atom_by_primary_index({
170
+ attribute_name: 'id',
171
+ attribute_value: id,
172
+ attribute_type: 'S',
173
+ });
174
+ }
175
+ async update_atom_by_id(id, item) {
176
+ return this.update_atom_by_primary_index({
177
+ attribute_name: 'id',
178
+ attribute_value: id,
179
+ attribute_type: 'S',
180
+ item,
181
+ });
182
+ }
183
+ async delete_by_id(id) {
184
+ return this.delete_atom_by_primary_index({
185
+ attribute_name: 'id',
186
+ attribute_value: id,
187
+ attribute_type: 'S',
188
+ });
189
+ }
190
+ async is_id_unique(id) {
191
+ return await this.is_primary_index_value_unique({
192
+ attribute_name: 'id',
193
+ attribute_type: 'S',
194
+ attribute_value: id,
195
+ });
196
+ }
197
+ }
198
+ exports.DynamoDBAtomWithIdClient = DynamoDBAtomWithIdClient;
199
+ class DynamoDBAtomWithCompositePrimaryKeyClient extends DynamoDBAtomClient {
200
+ async get_atom_by_composite_primary_key({ partition_key_name, partition_key_type, partition_key_value, sort_key_name, sort_key_type, sort_key_value, }) {
201
+ const params = {
202
+ TableName: this.name,
203
+ Key: {
204
+ [partition_key_name]: {
205
+ [partition_key_type]: partition_key_value,
206
+ },
207
+ [sort_key_name]: {
208
+ [sort_key_type]: sort_key_value,
209
+ },
210
+ },
211
+ };
212
+ // log.trace(`GET BY COMPOSITE KEY PARAMS: `, params);
213
+ const command = new client_dynamodb_1.GetItemCommand(params);
214
+ const response = await this.client.send(command);
215
+ // log.trace(`GET BY COMPOSITE KEY RESPONSE: `, response);
216
+ if (!response.Item) {
217
+ return null;
218
+ }
219
+ const item = response.Item;
220
+ const unmarshalled = (0, util_dynamodb_1.unmarshall)(item);
221
+ return unmarshalled;
222
+ }
223
+ async update_by_composite_primary_index({ partition_key_name, partition_key_type, partition_key_value, sort_key_name, sort_key_type, sort_key_value, item, }) {
224
+ const updateExpression = Object.keys(item)
225
+ .map((key) => `SET ${key} = :${key}`)
226
+ .join(', ');
227
+ const params = {
228
+ TableName: this.name,
229
+ Key: {
230
+ [partition_key_name]: {
231
+ [partition_key_type]: partition_key_value,
232
+ },
233
+ [sort_key_name]: {
234
+ [sort_key_type]: sort_key_value,
235
+ },
236
+ },
237
+ UpdateExpression: updateExpression,
238
+ ExpressionAttributeValues: Object.entries(item).reduce((acc, [key, value]) => ({
239
+ ...acc,
240
+ [`:${key}`]: { [_dynamo_attribute_type_for(key, value)]: value },
241
+ }), {}),
242
+ };
243
+ // log.trace(`UPDATE BY COMPOSITE PRIMARY INDEX PARAMS: `, params);
244
+ const command = new client_dynamodb_1.UpdateItemCommand(params);
245
+ const respone = await this.client.send(command);
246
+ // log.trace(`UPDATE BY COMPOSITE PRIMARY INDEX RESPONSE: `, respone);
247
+ return respone;
248
+ }
249
+ async delete_by_composite_key({ partition_key_name, partition_key_type, partition_key_value, sort_key_name, sort_key_type, sort_key_value, }) {
250
+ const params = {
251
+ TableName: this.name,
252
+ Key: {
253
+ [partition_key_name]: { [partition_key_type]: partition_key_value },
254
+ [sort_key_name]: { [sort_key_type]: sort_key_value },
255
+ },
256
+ };
257
+ // log.trace(`DELETE BY COMPOSITE INDEX PARAMS: `, params);
258
+ const command = new client_dynamodb_1.DeleteItemCommand(params);
259
+ const response = await this.client.send(command);
260
+ // log.trace(`DELETE BY COMPOSITE INDEX RESPONSE: `, response);
261
+ return response;
262
+ }
263
+ }
264
+ exports.DynamoDBAtomWithCompositePrimaryKeyClient = DynamoDBAtomWithCompositePrimaryKeyClient;
265
+ function _dynamo_attribute_type_for(name, value) {
266
+ switch (typeof value) {
267
+ case 'string': {
268
+ return 'S';
269
+ }
270
+ case 'number': {
271
+ return 'N';
272
+ }
273
+ case 'boolean': {
274
+ return 'B';
275
+ }
276
+ }
277
+ throw new Error(`Attribute type not supported. Attribute name '${name}'` +
278
+ ` , attribute type '${typeof value}'`);
279
+ }
280
+ //# sourceMappingURL=dynamodb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AAa,CAAC,EAAE,EAAC,CAAC,aAAa,CAAC,EAAE,cAAc,EAAC;aACnD;SACmC,CAAC;QACvC,2DAA2D;QAC3D,MAAM,OAAO,GAAG,IAAI,mCAAiB,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,+DAA+D;QAC/D,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1HD,8FA0HC;AAED,SAAS,0BAA0B,CACjC,IAAY,EACZ,KAAc;IAEd,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,GAAG,CAAC;QACb,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,GAAG,CAAC;QACb,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CACb,iDAAiD,IAAI,GAAG;QACtD,sBAAsB,OAAO,KAAK,GAAG,CACxC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ *
3
+ * MongoDB Atom client module
4
+ *
5
+ */
6
+ import mongodb from 'mongodb';
7
+ import * as atom_types from '../types/atom';
8
+ import * as sql_types from '../types/sql';
9
+ import * as where_types from '../types/where';
10
+ export declare class MongoDBAtomClient<S extends atom_types.mongodb_atom> {
11
+ private db;
12
+ name: string;
13
+ collection: mongodb.Collection<S>;
14
+ constructor(db: mongodb.Db, name: string);
15
+ get_atom({ where, order, }: {
16
+ where?: where_types.Where<S>;
17
+ order?: sql_types.OrderBy;
18
+ }): Promise<S | null>;
19
+ get_atoms({ where, order, limit, }: {
20
+ where?: where_types.Where<S>;
21
+ order?: sql_types.OrderBy;
22
+ limit?: number;
23
+ }): Promise<S[]>;
24
+ put_atom(atom: Partial<S>): Promise<mongodb.InsertOneResult>;
25
+ put_atoms(atoms: Partial<S>[]): Promise<mongodb.InsertManyResult>;
26
+ update_atom({ where, atom, }: {
27
+ where?: where_types.Where<S>;
28
+ atom: Partial<S>;
29
+ }): Promise<mongodb.UpdateResult>;
30
+ update_atoms({ where, atom, }: {
31
+ where?: where_types.Where<S>;
32
+ atom: Partial<S>;
33
+ }): Promise<mongodb.UpdateResult>;
34
+ delete_atom({ where, }: {
35
+ where?: where_types.Where<S>;
36
+ }): Promise<mongodb.DeleteResult>;
37
+ delete_atoms({ where, }: {
38
+ where?: where_types.Where<S>;
39
+ }): Promise<mongodb.DeleteResult>;
40
+ get_random_atom({ where }: {
41
+ where?: where_types.Where<S>;
42
+ }): Promise<S | null>;
43
+ }