@junobuild/functions 0.0.6 → 0.0.7
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 +224 -107
- package/chunk-OVO3T2DM.js +2 -0
- package/chunk-OVO3T2DM.js.map +7 -0
- package/global.d.js +1 -0
- package/global.d.js.map +7 -0
- package/global.d.ts +17 -0
- package/{dist/types/configs → hooks/db}/assertions.d.ts +13 -13
- package/{dist/types/configs → hooks/db}/hooks.d.ts +13 -13
- package/{dist/types/configs/collections.config.d.ts → hooks/schemas/collections.d.ts} +3 -3
- package/hooks/schemas/context.d.ts +56 -0
- package/{dist/types/hooks → hooks/schemas/db}/context.d.ts +8 -76
- package/{dist/types/hooks/datastore.d.ts → hooks/schemas/db/payload.d.ts} +0 -145
- package/ic-cdk/id.d.ts +11 -0
- package/ic-cdk.d.ts +1 -0
- package/ic-cdk.js +7 -0
- package/ic-cdk.js.map +7 -0
- package/index.d.ts +10 -0
- package/index.js +2 -0
- package/index.js.map +7 -0
- package/package.json +22 -13
- package/schemas/candid.d.ts +11 -0
- package/{dist/types/hooks → schemas}/core.d.ts +16 -10
- package/schemas/db.d.ts +57 -0
- package/sdk/db.sdk.d.ts +13 -0
- package/sdk/schemas/db.d.ts +109 -0
- package/sdk/serializer.sdk.d.ts +17 -0
- package/sdk.d.ts +3 -0
- package/sdk.js +2 -0
- package/sdk.js.map +7 -0
- package/src/global.d.ts +17 -0
- package/dist/browser/index.js +0 -2
- package/dist/browser/index.js.map +0 -7
- package/dist/index.js +0 -1
- package/dist/types/global.d.ts +0 -8
- package/dist/types/index.d.ts +0 -9
- package/dist/types/sdk/datastore.sdk.d.ts +0 -3
- /package/{dist/types/configs → hooks/schemas}/satellite.env.d.ts +0 -0
- /package/{dist/types/polyfills → polyfills}/console.polyfill.d.ts +0 -0
|
@@ -1,60 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* @see DocDescription
|
|
4
|
-
*/
|
|
5
|
-
export declare const DocDescriptionSchema: z.ZodString;
|
|
6
|
-
/**
|
|
7
|
-
* Represents a document description with a maximum length of 1024 characters.
|
|
8
|
-
*/
|
|
9
|
-
export type DocDescription = z.infer<typeof DocDescriptionSchema>;
|
|
10
|
-
/**
|
|
11
|
-
* @see Doc
|
|
12
|
-
*/
|
|
13
|
-
export declare const DocSchema: z.ZodObject<{
|
|
14
|
-
/**
|
|
15
|
-
* The user who owns this document.
|
|
16
|
-
*/
|
|
17
|
-
owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
18
|
-
/**
|
|
19
|
-
* The raw data of the document.
|
|
20
|
-
*/
|
|
21
|
-
data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
22
|
-
/**
|
|
23
|
-
* An optional description of the document.
|
|
24
|
-
*/
|
|
25
|
-
description: z.ZodOptional<z.ZodString>;
|
|
26
|
-
/**
|
|
27
|
-
* The timestamp when the document was first created.
|
|
28
|
-
*/
|
|
29
|
-
created_at: z.ZodBigInt;
|
|
30
|
-
/**
|
|
31
|
-
* The timestamp when the document was last updated.
|
|
32
|
-
*/
|
|
33
|
-
updated_at: z.ZodBigInt;
|
|
34
|
-
/**
|
|
35
|
-
* The version number of the document, used for consistency checks.
|
|
36
|
-
* If not provided, it's assumed to be the first version.
|
|
37
|
-
*/
|
|
38
|
-
version: z.ZodOptional<z.ZodBigInt>;
|
|
39
|
-
}, "strict", z.ZodTypeAny, {
|
|
40
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
41
|
-
data: Uint8Array<ArrayBufferLike>;
|
|
42
|
-
created_at: bigint;
|
|
43
|
-
updated_at: bigint;
|
|
44
|
-
description?: string | undefined;
|
|
45
|
-
version?: bigint | undefined;
|
|
46
|
-
}, {
|
|
47
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
48
|
-
data: Uint8Array<ArrayBufferLike>;
|
|
49
|
-
created_at: bigint;
|
|
50
|
-
updated_at: bigint;
|
|
51
|
-
description?: string | undefined;
|
|
52
|
-
version?: bigint | undefined;
|
|
53
|
-
}>;
|
|
54
|
-
/**
|
|
55
|
-
* Represents a document stored in a collection.
|
|
56
|
-
*/
|
|
57
|
-
export type Doc = z.infer<typeof DocSchema>;
|
|
58
2
|
/**
|
|
59
3
|
* @see DocUpsert
|
|
60
4
|
*/
|
|
@@ -64,30 +8,11 @@ export declare const DocUpsertSchema: z.ZodObject<{
|
|
|
64
8
|
* Undefined if this is a new document.
|
|
65
9
|
*/
|
|
66
10
|
before: z.ZodOptional<z.ZodObject<{
|
|
67
|
-
/**
|
|
68
|
-
* The user who owns this document.
|
|
69
|
-
*/
|
|
70
11
|
owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
71
|
-
/**
|
|
72
|
-
* The raw data of the document.
|
|
73
|
-
*/
|
|
74
12
|
data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
75
|
-
/**
|
|
76
|
-
* An optional description of the document.
|
|
77
|
-
*/
|
|
78
13
|
description: z.ZodOptional<z.ZodString>;
|
|
79
|
-
/**
|
|
80
|
-
* The timestamp when the document was first created.
|
|
81
|
-
*/
|
|
82
14
|
created_at: z.ZodBigInt;
|
|
83
|
-
/**
|
|
84
|
-
* The timestamp when the document was last updated.
|
|
85
|
-
*/
|
|
86
15
|
updated_at: z.ZodBigInt;
|
|
87
|
-
/**
|
|
88
|
-
* The version number of the document, used for consistency checks.
|
|
89
|
-
* If not provided, it's assumed to be the first version.
|
|
90
|
-
*/
|
|
91
16
|
version: z.ZodOptional<z.ZodBigInt>;
|
|
92
17
|
}, "strict", z.ZodTypeAny, {
|
|
93
18
|
owner: Uint8Array<ArrayBufferLike>;
|
|
@@ -108,30 +33,11 @@ export declare const DocUpsertSchema: z.ZodObject<{
|
|
|
108
33
|
* The new version of the document after the update.
|
|
109
34
|
*/
|
|
110
35
|
after: z.ZodObject<{
|
|
111
|
-
/**
|
|
112
|
-
* The user who owns this document.
|
|
113
|
-
*/
|
|
114
36
|
owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
115
|
-
/**
|
|
116
|
-
* The raw data of the document.
|
|
117
|
-
*/
|
|
118
37
|
data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
119
|
-
/**
|
|
120
|
-
* An optional description of the document.
|
|
121
|
-
*/
|
|
122
38
|
description: z.ZodOptional<z.ZodString>;
|
|
123
|
-
/**
|
|
124
|
-
* The timestamp when the document was first created.
|
|
125
|
-
*/
|
|
126
39
|
created_at: z.ZodBigInt;
|
|
127
|
-
/**
|
|
128
|
-
* The timestamp when the document was last updated.
|
|
129
|
-
*/
|
|
130
40
|
updated_at: z.ZodBigInt;
|
|
131
|
-
/**
|
|
132
|
-
* The version number of the document, used for consistency checks.
|
|
133
|
-
* If not provided, it's assumed to be the first version.
|
|
134
|
-
*/
|
|
135
41
|
version: z.ZodOptional<z.ZodBigInt>;
|
|
136
42
|
}, "strict", z.ZodTypeAny, {
|
|
137
43
|
owner: Uint8Array<ArrayBufferLike>;
|
|
@@ -228,30 +134,11 @@ export declare const DocAssertSetSchema: z.ZodObject<{
|
|
|
228
134
|
* Undefined if this is a new document.
|
|
229
135
|
*/
|
|
230
136
|
current: z.ZodOptional<z.ZodObject<{
|
|
231
|
-
/**
|
|
232
|
-
* The user who owns this document.
|
|
233
|
-
*/
|
|
234
137
|
owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
235
|
-
/**
|
|
236
|
-
* The raw data of the document.
|
|
237
|
-
*/
|
|
238
138
|
data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
239
|
-
/**
|
|
240
|
-
* An optional description of the document.
|
|
241
|
-
*/
|
|
242
139
|
description: z.ZodOptional<z.ZodString>;
|
|
243
|
-
/**
|
|
244
|
-
* The timestamp when the document was first created.
|
|
245
|
-
*/
|
|
246
140
|
created_at: z.ZodBigInt;
|
|
247
|
-
/**
|
|
248
|
-
* The timestamp when the document was last updated.
|
|
249
|
-
*/
|
|
250
141
|
updated_at: z.ZodBigInt;
|
|
251
|
-
/**
|
|
252
|
-
* The version number of the document, used for consistency checks.
|
|
253
|
-
* If not provided, it's assumed to be the first version.
|
|
254
|
-
*/
|
|
255
142
|
version: z.ZodOptional<z.ZodBigInt>;
|
|
256
143
|
}, "strict", z.ZodTypeAny, {
|
|
257
144
|
owner: Uint8Array<ArrayBufferLike>;
|
|
@@ -330,35 +217,3 @@ export declare const DocAssertSetSchema: z.ZodObject<{
|
|
|
330
217
|
* throw an error if their validation fails.
|
|
331
218
|
*/
|
|
332
219
|
export type DocAssertSet = z.infer<typeof DocAssertSetSchema>;
|
|
333
|
-
/**
|
|
334
|
-
* @see SetDoc
|
|
335
|
-
*/
|
|
336
|
-
export declare const SetDocSchema: z.ZodObject<{
|
|
337
|
-
/**
|
|
338
|
-
* The raw data of the document.
|
|
339
|
-
*/
|
|
340
|
-
data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
341
|
-
/**
|
|
342
|
-
* An optional description of the document.
|
|
343
|
-
*/
|
|
344
|
-
description: z.ZodOptional<z.ZodString>;
|
|
345
|
-
/**
|
|
346
|
-
* The expected version number to ensure consistency.
|
|
347
|
-
* If provided, the operation will fail if the stored version does not match.
|
|
348
|
-
*/
|
|
349
|
-
version: z.ZodOptional<z.ZodBigInt>;
|
|
350
|
-
}, "strict", z.ZodTypeAny, {
|
|
351
|
-
data: Uint8Array<ArrayBufferLike>;
|
|
352
|
-
description?: string | undefined;
|
|
353
|
-
version?: bigint | undefined;
|
|
354
|
-
}, {
|
|
355
|
-
data: Uint8Array<ArrayBufferLike>;
|
|
356
|
-
description?: string | undefined;
|
|
357
|
-
version?: bigint | undefined;
|
|
358
|
-
}>;
|
|
359
|
-
/**
|
|
360
|
-
* Represents a request to set or update a document.
|
|
361
|
-
*
|
|
362
|
-
* This is used when submitting new document data.
|
|
363
|
-
*/
|
|
364
|
-
export type SetDoc = z.infer<typeof SetDocSchema>;
|
package/ic-cdk/id.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Principal } from '@dfinity/principal';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the Satellite's Principal ID.
|
|
4
|
+
*
|
|
5
|
+
* This function is a JavaScript binding for the Rust function
|
|
6
|
+
* [`ic_cdk::id()`](https://docs.rs/ic-cdk/latest/ic_cdk/fn.id.html), which returns
|
|
7
|
+
* the Principal of the executing canister.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Principal} The Principal ID of the Satellite.
|
|
10
|
+
*/
|
|
11
|
+
export declare const id: () => Principal;
|
package/ic-cdk.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ic-cdk/id';
|
package/ic-cdk.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var y="abcdefghijklmnopqrstuvwxyz234567",l=Object.create(null);for(let e=0;e<y.length;e++)l[y[e]]=e;l[0]=l.o;l[1]=l.i;function k(e){let t=0,n=0,r="";function o(c){return t<0?n|=c>>-t:n=c<<t&248,t>3?(t-=8,1):(t<4&&(r+=y[n>>3],t+=5),0)}for(let c=0;c<e.length;)c+=o(e[c]);return r+(t<0?y[n>>3]:"")}function O(e){let t=0,n=0,r=new Uint8Array(e.length*4/3|0),o=0;function c(x){let s=l[x.toLowerCase()];if(s===void 0)throw new Error(`Invalid character: ${JSON.stringify(x)}`);s<<=3,n|=s>>>t,t+=5,t>=8&&(r[o++]=n,t-=8,t>0?n=s<<5-t&255:n=0)}for(let x of e)c(x);return r.slice(0,o)}var V=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function H(e){let t=new Uint8Array(e),n=-1;for(let r=0;r<t.length;r++){let c=(t[r]^n)&255;n=V[c]^n>>>8}return(n^-1)>>>0}function G(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function L(e,...t){if(!G(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function B(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function N(e,t){L(e);let n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var m=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),d=(e,t)=>e<<32-t|e>>>t;var tt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function M(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function T(e){return typeof e=="string"&&(e=M(e)),L(e),e}var w=class{clone(){return this._cloneInto()}},et={}.toString;function j(e){let t=r=>e().update(T(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function R(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);let o=BigInt(32),c=BigInt(4294967295),x=Number(n>>o&c),s=Number(n&c),f=r?4:0,a=r?0:4;e.setUint32(t+f,x,r),e.setUint32(t+a,s,r)}var F=(e,t,n)=>e&t^~e&n,v=(e,t,n)=>e&t^e&n^t&n,_=class extends w{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=m(this.buffer)}update(t){B(this);let{view:n,buffer:r,blockLen:o}=this;t=T(t);let c=t.length;for(let x=0;x<c;){let s=Math.min(o-this.pos,c-x);if(s===o){let f=m(t);for(;o<=c-x;x+=o)this.process(f,x);continue}r.set(t.subarray(x,x+s),this.pos),this.pos+=s,x+=s,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){B(this),N(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:c}=this,{pos:x}=this;n[x++]=128,this.buffer.subarray(x).fill(0),this.padOffset>o-x&&(this.process(r,0),x=0);for(let i=x;i<o;i++)n[i]=0;R(r,o-8,BigInt(this.length*8),c),this.process(r,0);let s=m(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=f/4,b=this.get();if(a>b.length)throw new Error("_sha2: outputLen bigger than state");for(let i=0;i<a;i++)s.setUint32(4*i,b[i],c)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:c,destroyed:x,pos:s}=this;return t.length=o,t.pos=s,t.finished=c,t.destroyed=x,o%n&&t.buffer.set(r),t}};var q=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),u=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),h=new Uint32Array(64),S=class extends _{constructor(){super(64,32,8,!1),this.A=u[0]|0,this.B=u[1]|0,this.C=u[2]|0,this.D=u[3]|0,this.E=u[4]|0,this.F=u[5]|0,this.G=u[6]|0,this.H=u[7]|0}get(){let{A:t,B:n,C:r,D:o,E:c,F:x,G:s,H:f}=this;return[t,n,r,o,c,x,s,f]}set(t,n,r,o,c,x,s,f){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=c|0,this.F=x|0,this.G=s|0,this.H=f|0}process(t,n){for(let i=0;i<16;i++,n+=4)h[i]=t.getUint32(n,!1);for(let i=16;i<64;i++){let g=h[i-15],p=h[i-2],I=d(g,7)^d(g,18)^g>>>3,E=d(p,17)^d(p,19)^p>>>10;h[i]=E+h[i-7]+I+h[i-16]|0}let{A:r,B:o,C:c,D:x,E:s,F:f,G:a,H:b}=this;for(let i=0;i<64;i++){let g=d(s,6)^d(s,11)^d(s,25),p=b+g+F(s,f,a)+q[i]+h[i]|0,E=(d(r,2)^d(r,13)^d(r,22))+v(r,o,c)|0;b=a,a=f,f=s,s=x+p|0,x=c,c=o,o=r,r=p+E|0}r=r+this.A|0,o=o+this.B|0,c=c+this.C|0,x=x+this.D|0,s=s+this.E|0,f=f+this.F|0,a=a+this.G|0,b=b+this.H|0,this.set(r,o,c,x,s,f,a,b)}roundClean(){h.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},C=class extends S{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};var D=j(()=>new C);function P(e){return D.create().update(new Uint8Array(e)).digest()}var A="__principal__",J=2,$=4,W="aaaaa-aa",X=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(n=>parseInt(n,16)))},K=e=>e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),""),U=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([$]))}static managementCanister(){return this.fromHex(W)}static selfAuthenticating(t){let n=P(t);return new this(new Uint8Array([...n,J]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(X(t))}static fromText(t){let n=t;if(t.includes(A)){let x=JSON.parse(t);A in x&&(n=x[A])}let r=n.toLowerCase().replace(/-/g,""),o=O(r);o=o.slice(4,o.length);let c=new this(o);if(c.toText()!==n)throw new Error(`Principal "${c.toText()}" does not have a valid checksum (original value "${n}" may not be a valid Principal ID).`);return c}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===$}toUint8Array(){return this._arr}toHex(){return K(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,H(this._arr));let r=new Uint8Array(t),o=Uint8Array.from(this._arr),c=new Uint8Array([...r,...o]),s=k(c).match(/.{1,5}/g);if(!s)throw new Error;return s.join("-")}toString(){return this.toText()}toJSON(){return{[A]:this.toText()}}compareTo(t){for(let n=0;n<Math.min(this._arr.length,t._arr.length);n++){if(this._arr[n]<t._arr[n])return"lt";if(this._arr[n]>t._arr[n])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let n=this.compareTo(t);return n=="lt"||n=="eq"}gtEq(t){let n=this.compareTo(t);return n=="gt"||n=="eq"}};var lt=()=>U.fromUint8Array(__ic_cdk_id());export{lt as id};
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
@noble/hashes/esm/utils.js:
|
|
5
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
6
|
+
*/
|
|
7
|
+
//# sourceMappingURL=ic-cdk.js.map
|
package/ic-cdk.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/@dfinity/principal/src/utils/base32.ts", "../../node_modules/@dfinity/principal/src/utils/getCrc.ts", "../../node_modules/@noble/hashes/src/_assert.ts", "../../node_modules/@noble/hashes/src/utils.ts", "../../node_modules/@noble/hashes/src/_md.ts", "../../node_modules/@noble/hashes/src/sha256.ts", "../../node_modules/@dfinity/principal/src/utils/sha224.ts", "../../node_modules/@dfinity/principal/src/index.ts", "src/ic-cdk/id.ts"],
|
|
4
|
+
"sourcesContent": ["const alphabet = 'abcdefghijklmnopqrstuvwxyz234567';\n\n// Build a lookup table for decoding.\nconst lookupTable: Record<string, number> = Object.create(null);\nfor (let i = 0; i < alphabet.length; i++) {\n lookupTable[alphabet[i]] = i;\n}\n\n// Add aliases for rfc4648.\nlookupTable['0'] = lookupTable.o;\nlookupTable['1'] = lookupTable.i;\n\n/**\n * @param input The input array to encode.\n * @returns A Base32 string encoding the input.\n */\nexport function encode(input: Uint8Array): string {\n // How many bits will we skip from the first byte.\n let skip = 0;\n // 5 high bits, carry from one byte to the next.\n let bits = 0;\n\n // The output string in base32.\n let output = '';\n\n function encodeByte(byte: number) {\n if (skip < 0) {\n // we have a carry from the previous byte\n bits |= byte >> -skip;\n } else {\n // no carry\n bits = (byte << skip) & 248;\n }\n\n if (skip > 3) {\n // Not enough data to produce a character, get us another one\n skip -= 8;\n return 1;\n }\n\n if (skip < 4) {\n // produce a character\n output += alphabet[bits >> 3];\n skip += 5;\n }\n\n return 0;\n }\n\n for (let i = 0; i < input.length; ) {\n i += encodeByte(input[i]);\n }\n\n return output + (skip < 0 ? alphabet[bits >> 3] : '');\n}\n\n/**\n * @param input The base32 encoded string to decode.\n */\nexport function decode(input: string): Uint8Array {\n // how many bits we have from the previous character.\n let skip = 0;\n // current byte we're producing.\n let byte = 0;\n\n const output = new Uint8Array(((input.length * 4) / 3) | 0);\n let o = 0;\n\n function decodeChar(char: string) {\n // Consume a character from the stream, store\n // the output in this.output. As before, better\n // to use update().\n let val = lookupTable[char.toLowerCase()];\n if (val === undefined) {\n throw new Error(`Invalid character: ${JSON.stringify(char)}`);\n }\n\n // move to the high bits\n val <<= 3;\n byte |= val >>> skip;\n skip += 5;\n\n if (skip >= 8) {\n // We have enough bytes to produce an output\n output[o++] = byte;\n skip -= 8;\n\n if (skip > 0) {\n byte = (val << (5 - skip)) & 255;\n } else {\n byte = 0;\n }\n }\n }\n\n for (const c of input) {\n decodeChar(c);\n }\n\n return output.slice(0, o);\n}\n", "// This file is translated to JavaScript from\n// https://lxp32.github.io/docs/a-simple-example-crc32-calculation/\nconst lookUpTable: Uint32Array = new Uint32Array([\n 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,\n 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,\n 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,\n 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,\n 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,\n 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,\n 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,\n 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,\n 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,\n 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,\n 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,\n 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,\n 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,\n 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,\n 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,\n 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,\n 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,\n 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,\n 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,\n 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,\n 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,\n 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,\n 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,\n 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,\n 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,\n 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,\n 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,\n 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,\n 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,\n 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,\n 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,\n 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,\n]);\n\n/**\n * Calculate the CRC32 of an ArrayBufferLike.\n * @param buf The BufferLike to calculate the CRC32 of.\n */\nexport function getCrc32(buf: ArrayBufferLike): number {\n const b = new Uint8Array(buf);\n let crc = -1;\n\n for (let i = 0; i < b.length; i++) {\n const byte = b[i];\n const t = (byte ^ crc) & 0xff;\n crc = lookUpTable[t] ^ (crc >>> 8);\n }\n\n return (crc ^ -1) >>> 0;\n}\n", "function number(n: number) {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`);\n}\n\nfunction bool(b: boolean) {\n if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`);\n}\n\n// copied from utils\nexport function isBytes(a: unknown): a is Uint8Array {\n return (\n a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')\n );\n}\n\nfunction bytes(b: Uint8Array | undefined, ...lengths: number[]) {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);\n}\n\ntype Hash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\nfunction hash(h: Hash) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(h.outputLen);\n number(h.blockLen);\n}\n\nfunction exists(instance: any, checkFinished = true) {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\nfunction output(out: any, instance: any) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\n\nexport { number, bool, bytes, hash, exists, output };\n\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n", "/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { bytes as abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a: unknown): a is Uint8Array {\n return (\n a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')\n );\n}\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n// Cast array to different type\nexport const u8 = (arr: TypedArray) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr: TypedArray) =>\n new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n\n// Cast array to view\nexport const createView = (arr: TypedArray) =>\n new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word: number, shift: number) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word: number, shift: number) =>\n (word << shift) | ((word >>> (32 - shift)) >>> 0);\n\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\n// The byte swap operation for uint32\nexport const byteSwap = (word: number) =>\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n: number) => n : (n: number) => byteSwap(n);\n\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr: Uint32Array) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 } as const;\nfunction asciiToBase16(char: number): number | undefined {\n if (char >= asciis._0 && char <= asciis._9) return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F) return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f) return char - (asciis._a - 10);\n return;\n}\n\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\n\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => {};\n\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters: number, tick: number, cb: (i: number) => void) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n// For runtime check if class implements interface\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\nconst toStr = {}.toString;\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\nexport type CHash = ReturnType<typeof wrapConstructor>;\n\nexport function wrapConstructor<T extends Hash<T>>(hashCons: () => Hash<T>) {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "import { exists, output } from './_assert.js';\nimport { Hash, createView, Input, toBytes } from './utils.js';\n\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n/**\n * Choice: a ? b : c\n */\nexport const Chi = (a: number, b: number, c: number) => (a & b) ^ (~a & c);\n\n/**\n * Majority function, true if any two inputs is true\n */\nexport const Maj = (a: number, b: number, c: number) => (a & b) ^ (a & c) ^ (b & c);\n\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport abstract class HashMD<T extends HashMD<T>> extends Hash<T> {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(\n readonly blockLen: number,\n public outputLen: number,\n readonly padOffset: number,\n readonly isLE: boolean\n ) {\n super();\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n exists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array) {\n exists(this);\n output(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n}\n", "import { HashMD, Chi, Maj } from './_md.js';\nimport { rotr, wrapConstructor } from './utils.js';\n\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD<SHA256> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n A = SHA256_IV[0] | 0;\n B = SHA256_IV[1] | 0;\n C = SHA256_IV[2] | 0;\n D = SHA256_IV[3] | 0;\n E = SHA256_IV[4] | 0;\n F = SHA256_IV[5] | 0;\n G = SHA256_IV[6] | 0;\n H = SHA256_IV[7] | 0;\n\n constructor() {\n super(64, 32, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n A = 0xc1059ed8 | 0;\n B = 0x367cd507 | 0;\n C = 0x3070dd17 | 0;\n D = 0xf70e5939 | 0;\n E = 0xffc00b31 | 0;\n F = 0x68581511 | 0;\n G = 0x64f98fa7 | 0;\n H = 0xbefa4fa4 | 0;\n constructor() {\n super();\n this.outputLen = 28;\n }\n}\n\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n", "import { sha224 as jsSha224 } from '@noble/hashes/sha256';\n\n/**\n * Returns the SHA224 hash of the buffer.\n * @param data Arraybuffer to encode\n */\nexport function sha224(data: ArrayBuffer): Uint8Array {\n return jsSha224.create().update(new Uint8Array(data)).digest();\n}\n", "import { decode, encode } from './utils/base32';\nimport { getCrc32 } from './utils/getCrc';\nimport { sha224 } from './utils/sha224';\n\nexport const JSON_KEY_PRINCIPAL = '__principal__';\nconst SELF_AUTHENTICATING_SUFFIX = 2;\nconst ANONYMOUS_SUFFIX = 4;\n\nconst MANAGEMENT_CANISTER_PRINCIPAL_HEX_STR = 'aaaaa-aa';\n\nconst fromHexString = (hexString: string) =>\n new Uint8Array((hexString.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)));\n\nconst toHexString = (bytes: Uint8Array) =>\n bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');\n\nexport type JsonnablePrincipal = {\n [JSON_KEY_PRINCIPAL]: string;\n};\n\nexport class Principal {\n public static anonymous(): Principal {\n return new this(new Uint8Array([ANONYMOUS_SUFFIX]));\n }\n\n /**\n * Utility method, returning the principal representing the management canister, decoded from the hex string `'aaaaa-aa'`\n * @returns {Principal} principal of the management canister\n */\n public static managementCanister(): Principal {\n return this.fromHex(MANAGEMENT_CANISTER_PRINCIPAL_HEX_STR);\n }\n\n public static selfAuthenticating(publicKey: Uint8Array): Principal {\n const sha = sha224(publicKey);\n return new this(new Uint8Array([...sha, SELF_AUTHENTICATING_SUFFIX]));\n }\n\n public static from(other: unknown): Principal {\n if (typeof other === 'string') {\n return Principal.fromText(other);\n } else if (Object.getPrototypeOf(other) === Uint8Array.prototype) {\n return new Principal(other as Uint8Array);\n } else if (\n typeof other === 'object' &&\n other !== null &&\n (other as Principal)._isPrincipal === true\n ) {\n return new Principal((other as Principal)._arr);\n }\n\n throw new Error(`Impossible to convert ${JSON.stringify(other)} to Principal.`);\n }\n\n public static fromHex(hex: string): Principal {\n return new this(fromHexString(hex));\n }\n\n public static fromText(text: string): Principal {\n let maybePrincipal = text;\n // If formatted as JSON string, parse it first\n if (text.includes(JSON_KEY_PRINCIPAL)) {\n const obj = JSON.parse(text);\n if (JSON_KEY_PRINCIPAL in obj) {\n maybePrincipal = obj[JSON_KEY_PRINCIPAL];\n }\n }\n\n const canisterIdNoDash = maybePrincipal.toLowerCase().replace(/-/g, '');\n\n let arr = decode(canisterIdNoDash);\n arr = arr.slice(4, arr.length);\n\n const principal = new this(arr);\n if (principal.toText() !== maybePrincipal) {\n throw new Error(\n `Principal \"${principal.toText()}\" does not have a valid checksum (original value \"${maybePrincipal}\" may not be a valid Principal ID).`,\n );\n }\n\n return principal;\n }\n\n public static fromUint8Array(arr: Uint8Array): Principal {\n return new this(arr);\n }\n\n public readonly _isPrincipal = true;\n\n protected constructor(private _arr: Uint8Array) {}\n\n public isAnonymous(): boolean {\n return this._arr.byteLength === 1 && this._arr[0] === ANONYMOUS_SUFFIX;\n }\n\n public toUint8Array(): Uint8Array {\n return this._arr;\n }\n\n public toHex(): string {\n return toHexString(this._arr).toUpperCase();\n }\n\n public toText(): string {\n const checksumArrayBuf = new ArrayBuffer(4);\n const view = new DataView(checksumArrayBuf);\n view.setUint32(0, getCrc32(this._arr));\n const checksum = new Uint8Array(checksumArrayBuf);\n\n const bytes = Uint8Array.from(this._arr);\n const array = new Uint8Array([...checksum, ...bytes]);\n\n const result = encode(array);\n const matches = result.match(/.{1,5}/g);\n if (!matches) {\n // This should only happen if there's no character, which is unreachable.\n throw new Error();\n }\n return matches.join('-');\n }\n\n public toString(): string {\n return this.toText();\n }\n\n /**\n * Serializes to JSON\n * @returns {JsonnablePrincipal} a JSON object with a single key, {@link JSON_KEY_PRINCIPAL}, whose value is the principal as a string\n */\n public toJSON(): JsonnablePrincipal {\n return { [JSON_KEY_PRINCIPAL]: this.toText() };\n }\n\n /**\n * Utility method taking a Principal to compare against. Used for determining canister ranges in certificate verification\n * @param {Principal} other - a {@link Principal} to compare\n * @returns {'lt' | 'eq' | 'gt'} `'lt' | 'eq' | 'gt'` a string, representing less than, equal to, or greater than\n */\n public compareTo(other: Principal): 'lt' | 'eq' | 'gt' {\n for (let i = 0; i < Math.min(this._arr.length, other._arr.length); i++) {\n if (this._arr[i] < other._arr[i]) return 'lt';\n else if (this._arr[i] > other._arr[i]) return 'gt';\n }\n // Here, at least one principal is a prefix of the other principal (they could be the same)\n if (this._arr.length < other._arr.length) return 'lt';\n if (this._arr.length > other._arr.length) return 'gt';\n return 'eq';\n }\n\n /**\n * Utility method checking whether a provided Principal is less than or equal to the current one using the {@link Principal.compareTo} method\n * @param other a {@link Principal} to compare\n * @returns {boolean} boolean\n */\n public ltEq(other: Principal): boolean {\n const cmp = this.compareTo(other);\n return cmp == 'lt' || cmp == 'eq';\n }\n\n /**\n * Utility method checking whether a provided Principal is greater than or equal to the current one using the {@link Principal.compareTo} method\n * @param other a {@link Principal} to compare\n * @returns {boolean} boolean\n */\n public gtEq(other: Principal): boolean {\n const cmp = this.compareTo(other);\n return cmp == 'gt' || cmp == 'eq';\n }\n}\n", "import {Principal} from '@dfinity/principal';\n\n/**\n * Retrieves the Satellite's Principal ID.\n *\n * This function is a JavaScript binding for the Rust function\n * [`ic_cdk::id()`](https://docs.rs/ic-cdk/latest/ic_cdk/fn.id.html), which returns\n * the Principal of the executing canister.\n *\n * @returns {Principal} The Principal ID of the Satellite.\n */\nexport const id = (): Principal => {\n const principal = Principal.fromUint8Array(__ic_cdk_id());\n\n // We assume the Principal is always built using the global function and is therefore always valid.\n // In other words, we do not validate it to conserve resources and optimize performance.\n\n return principal;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,IAAMA,EAAW,mCAGXC,EAAsC,OAAO,OAAO,IAAI,EAC9D,QAASC,EAAI,EAAGA,EAAIF,EAAS,OAAQE,IACnCD,EAAYD,EAASE,CAAC,CAAC,EAAIA,EAI7BD,EAAY,CAAG,EAAIA,EAAY,EAC/BA,EAAY,CAAG,EAAIA,EAAY,EAMzB,SAAUE,EAAOC,EAAiB,CAEtC,IAAIC,EAAO,EAEPC,EAAO,EAGPC,EAAS,GAEb,SAASC,EAAWC,EAAY,CAS9B,OARIJ,EAAO,EAETC,GAAQG,GAAQ,CAACJ,EAGjBC,EAAQG,GAAQJ,EAAQ,IAGtBA,EAAO,GAETA,GAAQ,EACD,IAGLA,EAAO,IAETE,GAAUP,EAASM,GAAQ,CAAC,EAC5BD,GAAQ,GAGH,EACT,CAEA,QAASH,EAAI,EAAGA,EAAIE,EAAM,QACxBF,GAAKM,EAAWJ,EAAM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,KAAK,KAAK,IAAI,EACjCoB,EAAQ,IAAI,WAAW,CAAC,GAAGD,EAAU,GAAGnB,CAAK,CAAC,EAG9CqB,EADSC,EAAOF,CAAK,EACJ,MAAM,SAAS,EACtC,GAAI,CAACC,EAEH,MAAM,IAAI,MAEZ,OAAOA,EAAQ,KAAK,GAAG,CACzB,CAEO,UAAQ,CACb,OAAO,KAAK,OAAM,CACpB,CAMO,QAAM,CACX,MAAO,CAAE,CAAC9B,CAAkB,EAAG,KAAK,OAAM,CAAE,CAC9C,CAOO,UAAUiB,EAAgB,CAC/B,QAASe,EAAI,EAAGA,EAAI,KAAK,IAAI,KAAK,KAAK,OAAQf,EAAM,KAAK,MAAM,EAAGe,IAAK,CACtE,GAAI,KAAK,KAAKA,CAAC,EAAIf,EAAM,KAAKe,CAAC,EAAG,MAAO,KACpC,GAAI,KAAK,KAAKA,CAAC,EAAIf,EAAM,KAAKe,CAAC,EAAG,MAAO,KAGhD,OAAI,KAAK,KAAK,OAASf,EAAM,KAAK,OAAe,KAC7C,KAAK,KAAK,OAASA,EAAM,KAAK,OAAe,KAC1C,IACT,CAOO,KAAKA,EAAgB,CAC1B,IAAMgB,EAAM,KAAK,UAAUhB,CAAK,EAChC,OAAOgB,GAAO,MAAQA,GAAO,IAC/B,CAOO,KAAKhB,EAAgB,CAC1B,IAAMgB,EAAM,KAAK,UAAUhB,CAAK,EAChC,OAAOgB,GAAO,MAAQA,GAAO,IAC/B,GC5JK,IAAMC,GAAK,IACEC,EAAU,eAAe,YAAY,CAAC",
|
|
6
|
+
"names": ["alphabet", "lookupTable", "i", "encode", "input", "skip", "bits", "output", "encodeByte", "byte", "decode", "decodeChar", "char", "val", "c", "lookUpTable", "getCrc32", "buf", "b", "crc", "i", "t", "isBytes", "a", "bytes", "b", "lengths", "exists", "instance", "checkFinished", "output", "out", "bytes", "min", "createView", "arr", "rotr", "word", "shift", "isLE", "utf8ToBytes", "str", "toBytes", "data", "bytes", "Hash", "toStr", "wrapConstructor", "hashCons", "hashC", "msg", "toBytes", "tmp", "setBigUint64", "view", "byteOffset", "value", "isLE", "_32n", "_u32_max", "wh", "wl", "h", "l", "Chi", "a", "b", "c", "Maj", "HashMD", "Hash", "blockLen", "outputLen", "padOffset", "createView", "data", "exists", "buffer", "toBytes", "len", "pos", "take", "dataView", "out", "output", "oview", "outLen", "state", "res", "to", "length", "finished", "destroyed", "SHA256_K", "SHA256_IV", "SHA256_W", "SHA256", "HashMD", "A", "B", "C", "D", "E", "F", "G", "H", "view", "offset", "W15", "W2", "s0", "rotr", "s1", "sigma1", "T1", "Chi", "T2", "Maj", "SHA224", "sha224", "wrapConstructor", "SHA224", "sha224", "data", "JSON_KEY_PRINCIPAL", "SELF_AUTHENTICATING_SUFFIX", "ANONYMOUS_SUFFIX", "MANAGEMENT_CANISTER_PRINCIPAL_HEX_STR", "fromHexString", "hexString", "_a", "byte", "toHexString", "bytes", "str", "Principal", "_Principal", "_arr", "publicKey", "sha", "sha224", "other", "hex", "text", "maybePrincipal", "obj", "canisterIdNoDash", "arr", "decode", "principal", "checksumArrayBuf", "getCrc32", "checksum", "array", "matches", "encode", "i", "cmp", "id", "Principal"]
|
|
7
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './hooks/db/assertions';
|
|
2
|
+
export * from './hooks/db/hooks';
|
|
3
|
+
export * from './hooks/schemas/collections';
|
|
4
|
+
export * from './hooks/schemas/context';
|
|
5
|
+
export * from './hooks/schemas/db/context';
|
|
6
|
+
export * from './hooks/schemas/db/payload';
|
|
7
|
+
export * from './hooks/schemas/satellite.env';
|
|
8
|
+
export * from './schemas/candid';
|
|
9
|
+
export * from './schemas/core';
|
|
10
|
+
import './polyfills/console.polyfill';
|
package/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as E,b as R,c as f,d as S,e as T,f as y,g as d,h,i as n}from"./chunk-OVO3T2DM.js";import*as o from"zod";import*as r from"zod";var s=r.object({collections:r.array(r.string()).min(1)}).strict();import*as k from"zod";import*as z from"zod";var x=e=>z.object({caller:T,data:e}).strict();import*as c from"zod";var l=c.object({before:n.optional(),after:n}).strict(),b=c.object({data:S,description:h.optional(),version:f.optional()}).strict(),A=c.object({current:n.optional(),proposed:b}).strict();var O=e=>k.object({collection:y,key:d,data:e}).strict(),D=x(O(l)),H=x(O(A));import*as p from"zod";var i=p.record(p.unknown());var j=e=>s.extend({assert:o.function().args(e).returns(o.void())}).strict(),F=j(H),W=F,C=e=>o.function().args(i).returns(e),X=e=>o.union([e,C(e)]);function Y(e){return e}import*as t from"zod";var v=e=>s.extend({run:t.function().args(e).returns(t.promise(t.void()))}).strict(),Z=v(D),re=Z,g=e=>t.function().args(i).returns(e),ne=e=>t.union([e,g(e)]);function se(e){return e}import{jsonReplacer as _}from"@dfinity/utils";var m=e=>{let u=e.map(a=>typeof a=="object"?JSON.stringify(a,_):a).join(" ");globalThis.__ic_cdk_print(u)};globalThis.console={info(...e){m(e)},log(...e){m(e)},warn(...e){m(e)},error(...e){m(e)}};export{X as AssertFnOrObjectSchema,C as AssertFnSchema,W as AssertSchema,H as AssertSetDocContextSchema,F as AssertSetDocSchema,y as CollectionSchema,s as CollectionsSchema,A as DocAssertSetSchema,O as DocContextSchema,l as DocUpsertSchema,x as HookContextSchema,ne as HookFnOrObjectSchema,g as HookFnSchema,re as HookSchema,d as KeySchema,D as OnSetDocContextSchema,Z as OnSetDocSchema,b as ProposedDocSchema,S as RawDataSchema,E as RawPrincipalSchema,T as RawUserIdSchema,i as SatelliteEnvSchema,R as TimestampSchema,f as VersionSchema,Y as defineAssert,se as defineHook};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/hooks/db/assertions.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/db/hooks.ts", "src/polyfills/console.polyfill.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport {CollectionsSchema} from '../schemas/collections';\nimport {AssertSetDocContextSchema} from '../schemas/db/context';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: z.function().args(contextSchema).returns(z.void())\n }).strict();\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = z.infer<typeof AssertSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Assert\n */\nexport const AssertSchema = AssertSetDocSchema;\n\n/**\n * All assertions definitions.\n */\nexport type Assert = z.infer<typeof AssertSchema>;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(assertSchema);\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, AssertFnSchema(assertSchema)]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n /**\n * An array containing at least one collection name where the hook or assertion will be executed.\n */\n collections: z.array(z.string()).min(1)\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport type Collections = z.infer<typeof CollectionsSchema>;\n", "import * as z from 'zod';\nimport {CollectionSchema, KeySchema} from '../../../schemas/core';\nimport {HookContextSchema} from '../context';\nimport {DocAssertSetSchema, DocUpsertSchema} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The name of the collection where the document is stored.\n */\n collection: CollectionSchema,\n\n /**\n * The unique key identifying the document within the collection.\n */\n key: KeySchema,\n\n /**\n * The data associated with the document operation.\n */\n data: dataSchema\n })\n .strict();\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport type DocContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof DocContextSchema<T>>>;\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = z.infer<typeof OnSetDocContextSchema>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertSetDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = z.infer<typeof AssertSetDocContextSchema>;\n", "import * as z from 'zod';\nimport {RawUserIdSchema} from '../../schemas/core';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserIdSchema,\n\n /**\n * The data associated with the hook execution.\n */\n data: dataSchema\n })\n .strict();\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport type HookContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof HookContextSchema<T>>>;\n", "import * as z from 'zod';\nimport {RawDataSchema, VersionSchema} from '../../../schemas/core';\nimport {DocDescriptionSchema, DocSchema} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before: DocSchema.optional(),\n\n /**\n * The new version of the document after the update.\n */\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport type DocUpsert = z.infer<typeof DocUpsertSchema>;\n\n/**\n * @see ProposedDoc\n */\nexport const ProposedDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document.\n * This can be validated before allowing the operation.\n */\nexport type ProposedDoc = z.infer<typeof ProposedDocSchema>;\n\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current: DocSchema.optional(),\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: ProposedDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport type DocAssertSet = z.infer<typeof DocAssertSetSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.unknown());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod';\nimport {CollectionsSchema} from '../schemas/collections';\nimport {OnSetDocContextSchema} from '../schemas/db/context';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: z.function().args(contextSchema).returns(z.promise(z.void()))\n }).strict();\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = z.infer<typeof OnSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Hook\n */\nexport const HookSchema = OnSetDocSchema;\n\n/**\n * All hooks definitions.\n */\nexport type Hook = z.infer<typeof HookSchema>;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(hookSchema);\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, HookFnSchema(hookSchema)]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n"],
|
|
5
|
+
"mappings": "2FAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MAKZ,IAAMC,EACV,SAAO,CAIN,YAAe,QAAQ,SAAO,CAAC,EAAE,IAAI,CAAC,CACxC,CAAC,EACA,OAAO,ECZV,UAAYC,MAAO,MCAnB,UAAY,MAAO,MAMZ,IAAMC,EAA6CC,GAErD,SAAO,CAIN,OAAQC,EAKR,KAAMD,CACR,CAAC,EACA,OAAO,ECnBZ,UAAYE,MAAO,MAOZ,IAAMC,EACV,SAAO,CAKN,OAAQC,EAAU,SAAS,EAK3B,MAAOA,CACT,CAAC,EACA,OAAO,EAYGC,EACV,SAAO,CAIN,KAAMC,EAKN,YAAaC,EAAqB,SAAS,EAK3C,QAASC,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EAWGC,EACV,SAAO,CAKN,QAASL,EAAU,SAAS,EAM5B,SAAUC,CACZ,CAAC,EACA,OAAO,EFlEH,IAAMK,EAA4CC,GAEpD,SAAO,CAIN,WAAYC,EAKZ,IAAKC,EAKL,KAAMF,CACR,CAAC,EACA,OAAO,EAYCG,EAAwBC,EAAkBL,EAAiBM,CAAe,CAAC,EAa3EC,EAA4BF,EAA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BD,EAA6BC,CAAC,CAChC,CACF",
|
|
6
|
+
"names": ["z", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "z", "DocUpsertSchema", "DocSchema", "ProposedDocSchema", "RawDataSchema", "DocDescriptionSchema", "VersionSchema", "DocAssertSetSchema", "DocContextSchema", "dataSchema", "CollectionSchema", "KeySchema", "OnSetDocContextSchema", "HookContextSchema", "DocUpsertSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "z", "SatelliteEnvSchema", "OnAssertSchema", "contextSchema", "CollectionsSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsSchema", "OnSetDocSchema", "OnSetDocContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/functions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "
|
|
9
|
-
"module": "
|
|
10
|
-
"types": "
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"module": "index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"import": "./index.js"
|
|
15
|
+
},
|
|
16
|
+
"./sdk": {
|
|
17
|
+
"types": "./sdk.d.ts",
|
|
18
|
+
"import": "./sdk.js"
|
|
19
|
+
},
|
|
20
|
+
"./ic-cdk": {
|
|
21
|
+
"types": "./ic-cdk.d.ts",
|
|
22
|
+
"import": "./ic-cdk.js"
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
25
|
"files": [
|
|
20
|
-
"dist",
|
|
21
26
|
"README.md",
|
|
22
|
-
"LICENSE"
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"**/*.js",
|
|
29
|
+
"**/*.js.map",
|
|
30
|
+
"**/*.d.ts",
|
|
31
|
+
"**/*.d.ts.map"
|
|
23
32
|
],
|
|
24
33
|
"scripts": {
|
|
25
|
-
"
|
|
26
|
-
"ts-declaration": "tsc --emitDeclarationOnly
|
|
27
|
-
"build": "npm run
|
|
34
|
+
"clean": "git ls-files --others --ignored --exclude-standard | grep -v \"LICENSE\" | xargs rm -rf",
|
|
35
|
+
"ts-declaration": "tsc --emitDeclarationOnly -outDir . && cp -R src/*.d.ts ./",
|
|
36
|
+
"build": "npm run clean && tsc --noEmit && node esbuild.mjs && npm run ts-declaration",
|
|
28
37
|
"prepack": "npm run build"
|
|
29
38
|
},
|
|
30
39
|
"repository": {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* @see RawPrincipal
|
|
4
|
+
*/
|
|
5
|
+
export declare const RawPrincipalSchema: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
6
|
+
/**
|
|
7
|
+
* Represents a raw principal identifier.
|
|
8
|
+
*
|
|
9
|
+
* Principals are unique identities used in authentication and authorization.
|
|
10
|
+
*/
|
|
11
|
+
export type RawPrincipal = z.infer<typeof RawPrincipalSchema>;
|
|
@@ -29,16 +29,6 @@ export declare const RawDataSchema: z.ZodType<Uint8Array<ArrayBufferLike>, z.Zod
|
|
|
29
29
|
* This is used to store unstructured data in a document.
|
|
30
30
|
*/
|
|
31
31
|
export type RawData = z.infer<typeof RawDataSchema>;
|
|
32
|
-
/**
|
|
33
|
-
* @see RawPrincipal
|
|
34
|
-
*/
|
|
35
|
-
export declare const RawPrincipalSchema: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
36
|
-
/**
|
|
37
|
-
* Represents a raw principal identifier.
|
|
38
|
-
*
|
|
39
|
-
* Principals are unique identities used in authentication and authorization.
|
|
40
|
-
*/
|
|
41
|
-
export type RawPrincipal = z.infer<typeof RawPrincipalSchema>;
|
|
42
32
|
/**
|
|
43
33
|
* @see RawUserId
|
|
44
34
|
*/
|
|
@@ -49,3 +39,19 @@ export declare const RawUserIdSchema: z.ZodType<Uint8Array<ArrayBufferLike>, z.Z
|
|
|
49
39
|
* This is a principal associated with a user.
|
|
50
40
|
*/
|
|
51
41
|
export type RawUserId = z.infer<typeof RawUserIdSchema>;
|
|
42
|
+
/**
|
|
43
|
+
* @see Collection
|
|
44
|
+
*/
|
|
45
|
+
export declare const CollectionSchema: z.ZodString;
|
|
46
|
+
/**
|
|
47
|
+
* A collection name where data are stored.
|
|
48
|
+
*/
|
|
49
|
+
export type Collection = z.infer<typeof CollectionSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* @see Key
|
|
52
|
+
*/
|
|
53
|
+
export declare const KeySchema: z.ZodString;
|
|
54
|
+
/**
|
|
55
|
+
* A unique key identifier within a collection.
|
|
56
|
+
*/
|
|
57
|
+
export type Key = z.infer<typeof KeySchema>;
|
package/schemas/db.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* @see DocDescription
|
|
4
|
+
*/
|
|
5
|
+
export declare const DocDescriptionSchema: z.ZodString;
|
|
6
|
+
/**
|
|
7
|
+
* Represents a document description with a maximum length of 1024 characters.
|
|
8
|
+
*/
|
|
9
|
+
export type DocDescription = z.infer<typeof DocDescriptionSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* @see Doc
|
|
12
|
+
*/
|
|
13
|
+
export declare const DocSchema: z.ZodObject<{
|
|
14
|
+
/**
|
|
15
|
+
* The user who owns this document.
|
|
16
|
+
*/
|
|
17
|
+
owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
18
|
+
/**
|
|
19
|
+
* The raw data of the document.
|
|
20
|
+
*/
|
|
21
|
+
data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
|
|
22
|
+
/**
|
|
23
|
+
* An optional description of the document.
|
|
24
|
+
*/
|
|
25
|
+
description: z.ZodOptional<z.ZodString>;
|
|
26
|
+
/**
|
|
27
|
+
* The timestamp when the document was first created.
|
|
28
|
+
*/
|
|
29
|
+
created_at: z.ZodBigInt;
|
|
30
|
+
/**
|
|
31
|
+
* The timestamp when the document was last updated.
|
|
32
|
+
*/
|
|
33
|
+
updated_at: z.ZodBigInt;
|
|
34
|
+
/**
|
|
35
|
+
* The version number of the document, used for consistency checks.
|
|
36
|
+
* If not provided, it's assumed to be the first version.
|
|
37
|
+
*/
|
|
38
|
+
version: z.ZodOptional<z.ZodBigInt>;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
owner: Uint8Array<ArrayBufferLike>;
|
|
41
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
42
|
+
created_at: bigint;
|
|
43
|
+
updated_at: bigint;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
version?: bigint | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
owner: Uint8Array<ArrayBufferLike>;
|
|
48
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
49
|
+
created_at: bigint;
|
|
50
|
+
updated_at: bigint;
|
|
51
|
+
description?: string | undefined;
|
|
52
|
+
version?: bigint | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Represents a document stored in a collection.
|
|
56
|
+
*/
|
|
57
|
+
export type Doc = z.infer<typeof DocSchema>;
|
package/sdk/db.sdk.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SetDocStoreParams } from './schemas/db';
|
|
2
|
+
/**
|
|
3
|
+
* Stores or updates a document in the datastore.
|
|
4
|
+
*
|
|
5
|
+
* The data must have been encoded - using encodeDocData - before calling this function.
|
|
6
|
+
*
|
|
7
|
+
* @param {SetDocStoreParams} params - The parameters required to store the document,
|
|
8
|
+
* including the caller, collection, key, and document data.
|
|
9
|
+
*
|
|
10
|
+
* @throws {z.ZodError} If the provided parameters do not match the expected schema.
|
|
11
|
+
* @throws {Error} If the Satellite fails at validating the submitted document before storing it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const setDocStore: (params: SetDocStoreParams) => void;
|