@junobuild/functions 0.3.2 → 0.3.3
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 +33 -13
- package/chunk-CCKUQNB5.js +2 -0
- package/chunk-CCKUQNB5.js.map +7 -0
- package/chunk-SFZECPH3.js +2 -0
- package/chunk-SFZECPH3.js.map +7 -0
- package/hooks/assertions.d.ts +2 -2
- package/hooks/hooks.d.ts +2 -2
- package/hooks/schemas/collections.d.ts +1 -1
- package/hooks/schemas/context.d.ts +1 -1
- package/hooks/schemas/db/context.d.ts +1 -1
- package/hooks/schemas/db/payload.d.ts +1 -1
- package/hooks/schemas/satellite.env.d.ts +1 -1
- package/hooks/schemas/storage/context.d.ts +1 -1
- package/hooks/schemas/storage/payload.d.ts +1 -1
- package/ic-cdk/schemas/call.d.ts +1 -1
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +2 -2
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/package.json +2 -2
- package/schemas/candid.d.ts +1 -1
- package/schemas/db.d.ts +1 -1
- package/schemas/list.d.ts +1 -1
- package/schemas/satellite.d.ts +1 -1
- package/schemas/storage.d.ts +2 -2
- package/sdk/schemas/collections.d.ts +1 -1
- package/sdk/schemas/controllers.d.ts +1 -1
- package/sdk/schemas/db.d.ts +112 -112
- package/sdk/schemas/params.d.ts +1 -1
- package/sdk/schemas/storage.d.ts +1 -1
- package/sdk.js +1 -1
- package/sdk.js.map +2 -2
- package/utils/zod.utils.d.ts +23 -2
- package/chunk-KY6LCVKU.js +0 -2
- package/chunk-KY6LCVKU.js.map +0 -7
- package/chunk-R6MTJSTE.js +0 -2
- package/chunk-R6MTJSTE.js.map +0 -7
package/sdk/schemas/db.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { type CollectionParams, type ListStoreParams } from './params';
|
|
|
4
4
|
/**
|
|
5
5
|
* @see GetDocStoreParams
|
|
6
6
|
*/
|
|
7
|
-
export declare const GetDocStoreParamsSchema: import("zod
|
|
8
|
-
collection: import("zod
|
|
9
|
-
caller: import("zod
|
|
10
|
-
key: import("zod
|
|
7
|
+
export declare const GetDocStoreParamsSchema: import("zod").ZodObject<{
|
|
8
|
+
collection: import("zod").ZodString;
|
|
9
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
|
|
10
|
+
key: import("zod").ZodString;
|
|
11
11
|
}, import("zod/v4/core").$strict>;
|
|
12
12
|
/**
|
|
13
13
|
* Represents the base parameters required to access the datastore and modify a document.
|
|
@@ -25,14 +25,14 @@ export type GetDocStoreParams = CollectionParams & {
|
|
|
25
25
|
/**
|
|
26
26
|
* @see SetDocStoreParams
|
|
27
27
|
*/
|
|
28
|
-
export declare const SetDocStoreParamsSchema: import("zod
|
|
29
|
-
collection: import("zod
|
|
30
|
-
caller: import("zod
|
|
31
|
-
key: import("zod
|
|
32
|
-
doc: import("zod
|
|
33
|
-
data: import("zod
|
|
34
|
-
description: import("zod
|
|
35
|
-
version: import("zod
|
|
28
|
+
export declare const SetDocStoreParamsSchema: import("zod").ZodObject<{
|
|
29
|
+
collection: import("zod").ZodString;
|
|
30
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
|
|
31
|
+
key: import("zod").ZodString;
|
|
32
|
+
doc: import("zod").ZodObject<{
|
|
33
|
+
data: import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
|
|
34
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
|
+
version: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
36
36
|
}, import("zod/v4/core").$strict>;
|
|
37
37
|
}, import("zod/v4/core").$strict>;
|
|
38
38
|
/**
|
|
@@ -50,12 +50,12 @@ export type SetDocStoreParams = GetDocStoreParams & {
|
|
|
50
50
|
/**
|
|
51
51
|
* @see DeleteDocStoreParams
|
|
52
52
|
*/
|
|
53
|
-
export declare const DeleteDocStoreParamsSchema: import("zod
|
|
54
|
-
collection: import("zod
|
|
55
|
-
caller: import("zod
|
|
56
|
-
key: import("zod
|
|
57
|
-
doc: import("zod
|
|
58
|
-
version: import("zod
|
|
53
|
+
export declare const DeleteDocStoreParamsSchema: import("zod").ZodObject<{
|
|
54
|
+
collection: import("zod").ZodString;
|
|
55
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
|
|
56
|
+
key: import("zod").ZodString;
|
|
57
|
+
doc: import("zod").ZodObject<{
|
|
58
|
+
version: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
59
59
|
}, import("zod/v4/core").$strict>;
|
|
60
60
|
}, import("zod/v4/core").$strict>;
|
|
61
61
|
/**
|
|
@@ -73,8 +73,8 @@ export type DeleteDocStoreParams = GetDocStoreParams & {
|
|
|
73
73
|
/**
|
|
74
74
|
* @see CountCollectionDocsStoreParams
|
|
75
75
|
*/
|
|
76
|
-
export declare const CountCollectionDocsStoreParamsSchema: import("zod
|
|
77
|
-
collection: import("zod
|
|
76
|
+
export declare const CountCollectionDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
77
|
+
collection: import("zod").ZodString;
|
|
78
78
|
}, import("zod/v4/core").$strict>;
|
|
79
79
|
/**
|
|
80
80
|
* The parameters required to count documents from the datastore.
|
|
@@ -83,45 +83,45 @@ export type CountCollectionDocsStoreParams = CollectionParams;
|
|
|
83
83
|
/**
|
|
84
84
|
* @see CountDocsStoreParams
|
|
85
85
|
*/
|
|
86
|
-
export declare const CountDocsStoreParamsSchema: import("zod
|
|
87
|
-
collection: import("zod
|
|
88
|
-
caller: import("zod
|
|
89
|
-
params: import("zod
|
|
90
|
-
matcher: import("zod
|
|
91
|
-
key: import("zod
|
|
92
|
-
description: import("zod
|
|
93
|
-
created_at: import("zod
|
|
94
|
-
equal: import("zod
|
|
95
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
96
|
-
greater_than: import("zod
|
|
97
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
98
|
-
less_than: import("zod
|
|
99
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
100
|
-
between: import("zod
|
|
86
|
+
export declare const CountDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
87
|
+
collection: import("zod").ZodString;
|
|
88
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
|
|
89
|
+
params: import("zod").ZodObject<{
|
|
90
|
+
matcher: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
91
|
+
key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
92
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
93
|
+
created_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
94
|
+
equal: import("zod").ZodBigInt;
|
|
95
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
96
|
+
greater_than: import("zod").ZodBigInt;
|
|
97
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
98
|
+
less_than: import("zod").ZodBigInt;
|
|
99
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
100
|
+
between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
|
|
101
101
|
}, import("zod/v4/core").$strip>]>>;
|
|
102
|
-
updated_at: import("zod
|
|
103
|
-
equal: import("zod
|
|
104
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
105
|
-
greater_than: import("zod
|
|
106
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
107
|
-
less_than: import("zod
|
|
108
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
109
|
-
between: import("zod
|
|
102
|
+
updated_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
103
|
+
equal: import("zod").ZodBigInt;
|
|
104
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
105
|
+
greater_than: import("zod").ZodBigInt;
|
|
106
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
107
|
+
less_than: import("zod").ZodBigInt;
|
|
108
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
109
|
+
between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
|
|
110
110
|
}, import("zod/v4/core").$strip>]>>;
|
|
111
111
|
}, import("zod/v4/core").$strict>>;
|
|
112
|
-
paginate: import("zod
|
|
113
|
-
start_after: import("zod
|
|
114
|
-
limit: import("zod
|
|
112
|
+
paginate: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
113
|
+
start_after: import("zod").ZodOptional<import("zod").ZodString>;
|
|
114
|
+
limit: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
115
115
|
}, import("zod/v4/core").$strict>>;
|
|
116
|
-
order: import("zod
|
|
117
|
-
desc: import("zod
|
|
118
|
-
field: import("zod
|
|
116
|
+
order: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
117
|
+
desc: import("zod").ZodBoolean;
|
|
118
|
+
field: import("zod").ZodEnum<{
|
|
119
119
|
created_at: "created_at";
|
|
120
120
|
updated_at: "updated_at";
|
|
121
121
|
keys: "keys";
|
|
122
122
|
}>;
|
|
123
123
|
}, import("zod/v4/core").$strict>>;
|
|
124
|
-
owner: import("zod
|
|
124
|
+
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
|
|
125
125
|
}, import("zod/v4/core").$strict>;
|
|
126
126
|
}, import("zod/v4/core").$strict>;
|
|
127
127
|
/**
|
|
@@ -131,45 +131,45 @@ export type CountDocsStoreParams = ListStoreParams;
|
|
|
131
131
|
/**
|
|
132
132
|
* @see ListDocsStoreParams
|
|
133
133
|
*/
|
|
134
|
-
export declare const ListDocsStoreParamsSchema: import("zod
|
|
135
|
-
collection: import("zod
|
|
136
|
-
caller: import("zod
|
|
137
|
-
params: import("zod
|
|
138
|
-
matcher: import("zod
|
|
139
|
-
key: import("zod
|
|
140
|
-
description: import("zod
|
|
141
|
-
created_at: import("zod
|
|
142
|
-
equal: import("zod
|
|
143
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
144
|
-
greater_than: import("zod
|
|
145
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
146
|
-
less_than: import("zod
|
|
147
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
148
|
-
between: import("zod
|
|
134
|
+
export declare const ListDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
135
|
+
collection: import("zod").ZodString;
|
|
136
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
|
|
137
|
+
params: import("zod").ZodObject<{
|
|
138
|
+
matcher: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
139
|
+
key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
140
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
141
|
+
created_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
142
|
+
equal: import("zod").ZodBigInt;
|
|
143
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
144
|
+
greater_than: import("zod").ZodBigInt;
|
|
145
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
146
|
+
less_than: import("zod").ZodBigInt;
|
|
147
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
148
|
+
between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
|
|
149
149
|
}, import("zod/v4/core").$strip>]>>;
|
|
150
|
-
updated_at: import("zod
|
|
151
|
-
equal: import("zod
|
|
152
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
153
|
-
greater_than: import("zod
|
|
154
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
155
|
-
less_than: import("zod
|
|
156
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
157
|
-
between: import("zod
|
|
150
|
+
updated_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
151
|
+
equal: import("zod").ZodBigInt;
|
|
152
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
153
|
+
greater_than: import("zod").ZodBigInt;
|
|
154
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
155
|
+
less_than: import("zod").ZodBigInt;
|
|
156
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
157
|
+
between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
|
|
158
158
|
}, import("zod/v4/core").$strip>]>>;
|
|
159
159
|
}, import("zod/v4/core").$strict>>;
|
|
160
|
-
paginate: import("zod
|
|
161
|
-
start_after: import("zod
|
|
162
|
-
limit: import("zod
|
|
160
|
+
paginate: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
161
|
+
start_after: import("zod").ZodOptional<import("zod").ZodString>;
|
|
162
|
+
limit: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
163
163
|
}, import("zod/v4/core").$strict>>;
|
|
164
|
-
order: import("zod
|
|
165
|
-
desc: import("zod
|
|
166
|
-
field: import("zod
|
|
164
|
+
order: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
165
|
+
desc: import("zod").ZodBoolean;
|
|
166
|
+
field: import("zod").ZodEnum<{
|
|
167
167
|
created_at: "created_at";
|
|
168
168
|
updated_at: "updated_at";
|
|
169
169
|
keys: "keys";
|
|
170
170
|
}>;
|
|
171
171
|
}, import("zod/v4/core").$strict>>;
|
|
172
|
-
owner: import("zod
|
|
172
|
+
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
|
|
173
173
|
}, import("zod/v4/core").$strict>;
|
|
174
174
|
}, import("zod/v4/core").$strict>;
|
|
175
175
|
/**
|
|
@@ -179,8 +179,8 @@ export type ListDocsStoreParams = ListStoreParams;
|
|
|
179
179
|
/**
|
|
180
180
|
* @see DeleteDocsStoreParams
|
|
181
181
|
*/
|
|
182
|
-
export declare const DeleteDocsStoreParamsSchema: import("zod
|
|
183
|
-
collection: import("zod
|
|
182
|
+
export declare const DeleteDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
183
|
+
collection: import("zod").ZodString;
|
|
184
184
|
}, import("zod/v4/core").$strict>;
|
|
185
185
|
/**
|
|
186
186
|
* The parameters required to delete the documents from a collection of the datastore.
|
|
@@ -189,45 +189,45 @@ export type DeleteDocsStoreParams = CollectionParams;
|
|
|
189
189
|
/**
|
|
190
190
|
* @see DeleteFilteredDocsParams
|
|
191
191
|
*/
|
|
192
|
-
export declare const DeleteFilteredDocsStoreParamsSchema: import("zod
|
|
193
|
-
collection: import("zod
|
|
194
|
-
caller: import("zod
|
|
195
|
-
params: import("zod
|
|
196
|
-
matcher: import("zod
|
|
197
|
-
key: import("zod
|
|
198
|
-
description: import("zod
|
|
199
|
-
created_at: import("zod
|
|
200
|
-
equal: import("zod
|
|
201
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
202
|
-
greater_than: import("zod
|
|
203
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
204
|
-
less_than: import("zod
|
|
205
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
206
|
-
between: import("zod
|
|
192
|
+
export declare const DeleteFilteredDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
193
|
+
collection: import("zod").ZodString;
|
|
194
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
|
|
195
|
+
params: import("zod").ZodObject<{
|
|
196
|
+
matcher: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
197
|
+
key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
198
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
199
|
+
created_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
200
|
+
equal: import("zod").ZodBigInt;
|
|
201
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
202
|
+
greater_than: import("zod").ZodBigInt;
|
|
203
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
204
|
+
less_than: import("zod").ZodBigInt;
|
|
205
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
206
|
+
between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
|
|
207
207
|
}, import("zod/v4/core").$strip>]>>;
|
|
208
|
-
updated_at: import("zod
|
|
209
|
-
equal: import("zod
|
|
210
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
211
|
-
greater_than: import("zod
|
|
212
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
213
|
-
less_than: import("zod
|
|
214
|
-
}, import("zod/v4/core").$strip>, import("zod
|
|
215
|
-
between: import("zod
|
|
208
|
+
updated_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
209
|
+
equal: import("zod").ZodBigInt;
|
|
210
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
211
|
+
greater_than: import("zod").ZodBigInt;
|
|
212
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
213
|
+
less_than: import("zod").ZodBigInt;
|
|
214
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
215
|
+
between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
|
|
216
216
|
}, import("zod/v4/core").$strip>]>>;
|
|
217
217
|
}, import("zod/v4/core").$strict>>;
|
|
218
|
-
paginate: import("zod
|
|
219
|
-
start_after: import("zod
|
|
220
|
-
limit: import("zod
|
|
218
|
+
paginate: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
219
|
+
start_after: import("zod").ZodOptional<import("zod").ZodString>;
|
|
220
|
+
limit: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
221
221
|
}, import("zod/v4/core").$strict>>;
|
|
222
|
-
order: import("zod
|
|
223
|
-
desc: import("zod
|
|
224
|
-
field: import("zod
|
|
222
|
+
order: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
223
|
+
desc: import("zod").ZodBoolean;
|
|
224
|
+
field: import("zod").ZodEnum<{
|
|
225
225
|
created_at: "created_at";
|
|
226
226
|
updated_at: "updated_at";
|
|
227
227
|
keys: "keys";
|
|
228
228
|
}>;
|
|
229
229
|
}, import("zod/v4/core").$strict>>;
|
|
230
|
-
owner: import("zod
|
|
230
|
+
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
|
|
231
231
|
}, import("zod/v4/core").$strict>;
|
|
232
232
|
}, import("zod/v4/core").$strict>;
|
|
233
233
|
/**
|
package/sdk/schemas/params.d.ts
CHANGED
package/sdk/schemas/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as z from 'zod
|
|
1
|
+
import * as z from 'zod';
|
|
2
2
|
import { type RawUserId, type UserId } from '../../schemas/satellite';
|
|
3
3
|
import { type AssetEncoding, type AssetKey, type Blob, type FullPath, type HeaderFields } from '../../schemas/storage';
|
|
4
4
|
import { type Memory } from './collections';
|
package/sdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-SFZECPH3.js";import{b as h}from"./chunk-CCKUQNB5.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"@dfinity/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/v4';\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 '@dfinity/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/v4';\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/v4';\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/v4';\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_chunks_store(encoding, chunk_index, memory);\n};\n"],
|
|
5
|
-
"mappings": "oKAAA,UAAYA,MAAO,
|
|
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 '@dfinity/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_chunks_store(encoding, chunk_index, memory);\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
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/utils/zod.utils.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
import * as z from 'zod
|
|
2
|
-
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Zod function schema so that parsing returns the **original function**
|
|
4
|
+
* instead of Zod's wrapped validator.
|
|
5
|
+
*
|
|
6
|
+
* Why?
|
|
7
|
+
* ----
|
|
8
|
+
* In Zod v4, `z.function({...})` normally returns a wrapper that validates
|
|
9
|
+
* both arguments and the return value **every time the function is called**.
|
|
10
|
+
* If your function's return type is `void | Promise<void>`, Zod tries to
|
|
11
|
+
* validate it synchronously, which can throw
|
|
12
|
+
* "Encountered Promise during synchronous parse"
|
|
13
|
+
* when the implementation is async.
|
|
14
|
+
*
|
|
15
|
+
* By using `.implement`, we tell Zod: “this is the function that satisfies
|
|
16
|
+
* the schema.” That way the schema still validates the function shape at
|
|
17
|
+
* parse time, but the returned value is the **original function** you passed
|
|
18
|
+
* in — no runtime wrapper, no sync/async mismatch.
|
|
19
|
+
*
|
|
20
|
+
* Reference:
|
|
21
|
+
* https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912*
|
|
22
|
+
*/
|
|
23
|
+
export declare const createFunctionSchema: <T extends z.ZodFunction>(schema: T) => z.ZodCustom<Parameters<T["implement"]>[0], Parameters<T["implement"]>[0]>;
|
package/chunk-KY6LCVKU.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Principal as r}from"@dfinity/principal";import*as i from"zod/v4";var n=i.custom(a=>a instanceof Uint8Array,{message:"Expected Uint8Array"}),c=n,t=i.custom(a=>a instanceof r,{message:"Expected an instance of a Principal"});export{n as a,c as b,t as c};
|
|
2
|
-
//# sourceMappingURL=chunk-KY6LCVKU.js.map
|
package/chunk-KY6LCVKU.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/schemas/candid.ts"],
|
|
4
|
-
"sourcesContent": ["import {Principal as CandidPrincipal} from '@dfinity/principal';\nimport * as z from 'zod/v4';\n\n/**\n * A schema that validates a value is an Uint8Array.\n */\nexport const Uint8ArraySchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\n\n/**\n * @see RawPrincipal\n */\nexport const RawPrincipalSchema = Uint8ArraySchema;\n\n/**\n * Represents a raw principal - a Uint8Array representation of a Principal.\n */\nexport type RawPrincipal = z.infer<typeof RawPrincipalSchema>;\n\n/**\n * @see Principal\n */\nexport const PrincipalSchema = z.custom<CandidPrincipal>((val) => val instanceof CandidPrincipal, {\n message: 'Expected an instance of a Principal'\n});\n\n/**\n * Represents a principal - i.e. an object instantiated with the class Principal.\n */\nexport type Principal = z.infer<typeof PrincipalSchema>;\n"],
|
|
5
|
-
"mappings": "AAAA,OAAQ,aAAaA,MAAsB,qBAC3C,UAAYC,MAAO,SAKZ,IAAMC,EAAqB,SAAoBC,GAAQA,aAAe,WAAY,CACvF,QAAS,qBACX,CAAC,EAKYC,EAAqBF,EAUrBG,EAAoB,SAAyBF,GAAQA,aAAeH,EAAiB,CAChG,QAAS,qCACX,CAAC",
|
|
6
|
-
"names": ["CandidPrincipal", "z", "Uint8ArraySchema", "val", "RawPrincipalSchema", "PrincipalSchema"]
|
|
7
|
-
}
|
package/chunk-R6MTJSTE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as s,b as h,c as l}from"./chunk-KY6LCVKU.js";import*as i from"zod/v4";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/v4";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/v4";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/v4";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-R6MTJSTE.js.map
|