@junobuild/functions 0.0.12 → 0.0.13

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/schemas/db.d.ts CHANGED
@@ -1,13 +1,6 @@
1
1
  import * as z from 'zod';
2
2
  import { Uint8ArraySchema } from './candid';
3
- /**
4
- * @see DocDescription
5
- */
6
- export declare const DocDescriptionSchema: z.ZodString;
7
- /**
8
- * Represents a document description with a maximum length of 1024 characters.
9
- */
10
- export type DocDescription = z.infer<typeof DocDescriptionSchema>;
3
+ import { Description, type RawUserId, type Timestamp, type Version } from './satellite';
11
4
  /**
12
5
  * @see RawData
13
6
  */
@@ -22,30 +15,66 @@ export type RawData = z.infer<typeof Uint8ArraySchema>;
22
15
  * @see Doc
23
16
  */
24
17
  export declare const DocSchema: z.ZodObject<{
18
+ owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
19
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
20
+ description: z.ZodOptional<z.ZodString>;
21
+ created_at: z.ZodBigInt;
22
+ updated_at: z.ZodBigInt;
23
+ version: z.ZodOptional<z.ZodBigInt>;
24
+ }, "strict", z.ZodTypeAny, {
25
+ owner: Uint8Array<ArrayBufferLike>;
26
+ data: Uint8Array<ArrayBufferLike>;
27
+ created_at: bigint;
28
+ updated_at: bigint;
29
+ description?: string | undefined;
30
+ version?: bigint | undefined;
31
+ }, {
32
+ owner: Uint8Array<ArrayBufferLike>;
33
+ data: Uint8Array<ArrayBufferLike>;
34
+ created_at: bigint;
35
+ updated_at: bigint;
36
+ description?: string | undefined;
37
+ version?: bigint | undefined;
38
+ }>;
39
+ /**
40
+ * Represents a document stored in a collection.
41
+ */
42
+ export interface Doc {
25
43
  /**
26
44
  * The user who owns this document.
27
45
  */
28
- owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
46
+ owner: RawUserId;
29
47
  /**
30
48
  * The raw data of the document.
31
49
  */
32
- data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
50
+ data: RawData;
33
51
  /**
34
52
  * An optional description of the document.
35
53
  */
36
- description: z.ZodOptional<z.ZodString>;
54
+ description?: Description;
37
55
  /**
38
56
  * The timestamp when the document was first created.
39
57
  */
40
- created_at: z.ZodBigInt;
58
+ created_at: Timestamp;
41
59
  /**
42
60
  * The timestamp when the document was last updated.
43
61
  */
44
- updated_at: z.ZodBigInt;
62
+ updated_at: Timestamp;
45
63
  /**
46
64
  * The version number of the document, used for consistency checks.
47
65
  * If not provided, it's assumed to be the first version.
48
66
  */
67
+ version?: Version;
68
+ }
69
+ /**
70
+ * @see OptionDoc
71
+ */
72
+ export declare const OptionDocSchema: z.ZodOptional<z.ZodObject<{
73
+ owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
74
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
75
+ description: z.ZodOptional<z.ZodString>;
76
+ created_at: z.ZodBigInt;
77
+ updated_at: z.ZodBigInt;
49
78
  version: z.ZodOptional<z.ZodBigInt>;
50
79
  }, "strict", z.ZodTypeAny, {
51
80
  owner: Uint8Array<ArrayBufferLike>;
@@ -61,8 +90,62 @@ export declare const DocSchema: z.ZodObject<{
61
90
  updated_at: bigint;
62
91
  description?: string | undefined;
63
92
  version?: bigint | undefined;
93
+ }>>;
94
+ /**
95
+ * A shorthand for a document that might or not be defined.
96
+ */
97
+ export type OptionDoc = Doc | undefined;
98
+ /**
99
+ * @see SetDoc
100
+ */
101
+ export declare const SetDocSchema: z.ZodObject<{
102
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
103
+ description: z.ZodOptional<z.ZodString>;
104
+ version: z.ZodOptional<z.ZodBigInt>;
105
+ }, "strict", z.ZodTypeAny, {
106
+ data: Uint8Array<ArrayBufferLike>;
107
+ description?: string | undefined;
108
+ version?: bigint | undefined;
109
+ }, {
110
+ data: Uint8Array<ArrayBufferLike>;
111
+ description?: string | undefined;
112
+ version?: bigint | undefined;
64
113
  }>;
65
114
  /**
66
- * Represents a document stored in a collection.
115
+ * Represents the proposed version of a document to be created or updated.
116
+ * This can be validated before allowing the operation.
117
+ */
118
+ export interface SetDoc {
119
+ /**
120
+ * The raw data of the document.
121
+ */
122
+ data: RawData;
123
+ /**
124
+ * An optional description of the document.
125
+ */
126
+ description?: Description;
127
+ /**
128
+ * The expected version number to ensure consistency.
129
+ */
130
+ version?: Version;
131
+ }
132
+ /**
133
+ * @see DelDoc
67
134
  */
68
- export type Doc = z.infer<typeof DocSchema>;
135
+ export declare const DelDocSchema: z.ZodObject<{
136
+ version: z.ZodOptional<z.ZodBigInt>;
137
+ }, "strict", z.ZodTypeAny, {
138
+ version?: bigint | undefined;
139
+ }, {
140
+ version?: bigint | undefined;
141
+ }>;
142
+ /**
143
+ * Represents the proposed version of a document to be deleted.
144
+ * This can be validated before allowing the operation.
145
+ */
146
+ export interface DelDoc {
147
+ /**
148
+ * The expected version number to ensure consistency.
149
+ */
150
+ version?: Version;
151
+ }
@@ -55,3 +55,12 @@ export declare const KeySchema: z.ZodString;
55
55
  * A unique key identifier within a collection.
56
56
  */
57
57
  export type Key = z.infer<typeof KeySchema>;
58
+ /**
59
+ * @see Description
60
+ */
61
+ export declare const DescriptionSchema: z.ZodString;
62
+ /**
63
+ * Represents a description with a maximum length of 1024 characters.
64
+ * Used for document and asset fields which can be useful for search purpose.
65
+ */
66
+ export type Description = z.infer<typeof DescriptionSchema>;
@@ -0,0 +1,307 @@
1
+ import * as z from 'zod';
2
+ import { type Collection, type Description, type RawUserId, type Timestamp, type Version } from './satellite';
3
+ /**
4
+ * Represents a single HTTP header as a tuple of name and value.
5
+ */
6
+ export type HeaderField = [string, string];
7
+ /**
8
+ * Binary content used in asset encoding.
9
+ */
10
+ export type Blob = Uint8Array;
11
+ /**
12
+ * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values
13
+ */
14
+ export type BlobOrKey = Uint8Array;
15
+ /**
16
+ * Represents a SHA-256 hash as a 32-byte binary value.
17
+ */
18
+ export type Hash = Uint8Array;
19
+ /**
20
+ * Metadata identifying an asset within a collection and the storage system.
21
+ */
22
+ export interface AssetKey {
23
+ /**
24
+ * The name of the asset (e.g., "logo.png").
25
+ */
26
+ name: string;
27
+ /**
28
+ * The full relative path of the asset (e.g., "/images/logo.png").
29
+ */
30
+ full_path: string;
31
+ /**
32
+ * Optional access token for the asset.
33
+ * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333
34
+ */
35
+ token?: string;
36
+ /**
37
+ * The collection to which this asset belongs.
38
+ */
39
+ collection: Collection;
40
+ /**
41
+ * The owner of the asset.
42
+ */
43
+ owner: RawUserId;
44
+ /**
45
+ * Optional description of the asset for indexing/search.
46
+ */
47
+ description?: Description;
48
+ }
49
+ /**
50
+ * Represents a specific encoding of an asset, such as "gzip" or "identity" (no compression).
51
+ */
52
+ export interface AssetEncoding {
53
+ /**
54
+ * Timestamp when the encoding was last modified.
55
+ */
56
+ modified: Timestamp;
57
+ /**
58
+ * Chunks of binary content or references to them.
59
+ */
60
+ content_chunks: BlobOrKey[];
61
+ /**
62
+ * Total byte size of the encoded content.
63
+ */
64
+ total_length: bigint;
65
+ /**
66
+ * SHA-256 hash of the encoded content.
67
+ */
68
+ sha256: Hash;
69
+ }
70
+ /**
71
+ * @see Asset
72
+ */
73
+ export declare const AssetSchema: z.ZodObject<{
74
+ key: z.ZodObject<{
75
+ name: z.ZodString;
76
+ full_path: z.ZodString;
77
+ token: z.ZodOptional<z.ZodString>;
78
+ collection: z.ZodString;
79
+ owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
80
+ description: z.ZodOptional<z.ZodString>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ owner: Uint8Array<ArrayBufferLike>;
83
+ collection: string;
84
+ name: string;
85
+ full_path: string;
86
+ description?: string | undefined;
87
+ token?: string | undefined;
88
+ }, {
89
+ owner: Uint8Array<ArrayBufferLike>;
90
+ collection: string;
91
+ name: string;
92
+ full_path: string;
93
+ description?: string | undefined;
94
+ token?: string | undefined;
95
+ }>;
96
+ headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">;
97
+ encodings: z.ZodRecord<z.ZodString, z.ZodObject<{
98
+ modified: z.ZodBigInt;
99
+ content_chunks: z.ZodArray<z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>, "many">;
100
+ total_length: z.ZodBigInt;
101
+ sha256: z.ZodEffects<z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
102
+ }, "strip", z.ZodTypeAny, {
103
+ modified: bigint;
104
+ content_chunks: Uint8Array<ArrayBufferLike>[];
105
+ total_length: bigint;
106
+ sha256: Uint8Array<ArrayBuffer>;
107
+ }, {
108
+ modified: bigint;
109
+ content_chunks: Uint8Array<ArrayBufferLike>[];
110
+ total_length: bigint;
111
+ sha256: Uint8Array<ArrayBuffer>;
112
+ }>>;
113
+ created_at: z.ZodBigInt;
114
+ updated_at: z.ZodBigInt;
115
+ version: z.ZodOptional<z.ZodBigInt>;
116
+ }, "strict", z.ZodTypeAny, {
117
+ created_at: bigint;
118
+ updated_at: bigint;
119
+ key: {
120
+ owner: Uint8Array<ArrayBufferLike>;
121
+ collection: string;
122
+ name: string;
123
+ full_path: string;
124
+ description?: string | undefined;
125
+ token?: string | undefined;
126
+ };
127
+ headers: [string, string][];
128
+ encodings: Record<string, {
129
+ modified: bigint;
130
+ content_chunks: Uint8Array<ArrayBufferLike>[];
131
+ total_length: bigint;
132
+ sha256: Uint8Array<ArrayBuffer>;
133
+ }>;
134
+ version?: bigint | undefined;
135
+ }, {
136
+ created_at: bigint;
137
+ updated_at: bigint;
138
+ key: {
139
+ owner: Uint8Array<ArrayBufferLike>;
140
+ collection: string;
141
+ name: string;
142
+ full_path: string;
143
+ description?: string | undefined;
144
+ token?: string | undefined;
145
+ };
146
+ headers: [string, string][];
147
+ encodings: Record<string, {
148
+ modified: bigint;
149
+ content_chunks: Uint8Array<ArrayBufferLike>[];
150
+ total_length: bigint;
151
+ sha256: Uint8Array<ArrayBuffer>;
152
+ }>;
153
+ version?: bigint | undefined;
154
+ }>;
155
+ /**
156
+ * A stored asset including its metadata, encodings, and timestamps.
157
+ */
158
+ export interface Asset {
159
+ /**
160
+ * Metadata about the asset's identity and ownership.
161
+ */
162
+ key: AssetKey;
163
+ /**
164
+ * Optional HTTP headers associated with the asset.
165
+ */
166
+ headers: HeaderField[];
167
+ /**
168
+ * A mapping from encoding types (e.g., "identity", "gzip") to the corresponding encoded version.
169
+ */
170
+ encodings: Record<string, AssetEncoding>;
171
+ /**
172
+ * Timestamp when the asset was created.
173
+ */
174
+ created_at: Timestamp;
175
+ /**
176
+ * Timestamp when the asset was last updated.
177
+ */
178
+ updated_at: Timestamp;
179
+ /**
180
+ * Optional version number of the asset.
181
+ */
182
+ version?: Version;
183
+ }
184
+ /**
185
+ * A string identifier representing a specific encoding format (e.g., "gzip", "identity").
186
+ */
187
+ export type EncodingType = string;
188
+ /**
189
+ * A unique reference identifier for batches.
190
+ */
191
+ export type ReferenceId = bigint;
192
+ /**
193
+ * @see Batch
194
+ */
195
+ export declare const BatchSchema: z.ZodObject<{
196
+ key: z.ZodObject<{
197
+ name: z.ZodString;
198
+ full_path: z.ZodString;
199
+ token: z.ZodOptional<z.ZodString>;
200
+ collection: z.ZodString;
201
+ owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
202
+ description: z.ZodOptional<z.ZodString>;
203
+ }, "strip", z.ZodTypeAny, {
204
+ owner: Uint8Array<ArrayBufferLike>;
205
+ collection: string;
206
+ name: string;
207
+ full_path: string;
208
+ description?: string | undefined;
209
+ token?: string | undefined;
210
+ }, {
211
+ owner: Uint8Array<ArrayBufferLike>;
212
+ collection: string;
213
+ name: string;
214
+ full_path: string;
215
+ description?: string | undefined;
216
+ token?: string | undefined;
217
+ }>;
218
+ reference_id: z.ZodOptional<z.ZodBigInt>;
219
+ expires_at: z.ZodBigInt;
220
+ encoding_type: z.ZodOptional<z.ZodString>;
221
+ }, "strict", z.ZodTypeAny, {
222
+ key: {
223
+ owner: Uint8Array<ArrayBufferLike>;
224
+ collection: string;
225
+ name: string;
226
+ full_path: string;
227
+ description?: string | undefined;
228
+ token?: string | undefined;
229
+ };
230
+ expires_at: bigint;
231
+ reference_id?: bigint | undefined;
232
+ encoding_type?: string | undefined;
233
+ }, {
234
+ key: {
235
+ owner: Uint8Array<ArrayBufferLike>;
236
+ collection: string;
237
+ name: string;
238
+ full_path: string;
239
+ description?: string | undefined;
240
+ token?: string | undefined;
241
+ };
242
+ expires_at: bigint;
243
+ reference_id?: bigint | undefined;
244
+ encoding_type?: string | undefined;
245
+ }>;
246
+ /**
247
+ * Represents a batch of chunks to be uploaded and committed to an asset.
248
+ */
249
+ export interface Batch {
250
+ /**
251
+ * The metadata key for the asset being uploaded.
252
+ */
253
+ key: AssetKey;
254
+ /**
255
+ * Optional reference ID for tracking or validation.
256
+ */
257
+ reference_id?: ReferenceId;
258
+ /**
259
+ * Timestamp when this batch expires.
260
+ */
261
+ expires_at: Timestamp;
262
+ /**
263
+ * Optional encoding format (e.g., "gzip").
264
+ */
265
+ encoding_type?: EncodingType;
266
+ }
267
+ /**
268
+ * A unique identifier representing a single chunk of data.
269
+ */
270
+ export type ChunkId = bigint;
271
+ /**
272
+ * A unique identifier representing a batch of upload.
273
+ */
274
+ export type BatchId = bigint;
275
+ /**
276
+ * @see CommitBatch
277
+ */
278
+ export declare const CommitBatchSchema: z.ZodObject<{
279
+ batch_id: z.ZodBigInt;
280
+ headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">;
281
+ chunk_ids: z.ZodArray<z.ZodBigInt, "many">;
282
+ }, "strict", z.ZodTypeAny, {
283
+ headers: [string, string][];
284
+ batch_id: bigint;
285
+ chunk_ids: bigint[];
286
+ }, {
287
+ headers: [string, string][];
288
+ batch_id: bigint;
289
+ chunk_ids: bigint[];
290
+ }>;
291
+ /**
292
+ * Represents the final step in uploading an asset, committing the batch to storage.
293
+ */
294
+ export interface CommitBatch {
295
+ /**
296
+ * The ID of the batch being committed.
297
+ */
298
+ batch_id: BatchId;
299
+ /**
300
+ * HTTP headers associated with this asset.
301
+ */
302
+ headers: HeaderField[];
303
+ /**
304
+ * List of chunk IDs that make up the asset content.
305
+ */
306
+ chunk_ids: ChunkId[];
307
+ }
package/sdk/db.sdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SetDocStoreParams } from './schemas/db';
1
+ import { DeleteDocStoreParams, SetDocStoreParams } from './schemas/db';
2
2
  /**
3
3
  * Stores or updates a document in the datastore.
4
4
  *
@@ -11,3 +11,13 @@ import { SetDocStoreParams } from './schemas/db';
11
11
  * @throws {Error} If the Satellite fails at validating the submitted document before storing it.
12
12
  */
13
13
  export declare const setDocStore: (params: SetDocStoreParams) => void;
14
+ /**
15
+ * Delete a document in the datastore.
16
+ *
17
+ * @param {DeleteDocStoreParams} params - The parameters required to delete the document,
18
+ * including the caller, collection, key, and version of the document.
19
+ *
20
+ * @throws {z.ZodError} If the provided parameters do not match the expected schema.
21
+ * @throws {Error} If the Satellite fails at validating the submitted request before deleting it.
22
+ */
23
+ export declare const deleteDocStore: (params: DeleteDocStoreParams) => void;
@@ -1,101 +1,59 @@
1
1
  import * as z from 'zod';
2
+ import { type DelDoc, type SetDoc } from '../../schemas/db';
3
+ import { type Collection, type Key, type RawUserId, type UserId } from '../../schemas/satellite';
2
4
  /**
3
- * @see SetDoc
5
+ * Represents the base parameters required to access the datastore and modify a document.
4
6
  */
5
- export declare const SetDocSchema: z.ZodObject<{
7
+ export interface DocStoreParams {
6
8
  /**
7
- * The unique key identifying the document within the collection.
8
- */
9
- key: z.ZodString;
10
- /**
11
- * An optional description of the document.
9
+ * The caller who initiate the document operation.
12
10
  */
13
- description: z.ZodOptional<z.ZodString>;
11
+ caller: RawUserId | UserId;
14
12
  /**
15
- * The raw data of the document.
13
+ * The name of the collection where the document is stored.
16
14
  */
17
- data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
15
+ collection: Collection;
18
16
  /**
19
- * The expected version number to ensure consistency.
20
- * If provided, the operation will fail if the stored version does not match.
17
+ * The unique key identifying the document within the collection.
21
18
  */
22
- version: z.ZodOptional<z.ZodBigInt>;
23
- }, "strict", z.ZodTypeAny, {
24
- data: Uint8Array<ArrayBufferLike>;
25
- key: string;
26
- description?: string | undefined;
27
- version?: bigint | undefined;
28
- }, {
29
- data: Uint8Array<ArrayBufferLike>;
30
- key: string;
31
- description?: string | undefined;
32
- version?: bigint | undefined;
33
- }>;
34
- /**
35
- * Represents a request to set or update a document.
36
- *
37
- * This is used when submitting new document data.
38
- */
39
- export type SetDoc = z.infer<typeof SetDocSchema>;
19
+ key: Key;
20
+ }
40
21
  /**
41
22
  * @see SetDocStoreParams
42
23
  */
43
- export declare const SetDocStoreParamsSchema: z.ZodObject<{
44
- /**
45
- * The caller who initiate the document operation.
46
- */
24
+ export declare const SetDocStoreParamsSchema: z.ZodObject<z.objectUtil.extendShape<{
47
25
  caller: z.ZodUnion<[z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>, z.ZodType<import("@dfinity/principal").Principal, z.ZodTypeDef, import("@dfinity/principal").Principal>]>;
48
- /**
49
- * The name of the collection where the document is stored.
50
- */
51
26
  collection: z.ZodString;
52
- /**
53
- * The data, key and other information required to create or update a document.
54
- */
27
+ key: z.ZodString;
28
+ }, {
55
29
  doc: z.ZodObject<{
56
- /**
57
- * The unique key identifying the document within the collection.
58
- */
59
- key: z.ZodString;
60
- /**
61
- * An optional description of the document.
62
- */
63
- description: z.ZodOptional<z.ZodString>;
64
- /**
65
- * The raw data of the document.
66
- */
67
30
  data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
68
- /**
69
- * The expected version number to ensure consistency.
70
- * If provided, the operation will fail if the stored version does not match.
71
- */
31
+ description: z.ZodOptional<z.ZodString>;
72
32
  version: z.ZodOptional<z.ZodBigInt>;
73
33
  }, "strict", z.ZodTypeAny, {
74
34
  data: Uint8Array<ArrayBufferLike>;
75
- key: string;
76
35
  description?: string | undefined;
77
36
  version?: bigint | undefined;
78
37
  }, {
79
38
  data: Uint8Array<ArrayBufferLike>;
80
- key: string;
81
39
  description?: string | undefined;
82
40
  version?: bigint | undefined;
83
41
  }>;
84
- }, "strict", z.ZodTypeAny, {
42
+ }>, "strict", z.ZodTypeAny, {
85
43
  caller: Uint8Array<ArrayBufferLike> | import("@dfinity/principal").Principal;
86
44
  collection: string;
45
+ key: string;
87
46
  doc: {
88
47
  data: Uint8Array<ArrayBufferLike>;
89
- key: string;
90
48
  description?: string | undefined;
91
49
  version?: bigint | undefined;
92
50
  };
93
51
  }, {
94
52
  caller: Uint8Array<ArrayBufferLike> | import("@dfinity/principal").Principal;
95
53
  collection: string;
54
+ key: string;
96
55
  doc: {
97
56
  data: Uint8Array<ArrayBufferLike>;
98
- key: string;
99
57
  description?: string | undefined;
100
58
  version?: bigint | undefined;
101
59
  };
@@ -106,4 +64,51 @@ export declare const SetDocStoreParamsSchema: z.ZodObject<{
106
64
  * This includes the document data along with metadata such as the caller,
107
65
  * collection, and key.
108
66
  */
109
- export type SetDocStoreParams = z.infer<typeof SetDocStoreParamsSchema>;
67
+ export type SetDocStoreParams = DocStoreParams & {
68
+ /**
69
+ * The data, optional description and version required to create or update a document.
70
+ */
71
+ doc: SetDoc;
72
+ };
73
+ /**
74
+ * @see DeleteDocStoreParams
75
+ */
76
+ export declare const DeleteDocStoreParamsSchema: z.ZodObject<z.objectUtil.extendShape<{
77
+ caller: z.ZodUnion<[z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>, z.ZodType<import("@dfinity/principal").Principal, z.ZodTypeDef, import("@dfinity/principal").Principal>]>;
78
+ collection: z.ZodString;
79
+ key: z.ZodString;
80
+ }, {
81
+ doc: z.ZodObject<{
82
+ version: z.ZodOptional<z.ZodBigInt>;
83
+ }, "strict", z.ZodTypeAny, {
84
+ version?: bigint | undefined;
85
+ }, {
86
+ version?: bigint | undefined;
87
+ }>;
88
+ }>, "strict", z.ZodTypeAny, {
89
+ caller: Uint8Array<ArrayBufferLike> | import("@dfinity/principal").Principal;
90
+ collection: string;
91
+ key: string;
92
+ doc: {
93
+ version?: bigint | undefined;
94
+ };
95
+ }, {
96
+ caller: Uint8Array<ArrayBufferLike> | import("@dfinity/principal").Principal;
97
+ collection: string;
98
+ key: string;
99
+ doc: {
100
+ version?: bigint | undefined;
101
+ };
102
+ }>;
103
+ /**
104
+ * Represents the parameters required to delete a document.
105
+ *
106
+ * This includes the document version along with metadata such as the caller,
107
+ * collection, and key.
108
+ */
109
+ export type DeleteDocStoreParams = DocStoreParams & {
110
+ /**
111
+ * The version required to delete a document.
112
+ */
113
+ doc: DelDoc;
114
+ };
package/sdk.js CHANGED
@@ -1,2 +1,2 @@
1
- import{b as a,c as r,d as c,e as s,f as m,g as i,h as n}from"./chunk-LVVTFR6B.js";import"./chunk-CCKUQNB5.js";import{Principal as h}from"@dfinity/principal";import*as e from"zod";var f=e.object({key:m,description:i.optional(),data:n,version:a.optional()}).strict(),p=e.object({caller:r.or(c),collection:s,doc:f}).strict();var T=o=>{p.parse(o);let{caller:t,collection:S,doc:l}=o,{key:_,...D}=l,d=t instanceof h?t.toUint8Array():t;__juno_satellite_datastore_set_doc_store(d,S,_,D)};import{jsonReplacer as x,jsonReviver as y}from"@dfinity/utils";var U=o=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(o),y),k=o=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(o,x));export{f as SetDocSchema,p as SetDocStoreParamsSchema,U as decodeDocData,k as encodeDocData,T as setDocStore};
1
+ import{c as s,d as l,e as m,f as D,k as S,l as n}from"./chunk-6G6FWQ45.js";import"./chunk-CCKUQNB5.js";import{Principal as y}from"@dfinity/principal";import*as p from"zod";var d=p.object({caller:s.or(l),collection:m,key:D}),i=d.extend({doc:S}).strict(),_=d.extend({doc:n}).strict();var C=e=>{i.parse(e);let{caller:o,collection:t,key:r,doc:a}=e,c=o instanceof y?o.toUint8Array():o;__juno_satellite_datastore_set_doc_store(c,t,r,a)},k=e=>{_.parse(e);let{caller:o,collection:t,key:r,doc:a}=e,c=o instanceof y?o.toUint8Array():o;__juno_satellite_datastore_delete_doc_store(c,t,r,a)};import{jsonReplacer as x,jsonReviver as f}from"@dfinity/utils";var T=e=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(e),f),K=e=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(e,x));export{_ as DeleteDocStoreParamsSchema,i as SetDocStoreParamsSchema,T as decodeDocData,k as deleteDocStore,K as encodeDocData,C as setDocStore};
2
2
  //# sourceMappingURL=sdk.js.map