@encodeagent/platform-helper-data 1.2510.1041539 → 1.2510.1282253
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/cosmosdb/index.d.ts +25 -0
- package/dist/cosmosdb/index.d.ts.map +1 -0
- package/dist/cosmosdb/index.js +210 -0
- package/dist/cosmosdb/index.js.map +1 -0
- package/dist/cosmosdb/query-builder.d.ts +10 -0
- package/dist/cosmosdb/query-builder.d.ts.map +1 -0
- package/dist/cosmosdb/query-builder.js +123 -0
- package/dist/cosmosdb/query-builder.js.map +1 -0
- package/dist/dynamodb/index.d.ts +24 -0
- package/dist/dynamodb/index.d.ts.map +1 -0
- package/dist/dynamodb/index.js +189 -0
- package/dist/dynamodb/index.js.map +1 -0
- package/dist/firestore/index.d.ts +9 -0
- package/dist/firestore/index.d.ts.map +1 -0
- package/dist/firestore/index.js +79 -0
- package/dist/firestore/index.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/mongodb/index.d.ts +18 -0
- package/dist/mongodb/index.d.ts.map +1 -0
- package/dist/mongodb/index.js +208 -0
- package/dist/mongodb/index.js.map +1 -0
- package/dist/util.d.ts +125 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +40 -0
- package/dist/util.js.map +1 -0
- package/dist/wrapper/index.d.ts +31 -6
- package/dist/wrapper/index.d.ts.map +1 -1
- package/dist/wrapper/index.js +197 -46
- package/dist/wrapper/index.js.map +1 -1
- package/package.json +4 -5
- package/dist/aws-dynamodb/index.d.ts +0 -17
- package/dist/aws-dynamodb/index.d.ts.map +0 -1
- package/dist/aws-dynamodb/index.js +0 -96
- package/dist/aws-dynamodb/index.js.map +0 -1
- package/dist/azure-cosmosdb/index.d.ts +0 -17
- package/dist/azure-cosmosdb/index.d.ts.map +0 -1
- package/dist/azure-cosmosdb/index.js +0 -91
- package/dist/azure-cosmosdb/index.js.map +0 -1
- package/dist/gcp-firestore/index.d.ts +0 -7
- package/dist/gcp-firestore/index.d.ts.map +0 -1
- package/dist/gcp-firestore/index.js +0 -17
- package/dist/gcp-firestore/index.js.map +0 -1
- package/dist/mongo/index.d.ts +0 -7
- package/dist/mongo/index.d.ts.map +0 -1
- package/dist/mongo/index.js +0 -17
- package/dist/mongo/index.js.map +0 -1
- package/dist/types.d.ts +0 -46
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +0 -1
package/dist/wrapper/index.js
CHANGED
|
@@ -3,63 +3,58 @@
|
|
|
3
3
|
* @fileoverview Generic wrapper functions for multi-database operations
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.retrieve = void 0;
|
|
6
|
+
exports.upsert = exports.query = exports.create = exports.retrieve = void 0;
|
|
7
7
|
exports.connect = connect;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
8
|
+
const util_1 = require("../util");
|
|
9
|
+
const util_2 = require("../util");
|
|
10
|
+
const cosmosdb_1 = require("../cosmosdb");
|
|
11
|
+
const dynamodb_1 = require("../dynamodb");
|
|
12
|
+
const firestore_1 = require("../firestore");
|
|
13
|
+
const mongodb_1 = require("../mongodb");
|
|
14
14
|
/**
|
|
15
15
|
* Connect to database based on engine type
|
|
16
16
|
* @param props Database configuration with engine type
|
|
17
17
|
* @returns Promise<ConnectionResult>
|
|
18
18
|
*/
|
|
19
19
|
async function connect(props) {
|
|
20
|
-
const engine = props.engine ??
|
|
20
|
+
const engine = props.engine ?? util_2.ENGINE;
|
|
21
21
|
if (!props.uri) {
|
|
22
22
|
return {
|
|
23
23
|
engine,
|
|
24
24
|
error: 'The database URI is required'
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
engine,
|
|
30
|
-
error: 'The database key is required'
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const uri = props.uri ?? types_1.URI;
|
|
34
|
-
const key = props.key ?? types_1.KEY;
|
|
27
|
+
const uri = props.uri ?? util_2.URI;
|
|
28
|
+
const key = props.key ?? util_2.KEY;
|
|
35
29
|
const connectionProps = {
|
|
36
30
|
uri,
|
|
37
31
|
key
|
|
38
32
|
};
|
|
39
|
-
let connection =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
let connection = undefined;
|
|
34
|
+
// let connection: IConnectionResult | undefined = connections[engine];
|
|
35
|
+
// if (connection) {
|
|
36
|
+
// return connection;
|
|
37
|
+
// }
|
|
43
38
|
try {
|
|
44
39
|
switch (engine) {
|
|
45
|
-
case '
|
|
40
|
+
case 'cosmosdb':
|
|
46
41
|
{
|
|
47
|
-
connection = await (0,
|
|
42
|
+
connection = await (0, cosmosdb_1.connect)(connectionProps);
|
|
48
43
|
break;
|
|
49
44
|
}
|
|
50
|
-
case '
|
|
45
|
+
case 'dynamodb':
|
|
51
46
|
{
|
|
52
|
-
connection = await (0,
|
|
47
|
+
connection = await (0, dynamodb_1.connect)(connectionProps);
|
|
53
48
|
break;
|
|
54
49
|
}
|
|
55
|
-
case '
|
|
50
|
+
case 'firestore':
|
|
56
51
|
{
|
|
57
|
-
connection = await (0,
|
|
52
|
+
connection = await (0, firestore_1.connect)(connectionProps);
|
|
58
53
|
break;
|
|
59
54
|
}
|
|
60
55
|
case 'mongodb':
|
|
61
56
|
{
|
|
62
|
-
connection = await (0,
|
|
57
|
+
connection = await (0, mongodb_1.connect)(connectionProps);
|
|
63
58
|
break;
|
|
64
59
|
}
|
|
65
60
|
default:
|
|
@@ -84,46 +79,39 @@ async function connect(props) {
|
|
|
84
79
|
* @returns Promise<IRetrieveResult>
|
|
85
80
|
*/
|
|
86
81
|
const retrieve = async (props) => {
|
|
87
|
-
const { id, partitionKey } = props;
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const databaseId = props.databaseId ?? types_1.DATABASE_ID;
|
|
91
|
-
const containerId = props.containerId ?? types_1.DATABASE_CONTAINER_ID;
|
|
82
|
+
const { id, partitionKey, ...rest } = props;
|
|
83
|
+
const { engine, databaseId, containerId, uri, key } = (0, util_1.getDatabaseSetting)(rest);
|
|
84
|
+
const connection = await connect({ engine, uri, key });
|
|
92
85
|
if (!connection.client) {
|
|
93
86
|
return {
|
|
94
87
|
engine,
|
|
95
88
|
error: `The ${engine} client is required`
|
|
96
89
|
};
|
|
97
90
|
}
|
|
98
|
-
if (!containerId) {
|
|
99
|
-
return {
|
|
100
|
-
engine,
|
|
101
|
-
error: 'The containerId or process.env.CONTAINER_ID is required'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
91
|
if (!id) {
|
|
105
92
|
return {
|
|
106
93
|
engine,
|
|
107
|
-
error: '
|
|
94
|
+
error: 'The id is required'
|
|
108
95
|
};
|
|
109
96
|
}
|
|
110
97
|
const retrieveProps = {
|
|
111
98
|
client: connection.client,
|
|
112
99
|
id,
|
|
100
|
+
key,
|
|
113
101
|
databaseId,
|
|
114
102
|
containerId,
|
|
115
103
|
partitionKey
|
|
116
104
|
};
|
|
117
105
|
try {
|
|
118
106
|
switch (engine) {
|
|
119
|
-
case '
|
|
120
|
-
return await (0,
|
|
121
|
-
case '
|
|
122
|
-
return await (0,
|
|
123
|
-
case '
|
|
124
|
-
return await (0,
|
|
107
|
+
case 'cosmosdb':
|
|
108
|
+
return await (0, cosmosdb_1.retrieve)(retrieveProps);
|
|
109
|
+
case 'dynamodb':
|
|
110
|
+
return await (0, dynamodb_1.retrieve)(retrieveProps);
|
|
111
|
+
case 'firestore':
|
|
112
|
+
return await (0, firestore_1.retrieve)(retrieveProps);
|
|
125
113
|
case 'mongodb':
|
|
126
|
-
return await (0,
|
|
114
|
+
return await (0, mongodb_1.retrieve)(retrieveProps);
|
|
127
115
|
default:
|
|
128
116
|
return {
|
|
129
117
|
engine,
|
|
@@ -139,4 +127,167 @@ const retrieve = async (props) => {
|
|
|
139
127
|
}
|
|
140
128
|
};
|
|
141
129
|
exports.retrieve = retrieve;
|
|
130
|
+
/**
|
|
131
|
+
* Retrieve document by ID from any database
|
|
132
|
+
* @param props IRetrieveProps
|
|
133
|
+
* @returns Promise<IRetrieveResult>
|
|
134
|
+
*/
|
|
135
|
+
const create = async (props) => {
|
|
136
|
+
const { record, ...rest } = props;
|
|
137
|
+
const { engine, databaseId, containerId, uri, key } = (0, util_1.getDatabaseSetting)(rest);
|
|
138
|
+
const connection = await connect({ engine, uri, key });
|
|
139
|
+
console.log(connection);
|
|
140
|
+
if (!connection.client) {
|
|
141
|
+
return {
|
|
142
|
+
engine,
|
|
143
|
+
error: `The ${engine} client is required`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (!record) {
|
|
147
|
+
return {
|
|
148
|
+
engine,
|
|
149
|
+
error: 'The record is required'
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const createProps = {
|
|
153
|
+
client: connection.client,
|
|
154
|
+
record,
|
|
155
|
+
key,
|
|
156
|
+
databaseId,
|
|
157
|
+
containerId
|
|
158
|
+
};
|
|
159
|
+
try {
|
|
160
|
+
switch (engine) {
|
|
161
|
+
case 'cosmosdb':
|
|
162
|
+
return await (0, cosmosdb_1.create)(createProps);
|
|
163
|
+
case 'dynamodb':
|
|
164
|
+
return await (0, dynamodb_1.create)(createProps);
|
|
165
|
+
case 'firestore':
|
|
166
|
+
return await (0, firestore_1.create)(createProps);
|
|
167
|
+
case 'mongodb':
|
|
168
|
+
return await (0, mongodb_1.create)(createProps);
|
|
169
|
+
default:
|
|
170
|
+
return {
|
|
171
|
+
engine,
|
|
172
|
+
error: 'Invalid engine type'
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
engine,
|
|
179
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
exports.create = create;
|
|
184
|
+
/**
|
|
185
|
+
* Retrieve document by ID from any database
|
|
186
|
+
* @param props IRetrieveProps
|
|
187
|
+
* @returns Promise<IRetrieveResult>
|
|
188
|
+
*/
|
|
189
|
+
const query = async (props) => {
|
|
190
|
+
const { query, ...rest } = props;
|
|
191
|
+
let dbQuery = undefined;
|
|
192
|
+
const { engine, databaseId, containerId, uri, key } = (0, util_1.getDatabaseSetting)(rest);
|
|
193
|
+
const connection = await connect({ engine, uri, key });
|
|
194
|
+
if (!connection.client) {
|
|
195
|
+
return {
|
|
196
|
+
engine,
|
|
197
|
+
query,
|
|
198
|
+
dbQuery,
|
|
199
|
+
error: `The ${engine} client is required`
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const queryProps = {
|
|
203
|
+
client: connection.client,
|
|
204
|
+
query,
|
|
205
|
+
key,
|
|
206
|
+
databaseId,
|
|
207
|
+
containerId
|
|
208
|
+
};
|
|
209
|
+
try {
|
|
210
|
+
switch (engine) {
|
|
211
|
+
case 'cosmosdb':
|
|
212
|
+
return await (0, cosmosdb_1.query)(queryProps);
|
|
213
|
+
// case 'dynamodb':
|
|
214
|
+
// return await createFromAWS(createProps);
|
|
215
|
+
// case 'firestore':
|
|
216
|
+
// return await createFromGCP(createProps);
|
|
217
|
+
// case 'mongodb':
|
|
218
|
+
// return await createFromMongo(createProps);
|
|
219
|
+
default:
|
|
220
|
+
return {
|
|
221
|
+
engine,
|
|
222
|
+
query,
|
|
223
|
+
dbQuery,
|
|
224
|
+
error: 'Invalid engine type'
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
return {
|
|
230
|
+
engine,
|
|
231
|
+
data: [],
|
|
232
|
+
query,
|
|
233
|
+
dbQuery,
|
|
234
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.query = query;
|
|
239
|
+
/**
|
|
240
|
+
* Upsert (create or update) document in any database
|
|
241
|
+
* @param props IUpsertProps
|
|
242
|
+
* @returns Promise<IUpsertResult>
|
|
243
|
+
*/
|
|
244
|
+
const upsert = async (props) => {
|
|
245
|
+
const { record, partitionKey, ...rest } = props;
|
|
246
|
+
const { engine, databaseId, containerId, uri, key } = (0, util_1.getDatabaseSetting)(rest);
|
|
247
|
+
const connection = await connect({ engine, uri, key });
|
|
248
|
+
if (!connection.client) {
|
|
249
|
+
return {
|
|
250
|
+
engine,
|
|
251
|
+
error: `The ${engine} client is required`
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
if (!record) {
|
|
255
|
+
return {
|
|
256
|
+
engine,
|
|
257
|
+
error: 'The record is required'
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const upsertProps = {
|
|
261
|
+
client: connection.client,
|
|
262
|
+
record,
|
|
263
|
+
key,
|
|
264
|
+
databaseId,
|
|
265
|
+
containerId,
|
|
266
|
+
partitionKey
|
|
267
|
+
};
|
|
268
|
+
try {
|
|
269
|
+
switch (engine) {
|
|
270
|
+
case 'cosmosdb':
|
|
271
|
+
return await (0, cosmosdb_1.upsert)(upsertProps);
|
|
272
|
+
case 'dynamodb':
|
|
273
|
+
return await (0, dynamodb_1.upsert)(upsertProps);
|
|
274
|
+
case 'firestore':
|
|
275
|
+
return await (0, firestore_1.upsert)(upsertProps);
|
|
276
|
+
case 'mongodb':
|
|
277
|
+
return await (0, mongodb_1.upsert)(upsertProps);
|
|
278
|
+
default:
|
|
279
|
+
return {
|
|
280
|
+
engine,
|
|
281
|
+
error: 'Invalid engine type'
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
return {
|
|
287
|
+
engine,
|
|
288
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
exports.upsert = upsert;
|
|
142
293
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA+BH,0BA+DC;AA5FD,kCAOiB;AACjB,kCAA2C;AAE3C,0CAAoK;AACpK,0CAAmI;AACnI,4CAAoI;AACpI,wCAA0I;AAW1I;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,KAAuB;IACjD,MAAM,MAAM,GAAoB,KAAK,CAAC,MAAM,IAAI,aAAM,CAAC;IAEvD,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACb,OAAO;YACH,MAAM;YACN,KAAK,EAAE,8BAA8B;SACxC,CAAC;IACN,CAAC;IAED,MAAM,GAAG,GAAW,KAAK,CAAC,GAAG,IAAI,UAAG,CAAC;IACrC,MAAM,GAAG,GAAuB,KAAK,CAAC,GAAG,IAAI,UAAG,CAAC;IAEjD,MAAM,eAAe,GAA+B;QAChD,GAAG;QACH,GAAG;KACN,CAAC;IAEF,IAAI,UAAU,GAAkC,SAAS,CAAC;IAE1D,uEAAuE;IAEvE,oBAAoB;IACpB,yBAAyB;IACzB,IAAI;IAEJ,IAAI,CAAC;QACD,QAAQ,MAAM,EAAE,CAAC;YACb,KAAK,UAAU;gBACX,CAAC;oBACG,UAAU,GAAG,MAAM,IAAA,kBAAY,EAAC,eAAe,CAAC,CAAC;oBACjD,MAAM;gBACV,CAAC;YACL,KAAK,UAAU;gBACX,CAAC;oBACG,UAAU,GAAG,MAAM,IAAA,kBAAU,EAAC,eAAe,CAAC,CAAC;oBAC/C,MAAM;gBACV,CAAC;YACL,KAAK,WAAW;gBACZ,CAAC;oBACG,UAAU,GAAG,MAAM,IAAA,mBAAU,EAAC,eAAe,CAAC,CAA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AAC;QACrB,OAAO;YACH,MAAM;YACN,KAAK,EAAE,OAAO,MAAM,qBAAqB;SAC5C,CAAC;IACN,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO;YACH,MAAM;YACN,KAAK,EAAE,wBAAwB;SAClC,CAAC;IACN,CAAC;IAED,MAAM,WAAW,GAAqB;QAClC,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,MAAM;QACN,GAAG;QACH,UAAU;QACV,WAAW;QACX,YAAY;KACf,CAAC;IAEF,IAAI,CAAC;QACD,QAAQ,MAAM,EAAE,CAAC;YACb,KAAK,UAAU;gBACX,OAAO,MAAM,IAAA,iBAAe,EAAC,WAAW,CAAC,CAAC;YAC9C,KAAK,UAAU;gBACX,OAAO,MAAM,IAAA,iBAAa,EAAC,WAAW,CAAC,CAAC;YAC5C,KAAK,WAAW;gBACZ,OAAO,MAAM,IAAA,kBAAa,EAAC,WAAW,CAAC,CAAC;YAC5C,KAAK,SAAS;gBACV,OAAO,MAAM,IAAA,gBAAe,EAAC,WAAW,CAAC,CAAC;YAC9C;gBACI,OAAO;oBACH,MAAM;oBACN,KAAK,EAAE,qBAAqB;iBAC/B,CAAC;QACV,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM;YACN,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;SAC3E,CAAC;IACN,CAAC;AACL,CAAC,CAAA;AAnDY,QAAA,MAAM,UAmDlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@encodeagent/platform-helper-data",
|
|
3
|
-
"version": "1.2510.
|
|
3
|
+
"version": "1.2510.1282253",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">20.0.0 <23.0.0"
|
|
6
6
|
},
|
|
@@ -34,15 +34,14 @@
|
|
|
34
34
|
"@aws-sdk/client-dynamodb": "^3.879.0",
|
|
35
35
|
"@aws-sdk/util-dynamodb": "^3.879.0",
|
|
36
36
|
"@azure/cosmos": "^4.5.0",
|
|
37
|
-
"@encodeagent/platform-helper-util": "^1.2510.
|
|
37
|
+
"@encodeagent/platform-helper-util": "^1.2510.1242245",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
|
-
"
|
|
39
|
+
"mongo-sdk": "npm:mongodb@^6.20.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/jest": "^29.5.5",
|
|
43
43
|
"@types/lodash": "^4.14.199",
|
|
44
44
|
"@types/node": "^20.6.0",
|
|
45
|
-
"@types/uuid": "^9.0.4",
|
|
46
45
|
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
47
46
|
"@typescript-eslint/parser": "^6.7.0",
|
|
48
47
|
"dotenv": "^17.2.1",
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
},
|
|
54
53
|
"repository": {
|
|
55
54
|
"type": "git",
|
|
56
|
-
"url": "git+https://github.com/EncodeAgent/
|
|
55
|
+
"url": "git+https://github.com/EncodeAgent/po-platform-helper-data.git",
|
|
57
56
|
"directory": "helper/data"
|
|
58
57
|
},
|
|
59
58
|
"publishConfig": {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview AWS DynamoDB implementation
|
|
3
|
-
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Create AWS DynamoDB connection
|
|
7
|
-
* @param props Connection properties with URI and key
|
|
8
|
-
* @returns Promise<IConnectionResult>
|
|
9
|
-
*/
|
|
10
|
-
export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
|
|
11
|
-
/**
|
|
12
|
-
* Retrieve document by ID from AWS DynamoDB
|
|
13
|
-
* @param props Retrieve properties with client, collection (table), and id
|
|
14
|
-
* @returns Promise<IRetrieveResult<T>>
|
|
15
|
-
*/
|
|
16
|
-
export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aws-dynamodb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAM1H;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmD3F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAkCpG"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview AWS DynamoDB implementation
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.connect = connect;
|
|
7
|
-
exports.retrieve = retrieve;
|
|
8
|
-
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
9
|
-
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
10
|
-
const ENGINE = "aws-dynamodb";
|
|
11
|
-
/**
|
|
12
|
-
* Create AWS DynamoDB connection
|
|
13
|
-
* @param props Connection properties with URI and key
|
|
14
|
-
* @returns Promise<IConnectionResult>
|
|
15
|
-
*/
|
|
16
|
-
async function connect(props) {
|
|
17
|
-
try {
|
|
18
|
-
const { uri, key } = props;
|
|
19
|
-
if (!uri) {
|
|
20
|
-
return {
|
|
21
|
-
engine: "aws-dynamodb",
|
|
22
|
-
error: 'AWS DynamoDB URI is required'
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (!key) {
|
|
26
|
-
return {
|
|
27
|
-
engine: ENGINE,
|
|
28
|
-
error: 'AWS DynamoDB access key is required'
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Parse AWS credentials from key (format: accessKeyId:secretAccessKey)
|
|
32
|
-
const [accessKeyId, secretAccessKey] = key.split(':');
|
|
33
|
-
if (!accessKeyId || !secretAccessKey) {
|
|
34
|
-
return {
|
|
35
|
-
engine: ENGINE,
|
|
36
|
-
error: 'AWS key must be in format: accessKeyId:secretAccessKey'
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// Create DynamoDB client configuration
|
|
40
|
-
const clientConfig = {
|
|
41
|
-
credentials: {
|
|
42
|
-
accessKeyId,
|
|
43
|
-
secretAccessKey
|
|
44
|
-
},
|
|
45
|
-
endpoint: uri.startsWith('http') ? uri : undefined
|
|
46
|
-
};
|
|
47
|
-
// Create AWS DynamoDB client
|
|
48
|
-
const client = new client_dynamodb_1.DynamoDBClient(clientConfig);
|
|
49
|
-
return {
|
|
50
|
-
engine: ENGINE,
|
|
51
|
-
client
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return {
|
|
56
|
-
engine: ENGINE,
|
|
57
|
-
error: error instanceof Error ? error.message : 'Failed to connect to AWS DynamoDB'
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Retrieve document by ID from AWS DynamoDB
|
|
63
|
-
* @param props Retrieve properties with client, collection (table), and id
|
|
64
|
-
* @returns Promise<IRetrieveResult<T>>
|
|
65
|
-
*/
|
|
66
|
-
async function retrieve(props) {
|
|
67
|
-
try {
|
|
68
|
-
const { client, id, containerId } = props;
|
|
69
|
-
// Create GetItem command
|
|
70
|
-
const command = new client_dynamodb_1.GetItemCommand({
|
|
71
|
-
TableName: containerId,
|
|
72
|
-
Key: (0, util_dynamodb_1.marshall)({ id })
|
|
73
|
-
});
|
|
74
|
-
// Execute the command
|
|
75
|
-
const response = await client.send(command);
|
|
76
|
-
if (!response.Item) {
|
|
77
|
-
return {
|
|
78
|
-
engine: ENGINE,
|
|
79
|
-
error: `Document with ID '${id}' not found in table '${containerId}'`
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
// Unmarshall the DynamoDB item to regular object
|
|
83
|
-
const data = (0, util_dynamodb_1.unmarshall)(response.Item);
|
|
84
|
-
return {
|
|
85
|
-
engine: ENGINE,
|
|
86
|
-
data
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
return {
|
|
91
|
-
engine: ENGINE,
|
|
92
|
-
error: error instanceof Error ? error.message : 'Failed to retrieve document from DynamoDB'
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aws-dynamodb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAaH,0BAmDC;AAOD,4BAkCC;AAtGD,8DAA0E;AAE1E,0DAA8D;AAC9D,MAAM,MAAM,GAAG,cAAc,CAAC;AAE9B;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,KAAiC;IAC3D,IAAI,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;QAE3B,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,OAAO;gBACH,MAAM,EAAE,cAAc;gBACtB,KAAK,EAAE,8BAA8B;aACxC,CAAC;QACN,CAAC;QAED,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,qCAAqC;aAC/C,CAAC;QACN,CAAC;QAED,uEAAuE;QACvE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,GAAG,CAAC,KAA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AW,GAAG;aACxE,CAAC;QACN,CAAC;QAED,iDAAiD;QACjD,MAAM,IAAI,GAAG,IAAA,0BAAU,EAAC,QAAQ,CAAC,IAAI,CAAM,CAAC;QAE5C,OAAO;YACH,MAAM,EAAE,MAAM;YACd,IAAI;SACP,CAAC;IAEN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2CAA2C;SAC9F,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Azure Cosmos DB implementation
|
|
3
|
-
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Create Azure Cosmos DB connection
|
|
7
|
-
* @param props Connection properties with URI and key
|
|
8
|
-
* @returns Promise<IConnectionResult>
|
|
9
|
-
*/
|
|
10
|
-
export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
|
|
11
|
-
/**
|
|
12
|
-
* Retrieve document by ID from Azure Cosmos DB
|
|
13
|
-
* @param props Retrieve properties with client, collection (container), and id
|
|
14
|
-
* @returns Promise<IRetrieveResult<T>>
|
|
15
|
-
*/
|
|
16
|
-
export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/azure-cosmosdb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAyB1H;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgC3F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAgDpG"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Azure Cosmos DB implementation
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.connect = connect;
|
|
7
|
-
exports.retrieve = retrieve;
|
|
8
|
-
const platform_helper_util_1 = require("@encodeagent/platform-helper-util");
|
|
9
|
-
const cosmos_1 = require("@azure/cosmos");
|
|
10
|
-
const ENGINE = "azure-cosmosdb";
|
|
11
|
-
/**
|
|
12
|
-
* Create Azure Cosmos DB connection
|
|
13
|
-
* @param props Connection properties with URI and key
|
|
14
|
-
* @returns Promise<IConnectionResult>
|
|
15
|
-
*/
|
|
16
|
-
async function connect(props) {
|
|
17
|
-
try {
|
|
18
|
-
const { uri, key } = props;
|
|
19
|
-
if (!uri) {
|
|
20
|
-
return {
|
|
21
|
-
engine: ENGINE,
|
|
22
|
-
error: 'Azure Cosmos DB URI is required'
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (!key) {
|
|
26
|
-
return {
|
|
27
|
-
engine: ENGINE,
|
|
28
|
-
error: 'Azure Cosmos DB key is required'
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Create Azure Cosmos DB client
|
|
32
|
-
const client = new cosmos_1.CosmosClient({ endpoint: uri, key });
|
|
33
|
-
return {
|
|
34
|
-
engine: ENGINE,
|
|
35
|
-
client
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
return {
|
|
40
|
-
engine: ENGINE,
|
|
41
|
-
error: error instanceof Error ? error.message : 'Failed to connect to Azure Cosmos DB'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Retrieve document by ID from Azure Cosmos DB
|
|
47
|
-
* @param props Retrieve properties with client, collection (container), and id
|
|
48
|
-
* @returns Promise<IRetrieveResult<T>>
|
|
49
|
-
*/
|
|
50
|
-
async function retrieve(props) {
|
|
51
|
-
try {
|
|
52
|
-
const { client, id, partitionKey, databaseId, containerId } = props;
|
|
53
|
-
// Get database and container references
|
|
54
|
-
const database = client.database(databaseId);
|
|
55
|
-
if (!databaseId) {
|
|
56
|
-
return {
|
|
57
|
-
engine: ENGINE,
|
|
58
|
-
error: 'The databaseId or process.env.DATABASE_ID is required'
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const container = database.container(containerId);
|
|
62
|
-
if ((0, platform_helper_util_1.isNonEmptyString)(partitionKey)) {
|
|
63
|
-
const { resource: item } = await container.item(id, partitionKey).read();
|
|
64
|
-
return {
|
|
65
|
-
engine: ENGINE,
|
|
66
|
-
data: item
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
const iterator = container.items.query({
|
|
71
|
-
query: "SELECT * FROM c WHERE c.id = @id",
|
|
72
|
-
parameters: [{ name: "@id", value: id }],
|
|
73
|
-
}, {
|
|
74
|
-
enableCrossPartitionQuery: true,
|
|
75
|
-
maxItemCount: 1, // fetch small pages; still fan-out under the hood
|
|
76
|
-
});
|
|
77
|
-
const { resources: items /*, headers */ } = await iterator.fetchNext();
|
|
78
|
-
return {
|
|
79
|
-
engine: ENGINE,
|
|
80
|
-
data: items?.[0] ?? null
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return {
|
|
86
|
-
engine: ENGINE,
|
|
87
|
-
error: error instanceof Error ? error.message : 'Failed to retrieve document from Cosmos DB'
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/azure-cosmosdb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAiCH,0BAgCC;AAOD,4BAgDC;AAtHD,4EAAqE;AAErE,0CAA6C;AAE7C,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAsBhC;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,KAAiC;IAC3D,IAAI,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;QAE3B,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,iCAAiC;aAC3C,CAAC;QACN,CAAC;QAED,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,iCAAiC;aAC3C,CAAC;QACN,CAAC;QAED,gCAAgC;QAChC,MAAM,MAAM,GAAG,IAAI,qBAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAExD,OAAO;YACH,MAAM,EAAE,MAAM;YACd,MAAM;SACT,CAAC;IAEN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sCAAsC;SACzF,CAAC;IACN,CAAC;AACL,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,QAAQ,CAAI,KAAqC;IACnE,IAAI,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;QAIpE,wCAAwC;QACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,UA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
-
* @fileoverview GCP Firestore implementation
|
|
3
|
-
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
|
|
5
|
-
export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
|
|
6
|
-
export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gcp-firestore/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAI1H,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAG3F;AAGD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAGpG"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview GCP Firestore implementation
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.connect = connect;
|
|
7
|
-
exports.retrieve = retrieve;
|
|
8
|
-
const ENGINE = "gcp-firestore";
|
|
9
|
-
async function connect(props) {
|
|
10
|
-
// TODO: Implement GCP Firestore connection
|
|
11
|
-
throw new Error('GCP Firestore connection not implemented');
|
|
12
|
-
}
|
|
13
|
-
async function retrieve(props) {
|
|
14
|
-
// TODO: Implement GCP Firestore retrieve by ID
|
|
15
|
-
throw new Error('GCP Firestore retrieve not implemented');
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gcp-firestore/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAMH,0BAGC;AAGD,4BAGC;AAXD,MAAM,MAAM,GAAG,eAAe,CAAC;AAExB,KAAK,UAAU,OAAO,CAAC,KAAiC;IAC3D,2CAA2C;IAC3C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;AAChE,CAAC;AAGM,KAAK,UAAU,QAAQ,CAAI,KAAqC;IACnE,+CAA+C;IAC/C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/mongo/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview MongoDB implementation
|
|
3
|
-
*/
|
|
4
|
-
import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
|
|
5
|
-
export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
|
|
6
|
-
export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mongo/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAI1H,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAG3F;AAGD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAGpG"}
|