mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-18 12:07:06 +00:00
* Remove dev-console-ui-utils and update related services * Remove debug console.log statements from backend code Eliminated various leftover console.log and debug print statements across multiple backend modules and services to clean up the codebase and reduce unnecessary logging in production. * Remove unnecessary console.log statements
73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
import { safeHasOwnProperty } from '../lib/objectfn.js';
|
|
import BaseOperation from './BaseOperation.js';
|
|
|
|
export default class extends BaseOperation {
|
|
static requiredForCreate = [
|
|
'uuid',
|
|
'parent_uid',
|
|
];
|
|
|
|
static allowedForCreate = [
|
|
...this.requiredForCreate,
|
|
'name',
|
|
'user_id',
|
|
'is_dir',
|
|
'created',
|
|
'modified',
|
|
'immutable',
|
|
'shortcut_to',
|
|
'is_shortcut',
|
|
'metadata',
|
|
'bucket',
|
|
'bucket_region',
|
|
'thumbnail',
|
|
'accessed',
|
|
'size',
|
|
'symlink_path',
|
|
'is_symlink',
|
|
'associated_app_id',
|
|
'path',
|
|
];
|
|
|
|
constructor (entry) {
|
|
super();
|
|
const requiredForCreate = this.constructor.requiredForCreate;
|
|
const allowedForCreate = this.constructor.allowedForCreate;
|
|
|
|
{
|
|
const sanitized_entry = {};
|
|
for ( const k of allowedForCreate ) {
|
|
if ( safeHasOwnProperty(entry, k) ) {
|
|
sanitized_entry[k] = entry[k];
|
|
}
|
|
}
|
|
entry = sanitized_entry;
|
|
}
|
|
|
|
for ( const k of requiredForCreate ) {
|
|
if ( ! safeHasOwnProperty(entry, k) ) {
|
|
throw new Error(`Missing required property: ${k}`);
|
|
}
|
|
}
|
|
|
|
this.entry = entry;
|
|
}
|
|
|
|
getStatement () {
|
|
const fields = Object.keys(this.entry);
|
|
const statement = 'INSERT INTO fsentries ' +
|
|
`(${fields.join(', ')}) ` +
|
|
`VALUES (${fields.map(() => '?').join(', ')})`;
|
|
const values = fields.map(k => this.entry[k]);
|
|
return { statement, values };
|
|
}
|
|
|
|
apply (answer) {
|
|
answer.entry = { ...this.entry };
|
|
}
|
|
|
|
get uuid () {
|
|
return this.entry.uuid;
|
|
}
|
|
};
|