@teamkeel/functions-runtime 0.394.0-prerelease → 0.394.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/package.json +3 -3
- package/src/File.js +28 -28
- package/src/ModelAPI.js +0 -4
- package/src/ModelAPI.test.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamkeel/functions-runtime",
|
|
3
|
-
"version": "0.394.
|
|
3
|
+
"version": "0.394.1",
|
|
4
4
|
"description": "Internal package used by @teamkeel/sdk",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"vitest": "^0.34.6"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aws-sdk/client-s3": "^3.
|
|
23
|
-
"@aws-sdk/credential-providers": "^3.
|
|
22
|
+
"@aws-sdk/client-s3": "^3.637.0",
|
|
23
|
+
"@aws-sdk/credential-providers": "^3.637.0",
|
|
24
24
|
"@neondatabase/serverless": "^0.9.4",
|
|
25
25
|
"@opentelemetry/api": "^1.7.0",
|
|
26
26
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.46.0",
|
package/src/File.js
CHANGED
|
@@ -205,35 +205,35 @@ async function storeFile(contents, key, filename, contentType, expires) {
|
|
|
205
205
|
console.error("Error uploading file:", error);
|
|
206
206
|
throw error;
|
|
207
207
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const db = useDatabase();
|
|
208
|
+
} else {
|
|
209
|
+
// default to db storage
|
|
210
|
+
const db = useDatabase();
|
|
212
211
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
212
|
+
try {
|
|
213
|
+
let query = db
|
|
214
|
+
.insertInto("keel_storage")
|
|
215
|
+
.values({
|
|
216
|
+
id: key,
|
|
217
|
+
filename: filename,
|
|
218
|
+
content_type: contentType,
|
|
219
|
+
data: contents,
|
|
220
|
+
})
|
|
221
|
+
.onConflict((oc) =>
|
|
222
|
+
oc
|
|
223
|
+
.column("id")
|
|
224
|
+
.doUpdateSet(() => ({
|
|
225
|
+
filename: filename,
|
|
226
|
+
content_type: contentType,
|
|
227
|
+
data: contents,
|
|
228
|
+
}))
|
|
229
|
+
.where("keel_storage.id", "=", key)
|
|
230
|
+
)
|
|
231
|
+
.returningAll();
|
|
232
|
+
|
|
233
|
+
await query.execute();
|
|
234
|
+
} catch (e) {
|
|
235
|
+
throw new DatabaseError(e);
|
|
236
|
+
}
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
package/src/ModelAPI.js
CHANGED
|
@@ -233,7 +233,6 @@ class ModelAPI {
|
|
|
233
233
|
|
|
234
234
|
async function create(conn, tableName, tableConfigs, values) {
|
|
235
235
|
try {
|
|
236
|
-
console.log(values);
|
|
237
236
|
let query = conn.insertInto(tableName);
|
|
238
237
|
|
|
239
238
|
const keys = values ? Object.keys(values) : [];
|
|
@@ -250,9 +249,6 @@ async function create(conn, tableName, tableConfigs, values) {
|
|
|
250
249
|
const columnConfig = tableConfig[key];
|
|
251
250
|
|
|
252
251
|
if (!columnConfig) {
|
|
253
|
-
console.log(key);
|
|
254
|
-
console.log(typeof value);
|
|
255
|
-
console.log(value instanceof InlineFile);
|
|
256
252
|
if (value instanceof InlineFile) {
|
|
257
253
|
const storedFile = await value.store();
|
|
258
254
|
row[key] = storedFile.toDbRecord();
|
package/src/ModelAPI.test.js
CHANGED
|
@@ -37,6 +37,14 @@ beforeEach(async () => {
|
|
|
37
37
|
CREATE TABLE author(
|
|
38
38
|
id text PRIMARY KEY,
|
|
39
39
|
name text NOT NULL
|
|
40
|
+
);
|
|
41
|
+
CREATE TABLE IF NOT EXISTS keel_storage(
|
|
42
|
+
id text NOT NULL,
|
|
43
|
+
filename text NOT NULL,
|
|
44
|
+
content_type text NOT NULL,
|
|
45
|
+
data bytea NOT NULL,
|
|
46
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
47
|
+
PRIMARY KEY (id)
|
|
40
48
|
);`.execute(db);
|
|
41
49
|
|
|
42
50
|
const tableConfigMap = {
|