@factorearth/recordmiddleware-dataaccesslayer 1.0.8-alpha.0 → 1.0.9-alpha.0

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.
@@ -0,0 +1 @@
1
+ export declare const getTableSchema: (tableName: string) => Promise<string[]>;
@@ -0,0 +1,26 @@
1
+ import { dynamoDbDocClient } from "./aws-services.js";
2
+ import { DescribeTableCommand } from "@aws-sdk/client-dynamodb";
3
+ export const getTableSchema = async (tableName) => {
4
+ const params = {
5
+ TableName: tableName,
6
+ };
7
+ try {
8
+ const data = await dynamoDbDocClient.send(new DescribeTableCommand(params));
9
+ if (data.Table && data.Table.AttributeDefinitions) {
10
+ const tableSchema = [];
11
+ for (const attribute of data.Table.AttributeDefinitions) {
12
+ if (attribute.AttributeName)
13
+ tableSchema.push(attribute.AttributeName);
14
+ }
15
+ return tableSchema;
16
+ }
17
+ else {
18
+ throw new Error("Table schema could not be retrieved");
19
+ }
20
+ }
21
+ catch (err) {
22
+ console.error("Error", err);
23
+ throw err;
24
+ }
25
+ };
26
+ //# sourceMappingURL=getTableSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTableSchema.js","sourceRoot":"","sources":["../lib/getTableSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,SAAiB,EAAqB,EAAE;IAC5E,MAAM,MAAM,GAAG;QACd,SAAS,EAAE,SAAS;KACpB,CAAC;IAEF,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;QAE5E,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;YACnD,MAAM,WAAW,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;gBACzD,IAAI,SAAS,CAAC,aAAa;oBAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YACxE,CAAC;YACD,OAAO,WAAW,CAAC;QACpB,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC5B,MAAM,GAAG,CAAC;IACX,CAAC;AACF,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./getItem.js";
8
8
  export * from "./putItem.js";
9
9
  export * from "./updateItem.js";
10
10
  export * from "./utils.js";
11
+ export * from "./getTableSchema.js";
11
12
  export declare const MAX_ITEMS_BATCH_WRITE = 25;
12
13
  export declare const MAX_ITEMS_BATCH_READ = 100;
13
14
  export interface BatchInput {
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export * from "./getItem.js";
8
8
  export * from "./putItem.js";
9
9
  export * from "./updateItem.js";
10
10
  export * from "./utils.js";
11
+ export * from "./getTableSchema.js";
11
12
  export const MAX_ITEMS_BATCH_WRITE = 25;
12
13
  export const MAX_ITEMS_BATCH_READ = 100;
13
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAE3B,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AAEpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorearth/recordmiddleware-dataaccesslayer",
3
- "version": "1.0.8-alpha.0",
3
+ "version": "1.0.9-alpha.0",
4
4
  "description": "A module for accessing dynamdb efficiently",
5
5
  "author": "madtrx <marlin.makori@gmail.com>",
6
6
  "homepage": "https://github.com/FactorEarth/RecordMiddleware#readme",
@@ -32,5 +32,5 @@
32
32
  "access": "public",
33
33
  "registry": "https://registry.npmjs.org/"
34
34
  },
35
- "gitHead": "43e00c10896af9c9082e9aa1233764cdee348cc8"
35
+ "gitHead": "75abc890569be67d376ea53e6e427cf40e086781"
36
36
  }