@junobuild/functions 0.0.13 → 0.0.14
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 +217 -26
- package/{chunk-6G6FWQ45.js → chunk-367GY4VX.js} +1 -1
- package/chunk-367GY4VX.js.map +7 -0
- package/global.d.ts +12 -0
- package/hooks/assertions.d.ts +40 -40
- package/hooks/schemas/db/context.d.ts +1 -1
- package/hooks/schemas/storage/context.d.ts +12 -12
- package/hooks/schemas/storage/payload.d.ts +4 -4
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/satellite.d.ts +1 -1
- package/schemas/storage.d.ts +2 -2
- package/sdk/controllers.sdk.d.ts +39 -0
- package/sdk/schemas/controllers.d.ts +174 -0
- package/sdk/schemas/db.d.ts +1 -1
- package/sdk/utils/caller.utils.d.ts +10 -0
- package/sdk.d.ts +2 -0
- package/sdk.js +1 -1
- package/sdk.js.map +4 -4
- package/src/global.d.ts +12 -0
- package/tests/mocks/controllers.mocks.d.ts +4 -0
- package/chunk-6G6FWQ45.js.map +0 -7
|
@@ -1167,6 +1167,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1167
1167
|
expires_at: z.ZodBigInt;
|
|
1168
1168
|
encoding_type: z.ZodOptional<z.ZodString>;
|
|
1169
1169
|
}, "strict", z.ZodTypeAny, {
|
|
1170
|
+
expires_at: bigint;
|
|
1170
1171
|
key: {
|
|
1171
1172
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1172
1173
|
collection: string;
|
|
@@ -1175,10 +1176,10 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1175
1176
|
description?: string | undefined;
|
|
1176
1177
|
token?: string | undefined;
|
|
1177
1178
|
};
|
|
1178
|
-
expires_at: bigint;
|
|
1179
1179
|
reference_id?: bigint | undefined;
|
|
1180
1180
|
encoding_type?: string | undefined;
|
|
1181
1181
|
}, {
|
|
1182
|
+
expires_at: bigint;
|
|
1182
1183
|
key: {
|
|
1183
1184
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1184
1185
|
collection: string;
|
|
@@ -1187,7 +1188,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1187
1188
|
description?: string | undefined;
|
|
1188
1189
|
token?: string | undefined;
|
|
1189
1190
|
};
|
|
1190
|
-
expires_at: bigint;
|
|
1191
1191
|
reference_id?: bigint | undefined;
|
|
1192
1192
|
encoding_type?: string | undefined;
|
|
1193
1193
|
}>;
|
|
@@ -1206,6 +1206,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1206
1206
|
}>;
|
|
1207
1207
|
}, "strict", z.ZodTypeAny, {
|
|
1208
1208
|
batch: {
|
|
1209
|
+
expires_at: bigint;
|
|
1209
1210
|
key: {
|
|
1210
1211
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1211
1212
|
collection: string;
|
|
@@ -1214,7 +1215,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1214
1215
|
description?: string | undefined;
|
|
1215
1216
|
token?: string | undefined;
|
|
1216
1217
|
};
|
|
1217
|
-
expires_at: bigint;
|
|
1218
1218
|
reference_id?: bigint | undefined;
|
|
1219
1219
|
encoding_type?: string | undefined;
|
|
1220
1220
|
};
|
|
@@ -1245,6 +1245,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1245
1245
|
} | undefined;
|
|
1246
1246
|
}, {
|
|
1247
1247
|
batch: {
|
|
1248
|
+
expires_at: bigint;
|
|
1248
1249
|
key: {
|
|
1249
1250
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1250
1251
|
collection: string;
|
|
@@ -1253,7 +1254,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1253
1254
|
description?: string | undefined;
|
|
1254
1255
|
token?: string | undefined;
|
|
1255
1256
|
};
|
|
1256
|
-
expires_at: bigint;
|
|
1257
1257
|
reference_id?: bigint | undefined;
|
|
1258
1258
|
encoding_type?: string | undefined;
|
|
1259
1259
|
};
|
|
@@ -1395,6 +1395,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1395
1395
|
expires_at: z.ZodBigInt;
|
|
1396
1396
|
encoding_type: z.ZodOptional<z.ZodString>;
|
|
1397
1397
|
}, "strict", z.ZodTypeAny, {
|
|
1398
|
+
expires_at: bigint;
|
|
1398
1399
|
key: {
|
|
1399
1400
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1400
1401
|
collection: string;
|
|
@@ -1403,10 +1404,10 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1403
1404
|
description?: string | undefined;
|
|
1404
1405
|
token?: string | undefined;
|
|
1405
1406
|
};
|
|
1406
|
-
expires_at: bigint;
|
|
1407
1407
|
reference_id?: bigint | undefined;
|
|
1408
1408
|
encoding_type?: string | undefined;
|
|
1409
1409
|
}, {
|
|
1410
|
+
expires_at: bigint;
|
|
1410
1411
|
key: {
|
|
1411
1412
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1412
1413
|
collection: string;
|
|
@@ -1415,7 +1416,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1415
1416
|
description?: string | undefined;
|
|
1416
1417
|
token?: string | undefined;
|
|
1417
1418
|
};
|
|
1418
|
-
expires_at: bigint;
|
|
1419
1419
|
reference_id?: bigint | undefined;
|
|
1420
1420
|
encoding_type?: string | undefined;
|
|
1421
1421
|
}>;
|
|
@@ -1434,6 +1434,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1434
1434
|
}>;
|
|
1435
1435
|
}, "strict", z.ZodTypeAny, {
|
|
1436
1436
|
batch: {
|
|
1437
|
+
expires_at: bigint;
|
|
1437
1438
|
key: {
|
|
1438
1439
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1439
1440
|
collection: string;
|
|
@@ -1442,7 +1443,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1442
1443
|
description?: string | undefined;
|
|
1443
1444
|
token?: string | undefined;
|
|
1444
1445
|
};
|
|
1445
|
-
expires_at: bigint;
|
|
1446
1446
|
reference_id?: bigint | undefined;
|
|
1447
1447
|
encoding_type?: string | undefined;
|
|
1448
1448
|
};
|
|
@@ -1473,6 +1473,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1473
1473
|
} | undefined;
|
|
1474
1474
|
}, {
|
|
1475
1475
|
batch: {
|
|
1476
|
+
expires_at: bigint;
|
|
1476
1477
|
key: {
|
|
1477
1478
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1478
1479
|
collection: string;
|
|
@@ -1481,7 +1482,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1481
1482
|
description?: string | undefined;
|
|
1482
1483
|
token?: string | undefined;
|
|
1483
1484
|
};
|
|
1484
|
-
expires_at: bigint;
|
|
1485
1485
|
reference_id?: bigint | undefined;
|
|
1486
1486
|
encoding_type?: string | undefined;
|
|
1487
1487
|
};
|
|
@@ -1623,6 +1623,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1623
1623
|
expires_at: z.ZodBigInt;
|
|
1624
1624
|
encoding_type: z.ZodOptional<z.ZodString>;
|
|
1625
1625
|
}, "strict", z.ZodTypeAny, {
|
|
1626
|
+
expires_at: bigint;
|
|
1626
1627
|
key: {
|
|
1627
1628
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1628
1629
|
collection: string;
|
|
@@ -1631,10 +1632,10 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1631
1632
|
description?: string | undefined;
|
|
1632
1633
|
token?: string | undefined;
|
|
1633
1634
|
};
|
|
1634
|
-
expires_at: bigint;
|
|
1635
1635
|
reference_id?: bigint | undefined;
|
|
1636
1636
|
encoding_type?: string | undefined;
|
|
1637
1637
|
}, {
|
|
1638
|
+
expires_at: bigint;
|
|
1638
1639
|
key: {
|
|
1639
1640
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1640
1641
|
collection: string;
|
|
@@ -1643,7 +1644,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1643
1644
|
description?: string | undefined;
|
|
1644
1645
|
token?: string | undefined;
|
|
1645
1646
|
};
|
|
1646
|
-
expires_at: bigint;
|
|
1647
1647
|
reference_id?: bigint | undefined;
|
|
1648
1648
|
encoding_type?: string | undefined;
|
|
1649
1649
|
}>;
|
|
@@ -1662,6 +1662,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1662
1662
|
}>;
|
|
1663
1663
|
}, "strict", z.ZodTypeAny, {
|
|
1664
1664
|
batch: {
|
|
1665
|
+
expires_at: bigint;
|
|
1665
1666
|
key: {
|
|
1666
1667
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1667
1668
|
collection: string;
|
|
@@ -1670,7 +1671,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1670
1671
|
description?: string | undefined;
|
|
1671
1672
|
token?: string | undefined;
|
|
1672
1673
|
};
|
|
1673
|
-
expires_at: bigint;
|
|
1674
1674
|
reference_id?: bigint | undefined;
|
|
1675
1675
|
encoding_type?: string | undefined;
|
|
1676
1676
|
};
|
|
@@ -1701,6 +1701,7 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1701
1701
|
} | undefined;
|
|
1702
1702
|
}, {
|
|
1703
1703
|
batch: {
|
|
1704
|
+
expires_at: bigint;
|
|
1704
1705
|
key: {
|
|
1705
1706
|
owner: Uint8Array<ArrayBufferLike>;
|
|
1706
1707
|
collection: string;
|
|
@@ -1709,7 +1710,6 @@ export declare const AssertUploadAssetContextSchema: z.ZodObject<{
|
|
|
1709
1710
|
description?: string | undefined;
|
|
1710
1711
|
token?: string | undefined;
|
|
1711
1712
|
};
|
|
1712
|
-
expires_at: bigint;
|
|
1713
1713
|
reference_id?: bigint | undefined;
|
|
1714
1714
|
encoding_type?: string | undefined;
|
|
1715
1715
|
};
|
|
@@ -113,6 +113,7 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
113
113
|
expires_at: z.ZodBigInt;
|
|
114
114
|
encoding_type: z.ZodOptional<z.ZodString>;
|
|
115
115
|
}, "strict", z.ZodTypeAny, {
|
|
116
|
+
expires_at: bigint;
|
|
116
117
|
key: {
|
|
117
118
|
owner: Uint8Array<ArrayBufferLike>;
|
|
118
119
|
collection: string;
|
|
@@ -121,10 +122,10 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
121
122
|
description?: string | undefined;
|
|
122
123
|
token?: string | undefined;
|
|
123
124
|
};
|
|
124
|
-
expires_at: bigint;
|
|
125
125
|
reference_id?: bigint | undefined;
|
|
126
126
|
encoding_type?: string | undefined;
|
|
127
127
|
}, {
|
|
128
|
+
expires_at: bigint;
|
|
128
129
|
key: {
|
|
129
130
|
owner: Uint8Array<ArrayBufferLike>;
|
|
130
131
|
collection: string;
|
|
@@ -133,7 +134,6 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
133
134
|
description?: string | undefined;
|
|
134
135
|
token?: string | undefined;
|
|
135
136
|
};
|
|
136
|
-
expires_at: bigint;
|
|
137
137
|
reference_id?: bigint | undefined;
|
|
138
138
|
encoding_type?: string | undefined;
|
|
139
139
|
}>;
|
|
@@ -152,6 +152,7 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
152
152
|
}>;
|
|
153
153
|
}, "strict", z.ZodTypeAny, {
|
|
154
154
|
batch: {
|
|
155
|
+
expires_at: bigint;
|
|
155
156
|
key: {
|
|
156
157
|
owner: Uint8Array<ArrayBufferLike>;
|
|
157
158
|
collection: string;
|
|
@@ -160,7 +161,6 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
160
161
|
description?: string | undefined;
|
|
161
162
|
token?: string | undefined;
|
|
162
163
|
};
|
|
163
|
-
expires_at: bigint;
|
|
164
164
|
reference_id?: bigint | undefined;
|
|
165
165
|
encoding_type?: string | undefined;
|
|
166
166
|
};
|
|
@@ -191,6 +191,7 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
191
191
|
} | undefined;
|
|
192
192
|
}, {
|
|
193
193
|
batch: {
|
|
194
|
+
expires_at: bigint;
|
|
194
195
|
key: {
|
|
195
196
|
owner: Uint8Array<ArrayBufferLike>;
|
|
196
197
|
collection: string;
|
|
@@ -199,7 +200,6 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
199
200
|
description?: string | undefined;
|
|
200
201
|
token?: string | undefined;
|
|
201
202
|
};
|
|
202
|
-
expires_at: bigint;
|
|
203
203
|
reference_id?: bigint | undefined;
|
|
204
204
|
encoding_type?: string | undefined;
|
|
205
205
|
};
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x,b as g,c as y,d as ue,e as A,f as j,g as U,h as ze,i as s,j as ke,k as _,l as M}from"./chunk-
|
|
1
|
+
import{a as x,b as g,c as y,d as ue,e as A,f as j,g as U,h as ze,i as s,j as ke,k as _,l as M}from"./chunk-367GY4VX.js";import{a as F,b as fe,c as Te}from"./chunk-CCKUQNB5.js";import*as m from"zod";import*as a from"zod";var D=a.object({collections:a.array(a.string()).readonly()}).strict();import*as n from"zod";var o=e=>n.object({caller:y,data:e}).strict(),I=e=>n.function().args(e).returns(n.void()),B=e=>n.function().args(e).returns(n.promise(n.void()).or(n.void()));import*as i from"zod";import*as d from"zod";var u=d.object({before:s.optional(),after:s}).strict(),Z=d.object({current:s.optional(),proposed:_}).strict(),R=d.object({current:s.optional(),proposed:M}).strict();var p=e=>i.object({collection:A,key:j,data:e}).strict(),v=o(p(u)),E=o(i.array(p(u))),z=o(p(s.optional())),k=o(i.array(p(s.optional()))),b=o(i.array(p(s.optional()))),w=o(p(Z)),K=o(p(R));import*as h from"zod";var S=h.record(h.unknown());import*as H from"zod";import*as t from"zod";var V=t.tuple([t.string(),t.string()]),ee=F,te=ee,oe=t.instanceof(Uint8Array).refine(e=>e.length===32,{message:"Hash must be a Uint8Array of length 32"}),J=t.object({name:t.string(),full_path:t.string(),token:t.string().optional(),collection:A,owner:y,description:U.optional()}),ne=t.object({modified:x,content_chunks:t.array(te),total_length:t.bigint(),sha256:oe}),c=t.object({key:J,headers:t.array(V),encodings:t.record(ne),created_at:x,updated_at:x,version:g.optional()}).strict(),se=t.string(),re=t.bigint(),N=t.object({key:J,reference_id:re.optional(),expires_at:x,encoding_type:se.optional()}).strict(),ce=t.bigint(),pe=t.bigint(),P=t.object({batch_id:pe,headers:t.array(V),chunk_ids:t.array(ce)}).strict();import*as q from"zod";var G=q.object({current:c.optional(),batch:N,commit_batch:P}).strict();var L=o(c),Q=o(c.optional()),W=o(H.array(c.optional())),X=o(H.array(c.optional())),Y=o(G),$=o(c);var O=e=>D.extend({assert:I(e)}).strict(),ae=O(w),ie=O(K),xe=O(Y),me=O($),Ye=m.union([ae,ie,xe,me]),le=e=>m.function().args(S).returns(e),$e=e=>m.union([e,le(e)]);function et(e){return e}import*as l from"zod";var r=e=>D.extend({run:B(e)}).strict(),ye=r(v),Ae=r(E),mt=r(z),lt=r(k),yt=r(b),De=r(L),de=r(Q),he=r(W),Se=r(X),At=l.union([ye,Ae,z,k,b,De,de,he,Se]),Oe=e=>l.function().args(S).returns(e),Dt=e=>l.union([e,Oe(e)]);function dt(e){return e}import{jsonReplacer as Ce}from"@dfinity/utils";var C=e=>{let f=e.map(T=>typeof T=="object"?JSON.stringify(T,Ce):T).join(" ");globalThis.__ic_cdk_print(f)};globalThis.console={info(...e){C(e)},log(...e){C(e)},warn(...e){C(e)},error(...e){C(e)}};export{$ as AssertDeleteAssetContextSchema,me as AssertDeleteAssetSchema,K as AssertDeleteDocContextSchema,ie as AssertDeleteDocSchema,$e as AssertFnOrObjectSchema,le as AssertFnSchema,I as AssertFunctionSchema,Ye as AssertSchema,w as AssertSetDocContextSchema,ae as AssertSetDocSchema,Y as AssertUploadAssetContextSchema,xe as AssertUploadAssetSchema,G as AssetAssertUploadSchema,c as AssetSchema,N as BatchSchema,A as CollectionSchema,D as CollectionsSchema,P as CommitBatchSchema,M as DelDocSchema,U as DescriptionSchema,R as DocAssertDeleteSchema,Z as DocAssertSetSchema,p as DocContextSchema,s as DocSchema,u as DocUpsertSchema,o as HookContextSchema,Dt as HookFnOrObjectSchema,Oe as HookFnSchema,At as HookSchema,j as KeySchema,Q as OnDeleteAssetContextSchema,de as OnDeleteAssetSchema,z as OnDeleteDocContextSchema,mt as OnDeleteDocSchema,X as OnDeleteFilteredAssetsContextSchema,Se as OnDeleteFilteredAssetsSchema,b as OnDeleteFilteredDocsContextSchema,yt as OnDeleteFilteredDocsSchema,W as OnDeleteManyAssetsContextSchema,he as OnDeleteManyAssetsSchema,k as OnDeleteManyDocsContextSchema,lt as OnDeleteManyDocsSchema,v as OnSetDocContextSchema,ye as OnSetDocSchema,E as OnSetManyDocsContextSchema,Ae as OnSetManyDocsSchema,L as OnUploadAssetContextSchema,De as OnUploadAssetSchema,ke as OptionDocSchema,Te as PrincipalSchema,ze as RawDataSchema,fe as RawPrincipalSchema,y as RawUserIdSchema,B as RunFunctionSchema,S as SatelliteEnvSchema,_ as SetDocSchema,x as TimestampSchema,F as Uint8ArraySchema,ue as UserIdSchema,g as VersionSchema,et as defineAssert,dt as defineHook};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/hooks/assertions.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/schemas/storage/context.ts", "src/schemas/storage.ts", "src/hooks/schemas/storage/payload.ts", "src/hooks/hooks.ts", "src/polyfills/console.polyfill.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function().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';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import type {baseObjectInputType, baseObjectOutputType, ZodObject, ZodTypeAny} from 'zod';\nimport * as z from 'zod';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n // TODO: workaround for https://github.com/colinhacks/zod/issues/3998\n return z.object(schemaShape).strict() as ZodObject<\n typeof schemaShape,\n 'strict',\n ZodTypeAny,\n baseObjectOutputType<typeof schemaShape>,\n baseObjectInputType<typeof schemaShape>\n >;\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.void());\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.promise(z.void()).or(z.void()));\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import type {baseObjectInputType, baseObjectOutputType, ZodObject, ZodTypeAny} from 'zod';\nimport * as z from 'zod';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n // TODO: workaround for https://github.com/colinhacks/zod/issues/3998\n return z.object(schemaShape).strict() as ZodObject<\n typeof schemaShape,\n 'strict',\n ZodTypeAny,\n baseObjectOutputType<typeof schemaShape>,\n baseObjectInputType<typeof schemaShape>\n >;\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The unique key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.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 {Asset, AssetSchema} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see Blob\n */\nconst BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nconst AssetKeySchema = z.object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n});\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nconst AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: z.array(HeaderFieldSchema),\n encodings: z.record(AssetEncodingSchema),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: Record<string, AssetEncoding>;\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.string();\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = string;\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: z.array(HeaderFieldSchema),\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n", "import * as z from 'zod';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function().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"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function().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';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import type {baseObjectInputType, baseObjectOutputType, ZodObject, ZodTypeAny} from 'zod';\nimport * as z from 'zod';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n // TODO: workaround for https://github.com/colinhacks/zod/issues/3998\n return z.object(schemaShape).strict() as ZodObject<\n typeof schemaShape,\n 'strict',\n ZodTypeAny,\n baseObjectOutputType<typeof schemaShape>,\n baseObjectInputType<typeof schemaShape>\n >;\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.void());\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.promise(z.void()).or(z.void()));\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import type {baseObjectInputType, baseObjectOutputType, ZodObject, ZodTypeAny} from 'zod';\nimport * as z from 'zod';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n // TODO: workaround for https://github.com/colinhacks/zod/issues/3998\n return z.object(schemaShape).strict() as ZodObject<\n typeof schemaShape,\n 'strict',\n ZodTypeAny,\n baseObjectOutputType<typeof schemaShape>,\n baseObjectInputType<typeof schemaShape>\n >;\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.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 {Asset, AssetSchema} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see Blob\n */\nconst BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nconst AssetKeySchema = z.object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n});\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nconst AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: z.array(HeaderFieldSchema),\n encodings: z.record(AssetEncodingSchema),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: Record<string, AssetEncoding>;\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.string();\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = string;\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: z.array(HeaderFieldSchema),\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n", "import * as z from 'zod';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function().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
5
|
"mappings": "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",
|
|
6
6
|
"names": ["z", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "AssertFunctionSchema", "contextSchema", "RunFunctionSchema", "z", "z", "DocUpsertSchema", "DocSchema", "DocAssertSetSchema", "SetDocSchema", "DocAssertDeleteSchema", "DelDocSchema", "DocContextSchema", "dataSchema", "CollectionSchema", "KeySchema", "OnSetDocContextSchema", "HookContextSchema", "DocUpsertSchema", "OnSetManyDocsContextSchema", "OnDeleteDocContextSchema", "DocSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsContextSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "AssertDeleteDocContextSchema", "DocAssertDeleteSchema", "z", "SatelliteEnvSchema", "z", "z", "HeaderFieldSchema", "BlobSchema", "Uint8ArraySchema", "BlobOrKeySchema", "HashSchema", "val", "AssetKeySchema", "CollectionSchema", "RawUserIdSchema", "DescriptionSchema", "AssetEncodingSchema", "TimestampSchema", "AssetSchema", "VersionSchema", "EncodingTypeSchema", "ReferenceIdSchema", "BatchSchema", "ChunkIdSchema", "BatchIdSchema", "CommitBatchSchema", "z", "AssetAssertUploadSchema", "AssetSchema", "BatchSchema", "CommitBatchSchema", "OnUploadAssetContextSchema", "HookContextSchema", "AssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsContextSchema", "AssertUploadAssetContextSchema", "AssetAssertUploadSchema", "AssertDeleteAssetContextSchema", "OnAssertSchema", "contextSchema", "CollectionsSchema", "AssertFunctionSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertDeleteDocSchema", "AssertDeleteDocContextSchema", "AssertUploadAssetSchema", "AssertUploadAssetContextSchema", "AssertDeleteAssetSchema", "AssertDeleteAssetContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsSchema", "RunFunctionSchema", "OnSetDocSchema", "OnSetDocContextSchema", "OnSetManyDocsSchema", "OnSetManyDocsContextSchema", "OnDeleteDocSchema", "OnDeleteDocContextSchema", "OnDeleteManyDocsSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsSchema", "OnDeleteFilteredDocsContextSchema", "OnUploadAssetSchema", "OnUploadAssetContextSchema", "OnDeleteAssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsSchema", "OnDeleteFilteredAssetsContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg"]
|
|
7
7
|
}
|
package/package.json
CHANGED
package/schemas/satellite.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type Collection = z.infer<typeof CollectionSchema>;
|
|
|
52
52
|
*/
|
|
53
53
|
export declare const KeySchema: z.ZodString;
|
|
54
54
|
/**
|
|
55
|
-
* A
|
|
55
|
+
* A key identifier within a collection.
|
|
56
56
|
*/
|
|
57
57
|
export type Key = z.infer<typeof KeySchema>;
|
|
58
58
|
/**
|
package/schemas/storage.d.ts
CHANGED
|
@@ -219,6 +219,7 @@ export declare const BatchSchema: z.ZodObject<{
|
|
|
219
219
|
expires_at: z.ZodBigInt;
|
|
220
220
|
encoding_type: z.ZodOptional<z.ZodString>;
|
|
221
221
|
}, "strict", z.ZodTypeAny, {
|
|
222
|
+
expires_at: bigint;
|
|
222
223
|
key: {
|
|
223
224
|
owner: Uint8Array<ArrayBufferLike>;
|
|
224
225
|
collection: string;
|
|
@@ -227,10 +228,10 @@ export declare const BatchSchema: z.ZodObject<{
|
|
|
227
228
|
description?: string | undefined;
|
|
228
229
|
token?: string | undefined;
|
|
229
230
|
};
|
|
230
|
-
expires_at: bigint;
|
|
231
231
|
reference_id?: bigint | undefined;
|
|
232
232
|
encoding_type?: string | undefined;
|
|
233
233
|
}, {
|
|
234
|
+
expires_at: bigint;
|
|
234
235
|
key: {
|
|
235
236
|
owner: Uint8Array<ArrayBufferLike>;
|
|
236
237
|
collection: string;
|
|
@@ -239,7 +240,6 @@ export declare const BatchSchema: z.ZodObject<{
|
|
|
239
240
|
description?: string | undefined;
|
|
240
241
|
token?: string | undefined;
|
|
241
242
|
};
|
|
242
|
-
expires_at: bigint;
|
|
243
243
|
reference_id?: bigint | undefined;
|
|
244
244
|
encoding_type?: string | undefined;
|
|
245
245
|
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ControllerCheckParams, Controllers } from './schemas/controllers';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the list of admin controllers from the Satellite.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Controllers} The list of admin controllers.
|
|
6
|
+
*
|
|
7
|
+
* @throws {z.ZodError} If the returned value does not match the expected schema.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAdminControllers: () => Controllers;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the list of controllers from the Satellite.
|
|
12
|
+
*
|
|
13
|
+
* @returns {Controllers} The list of all controllers.
|
|
14
|
+
*
|
|
15
|
+
* @throws {z.ZodError} If the returned value does not match the expected schema.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getControllers: () => Controllers;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the given caller is an admin among the provided controllers.
|
|
20
|
+
*
|
|
21
|
+
* @param {ControllerCheckParams} params - The parameters including the caller identity
|
|
22
|
+
* and the list of controllers to verify against.
|
|
23
|
+
*
|
|
24
|
+
* @returns {boolean} Whether the caller is an admin.
|
|
25
|
+
*
|
|
26
|
+
* @throws {z.ZodError} If any input does not match the expected schema.
|
|
27
|
+
*/
|
|
28
|
+
export declare const isAdminController: (params: ControllerCheckParams) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the given caller exists among the provided controllers.
|
|
31
|
+
*
|
|
32
|
+
* @param {ControllerCheckParams} params - The parameters including the caller identity
|
|
33
|
+
* and the list of controllers to verify against.
|
|
34
|
+
*
|
|
35
|
+
* @returns {boolean} Whether the caller is a controller.
|
|
36
|
+
*
|
|
37
|
+
* @throws {z.ZodError} If any input does not match the expected schema.
|
|
38
|
+
*/
|
|
39
|
+
export declare const isController: (params: ControllerCheckParams) => boolean;
|