@teamkeel/functions-runtime 0.405.2 → 0.406.2

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/compose.yaml CHANGED
@@ -1,6 +1,6 @@
1
1
  services:
2
2
  postgres:
3
- image: postgres:11.13-alpine
3
+ image: pgvector/pgvector:pg15
4
4
  restart: always
5
5
  environment:
6
6
  - POSTGRES_USER=postgres
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@teamkeel/functions-runtime",
3
- "version": "0.405.2",
3
+ "version": "0.406.2",
4
4
  "description": "Internal package used by @teamkeel/sdk",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
- "test": "vitest run --reporter verbose --threads false",
7
+ "test": "vitest run --reporter verbose --pool=threads --poolOptions.threads.singleThread",
8
8
  "format": "npx prettier --write src/**/*.js"
9
9
  },
10
10
  "keywords": [],
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "prettier": "3.1.1",
19
- "vitest": "^0.34.6"
19
+ "vitest": "^3.0.7"
20
20
  },
21
21
  "dependencies": {
22
22
  "@aws-sdk/client-s3": "~3.722.0",
package/src/File.js CHANGED
@@ -14,7 +14,11 @@ const s3Client = (() => {
14
14
  return null;
15
15
  }
16
16
 
17
- if (!process.env.TEST_AWS_ENDPOINT) {
17
+ // Set in integration tests to send all AWS API calls to a test server
18
+ // for mocking
19
+ const endpoint = process.env.TEST_AWS_ENDPOINT;
20
+
21
+ if (!endpoint) {
18
22
  // If no test endpoint is provided then use the env's configuration
19
23
  return new S3Client({
20
24
  region: process.env.KEEL_REGION,
@@ -22,20 +26,14 @@ const s3Client = (() => {
22
26
  });
23
27
  }
24
28
 
25
- // Set in integration tests to send all AWS API calls to a test server
26
- // for mocking
27
- const endpoint = process.env.TEST_AWS_ENDPOINT;
28
-
29
29
  return new S3Client({
30
30
  region: process.env.KEEL_REGION,
31
31
 
32
- // If a test endpoint is provided then use some test credentials rather than fromEnv()
33
- credentials: endpoint
34
- ? {
35
- accessKeyId: "test",
36
- secretAccessKey: "test",
37
- }
38
- : fromEnv(),
32
+ // If a test endpoint is provided then use some test credentials
33
+ credentials: {
34
+ accessKeyId: "test",
35
+ secretAccessKey: "test",
36
+ },
39
37
 
40
38
  // If a custom endpoint is set we need to use a custom resolver. Just setting the base endpoint isn't enough for S3 as it
41
39
  // as the default resolver uses the bucket name as a sub-domain, which likely won't work with the custom endpoint.
@@ -107,7 +107,9 @@ test("ModelAPI.create - throws if not not null constraint violation", async () =
107
107
  id: KSUID.randomSync().string,
108
108
  name: null,
109
109
  })
110
- ).rejects.toThrow('null value in column "name" violates not-null constraint');
110
+ ).rejects.toThrow(
111
+ 'null value in column "name" of relation "author" violates not-null constraint'
112
+ );
111
113
  });
112
114
 
113
115
  test("ModelAPI.create - throws if database constraint fails", async () => {
@@ -925,7 +927,7 @@ test("ModelAPI.update - throws if not not null constraint violation", async () =
925
927
  );
926
928
 
927
929
  await expect(result).rejects.toThrow(
928
- 'null value in column "name" violates not-null constraint'
930
+ 'null value in column "name" of relation "author" violates not-null constraint'
929
931
  );
930
932
  });
931
933
 
package/src/applyJoins.js CHANGED
@@ -1,3 +1,5 @@
1
+ const { snakeCase } = require("./casing");
2
+
1
3
  /**
2
4
  * Adds the joins required by the where conditions to the given
3
5
  * Kysely instance and returns the resulting new Kysely instance.
@@ -15,7 +17,7 @@ function applyJoins(context, qb, where) {
15
17
  const srcTable = context.tableAlias();
16
18
 
17
19
  for (const key of Object.keys(where)) {
18
- const rel = conf[key];
20
+ const rel = conf[snakeCase(key)];
19
21
  if (!rel) {
20
22
  continue;
21
23
  }
@@ -71,13 +71,12 @@ const opMapping = {
71
71
  */
72
72
  function applyWhereConditions(context, qb, where = {}) {
73
73
  const conf = context.tableConfig();
74
-
75
74
  for (const key of Object.keys(where)) {
76
75
  const v = where[key];
77
76
 
78
77
  // Handle nested where conditions e.g. using a join table
79
- if (conf && conf[key]) {
80
- const rel = conf[key];
78
+ if (conf && conf[snakeCase(key)]) {
79
+ const rel = conf[snakeCase(key)];
81
80
  context.withJoin(rel.referencesTable, () => {
82
81
  qb = applyWhereConditions(context, qb, v);
83
82
  });
@@ -177,12 +177,14 @@ describe("ModelAPI error handling", () => {
177
177
  jsonrpc: "2.0",
178
178
  error: {
179
179
  code: RuntimeErrors.NotNullConstraintError,
180
- message: 'null value in column "title" violates not-null constraint',
180
+ message:
181
+ 'null value in column "title" of relation "post" violates not-null constraint',
181
182
  data: {
182
183
  code: "23502",
183
184
  column: "title",
184
185
  detail: expect.stringContaining("Failing row contains"),
185
186
  table: "post",
187
+ value: undefined,
186
188
  },
187
189
  },
188
190
  });
@@ -229,12 +231,13 @@ describe("ModelAPI error handling", () => {
229
231
  error: {
230
232
  code: RuntimeErrors.NotNullConstraintError,
231
233
  message:
232
- 'null value in column "author_id" violates not-null constraint',
234
+ 'null value in column "author_id" of relation "post" violates not-null constraint',
233
235
  data: {
234
236
  code: "23502",
235
237
  column: "author_id",
236
238
  detail: expect.stringContaining("Failing row contains"),
237
239
  table: "post",
240
+ value: undefined,
238
241
  },
239
242
  },
240
243
  });
@@ -374,12 +374,14 @@ describe("ModelAPI error handling", () => {
374
374
  jsonrpc: "2.0",
375
375
  error: {
376
376
  code: RuntimeErrors.NotNullConstraintError,
377
- message: 'null value in column "title" violates not-null constraint',
377
+ message:
378
+ 'null value in column "title" of relation "post" violates not-null constraint',
378
379
  data: {
379
380
  code: "23502",
380
381
  column: "title",
381
382
  detail: expect.stringContaining("Failing row contains"),
382
383
  table: "post",
384
+ value: undefined,
383
385
  },
384
386
  },
385
387
  });
@@ -423,12 +425,13 @@ describe("ModelAPI error handling", () => {
423
425
  error: {
424
426
  code: RuntimeErrors.NotNullConstraintError,
425
427
  message:
426
- 'null value in column "author_id" violates not-null constraint',
428
+ 'null value in column "author_id" of relation "post" violates not-null constraint',
427
429
  data: {
428
430
  code: "23502",
429
431
  column: "author_id",
430
432
  detail: expect.stringContaining("Failing row contains"),
431
433
  table: "post",
434
+ value: undefined,
432
435
  },
433
436
  },
434
437
  });