@junobuild/functions 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +99 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -219,6 +219,10 @@ Parameters:
219
219
  - `caller`: - The caller identity, either a raw `Uint8Array`
220
220
  or a `Principal` instance.
221
221
 
222
+ Returns:
223
+
224
+ The raw user ID as a `Uint8Array`.
225
+
222
226
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/utils/caller.utils.ts#L12)
223
227
 
224
228
  #### :gear: getAdminControllers
@@ -229,6 +233,10 @@ Gets the list of admin controllers from the Satellite.
229
233
  | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
230
234
  | `getAdminControllers` | `() => [Uint8Array<ArrayBufferLike>, { metadata: [string, string][]; created_at: bigint; updated_at: bigint; scope: "write" or "admin" or "submit"; expires_at?: bigint or undefined; }][]` |
231
235
 
236
+ Returns:
237
+
238
+ The list of admin controllers.
239
+
232
240
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/controllers.sdk.ts#L15)
233
241
 
234
242
  #### :gear: getControllers
@@ -239,6 +247,10 @@ Gets the list of controllers from the Satellite.
239
247
  | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
240
248
  | `getControllers` | `() => [Uint8Array<ArrayBufferLike>, { metadata: [string, string][]; created_at: bigint; updated_at: bigint; scope: "write" or "admin" or "submit"; expires_at?: bigint or undefined; }][]` |
241
249
 
250
+ Returns:
251
+
252
+ The list of all controllers.
253
+
242
254
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/controllers.sdk.ts#L24)
243
255
 
244
256
  #### :gear: isAdminController
@@ -254,6 +266,10 @@ Parameters:
254
266
  - `params`: - The parameters including the caller identity
255
267
  and the list of controllers to verify against.
256
268
 
269
+ Returns:
270
+
271
+ Whether the caller is an admin.
272
+
257
273
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/controllers.sdk.ts#L36)
258
274
 
259
275
  #### :gear: isController
@@ -269,6 +285,10 @@ Parameters:
269
285
  - `params`: - The parameters including the caller identity
270
286
  and the list of controllers to verify against.
271
287
 
288
+ Returns:
289
+
290
+ Whether the caller is a controller.
291
+
272
292
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/controllers.sdk.ts#L56)
273
293
 
274
294
  #### :gear: setDocStore
@@ -286,6 +306,11 @@ Parameters:
286
306
  - `params`: - The parameters required to store the document,
287
307
  including the caller, collection, key, and document data.
288
308
 
309
+ Returns:
310
+
311
+ The context of the stored or updated document,
312
+ including its key, collection, and both the previous and current versions of the document.
313
+
289
314
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L39)
290
315
 
291
316
  #### :gear: deleteDocStore
@@ -301,6 +326,11 @@ Parameters:
301
326
  - `params`: - The parameters required to delete the document,
302
327
  including the caller, collection, key, and the expected version of the document.
303
328
 
329
+ Returns:
330
+
331
+ The context of the deleted document,
332
+ including its key, collection, and optionally the previous document data if it existed.
333
+
304
334
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L61)
305
335
 
306
336
  #### :gear: getDocStore
@@ -315,6 +345,10 @@ Parameters:
315
345
 
316
346
  - `params`: - The parameters required to get the document.
317
347
 
348
+ Returns:
349
+
350
+ The document if found, or undefined if not.
351
+
318
352
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L81)
319
353
 
320
354
  #### :gear: listDocsStore
@@ -329,6 +363,10 @@ Parameters:
329
363
 
330
364
  - `params`: - The parameters required to perform the list operation.
331
365
 
366
+ Returns:
367
+
368
+ A list result containing matching documents and pagination metadata.
369
+
332
370
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L101)
333
371
 
334
372
  #### :gear: countCollectionDocsStore
@@ -343,6 +381,10 @@ Parameters:
343
381
 
344
382
  - `params`: - The parameters required to count documents in the collection.
345
383
 
384
+ Returns:
385
+
386
+ The total number of documents in the specified collection.
387
+
346
388
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L121)
347
389
 
348
390
  #### :gear: countDocsStore
@@ -357,6 +399,10 @@ Parameters:
357
399
 
358
400
  - `params`: - The parameters required to perform the filtered count.
359
401
 
402
+ Returns:
403
+
404
+ The number of documents that match the provided filters.
405
+
360
406
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L139)
361
407
 
362
408
  #### :gear: deleteDocsStore
@@ -385,6 +431,10 @@ Parameters:
385
431
 
386
432
  - `params`: - The parameters required to perform the filtered deletion.
387
433
 
434
+ Returns:
435
+
436
+ The context resulting of the deletion of documents that match the provided filters.
437
+
388
438
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L175)
389
439
 
390
440
  #### :gear: decodeDocData
@@ -399,6 +449,10 @@ Parameters:
399
449
 
400
450
  - `data`: - The raw data to be decoded.
401
451
 
452
+ Returns:
453
+
454
+ The parsed JavaScript object.
455
+
402
456
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L11)
403
457
 
404
458
  #### :gear: encodeDocData
@@ -413,6 +467,10 @@ Parameters:
413
467
 
414
468
  - `data`: - The data to be encoded.
415
469
 
470
+ Returns:
471
+
472
+ The serialized raw data.
473
+
416
474
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L21)
417
475
 
418
476
  #### :gear: countCollectionAssetsStore
@@ -427,6 +485,10 @@ Parameters:
427
485
 
428
486
  - `params`: - The parameters required to count assets in the collection.
429
487
 
488
+ Returns:
489
+
490
+ The total number of assets in the specified collection.
491
+
430
492
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L35)
431
493
 
432
494
  #### :gear: countAssetsStore
@@ -441,6 +503,10 @@ Parameters:
441
503
 
442
504
  - `params`: - The parameters required to perform the filtered count.
443
505
 
506
+ Returns:
507
+
508
+ The number of assets that match the provided filters.
509
+
444
510
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L53)
445
511
 
446
512
  #### :gear: setAssetHandler
@@ -469,6 +535,10 @@ Parameters:
469
535
 
470
536
  - `params`: - The parameters required to delete the asset.
471
537
 
538
+ Returns:
539
+
540
+ The potentially deleted asset.
541
+
472
542
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L89)
473
543
 
474
544
  #### :gear: deleteAssetsStore
@@ -497,6 +567,10 @@ Parameters:
497
567
 
498
568
  - `params`: - The parameters required to perform the filtered deletion.
499
569
 
570
+ Returns:
571
+
572
+ The potential asset resulting of the deletion that match the provided filters.
573
+
500
574
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L125)
501
575
 
502
576
  #### :gear: getAssetStore
@@ -511,6 +585,10 @@ Parameters:
511
585
 
512
586
  - `params`: - The parameters required to get the asset.
513
587
 
588
+ Returns:
589
+
590
+ The asset if found, or undefined if not.
591
+
514
592
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L147)
515
593
 
516
594
  #### :gear: listAssetsStore
@@ -525,6 +603,10 @@ Parameters:
525
603
 
526
604
  - `params`: - The parameters required to perform the list operation.
527
605
 
606
+ Returns:
607
+
608
+ A list result containing matching assets and pagination metadata.
609
+
528
610
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L167)
529
611
 
530
612
  #### :gear: getContentChunksStore
@@ -541,6 +623,10 @@ Parameters:
541
623
 
542
624
  - `params`: - The parameters including encoding, chunk index, and memory type.
543
625
 
626
+ Returns:
627
+
628
+ The content chunk if found, or `undefined` if not.
629
+
544
630
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L189)
545
631
 
546
632
  #### :gear: call
@@ -558,6 +644,11 @@ Parameters:
558
644
 
559
645
  - `params`: - The parameters required for the canister call
560
646
 
647
+ Returns:
648
+
649
+ A promise resolving to the decoded result of the call.
650
+ Returns `undefined` if the canister response is empty.
651
+
561
652
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/call.ic-cdk.ts#L20)
562
653
 
563
654
  #### :gear: id
@@ -572,6 +663,10 @@ the Principal of the executing canister.
572
663
  | -------- | ----------------- |
573
664
  | `id` | `() => Principal` |
574
665
 
666
+ Returns:
667
+
668
+ The Principal ID of the Satellite.
669
+
575
670
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/id.ic-cdk.ts#L12)
576
671
 
577
672
  #### :gear: time
@@ -586,6 +681,10 @@ the system time publicly exposed and verified part of the IC state tree
586
681
  | -------- | -------------- |
587
682
  | `time` | `() => bigint` |
588
683
 
684
+ Returns:
685
+
686
+ The current timestamp.
687
+
589
688
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/time.ic-cdk.ts#L10)
590
689
 
591
690
  ### :wrench: Constants
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/functions",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",