Skip to content

Commit

Permalink
fix: fix js
Browse files Browse the repository at this point in the history
  • Loading branch information
RutZap committed Jan 20, 2025
1 parent 96a5bf5 commit e09822b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/functions-runtime/src/ModelAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const { sql } = require("kysely");
const { useDatabase } = require("./database");
const {
transformRichDataTypes,
isPlainObject,
isReferencingExistingRecord,
} = require("./parsing");
const { isPlainObject } = require("./type-utils");
const { QueryBuilder } = require("./QueryBuilder");
const { QueryContext } = require("./QueryContext");
const { applyWhereConditions } = require("./applyWhereConditions");
Expand Down
3 changes: 2 additions & 1 deletion packages/functions-runtime/src/camelCasePlugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { CamelCasePlugin } = require("kysely");
const { isPlainObject, isRichType } = require("./parsing");
const { isPlainObject, isRichType } = require("./type-utils");

// KeelCamelCasePlugin is a wrapper around kysely's camel case plugin.
class KeelCamelCasePlugin {
constructor(opt) {
Expand Down
15 changes: 1 addition & 14 deletions packages/functions-runtime/src/parsing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Duration } = require("./Duration");
const { InlineFile, File } = require("./File");
const { isPlainObject } = require("./type-utils");

// parseInputs takes a set of inputs and creates objects for the ones that are of a complex type.
//
Expand Down Expand Up @@ -81,18 +82,6 @@ function transformRichDataTypes(data) {
return row;
}

function isPlainObject(obj) {
return Object.prototype.toString.call(obj) === "[object Object]";
}

function isRichType(obj) {
if (!isPlainObject(obj)) {
return false;
}

return obj instanceof Duration;
}

function isReferencingExistingRecord(value) {
return Object.keys(value).length === 1 && value.id;
}
Expand All @@ -101,7 +90,5 @@ module.exports = {
parseInputs,
parseOutputs,
transformRichDataTypes,
isPlainObject,
isRichType,
isReferencingExistingRecord,
};
18 changes: 18 additions & 0 deletions packages/functions-runtime/src/type-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { Duration } = require("./Duration");

function isPlainObject(obj) {
return Object.prototype.toString.call(obj) === "[object Object]";
}

function isRichType(obj) {
if (!isPlainObject(obj)) {
return false;
}

return obj instanceof Duration;
}

module.exports = {
isPlainObject,
isRichType,
};

0 comments on commit e09822b

Please sign in to comment.