@junobuild/functions 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +994 -213
- package/chunk-6G6FWQ45.js +2 -0
- package/chunk-6G6FWQ45.js.map +7 -0
- package/global.d.ts +11 -6
- package/hooks/assertions.d.ts +7149 -0
- package/hooks/hooks.d.ts +10529 -0
- package/hooks/schemas/collections.d.ts +8 -5
- package/hooks/schemas/context.d.ts +13 -21
- package/hooks/schemas/db/context.d.ts +2119 -247
- package/hooks/schemas/db/payload.d.ts +96 -52
- package/hooks/schemas/storage/context.d.ts +2010 -0
- package/hooks/schemas/storage/payload.d.ts +248 -0
- package/ic-cdk/schemas/call.d.ts +23 -16
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +2 -2
- package/index.d.ts +5 -2
- package/index.js +1 -1
- package/index.js.map +4 -4
- package/package.json +1 -1
- package/schemas/db.d.ts +98 -15
- package/schemas/satellite.d.ts +9 -0
- package/schemas/storage.d.ts +307 -0
- package/sdk/db.sdk.d.ts +11 -1
- package/sdk/schemas/db.d.ts +66 -61
- package/sdk.js +1 -1
- package/sdk.js.map +3 -3
- package/src/global.d.ts +11 -6
- package/chunk-LVVTFR6B.js +0 -2
- package/chunk-LVVTFR6B.js.map +0 -7
- package/hooks/db/assertions.d.ts +0 -2127
- package/hooks/db/hooks.d.ts +0 -2577
package/sdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/sdk/db.sdk.ts", "src/sdk/schemas/db.ts", "src/sdk/serializer.sdk.ts"],
|
|
4
|
-
"sourcesContent": ["import {Principal} from '@dfinity/principal';\nimport {SetDocStoreParams
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Principal", "z", "
|
|
4
|
+
"sourcesContent": ["import {Principal} from '@dfinity/principal';\nimport {\n DeleteDocStoreParams,\n DeleteDocStoreParamsSchema,\n SetDocStoreParams,\n SetDocStoreParamsSchema\n} from './schemas/db';\n\n/**\n * Stores or updates a document in the datastore.\n *\n * The data must have been encoded - using encodeDocData - before calling this function.\n *\n * @param {SetDocStoreParams} params - The parameters required to store the document,\n * including the caller, collection, key, and document data.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails at validating the submitted document before storing it.\n */\nexport const setDocStore = (params: SetDocStoreParams) => {\n SetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller =\n providedCaller instanceof Principal ? providedCaller.toUint8Array() : providedCaller;\n\n __juno_satellite_datastore_set_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Delete a document in the datastore.\n *\n * @param {DeleteDocStoreParams} params - The parameters required to delete the document,\n * including the caller, collection, key, and version of the document.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails at validating the submitted request before deleting it.\n */\nexport const deleteDocStore = (params: DeleteDocStoreParams) => {\n DeleteDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller =\n providedCaller instanceof Principal ? providedCaller.toUint8Array() : providedCaller;\n\n __juno_satellite_datastore_delete_doc_store(caller, collection, key, doc);\n};\n", "import * as z from 'zod';\nimport {type DelDoc, DelDocSchema, type SetDoc, SetDocSchema} from '../../schemas/db';\nimport {\n type Collection,\n CollectionSchema,\n type Key,\n KeySchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see DocStoreParams\n */\nconst DocStoreParamsSchema = z.object({\n caller: RawUserIdSchema.or(UserIdSchema),\n collection: CollectionSchema,\n key: KeySchema\n});\n\n/**\n * Represents the base parameters required to access the datastore and modify a document.\n */\nexport interface DocStoreParams {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\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/**\n * @see SetDocStoreParams\n */\nexport const SetDocStoreParamsSchema = DocStoreParamsSchema.extend({\n doc: SetDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to store or update a document.\n *\n * This includes the document data along with metadata such as the caller,\n * collection, and key.\n */\nexport type SetDocStoreParams = DocStoreParams & {\n /**\n * The data, optional description and version required to create or update a document.\n */\n doc: SetDoc;\n};\n\n/**\n * @see DeleteDocStoreParams\n */\nexport const DeleteDocStoreParamsSchema = DocStoreParamsSchema.extend({\n doc: DelDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to delete a document.\n *\n * This includes the document version along with metadata such as the caller,\n * collection, and key.\n */\nexport type DeleteDocStoreParams = DocStoreParams & {\n /**\n * The version required to delete a document.\n */\n doc: DelDoc;\n};\n", "import {jsonReplacer, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../schemas/db';\n\n/**\n * Decodes the raw data of a document into a JavaScript object.\n *\n * @template T The expected type of the decoded object.\n * @param {RawData} data - The raw data to be decoded.\n * @returns {T} The parsed JavaScript object.\n */\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\n/**\n * Encodes a JavaScript object into a raw data format to be applied to a document.\n *\n * @template T The type of the object to be encoded.\n * @param {T} data - The data to be encoded.\n * @returns {RawData} The serialized raw data.\n */\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\n"],
|
|
5
|
+
"mappings": "uGAAA,OAAQ,aAAAA,MAAgB,qBCAxB,UAAYC,MAAO,MAgBnB,IAAMC,EAAyB,SAAO,CACpC,OAAQC,EAAgB,GAAGC,CAAY,EACvC,WAAYC,EACZ,IAAKC,CACP,CAAC,EAyBYC,EAA0BL,EAAqB,OAAO,CACjE,IAAKM,CACP,CAAC,EAAE,OAAO,EAkBGC,EAA6BP,EAAqB,OAAO,CACpE,IAAKQ,CACP,CAAC,EAAE,OAAO,EDhDH,IAAMC,EAAeC,GAA8B,CACxDC,EAAwB,MAAMD,CAAM,EAEpC,GAAM,CAAC,OAAQE,EAAgB,WAAAC,EAAY,IAAAC,EAAK,IAAAC,CAAG,EAAIL,EAEjDM,EACJJ,aAA0BK,EAAYL,EAAe,aAAa,EAAIA,EAExE,yCAAyCI,EAAQH,EAAYC,EAAKC,CAAG,CACvE,EAWaG,EAAkBR,GAAiC,CAC9DS,EAA2B,MAAMT,CAAM,EAEvC,GAAM,CAAC,OAAQE,EAAgB,WAAAC,EAAY,IAAAC,EAAK,IAAAC,CAAG,EAAIL,EAEjDM,EACJJ,aAA0BK,EAAYL,EAAe,aAAa,EAAIA,EAExE,4CAA4CI,EAAQH,EAAYC,EAAKC,CAAG,CAC1E,EEhDA,OAAQ,gBAAAK,EAAc,eAAAC,MAAkB,iBAUjC,IAAMC,EAAoBC,GAC/B,KAAK,MAAM,4CAA4CA,CAAI,EAAGF,CAAW,EAS9DG,EAAoBD,GAC/B,8CAA8C,KAAK,UAAUA,EAAMH,CAAY,CAAC",
|
|
6
|
+
"names": ["Principal", "z", "DocStoreParamsSchema", "RawUserIdSchema", "UserIdSchema", "CollectionSchema", "KeySchema", "SetDocStoreParamsSchema", "SetDocSchema", "DeleteDocStoreParamsSchema", "DelDocSchema", "setDocStore", "params", "SetDocStoreParamsSchema", "providedCaller", "collection", "key", "doc", "caller", "Principal", "deleteDocStore", "DeleteDocStoreParamsSchema", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData"]
|
|
7
7
|
}
|
package/src/global.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {RawData} from './schemas/db';
|
|
2
|
-
import type {RawPrincipal, RawUserId} from './schemas/satellite';
|
|
3
|
-
import type {SetDoc} from './sdk/schemas/db';
|
|
1
|
+
import type {DelDoc, RawData, SetDoc} from './schemas/db';
|
|
2
|
+
import type {Collection, Key, RawPrincipal, RawUserId} from './schemas/satellite';
|
|
4
3
|
|
|
5
4
|
declare global {
|
|
6
5
|
function __juno_satellite_datastore_raw_data_to_text(data: RawData): string;
|
|
@@ -8,9 +7,15 @@ declare global {
|
|
|
8
7
|
|
|
9
8
|
function __juno_satellite_datastore_set_doc_store(
|
|
10
9
|
caller: RawUserId,
|
|
11
|
-
collection:
|
|
12
|
-
key:
|
|
13
|
-
value:
|
|
10
|
+
collection: Collection,
|
|
11
|
+
key: Key,
|
|
12
|
+
value: SetDoc
|
|
13
|
+
): void;
|
|
14
|
+
function __juno_satellite_datastore_delete_doc_store(
|
|
15
|
+
caller: RawUserId,
|
|
16
|
+
collection: Collection,
|
|
17
|
+
key: Key,
|
|
18
|
+
value: DelDoc
|
|
14
19
|
): void;
|
|
15
20
|
|
|
16
21
|
function __ic_cdk_id(): RawPrincipal;
|
package/chunk-LVVTFR6B.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as r,b as a,c as p}from"./chunk-CCKUQNB5.js";import*as e from"zod";var o=e.bigint(),c=e.bigint(),i=a,h=p,S=e.string(),f=e.string();import*as t from"zod";var m=t.string().max(1024),n=r,d=t.object({owner:i,data:n,description:m.optional(),created_at:o,updated_at:o,version:c.optional()}).strict();export{o as a,c as b,i as c,h as d,S as e,f,m as g,n as h,d as i};
|
|
2
|
-
//# sourceMappingURL=chunk-LVVTFR6B.js.map
|
package/chunk-LVVTFR6B.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/schemas/satellite.ts", "src/schemas/db.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport {PrincipalSchema, RawPrincipalSchema} from './candid';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = z.infer<typeof RawUserIdSchema>;\n\n/**\n * @see UserId\n */\nexport const UserIdSchema = PrincipalSchema;\n\n/**\n * Represents a user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type UserId = z.infer<typeof UserIdSchema>;\n\n/**\n * @see Collection\n */\nexport const CollectionSchema = z.string();\n\n/**\n * A collection name where data are stored.\n */\nexport type Collection = z.infer<typeof CollectionSchema>;\n\n/**\n * @see Key\n */\nexport const KeySchema = z.string();\n\n/**\n * A unique key identifier within a collection.\n */\nexport type Key = z.infer<typeof KeySchema>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {RawUserIdSchema, TimestampSchema, VersionSchema} from './satellite';\n\n/**\n * @see DocDescription\n */\nexport const DocDescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a document description with a maximum length of 1024 characters.\n */\nexport type DocDescription = z.infer<typeof DocDescriptionSchema>;\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = Uint8ArraySchema;\n\n/**\n * Represents raw binary data.\n *\n * This is used to store structured data in a document.\n */\nexport type RawData = z.infer<typeof Uint8ArraySchema>;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n /**\n * The user who owns this document.\n */\n owner: RawUserIdSchema,\n\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 timestamp when the document was first created.\n */\n created_at: TimestampSchema,\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: TimestampSchema,\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport type Doc = z.infer<typeof DocSchema>;\n"],
|
|
5
|
-
"mappings": "sDAAA,UAAYA,MAAO,MAMZ,IAAMC,EAAoB,SAAO,EAY3BC,EAAkB,SAAO,EAYzBC,EAAkBC,EAYlBC,EAAeC,EAYfC,EAAqB,SAAO,EAU5BC,EAAc,SAAO,EChElC,UAAYC,MAAO,MAOZ,IAAMC,EAAyB,SAAO,EAAE,IAAI,IAAI,EAU1CC,EAAgBC,EAYhBC,EACV,SAAO,CAIN,MAAOC,EAKP,KAAMH,EAKN,YAAaD,EAAqB,SAAS,EAK3C,WAAYK,EAKZ,WAAYA,EAMZ,QAASC,EAAc,SAAS,CAClC,CAAC,EACA,OAAO",
|
|
6
|
-
"names": ["z", "TimestampSchema", "VersionSchema", "RawUserIdSchema", "RawPrincipalSchema", "UserIdSchema", "PrincipalSchema", "CollectionSchema", "KeySchema", "z", "DocDescriptionSchema", "RawDataSchema", "Uint8ArraySchema", "DocSchema", "RawUserIdSchema", "TimestampSchema", "VersionSchema"]
|
|
7
|
-
}
|