@decaf-ts/for-fabric 0.1.22 → 0.1.24

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.
Files changed (117) hide show
  1. package/dist/for-fabric.cjs +1 -1
  2. package/dist/for-fabric.cjs.map +1 -1
  3. package/dist/for-fabric.js +1 -1
  4. package/dist/for-fabric.js.map +1 -1
  5. package/lib/client/FabricClientAdapter.cjs +39 -61
  6. package/lib/client/FabricClientAdapter.d.ts +28 -42
  7. package/lib/client/FabricClientAdapter.js.map +1 -1
  8. package/lib/client/FabricClientDispatch.cjs +1 -3
  9. package/lib/client/FabricClientDispatch.d.ts +6 -5
  10. package/lib/client/FabricClientDispatch.js.map +1 -1
  11. package/lib/client/FabricClientPaginator.cjs +5 -56
  12. package/lib/client/FabricClientPaginator.d.ts +6 -6
  13. package/lib/client/FabricClientPaginator.js.map +1 -1
  14. package/lib/client/FabricClientRepository.cjs +50 -103
  15. package/lib/client/FabricClientRepository.d.ts +21 -17
  16. package/lib/client/FabricClientRepository.js.map +1 -1
  17. package/lib/client/FabricClientStatement.cjs +7 -97
  18. package/lib/client/FabricClientStatement.d.ts +6 -7
  19. package/lib/client/FabricClientStatement.js.map +1 -1
  20. package/lib/client/erc20/FabricERC20ClientRepository.d.ts +5 -5
  21. package/lib/client/erc20/FabricERC20ClientRepository.js.map +1 -1
  22. package/lib/client/fabric-fs.d.ts +1 -1
  23. package/lib/client/services/FabricEnrollmentService.d.ts +1 -1
  24. package/lib/contract/Address.cjs +73 -0
  25. package/lib/contract/Address.d.ts +13 -0
  26. package/lib/contract/Address.js.map +1 -0
  27. package/lib/contract/AddressContract.cjs +34 -0
  28. package/lib/contract/AddressContract.d.ts +5 -0
  29. package/lib/contract/AddressContract.js.map +1 -0
  30. package/lib/contract/index.cjs +6 -1
  31. package/lib/contract/index.js.map +1 -1
  32. package/lib/contracts/ContractAdapter.cjs +53 -20
  33. package/lib/contracts/ContractAdapter.d.ts +3 -3
  34. package/lib/contracts/ContractAdapter.js.map +1 -1
  35. package/lib/contracts/ContractContext.cjs +2 -2
  36. package/lib/contracts/ContractContext.d.ts +1 -1
  37. package/lib/contracts/ContractContext.js.map +1 -1
  38. package/lib/contracts/FabricContractRepository.js.map +1 -1
  39. package/lib/contracts/crud/crud-contract.cjs +14 -0
  40. package/lib/contracts/crud/crud-contract.d.ts +15 -4
  41. package/lib/contracts/crud/crud-contract.js.map +1 -1
  42. package/lib/contracts/crud/serialized-crud-contract.cjs +58 -8
  43. package/lib/contracts/crud/serialized-crud-contract.d.ts +6 -2
  44. package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
  45. package/lib/contracts/types.d.ts +2 -2
  46. package/lib/esm/client/FabricClientAdapter.d.ts +28 -42
  47. package/lib/esm/client/FabricClientAdapter.js +39 -60
  48. package/lib/esm/client/FabricClientAdapter.js.map +1 -1
  49. package/lib/esm/client/FabricClientDispatch.d.ts +6 -5
  50. package/lib/esm/client/FabricClientDispatch.js +3 -5
  51. package/lib/esm/client/FabricClientDispatch.js.map +1 -1
  52. package/lib/esm/client/FabricClientPaginator.d.ts +6 -6
  53. package/lib/esm/client/FabricClientPaginator.js +6 -57
  54. package/lib/esm/client/FabricClientPaginator.js.map +1 -1
  55. package/lib/esm/client/FabricClientRepository.d.ts +21 -17
  56. package/lib/esm/client/FabricClientRepository.js +50 -103
  57. package/lib/esm/client/FabricClientRepository.js.map +1 -1
  58. package/lib/esm/client/FabricClientStatement.d.ts +6 -7
  59. package/lib/esm/client/FabricClientStatement.js +8 -98
  60. package/lib/esm/client/FabricClientStatement.js.map +1 -1
  61. package/lib/esm/client/erc20/FabricERC20ClientRepository.d.ts +5 -5
  62. package/lib/esm/client/erc20/FabricERC20ClientRepository.js.map +1 -1
  63. package/lib/esm/client/fabric-fs.d.ts +1 -1
  64. package/lib/esm/client/services/FabricEnrollmentService.d.ts +1 -1
  65. package/lib/esm/contract/Address.d.ts +13 -0
  66. package/lib/esm/contract/Address.js +70 -0
  67. package/lib/esm/contract/Address.js.map +1 -0
  68. package/lib/esm/contract/AddressContract.d.ts +5 -0
  69. package/lib/esm/contract/AddressContract.js +31 -0
  70. package/lib/esm/contract/AddressContract.js.map +1 -0
  71. package/lib/esm/contract/index.js +6 -1
  72. package/lib/esm/contract/index.js.map +1 -1
  73. package/lib/esm/contracts/ContractAdapter.d.ts +3 -3
  74. package/lib/esm/contracts/ContractAdapter.js +53 -20
  75. package/lib/esm/contracts/ContractAdapter.js.map +1 -1
  76. package/lib/esm/contracts/ContractContext.d.ts +1 -1
  77. package/lib/esm/contracts/ContractContext.js +1 -1
  78. package/lib/esm/contracts/ContractContext.js.map +1 -1
  79. package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
  80. package/lib/esm/contracts/crud/crud-contract.d.ts +15 -4
  81. package/lib/esm/contracts/crud/crud-contract.js +17 -3
  82. package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
  83. package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +6 -2
  84. package/lib/esm/contracts/crud/serialized-crud-contract.js +58 -8
  85. package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
  86. package/lib/esm/contracts/types.d.ts +2 -2
  87. package/lib/esm/shared/decorators.d.ts +7 -8
  88. package/lib/esm/shared/decorators.js +74 -59
  89. package/lib/esm/shared/decorators.js.map +1 -1
  90. package/lib/esm/shared/errors.d.ts +3 -0
  91. package/lib/esm/shared/errors.js +5 -0
  92. package/lib/esm/shared/errors.js.map +1 -1
  93. package/lib/esm/shared/overrides/overrides.js +39 -38
  94. package/lib/esm/shared/overrides/overrides.js.map +1 -1
  95. package/lib/esm/shared/types.d.ts +5 -9
  96. package/lib/esm/shared/utils.d.ts +1 -1
  97. package/lib/esm/version.d.ts +1 -1
  98. package/lib/esm/version.js +1 -1
  99. package/lib/shared/decorators.cjs +71 -56
  100. package/lib/shared/decorators.d.ts +7 -8
  101. package/lib/shared/decorators.js.map +1 -1
  102. package/lib/shared/errors.cjs +7 -1
  103. package/lib/shared/errors.d.ts +3 -0
  104. package/lib/shared/errors.js.map +1 -1
  105. package/lib/shared/overrides/overrides.cjs +39 -38
  106. package/lib/shared/overrides/overrides.js.map +1 -1
  107. package/lib/shared/types.d.ts +5 -9
  108. package/lib/shared/utils.d.ts +1 -1
  109. package/lib/version.cjs +1 -1
  110. package/lib/version.d.ts +1 -1
  111. package/package.json +1 -1
  112. package/lib/client/types.cjs +0 -3
  113. package/lib/client/types.d.ts +0 -7
  114. package/lib/client/types.js.map +0 -1
  115. package/lib/esm/client/types.d.ts +0 -7
  116. package/lib/esm/client/types.js +0 -2
  117. package/lib/esm/client/types.js.map +0 -1
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SerializedCrudContract = void 0;
13
13
  const crud_contract_1 = require("./crud-contract.cjs");
14
14
  const fabric_contract_api_1 = require("fabric-contract-api");
15
+ const core_1 = require("@decaf-ts/core");
16
+ const db_decorators_1 = require("@decaf-ts/db-decorators");
15
17
  /**
16
18
  * @description CRUD contract variant that serializes/deserializes payloads
17
19
  * @summary Exposes the same CRUD operations as FabricCrudContract but takes and returns JSON strings to facilitate simple client interactions.
@@ -71,14 +73,50 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
71
73
  log.info(`Updating ${modelList.length} entries to the table`);
72
74
  return JSON.stringify((await super.updateAll(ctx, modelList)).map((m) => this.serialize(m)));
73
75
  }
74
- async statement(context, method) {
75
- const { ctx } = await this.logCtx([context], this.statement);
76
- return super.statement(ctx, method);
76
+ async statement(context, method, ...args) {
77
+ const { ctx, log } = await this.logCtx([...args, context], this.statement);
78
+ args = args.map((a) => {
79
+ try {
80
+ return JSON.parse(a);
81
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
82
+ }
83
+ catch (e) {
84
+ return a;
85
+ }
86
+ });
87
+ log.info(`calling prepared statement ${method}`);
88
+ log.debug(`with args ${args}`);
89
+ return super.statement(ctx, method, ...args);
77
90
  }
78
- async raw(context, rawInput, docsOnly) {
91
+ async listBy(context, key, order, ...args) {
92
+ const { ctx } = await this.logCtx([...args, context], this.listBy);
93
+ return super.listBy(ctx, key, order);
94
+ }
95
+ async paginateBy(context, key, order, size, ...args) {
96
+ const { ctx } = await this.logCtx([...args, context], this.paginateBy);
97
+ return super.paginateBy(ctx, key, order, size);
98
+ }
99
+ async findOneBy(context, key, value, ...args) {
100
+ const { ctx } = await this.logCtx([...args, context], this.paginateBy);
101
+ return super.findOneBy(ctx, key, value, ...args);
102
+ }
103
+ // @Transaction(false)
104
+ async query(context, condition, orderBy, order, limit, skip, ...args) {
105
+ const { ctx } = await this.logCtx([context], this.query);
106
+ let cond;
107
+ try {
108
+ cond = core_1.Condition.from(JSON.parse(condition));
109
+ }
110
+ catch (e) {
111
+ throw new db_decorators_1.SerializationError(`Invalid condition: ${e}`);
112
+ }
113
+ return super.query(ctx, cond, orderBy, order, limit, skip, ...args);
114
+ }
115
+ // @Transaction(false)
116
+ async raw(context, rawInput, docsOnly, ...args) {
79
117
  const { ctx } = await this.logCtx([context], this.raw);
80
118
  const parsedInput = JSON.parse(rawInput);
81
- return super.raw(ctx, parsedInput, docsOnly);
119
+ return super.raw(ctx, parsedInput, docsOnly, ...args);
82
120
  }
83
121
  async init(ctx) {
84
122
  await super.init(ctx);
@@ -145,15 +183,27 @@ __decorate([
145
183
  __decorate([
146
184
  (0, fabric_contract_api_1.Transaction)(false),
147
185
  __metadata("design:type", Function),
148
- __metadata("design:paramtypes", [fabric_contract_api_1.Context, String]),
186
+ __metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String]),
149
187
  __metadata("design:returntype", Promise)
150
188
  ], SerializedCrudContract.prototype, "statement", null);
151
189
  __decorate([
152
190
  (0, fabric_contract_api_1.Transaction)(false),
153
191
  __metadata("design:type", Function),
154
- __metadata("design:paramtypes", [fabric_contract_api_1.Context, String, Boolean]),
192
+ __metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String, String]),
193
+ __metadata("design:returntype", Promise)
194
+ ], SerializedCrudContract.prototype, "listBy", null);
195
+ __decorate([
196
+ (0, fabric_contract_api_1.Transaction)(false),
197
+ __metadata("design:type", Function),
198
+ __metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String, Number, String]),
199
+ __metadata("design:returntype", Promise)
200
+ ], SerializedCrudContract.prototype, "paginateBy", null);
201
+ __decorate([
202
+ (0, fabric_contract_api_1.Transaction)(false),
203
+ __metadata("design:type", Function),
204
+ __metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String, String]),
155
205
  __metadata("design:returntype", Promise)
156
- ], SerializedCrudContract.prototype, "raw", null);
206
+ ], SerializedCrudContract.prototype, "findOneBy", null);
157
207
  __decorate([
158
208
  (0, fabric_contract_api_1.Transaction)(),
159
209
  __metadata("design:type", Function),
@@ -23,8 +23,12 @@ export declare class SerializedCrudContract<M extends Model> extends FabricCrudC
23
23
  deleteAll(context: Ctx, keys: string): Promise<string>;
24
24
  readAll(context: Ctx, keys: string): Promise<string>;
25
25
  updateAll(context: Ctx, models: string): Promise<string>;
26
- statement(context: Ctx, method: string): Promise<any>;
27
- raw(context: Ctx, rawInput: string, docsOnly: boolean): Promise<any>;
26
+ statement(context: Ctx, method: string, ...args: string[]): Promise<any>;
27
+ listBy(context: Ctx, key: string, order: string, ...args: string[]): Promise<M[]>;
28
+ paginateBy(context: Ctx, key: string, order: string, size: number, ...args: string[]): Promise<import("@decaf-ts/core").Paginator<M, M[], any>>;
29
+ findOneBy(context: Ctx, key: string, value: string, ...args: string[]): Promise<M>;
30
+ query(context: Ctx, condition: string, orderBy: string, order: string, limit?: number, skip?: number, ...args: string[]): Promise<M[]>;
31
+ raw(context: Ctx, rawInput: string, docsOnly: boolean, ...args: string[]): Promise<any>;
28
32
  init(ctx: Ctx): Promise<void>;
29
33
  healthcheck(context: Ctx): Promise<string>;
30
34
  createAll(context: Ctx, models: string): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"serialized-crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/ser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iCAAW,EAAC,KAAK,CAAC;;qCAER,6BAAG;;uDAOb;AAmCc;IADd,IAAA,iCAAW,GAAE;;qCACW,6BAAG;;kDAE3B;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACiB,6BAAG;;yDAKtC;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACoB,6BAAG;;uDAapC"}
@@ -1,6 +1,6 @@
1
- import { RepositoryFlags } from "@decaf-ts/db-decorators";
2
1
  import { ChaincodeStub, ClientIdentity } from "fabric-shim-api";
3
2
  import { Logger } from "@decaf-ts/logging";
3
+ import { FabricFlags } from "../shared/index";
4
4
  /**
5
5
  * @description Flags for Fabric chaincode contract operations
6
6
  * @summary Extends repository flags with Fabric-specific context elements available during Fabric chaincode execution, such as the ChaincodeStub, ClientIdentity and a request-scoped Logger.
@@ -10,7 +10,7 @@ import { Logger } from "@decaf-ts/logging";
10
10
  * @interface FabricContractFlags
11
11
  * @memberOf module:fabric.contracts
12
12
  */
13
- export interface FabricContractFlags extends RepositoryFlags {
13
+ export interface FabricContractFlags extends FabricFlags {
14
14
  /**
15
15
  * @description Chaincode stub for interacting with the ledger
16
16
  */
@@ -1,16 +1,13 @@
1
+ import "../shared/overrides";
2
+ import { type MangoQuery } from "@decaf-ts/for-couchdb";
1
3
  import { Client } from "@grpc/grpc-js";
2
- import { Model, type Serializer } from "@decaf-ts/decorator-validation";
3
- import { type FabricFlags, type PeerConfig } from "../shared/types";
4
+ import { Model, type ModelConstructor, type Serializer } from "@decaf-ts/decorator-validation";
5
+ import { type FabricFlags, type PeerConfig, type SegregatedModel } from "../shared/types";
4
6
  import { Gateway, Network, Contract as Contrakt } from "@hyperledger/fabric-gateway";
5
- import { BaseError, OperationKeys } from "@decaf-ts/db-decorators";
6
- import { Context, type PrimaryKeyType } from "@decaf-ts/db-decorators";
7
- import { Adapter, ContextOf, PreparedModel, Repository, Statement } from "@decaf-ts/core";
8
- import type { ContextualArgs, MaybeContextualArg } from "@decaf-ts/core";
9
- import type { FabricClientDispatch } from "./FabricClientDispatch";
7
+ import { BaseError, OperationKeys, type PrimaryKeyType } from "@decaf-ts/db-decorators";
8
+ import { Context, Adapter, type AdapterFlags, Repository, Statement, type PreparedStatement, Paginator, MaybeContextualArg, ContextualArgs, type PreparedModel } from "@decaf-ts/core";
9
+ import { FabricClientDispatch } from "./FabricClientDispatch";
10
10
  import { type Constructor } from "@decaf-ts/decoration";
11
- import { type FabricQuery } from "./types";
12
- export declare class FabricClientContext extends Context<FabricFlags> {
13
- }
14
11
  /**
15
12
  * @description Adapter for interacting with Hyperledger Fabric networks
16
13
  * @summary The FabricAdapter extends CouchDBAdapter to provide a seamless interface for interacting with Hyperledger Fabric networks.
@@ -62,7 +59,7 @@ export declare class FabricClientContext extends Context<FabricFlags> {
62
59
  * FabricAdapter->>FabricAdapter: serializer.deserialize(decodedResult)
63
60
  * FabricAdapter-->>Client: deserializedResult
64
61
  */
65
- export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, FabricQuery, FabricClientContext> {
62
+ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, MangoQuery, Context<FabricFlags>> {
66
63
  /**
67
64
  * @description Static text decoder for converting Uint8Array to string
68
65
  */
@@ -77,8 +74,9 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
77
74
  * @param {string} [alias] - Optional alias for the adapter instance
78
75
  */
79
76
  constructor(config: PeerConfig, alias?: string);
80
- Statement<M extends Model>(): Statement<M, Adapter<PeerConfig, Client, any, any>, any>;
81
- 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>;
77
+ Statement<M extends Model>(overrides?: Partial<AdapterFlags>): Statement<M, FabricClientAdapter, any, MangoQuery>;
78
+ Paginator<M extends Model>(query: PreparedStatement<any> | MangoQuery, size: number, clazz: Constructor<M>): Paginator<M, any, MangoQuery>;
79
+ 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<Context<FabricFlags>>;
82
80
  /**
83
81
  * @description Decodes a Uint8Array to a string
84
82
  * @summary Converts binary data received from Fabric to a string using UTF-8 encoding
@@ -86,8 +84,8 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
86
84
  * @return {string} The decoded string
87
85
  */
88
86
  decode(data: Uint8Array): string;
89
- repository<R extends Repository<any, Adapter<PeerConfig, Client, FabricQuery, FabricClientContext>>>(): Constructor<R>;
90
- protected createPrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: MaybeContextualArg<ContextOf<FabricClientAdapter>>): [Constructor<M>, PrimaryKeyType, Record<string, any>, ...any[], Context];
87
+ repository<R extends Repository<any, Adapter<PeerConfig, Client, MangoQuery, Context<FabricFlags>>>>(): Constructor<R>;
88
+ protected createPrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: MaybeContextualArg<Context<FabricFlags>>): [Constructor<M>, PrimaryKeyType, Record<string, any>, ...any[], Context];
91
89
  /**
92
90
  * @description Prepares multiple records for creation
93
91
  * @summary Adds necessary CouchDB fields to multiple records before creation
@@ -97,8 +95,8 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
97
95
  * @return A tuple containing the tableName, ids, and prepared records
98
96
  * @throws {InternalError} If ids and models arrays have different lengths
99
97
  */
100
- protected createAllPrefix<M extends Model>(clazz: Constructor<M>, ids: string[] | number[], models: Record<string, any>[], ...args: MaybeContextualArg<ContextOf<FabricClientAdapter>>): any[];
101
- protected updateAllPrefix<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: MaybeContextualArg<ContextOf<FabricClientAdapter>>): any[];
98
+ protected createAllPrefix<M extends Model>(clazz: Constructor<M>, ids: string[] | number[], models: Record<string, any>[], ...args: MaybeContextualArg<Context<FabricFlags>>): any[];
99
+ protected updateAllPrefix<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: MaybeContextualArg<Context<FabricFlags>>): any[];
102
100
  /**
103
101
  * @description Creates multiple records in a single transaction
104
102
  * @summary Submits a transaction to create multiple records in the Fabric ledger
@@ -108,7 +106,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
108
106
  * @param {Record<string, any>} transient - Transient data for the transaction
109
107
  * @return {Promise<Array<Record<string, any>>>} Promise resolving to the created records
110
108
  */
111
- createAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
109
+ createAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>[]>;
112
110
  /**
113
111
  * @description Reads multiple records in a single transaction
114
112
  * @summary Submits a transaction to read multiple records from the Fabric ledger
@@ -116,7 +114,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
116
114
  * @param {string[] | number[]} ids - Array of record identifiers to read
117
115
  * @return {Promise<Array<Record<string, any>>>} Promise resolving to the retrieved records
118
116
  */
119
- readAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
117
+ readAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>[]>;
120
118
  /**
121
119
  * @description Updates multiple records in a single transaction
122
120
  * @summary Submits a transaction to update multiple records in the Fabric ledger
@@ -126,7 +124,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
126
124
  * @param {Record<string, any>} transient - Transient data for the transaction
127
125
  * @return {Promise<Array<Record<string, any>>>} Promise resolving to the updated records
128
126
  */
129
- updateAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
127
+ updateAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>[]>;
130
128
  /**
131
129
  * @description Deletes multiple records in a single transaction
132
130
  * @summary Submits a transaction to delete multiple records from the Fabric ledger
@@ -135,7 +133,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
135
133
  * @param {Serializer<any>} serializer - Serializer for the model data
136
134
  * @return {Promise<Array<Record<string, any>>>} Promise resolving to the deleted records
137
135
  */
138
- deleteAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>[]>;
136
+ deleteAll<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>[]>;
139
137
  /**
140
138
  * @description Prepares a model for persistence
141
139
  * @summary Converts a model instance into a format suitable for database storage,
@@ -145,20 +143,8 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
145
143
  * @param pk - The primary key property name
146
144
  * @return The prepared data
147
145
  */
148
- prepare<M extends Model>(model: M, ...args: ContextualArgs<FabricClientContext>): PreparedModel;
149
- /**
150
- * @description Converts database data back into a model instance
151
- * @summary Reconstructs a model instance from database data, handling column mapping
152
- * and reattaching transient properties
153
- * @template M - The model type
154
- * @param obj - The database record
155
- * @param {string|Constructor<M>} clazz - The model class or name
156
- * @param pk - The primary key property name
157
- * @param {string|number|bigint} id - The primary key value
158
- * @param [transient] - Transient properties to reattach
159
- * @return {M} The reconstructed model instance
160
- */
161
- revert<M extends Model>(obj: Record<string, any>, clazz: Constructor<M>, id: PrimaryKeyType, transient?: Record<string, any>, ...args: ContextualArgs<FabricClientContext>): M;
146
+ prepare<M extends Model>(model: M, ...args: ContextualArgs<Context<FabricFlags>>): SegregatedModel<M> & PreparedModel;
147
+ revert<M extends Model>(obj: Record<string, any>, clazz: Constructor<M>, id: PrimaryKeyType, transient?: Record<string, any>, ...args: ContextualArgs<Context<FabricFlags>>): M;
162
148
  /**
163
149
  * @description Creates indexes for the given models
164
150
  * @summary Abstract method that must be implemented to create database indexes for the specified models
@@ -166,7 +152,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
166
152
  * @param {...Constructor<M>} models - The model constructors to create indexes for
167
153
  * @return {Promise<void>} A promise that resolves when all indexes are created
168
154
  */
169
- protected index<M extends Model>(...args: MaybeContextualArg<FabricClientContext, [
155
+ protected index<M extends Model>(...args: MaybeContextualArg<Context<FabricFlags>, [
170
156
  string,
171
157
  ...(Constructor<M> | string)[]
172
158
  ]>): Promise<void>;
@@ -179,7 +165,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
179
165
  * @param {Record<string, any>} transient - Transient data for the transaction
180
166
  * @return {Promise<Record<string, any>>} Promise resolving to the created record
181
167
  */
182
- create<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
168
+ create<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, transient?: Record<string, any>, ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>>;
183
169
  /**
184
170
  * @description Reads a single record
185
171
  * @summary Evaluates a transaction to read a record from the Fabric ledger
@@ -187,8 +173,8 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
187
173
  * @param {string | number} id - The record identifier
188
174
  * @return {Promise<Record<string, any>>} Promise resolving to the retrieved record
189
175
  */
190
- read<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
191
- updatePrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: MaybeContextualArg<FabricClientContext>): any[];
176
+ read<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>>;
177
+ updatePrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: MaybeContextualArg<Context<FabricFlags>>): any[];
192
178
  /**
193
179
  * @description Updates a single record
194
180
  * @summary Submits a transaction to update a record in the Fabric ledger
@@ -198,7 +184,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
198
184
  * @param {Record<string, any>} transient - Transient data for the transaction
199
185
  * @return {Promise<Record<string, any>>} Promise resolving to the updated record
200
186
  */
201
- update<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
187
+ update<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, transient?: Record<string, any>, ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>>;
202
188
  /**
203
189
  * @description Deletes a single record
204
190
  * @summary Submits a transaction to delete a record from the Fabric ledger
@@ -206,7 +192,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
206
192
  * @param {string | number} id - The record identifier to delete
207
193
  * @return {Promise<Record<string, any>>} Promise resolving to the deleted record
208
194
  */
209
- delete<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<FabricClientContext>): Promise<Record<string, any>>;
195
+ delete<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<Context<FabricFlags>>): Promise<Record<string, any>>;
210
196
  /**
211
197
  * @description Executes a raw query against the Fabric ledger
212
198
  * @summary Evaluates a transaction to perform a query using Mango Query syntax
@@ -232,7 +218,7 @@ export declare class FabricClientAdapter extends Adapter<PeerConfig, Client, Fab
232
218
  * FabricAdapter->>FabricAdapter: Process result based on type
233
219
  * FabricAdapter-->>Client: processed result
234
220
  */
235
- raw<V>(rawInput: FabricQuery, ...args: ContextualArgs<FabricClientContext>): Promise<V>;
221
+ raw<V, D extends boolean>(rawInput: MangoQuery, docsOnly: D | undefined, clazz: ModelConstructor<any>, ...args: ContextualArgs<Context<FabricFlags>>): Promise<V>;
236
222
  /**
237
223
  * @description Gets or creates a gRPC client for the Fabric peer
238
224
  * @summary Returns a cached client or creates a new one if none exists
@@ -7,6 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
+ var _a;
11
+ import "./../shared/overrides/index.js";
10
12
  import { CouchDBKeys } from "@decaf-ts/for-couchdb";
11
13
  import { Client } from "@grpc/grpc-js";
12
14
  import * as grpc from "@grpc/grpc-js";
@@ -15,16 +17,15 @@ import { debug, final, Logging } from "@decaf-ts/logging";
15
17
  import { connect, } from "@hyperledger/fabric-gateway";
16
18
  import { getIdentity, getSigner } from "./fabric-fs.js";
17
19
  import { InternalError, OperationKeys, SerializationError, BulkCrudOperationKeys, NotFoundError, ConflictError, BadRequestError, } from "@decaf-ts/db-decorators";
18
- import { Context } from "@decaf-ts/db-decorators";
19
- import { Adapter, AuthorizationError, ConnectionError, ForbiddenError, MigrationError, ObserverError, PagingError, PersistenceKeys, QueryError, UnsupportedError, } from "@decaf-ts/core";
20
- import { FabricClientRepository } from "./FabricClientRepository.js";
20
+ import { Context, Adapter, AuthorizationError, ConnectionError, ForbiddenError, MigrationError, ObserverError, PagingError, PersistenceKeys, QueryError, UnsupportedError, } from "@decaf-ts/core";
21
21
  import { FabricFlavour } from "./../shared/constants.js";
22
22
  import { ClientSerializer } from "./../shared/ClientSerializer.js";
23
23
  import { HSMSignerFactoryCustom } from "./fabric-hsm.js";
24
24
  import { generateModelIndexes, readModelFolders, writeIndexes, } from "./indexes/index.js";
25
25
  import { FabricClientStatement } from "./FabricClientStatement.js";
26
- export class FabricClientContext extends Context {
27
- }
26
+ import { FabricClientPaginator } from "./FabricClientPaginator.js";
27
+ import { FabricClientRepository } from "./FabricClientRepository.js";
28
+ import { EndorsementError } from "./../shared/errors.js";
28
29
  /**
29
30
  * @description Adapter for interacting with Hyperledger Fabric networks
30
31
  * @summary The FabricAdapter extends CouchDBAdapter to provide a seamless interface for interacting with Hyperledger Fabric networks.
@@ -93,14 +94,17 @@ export class FabricClientAdapter extends Adapter {
93
94
  super(config, FabricFlavour, alias);
94
95
  this.serializer = FabricClientAdapter.serializer;
95
96
  }
96
- Statement() {
97
- return new FabricClientStatement(this);
97
+ Statement(overrides) {
98
+ return new FabricClientStatement(this, overrides);
99
+ }
100
+ Paginator(query, size, clazz) {
101
+ return new FabricClientPaginator(this, query, size, clazz);
98
102
  }
99
103
  async context(operation, overrides, model, ...args) {
100
104
  const log = this.log.for(this.context);
101
105
  log.debug(`Creating new context for ${operation} operation on ${Array.isArray(model) ? model.map((m) => m.name) : model.name} model with flag overrides: ${JSON.stringify(overrides)}`);
102
106
  const flags = await this.flags(operation, model, overrides, ...args);
103
- return new FabricClientContext().accumulate(flags);
107
+ return new Context().accumulate(flags);
104
108
  }
105
109
  /**
106
110
  * @description Decodes a Uint8Array to a string
@@ -272,53 +276,24 @@ export class FabricClientAdapter extends Adapter {
272
276
  }
273
277
  return {
274
278
  record: split.model,
279
+ model: split.model,
275
280
  id: model[Model.pk(model.constructor)],
276
281
  transient: split.transient,
282
+ private: split.private,
283
+ shared: split.shared,
277
284
  };
278
285
  }
279
- /**
280
- * @description Converts database data back into a model instance
281
- * @summary Reconstructs a model instance from database data, handling column mapping
282
- * and reattaching transient properties
283
- * @template M - The model type
284
- * @param obj - The database record
285
- * @param {string|Constructor<M>} clazz - The model class or name
286
- * @param pk - The primary key property name
287
- * @param {string|number|bigint} id - The primary key value
288
- * @param [transient] - Transient properties to reattach
289
- * @return {M} The reconstructed model instance
290
- */
291
286
  revert(obj, clazz, id, transient, ...args) {
292
- const { log, ctx } = this.logCtx(args, this.revert);
293
- const ob = {};
294
- const pk = Model.pk(clazz);
295
- ob[pk] = id;
296
- const m = new clazz(ob);
297
- log.silly(`Rebuilding model ${m.constructor.name} id ${id}`);
298
- const metadata = obj[PersistenceKeys.METADATA];
299
- const result = Object.keys(m).reduce((accum, key) => {
300
- accum[key] = obj[key];
301
- return accum;
302
- }, m);
303
- if (ctx.get("rebuildWithTransient") && transient) {
287
+ const { log } = this.logCtx(args, this.revert);
288
+ if (transient) {
304
289
  log.verbose(`re-adding transient properties: ${Object.keys(transient).join(", ")}`);
305
290
  Object.entries(transient).forEach(([key, val]) => {
306
- if (key in result)
307
- throw new InternalError(`Transient property ${key} already exists on model ${m.constructor.name}. should be impossible`);
308
- result[key] = val;
291
+ if (key in obj)
292
+ throw new InternalError(`Transient property ${key} already exists on model ${typeof clazz === "string" ? clazz : clazz.name}. should be impossible`);
293
+ obj[key] = val;
309
294
  });
310
295
  }
311
- if (metadata) {
312
- // TODO move to couchdb
313
- log.silly(`Passing along ${this.flavour} persistence metadata for ${m.constructor.name} id ${id}: ${metadata}`);
314
- Object.defineProperty(result, PersistenceKeys.METADATA, {
315
- enumerable: false,
316
- configurable: true,
317
- writable: true,
318
- value: metadata,
319
- });
320
- }
321
- return result;
296
+ return new clazz(obj);
322
297
  }
323
298
  /**
324
299
  * @description Creates indexes for the given models
@@ -356,9 +331,8 @@ export class FabricClientAdapter extends Adapter {
356
331
  * @param {Record<string, any>} transient - Transient data for the transaction
357
332
  * @return {Promise<Record<string, any>>} Promise resolving to the created record
358
333
  */
359
- async create(clazz, id, model, ...args) {
334
+ async create(clazz, id, model, transient = {}, ...args) {
360
335
  const ctxArgs = [...args];
361
- const transient = {}; //(ctxArgs.shift() as Record<string, any>) || {}; TODO: Verify
362
336
  const { log } = this.logCtx(ctxArgs, this.create);
363
337
  const tableName = Model.tableName(clazz);
364
338
  log.verbose(`adding entry to ${tableName} table`);
@@ -399,9 +373,8 @@ export class FabricClientAdapter extends Adapter {
399
373
  * @param {Record<string, any>} transient - Transient data for the transaction
400
374
  * @return {Promise<Record<string, any>>} Promise resolving to the updated record
401
375
  */
402
- async update(clazz, id, model, ...args) {
376
+ async update(clazz, id, model, transient = {}, ...args) {
403
377
  const ctxArgs = [...args];
404
- const transient = {}; //(ctxArgs.shift() as Record<string, any>) || {}; TODO: Verify
405
378
  const { log } = this.logCtx(ctxArgs, this.updateAll);
406
379
  log.info(`CLIENT UPDATE class : ${typeof clazz}`);
407
380
  const tableName = Model.tableName(clazz);
@@ -451,13 +424,13 @@ export class FabricClientAdapter extends Adapter {
451
424
  * FabricAdapter->>FabricAdapter: Process result based on type
452
425
  * FabricAdapter-->>Client: processed result
453
426
  */
454
- async raw(rawInput, ...args) {
455
- const { log, ctxArgs } = this.logCtx(args, this.raw);
456
- const tableName = rawInput.class.name;
457
- log.info(`Performing prepared statement ${rawInput.method} on table ${Model.tableName(rawInput.class)}`);
427
+ async raw(rawInput, docsOnly = true, clazz, ...args) {
428
+ const { log } = this.logCtx(args, this.raw);
429
+ const tableName = clazz.name;
430
+ log.info(`Performing raw statement on table ${Model.tableName(clazz)}`);
458
431
  let transactionResult;
459
432
  try {
460
- transactionResult = await this.evaluateTransaction(PersistenceKeys.STATEMENT, [rawInput.method, ...rawInput.args, rawInput.params], undefined, undefined, tableName);
433
+ transactionResult = await this.evaluateTransaction("raw", [JSON.stringify(rawInput), docsOnly], undefined, undefined, tableName);
461
434
  }
462
435
  catch (e) {
463
436
  throw this.parseError(e);
@@ -785,6 +758,12 @@ export class FabricClientAdapter extends Adapter {
785
758
  // )
786
759
  // )
787
760
  // return new UnauthorizedPrivateDataAccess(err) as E;
761
+ if (err instanceof Error && err.code) {
762
+ switch (err.code) {
763
+ case 9:
764
+ return new EndorsementError(err);
765
+ }
766
+ }
788
767
  const msg = typeof err === "string" ? err : err.message;
789
768
  if (msg.includes(NotFoundError.name))
790
769
  return new NotFoundError(err);
@@ -823,34 +802,34 @@ __decorate([
823
802
  debug(),
824
803
  final(),
825
804
  __metadata("design:type", Function),
826
- __metadata("design:paramtypes", [Object, Object, Object, FabricClientContext]),
805
+ __metadata("design:paramtypes", [Object, Object, Object, Object, Context]),
827
806
  __metadata("design:returntype", Promise)
828
807
  ], FabricClientAdapter.prototype, "create", null);
829
808
  __decorate([
830
809
  debug(),
831
810
  final(),
832
811
  __metadata("design:type", Function),
833
- __metadata("design:paramtypes", [Object, Object, FabricClientContext]),
812
+ __metadata("design:paramtypes", [Object, Object, Context]),
834
813
  __metadata("design:returntype", Promise)
835
814
  ], FabricClientAdapter.prototype, "read", null);
836
815
  __decorate([
837
816
  debug(),
838
817
  final(),
839
818
  __metadata("design:type", Function),
840
- __metadata("design:paramtypes", [Object, Object, Object, FabricClientContext]),
819
+ __metadata("design:paramtypes", [Object, Object, Object, Object, Context]),
841
820
  __metadata("design:returntype", Promise)
842
821
  ], FabricClientAdapter.prototype, "update", null);
843
822
  __decorate([
844
823
  debug(),
845
824
  final(),
846
825
  __metadata("design:type", Function),
847
- __metadata("design:paramtypes", [Object, Object, FabricClientContext]),
826
+ __metadata("design:paramtypes", [Object, Object, Context]),
848
827
  __metadata("design:returntype", Promise)
849
828
  ], FabricClientAdapter.prototype, "delete", null);
850
829
  __decorate([
851
830
  debug(),
852
831
  __metadata("design:type", Function),
853
- __metadata("design:paramtypes", [Object, FabricClientContext]),
832
+ __metadata("design:paramtypes", [Object, typeof (_a = typeof D !== "undefined" && D) === "function" ? _a : Object, Object, Context]),
854
833
  __metadata("design:returntype", Promise)
855
834
  ], FabricClientAdapter.prototype, "raw", null);
856
835
  FabricClientAdapter.decoration();