Spaces:
Sleeping
Sleeping
Download extensions/puterfs/fsentries/Insert.js from AZILS/puter-deploy: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/spaces/AZILS/puter-deploy/resolve/main/extensions/puterfs/fsentries/Insert.js
- Command line
-
hf download hf://spaces/AZILS/puter-deploy/extensions/puterfs/fsentries/Insert.js
-
curl -L -o Insert.js https://huggingface.co/spaces/AZILS/puter-deploy/resolve/main/extensions/puterfs/fsentries/Insert.js
1.89 kB
| 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; | |
| } | |
| }; | |