@junobuild/functions 0.5.1-next-2025-11-29.1 → 0.5.1-next-2025-12-01

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/README.md CHANGED
@@ -53,7 +53,6 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
53
53
  - [deleteAssetStore](#gear-deleteassetstore)
54
54
  - [deleteAssetsStore](#gear-deleteassetsstore)
55
55
  - [deleteFilteredAssetsStore](#gear-deletefilteredassetsstore)
56
- - [setAssetTokenStore](#gear-setassettokenstore)
57
56
  - [getAssetStore](#gear-getassetstore)
58
57
  - [listAssetsStore](#gear-listassetsstore)
59
58
  - [getContentChunksStore](#gear-getcontentchunksstore)
@@ -530,7 +529,7 @@ Returns:
530
529
 
531
530
  The total number of assets in the specified collection.
532
531
 
533
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L37)
532
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L35)
534
533
 
535
534
  #### :gear: countAssetsStore
536
535
 
@@ -548,7 +547,7 @@ Returns:
548
547
 
549
548
  The number of assets that match the provided filters.
550
549
 
551
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L55)
550
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L53)
552
551
 
553
552
  #### :gear: setAssetHandler
554
553
 
@@ -562,7 +561,7 @@ Parameters:
562
561
 
563
562
  - `params`: - The parameters required to set or update an asset.
564
563
 
565
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L73)
564
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L71)
566
565
 
567
566
  #### :gear: deleteAssetStore
568
567
 
@@ -580,7 +579,7 @@ Returns:
580
579
 
581
580
  The potentially deleted asset.
582
581
 
583
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L91)
582
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L89)
584
583
 
585
584
  #### :gear: deleteAssetsStore
586
585
 
@@ -594,7 +593,7 @@ Parameters:
594
593
 
595
594
  - `params`: - The parameters required to delete assets in the collection.
596
595
 
597
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L109)
596
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L107)
598
597
 
599
598
  #### :gear: deleteFilteredAssetsStore
600
599
 
@@ -612,21 +611,7 @@ Returns:
612
611
 
613
612
  The potential asset resulting of the deletion that match the provided filters.
614
613
 
615
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L127)
616
-
617
- #### :gear: setAssetTokenStore
618
-
619
- Set or update an access token for an asset in a collection's store.
620
-
621
- | Function | Type |
622
- | -------------------- | -------------------------------------------- |
623
- | `setAssetTokenStore` | `(params: SetAssetTokenStoreParams) => void` |
624
-
625
- Parameters:
626
-
627
- - `params`: - The parameters required to set the token of the asset.
628
-
629
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L147)
614
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L125)
630
615
 
631
616
  #### :gear: getAssetStore
632
617
 
@@ -644,7 +629,7 @@ Returns:
644
629
 
645
630
  The asset if found, or undefined if not.
646
631
 
647
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L167)
632
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L147)
648
633
 
649
634
  #### :gear: listAssetsStore
650
635
 
@@ -662,7 +647,7 @@ Returns:
662
647
 
663
648
  A list result containing matching assets and pagination metadata.
664
649
 
665
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L187)
650
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L167)
666
651
 
667
652
  #### :gear: getContentChunksStore
668
653
 
@@ -682,7 +667,7 @@ Returns:
682
667
 
683
668
  The content chunk if found, or `undefined` if not.
684
669
 
685
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L209)
670
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L189)
686
671
 
687
672
  #### :gear: call
688
673
 
@@ -780,7 +765,6 @@ The current timestamp.
780
765
  - [BatchSchema](#gear-batchschema)
781
766
  - [CommitBatchSchema](#gear-commitbatchschema)
782
767
  - [FullPathSchema](#gear-fullpathschema)
783
- - [AssetAccessTokenSchema](#gear-assetaccesstokenschema)
784
768
  - [OptionAssetSchema](#gear-optionassetschema)
785
769
  - [AssetAssertUploadSchema](#gear-assetassertuploadschema)
786
770
  - [OnUploadAssetContextSchema](#gear-onuploadassetcontextschema)
@@ -834,7 +818,6 @@ The current timestamp.
834
818
  - [DeleteAssetsStoreParamsSchema](#gear-deleteassetsstoreparamsschema)
835
819
  - [DeleteFilteredAssetsStoreParamsSchema](#gear-deletefilteredassetsstoreparamsschema)
836
820
  - [DeleteAssetStoreParamsSchema](#gear-deleteassetstoreparamsschema)
837
- - [SetAssetTokenStoreParamsSchema](#gear-setassettokenstoreparamsschema)
838
821
  - [ListAssetsStoreParamsSchema](#gear-listassetsstoreparamsschema)
839
822
  - [GetContentChunksStoreParamsSchema](#gear-getcontentchunksstoreparamsschema)
840
823
  - [IDLTypeSchema](#gear-idltypeschema)
@@ -1273,18 +1256,6 @@ References:
1273
1256
 
1274
1257
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L339)
1275
1258
 
1276
- #### :gear: AssetAccessTokenSchema
1277
-
1278
- | Constant | Type |
1279
- | ------------------------ | ------------------------ |
1280
- | `AssetAccessTokenSchema` | `ZodOptional<ZodString>` |
1281
-
1282
- References:
1283
-
1284
- - AssetAccessToken
1285
-
1286
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L352)
1287
-
1288
1259
  #### :gear: OptionAssetSchema
1289
1260
 
1290
1261
  | Constant | Type |
@@ -1295,7 +1266,7 @@ References:
1295
1266
 
1296
1267
  - OptionAsset
1297
1268
 
1298
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L365)
1269
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L352)
1299
1270
 
1300
1271
  #### :gear: AssetAssertUploadSchema
1301
1272
 
@@ -1847,7 +1818,7 @@ References:
1847
1818
 
1848
1819
  - GetAssetStoreParams
1849
1820
 
1850
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L28)
1821
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L26)
1851
1822
 
1852
1823
  #### :gear: CountCollectionAssetsStoreParamsSchema
1853
1824
 
@@ -1859,7 +1830,7 @@ References:
1859
1830
 
1860
1831
  - CountCollectionAssetsStoreParams
1861
1832
 
1862
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L51)
1833
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L49)
1863
1834
 
1864
1835
  #### :gear: CountAssetsStoreParamsSchema
1865
1836
 
@@ -1871,7 +1842,7 @@ References:
1871
1842
 
1872
1843
  - CountAssetsStoreParams
1873
1844
 
1874
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L61)
1845
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L59)
1875
1846
 
1876
1847
  #### :gear: SetAssetHandlerParamsSchema
1877
1848
 
@@ -1883,7 +1854,7 @@ References:
1883
1854
 
1884
1855
  - SetAssetHandlerParams
1885
1856
 
1886
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L71)
1857
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L69)
1887
1858
 
1888
1859
  #### :gear: DeleteAssetsStoreParamsSchema
1889
1860
 
@@ -1895,7 +1866,7 @@ References:
1895
1866
 
1896
1867
  - DeleteAssetsStoreParams
1897
1868
 
1898
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L102)
1869
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L100)
1899
1870
 
1900
1871
  #### :gear: DeleteFilteredAssetsStoreParamsSchema
1901
1872
 
@@ -1907,7 +1878,7 @@ References:
1907
1878
 
1908
1879
  - DeleteFilteredAssetsParams
1909
1880
 
1910
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L112)
1881
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L110)
1911
1882
 
1912
1883
  #### :gear: DeleteAssetStoreParamsSchema
1913
1884
 
@@ -1919,19 +1890,7 @@ References:
1919
1890
 
1920
1891
  - DeleteAssetStoreParams
1921
1892
 
1922
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L122)
1923
-
1924
- #### :gear: SetAssetTokenStoreParamsSchema
1925
-
1926
- | Constant | Type |
1927
- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1928
- | `SetAssetTokenStoreParamsSchema` | `ZodObject<{ collection: ZodString; caller: ZodUnion<[ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, ZodCustom<...>]>; full_path: ZodString; token: ZodOptional<...>; }, $strict>` |
1929
-
1930
- References:
1931
-
1932
- - SetAssetTokenStoreParams
1933
-
1934
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L132)
1893
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L120)
1935
1894
 
1936
1895
  #### :gear: ListAssetsStoreParamsSchema
1937
1896
 
@@ -1943,7 +1902,7 @@ References:
1943
1902
 
1944
1903
  - ListAssetsStoreParams
1945
1904
 
1946
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L150)
1905
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L130)
1947
1906
 
1948
1907
  #### :gear: GetContentChunksStoreParamsSchema
1949
1908
 
@@ -1955,7 +1914,7 @@ References:
1955
1914
 
1956
1915
  - GetContentChunksStoreParams
1957
1916
 
1958
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L160)
1917
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L140)
1959
1918
 
1960
1919
  #### :gear: IDLTypeSchema
1961
1920
 
@@ -2352,7 +2311,7 @@ The parameters required to set (or update) an asset.
2352
2311
  | `content` | `Blob` | The binary content of the asset. |
2353
2312
  | `headers` | `HeaderFields` | Associated HTTP headers. |
2354
2313
 
2355
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L82)
2314
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L80)
2356
2315
 
2357
2316
  #### :gear: GetContentChunksStoreParams
2358
2317
 
@@ -2364,7 +2323,7 @@ The parameters required to retrieve a specific chunk from an asset.
2364
2323
  | `chunk_index` | `bigint` | The index of the chunk to retrieve. |
2365
2324
  | `memory` | `"heap" or "stable"` | The memory type to retrieve the chunk from. |
2366
2325
 
2367
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L171)
2326
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L151)
2368
2327
 
2369
2328
  #### :gear: CallParams
2370
2329
 
@@ -2414,7 +2373,6 @@ Type representing the parameters required to make a canister call.
2414
2373
  - [ChunkId](#gear-chunkid)
2415
2374
  - [BatchId](#gear-batchid)
2416
2375
  - [FullPath](#gear-fullpath)
2417
- - [AssetAccessToken](#gear-assetaccesstoken)
2418
2376
  - [OptionAsset](#gear-optionasset)
2419
2377
  - [OnUploadAssetContext](#gear-onuploadassetcontext)
2420
2378
  - [OnDeleteAssetContext](#gear-ondeleteassetcontext)
@@ -2465,7 +2423,6 @@ Type representing the parameters required to make a canister call.
2465
2423
  - [DeleteAssetsStoreParams](#gear-deleteassetsstoreparams)
2466
2424
  - [DeleteFilteredAssetsStoreParams](#gear-deletefilteredassetsstoreparams)
2467
2425
  - [DeleteAssetStoreParams](#gear-deleteassetstoreparams)
2468
- - [SetAssetTokenStoreParams](#gear-setassettokenstoreparams)
2469
2426
  - [ListAssetsStoreParams](#gear-listassetsstoreparams)
2470
2427
  - [IDLType](#gear-idltype)
2471
2428
  - [CallArg](#gear-callarg)
@@ -2846,19 +2803,6 @@ Example: `/images/a-sun-above-the-mountains.png`
2846
2803
 
2847
2804
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L347)
2848
2805
 
2849
- #### :gear: AssetAccessToken
2850
-
2851
- An optional access token that can be used to make an asset private on the web.
2852
- Private as in practically unguessable (if complex enough and not shared of course).
2853
-
2854
- Example: `/images/a-sun-above-the-mountains.png?token=a-super-long-unguessable-not-shared-id`
2855
-
2856
- | Type | Type |
2857
- | ------------------ | --------------------- |
2858
- | `AssetAccessToken` | `string or undefined` |
2859
-
2860
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L360)
2861
-
2862
2806
  #### :gear: OptionAsset
2863
2807
 
2864
2808
  A shorthand for an asset that might or not be defined.
@@ -2867,7 +2811,7 @@ A shorthand for an asset that might or not be defined.
2867
2811
  | ------------- | -------------------- |
2868
2812
  | `OptionAsset` | `Asset or undefined` |
2869
2813
 
2870
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L370)
2814
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/storage.ts#L357)
2871
2815
 
2872
2816
  #### :gear: OnUploadAssetContext
2873
2817
 
@@ -3319,7 +3263,7 @@ Represents the base parameters required to access the storage and modify an asse
3319
3263
  | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3320
3264
  | `GetAssetStoreParams` | `CollectionParams and { /** * The caller who initiate the document operation. */ caller: RawUserId or UserId; /** * The full_path identifying the asset within the collection. */ full_path: FullPath; }` |
3321
3265
 
3322
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L36)
3266
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L34)
3323
3267
 
3324
3268
  #### :gear: CountCollectionAssetsStoreParams
3325
3269
 
@@ -3329,7 +3273,7 @@ The parameters required to count documents from the storage.
3329
3273
  | ---------------------------------- | ------------------ |
3330
3274
  | `CountCollectionAssetsStoreParams` | `CollectionParams` |
3331
3275
 
3332
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L56)
3276
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L54)
3333
3277
 
3334
3278
  #### :gear: CountAssetsStoreParams
3335
3279
 
@@ -3339,7 +3283,7 @@ The parameters required to count documents from the storage.
3339
3283
  | ------------------------ | ----------------- |
3340
3284
  | `CountAssetsStoreParams` | `ListStoreParams` |
3341
3285
 
3342
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L66)
3286
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L64)
3343
3287
 
3344
3288
  #### :gear: DeleteAssetsStoreParams
3345
3289
 
@@ -3349,7 +3293,7 @@ The parameters required to delete the assets from a collection of the storage.
3349
3293
  | ------------------------- | ------------------ |
3350
3294
  | `DeleteAssetsStoreParams` | `CollectionParams` |
3351
3295
 
3352
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L107)
3296
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L105)
3353
3297
 
3354
3298
  #### :gear: DeleteFilteredAssetsStoreParams
3355
3299
 
@@ -3359,7 +3303,7 @@ The parameters required to delete assets from the storage.
3359
3303
  | --------------------------------- | ----------------- |
3360
3304
  | `DeleteFilteredAssetsStoreParams` | `ListStoreParams` |
3361
3305
 
3362
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L117)
3306
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L115)
3363
3307
 
3364
3308
  #### :gear: DeleteAssetStoreParams
3365
3309
 
@@ -3369,17 +3313,7 @@ Represents the parameters required to delete an asset.
3369
3313
  | ------------------------ | --------------------- |
3370
3314
  | `DeleteAssetStoreParams` | `GetAssetStoreParams` |
3371
3315
 
3372
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L127)
3373
-
3374
- #### :gear: SetAssetTokenStoreParams
3375
-
3376
- Represents the parameters required to delete an asset.
3377
-
3378
- | Type | Type |
3379
- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3380
- | `SetAssetTokenStoreParams` | `GetAssetStoreParams and { /** * The token to apply to the asset. * Setting `undefined` removes the protection and makes the asset public. */ token: AssetAccessToken; }` |
3381
-
3382
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L139)
3316
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L125)
3383
3317
 
3384
3318
  #### :gear: ListAssetsStoreParams
3385
3319
 
@@ -3389,7 +3323,7 @@ The parameters required to list documents from the datastore.
3389
3323
  | ----------------------- | ----------------- |
3390
3324
  | `ListAssetsStoreParams` | `ListStoreParams` |
3391
3325
 
3392
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L155)
3326
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/storage.ts#L135)
3393
3327
 
3394
3328
  #### :gear: IDLType
3395
3329
 
@@ -0,0 +1,2 @@
1
+ import{a as s,b as h,c as l}from"./chunk-7B6WU32N.js";import*as i from"zod";var o=i.bigint(),r=i.bigint(),n=h,O=l,y=i.string(),c=i.string(),a=i.string().max(1024);import*as p from"zod";var g=s,_=p.object({owner:n,data:g,description:a.optional(),created_at:o,updated_at:o,version:r.optional()}).strict(),H=_.optional(),V=p.object({data:g,description:a.optional(),version:r.optional()}).strict(),P=p.object({version:r.optional()}).strict();import*as e from"zod";var u=e.tuple([e.string(),e.string()]),x=e.array(u),T=s,A=T,D=e.instanceof(Uint8Array).refine(m=>m.length===32,{message:"Hash must be a Uint8Array of length 32"}),z=e.object({name:e.string(),full_path:e.string(),token:e.string().optional(),collection:y,owner:n,description:a.optional()}).strict(),S=e.object({modified:o,content_chunks:e.array(A),total_length:e.bigint(),sha256:D}),w=S.omit({content_chunks:!0}).strict(),d=e.enum(["identity","gzip","compress","deflate","br"]),f=e.object({key:z,headers:x,encodings:e.array(e.tuple([d,S])),created_at:o,updated_at:o,version:r.optional()}).strict(),q=f.omit({encodings:!0}).extend({encodings:e.array(e.tuple([d,w]))}).strict(),I=e.bigint(),Z=e.object({key:z,reference_id:I.optional(),expires_at:o,encoding_type:d.optional()}).strict(),U=e.bigint(),R=e.bigint(),G=e.object({batch_id:R,headers:x,chunk_ids:e.array(U)}).strict(),J=e.string(),Q=f.optional();import*as t from"zod";var b=t.union([t.object({equal:o}),t.object({greater_than:o}),t.object({less_than:o}),t.object({between:t.tuple([o,o])})]),k=t.object({key:c.optional(),description:a.optional(),created_at:b.optional(),updated_at:b.optional()}).strict(),j=t.object({start_after:c.optional(),limit:t.bigint().optional()}).strict(),C=t.enum(["keys","created_at","updated_at"]),L=t.object({desc:t.boolean(),field:C}).strict(),Y=t.object({matcher:k.optional(),paginate:j.optional(),order:L.optional(),owner:n.optional()}).strict(),$=m=>t.object({items:t.array(t.tuple([c,m])),items_length:t.bigint(),items_page:t.bigint().optional(),matches_length:t.bigint(),matches_pages:t.bigint().optional()}).strict();export{o as a,r as b,n as c,O as d,y as e,c as f,a as g,g as h,_ as i,H as j,V as k,P as l,x as m,T as n,z as o,S as p,f as q,q as r,Z as s,G as t,J as u,Q as v,b as w,k as x,j as y,C as z,L as A,Y as B,$ as C};
2
+ //# sourceMappingURL=chunk-4ZHRSCXC.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/schemas/satellite.ts", "src/schemas/db.ts", "src/schemas/storage.ts", "src/schemas/list.ts"],
4
- "sourcesContent": ["import * as z from 'zod';\nimport {PrincipalSchema, RawPrincipalSchema} from './candid';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = z.infer<typeof RawUserIdSchema>;\n\n/**\n * @see UserId\n */\nexport const UserIdSchema = PrincipalSchema;\n\n/**\n * Represents a user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type UserId = z.infer<typeof UserIdSchema>;\n\n/**\n * @see Collection\n */\nexport const CollectionSchema = z.string();\n\n/**\n * A collection name where data are stored.\n */\nexport type Collection = z.infer<typeof CollectionSchema>;\n\n/**\n * @see Key\n */\nexport const KeySchema = z.string();\n\n/**\n * A key identifier within a collection.\n */\nexport type Key = z.infer<typeof KeySchema>;\n\n/**\n * @see Description\n */\nexport const DescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a description with a maximum length of 1024 characters.\n * Used for document and asset fields which can be useful for search purpose.\n */\nexport type Description = z.infer<typeof DescriptionSchema>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = Uint8ArraySchema;\n\n/**\n * Represents raw binary data.\n *\n * This is used to store structured data in a document.\n */\nexport type RawData = z.infer<typeof Uint8ArraySchema>;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n owner: RawUserIdSchema,\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport interface Doc {\n /**\n * The user who owns this document.\n */\n owner: RawUserId;\n\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version?: Version;\n}\n\n/**\n * @see OptionDoc\n */\nexport const OptionDocSchema = DocSchema.optional();\n\n/**\n * A shorthand for a document that might or not be defined.\n */\nexport type OptionDoc = Doc | undefined;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be created or updated.\n * This can be validated before allowing the operation.\n */\nexport interface SetDoc {\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n\n/**\n * @see DelDoc\n */\nexport const DelDocSchema = z\n .object({\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be deleted.\n * This can be validated before allowing the operation.\n */\nexport interface DelDoc {\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see HeaderFields\n */\nexport const HeaderFieldsSchema = z.array(HeaderFieldSchema);\n\n/**\n * Represents a list of HTTP headers.\n */\nexport type HeaderFields = HeaderField[];\n\n/**\n * @see Blob\n */\nexport const BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nexport const AssetKeySchema = z\n .object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n })\n .strict();\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nexport const AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see AssetEncodingNoContent\n */\nconst AssetEncodingNoContentSchema = AssetEncodingSchema.omit({content_chunks: true}).strict();\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression), without the chunks.\n */\nexport type AssetEncodingNoContent = Omit<AssetEncoding, 'content_chunks'>;\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.enum(['identity', 'gzip', 'compress', 'deflate', 'br']);\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: HeaderFieldsSchema,\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingSchema])),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: [EncodingType, AssetEncoding][];\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see AssetNoContent\n */\nexport const AssetNoContentSchema = AssetSchema.omit({encodings: true})\n .extend({\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingNoContentSchema]))\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings without chunks, and timestamps.\n */\nexport type AssetNoContent = Omit<Asset, 'encodings'> & {\n encodings: [EncodingType, AssetEncodingNoContent][];\n};\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: HeaderFieldsSchema,\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n\n/**\n * @see FullPath\n */\nexport const FullPathSchema = z.string();\n\n/**\n * Represents the relative path of an asset in storage.\n * For assets that are not part of the frontend app, the collection must be included at the root of the path.\n *\n * Example: `/images/a-sun-above-the-mountains.png`\n */\nexport type FullPath = string;\n\n/**\n * @see AssetAccessToken\n */\nexport const AssetAccessTokenSchema = z.string().optional();\n\n/**\n * An optional access token that can be used to make an asset private on the web.\n * Private as in practically unguessable (if complex enough and not shared of course).\n *\n * Example: `/images/a-sun-above-the-mountains.png?token=a-super-long-unguessable-not-shared-id`\n */\nexport type AssetAccessToken = string | undefined;\n\n/**\n * @see OptionAsset\n */\nexport const OptionAssetSchema = AssetSchema.optional();\n\n/**\n * A shorthand for an asset that might or not be defined.\n */\nexport type OptionAsset = Asset | undefined;\n", "import * as z from 'zod';\nimport {\n type Description,\n type Key,\n type RawUserId,\n type Timestamp,\n DescriptionSchema,\n KeySchema,\n RawUserIdSchema,\n TimestampSchema\n} from './satellite';\n\n/**\n * @see TimestampMatcher\n */\nexport const TimestampMatcherSchema = z.union([\n z.object({equal: TimestampSchema}),\n z.object({greater_than: TimestampSchema}),\n z.object({less_than: TimestampSchema}),\n z.object({between: z.tuple([TimestampSchema, TimestampSchema])})\n]);\n\n/**\n * TimestampMatcher matches a timestamp field using a specific strategy.\n */\nexport type TimestampMatcher =\n | {equal: Timestamp}\n | {greater_than: Timestamp}\n | {less_than: Timestamp}\n | {between: [Timestamp, Timestamp]};\n\n/**\n * @see ListMatcher\n */\nexport const ListMatcherSchema = z\n .object({\n key: KeySchema.optional(),\n description: DescriptionSchema.optional(),\n created_at: TimestampMatcherSchema.optional(),\n updated_at: TimestampMatcherSchema.optional()\n })\n .strict();\n\n/**\n * Matcher used to filter list results.\n */\nexport interface ListMatcher {\n key?: Key;\n description?: Description;\n created_at?: TimestampMatcher;\n updated_at?: TimestampMatcher;\n}\n\n/**\n * @see ListPaginate\n */\nexport const ListPaginateSchema = z\n .object({\n start_after: KeySchema.optional(),\n limit: z.bigint().optional()\n })\n .strict();\n\n/**\n * Optional pagination controls for listing.\n */\nexport interface ListPaginate {\n start_after?: Key;\n limit?: bigint;\n}\n\n/**\n * @see ListOrderField\n */\nexport const ListOrderFieldSchema = z.enum(['keys', 'created_at', 'updated_at']);\n\n/**\n * Enum representing possible fields to order by.\n */\nexport type ListOrderField = 'keys' | 'updated_at' | 'created_at';\n\n/**\n * @see ListOrder\n */\nexport const ListOrderSchema = z\n .object({\n desc: z.boolean(),\n field: ListOrderFieldSchema\n })\n .strict();\n\n/**\n * Ordering strategy for listing documents.\n */\nexport interface ListOrder {\n desc: boolean;\n field: ListOrderField;\n}\n\n/**\n * @see ListParams\n */\nexport const ListParamsSchema = z\n .object({\n matcher: ListMatcherSchema.optional(),\n paginate: ListPaginateSchema.optional(),\n order: ListOrderSchema.optional(),\n owner: RawUserIdSchema.optional()\n })\n .strict();\n\n/**\n * Full set of listing parameters.\n */\nexport interface ListParams {\n matcher?: ListMatcher;\n paginate?: ListPaginate;\n order?: ListOrder;\n owner?: RawUserId;\n}\n\n/**\n * Represents a list result.\n *\n * @template T - The type of the data returned per item.\n * @see JsListResults\n */\nexport const createListResultsSchema = <T extends z.ZodTypeAny>(itemData: T) =>\n z\n .object({\n items: z.array(z.tuple([KeySchema, itemData])),\n items_length: z.bigint(),\n items_page: z.bigint().optional(),\n matches_length: z.bigint(),\n matches_pages: z.bigint().optional()\n })\n .strict();\n\n/**\n * List results, parameterized by type of returned item.\n */\nexport interface ListResults<T> {\n items: [Key, T][];\n items_length: bigint;\n items_page?: bigint;\n matches_length: bigint;\n matches_pages?: bigint;\n}\n"],
5
- "mappings": "sDAAA,UAAYA,MAAO,MAMZ,IAAMC,EAAoB,SAAO,EAY3BC,EAAkB,SAAO,EAYzBC,EAAkBC,EAYlBC,EAAeC,EAYfC,EAAqB,SAAO,EAU5BC,EAAc,SAAO,EAUrBC,EAAsB,SAAO,EAAE,IAAI,IAAI,EC1EpD,UAAYC,MAAO,MAgBZ,IAAMC,EAAgBC,EAYhBC,EACV,SAAO,CACN,MAAOC,EACP,KAAMH,EACN,YAAaI,EAAkB,SAAS,EACxC,WAAYC,EACZ,WAAYA,EACZ,QAASC,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EAyCGC,EAAkBL,EAAU,SAAS,EAUrCM,EACV,SAAO,CACN,KAAMR,EACN,YAAaI,EAAkB,SAAS,EACxC,QAASE,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EA0BGG,EACV,SAAO,CACN,QAASH,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EC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yBGG,EAAmB,SAAO,EAa1BC,EAA2B,SAAO,EAAE,SAAS,EAa7CC,EAAoBV,EAAY,SAAS,EC5WtD,UAAYW,MAAO,MAeZ,IAAMC,EAA2B,QAAM,CAC1C,SAAO,CAAC,MAAOC,CAAe,CAAC,EAC/B,SAAO,CAAC,aAAcA,CAAe,CAAC,EACtC,SAAO,CAAC,UAAWA,CAAe,CAAC,EACnC,SAAO,CAAC,QAAW,QAAM,CAACA,EAAiBA,CAAe,CAAC,CAAC,CAAC,CACjE,CAAC,EAcYC,EACV,SAAO,CACN,IAAKC,EAAU,SAAS,EACxB,YAAaC,EAAkB,SAAS,EACxC,WAAYJ,EAAuB,SAAS,EAC5C,WAAYA,EAAuB,SAAS,CAC9C,CAAC,EACA,OAAO,EAeGK,EACV,SAAO,CACN,YAAaF,EAAU,SAAS,EAChC,MAAS,SAAO,EAAE,SAAS,CAC7B,CAAC,EACA,OAAO,EAaGG,EAAyB,OAAK,CAAC,OAAQ,aAAc,YAAY,CAAC,EAUlEC,EACV,SAAO,CACN,KAAQ,UAAQ,EAChB,MAAOD,CACT,CAAC,EACA,OAAO,EAaGE,EACV,SAAO,CACN,QAASN,EAAkB,SAAS,EACpC,SAAUG,EAAmB,SAAS,EACtC,MAAOE,EAAgB,SAAS,EAChC,MAAOE,EAAgB,SAAS,CAClC,CAAC,EACA,OAAO,EAkBGC,GAAmDC,GAE3D,SAAO,CACN,MAAS,QAAQ,QAAM,CAACR,EAAWQ,CAAQ,CAAC,CAAC,EAC7C,aAAgB,SAAO,EACvB,WAAc,SAAO,EAAE,SAAS,EAChC,eAAkB,SAAO,EACzB,cAAiB,SAAO,EAAE,SAAS,CACrC,CAAC,EACA,OAAO",
6
- "names": ["z", "TimestampSchema", "VersionSchema", "RawUserIdSchema", "RawPrincipalSchema", "UserIdSchema", "PrincipalSchema", "CollectionSchema", "KeySchema", "DescriptionSchema", "z", "RawDataSchema", "Uint8ArraySchema", "DocSchema", "RawUserIdSchema", "DescriptionSchema", "TimestampSchema", "VersionSchema", "OptionDocSchema", "SetDocSchema", "DelDocSchema", "z", "HeaderFieldSchema", "HeaderFieldsSchema", "BlobSchema", "Uint8ArraySchema", "BlobOrKeySchema", "HashSchema", "val", "AssetKeySchema", "CollectionSchema", "RawUserIdSchema", "DescriptionSchema", "AssetEncodingSchema", "TimestampSchema", "AssetEncodingNoContentSchema", "EncodingTypeSchema", "AssetSchema", "VersionSchema", "AssetNoContentSchema", "ReferenceIdSchema", "BatchSchema", "ChunkIdSchema", "BatchIdSchema", "CommitBatchSchema", "FullPathSchema", "AssetAccessTokenSchema", "OptionAssetSchema", "z", "TimestampMatcherSchema", "TimestampSchema", "ListMatcherSchema", "KeySchema", "DescriptionSchema", "ListPaginateSchema", "ListOrderFieldSchema", "ListOrderSchema", "ListParamsSchema", "RawUserIdSchema", "createListResultsSchema", "itemData"]
4
+ "sourcesContent": ["import * as z from 'zod';\nimport {PrincipalSchema, RawPrincipalSchema} from './candid';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = z.infer<typeof RawUserIdSchema>;\n\n/**\n * @see UserId\n */\nexport const UserIdSchema = PrincipalSchema;\n\n/**\n * Represents a user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type UserId = z.infer<typeof UserIdSchema>;\n\n/**\n * @see Collection\n */\nexport const CollectionSchema = z.string();\n\n/**\n * A collection name where data are stored.\n */\nexport type Collection = z.infer<typeof CollectionSchema>;\n\n/**\n * @see Key\n */\nexport const KeySchema = z.string();\n\n/**\n * A key identifier within a collection.\n */\nexport type Key = z.infer<typeof KeySchema>;\n\n/**\n * @see Description\n */\nexport const DescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a description with a maximum length of 1024 characters.\n * Used for document and asset fields which can be useful for search purpose.\n */\nexport type Description = z.infer<typeof DescriptionSchema>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = Uint8ArraySchema;\n\n/**\n * Represents raw binary data.\n *\n * This is used to store structured data in a document.\n */\nexport type RawData = z.infer<typeof Uint8ArraySchema>;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n owner: RawUserIdSchema,\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport interface Doc {\n /**\n * The user who owns this document.\n */\n owner: RawUserId;\n\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version?: Version;\n}\n\n/**\n * @see OptionDoc\n */\nexport const OptionDocSchema = DocSchema.optional();\n\n/**\n * A shorthand for a document that might or not be defined.\n */\nexport type OptionDoc = Doc | undefined;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be created or updated.\n * This can be validated before allowing the operation.\n */\nexport interface SetDoc {\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n\n/**\n * @see DelDoc\n */\nexport const DelDocSchema = z\n .object({\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be deleted.\n * This can be validated before allowing the operation.\n */\nexport interface DelDoc {\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see HeaderFields\n */\nexport const HeaderFieldsSchema = z.array(HeaderFieldSchema);\n\n/**\n * Represents a list of HTTP headers.\n */\nexport type HeaderFields = HeaderField[];\n\n/**\n * @see Blob\n */\nexport const BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nexport const AssetKeySchema = z\n .object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n })\n .strict();\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nexport const AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see AssetEncodingNoContent\n */\nconst AssetEncodingNoContentSchema = AssetEncodingSchema.omit({content_chunks: true}).strict();\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression), without the chunks.\n */\nexport type AssetEncodingNoContent = Omit<AssetEncoding, 'content_chunks'>;\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.enum(['identity', 'gzip', 'compress', 'deflate', 'br']);\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: HeaderFieldsSchema,\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingSchema])),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: [EncodingType, AssetEncoding][];\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see AssetNoContent\n */\nexport const AssetNoContentSchema = AssetSchema.omit({encodings: true})\n .extend({\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingNoContentSchema]))\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings without chunks, and timestamps.\n */\nexport type AssetNoContent = Omit<Asset, 'encodings'> & {\n encodings: [EncodingType, AssetEncodingNoContent][];\n};\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: HeaderFieldsSchema,\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n\n/**\n * @see FullPath\n */\nexport const FullPathSchema = z.string();\n\n/**\n * Represents the relative path of an asset in storage.\n * For assets that are not part of the frontend app, the collection must be included at the root of the path.\n *\n * Example: `/images/a-sun-above-the-mountains.png`\n */\nexport type FullPath = string;\n\n/**\n * @see OptionAsset\n */\nexport const OptionAssetSchema = AssetSchema.optional();\n\n/**\n * A shorthand for an asset that might or not be defined.\n */\nexport type OptionAsset = Asset | undefined;\n", "import * as z from 'zod';\nimport {\n type Description,\n type Key,\n type RawUserId,\n type Timestamp,\n DescriptionSchema,\n KeySchema,\n RawUserIdSchema,\n TimestampSchema\n} from './satellite';\n\n/**\n * @see TimestampMatcher\n */\nexport const TimestampMatcherSchema = z.union([\n z.object({equal: TimestampSchema}),\n z.object({greater_than: TimestampSchema}),\n z.object({less_than: TimestampSchema}),\n z.object({between: z.tuple([TimestampSchema, TimestampSchema])})\n]);\n\n/**\n * TimestampMatcher matches a timestamp field using a specific strategy.\n */\nexport type TimestampMatcher =\n | {equal: Timestamp}\n | {greater_than: Timestamp}\n | {less_than: Timestamp}\n | {between: [Timestamp, Timestamp]};\n\n/**\n * @see ListMatcher\n */\nexport const ListMatcherSchema = z\n .object({\n key: KeySchema.optional(),\n description: DescriptionSchema.optional(),\n created_at: TimestampMatcherSchema.optional(),\n updated_at: TimestampMatcherSchema.optional()\n })\n .strict();\n\n/**\n * Matcher used to filter list results.\n */\nexport interface ListMatcher {\n key?: Key;\n description?: Description;\n created_at?: TimestampMatcher;\n updated_at?: TimestampMatcher;\n}\n\n/**\n * @see ListPaginate\n */\nexport const ListPaginateSchema = z\n .object({\n start_after: KeySchema.optional(),\n limit: z.bigint().optional()\n })\n .strict();\n\n/**\n * Optional pagination controls for listing.\n */\nexport interface ListPaginate {\n start_after?: Key;\n limit?: bigint;\n}\n\n/**\n * @see ListOrderField\n */\nexport const ListOrderFieldSchema = z.enum(['keys', 'created_at', 'updated_at']);\n\n/**\n * Enum representing possible fields to order by.\n */\nexport type ListOrderField = 'keys' | 'updated_at' | 'created_at';\n\n/**\n * @see ListOrder\n */\nexport const ListOrderSchema = z\n .object({\n desc: z.boolean(),\n field: ListOrderFieldSchema\n })\n .strict();\n\n/**\n * Ordering strategy for listing documents.\n */\nexport interface ListOrder {\n desc: boolean;\n field: ListOrderField;\n}\n\n/**\n * @see ListParams\n */\nexport const ListParamsSchema = z\n .object({\n matcher: ListMatcherSchema.optional(),\n paginate: ListPaginateSchema.optional(),\n order: ListOrderSchema.optional(),\n owner: RawUserIdSchema.optional()\n })\n .strict();\n\n/**\n * Full set of listing parameters.\n */\nexport interface ListParams {\n matcher?: ListMatcher;\n paginate?: ListPaginate;\n order?: ListOrder;\n owner?: RawUserId;\n}\n\n/**\n * Represents a list result.\n *\n * @template T - The type of the data returned per item.\n * @see JsListResults\n */\nexport const createListResultsSchema = <T extends z.ZodTypeAny>(itemData: T) =>\n z\n .object({\n items: z.array(z.tuple([KeySchema, itemData])),\n items_length: z.bigint(),\n items_page: z.bigint().optional(),\n matches_length: z.bigint(),\n matches_pages: z.bigint().optional()\n })\n .strict();\n\n/**\n * List results, parameterized by type of returned item.\n */\nexport interface ListResults<T> {\n items: [Key, T][];\n items_length: bigint;\n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,SAAO,CACN,KAAQ,UAAQ,EAChB,MAAOD,CACT,CAAC,EACA,OAAO,EAaGE,EACV,SAAO,CACN,QAASN,EAAkB,SAAS,EACpC,SAAUG,EAAmB,SAAS,EACtC,MAAOE,EAAgB,SAAS,EAChC,MAAOE,EAAgB,SAAS,CAClC,CAAC,EACA,OAAO,EAkBGC,EAAmDC,GAE3D,SAAO,CACN,MAAS,QAAQ,QAAM,CAACR,EAAWQ,CAAQ,CAAC,CAAC,EAC7C,aAAgB,SAAO,EACvB,WAAc,SAAO,EAAE,SAAS,EAChC,eAAkB,SAAO,EACzB,cAAiB,SAAO,EAAE,SAAS,CACrC,CAAC,EACA,OAAO",
6
+ "names": ["z", "TimestampSchema", "VersionSchema", "RawUserIdSchema", "RawPrincipalSchema", "UserIdSchema", "PrincipalSchema", "CollectionSchema", "KeySchema", "DescriptionSchema", "z", "RawDataSchema", "Uint8ArraySchema", "DocSchema", "RawUserIdSchema", "DescriptionSchema", "TimestampSchema", "VersionSchema", "OptionDocSchema", "SetDocSchema", "DelDocSchema", "z", "HeaderFieldSchema", "HeaderFieldsSchema", "BlobSchema", "Uint8ArraySchema", "BlobOrKeySchema", "HashSchema", "val", "AssetKeySchema", "CollectionSchema", "RawUserIdSchema", "DescriptionSchema", "AssetEncodingSchema", "TimestampSchema", "AssetEncodingNoContentSchema", "EncodingTypeSchema", "AssetSchema", "VersionSchema", "AssetNoContentSchema", "ReferenceIdSchema", "BatchSchema", "ChunkIdSchema", "BatchIdSchema", "CommitBatchSchema", "FullPathSchema", "OptionAssetSchema", "z", "TimestampMatcherSchema", "TimestampSchema", "ListMatcherSchema", "KeySchema", "DescriptionSchema", "ListPaginateSchema", "ListOrderFieldSchema", "ListOrderSchema", "ListParamsSchema", "RawUserIdSchema", "createListResultsSchema", "itemData"]
7
7
  }
package/global.d.ts CHANGED
@@ -4,7 +4,6 @@ import type {DelDoc, Doc, OptionDoc, RawData, SetDoc} from './schemas/db';
4
4
  import type {ListParams, ListResults} from './schemas/list';
5
5
  import type {Collection, Key, RawPrincipal, RawUserId} from './schemas/satellite';
6
6
  import type {
7
- AssetAccessToken,
8
7
  AssetEncoding,
9
8
  AssetKey,
10
9
  AssetNoContent,
@@ -102,12 +101,6 @@ declare global {
102
101
  chunk_index: bigint,
103
102
  memory: Memory
104
103
  ): Blob | undefined;
105
- function __juno_satellite_storage_set_asset_token_store(
106
- caller: RawUserId,
107
- collection: Collection,
108
- full_path: FullPath,
109
- token: AssetAccessToken
110
- ): void;
111
104
 
112
105
  function __ic_cdk_id(): RawPrincipal;
113
106
  function __ic_cdk_time(): bigint;
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{A as Ue,B as Me,C as je,D as ve,a as ie,b as De,c as z,d as Ae,e as F,f as H,g as ye,h as Se,i as n,j as Oe,k as b,l as U,m as de,n as he,o as Ce,p as fe,q as r,r as Te,s as M,t as j,u as ue,v as ke,w as ze,x as Fe,y as He,z as be}from"./chunk-KVADXJMF.js";import{a as xe,b as me,c as le}from"./chunk-7B6WU32N.js";import"./chunk-4C666HHU.js";import*as a from"zod";import*as v from"zod";var c=e=>v.custom(i=>e.implement(i));import*as m from"zod";var A=m.object({collections:m.array(m.string()).readonly()}).strict();import*as o from"zod";var t=e=>o.strictObject({caller:z,data:e}),_=e=>c(o.function({input:o.tuple([e]),output:o.void()})),Z=e=>c(o.function({input:o.tuple([e]),output:o.promise(o.void()).or(o.void())}));import*as l from"zod";import*as y from"zod";var C=y.object({before:n.optional(),after:n}).strict(),R=y.object({current:n.optional(),proposed:b}).strict(),g=y.object({current:n.optional(),proposed:U}).strict();var p=e=>l.strictObject({collection:F,key:H,data:e}),E=t(p(C)),B=t(l.array(p(C))),f=t(p(n.optional())),T=t(l.array(p(n.optional()))),u=t(l.array(p(n.optional()))),w=t(p(R)),I=t(p(g));import*as D from"zod";var S=D.record(D.string(),D.string());import*as k from"zod";import*as K from"zod";var P=K.object({current:r.optional(),batch:M,commit_batch:j}).strict();var J=t(r),N=t(r.optional()),q=t(k.array(r.optional())),G=t(k.array(r.optional())),L=t(P),Q=t(r);var O=e=>A.extend({assert:_(e)}).strict(),V=O(w),W=O(I),X=O(L),Y=O(Q),st=a.union([V,W,X,Y]),$=e=>a.function({input:a.tuple([S]),output:e}),rt=e=>a.union([e,c($(e))]);function ct(e){return e}import*as x from"zod";var s=e=>A.extend({run:Z(e)}).strict(),ee=s(E),te=s(B),At=s(f),yt=s(T),St=s(u),oe=s(J),ne=s(N),se=s(q),re=s(G),Ot=x.union([ee,te,f,T,u,oe,ne,se,re]),ce=e=>x.function({input:x.tuple([S]),output:e}),dt=e=>x.union([e,c(ce(e))]);function ht(e){return e}import{jsonReplacer as pe}from"@dfinity/utils";var d=e=>{let i=e.map(h=>typeof h=="object"?JSON.stringify(h,pe):h).join(" ");globalThis.__ic_cdk_print(i)};globalThis.console={info(...e){d(e)},log(...e){d(e)},warn(...e){d(e)},error(...e){d(e)}};var ae=()=>(__juno_satellite_random()>>>0)/4294967296;globalThis.Math.random=ae;export{Q as AssertDeleteAssetContextSchema,Y as AssertDeleteAssetSchema,I as AssertDeleteDocContextSchema,W as AssertDeleteDocSchema,rt as AssertFnOrObjectSchema,$ as AssertFnSchema,_ as AssertFunctionSchema,st as AssertSchema,w as AssertSetDocContextSchema,V as AssertSetDocSchema,L as AssertUploadAssetContextSchema,X as AssertUploadAssetSchema,ke as AssetAccessTokenSchema,P as AssetAssertUploadSchema,fe as AssetEncodingSchema,Ce as AssetKeySchema,Te as AssetNoContentSchema,r as AssetSchema,M as BatchSchema,he as BlobSchema,F as CollectionSchema,A as CollectionsSchema,j as CommitBatchSchema,U as DelDocSchema,ye as DescriptionSchema,g as DocAssertDeleteSchema,R as DocAssertSetSchema,p as DocContextSchema,n as DocSchema,C as DocUpsertSchema,ue as FullPathSchema,de as HeaderFieldsSchema,t as HookContextSchema,dt as HookFnOrObjectSchema,ce as HookFnSchema,Ot as HookSchema,H as KeySchema,He as ListMatcherSchema,Ue as ListOrderFieldSchema,Me as ListOrderSchema,be as ListPaginateSchema,je as ListParamsSchema,N as OnDeleteAssetContextSchema,ne as OnDeleteAssetSchema,f as OnDeleteDocContextSchema,At as OnDeleteDocSchema,G as OnDeleteFilteredAssetsContextSchema,re as OnDeleteFilteredAssetsSchema,u as OnDeleteFilteredDocsContextSchema,St as OnDeleteFilteredDocsSchema,q as OnDeleteManyAssetsContextSchema,se as OnDeleteManyAssetsSchema,T as OnDeleteManyDocsContextSchema,yt as OnDeleteManyDocsSchema,E as OnSetDocContextSchema,ee as OnSetDocSchema,B as OnSetManyDocsContextSchema,te as OnSetManyDocsSchema,J as OnUploadAssetContextSchema,oe as OnUploadAssetSchema,ze as OptionAssetSchema,Oe as OptionDocSchema,le as PrincipalSchema,Se as RawDataSchema,me as RawPrincipalSchema,z as RawUserIdSchema,Z as RunFunctionSchema,S as SatelliteEnvSchema,b as SetDocSchema,Fe as TimestampMatcherSchema,ie as TimestampSchema,xe as Uint8ArraySchema,Ae as UserIdSchema,De as VersionSchema,ve as createListResultsSchema,ct as defineAssert,ht as defineHook};
1
+ import{A as Ue,B as Me,C as je,a as ie,b as De,c as z,d as Ae,e as F,f as H,g as ye,h as Se,i as n,j as Oe,k as b,l as U,m as de,n as he,o as Ce,p as fe,q as r,r as Te,s as M,t as j,u as ue,v as ke,w as ze,x as Fe,y as He,z as be}from"./chunk-4ZHRSCXC.js";import{a as xe,b as me,c as le}from"./chunk-7B6WU32N.js";import"./chunk-4C666HHU.js";import*as a from"zod";import*as v from"zod";var c=e=>v.custom(i=>e.implement(i));import*as m from"zod";var A=m.object({collections:m.array(m.string()).readonly()}).strict();import*as o from"zod";var t=e=>o.strictObject({caller:z,data:e}),_=e=>c(o.function({input:o.tuple([e]),output:o.void()})),Z=e=>c(o.function({input:o.tuple([e]),output:o.promise(o.void()).or(o.void())}));import*as l from"zod";import*as y from"zod";var C=y.object({before:n.optional(),after:n}).strict(),R=y.object({current:n.optional(),proposed:b}).strict(),g=y.object({current:n.optional(),proposed:U}).strict();var p=e=>l.strictObject({collection:F,key:H,data:e}),E=t(p(C)),B=t(l.array(p(C))),f=t(p(n.optional())),T=t(l.array(p(n.optional()))),u=t(l.array(p(n.optional()))),w=t(p(R)),I=t(p(g));import*as D from"zod";var S=D.record(D.string(),D.string());import*as k from"zod";import*as K from"zod";var P=K.object({current:r.optional(),batch:M,commit_batch:j}).strict();var J=t(r),N=t(r.optional()),q=t(k.array(r.optional())),G=t(k.array(r.optional())),L=t(P),Q=t(r);var O=e=>A.extend({assert:_(e)}).strict(),V=O(w),W=O(I),X=O(L),Y=O(Q),nt=a.union([V,W,X,Y]),$=e=>a.function({input:a.tuple([S]),output:e}),st=e=>a.union([e,c($(e))]);function rt(e){return e}import*as x from"zod";var s=e=>A.extend({run:Z(e)}).strict(),ee=s(E),te=s(B),Dt=s(f),At=s(T),yt=s(u),oe=s(J),ne=s(N),se=s(q),re=s(G),St=x.union([ee,te,f,T,u,oe,ne,se,re]),ce=e=>x.function({input:x.tuple([S]),output:e}),Ot=e=>x.union([e,c(ce(e))]);function dt(e){return e}import{jsonReplacer as pe}from"@dfinity/utils";var d=e=>{let i=e.map(h=>typeof h=="object"?JSON.stringify(h,pe):h).join(" ");globalThis.__ic_cdk_print(i)};globalThis.console={info(...e){d(e)},log(...e){d(e)},warn(...e){d(e)},error(...e){d(e)}};var ae=()=>(__juno_satellite_random()>>>0)/4294967296;globalThis.Math.random=ae;export{Q as AssertDeleteAssetContextSchema,Y as AssertDeleteAssetSchema,I as AssertDeleteDocContextSchema,W as AssertDeleteDocSchema,st as AssertFnOrObjectSchema,$ as AssertFnSchema,_ as AssertFunctionSchema,nt as AssertSchema,w as AssertSetDocContextSchema,V as AssertSetDocSchema,L as AssertUploadAssetContextSchema,X as AssertUploadAssetSchema,P as AssetAssertUploadSchema,fe as AssetEncodingSchema,Ce as AssetKeySchema,Te as AssetNoContentSchema,r as AssetSchema,M as BatchSchema,he as BlobSchema,F as CollectionSchema,A as CollectionsSchema,j as CommitBatchSchema,U as DelDocSchema,ye as DescriptionSchema,g as DocAssertDeleteSchema,R as DocAssertSetSchema,p as DocContextSchema,n as DocSchema,C as DocUpsertSchema,ue as FullPathSchema,de as HeaderFieldsSchema,t as HookContextSchema,Ot as HookFnOrObjectSchema,ce as HookFnSchema,St as HookSchema,H as KeySchema,Fe as ListMatcherSchema,be as ListOrderFieldSchema,Ue as ListOrderSchema,He as ListPaginateSchema,Me as ListParamsSchema,N as OnDeleteAssetContextSchema,ne as OnDeleteAssetSchema,f as OnDeleteDocContextSchema,Dt as OnDeleteDocSchema,G as OnDeleteFilteredAssetsContextSchema,re as OnDeleteFilteredAssetsSchema,u as OnDeleteFilteredDocsContextSchema,yt as OnDeleteFilteredDocsSchema,q as OnDeleteManyAssetsContextSchema,se as OnDeleteManyAssetsSchema,T as OnDeleteManyDocsContextSchema,At as OnDeleteManyDocsSchema,E as OnSetDocContextSchema,ee as OnSetDocSchema,B as OnSetManyDocsContextSchema,te as OnSetManyDocsSchema,J as OnUploadAssetContextSchema,oe as OnUploadAssetSchema,ke as OptionAssetSchema,Oe as OptionDocSchema,le as PrincipalSchema,Se as RawDataSchema,me as RawPrincipalSchema,z as RawUserIdSchema,Z as RunFunctionSchema,S as SatelliteEnvSchema,b as SetDocSchema,ze as TimestampMatcherSchema,ie as TimestampSchema,xe as Uint8ArraySchema,Ae as UserIdSchema,De as VersionSchema,je as createListResultsSchema,rt as defineAssert,dt as defineHook};
2
2
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["src/hooks/assertions.ts", "src/utils/zod.utils.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/schemas/storage/context.ts", "src/hooks/schemas/storage/payload.ts", "src/hooks/hooks.ts", "src/polyfills/console.polyfill.ts", "src/polyfills/random.polyfill.ts"],
4
4
  "sourcesContent": ["import * as z from 'zod';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function({\n input: z.tuple([SatelliteEnvSchema]),\n output: assertSchema\n });\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, createFunctionSchema(AssertFnSchema(assertSchema))]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod';\n\n/**\n * Wraps a Zod function schema so that parsing returns the **original function**\n * instead of Zod's wrapped validator.\n *\n * Why?\n * ----\n * In Zod v4, `z.function({...})` normally returns a wrapper that validates\n * both arguments and the return value **every time the function is called**.\n * If your function's return type is `void | Promise<void>`, Zod tries to\n * validate it synchronously, which can throw\n * \"Encountered Promise during synchronous parse\"\n * when the implementation is async.\n *\n * By using `.implement`, we tell Zod: \u201Cthis is the function that satisfies\n * the schema.\u201D That way the schema still validates the function shape at\n * parse time, but the returned value is the **original function** you passed\n * in \u2014 no runtime wrapper, no sync/async mismatch.\n *\n * Reference:\n * https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912*\n */\nexport const createFunctionSchema = <T extends z.ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>((fn) =>\n schema.implement(fn as Parameters<T['implement']>[0])\n );\n", "import * as z from 'zod';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import * as z from 'zod';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\nimport {createFunctionSchema} from '../../utils/zod.utils';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(z.function({input: z.tuple([contextSchema]), output: z.void()}));\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(\n z.function({input: z.tuple([contextSchema]), output: z.promise(z.void()).or(z.void())})\n );\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import * as z from 'zod';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.string(), z.string());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod';\nimport {AssetSchema, type Asset} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n type OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n type OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n type OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: hookSchema});\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, createFunctionSchema(HookFnSchema(hookSchema))]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n", "/**\n * @see Math.random\n */\nconst random = (): number => {\n // __juno_satellite_random() returns a signed 32-bit int (i32)\n const value = __juno_satellite_random();\n\n // >>> 0 converts it to unsigned\n return (value >>> 0) / 2 ** 32;\n};\n\n/**\n * Overwrites Math.random with a pseudo-random number using the Satellite's internal RNG.\n *\n * \u26A0\uFE0F This function is not suitable for use cases requiring cryptographically secure or perfectly unpredictable randomness,\n * such as lotteries or gambling dApps.\n *\n * @returns {number} A pseudo-random 32-bit integer.\n *\n * @throws {Error} If the RNG has not been initialized.\n */\nglobalThis.Math.random = random;\n"],
5
- "mappings": "6VAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MAuBZ,IAAMC,EAAiDC,GAC1D,SAAuCC,GACvCD,EAAO,UAAUC,CAAmC,CACtD,EC1BF,UAAYC,MAAO,MAMZ,IAAMC,EACV,SAAO,CACN,YAAe,QAAQ,SAAO,CAAC,EAAE,SAAS,CAC5C,CAAC,EACA,OAAO,ECVV,UAAYC,MAAO,MAOZ,IAAMC,EAA6CC,GAM/C,eALW,CAClB,OAAQC,EACR,KAAMD,CACR,CAEiC,EAuBtBE,EAAgDC,GAC3DC,EAAuB,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,OAAK,CAAC,CAAC,CAAC,EAczEE,EAA6CF,GACxDC,EACI,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,UAAU,OAAK,CAAC,EAAE,GAAK,OAAK,CAAC,CAAC,CAAC,CACxF,ECtDF,UAAYG,MAAO,MCAnB,UAAYC,MAAO,MAaZ,IAAMC,EACV,SAAO,CACN,OAAQC,EAAU,SAAS,EAC3B,MAAOA,CACT,CA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,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF,EC1BA,IAAMG,GAAS,KAEC,wBAAwB,IAGpB,GAAK,WAazB,WAAW,KAAK,OAASA",
6
6
  "names": ["z", "z", "createFunctionSchema", "schema", "fn", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "AssertFunctionSchema", "contextSchema", "createFunctionSchema", "RunFunctionSchema", "z", "z", "DocUpsertSchema", "DocSchema", "DocAssertSetSchema", "SetDocSchema", "DocAssertDeleteSchema", "DelDocSchema", "DocContextSchema", "dataSchema", "CollectionSchema", "KeySchema", "OnSetDocContextSchema", "HookContextSchema", "DocUpsertSchema", "OnSetManyDocsContextSchema", "OnDeleteDocContextSchema", "DocSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsContextSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "AssertDeleteDocContextSchema", "DocAssertDeleteSchema", "z", "SatelliteEnvSchema", "z", "z", "AssetAssertUploadSchema", "AssetSchema", "BatchSchema", "CommitBatchSchema", "OnUploadAssetContextSchema", "HookContextSchema", "AssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsContextSchema", "AssertUploadAssetContextSchema", "AssetAssertUploadSchema", "AssertDeleteAssetContextSchema", "OnAssertSchema", "contextSchema", "CollectionsSchema", "AssertFunctionSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertDeleteDocSchema", "AssertDeleteDocContextSchema", "AssertUploadAssetSchema", "AssertUploadAssetContextSchema", "AssertDeleteAssetSchema", "AssertDeleteAssetContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "createFunctionSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsSchema", "RunFunctionSchema", "OnSetDocSchema", "OnSetDocContextSchema", "OnSetManyDocsSchema", "OnSetManyDocsContextSchema", "OnDeleteDocSchema", "OnDeleteDocContextSchema", "OnDeleteManyDocsSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsSchema", "OnDeleteFilteredDocsContextSchema", "OnUploadAssetSchema", "OnUploadAssetContextSchema", "OnDeleteAssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsSchema", "OnDeleteFilteredAssetsContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "createFunctionSchema", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg", "random"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/functions",
3
- "version": "0.5.1-next-2025-11-29.1",
3
+ "version": "0.5.1-next-2025-12-01",
4
4
  "description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -290,17 +290,6 @@ export declare const FullPathSchema: z.ZodString;
290
290
  * Example: `/images/a-sun-above-the-mountains.png`
291
291
  */
292
292
  export type FullPath = string;
293
- /**
294
- * @see AssetAccessToken
295
- */
296
- export declare const AssetAccessTokenSchema: z.ZodOptional<z.ZodString>;
297
- /**
298
- * An optional access token that can be used to make an asset private on the web.
299
- * Private as in practically unguessable (if complex enough and not shared of course).
300
- *
301
- * Example: `/images/a-sun-above-the-mountains.png?token=a-super-long-unguessable-not-shared-id`
302
- */
303
- export type AssetAccessToken = string | undefined;
304
293
  /**
305
294
  * @see OptionAsset
306
295
  */
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod';
2
2
  import { type RawUserId, type UserId } from '../../schemas/satellite';
3
- import { type AssetAccessToken, type AssetEncoding, type AssetKey, type Blob, type FullPath, type HeaderFields } from '../../schemas/storage';
3
+ import { type AssetEncoding, type AssetKey, type Blob, type FullPath, type HeaderFields } from '../../schemas/storage';
4
4
  import { type Memory } from './collections';
5
5
  import { type CollectionParams, type ListStoreParams } from './params';
6
6
  /**
@@ -184,25 +184,6 @@ export declare const DeleteAssetStoreParamsSchema: z.ZodObject<{
184
184
  * Represents the parameters required to delete an asset.
185
185
  */
186
186
  export type DeleteAssetStoreParams = GetAssetStoreParams;
187
- /**
188
- * @see SetAssetTokenStoreParams
189
- */
190
- export declare const SetAssetTokenStoreParamsSchema: z.ZodObject<{
191
- collection: z.ZodString;
192
- caller: z.ZodUnion<[z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
193
- full_path: z.ZodString;
194
- token: z.ZodOptional<z.ZodString>;
195
- }, z.core.$strict>;
196
- /**
197
- * Represents the parameters required to delete an asset.
198
- */
199
- export type SetAssetTokenStoreParams = GetAssetStoreParams & {
200
- /**
201
- * The token to apply to the asset.
202
- * Setting `undefined` removes the protection and makes the asset public.
203
- */
204
- token: AssetAccessToken;
205
- };
206
187
  /**
207
188
  * @see ListAssetsStoreParams
208
189
  */
@@ -1,6 +1,6 @@
1
1
  import type { ListResults } from '../schemas/list';
2
2
  import type { AssetNoContent, Blob, OptionAsset } from '../schemas/storage';
3
- import { type CountAssetsStoreParams, type CountCollectionAssetsStoreParams, type DeleteAssetsStoreParams, type DeleteAssetStoreParams, type DeleteFilteredAssetsStoreParams, type GetAssetStoreParams, type GetContentChunksStoreParams, type ListAssetsStoreParams, type SetAssetHandlerParams, type SetAssetTokenStoreParams } from './schemas/storage';
3
+ import { type CountAssetsStoreParams, type CountCollectionAssetsStoreParams, type DeleteAssetsStoreParams, type DeleteAssetStoreParams, type DeleteFilteredAssetsStoreParams, type GetAssetStoreParams, type GetContentChunksStoreParams, type ListAssetsStoreParams, type SetAssetHandlerParams } from './schemas/storage';
4
4
  /**
5
5
  * Counts the number of assets in a specific collection.
6
6
  *
@@ -63,15 +63,6 @@ export declare const deleteAssetsStore: (params: DeleteAssetsStoreParams) => voi
63
63
  * @throws {Error} If the Satellite fails while performing the count operation.
64
64
  */
65
65
  export declare const deleteFilteredAssetsStore: (params: DeleteFilteredAssetsStoreParams) => OptionAsset[];
66
- /**
67
- * Set or update an access token for an asset in a collection's store.
68
- *
69
- * @param {SetAssetTokenStoreParams} params - The parameters required to set the token of the asset.
70
- *
71
- *@throws {z.ZodError} If the provided parameters do not match the expected schema.
72
- * @throws {Error} If the Satellite fails to validate the request or the token cannot be set.
73
- */
74
- export declare const setAssetTokenStore: (params: SetAssetTokenStoreParams) => void;
75
66
  /**
76
67
  * Retrieve an asset from the storage.
77
68
  *
package/sdk.js CHANGED
@@ -1,2 +1,2 @@
1
- import{C as I,a as _,c as n,d as m,e as y,f as D,k as x,l as u,m as A,n as f,o as k,p as g,u as U,v as j}from"./chunk-KVADXJMF.js";import{b as C}from"./chunk-7B6WU32N.js";import"./chunk-4C666HHU.js";import*as l from"zod";var V=l.enum(["write","admin","submit"]),W=l.tuple([l.string(),l.string()]),X=l.object({metadata:l.array(W),created_at:_,updated_at:_,expires_at:_.optional(),scope:V}).strict(),Y=l.tuple([C,X]),Z=l.array(Y),h=l.object({caller:n.or(m),controllers:Z});import{Principal as $}from"@icp-sdk/core/principal";var a=e=>$.from(e).toUint8Array();var me=()=>__juno_satellite_get_admin_controllers(),ie=()=>__juno_satellite_get_controllers(),pe=e=>{h.parse(e);let{caller:t,controllers:o}=e,r=a(t);return __juno_satellite_is_admin_controller(r,o)},Se=e=>{h.parse(e);let{caller:t,controllers:o}=e,r=a(t);return __juno_satellite_is_controller(r,o)};import*as L from"zod";var c=L.object({collection:y}).strict(),i=c.extend({caller:n.or(m),params:I}).strict();var d=c.extend({caller:n.or(m),key:D}).strict(),R=d.extend({doc:x}).strict(),z=d.extend({doc:u}).strict(),b=c,w=i,v=i,G=c,F=i;var fe=e=>{R.parse(e);let{caller:t,collection:o,key:r,doc:s}=e,p=a(t);return __juno_satellite_datastore_set_doc_store(p,o,r,s)},ke=e=>{z.parse(e);let{caller:t,collection:o,key:r,doc:s}=e,p=a(t);return __juno_satellite_datastore_delete_doc_store(p,o,r,s)},ge=e=>{d.parse(e);let{caller:t,collection:o,key:r}=e,s=a(t);return __juno_satellite_datastore_get_doc_store(s,o,r)},Ue=e=>{v.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_list_docs_store(s,o,r)},je=e=>{b.parse(e);let{collection:t}=e;return __juno_satellite_datastore_count_collection_docs_store(t)},Ie=e=>{w.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_count_docs_store(s,o,r)},Le=e=>{G.parse(e);let{collection:t}=e;__juno_satellite_datastore_delete_docs_store(t)},Re=e=>{F.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_delete_filtered_docs_store(s,o,r)};import*as T from"zod";var M=T.enum(["heap","stable"]);import*as S from"zod";var P=c.extend({caller:n.or(m),full_path:U}).strict(),O=c,H=i,K=S.object({key:k,content:f,headers:A}).strict(),B=c,N=i,E=P,J=P.extend({token:j}),q=i,Q=S.object({encoding:g,chunk_index:S.bigint(),memory:M}).strict();import{jsonReplacer as ee,jsonReviver as te}from"@dfinity/utils";var Oe=e=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(e),te),He=e=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(e,ee));var Ee=e=>{O.parse(e);let{collection:t}=e;return __juno_satellite_storage_count_collection_assets_store(t)},Je=e=>{H.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_count_assets_store(s,o,r)},qe=e=>{K.parse(e);let{key:t,content:o,headers:r}=e;__juno_satellite_storage_set_asset_handler(t,o,r)},Qe=e=>{E.parse(e);let{caller:t,collection:o,full_path:r}=e,s=a(t);return __juno_satellite_storage_delete_asset_store(s,o,r)},Ve=e=>{B.parse(e);let{collection:t}=e;__juno_satellite_storage_delete_assets_store(t)},We=e=>{N.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_delete_filtered_assets_store(s,o,r)},Xe=e=>{J.parse(e);let{caller:t,collection:o,full_path:r,token:s}=e,p=a(t);__juno_satellite_storage_set_asset_token_store(p,o,r,s)},Ye=e=>{P.parse(e);let{caller:t,collection:o,full_path:r}=e,s=a(t);return __juno_satellite_storage_get_asset_store(s,o,r)},Ze=e=>{q.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_list_assets_store(s,o,r)},$e=e=>{Q.parse(e);let{encoding:t,chunk_index:o,memory:r}=e;return __juno_satellite_storage_get_content_chunks_store(t,o,r)};export{c as CollectionParamsSchema,h as ControllerCheckParamsSchema,Y as ControllerRecordSchema,X as ControllerSchema,V as ControllerScopeSchema,Z as ControllersSchema,H as CountAssetsStoreParamsSchema,O as CountCollectionAssetsStoreParamsSchema,b as CountCollectionDocsStoreParamsSchema,w as CountDocsStoreParamsSchema,E as DeleteAssetStoreParamsSchema,B as DeleteAssetsStoreParamsSchema,z as DeleteDocStoreParamsSchema,G as DeleteDocsStoreParamsSchema,N as DeleteFilteredAssetsStoreParamsSchema,F as DeleteFilteredDocsStoreParamsSchema,P as GetAssetStoreParamsSchema,Q as GetContentChunksStoreParamsSchema,d as GetDocStoreParamsSchema,q as ListAssetsStoreParamsSchema,v as ListDocsStoreParamsSchema,i as ListStoreParamsSchema,M as MemorySchema,W as MetadataSchema,K as SetAssetHandlerParamsSchema,J as SetAssetTokenStoreParamsSchema,R as SetDocStoreParamsSchema,Je as countAssetsStore,Ee as countCollectionAssetsStore,je as countCollectionDocsStore,Ie as countDocsStore,Oe as decodeDocData,Qe as deleteAssetStore,Ve as deleteAssetsStore,ke as deleteDocStore,Le as deleteDocsStore,We as deleteFilteredAssetsStore,Re as deleteFilteredDocsStore,He as encodeDocData,me as getAdminControllers,Ye as getAssetStore,$e as getContentChunksStore,ie as getControllers,ge as getDocStore,pe as isAdminController,Se as isController,Ze as listAssetsStore,Ue as listDocsStore,qe as setAssetHandler,Xe as setAssetTokenStore,fe as setDocStore};
1
+ import{B as I,a as S,c as n,d as m,e as D,f as y,k as x,l as u,m as f,n as A,o as g,p as U,u as j}from"./chunk-4ZHRSCXC.js";import{b as h}from"./chunk-7B6WU32N.js";import"./chunk-4C666HHU.js";import*as l from"zod";var q=l.enum(["write","admin","submit"]),Q=l.tuple([l.string(),l.string()]),V=l.object({metadata:l.array(Q),created_at:S,updated_at:S,expires_at:S.optional(),scope:q}).strict(),W=l.tuple([h,V]),X=l.array(W),P=l.object({caller:n.or(m),controllers:X});import{Principal as Y}from"@icp-sdk/core/principal";var a=e=>Y.from(e).toUint8Array();var ce=()=>__juno_satellite_get_admin_controllers(),ne=()=>__juno_satellite_get_controllers(),me=e=>{P.parse(e);let{caller:t,controllers:o}=e,r=a(t);return __juno_satellite_is_admin_controller(r,o)},ie=e=>{P.parse(e);let{caller:t,controllers:o}=e,r=a(t);return __juno_satellite_is_controller(r,o)};import*as L from"zod";var c=L.object({collection:D}).strict(),i=c.extend({caller:n.or(m),params:I}).strict();var _=c.extend({caller:n.or(m),key:y}).strict(),R=_.extend({doc:x}).strict(),z=_.extend({doc:u}).strict(),k=c,b=i,w=i,v=c,F=i;var ue=e=>{R.parse(e);let{caller:t,collection:o,key:r,doc:s}=e,d=a(t);return __juno_satellite_datastore_set_doc_store(d,o,r,s)},fe=e=>{z.parse(e);let{caller:t,collection:o,key:r,doc:s}=e,d=a(t);return __juno_satellite_datastore_delete_doc_store(d,o,r,s)},Ae=e=>{_.parse(e);let{caller:t,collection:o,key:r}=e,s=a(t);return __juno_satellite_datastore_get_doc_store(s,o,r)},ge=e=>{w.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_list_docs_store(s,o,r)},Ue=e=>{k.parse(e);let{collection:t}=e;return __juno_satellite_datastore_count_collection_docs_store(t)},je=e=>{b.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_count_docs_store(s,o,r)},Ie=e=>{v.parse(e);let{collection:t}=e;__juno_satellite_datastore_delete_docs_store(t)},Le=e=>{F.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_delete_filtered_docs_store(s,o,r)};import*as G from"zod";var M=G.enum(["heap","stable"]);import*as p from"zod";var C=c.extend({caller:n.or(m),full_path:j}).strict(),O=c,H=i,T=p.object({key:g,content:A,headers:f}).strict(),K=c,B=i,N=C,E=i,J=p.object({encoding:U,chunk_index:p.bigint(),memory:M}).strict();import{jsonReplacer as Z,jsonReviver as $}from"@dfinity/utils";var Me=e=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(e),$),Oe=e=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(e,Z));var Be=e=>{O.parse(e);let{collection:t}=e;return __juno_satellite_storage_count_collection_assets_store(t)},Ne=e=>{H.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_count_assets_store(s,o,r)},Ee=e=>{T.parse(e);let{key:t,content:o,headers:r}=e;__juno_satellite_storage_set_asset_handler(t,o,r)},Je=e=>{N.parse(e);let{caller:t,collection:o,full_path:r}=e,s=a(t);return __juno_satellite_storage_delete_asset_store(s,o,r)},qe=e=>{K.parse(e);let{collection:t}=e;__juno_satellite_storage_delete_assets_store(t)},Qe=e=>{B.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_delete_filtered_assets_store(s,o,r)},Ve=e=>{C.parse(e);let{caller:t,collection:o,full_path:r}=e,s=a(t);return __juno_satellite_storage_get_asset_store(s,o,r)},We=e=>{E.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_list_assets_store(s,o,r)},Xe=e=>{J.parse(e);let{encoding:t,chunk_index:o,memory:r}=e;return __juno_satellite_storage_get_content_chunks_store(t,o,r)};export{c as CollectionParamsSchema,P as ControllerCheckParamsSchema,W as ControllerRecordSchema,V as ControllerSchema,q as ControllerScopeSchema,X as ControllersSchema,H as CountAssetsStoreParamsSchema,O as CountCollectionAssetsStoreParamsSchema,k as CountCollectionDocsStoreParamsSchema,b as CountDocsStoreParamsSchema,N as DeleteAssetStoreParamsSchema,K as DeleteAssetsStoreParamsSchema,z as DeleteDocStoreParamsSchema,v as DeleteDocsStoreParamsSchema,B as DeleteFilteredAssetsStoreParamsSchema,F as DeleteFilteredDocsStoreParamsSchema,C as GetAssetStoreParamsSchema,J as GetContentChunksStoreParamsSchema,_ as GetDocStoreParamsSchema,E as ListAssetsStoreParamsSchema,w as ListDocsStoreParamsSchema,i as ListStoreParamsSchema,M as MemorySchema,Q as MetadataSchema,T as SetAssetHandlerParamsSchema,R as SetDocStoreParamsSchema,Ne as countAssetsStore,Be as countCollectionAssetsStore,Ue as countCollectionDocsStore,je as countDocsStore,Me as decodeDocData,Je as deleteAssetStore,qe as deleteAssetsStore,fe as deleteDocStore,Ie as deleteDocsStore,Qe as deleteFilteredAssetsStore,Le as deleteFilteredDocsStore,Oe as encodeDocData,ce as getAdminControllers,Ve as getAssetStore,Xe as getContentChunksStore,ne as getControllers,Ae as getDocStore,me as isAdminController,ie as isController,We as listAssetsStore,ge as listDocsStore,Ee as setAssetHandler,ue as setDocStore};
2
2
  //# sourceMappingURL=sdk.js.map
package/sdk.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/sdk/schemas/controllers.ts", "src/sdk/utils/caller.utils.ts", "src/sdk/controllers.sdk.ts", "src/sdk/schemas/params.ts", "src/sdk/schemas/db.ts", "src/sdk/db.sdk.ts", "src/sdk/schemas/collections.ts", "src/sdk/schemas/storage.ts", "src/sdk/serializer.sdk.ts", "src/sdk/storage.sdk.ts"],
4
- "sourcesContent": ["import * as z from 'zod';\nimport {RawPrincipalSchema} from '../../schemas/candid';\nimport {\n type RawUserId,\n type Timestamp,\n type UserId,\n RawUserIdSchema,\n TimestampSchema,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see ControllerScopeSchema\n */\nexport const ControllerScopeSchema = z.enum(['write', 'admin', 'submit']);\n\n/**\n * Represents the permission scope of a controller.\n */\nexport type ControllerScope = z.infer<typeof ControllerScopeSchema>;\n\n/**\n * @see MetadataSchema\n */\nexport const MetadataSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single metadata entry as a key-value tuple.\n */\nexport type Metadata = z.infer<typeof MetadataSchema>;\n\n/**\n * @see ControllerSchema\n */\nexport const ControllerSchema = z\n .object({\n metadata: z.array(MetadataSchema),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n expires_at: TimestampSchema.optional(),\n scope: ControllerScopeSchema\n })\n .strict();\n\n/**\n * Represents a controller with access scope and associated metadata.\n */\nexport interface Controller {\n /**\n * A list of key-value metadata pairs associated with the controller.\n */\n metadata: Metadata[];\n\n /**\n * The timestamp when the controller was created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the controller was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional expiration timestamp for the controller.\n * \uD83D\uDC49 It's a placeholder for future implementation.\n */\n expires_at?: Timestamp;\n\n /**\n * The scope assigned to the controller.\n */\n scope: ControllerScope;\n}\n\n/**\n * @see ControllerRecordSchema\n */\nexport const ControllerRecordSchema = z.tuple([RawPrincipalSchema, ControllerSchema]);\n\n/**\n * Represents a tuple containing the principal ID and associated controller data.\n */\nexport type ControllerRecord = z.infer<typeof ControllerRecordSchema>;\n\n/**\n * @see ControllersSchema\n */\nexport const ControllersSchema = z.array(ControllerRecordSchema);\n\n/**\n * Represents a list of controllers.\n */\nexport type Controllers = z.infer<typeof ControllersSchema>;\n\n/**\n * @see ControllerCheckParamsSchema\n */\nexport const ControllerCheckParamsSchema = z.object({\n caller: RawUserIdSchema.or(UserIdSchema),\n controllers: ControllersSchema\n});\n\n/**\n * Represents the parameters required to perform controller checks.\n */\nexport interface ControllerCheckParams {\n /**\n * The identity of the caller to verify against the controller list.\n */\n caller: RawUserId | UserId;\n\n /**\n * The list of controllers to check against.\n */\n controllers: Controllers;\n}\n", "import {Principal} from '@icp-sdk/core/principal';\nimport type {RawUserId, UserId} from '../../schemas/satellite';\n\n/**\n * Normalizes a user ID into a raw `Uint8Array` representation.\n *\n * @param {RawUserId | UserId} caller - The caller identity, either a raw `Uint8Array`\n * or a `Principal` instance.\n *\n * @returns {RawUserId} The raw user ID as a `Uint8Array`.\n */\nexport const normalizeCaller = (caller: RawUserId | UserId): RawUserId =>\n Principal.from(caller).toUint8Array();\n", "import {\n type ControllerCheckParams,\n type Controllers,\n ControllerCheckParamsSchema\n} from './schemas/controllers';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Gets the list of admin controllers from the Satellite.\n *\n * @returns {Controllers} The list of admin controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getAdminControllers = (): Controllers => __juno_satellite_get_admin_controllers();\n\n/**\n * Gets the list of controllers from the Satellite.\n *\n * @returns {Controllers} The list of all controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getControllers = (): Controllers => __juno_satellite_get_controllers();\n\n/**\n * Checks if the given caller is an admin among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is an admin.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isAdminController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_admin_controller(caller, controllers);\n};\n\n/**\n * Checks if the given caller exists among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is a controller.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_controller(caller, controllers);\n};\n", "import * as z from 'zod';\nimport {type ListParams, ListParamsSchema} from '../../schemas/list';\nimport {\n type Collection,\n CollectionSchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see CollectionParams\n */\nexport const CollectionParamsSchema = z\n .object({\n collection: CollectionSchema\n })\n .strict();\n\n/**\n * The parameters required to scope an operation to a collection.\n */\nexport interface CollectionParams {\n /**\n * The name of the collection to target.\n */\n collection: Collection;\n}\n\n/**\n * @see ListStoreParams\n */\nexport const ListStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n params: ListParamsSchema\n}).strict();\n\n/**\n * The parameters required to list documents from the datastore respectively assets from the storage.\n */\nexport type ListStoreParams = CollectionParams & {\n /**\n * The identity of the caller requesting the list operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * Optional filtering, ordering, and pagination parameters.\n */\n params: ListParams;\n};\n", "import {type DelDoc, DelDocSchema, type SetDoc, SetDocSchema} from '../../schemas/db';\nimport {\n type Key,\n KeySchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\nimport {\n type CollectionParams,\n CollectionParamsSchema,\n type ListStoreParams,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetDocStoreParams\n */\nexport const GetDocStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n key: KeySchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the datastore and modify a document.\n */\nexport type GetDocStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n};\n\n/**\n * @see SetDocStoreParams\n */\nexport const SetDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: SetDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to store or update a document.\n *\n * This includes the document data along with metadata such as the caller,\n * collection, and key.\n */\nexport type SetDocStoreParams = GetDocStoreParams & {\n /**\n * The data, optional description and version required to create or update a document.\n */\n doc: SetDoc;\n};\n\n/**\n * @see DeleteDocStoreParams\n */\nexport const DeleteDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: DelDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to delete a document.\n *\n * This includes the document version along with metadata such as the caller,\n * collection, and key.\n */\nexport type DeleteDocStoreParams = GetDocStoreParams & {\n /**\n * The version required to delete a document.\n */\n doc: DelDoc;\n};\n\n/**\n * @see CountCollectionDocsStoreParams\n */\nexport const CountCollectionDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountCollectionDocsStoreParams = CollectionParams;\n\n/**\n * @see CountDocsStoreParams\n */\nexport const CountDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountDocsStoreParams = ListStoreParams;\n\n/**\n * @see ListDocsStoreParams\n */\nexport const ListDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListDocsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteDocsStoreParams\n */\nexport const DeleteDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the documents from a collection of the datastore.\n */\nexport type DeleteDocsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredDocsParams\n */\nexport const DeleteFilteredDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete documents from the datastore.\n */\nexport type DeleteFilteredDocsStoreParams = ListStoreParams;\n", "import type {DocContext} from '../hooks/schemas/db/context';\nimport type {DocUpsert} from '../hooks/schemas/db/payload';\nimport type {Doc, OptionDoc} from '../schemas/db';\nimport type {ListResults} from '../schemas/list';\nimport {\n type CountCollectionDocsStoreParams,\n CountCollectionDocsStoreParamsSchema,\n type CountDocsStoreParams,\n CountDocsStoreParamsSchema,\n type DeleteDocsStoreParams,\n DeleteDocsStoreParamsSchema,\n type DeleteDocStoreParams,\n DeleteDocStoreParamsSchema,\n type DeleteFilteredDocsStoreParams,\n DeleteFilteredDocsStoreParamsSchema,\n type GetDocStoreParams,\n GetDocStoreParamsSchema,\n type ListDocsStoreParams,\n ListDocsStoreParamsSchema,\n type SetDocStoreParams,\n SetDocStoreParamsSchema\n} from './schemas/db';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Stores or updates a document in the datastore.\n *\n * The data must have been encoded - using encodeDocData - before calling this function.\n *\n * @param {SetDocStoreParams} params - The parameters required to store the document,\n * including the caller, collection, key, and document data.\n *\n * @returns {DocContext<DocUpsert>} The context of the stored or updated document,\n * including its key, collection, and both the previous and current versions of the document.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate or store the document.\n */\nexport const setDocStore = (params: SetDocStoreParams): DocContext<DocUpsert> => {\n SetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_set_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Deletes a document from the datastore.\n *\n * @param {DeleteDocStoreParams} params - The parameters required to delete the document,\n * including the caller, collection, key, and the expected version of the document.\n *\n * @returns {DocContext<OptionDoc>} The context of the deleted document,\n * including its key, collection, and optionally the previous document data if it existed.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the document cannot be deleted.\n */\nexport const deleteDocStore = (params: DeleteDocStoreParams): DocContext<OptionDoc> => {\n DeleteDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Retrieve a document from the datastore.\n *\n * @param {GetDocStoreParams} params - The parameters required to get the document.\n *\n * @returns {OptionDoc} The document if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getDocStore = (params: GetDocStoreParams): OptionDoc => {\n GetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_get_doc_store(caller, collection, key);\n};\n\n/**\n * Lists documents from the datastore using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<Doc>} A list result containing matching documents and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listDocsStore = (params: ListDocsStoreParams): ListResults<Doc> => {\n ListDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_list_docs_store(caller, collection, listParams);\n};\n\n/**\n * Counts the number of documents in a specific collection.\n *\n * @param {CountCollectionDocsStoreParams} params - The parameters required to count documents in the collection.\n *\n * @returns {bigint} The total number of documents in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionDocsStore = (params: CountCollectionDocsStoreParams): bigint => {\n CountCollectionDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_datastore_count_collection_docs_store(collection);\n};\n\n/**\n * Counts the number of documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountDocsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countDocsStore = (params: CountDocsStoreParams): bigint => {\n CountDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_count_docs_store(caller, collection, listParams);\n};\n\n/**\n * Delete documents in a specific collection of the Datastore.\n *\n * @param {DeleteDocsStoreParams} params - The parameters required to delete documents in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteDocsStore = (params: DeleteDocsStoreParams): void => {\n DeleteDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_datastore_delete_docs_store(collection);\n};\n\n/**\n * Delete documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredDocsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {DocContext<OptionDoc>[]} The context resulting of the deletion of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredDocsStore = (\n params: DeleteFilteredDocsStoreParams\n): DocContext<OptionDoc>[] => {\n DeleteFilteredDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_filtered_docs_store(caller, collection, listParams);\n};\n", "import * as z from 'zod';\n\n/**\n * @see Memory\n */\nexport const MemorySchema = z.enum(['heap', 'stable']);\n\n/**\n * Memory type used to select storage or datastore location.\n */\nexport type Memory = z.infer<typeof MemorySchema>;\n", "import * as z from 'zod';\nimport {type RawUserId, type UserId, RawUserIdSchema, UserIdSchema} from '../../schemas/satellite';\nimport {\n type AssetAccessToken,\n type AssetEncoding,\n type AssetKey,\n type Blob,\n type FullPath,\n type HeaderFields,\n AssetAccessTokenSchema,\n AssetEncodingSchema,\n AssetKeySchema,\n BlobSchema,\n FullPathSchema,\n HeaderFieldsSchema\n} from '../../schemas/storage';\nimport {type Memory, MemorySchema} from './collections';\nimport {\n type CollectionParams,\n type ListStoreParams,\n CollectionParamsSchema,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetAssetStoreParams\n */\nexport const GetAssetStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n full_path: FullPathSchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the storage and modify an asset.\n */\nexport type GetAssetStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The full_path identifying the asset within the collection.\n */\n full_path: FullPath;\n};\n\n/**\n * @see CountCollectionAssetsStoreParams\n */\nexport const CountCollectionAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountCollectionAssetsStoreParams = CollectionParams;\n\n/**\n * @see CountAssetsStoreParams\n */\nexport const CountAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountAssetsStoreParams = ListStoreParams;\n\n/**\n * @see SetAssetHandlerParams\n */\nexport const SetAssetHandlerParamsSchema = z\n .object({\n key: AssetKeySchema,\n content: BlobSchema,\n headers: HeaderFieldsSchema\n })\n .strict();\n\n/**\n * The parameters required to set (or update) an asset.\n */\nexport interface SetAssetHandlerParams {\n /**\n * The key identifying the asset.\n */\n key: AssetKey;\n\n /**\n * The binary content of the asset.\n */\n content: Blob;\n\n /**\n * Associated HTTP headers.\n */\n headers: HeaderFields;\n}\n\n/**\n * @see DeleteAssetsStoreParams\n */\nexport const DeleteAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the assets from a collection of the storage.\n */\nexport type DeleteAssetsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredAssetsParams\n */\nexport const DeleteFilteredAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete assets from the storage.\n */\nexport type DeleteFilteredAssetsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteAssetStoreParams\n */\nexport const DeleteAssetStoreParamsSchema = GetAssetStoreParamsSchema;\n\n/**\n * Represents the parameters required to delete an asset.\n */\nexport type DeleteAssetStoreParams = GetAssetStoreParams;\n\n/**\n * @see SetAssetTokenStoreParams\n */\nexport const SetAssetTokenStoreParamsSchema = GetAssetStoreParamsSchema.extend({\n token: AssetAccessTokenSchema\n});\n\n/**\n * Represents the parameters required to delete an asset.\n */\nexport type SetAssetTokenStoreParams = GetAssetStoreParams & {\n /**\n * The token to apply to the asset.\n * Setting `undefined` removes the protection and makes the asset public.\n */\n token: AssetAccessToken;\n};\n\n/**\n * @see ListAssetsStoreParams\n */\nexport const ListAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListAssetsStoreParams = ListStoreParams;\n\n/**\n * @see GetContentChunksStoreParams\n */\nexport const GetContentChunksStoreParamsSchema = z\n .object({\n encoding: AssetEncodingSchema,\n chunk_index: z.bigint(),\n memory: MemorySchema\n })\n .strict();\n\n/**\n * The parameters required to retrieve a specific chunk from an asset.\n */\nexport interface GetContentChunksStoreParams {\n /**\n * The encoding of the chunks.\n */\n encoding: AssetEncoding;\n\n /**\n * The index of the chunk to retrieve.\n */\n chunk_index: bigint;\n\n /**\n * The memory type to retrieve the chunk from.\n */\n memory: Memory;\n}\n", "import {jsonReplacer, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../schemas/db';\n\n/**\n * Decodes the raw data of a document into a JavaScript object.\n *\n * @template T The expected type of the decoded object.\n * @param {RawData} data - The raw data to be decoded.\n * @returns {T} The parsed JavaScript object.\n */\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\n/**\n * Encodes a JavaScript object into a raw data format to be applied to a document.\n *\n * @template T The type of the object to be encoded.\n * @param {T} data - The data to be encoded.\n * @returns {RawData} The serialized raw data.\n */\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\n", "import type {ListResults} from '../schemas/list';\nimport type {AssetNoContent, Blob, OptionAsset} from '../schemas/storage';\nimport {\n type CountAssetsStoreParams,\n CountAssetsStoreParamsSchema,\n type CountCollectionAssetsStoreParams,\n CountCollectionAssetsStoreParamsSchema,\n type DeleteAssetsStoreParams,\n DeleteAssetsStoreParamsSchema,\n type DeleteAssetStoreParams,\n DeleteAssetStoreParamsSchema,\n type DeleteFilteredAssetsStoreParams,\n DeleteFilteredAssetsStoreParamsSchema,\n type GetAssetStoreParams,\n GetAssetStoreParamsSchema,\n type GetContentChunksStoreParams,\n GetContentChunksStoreParamsSchema,\n type ListAssetsStoreParams,\n ListAssetsStoreParamsSchema,\n type SetAssetHandlerParams,\n SetAssetHandlerParamsSchema,\n type SetAssetTokenStoreParams,\n SetAssetTokenStoreParamsSchema\n} from './schemas/storage';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Counts the number of assets in a specific collection.\n *\n * @param {CountCollectionAssetsStoreParams} params - The parameters required to count assets in the collection.\n *\n * @returns {bigint} The total number of assets in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionAssetsStore = (params: CountCollectionAssetsStoreParams): bigint => {\n CountCollectionAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_storage_count_collection_assets_store(collection);\n};\n\n/**\n * Counts the number of assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountAssetsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of assets that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countAssetsStore = (params: CountAssetsStoreParams): bigint => {\n CountAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_count_assets_store(caller, collection, listParams);\n};\n\n/**\n * Sets or updates an asset in the storage.\n *\n * @param {SetAssetHandlerParams} params - The parameters required to set or update an asset.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the operation.\n */\nexport const setAssetHandler = (params: SetAssetHandlerParams): void => {\n SetAssetHandlerParamsSchema.parse(params);\n\n const {key, content, headers} = params;\n\n __juno_satellite_storage_set_asset_handler(key, content, headers);\n};\n\n/**\n * Deletes an asset from the storage.\n *\n * @param {DeleteAssetStoreParams} params - The parameters required to delete the asset.\n *\n * @returns {OptionAsset} The potentially deleted asset.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the asset cannot be deleted.\n */\nexport const deleteAssetStore = (params: DeleteAssetStoreParams): OptionAsset => {\n DeleteAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_asset_store(caller, collection, full_path);\n};\n\n/**\n * Delete assets in a specific collection of the Storage.\n *\n * @param {DeleteAssetsStoreParams} params - The parameters required to delete assets in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteAssetsStore = (params: DeleteAssetsStoreParams): void => {\n DeleteAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_storage_delete_assets_store(collection);\n};\n\n/**\n * Delete assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredAssetsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {OptionAsset[]} The potential asset resulting of the deletion that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredAssetsStore = (\n params: DeleteFilteredAssetsStoreParams\n): OptionAsset[] => {\n DeleteFilteredAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_filtered_assets_store(caller, collection, listParams);\n};\n\n/**\n * Set or update an access token for an asset in a collection's store.\n *\n * @param {SetAssetTokenStoreParams} params - The parameters required to set the token of the asset.\n *\n *@throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the token cannot be set.\n */\nexport const setAssetTokenStore = (params: SetAssetTokenStoreParams): void => {\n SetAssetTokenStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path, token} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n __juno_satellite_storage_set_asset_token_store(caller, collection, full_path, token);\n};\n\n/**\n * Retrieve an asset from the storage.\n *\n * @param {GetAssetStoreParams} params - The parameters required to get the asset.\n *\n * @returns {OptionAsset} The asset if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getAssetStore = (params: GetAssetStoreParams): OptionAsset => {\n GetAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_get_asset_store(caller, collection, full_path);\n};\n\n/**\n * Lists assets (without content) from the storage using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<AssetNoContent>} A list result containing matching assets and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listAssetsStore = (params: ListAssetsStoreParams): ListResults<AssetNoContent> => {\n ListAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_list_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieves content chunks of an asset.\n *\n * This function fetches a content chunk of a given asset encoding using the specified parameters.\n *\n * @param {GetContentChunksStoreParams} params - The parameters including encoding, chunk index, and memory type.\n *\n * @returns {Blob | undefined} The content chunk if found, or `undefined` if not.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite throws an internal error during retrieval.\n */\nexport const getContentChunksStore = (params: GetContentChunksStoreParams): Blob | undefined => {\n GetContentChunksStoreParamsSchema.parse(params);\n\n const {encoding, chunk_index, memory} = params;\n\n return __juno_satellite_storage_get_content_chunks_store(encoding, chunk_index, memory);\n};\n"],
5
- "mappings": "uMAAA,UAAYA,MAAO,MAcZ,IAAMC,EAA0B,OAAK,CAAC,QAAS,QAAS,QAAQ,CAAC,EAU3DC,EAAmB,QAAM,CAAG,SAAO,EAAK,SAAO,CAAC,CAAC,EAUjDC,EACV,SAAO,CACN,SAAY,QAAMD,CAAc,EAChC,WAAYE,EACZ,WAAYA,EACZ,WAAYA,EAAgB,SAAS,EACrC,MAAOH,CACT,CAAC,EACA,OAAO,EAoCGI,EAA2B,QAAM,CAACC,EAAoBH,CAAgB,CAAC,EAUvEI,EAAsB,QAAMF,CAAsB,EAUlDG,EAAgC,SAAO,CAClD,OAAQC,EAAgB,GAAGC,CAAY,EACvC,YAAaH,CACf,CAAC,ECrGD,OAAQ,aAAAI,MAAgB,0BAWjB,IAAMC,EAAmBC,GAC9BF,EAAU,KAAKE,CAAM,EAAE,aAAa,ECE/B,IAAMC,GAAsB,IAAmB,uCAAuC,EAShFC,GAAiB,IAAmB,iCAAiC,EAYrEC,GAAqBC,GAA2C,CAC3EC,EAA4B,MAAMD,CAAM,EAExC,GAAM,CAAC,OAAQE,EAAgB,YAAAC,CAAW,EAAIH,EAExCI,EAASC,EAAgBH,CAAc,EAE7C,OAAO,qCAAqCE,EAAQD,CAAW,CACjE,EAYaG,GAAgBN,GAA2C,CACtEC,EAA4B,MAAMD,CAAM,EAExC,GAAM,CAAC,OAAQE,EAAgB,YAAA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,EAAIN,EAE3DO,EAASC,EAAgBH,CAAc,EAE7C,OAAO,sDAAsDE,EAAQL,EAAYI,CAAU,CAC7F,EAUae,GAAsBrB,GAA2C,CAC5EsB,EAA+B,MAAMtB,CAAM,EAE3C,GAAM,CAAC,OAAQK,EAAgB,WAAAH,EAAY,UAAAc,EAAW,MAAAO,CAAK,EAAIvB,EAEzDO,EAASC,EAAgBH,CAAc,EAE7C,+CAA+CE,EAAQL,EAAYc,EAAWO,CAAK,CACrF,EAYaC,GAAiBxB,GAA6C,CACzEyB,EAA0B,MAAMzB,CAAM,EAEtC,GAAM,CAAC,OAAQK,EAAgB,WAAAH,EAAY,UAAAc,CAAS,EAAIhB,EAElDO,EAASC,EAAgBH,CAAc,EAE7C,OAAO,yCAAyCE,EAAQL,EAAYc,CAAS,CAC/E,EAYaU,GAAmB1B,GAA+D,CAC7F2B,EAA4B,MAAM3B,CAAM,EAExC,GAAM,CAAC,OAAQK,EAAgB,WAAAH,EAAY,OAAQI,CAAU,EAAIN,EAE3DO,EAASC,EAAgBH,CAAc,EAE7C,OAAO,2CAA2CE,EAAQL,EAAYI,CAAU,CAClF,EAcasB,GAAyB5B,GAA0D,CAC9F6B,EAAkC,MAAM7B,CAAM,EAE9C,GAAM,CAAC,SAAA8B,EAAU,YAAAC,EAAa,OAAAC,CAAM,EAAIhC,EAExC,OAAO,kDAAkD8B,EAAUC,EAAaC,CAAM,CACxF",
6
- "names": ["z", "ControllerScopeSchema", "MetadataSchema", "ControllerSchema", "TimestampSchema", "ControllerRecordSchema", "RawPrincipalSchema", "ControllersSchema", "ControllerCheckParamsSchema", "RawUserIdSchema", "UserIdSchema", "Principal", "normalizeCaller", "caller", "getAdminControllers", "getControllers", "isAdminController", "params", "ControllerCheckParamsSchema", "providedCaller", "controllers", "caller", "normalizeCaller", "isController", "z", "CollectionParamsSchema", "CollectionSchema", "ListStoreParamsSchema", "RawUserIdSchema", "UserIdSchema", "ListParamsSchema", "GetDocStoreParamsSchema", "CollectionParamsSchema", "RawUserIdSchema", "UserIdSchema", "KeySchema", "SetDocStoreParamsSchema", "SetDocSchema", "DeleteDocStoreParamsSchema", "DelDocSchema", "CountCollectionDocsStoreParamsSchema", "CountDocsStoreParamsSchema", "ListStoreParamsSchema", "ListDocsStoreParamsSchema", "DeleteDocsStoreParamsSchema", "DeleteFilteredDocsStoreParamsSchema", "setDocStore", "params", "SetDocStoreParamsSchema", "providedCaller", "collection", "key", "doc", "caller", "normalizeCaller", "deleteDocStore", "DeleteDocStoreParamsSchema", "getDocStore", "GetDocStoreParamsSchema", "listDocsStore", "ListDocsStoreParamsSchema", "listParams", "countCollectionDocsStore", "CountCollectionDocsStoreParamsSchema", "countDocsStore", "CountDocsStoreParamsSchema", "deleteDocsStore", "DeleteDocsStoreParamsSchema", "deleteFilteredDocsStore", "DeleteFilteredDocsStoreParamsSchema", "z", "MemorySchema", "z", "GetAssetStoreParamsSchema", "CollectionParamsSchema", "RawUserIdSchema", "UserIdSchema", "FullPathSchema", "CountCollectionAssetsStoreParamsSchema", "CountAssetsStoreParamsSchema", "ListStoreParamsSchema", "SetAssetHandlerParamsSchema", "AssetKeySchema", "BlobSchema", "HeaderFieldsSchema", "DeleteAssetsStoreParamsSchema", "DeleteFilteredAssetsStoreParamsSchema", "DeleteAssetStoreParamsSchema", "SetAssetTokenStoreParamsSchema", "AssetAccessTokenSchema", "ListAssetsStoreParamsSchema", "GetContentChunksStoreParamsSchema", "AssetEncodingSchema", "MemorySchema", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData", "countCollectionAssetsStore", "params", "CountCollectionAssetsStoreParamsSchema", "collection", "countAssetsStore", "CountAssetsStoreParamsSchema", "providedCaller", "listParams", "caller", "normalizeCaller", "setAssetHandler", "SetAssetHandlerParamsSchema", "key", "content", "headers", "deleteAssetStore", "DeleteAssetStoreParamsSchema", "full_path", "deleteAssetsStore", "DeleteAssetsStoreParamsSchema", "deleteFilteredAssetsStore", "DeleteFilteredAssetsStoreParamsSchema", "setAssetTokenStore", "SetAssetTokenStoreParamsSchema", "token", "getAssetStore", "GetAssetStoreParamsSchema", "listAssetsStore", "ListAssetsStoreParamsSchema", "getContentChunksStore", "GetContentChunksStoreParamsSchema", "encoding", "chunk_index", "memory"]
4
+ "sourcesContent": ["import * as z from 'zod';\nimport {RawPrincipalSchema} from '../../schemas/candid';\nimport {\n type RawUserId,\n type Timestamp,\n type UserId,\n RawUserIdSchema,\n TimestampSchema,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see ControllerScopeSchema\n */\nexport const ControllerScopeSchema = z.enum(['write', 'admin', 'submit']);\n\n/**\n * Represents the permission scope of a controller.\n */\nexport type ControllerScope = z.infer<typeof ControllerScopeSchema>;\n\n/**\n * @see MetadataSchema\n */\nexport const MetadataSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single metadata entry as a key-value tuple.\n */\nexport type Metadata = z.infer<typeof MetadataSchema>;\n\n/**\n * @see ControllerSchema\n */\nexport const ControllerSchema = z\n .object({\n metadata: z.array(MetadataSchema),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n expires_at: TimestampSchema.optional(),\n scope: ControllerScopeSchema\n })\n .strict();\n\n/**\n * Represents a controller with access scope and associated metadata.\n */\nexport interface Controller {\n /**\n * A list of key-value metadata pairs associated with the controller.\n */\n metadata: Metadata[];\n\n /**\n * The timestamp when the controller was created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the controller was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional expiration timestamp for the controller.\n * \uD83D\uDC49 It's a placeholder for future implementation.\n */\n expires_at?: Timestamp;\n\n /**\n * The scope assigned to the controller.\n */\n scope: ControllerScope;\n}\n\n/**\n * @see ControllerRecordSchema\n */\nexport const ControllerRecordSchema = z.tuple([RawPrincipalSchema, ControllerSchema]);\n\n/**\n * Represents a tuple containing the principal ID and associated controller data.\n */\nexport type ControllerRecord = z.infer<typeof ControllerRecordSchema>;\n\n/**\n * @see ControllersSchema\n */\nexport const ControllersSchema = z.array(ControllerRecordSchema);\n\n/**\n * Represents a list of controllers.\n */\nexport type Controllers = z.infer<typeof ControllersSchema>;\n\n/**\n * @see ControllerCheckParamsSchema\n */\nexport const ControllerCheckParamsSchema = z.object({\n caller: RawUserIdSchema.or(UserIdSchema),\n controllers: ControllersSchema\n});\n\n/**\n * Represents the parameters required to perform controller checks.\n */\nexport interface ControllerCheckParams {\n /**\n * The identity of the caller to verify against the controller list.\n */\n caller: RawUserId | UserId;\n\n /**\n * The list of controllers to check against.\n */\n controllers: Controllers;\n}\n", "import {Principal} from '@icp-sdk/core/principal';\nimport type {RawUserId, UserId} from '../../schemas/satellite';\n\n/**\n * Normalizes a user ID into a raw `Uint8Array` representation.\n *\n * @param {RawUserId | UserId} caller - The caller identity, either a raw `Uint8Array`\n * or a `Principal` instance.\n *\n * @returns {RawUserId} The raw user ID as a `Uint8Array`.\n */\nexport const normalizeCaller = (caller: RawUserId | UserId): RawUserId =>\n Principal.from(caller).toUint8Array();\n", "import {\n type ControllerCheckParams,\n type Controllers,\n ControllerCheckParamsSchema\n} from './schemas/controllers';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Gets the list of admin controllers from the Satellite.\n *\n * @returns {Controllers} The list of admin controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getAdminControllers = (): Controllers => __juno_satellite_get_admin_controllers();\n\n/**\n * Gets the list of controllers from the Satellite.\n *\n * @returns {Controllers} The list of all controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getControllers = (): Controllers => __juno_satellite_get_controllers();\n\n/**\n * Checks if the given caller is an admin among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is an admin.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isAdminController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_admin_controller(caller, controllers);\n};\n\n/**\n * Checks if the given caller exists among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is a controller.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_controller(caller, controllers);\n};\n", "import * as z from 'zod';\nimport {type ListParams, ListParamsSchema} from '../../schemas/list';\nimport {\n type Collection,\n CollectionSchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see CollectionParams\n */\nexport const CollectionParamsSchema = z\n .object({\n collection: CollectionSchema\n })\n .strict();\n\n/**\n * The parameters required to scope an operation to a collection.\n */\nexport interface CollectionParams {\n /**\n * The name of the collection to target.\n */\n collection: Collection;\n}\n\n/**\n * @see ListStoreParams\n */\nexport const ListStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n params: ListParamsSchema\n}).strict();\n\n/**\n * The parameters required to list documents from the datastore respectively assets from the storage.\n */\nexport type ListStoreParams = CollectionParams & {\n /**\n * The identity of the caller requesting the list operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * Optional filtering, ordering, and pagination parameters.\n */\n params: ListParams;\n};\n", "import {type DelDoc, DelDocSchema, type SetDoc, SetDocSchema} from '../../schemas/db';\nimport {\n type Key,\n KeySchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\nimport {\n type CollectionParams,\n CollectionParamsSchema,\n type ListStoreParams,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetDocStoreParams\n */\nexport const GetDocStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n key: KeySchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the datastore and modify a document.\n */\nexport type GetDocStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n};\n\n/**\n * @see SetDocStoreParams\n */\nexport const SetDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: SetDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to store or update a document.\n *\n * This includes the document data along with metadata such as the caller,\n * collection, and key.\n */\nexport type SetDocStoreParams = GetDocStoreParams & {\n /**\n * The data, optional description and version required to create or update a document.\n */\n doc: SetDoc;\n};\n\n/**\n * @see DeleteDocStoreParams\n */\nexport const DeleteDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: DelDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to delete a document.\n *\n * This includes the document version along with metadata such as the caller,\n * collection, and key.\n */\nexport type DeleteDocStoreParams = GetDocStoreParams & {\n /**\n * The version required to delete a document.\n */\n doc: DelDoc;\n};\n\n/**\n * @see CountCollectionDocsStoreParams\n */\nexport const CountCollectionDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountCollectionDocsStoreParams = CollectionParams;\n\n/**\n * @see CountDocsStoreParams\n */\nexport const CountDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountDocsStoreParams = ListStoreParams;\n\n/**\n * @see ListDocsStoreParams\n */\nexport const ListDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListDocsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteDocsStoreParams\n */\nexport const DeleteDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the documents from a collection of the datastore.\n */\nexport type DeleteDocsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredDocsParams\n */\nexport const DeleteFilteredDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete documents from the datastore.\n */\nexport type DeleteFilteredDocsStoreParams = ListStoreParams;\n", "import type {DocContext} from '../hooks/schemas/db/context';\nimport type {DocUpsert} from '../hooks/schemas/db/payload';\nimport type {Doc, OptionDoc} from '../schemas/db';\nimport type {ListResults} from '../schemas/list';\nimport {\n type CountCollectionDocsStoreParams,\n CountCollectionDocsStoreParamsSchema,\n type CountDocsStoreParams,\n CountDocsStoreParamsSchema,\n type DeleteDocsStoreParams,\n DeleteDocsStoreParamsSchema,\n type DeleteDocStoreParams,\n DeleteDocStoreParamsSchema,\n type DeleteFilteredDocsStoreParams,\n DeleteFilteredDocsStoreParamsSchema,\n type GetDocStoreParams,\n GetDocStoreParamsSchema,\n type ListDocsStoreParams,\n ListDocsStoreParamsSchema,\n type SetDocStoreParams,\n SetDocStoreParamsSchema\n} from './schemas/db';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Stores or updates a document in the datastore.\n *\n * The data must have been encoded - using encodeDocData - before calling this function.\n *\n * @param {SetDocStoreParams} params - The parameters required to store the document,\n * including the caller, collection, key, and document data.\n *\n * @returns {DocContext<DocUpsert>} The context of the stored or updated document,\n * including its key, collection, and both the previous and current versions of the document.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate or store the document.\n */\nexport const setDocStore = (params: SetDocStoreParams): DocContext<DocUpsert> => {\n SetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_set_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Deletes a document from the datastore.\n *\n * @param {DeleteDocStoreParams} params - The parameters required to delete the document,\n * including the caller, collection, key, and the expected version of the document.\n *\n * @returns {DocContext<OptionDoc>} The context of the deleted document,\n * including its key, collection, and optionally the previous document data if it existed.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the document cannot be deleted.\n */\nexport const deleteDocStore = (params: DeleteDocStoreParams): DocContext<OptionDoc> => {\n DeleteDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Retrieve a document from the datastore.\n *\n * @param {GetDocStoreParams} params - The parameters required to get the document.\n *\n * @returns {OptionDoc} The document if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getDocStore = (params: GetDocStoreParams): OptionDoc => {\n GetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_get_doc_store(caller, collection, key);\n};\n\n/**\n * Lists documents from the datastore using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<Doc>} A list result containing matching documents and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listDocsStore = (params: ListDocsStoreParams): ListResults<Doc> => {\n ListDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_list_docs_store(caller, collection, listParams);\n};\n\n/**\n * Counts the number of documents in a specific collection.\n *\n * @param {CountCollectionDocsStoreParams} params - The parameters required to count documents in the collection.\n *\n * @returns {bigint} The total number of documents in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionDocsStore = (params: CountCollectionDocsStoreParams): bigint => {\n CountCollectionDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_datastore_count_collection_docs_store(collection);\n};\n\n/**\n * Counts the number of documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountDocsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countDocsStore = (params: CountDocsStoreParams): bigint => {\n CountDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_count_docs_store(caller, collection, listParams);\n};\n\n/**\n * Delete documents in a specific collection of the Datastore.\n *\n * @param {DeleteDocsStoreParams} params - The parameters required to delete documents in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteDocsStore = (params: DeleteDocsStoreParams): void => {\n DeleteDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_datastore_delete_docs_store(collection);\n};\n\n/**\n * Delete documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredDocsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {DocContext<OptionDoc>[]} The context resulting of the deletion of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredDocsStore = (\n params: DeleteFilteredDocsStoreParams\n): DocContext<OptionDoc>[] => {\n DeleteFilteredDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_filtered_docs_store(caller, collection, listParams);\n};\n", "import * as z from 'zod';\n\n/**\n * @see Memory\n */\nexport const MemorySchema = z.enum(['heap', 'stable']);\n\n/**\n * Memory type used to select storage or datastore location.\n */\nexport type Memory = z.infer<typeof MemorySchema>;\n", "import * as z from 'zod';\nimport {type RawUserId, type UserId, RawUserIdSchema, UserIdSchema} from '../../schemas/satellite';\nimport {\n type AssetEncoding,\n type AssetKey,\n type Blob,\n type FullPath,\n type HeaderFields,\n AssetEncodingSchema,\n AssetKeySchema,\n BlobSchema,\n FullPathSchema,\n HeaderFieldsSchema\n} from '../../schemas/storage';\nimport {type Memory, MemorySchema} from './collections';\nimport {\n type CollectionParams,\n type ListStoreParams,\n CollectionParamsSchema,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetAssetStoreParams\n */\nexport const GetAssetStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n full_path: FullPathSchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the storage and modify an asset.\n */\nexport type GetAssetStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The full_path identifying the asset within the collection.\n */\n full_path: FullPath;\n};\n\n/**\n * @see CountCollectionAssetsStoreParams\n */\nexport const CountCollectionAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountCollectionAssetsStoreParams = CollectionParams;\n\n/**\n * @see CountAssetsStoreParams\n */\nexport const CountAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountAssetsStoreParams = ListStoreParams;\n\n/**\n * @see SetAssetHandlerParams\n */\nexport const SetAssetHandlerParamsSchema = z\n .object({\n key: AssetKeySchema,\n content: BlobSchema,\n headers: HeaderFieldsSchema\n })\n .strict();\n\n/**\n * The parameters required to set (or update) an asset.\n */\nexport interface SetAssetHandlerParams {\n /**\n * The key identifying the asset.\n */\n key: AssetKey;\n\n /**\n * The binary content of the asset.\n */\n content: Blob;\n\n /**\n * Associated HTTP headers.\n */\n headers: HeaderFields;\n}\n\n/**\n * @see DeleteAssetsStoreParams\n */\nexport const DeleteAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the assets from a collection of the storage.\n */\nexport type DeleteAssetsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredAssetsParams\n */\nexport const DeleteFilteredAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete assets from the storage.\n */\nexport type DeleteFilteredAssetsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteAssetStoreParams\n */\nexport const DeleteAssetStoreParamsSchema = GetAssetStoreParamsSchema;\n\n/**\n * Represents the parameters required to delete an asset.\n */\nexport type DeleteAssetStoreParams = GetAssetStoreParams;\n\n/**\n * @see ListAssetsStoreParams\n */\nexport const ListAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListAssetsStoreParams = ListStoreParams;\n\n/**\n * @see GetContentChunksStoreParams\n */\nexport const GetContentChunksStoreParamsSchema = z\n .object({\n encoding: AssetEncodingSchema,\n chunk_index: z.bigint(),\n memory: MemorySchema\n })\n .strict();\n\n/**\n * The parameters required to retrieve a specific chunk from an asset.\n */\nexport interface GetContentChunksStoreParams {\n /**\n * The encoding of the chunks.\n */\n encoding: AssetEncoding;\n\n /**\n * The index of the chunk to retrieve.\n */\n chunk_index: bigint;\n\n /**\n * The memory type to retrieve the chunk from.\n */\n memory: Memory;\n}\n", "import {jsonReplacer, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../schemas/db';\n\n/**\n * Decodes the raw data of a document into a JavaScript object.\n *\n * @template T The expected type of the decoded object.\n * @param {RawData} data - The raw data to be decoded.\n * @returns {T} The parsed JavaScript object.\n */\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\n/**\n * Encodes a JavaScript object into a raw data format to be applied to a document.\n *\n * @template T The type of the object to be encoded.\n * @param {T} data - The data to be encoded.\n * @returns {RawData} The serialized raw data.\n */\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\n", "import type {ListResults} from '../schemas/list';\nimport type {AssetNoContent, Blob, OptionAsset} from '../schemas/storage';\nimport {\n type CountAssetsStoreParams,\n CountAssetsStoreParamsSchema,\n type CountCollectionAssetsStoreParams,\n CountCollectionAssetsStoreParamsSchema,\n type DeleteAssetsStoreParams,\n DeleteAssetsStoreParamsSchema,\n type DeleteAssetStoreParams,\n DeleteAssetStoreParamsSchema,\n type DeleteFilteredAssetsStoreParams,\n DeleteFilteredAssetsStoreParamsSchema,\n type GetAssetStoreParams,\n GetAssetStoreParamsSchema,\n type GetContentChunksStoreParams,\n GetContentChunksStoreParamsSchema,\n type ListAssetsStoreParams,\n ListAssetsStoreParamsSchema,\n type SetAssetHandlerParams,\n SetAssetHandlerParamsSchema\n} from './schemas/storage';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Counts the number of assets in a specific collection.\n *\n * @param {CountCollectionAssetsStoreParams} params - The parameters required to count assets in the collection.\n *\n * @returns {bigint} The total number of assets in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionAssetsStore = (params: CountCollectionAssetsStoreParams): bigint => {\n CountCollectionAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_storage_count_collection_assets_store(collection);\n};\n\n/**\n * Counts the number of assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountAssetsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of assets that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countAssetsStore = (params: CountAssetsStoreParams): bigint => {\n CountAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_count_assets_store(caller, collection, listParams);\n};\n\n/**\n * Sets or updates an asset in the storage.\n *\n * @param {SetAssetHandlerParams} params - The parameters required to set or update an asset.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the operation.\n */\nexport const setAssetHandler = (params: SetAssetHandlerParams): void => {\n SetAssetHandlerParamsSchema.parse(params);\n\n const {key, content, headers} = params;\n\n __juno_satellite_storage_set_asset_handler(key, content, headers);\n};\n\n/**\n * Deletes an asset from the storage.\n *\n * @param {DeleteAssetStoreParams} params - The parameters required to delete the asset.\n *\n * @returns {OptionAsset} The potentially deleted asset.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the asset cannot be deleted.\n */\nexport const deleteAssetStore = (params: DeleteAssetStoreParams): OptionAsset => {\n DeleteAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_asset_store(caller, collection, full_path);\n};\n\n/**\n * Delete assets in a specific collection of the Storage.\n *\n * @param {DeleteAssetsStoreParams} params - The parameters required to delete assets in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteAssetsStore = (params: DeleteAssetsStoreParams): void => {\n DeleteAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_storage_delete_assets_store(collection);\n};\n\n/**\n * Delete assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredAssetsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {OptionAsset[]} The potential asset resulting of the deletion that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredAssetsStore = (\n params: DeleteFilteredAssetsStoreParams\n): OptionAsset[] => {\n DeleteFilteredAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_filtered_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieve an asset from the storage.\n *\n * @param {GetAssetStoreParams} params - The parameters required to get the asset.\n *\n * @returns {OptionAsset} The asset if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getAssetStore = (params: GetAssetStoreParams): OptionAsset => {\n GetAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_get_asset_store(caller, collection, full_path);\n};\n\n/**\n * Lists assets (without content) from the storage using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<AssetNoContent>} A list result containing matching assets and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listAssetsStore = (params: ListAssetsStoreParams): ListResults<AssetNoContent> => {\n ListAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_list_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieves content chunks of an asset.\n *\n * This function fetches a content chunk of a given asset encoding using the specified parameters.\n *\n * @param {GetContentChunksStoreParams} params - The parameters including encoding, chunk index, and memory type.\n *\n * @returns {Blob | undefined} The content chunk if found, or `undefined` if not.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite throws an internal error during retrieval.\n */\nexport const getContentChunksStore = (params: GetContentChunksStoreParams): Blob | undefined => {\n GetContentChunksStoreParamsSchema.parse(params);\n\n const {encoding, chunk_index, memory} = params;\n\n return __juno_satellite_storage_get_content_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I,CAAU,EAAIN,EAE3DO,EAASC,EAAgBH,CAAc,EAE7C,OAAO,2CAA2CE,EAAQL,EAAYI,CAAU,CAClF,EAcamB,GAAyBzB,GAA0D,CAC9F0B,EAAkC,MAAM1B,CAAM,EAE9C,GAAM,CAAC,SAAA2B,EAAU,YAAAC,EAAa,OAAAC,CAAM,EAAI7B,EAExC,OAAO,kDAAkD2B,EAAUC,EAAaC,CAAM,CACxF",
6
+ "names": ["z", "ControllerScopeSchema", "MetadataSchema", "ControllerSchema", "TimestampSchema", "ControllerRecordSchema", "RawPrincipalSchema", "ControllersSchema", "ControllerCheckParamsSchema", "RawUserIdSchema", "UserIdSchema", "Principal", "normalizeCaller", "caller", "getAdminControllers", "getControllers", "isAdminController", "params", "ControllerCheckParamsSchema", "providedCaller", "controllers", "caller", "normalizeCaller", "isController", "z", "CollectionParamsSchema", "CollectionSchema", "ListStoreParamsSchema", "RawUserIdSchema", "UserIdSchema", "ListParamsSchema", "GetDocStoreParamsSchema", "CollectionParamsSchema", "RawUserIdSchema", "UserIdSchema", "KeySchema", "SetDocStoreParamsSchema", "SetDocSchema", "DeleteDocStoreParamsSchema", "DelDocSchema", "CountCollectionDocsStoreParamsSchema", "CountDocsStoreParamsSchema", "ListStoreParamsSchema", "ListDocsStoreParamsSchema", "DeleteDocsStoreParamsSchema", "DeleteFilteredDocsStoreParamsSchema", "setDocStore", "params", "SetDocStoreParamsSchema", "providedCaller", "collection", "key", "doc", "caller", "normalizeCaller", "deleteDocStore", "DeleteDocStoreParamsSchema", "getDocStore", "GetDocStoreParamsSchema", "listDocsStore", "ListDocsStoreParamsSchema", "listParams", "countCollectionDocsStore", "CountCollectionDocsStoreParamsSchema", "countDocsStore", "CountDocsStoreParamsSchema", "deleteDocsStore", "DeleteDocsStoreParamsSchema", "deleteFilteredDocsStore", "DeleteFilteredDocsStoreParamsSchema", "z", "MemorySchema", "z", "GetAssetStoreParamsSchema", "CollectionParamsSchema", "RawUserIdSchema", "UserIdSchema", "FullPathSchema", "CountCollectionAssetsStoreParamsSchema", "CountAssetsStoreParamsSchema", "ListStoreParamsSchema", "SetAssetHandlerParamsSchema", "AssetKeySchema", "BlobSchema", "HeaderFieldsSchema", "DeleteAssetsStoreParamsSchema", "DeleteFilteredAssetsStoreParamsSchema", "DeleteAssetStoreParamsSchema", "ListAssetsStoreParamsSchema", "GetContentChunksStoreParamsSchema", "AssetEncodingSchema", "MemorySchema", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData", "countCollectionAssetsStore", "params", "CountCollectionAssetsStoreParamsSchema", "collection", "countAssetsStore", "CountAssetsStoreParamsSchema", "providedCaller", "listParams", "caller", "normalizeCaller", "setAssetHandler", "SetAssetHandlerParamsSchema", "key", "content", "headers", "deleteAssetStore", "DeleteAssetStoreParamsSchema", "full_path", "deleteAssetsStore", "DeleteAssetsStoreParamsSchema", "deleteFilteredAssetsStore", "DeleteFilteredAssetsStoreParamsSchema", "getAssetStore", "GetAssetStoreParamsSchema", "listAssetsStore", "ListAssetsStoreParamsSchema", "getContentChunksStore", "GetContentChunksStoreParamsSchema", "encoding", "chunk_index", "memory"]
7
7
  }
package/src/global.d.ts CHANGED
@@ -4,7 +4,6 @@ import type {DelDoc, Doc, OptionDoc, RawData, SetDoc} from './schemas/db';
4
4
  import type {ListParams, ListResults} from './schemas/list';
5
5
  import type {Collection, Key, RawPrincipal, RawUserId} from './schemas/satellite';
6
6
  import type {
7
- AssetAccessToken,
8
7
  AssetEncoding,
9
8
  AssetKey,
10
9
  AssetNoContent,
@@ -102,12 +101,6 @@ declare global {
102
101
  chunk_index: bigint,
103
102
  memory: Memory
104
103
  ): Blob | undefined;
105
- function __juno_satellite_storage_set_asset_token_store(
106
- caller: RawUserId,
107
- collection: Collection,
108
- full_path: FullPath,
109
- token: AssetAccessToken
110
- ): void;
111
104
 
112
105
  function __ic_cdk_id(): RawPrincipal;
113
106
  function __ic_cdk_time(): bigint;
package/chunk-KVADXJMF.js DELETED
@@ -1,2 +0,0 @@
1
- import{a as s,b as h,c as l}from"./chunk-7B6WU32N.js";import*as i from"zod";var o=i.bigint(),r=i.bigint(),a=h,O=l,y=i.string(),c=i.string(),n=i.string().max(1024);import*as p from"zod";var g=s,_=p.object({owner:a,data:g,description:n.optional(),created_at:o,updated_at:o,version:r.optional()}).strict(),H=_.optional(),V=p.object({data:g,description:n.optional(),version:r.optional()}).strict(),P=p.object({version:r.optional()}).strict();import*as e from"zod";var u=e.tuple([e.string(),e.string()]),x=e.array(u),T=s,A=T,D=e.instanceof(Uint8Array).refine(m=>m.length===32,{message:"Hash must be a Uint8Array of length 32"}),z=e.object({name:e.string(),full_path:e.string(),token:e.string().optional(),collection:y,owner:a,description:n.optional()}).strict(),S=e.object({modified:o,content_chunks:e.array(A),total_length:e.bigint(),sha256:D}),w=S.omit({content_chunks:!0}).strict(),d=e.enum(["identity","gzip","compress","deflate","br"]),f=e.object({key:z,headers:x,encodings:e.array(e.tuple([d,S])),created_at:o,updated_at:o,version:r.optional()}).strict(),q=f.omit({encodings:!0}).extend({encodings:e.array(e.tuple([d,w]))}).strict(),I=e.bigint(),Z=e.object({key:z,reference_id:I.optional(),expires_at:o,encoding_type:d.optional()}).strict(),U=e.bigint(),R=e.bigint(),G=e.object({batch_id:R,headers:x,chunk_ids:e.array(U)}).strict(),J=e.string(),Q=e.string().optional(),W=f.optional();import*as t from"zod";var b=t.union([t.object({equal:o}),t.object({greater_than:o}),t.object({less_than:o}),t.object({between:t.tuple([o,o])})]),k=t.object({key:c.optional(),description:n.optional(),created_at:b.optional(),updated_at:b.optional()}).strict(),j=t.object({start_after:c.optional(),limit:t.bigint().optional()}).strict(),C=t.enum(["keys","created_at","updated_at"]),L=t.object({desc:t.boolean(),field:C}).strict(),$=t.object({matcher:k.optional(),paginate:j.optional(),order:L.optional(),owner:a.optional()}).strict(),ee=m=>t.object({items:t.array(t.tuple([c,m])),items_length:t.bigint(),items_page:t.bigint().optional(),matches_length:t.bigint(),matches_pages:t.bigint().optional()}).strict();export{o as a,r as b,a as c,O as d,y as e,c as f,n as g,g as h,_ as i,H as j,V as k,P as l,x as m,T as n,z as o,S as p,f as q,q as r,Z as s,G as t,J as u,Q as v,W as w,b as x,k as y,j as z,C as A,L as B,$ as C,ee as D};
2
- //# sourceMappingURL=chunk-KVADXJMF.js.map