@teamkeel/functions-runtime 0.220.0 → 0.221.1
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/index.d.ts +5 -0
- package/dist/index.js +59 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ declare module '@teamkeel/functions-runtime/db/resolver' {
|
|
|
52
52
|
import { SqlQueryParts } from "@teamkeel/functions-runtime/db/query";
|
|
53
53
|
export interface QueryResolver {
|
|
54
54
|
runQuery(query: SqlQueryParts): Promise<QueryResult>;
|
|
55
|
+
runRawQuery(query: string): Promise<QueryResultRow[]>;
|
|
55
56
|
}
|
|
56
57
|
export interface QueryResult {
|
|
57
58
|
rows: QueryResultRow[];
|
|
@@ -65,6 +66,7 @@ declare module '@teamkeel/functions-runtime/db/resolver' {
|
|
|
65
66
|
constructor(config: {
|
|
66
67
|
connectionString: string;
|
|
67
68
|
});
|
|
69
|
+
runRawQuery(query: string): Promise<QueryResultRow[]>;
|
|
68
70
|
runQuery(query: SqlQueryParts): Promise<QueryResult>;
|
|
69
71
|
private toQuery;
|
|
70
72
|
}
|
|
@@ -79,6 +81,7 @@ declare module '@teamkeel/functions-runtime/db/resolver' {
|
|
|
79
81
|
dbCredentialsSecretArn: string;
|
|
80
82
|
dbName: string;
|
|
81
83
|
});
|
|
84
|
+
runRawQuery(sql: string): Promise<QueryResultRow[]>;
|
|
82
85
|
runQuery(query: SqlQueryParts): Promise<QueryResult>;
|
|
83
86
|
private toQuery;
|
|
84
87
|
private toDataApiFormat;
|
|
@@ -140,6 +143,7 @@ declare module '@teamkeel/functions-runtime/logger/index' {
|
|
|
140
143
|
declare module '@teamkeel/functions-runtime/query' {
|
|
141
144
|
import { Conditions, ChainedQueryOpts, QueryOpts, Input, OrderClauses } from "@teamkeel/functions-runtime/types";
|
|
142
145
|
import * as ReturnTypes from "@teamkeel/functions-runtime/returnTypes";
|
|
146
|
+
import { QueryResultRow } from "@teamkeel/functions-runtime/db/resolver";
|
|
143
147
|
export class ChainableQuery<T extends IDer> {
|
|
144
148
|
private readonly tableName;
|
|
145
149
|
private readonly conditions;
|
|
@@ -164,6 +168,7 @@ declare module '@teamkeel/functions-runtime/query' {
|
|
|
164
168
|
private readonly logger;
|
|
165
169
|
constructor({ tableName, queryResolver, logger }: QueryOpts);
|
|
166
170
|
create: (inputs: Partial<T>) => Promise<ReturnTypes.FunctionCreateResponse<T>>;
|
|
171
|
+
rawSql: (sql: string) => Promise<QueryResultRow[]>;
|
|
167
172
|
where: (conditions: Conditions<T>) => ChainableQuery<T>;
|
|
168
173
|
delete: (id: string) => Promise<ReturnTypes.FunctionDeleteResponse<T>>;
|
|
169
174
|
findOne: (conditions: Conditions<T>) => Promise<ReturnTypes.FunctionGetResponse<T>>;
|
package/dist/index.js
CHANGED
|
@@ -25105,6 +25105,9 @@ var Query = class {
|
|
|
25105
25105
|
errors: []
|
|
25106
25106
|
};
|
|
25107
25107
|
};
|
|
25108
|
+
this.rawSql = async (sql) => {
|
|
25109
|
+
return this.queryResolver.runRawQuery(sql);
|
|
25110
|
+
};
|
|
25108
25111
|
this.where = (conditions) => {
|
|
25109
25112
|
return new ChainableQuery({
|
|
25110
25113
|
tableName: this.tableName,
|
|
@@ -25271,6 +25274,10 @@ var PgQueryResolver = class {
|
|
|
25271
25274
|
constructor(config) {
|
|
25272
25275
|
this.pool = new import_pg.default.Pool({ connectionString: config.connectionString });
|
|
25273
25276
|
}
|
|
25277
|
+
async runRawQuery(query) {
|
|
25278
|
+
const result = await this.pool.query(query);
|
|
25279
|
+
return result.rows;
|
|
25280
|
+
}
|
|
25274
25281
|
async runQuery(query) {
|
|
25275
25282
|
const result = await this.pool.query(this.toQuery(query));
|
|
25276
25283
|
if (result.rows) {
|
|
@@ -25310,6 +25317,58 @@ var AwsRdsDataClientQueryResolver = class {
|
|
|
25310
25317
|
this.dbCredentialsSecretArn = config.dbCredentialsSecretArn;
|
|
25311
25318
|
this.dbName = config.dbName;
|
|
25312
25319
|
}
|
|
25320
|
+
async runRawQuery(sql) {
|
|
25321
|
+
const input = {
|
|
25322
|
+
resourceArn: this.dbClusterResourceArn,
|
|
25323
|
+
secretArn: this.dbCredentialsSecretArn,
|
|
25324
|
+
database: this.dbName,
|
|
25325
|
+
sql,
|
|
25326
|
+
includeResultMetadata: true
|
|
25327
|
+
};
|
|
25328
|
+
const command = new import_client_rds_data.ExecuteStatementCommand(input);
|
|
25329
|
+
const data = await this.client.send(command);
|
|
25330
|
+
const rows = data.records.map((fieldArray) => {
|
|
25331
|
+
const row = {};
|
|
25332
|
+
for (let i = 0; i < fieldArray.length; i++) {
|
|
25333
|
+
const field = fieldArray[i];
|
|
25334
|
+
const column = data.columnMetadata[i].name;
|
|
25335
|
+
const typeName = data.columnMetadata[i].typeName;
|
|
25336
|
+
const value = import_client_rds_data.Field.visit(field, {
|
|
25337
|
+
isNull: function(value2) {
|
|
25338
|
+
return null;
|
|
25339
|
+
},
|
|
25340
|
+
booleanValue: function(value2) {
|
|
25341
|
+
return value2;
|
|
25342
|
+
},
|
|
25343
|
+
longValue: function(value2) {
|
|
25344
|
+
return value2;
|
|
25345
|
+
},
|
|
25346
|
+
doubleValue: function(value2) {
|
|
25347
|
+
return value2;
|
|
25348
|
+
},
|
|
25349
|
+
stringValue: function(value2) {
|
|
25350
|
+
if (typeName === "timestamp") {
|
|
25351
|
+
return new Date(value2);
|
|
25352
|
+
} else {
|
|
25353
|
+
return value2;
|
|
25354
|
+
}
|
|
25355
|
+
},
|
|
25356
|
+
blobValue: function(value2) {
|
|
25357
|
+
return value2;
|
|
25358
|
+
},
|
|
25359
|
+
arrayValue: function(value2) {
|
|
25360
|
+
return value2;
|
|
25361
|
+
},
|
|
25362
|
+
_: function(name, value2) {
|
|
25363
|
+
return value2;
|
|
25364
|
+
}
|
|
25365
|
+
});
|
|
25366
|
+
row[column] = value;
|
|
25367
|
+
}
|
|
25368
|
+
return row;
|
|
25369
|
+
});
|
|
25370
|
+
return rows;
|
|
25371
|
+
}
|
|
25313
25372
|
async runQuery(query) {
|
|
25314
25373
|
const { sql, params } = this.toQuery(query);
|
|
25315
25374
|
const input = {
|