@decaf-ts/for-fabric 0.1.2 → 0.1.4
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/dist/for-fabric.cjs +1 -1
- package/dist/for-fabric.cjs.map +1 -1
- package/dist/for-fabric.js +1 -1
- package/dist/for-fabric.js.map +1 -1
- package/lib/client/FabricClientAdapter.cjs +94 -81
- package/lib/client/FabricClientAdapter.d.ts +24 -33
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/client/FabricClientDispatch.cjs +14 -5
- package/lib/client/FabricClientDispatch.d.ts +7 -5
- package/lib/client/FabricClientDispatch.js.map +1 -1
- package/lib/client/FabricClientRepository.cjs +4 -137
- package/lib/client/FabricClientRepository.d.ts +6 -78
- package/lib/client/FabricClientRepository.js.map +1 -1
- package/lib/client/erc20/FabricERC20ClientRepository.cjs +17 -17
- package/lib/client/erc20/FabricERC20ClientRepository.d.ts +5 -5
- package/lib/client/erc20/FabricERC20ClientRepository.js.map +1 -1
- package/lib/client/logging.cjs +1 -3
- package/lib/client/logging.js.map +1 -1
- package/lib/client/services/FabricEnrollmentService.cjs +3 -3
- package/lib/client/services/FabricEnrollmentService.d.ts +2 -2
- package/lib/client/services/FabricEnrollmentService.js.map +1 -1
- package/lib/contracts/ContractAdapter.cjs +204 -115
- package/lib/contracts/ContractAdapter.d.ts +26 -34
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/ContractContext.cjs +1 -9
- package/lib/contracts/ContractContext.d.ts +0 -6
- package/lib/contracts/ContractContext.js.map +1 -1
- package/lib/contracts/ContractPrivateDataAdapter.cjs +429 -288
- package/lib/contracts/ContractPrivateDataAdapter.d.ts +0 -76
- package/lib/contracts/ContractPrivateDataAdapter.js.map +1 -1
- package/lib/contracts/FabricConstruction.cjs +3 -3
- package/lib/contracts/FabricConstruction.d.ts +9 -8
- package/lib/contracts/FabricConstruction.js.map +1 -1
- package/lib/contracts/FabricContractRepository.cjs +7 -202
- package/lib/contracts/FabricContractRepository.d.ts +5 -68
- package/lib/contracts/FabricContractRepository.js.map +1 -1
- package/lib/contracts/FabricContractRepositoryObservableHandler.cjs +4 -1
- package/lib/contracts/FabricContractRepositoryObservableHandler.d.ts +4 -4
- package/lib/contracts/FabricContractRepositoryObservableHandler.js.map +1 -1
- package/lib/contracts/FabricContractSequence.cjs +39 -60
- package/lib/contracts/FabricContractSequence.d.ts +29 -41
- package/lib/contracts/FabricContractSequence.js.map +1 -1
- package/lib/contracts/FabricContractStatement.cjs +6 -6
- package/lib/contracts/FabricContractStatement.d.ts +4 -6
- package/lib/contracts/FabricContractStatement.js.map +1 -1
- package/lib/contracts/crud/crud-contract.cjs +74 -44
- package/lib/contracts/crud/crud-contract.d.ts +7 -11
- package/lib/contracts/crud/crud-contract.js.map +1 -1
- package/lib/contracts/crud/serialized-crud-contract.cjs +12 -21
- package/lib/contracts/crud/serialized-crud-contract.d.ts +3 -11
- package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/contracts/erc20/erc20contract.cjs +73 -67
- package/lib/contracts/erc20/erc20contract.d.ts +13 -12
- package/lib/contracts/erc20/erc20contract.js.map +1 -1
- package/lib/contracts/logging.cjs +3 -9
- package/lib/contracts/logging.d.ts +1 -2
- package/lib/contracts/logging.js.map +1 -1
- package/lib/contracts/private-data.cjs +202 -118
- package/lib/contracts/private-data.d.ts +0 -16
- package/lib/contracts/private-data.js.map +1 -1
- package/lib/contracts/types.d.ts +1 -1
- package/lib/esm/client/FabricClientAdapter.d.ts +24 -33
- package/lib/esm/client/FabricClientAdapter.js +90 -78
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/client/FabricClientDispatch.d.ts +7 -5
- package/lib/esm/client/FabricClientDispatch.js +17 -8
- package/lib/esm/client/FabricClientDispatch.js.map +1 -1
- package/lib/esm/client/FabricClientRepository.d.ts +6 -78
- package/lib/esm/client/FabricClientRepository.js +4 -137
- package/lib/esm/client/FabricClientRepository.js.map +1 -1
- package/lib/esm/client/erc20/FabricERC20ClientRepository.d.ts +5 -5
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js +17 -17
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js.map +1 -1
- package/lib/esm/client/logging.js +1 -3
- package/lib/esm/client/logging.js.map +1 -1
- package/lib/esm/client/services/FabricEnrollmentService.d.ts +2 -2
- package/lib/esm/client/services/FabricEnrollmentService.js +3 -3
- package/lib/esm/client/services/FabricEnrollmentService.js.map +1 -1
- package/lib/esm/contracts/ContractAdapter.d.ts +26 -34
- package/lib/esm/contracts/ContractAdapter.js +205 -116
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/ContractContext.d.ts +0 -6
- package/lib/esm/contracts/ContractContext.js +1 -9
- package/lib/esm/contracts/ContractContext.js.map +1 -1
- package/lib/esm/contracts/ContractPrivateDataAdapter.d.ts +0 -76
- package/lib/esm/contracts/ContractPrivateDataAdapter.js +430 -285
- package/lib/esm/contracts/ContractPrivateDataAdapter.js.map +1 -1
- package/lib/esm/contracts/FabricConstruction.d.ts +9 -8
- package/lib/esm/contracts/FabricConstruction.js +3 -3
- package/lib/esm/contracts/FabricConstruction.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepository.d.ts +5 -68
- package/lib/esm/contracts/FabricContractRepository.js +7 -202
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.d.ts +4 -4
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js +5 -2
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js.map +1 -1
- package/lib/esm/contracts/FabricContractSequence.d.ts +29 -41
- package/lib/esm/contracts/FabricContractSequence.js +40 -61
- package/lib/esm/contracts/FabricContractSequence.js.map +1 -1
- package/lib/esm/contracts/FabricContractStatement.d.ts +4 -6
- package/lib/esm/contracts/FabricContractStatement.js +7 -7
- package/lib/esm/contracts/FabricContractStatement.js.map +1 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +7 -11
- package/lib/esm/contracts/crud/crud-contract.js +75 -45
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +3 -11
- package/lib/esm/contracts/crud/serialized-crud-contract.js +12 -21
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/esm/contracts/erc20/erc20contract.d.ts +13 -12
- package/lib/esm/contracts/erc20/erc20contract.js +73 -67
- package/lib/esm/contracts/erc20/erc20contract.js.map +1 -1
- package/lib/esm/contracts/logging.d.ts +1 -2
- package/lib/esm/contracts/logging.js +3 -9
- package/lib/esm/contracts/logging.js.map +1 -1
- package/lib/esm/contracts/private-data.d.ts +0 -16
- package/lib/esm/contracts/private-data.js +203 -111
- package/lib/esm/contracts/private-data.js.map +1 -1
- package/lib/esm/contracts/types.d.ts +1 -1
- package/lib/esm/shared/decorators.d.ts +14 -4
- package/lib/esm/shared/decorators.js +142 -42
- package/lib/esm/shared/decorators.js.map +1 -1
- package/lib/esm/shared/errors.js +2 -2
- package/lib/esm/shared/errors.js.map +1 -1
- package/lib/esm/shared/events.d.ts +1 -5
- package/lib/esm/shared/events.js.map +1 -1
- package/lib/esm/shared/model/Sequence.d.ts +14 -0
- package/lib/esm/shared/model/Sequence.js +33 -0
- package/lib/esm/shared/model/Sequence.js.map +1 -0
- package/lib/esm/shared/model/index.d.ts +2 -0
- package/lib/esm/shared/model/index.js +2 -0
- package/lib/esm/shared/model/index.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/decorators.cjs +148 -41
- package/lib/shared/decorators.d.ts +14 -4
- package/lib/shared/decorators.js.map +1 -1
- package/lib/shared/errors.cjs +2 -2
- package/lib/shared/errors.js.map +1 -1
- package/lib/shared/events.d.ts +1 -5
- package/lib/shared/events.js.map +1 -1
- package/lib/shared/model/Sequence.cjs +36 -0
- package/lib/shared/model/Sequence.d.ts +14 -0
- package/lib/shared/model/Sequence.js.map +1 -0
- package/lib/shared/model/index.cjs +2 -0
- package/lib/shared/model/index.d.ts +2 -0
- package/lib/shared/model/index.js.map +1 -1
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +2 -3
- package/lib/client/services/LoggedService.cjs +0 -47
- package/lib/client/services/LoggedService.d.ts +0 -42
- package/lib/client/services/LoggedService.js.map +0 -1
- package/lib/esm/client/services/LoggedService.d.ts +0 -42
- package/lib/esm/client/services/LoggedService.js +0 -43
- package/lib/esm/client/services/LoggedService.js.map +0 -1
|
@@ -1,120 +1,204 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
2
|
+
// import { InternalError, SerializationError } from "@decaf-ts/db-decorators";
|
|
3
|
+
// import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
// import { FabricModelKeys } from "../shared/constants";
|
|
5
|
+
// import { Constructor, Metadata } from "@decaf-ts/decoration";
|
|
6
|
+
//
|
|
7
|
+
// export const MISSING_PRIVATE_DATA_REGEX =
|
|
8
|
+
// /private\s+data\s+matching\s+public\s+hash\s+version\s+is\s+not\s+available/i;
|
|
9
|
+
//
|
|
10
|
+
// export const MISSING_PRIVATE_DATA_ERROR_MESSAGE =
|
|
11
|
+
// "private data matching public hash version is not available ...";
|
|
12
|
+
//
|
|
13
|
+
// export function processModel<M extends Model>(adapter: any, model: M) {
|
|
14
|
+
// const transient = Model.segregate(model);
|
|
15
|
+
// const privateData = modelToPrivate(model);
|
|
16
|
+
//
|
|
17
|
+
// const transformModel = (model: any) => {
|
|
18
|
+
// return Object.entries(model).reduce(
|
|
19
|
+
// (accum: Record<string, any>, [key, val]) => {
|
|
20
|
+
// if (typeof val === "undefined") return accum;
|
|
21
|
+
// const mappedProp = Model.columnName(
|
|
22
|
+
// model.constructor as Constructor,
|
|
23
|
+
// key as any
|
|
24
|
+
// );
|
|
25
|
+
// if (adapter.isReserved(mappedProp))
|
|
26
|
+
// throw new InternalError(`Property name ${mappedProp} is reserved`);
|
|
27
|
+
// accum[mappedProp] = val;
|
|
28
|
+
// return accum;
|
|
29
|
+
// },
|
|
30
|
+
// {}
|
|
31
|
+
// );
|
|
32
|
+
// };
|
|
33
|
+
//
|
|
34
|
+
// if (privateData.private) {
|
|
35
|
+
// const collections = Object.keys(privateData.private);
|
|
36
|
+
//
|
|
37
|
+
// for (const collection of collections) {
|
|
38
|
+
// privateData.private![collection] = transformModel(
|
|
39
|
+
// privateData.private![collection]
|
|
40
|
+
// );
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
//
|
|
44
|
+
// return {
|
|
45
|
+
// model: transient.model,
|
|
46
|
+
// transient: transient.transient,
|
|
47
|
+
// privateData: privateData.private,
|
|
48
|
+
// result: transformModel(transient.model),
|
|
49
|
+
// };
|
|
50
|
+
// }
|
|
51
|
+
//
|
|
52
|
+
// export function hasPrivateData<M extends Model>(model: M) {
|
|
53
|
+
// return !!getClassPrivateDataMetadata(model);
|
|
54
|
+
// }
|
|
55
|
+
//
|
|
56
|
+
// export function getClassPrivateDataMetadata<M extends Model>(
|
|
57
|
+
// model: M
|
|
58
|
+
// ): Record<string, any> | undefined {
|
|
59
|
+
// const constr = model.constructor as Constructor;
|
|
60
|
+
// const rootMetadata = Metadata.get(constr) || {};
|
|
61
|
+
// if (rootMetadata && rootMetadata[FabricModelKeys.PRIVATE])
|
|
62
|
+
// return rootMetadata[FabricModelKeys.PRIVATE];
|
|
63
|
+
// if (
|
|
64
|
+
// rootMetadata &&
|
|
65
|
+
// rootMetadata[FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE]
|
|
66
|
+
// )
|
|
67
|
+
// return rootMetadata[FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE];
|
|
68
|
+
// const flattened = Object.keys(rootMetadata || {}).reduce(
|
|
69
|
+
// (accum: Record<string, any>, key) => {
|
|
70
|
+
// if (key.includes(FabricModelKeys.PRIVATE)) {
|
|
71
|
+
// const property = key.split(Metadata.splitter).pop();
|
|
72
|
+
// if (property) accum[property] = Metadata.get(constr, key);
|
|
73
|
+
// }
|
|
74
|
+
// return accum;
|
|
75
|
+
// },
|
|
76
|
+
// {} as Record<string, any>
|
|
77
|
+
// );
|
|
78
|
+
// if (Object.keys(flattened).length) return flattened;
|
|
79
|
+
// const classKey = Metadata.key(
|
|
80
|
+
// FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE
|
|
81
|
+
// );
|
|
82
|
+
// const classMetadata =
|
|
83
|
+
// Metadata.get(constr, classKey) ??
|
|
84
|
+
// Metadata.get(constr, FabricModelKeys.PRIVATE);
|
|
85
|
+
// if (classMetadata) return classMetadata;
|
|
86
|
+
// const props = Metadata.properties(constr) || [];
|
|
87
|
+
// const metadata: Record<string, any> = {};
|
|
88
|
+
// for (const prop of props) {
|
|
89
|
+
// const keys = [
|
|
90
|
+
// Metadata.key(FabricModelKeys.PRIVATE, prop),
|
|
91
|
+
// Metadata.key(classKey, prop),
|
|
92
|
+
// ];
|
|
93
|
+
// const propMetadata = keys
|
|
94
|
+
// .map((key) => Metadata.get(constr, key))
|
|
95
|
+
// .find(Boolean);
|
|
96
|
+
// if (propMetadata) metadata[prop] = propMetadata;
|
|
97
|
+
// }
|
|
98
|
+
// return Object.keys(metadata).length ? metadata : undefined;
|
|
99
|
+
// }
|
|
100
|
+
//
|
|
101
|
+
// export function isModelPrivate<M extends Model>(model: M): boolean {
|
|
102
|
+
// const classMetadata = Metadata.get(
|
|
103
|
+
// model.constructor as Constructor,
|
|
104
|
+
// Metadata.key(FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE)
|
|
105
|
+
// );
|
|
106
|
+
// return Boolean(classMetadata?.isPrivate);
|
|
107
|
+
// }
|
|
108
|
+
//
|
|
109
|
+
// export function modelToPrivate<M extends Model>(
|
|
110
|
+
// model: M
|
|
111
|
+
// ): { model: M; private?: Record<string, Record<string, any>> } {
|
|
112
|
+
// if (!hasPrivateData(model)) return { model: model };
|
|
113
|
+
//
|
|
114
|
+
// const isPrivate = isModelPrivate(model);
|
|
115
|
+
// const modelCollections: Record<string, any> =
|
|
116
|
+
// getClassPrivateDataMetadata(model);
|
|
117
|
+
//
|
|
118
|
+
// let result: { model: Record<string, any>; private?: Record<string, any> } = {
|
|
119
|
+
// model: model as Record<string, any>,
|
|
120
|
+
// private: undefined,
|
|
121
|
+
// };
|
|
122
|
+
//
|
|
123
|
+
// // TODO: the is private is not workign correctly. If no properties it doesn't create the private part.
|
|
124
|
+
// if (isPrivate) {
|
|
125
|
+
// const privatePart = modelCollections.collections;
|
|
126
|
+
// result = (
|
|
127
|
+
// Metadata.properties(model.constructor as Constructor) || []
|
|
128
|
+
// ).reduce(
|
|
129
|
+
// (
|
|
130
|
+
// accum: { model: Record<string, any>; private?: Record<string, any> },
|
|
131
|
+
// k
|
|
132
|
+
// ) => {
|
|
133
|
+
// const collections = modelCollections.collections;
|
|
134
|
+
// accum.private = accum.private || {};
|
|
135
|
+
//
|
|
136
|
+
// for (const collection of collections) {
|
|
137
|
+
// try {
|
|
138
|
+
// accum.private[collection] = accum.private[collection] || {};
|
|
139
|
+
// accum.private[collection][k] = model[k as keyof M];
|
|
140
|
+
// } catch (e: unknown) {
|
|
141
|
+
// throw new SerializationError(
|
|
142
|
+
// `Failed to serialize private property ${k}: ${e}`
|
|
143
|
+
// );
|
|
144
|
+
// }
|
|
145
|
+
// }
|
|
146
|
+
//
|
|
147
|
+
// return accum;
|
|
148
|
+
// },
|
|
149
|
+
// { model: {}, private: privatePart } as {
|
|
150
|
+
// model: Record<string, any>;
|
|
151
|
+
// private?: Record<string, any>;
|
|
152
|
+
// }
|
|
153
|
+
// );
|
|
154
|
+
// } else {
|
|
155
|
+
// result = Object.entries(modelCollections).reduce(
|
|
156
|
+
// (
|
|
157
|
+
// accum: { model: Record<string, any>; private?: Record<string, any> },
|
|
158
|
+
// [k, val]
|
|
159
|
+
// ) => {
|
|
160
|
+
// const props = Metadata.properties(model.constructor as Constructor);
|
|
161
|
+
// if (!props?.includes(k)) return accum;
|
|
162
|
+
//
|
|
163
|
+
// const collections = (val as Record<string, any>).collections;
|
|
164
|
+
//
|
|
165
|
+
// if (collections?.length) {
|
|
166
|
+
// accum.private = accum.private || {};
|
|
167
|
+
//
|
|
168
|
+
// for (const collection of collections) {
|
|
169
|
+
// try {
|
|
170
|
+
// accum.private[collection] = accum.private[collection] || {};
|
|
171
|
+
// accum.private[collection][k] = model[k as keyof M];
|
|
172
|
+
// } catch (e: unknown) {
|
|
173
|
+
// throw new SerializationError(
|
|
174
|
+
// `Failed to serialize private property ${k}: ${e}`
|
|
175
|
+
// );
|
|
176
|
+
// }
|
|
177
|
+
// }
|
|
178
|
+
// } else {
|
|
179
|
+
// accum.model = accum.model || {};
|
|
180
|
+
// accum.model[k] = (model as Record<string, any>)[k];
|
|
181
|
+
// }
|
|
182
|
+
// return accum;
|
|
183
|
+
// },
|
|
184
|
+
// {} as { model: Record<string, any>; private?: Record<string, any> }
|
|
185
|
+
// );
|
|
186
|
+
// }
|
|
187
|
+
//
|
|
188
|
+
// result.model = result.model || {};
|
|
189
|
+
//
|
|
190
|
+
// result.model = Model.build(result.model, model.constructor.name);
|
|
191
|
+
//
|
|
192
|
+
// if (result.private) {
|
|
193
|
+
// const collections = Object.keys(result.private);
|
|
194
|
+
//
|
|
195
|
+
// for (const collection of collections) {
|
|
196
|
+
// result.private![collection] = Model.build(
|
|
197
|
+
// result.private![collection],
|
|
198
|
+
// model.constructor.name
|
|
199
|
+
// );
|
|
200
|
+
// }
|
|
201
|
+
// }
|
|
202
|
+
// return result as { model: M; private?: Record<string, Record<string, any>> };
|
|
203
|
+
// }
|
|
120
204
|
//# sourceMappingURL=private-data.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
-
export declare const MISSING_PRIVATE_DATA_REGEX: RegExp;
|
|
3
|
-
export declare const MISSING_PRIVATE_DATA_ERROR_MESSAGE = "private data matching public hash version is not available ...";
|
|
4
|
-
export declare function processModel<M extends Model>(adapter: any, model: M): {
|
|
5
|
-
model: M;
|
|
6
|
-
transient: Record<keyof M, any> | undefined;
|
|
7
|
-
privateData: Record<string, Record<string, any>> | undefined;
|
|
8
|
-
result: Record<string, any>;
|
|
9
|
-
};
|
|
10
|
-
export declare function hasPrivateData<M extends Model>(model: M): boolean;
|
|
11
|
-
export declare function getClassPrivateDataMetadata<M extends Model>(model: M): Record<string, any>;
|
|
12
|
-
export declare function isModelPrivate<M extends Model>(model: M): boolean;
|
|
13
|
-
export declare function modelToPrivate<M extends Model>(model: M): {
|
|
14
|
-
model: M;
|
|
15
|
-
private?: Record<string, Record<string, any>>;
|
|
16
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-data.js","sourceRoot":"","sources":["../../src/contracts/private-data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-data.js","sourceRoot":"","sources":["../../src/contracts/private-data.ts"],"names":[],"mappings":"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"}
|
package/lib/contracts/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface FabricContractFlags extends RepositoryFlags {
|
|
|
18
18
|
/**
|
|
19
19
|
* @description Client identity for the transaction submitter
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
identity: ClientIdentity;
|
|
22
22
|
/**
|
|
23
23
|
* @description Logger instance for the contract
|
|
24
24
|
*/
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { CouchDBAdapter, type MangoQuery } from "@decaf-ts/for-couchdb";
|
|
2
2
|
import { Client } from "@grpc/grpc-js";
|
|
3
3
|
import { Model, type Serializer } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { type Logger } from "@decaf-ts/logging";
|
|
5
4
|
import { type FabricFlags, type PeerConfig } from "../shared/types";
|
|
6
5
|
import { Gateway, Network, Contract as Contrakt } from "@hyperledger/fabric-gateway";
|
|
7
|
-
import { BaseError,
|
|
8
|
-
import {
|
|
6
|
+
import { BaseError, OperationKeys } from "@decaf-ts/db-decorators";
|
|
7
|
+
import { Context, type PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
8
|
+
import { Adapter, PreparedModel, Repository } from "@decaf-ts/core";
|
|
9
|
+
import type { ContextualArgs, MaybeContextualArg } from "@decaf-ts/core";
|
|
9
10
|
import type { FabricClientDispatch } from "./FabricClientDispatch";
|
|
10
11
|
import { type Constructor } from "@decaf-ts/decoration";
|
|
12
|
+
export declare class FabricClientContext extends Context<FabricFlags> {
|
|
13
|
+
}
|
|
11
14
|
/**
|
|
12
15
|
* @description Adapter for interacting with Hyperledger Fabric networks
|
|
13
16
|
* @summary The FabricAdapter extends CouchDBAdapter to provide a seamless interface for interacting with Hyperledger Fabric networks.
|
|
@@ -59,22 +62,13 @@ import { type Constructor } from "@decaf-ts/decoration";
|
|
|
59
62
|
* FabricAdapter->>FabricAdapter: serializer.deserialize(decodedResult)
|
|
60
63
|
* FabricAdapter-->>Client: deserializedResult
|
|
61
64
|
*/
|
|
62
|
-
export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Client,
|
|
65
|
+
export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Client, FabricClientContext> {
|
|
63
66
|
/**
|
|
64
67
|
* @description Static text decoder for converting Uint8Array to string
|
|
65
68
|
*/
|
|
66
69
|
private static decoder;
|
|
67
70
|
private static serializer;
|
|
68
|
-
|
|
69
|
-
* @description Static logger instance for the FabricAdapter class
|
|
70
|
-
*/
|
|
71
|
-
private static log;
|
|
72
|
-
/**
|
|
73
|
-
* @description Gets the logger instance for this adapter
|
|
74
|
-
* @summary Returns the static logger instance for the FabricAdapter class
|
|
75
|
-
* @return {Logger} The logger instance
|
|
76
|
-
*/
|
|
77
|
-
protected get log(): Logger;
|
|
71
|
+
protected static log: import("@decaf-ts/logging").Logger;
|
|
78
72
|
protected readonly serializer: Serializer<any>;
|
|
79
73
|
/**
|
|
80
74
|
* @description Creates a new FabricAdapter instance
|
|
@@ -83,6 +77,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
83
77
|
* @param {string} [alias] - Optional alias for the adapter instance
|
|
84
78
|
*/
|
|
85
79
|
constructor(config: PeerConfig, alias?: string);
|
|
80
|
+
context<M extends Model>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE | string, overrides: Partial<FabricFlags>, model: Constructor<M> | Constructor<M>[], ...args: any[]): Promise<FabricClientContext>;
|
|
86
81
|
/**
|
|
87
82
|
* @description Decodes a Uint8Array to a string
|
|
88
83
|
* @summary Converts binary data received from Fabric to a string using UTF-8 encoding
|
|
@@ -90,7 +85,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
90
85
|
* @return {string} The decoded string
|
|
91
86
|
*/
|
|
92
87
|
decode(data: Uint8Array): string;
|
|
93
|
-
repository<
|
|
88
|
+
repository<R extends Repository<any, Adapter<PeerConfig, Client, MangoQuery, FabricClientContext>>>(): Constructor<R>;
|
|
94
89
|
/**
|
|
95
90
|
* @description Creates multiple records in a single transaction
|
|
96
91
|
* @summary Submits a transaction to create multiple records in the Fabric ledger
|
|
@@ -100,7 +95,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
100
95
|
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
101
96
|
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the created records
|
|
102
97
|
*/
|
|
103
|
-
createAll(
|
|
98
|
+
createAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
|
|
104
99
|
/**
|
|
105
100
|
* @description Reads multiple records in a single transaction
|
|
106
101
|
* @summary Submits a transaction to read multiple records from the Fabric ledger
|
|
@@ -108,7 +103,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
108
103
|
* @param {string[] | number[]} ids - Array of record identifiers to read
|
|
109
104
|
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the retrieved records
|
|
110
105
|
*/
|
|
111
|
-
readAll(
|
|
106
|
+
readAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
|
|
112
107
|
/**
|
|
113
108
|
* @description Updates multiple records in a single transaction
|
|
114
109
|
* @summary Submits a transaction to update multiple records in the Fabric ledger
|
|
@@ -118,7 +113,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
118
113
|
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
119
114
|
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the updated records
|
|
120
115
|
*/
|
|
121
|
-
updateAll(
|
|
116
|
+
updateAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
|
|
122
117
|
/**
|
|
123
118
|
* @description Deletes multiple records in a single transaction
|
|
124
119
|
* @summary Submits a transaction to delete multiple records from the Fabric ledger
|
|
@@ -127,7 +122,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
127
122
|
* @param {Serializer<any>} serializer - Serializer for the model data
|
|
128
123
|
* @return {Promise<Array<Record<string, any>>>} Promise resolving to the deleted records
|
|
129
124
|
*/
|
|
130
|
-
deleteAll(
|
|
125
|
+
deleteAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
|
|
131
126
|
/**
|
|
132
127
|
* @description Prepares a model for persistence
|
|
133
128
|
* @summary Converts a model instance into a format suitable for database storage,
|
|
@@ -137,11 +132,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
137
132
|
* @param pk - The primary key property name
|
|
138
133
|
* @return The prepared data
|
|
139
134
|
*/
|
|
140
|
-
prepare<M extends Model>(model: M,
|
|
141
|
-
record: Record<string, any>;
|
|
142
|
-
id: string;
|
|
143
|
-
transient?: Record<string, any>;
|
|
144
|
-
};
|
|
135
|
+
prepare<M extends Model>(model: M, ...args: ContextualArgs<FabricClientContext>): PreparedModel;
|
|
145
136
|
/**
|
|
146
137
|
* @description Converts database data back into a model instance
|
|
147
138
|
* @summary Reconstructs a model instance from database data, handling column mapping
|
|
@@ -154,7 +145,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
154
145
|
* @param [transient] - Transient properties to reattach
|
|
155
146
|
* @return {M} The reconstructed model instance
|
|
156
147
|
*/
|
|
157
|
-
revert<M extends Model>(obj: Record<string, any>, clazz:
|
|
148
|
+
revert<M extends Model>(obj: Record<string, any>, clazz: Constructor<M>, id: PrimaryKeyType, transient?: Record<string, any>, ...args: ContextualArgs<FabricClientContext>): M;
|
|
158
149
|
/**
|
|
159
150
|
* @description Creates an index for a model
|
|
160
151
|
* @summary This method is not implemented for Fabric and will throw an error
|
|
@@ -172,7 +163,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
172
163
|
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
173
164
|
* @return {Promise<Record<string, any>>} Promise resolving to the created record
|
|
174
165
|
*/
|
|
175
|
-
create(
|
|
166
|
+
create<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
|
|
176
167
|
/**
|
|
177
168
|
* @description Reads a single record
|
|
178
169
|
* @summary Evaluates a transaction to read a record from the Fabric ledger
|
|
@@ -180,8 +171,8 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
180
171
|
* @param {string | number} id - The record identifier
|
|
181
172
|
* @return {Promise<Record<string, any>>} Promise resolving to the retrieved record
|
|
182
173
|
*/
|
|
183
|
-
read(
|
|
184
|
-
updatePrefix(
|
|
174
|
+
read<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
|
|
175
|
+
updatePrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: MaybeContextualArg<FabricClientContext>): any[];
|
|
185
176
|
/**
|
|
186
177
|
* @description Updates a single record
|
|
187
178
|
* @summary Submits a transaction to update a record in the Fabric ledger
|
|
@@ -191,7 +182,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
191
182
|
* @param {Record<string, any>} transient - Transient data for the transaction
|
|
192
183
|
* @return {Promise<Record<string, any>>} Promise resolving to the updated record
|
|
193
184
|
*/
|
|
194
|
-
update(
|
|
185
|
+
update<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
|
|
195
186
|
/**
|
|
196
187
|
* @description Deletes a single record
|
|
197
188
|
* @summary Submits a transaction to delete a record from the Fabric ledger
|
|
@@ -199,7 +190,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
199
190
|
* @param {string | number} id - The record identifier to delete
|
|
200
191
|
* @return {Promise<Record<string, any>>} Promise resolving to the deleted record
|
|
201
192
|
*/
|
|
202
|
-
delete(
|
|
193
|
+
delete<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
|
|
203
194
|
/**
|
|
204
195
|
* @description Executes a raw query against the Fabric ledger
|
|
205
196
|
* @summary Evaluates a transaction to perform a query using Mango Query syntax
|
|
@@ -225,7 +216,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
225
216
|
* FabricAdapter->>FabricAdapter: Process result based on type
|
|
226
217
|
* FabricAdapter-->>Client: processed result
|
|
227
218
|
*/
|
|
228
|
-
raw<V>(rawInput: MangoQuery,
|
|
219
|
+
raw<V>(rawInput: MangoQuery, ...args: ContextualArgs<FabricClientContext>): Promise<V>;
|
|
229
220
|
/**
|
|
230
221
|
* @description Gets or creates a gRPC client for the Fabric peer
|
|
231
222
|
* @summary Returns a cached client or creates a new one if none exists
|
|
@@ -281,7 +272,7 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
281
272
|
* @param {string} [reason] - Optional reason for the error
|
|
282
273
|
* @return {BaseError} The parsed error
|
|
283
274
|
*/
|
|
284
|
-
parseError(err: Error | string, reason?: string):
|
|
275
|
+
parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
285
276
|
/**
|
|
286
277
|
* @description Submits a transaction to the Fabric network
|
|
287
278
|
* @summary Executes a transaction that modifies the ledger state
|
|
@@ -381,5 +372,5 @@ export declare class FabricClientAdapter extends CouchDBAdapter<PeerConfig, Clie
|
|
|
381
372
|
* @param {string} [reason] - Optional reason for the error
|
|
382
373
|
* @return {BaseError} The parsed error
|
|
383
374
|
*/
|
|
384
|
-
protected static parseError(err: Error | string, reason?: string):
|
|
375
|
+
protected static parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
385
376
|
}
|