@heyputer/puter.js 2.2.4 → 2.2.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyputer/puter.js",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "Puter.js - A JavaScript library for interacting with Puter services.",
5
5
  "homepage": "https://developer.puter.com",
6
6
  "main": "src/index.js",
@@ -2,6 +2,7 @@ import path from '../../../lib/path.js';
2
2
  import * as utils from '../../../lib/utils.js';
3
3
  import getAbsolutePathForApp from '../utils/getAbsolutePathForApp.js';
4
4
 
5
+ /* eslint-disable */
5
6
  const upload = async function (items, dirPath, options = {}) {
6
7
  return new Promise(async (resolve, reject) => {
7
8
  const DataTransferItem = globalThis.DataTransfer || (class DataTransferItem {
@@ -299,6 +300,7 @@ const upload = async function (items, dirPath, options = {}) {
299
300
  op: options.shortcutTo ? 'shortcut' : 'write',
300
301
  dedupe_name: options.dedupeName ?? true,
301
302
  overwrite: options.overwrite ?? false,
303
+ thumbnail: options.thumbnail ?? undefined,
302
304
  create_missing_ancestors: (options.createMissingAncestors || options.createMissingParents),
303
305
  operation_id: operation_id,
304
306
  path: (
package/src/modules/KV.js CHANGED
@@ -233,6 +233,38 @@ class KV {
233
233
  return utils.make_driver_method(['key'], 'puter-kvstore', undefined, 'add').call(this, options);
234
234
  };
235
235
 
236
+ remove = async (...args) => {
237
+ if ( !args || args.length < 2 ) {
238
+ throw ({ message: 'At least one path is required', code: 'arguments_required' });
239
+ }
240
+
241
+ const key = args[0];
242
+ const paths = args.slice(1);
243
+
244
+ if ( Array.isArray(paths[0]) && paths.length === 1 ) {
245
+ throw ({ message: 'Paths must be provided as separate arguments', code: 'paths_invalid' });
246
+ }
247
+
248
+ if ( key === undefined || key === null ) {
249
+ throw ({ message: 'Key cannot be undefined', code: 'key_undefined' });
250
+ }
251
+
252
+ if ( key.length > this.MAX_KEY_SIZE ) {
253
+ throw ({ message: `Key size cannot be larger than ${this.MAX_KEY_SIZE}`, code: 'key_too_large' });
254
+ }
255
+
256
+ if ( paths.length === 0 ) {
257
+ throw ({ message: 'At least one path is required', code: 'arguments_required' });
258
+ }
259
+
260
+ if ( paths.some((path) => typeof path !== 'string') ) {
261
+ throw ({ message: 'All paths must be strings', code: 'paths_invalid' });
262
+ }
263
+
264
+ return utils.make_driver_method(['key', 'paths'], 'puter-kvstore', undefined, 'remove')
265
+ .call(this, { key, paths });
266
+ };
267
+
236
268
  update = utils.make_driver_method(['key', 'pathAndValueMap', 'ttl'], 'puter-kvstore', undefined, 'update', {
237
269
  preprocess: (args) => {
238
270
  if ( args.key === undefined || args.key === null ) {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-unused-vars */
1
2
  export type KVValue = string | number | boolean | object | unknown;
2
3
  export type KVScalar = KVValue | KVValue[];
3
4
 
@@ -28,6 +29,7 @@ export class KV {
28
29
  incr (key: string, amount?: number | KVIncrementPath): Promise<number>;
29
30
  decr (key: string, amount?: number | KVIncrementPath): Promise<number>;
30
31
  add (key: string, value?: KVValue | KVAddPath): Promise<KVValue>;
32
+ remove (key: string, ...paths: string[]): Promise<KVValue>;
31
33
  update (key: string, pathAndValueMap: KVUpdatePath, ttlSeconds?: number): Promise<KVValue>;
32
34
  expire (key: string, ttlSeconds: number): Promise<boolean>;
33
35
  expireAt (key: string, timestampSeconds: number): Promise<boolean>;