@learncard/learn-cloud-plugin 2.3.29 → 2.3.31

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/src/types.ts ADDED
@@ -0,0 +1,69 @@
1
+ import type { Filter } from '@learncard/learn-cloud-service';
2
+ import {
3
+ JWE,
4
+ JWKWithPrivateKey,
5
+ UnsignedVC,
6
+ VC,
7
+ VP,
8
+ PaginationResponseType,
9
+ PaginationOptionsType,
10
+ } from '@learncard/types';
11
+ import type { LearnCard, Plugin } from '@learncard/core';
12
+ import type { ProofOptions } from '@learncard/didkit-plugin';
13
+
14
+ /** @group LearnCloud Plugin */
15
+ export type LearnCloudPluginDependentMethods = {
16
+ createDagJwe: <T>(cleartext: T, recipients?: string[]) => Promise<JWE>;
17
+ decryptDagJwe: <T>(jwe: JWE, jwks?: JWKWithPrivateKey[]) => Promise<T>;
18
+ getDidAuthVp: (options?: ProofOptions) => Promise<VP | string>;
19
+ issueCredential: (
20
+ credential: UnsignedVC,
21
+ signingOptions?: Partial<ProofOptions>
22
+ ) => Promise<VC>;
23
+ crypto: () => Crypto;
24
+ hash?: (message: string, algorithm?: string) => Promise<string | undefined>;
25
+ };
26
+
27
+ /** @group LearnCloud Plugin */
28
+ export type LearnCloudPluginMethods = {
29
+ learnCloudCreate: <Document extends Record<string, any>>(
30
+ document: Document
31
+ ) => Promise<boolean>;
32
+ learnCloudCreateMany: <Document extends Record<string, any>>(
33
+ documents: Document[]
34
+ ) => Promise<boolean>;
35
+ learnCloudRead: <Document extends Record<string, any>>(
36
+ query: Filter<Document>,
37
+ includeAssociatedDids?: boolean
38
+ ) => Promise<Document[]>;
39
+ learnCloudReadPage: <Document extends Record<string, any>>(
40
+ query: Filter<Document>,
41
+ paginationOptions?: Partial<PaginationOptionsType>,
42
+ includeAssociatedDids?: boolean
43
+ ) => Promise<PaginationResponseType & { records: Document[] }>;
44
+ learnCloudCount: <Document extends Record<string, any>>(
45
+ query: Filter<Document>,
46
+ includeAssociatedDids?: boolean
47
+ ) => Promise<number>;
48
+ learnCloudUpdate: <Document extends Record<string, any>>(
49
+ query: Filter<Document>,
50
+ update: Partial<Document>
51
+ ) => Promise<number>;
52
+ learnCloudDelete: <Document extends Record<string, any>>(
53
+ query: Filter<Document>,
54
+ includeAssociatedDids?: boolean
55
+ ) => Promise<number | false>;
56
+ learnCloudBatchResolve: (uris: string[]) => Promise<(VC | VP | null)[]>;
57
+ };
58
+
59
+ /** @group LearnCloud Plugin */
60
+ export type LearnCloudPlugin = Plugin<
61
+ 'LearnCloud',
62
+ 'index' | 'read' | 'store',
63
+ LearnCloudPluginMethods,
64
+ 'id',
65
+ LearnCloudPluginDependentMethods
66
+ >;
67
+
68
+ /** @group LearnCloud Plugin */
69
+ export type LearnCloudDependentLearnCard = LearnCard<any, 'id', LearnCloudPluginDependentMethods>;