triangle-utils 1.4.135 → 1.4.137

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 declare class UtilsRDS {
12
12
  exec(sql: string, options?: {
13
13
  is_verbose?: boolean;
14
14
  }): Promise<any[]>;
15
- get(table_id: string, primary_key: Record<string, any>, attribute_names?: string[], options?: {
15
+ get(table_id: string, primary_key: Record<string, any>, options?: {
16
+ attribute_names?: string[];
16
17
  is_verbose?: boolean;
17
18
  }): Promise<Record<string, any> | undefined>;
18
- batch_get(table_id: string, primary_key: Record<string, any[]>, attribute_names?: string[], options?: {
19
+ batch_get(table_id: string, primary_key: Record<string, any[]>, options?: {
20
+ attribute_names?: string[];
19
21
  is_verbose?: boolean;
20
22
  }): Promise<any[]>;
21
23
  create(table_id: string, item: Record<string, any>, options?: {
@@ -30,6 +30,9 @@ function convert_rds_output(input) {
30
30
  else if (input.stringValue !== undefined) {
31
31
  return input.stringValue;
32
32
  }
33
+ else if (input.doubleValue !== undefined) {
34
+ return input.doubleValue;
35
+ }
33
36
  else if (input.longValue !== undefined) {
34
37
  return input.longValue;
35
38
  }
@@ -94,10 +97,10 @@ export class UtilsRDS {
94
97
  sql: sql,
95
98
  includeResultMetadata: true
96
99
  })
97
- // .then(response => {
98
- // console.log(response)
99
- // return response
100
- // })
100
+ .then(response => {
101
+ console.log(JSON.stringify(response, undefined, 4));
102
+ return response;
103
+ })
101
104
  .then(response => (response.records || [])
102
105
  .map((item) => Object.fromEntries((response.columnMetadata || [])
103
106
  .map((column, i) => [column.name || "", column.typeName === "numeric" ? Number(convert_rds_output(item[i])) : convert_rds_output(item[i])])
@@ -112,14 +115,14 @@ export class UtilsRDS {
112
115
  }
113
116
  return items;
114
117
  }
115
- async get(table_id, primary_key, attribute_names, options = {}) {
116
- const sql = "SELECT " + (attribute_names === undefined ? "*" : attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ");
118
+ async get(table_id, primary_key, options = {}) {
119
+ const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ");
117
120
  const items = await this.exec(sql, options);
118
121
  const item = items[0];
119
122
  return item;
120
123
  }
121
- async batch_get(table_id, primary_key, attribute_names, options = {}) {
122
- const sql = "SELECT " + (attribute_names === undefined ? "*" : attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, values]) => key_name + " IN " + "(" + values.map(value => convert_rds_input(value)).join(", ") + ")").join(" AND ");
124
+ async batch_get(table_id, primary_key, options = {}) {
125
+ const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, values]) => key_name + " IN " + "(" + values.map(value => convert_rds_input(value)).join(", ") + ")").join(" AND ");
123
126
  const items = await this.exec(sql, options);
124
127
  return items;
125
128
  }
package/dist/src/f.js CHANGED
@@ -73,4 +73,5 @@ const utils = new TriangleUtils(config);
73
73
  // name : "2026 Election in North Dakota",
74
74
  // target_ids : ["TURNOUT-2026-11-03"]
75
75
  // }, { is_verbose : true }))
76
- // console.log(await utils.rds.exec("SELECT * FROM prisms", { is_verbose : true }))
76
+ // console.log(await utils.rds.exec("SELECT * FROM prisms", { is_verbose : true }))\
77
+ console.log(await utils.rds.exec("SELECT * FROM state_voter_targets WHERE state_id = 'ND' AND voter_id = '187195'"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.135",
3
+ "version": "1.4.137",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsRDS.ts CHANGED
@@ -25,6 +25,8 @@ function convert_rds_output(input : Field) {
25
25
  return undefined
26
26
  } else if (input.stringValue !== undefined) {
27
27
  return input.stringValue
28
+ } else if (input.doubleValue !== undefined) {
29
+ return input.doubleValue
28
30
  } else if (input.longValue !== undefined) {
29
31
  return input.longValue
30
32
  } else if (input.booleanValue !== undefined) {
@@ -113,10 +115,10 @@ export class UtilsRDS {
113
115
  sql : sql,
114
116
  includeResultMetadata : true
115
117
  })
116
- // .then(response => {
117
- // console.log(response)
118
- // return response
119
- // })
118
+ .then(response => {
119
+ console.log(JSON.stringify(response, undefined, 4))
120
+ return response
121
+ })
120
122
  .then(response => (response.records || [])
121
123
  .map((item : any) => Object.fromEntries((response.columnMetadata || [])
122
124
  .map((column, i) => [column.name || "", column.typeName === "numeric" ? Number(convert_rds_output(item[i])) : convert_rds_output(item[i])])
@@ -137,12 +139,12 @@ export class UtilsRDS {
137
139
  async get(
138
140
  table_id : string,
139
141
  primary_key : Record<string, any>,
140
- attribute_names? : string[],
141
142
  options : {
143
+ attribute_names? : string[],
142
144
  is_verbose? : boolean
143
145
  } = {}
144
146
  ) {
145
- const sql = "SELECT " + (attribute_names === undefined ? "*" : attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ")
147
+ const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ")
146
148
  const items = await this.exec(sql, options)
147
149
  const item : Record<string, any> | undefined = items[0]
148
150
  return item
@@ -151,12 +153,12 @@ export class UtilsRDS {
151
153
  async batch_get(
152
154
  table_id : string,
153
155
  primary_key : Record<string, any[]>,
154
- attribute_names? : string[],
155
156
  options : {
157
+ attribute_names? : string[],
156
158
  is_verbose? : boolean
157
159
  } = {}
158
160
  ) {
159
- const sql = "SELECT " + (attribute_names === undefined ? "*" : attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, values]) => key_name + " IN " + "(" + values.map(value => convert_rds_input(value)).join(", ") + ")").join(" AND ")
161
+ const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, values]) => key_name + " IN " + "(" + values.map(value => convert_rds_input(value)).join(", ") + ")").join(" AND ")
160
162
  const items = await this.exec(sql, options)
161
163
  return items
162
164
  }
package/src/f.ts CHANGED
@@ -91,4 +91,7 @@ const utils = new TriangleUtils(config)
91
91
  // target_ids : ["TURNOUT-2026-11-03"]
92
92
  // }, { is_verbose : true }))
93
93
 
94
- // console.log(await utils.rds.exec("SELECT * FROM prisms", { is_verbose : true }))
94
+ // console.log(await utils.rds.exec("SELECT * FROM prisms", { is_verbose : true }))\
95
+
96
+
97
+ console.log(await utils.rds.exec("SELECT * FROM state_voter_targets WHERE state_id = 'ND' AND voter_id = '187195'"))