@teamkeel/functions-runtime 0.374.0 → 0.375.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/.env.test +1 -1
- package/compose.yaml +1 -1
- package/package.json +11 -11
- package/src/ModelAPI.test.js +40 -0
- package/src/applyAdditionalQueryConstraints.js +1 -1
- package/src/database.js +13 -0
- package/src/handleJob.test.js +0 -3
- package/src/handleRequest.test.js +0 -3
package/.env.test
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
KEEL_DB_CONN=postgresql://postgres:postgres@localhost:
|
|
1
|
+
KEEL_DB_CONN=postgresql://postgres:postgres@localhost:7654/functions-runtime
|
|
2
2
|
KEEL_DB_CONN_TYPE=pg
|
package/compose.yaml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamkeel/functions-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.375.1",
|
|
4
4
|
"description": "Internal package used by @teamkeel/sdk",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,20 +15,20 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"prettier": "
|
|
19
|
-
"vitest": "^0.
|
|
18
|
+
"prettier": "3.1.1",
|
|
19
|
+
"vitest": "^0.34.6"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@opentelemetry/api": "^1.
|
|
23
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.
|
|
24
|
-
"@opentelemetry/resources": "^1.
|
|
25
|
-
"@opentelemetry/sdk-trace-base": "^1.
|
|
26
|
-
"@opentelemetry/sdk-trace-node": "^1.
|
|
22
|
+
"@opentelemetry/api": "^1.7.0",
|
|
23
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.46.0",
|
|
24
|
+
"@opentelemetry/resources": "^1.19.0",
|
|
25
|
+
"@opentelemetry/sdk-trace-base": "^1.19.0",
|
|
26
|
+
"@opentelemetry/sdk-trace-node": "^1.19.0",
|
|
27
27
|
"change-case": "^4.1.2",
|
|
28
|
-
"json-rpc-2.0": "^1.
|
|
28
|
+
"json-rpc-2.0": "^1.7.0",
|
|
29
29
|
"ksuid": "^3.0.0",
|
|
30
|
-
"kysely": "^0.23.
|
|
31
|
-
"pg": "^8.
|
|
30
|
+
"kysely": "^0.23.5",
|
|
31
|
+
"pg": "^8.11.3",
|
|
32
32
|
"traceparent": "^1.0.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/ModelAPI.test.js
CHANGED
|
@@ -517,6 +517,46 @@ test("ModelAPI.findMany - orderBy", async () => {
|
|
|
517
517
|
expect(descendingDates.map((r) => r.name)).toEqual(["Sally", "Bob", "Jim"]);
|
|
518
518
|
});
|
|
519
519
|
|
|
520
|
+
test("ModelAPI.findMany - orderBy ASC and DESC capitalised", async () => {
|
|
521
|
+
await personAPI.create({
|
|
522
|
+
id: KSUID.randomSync().string,
|
|
523
|
+
name: "Jim",
|
|
524
|
+
married: false,
|
|
525
|
+
favouriteNumber: 10,
|
|
526
|
+
date: new Date(2023, 12, 29),
|
|
527
|
+
});
|
|
528
|
+
await personAPI.create({
|
|
529
|
+
id: KSUID.randomSync().string,
|
|
530
|
+
name: "Bob",
|
|
531
|
+
married: true,
|
|
532
|
+
favouriteNumber: 11,
|
|
533
|
+
date: new Date(2023, 12, 30),
|
|
534
|
+
});
|
|
535
|
+
await personAPI.create({
|
|
536
|
+
id: KSUID.randomSync().string,
|
|
537
|
+
name: "Sally",
|
|
538
|
+
married: true,
|
|
539
|
+
favouriteNumber: 12,
|
|
540
|
+
date: new Date(2023, 12, 31),
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
const ascendingNames = await personAPI.findMany({
|
|
544
|
+
orderBy: {
|
|
545
|
+
name: "ASC",
|
|
546
|
+
},
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
expect(ascendingNames.map((r) => r.name)).toEqual(["Bob", "Jim", "Sally"]);
|
|
550
|
+
|
|
551
|
+
const descendingNames = await personAPI.findMany({
|
|
552
|
+
orderBy: {
|
|
553
|
+
name: "DESC",
|
|
554
|
+
},
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
expect(descendingNames.map((r) => r.name)).toEqual(["Sally", "Jim", "Bob"]);
|
|
558
|
+
});
|
|
559
|
+
|
|
520
560
|
test("ModelAPI.findMany - offset", async () => {
|
|
521
561
|
await personAPI.create({
|
|
522
562
|
id: KSUID.randomSync().string,
|
|
@@ -10,7 +10,7 @@ function applyOffset(context, qb, offset) {
|
|
|
10
10
|
|
|
11
11
|
function applyOrderBy(context, qb, tableName, orderBy = {}) {
|
|
12
12
|
Object.entries(orderBy).forEach(([key, sortOrder]) => {
|
|
13
|
-
qb = qb.orderBy(`${tableName}.${snakeCase(key)}`, sortOrder);
|
|
13
|
+
qb = qb.orderBy(`${tableName}.${snakeCase(key)}`, sortOrder.toLowerCase());
|
|
14
14
|
});
|
|
15
15
|
return qb;
|
|
16
16
|
}
|
package/src/database.js
CHANGED
|
@@ -145,6 +145,19 @@ function getDialect() {
|
|
|
145
145
|
return new PostgresDialect({
|
|
146
146
|
pool: new InstrumentedPool({
|
|
147
147
|
Client: InstrumentedClient,
|
|
148
|
+
// Increased idle time before closing a connection in the local pool (from 10s default).
|
|
149
|
+
// Establising a new connection on (almost) every functions query can be expensive, so this
|
|
150
|
+
// will reduce having to open connections as regularly. https://node-postgres.com/apis/pool
|
|
151
|
+
//
|
|
152
|
+
// NOTE: We should consider setting this to 0 (i.e. never pool locally) and open and close
|
|
153
|
+
// connections with each invocation. This is because the freeze/thaw nature of lambdas can cause problems
|
|
154
|
+
// with long-lived connections - see https://github.com/brianc/node-postgres/issues/2718
|
|
155
|
+
// Once we're "fully regional" this should not be a performance problem anymore.
|
|
156
|
+
//
|
|
157
|
+
// Although I doubt we will run into these freeze/thaw issues if idleTimeoutMillis is always shorter than the
|
|
158
|
+
// time is takes for a lambda to freeze (which is not a constant, but could be as short as several minutes,
|
|
159
|
+
// https://www.pluralsight.com/resources/blog/cloud/how-long-does-aws-lambda-keep-your-idle-functions-around-before-a-cold-start)
|
|
160
|
+
idleTimeoutMillis: 120000,
|
|
148
161
|
connectionString: mustEnv("KEEL_DB_CONN"),
|
|
149
162
|
}),
|
|
150
163
|
});
|
package/src/handleJob.test.js
CHANGED
|
@@ -99,9 +99,6 @@ describe("ModelAPI error handling", () => {
|
|
|
99
99
|
let db;
|
|
100
100
|
|
|
101
101
|
beforeEach(async () => {
|
|
102
|
-
process.env.KEEL_DB_CONN_TYPE = "pg";
|
|
103
|
-
process.env.KEEL_DB_CONN = `postgresql://postgres:postgres@localhost:5432/functions-runtime`;
|
|
104
|
-
|
|
105
102
|
db = useDatabase();
|
|
106
103
|
|
|
107
104
|
await sql`
|
|
@@ -218,9 +218,6 @@ describe("ModelAPI error handling", () => {
|
|
|
218
218
|
let db;
|
|
219
219
|
|
|
220
220
|
beforeEach(async () => {
|
|
221
|
-
process.env.KEEL_DB_CONN_TYPE = "pg";
|
|
222
|
-
process.env.KEEL_DB_CONN = `postgresql://postgres:postgres@localhost:5432/functions-runtime`;
|
|
223
|
-
|
|
224
221
|
db = useDatabase();
|
|
225
222
|
|
|
226
223
|
await sql`
|