@distrohelena/canton-typescript-sdk 0.1.4 → 0.1.6

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 (254) hide show
  1. package/README.md +333 -1
  2. package/dist/client/canton-client-options.d.ts +3 -0
  3. package/dist/client/canton-client-options.js +2 -0
  4. package/dist/client/service-registry.js +4 -3
  5. package/dist/core/errors/grpc-transport-error.d.ts +14 -0
  6. package/dist/core/errors/grpc-transport-error.js +76 -0
  7. package/dist/core/signing/sign-command-request.d.ts +4 -0
  8. package/dist/core/signing/sign-command-request.js +4 -0
  9. package/dist/core/signing/sign-command-result.d.ts +2 -0
  10. package/dist/core/signing/sign-command-result.js +9 -0
  11. package/dist/core/transports/transport.interface.d.ts +2 -2
  12. package/dist/core/types/canton-hash-purpose.d.ts +2 -1
  13. package/dist/core/types/canton-hash-purpose.js +1 -0
  14. package/dist/core/types/commands/create-and-exercise-command.js +1 -1
  15. package/dist/core/types/commands/exercise-by-key-command.js +2 -2
  16. package/dist/core/types/commands/exercise-command.js +2 -2
  17. package/dist/core/types/daml-numeric.d.ts +6 -0
  18. package/dist/core/types/daml-numeric.js +14 -0
  19. package/dist/core/types/daml-party.d.ts +6 -0
  20. package/dist/core/types/daml-party.js +14 -0
  21. package/dist/core/types/requests/create-decentralized-party-request.d.ts +41 -0
  22. package/dist/core/types/requests/create-decentralized-party-request.js +82 -0
  23. package/dist/core/types/requests/create-external-party-request.d.ts +42 -0
  24. package/dist/core/types/requests/create-external-party-request.js +47 -0
  25. package/dist/core/types/requests/finalize-decentralized-party-request.d.ts +39 -0
  26. package/dist/core/types/requests/finalize-decentralized-party-request.js +42 -0
  27. package/dist/core/types/requests/get-active-contracts-page-request.d.ts +15 -2
  28. package/dist/core/types/requests/get-active-contracts-page-request.js +4 -0
  29. package/dist/core/types/requests/submit-command-request.d.ts +2 -0
  30. package/dist/core/types/requests/submit-command-request.js +2 -0
  31. package/dist/core/types/topology/topology-signature-format.d.ts +2 -1
  32. package/dist/core/types/topology/topology-signature-format.js +1 -0
  33. package/dist/daml-lf/container/dar-archive-entry.d.ts +8 -0
  34. package/dist/daml-lf/container/dar-archive-entry.js +8 -0
  35. package/dist/daml-lf/container/dar-archive-loader.js +14 -0
  36. package/dist/daml-lf/container/dar-archive.d.ts +6 -0
  37. package/dist/daml-lf/container/dar-archive.js +4 -0
  38. package/dist/daml-lf/container/dar-source-bundle-loader.d.ts +5 -0
  39. package/dist/daml-lf/container/dar-source-bundle-loader.js +33 -0
  40. package/dist/daml-lf/container/dar-source-bundle.d.ts +45 -0
  41. package/dist/daml-lf/container/dar-source-bundle.js +11 -0
  42. package/dist/daml-lf/container/dar-source-file-entry.d.ts +8 -0
  43. package/dist/daml-lf/container/dar-source-file-entry.js +8 -0
  44. package/dist/daml-lf/daml-lf-compilation.d.ts +12 -0
  45. package/dist/daml-lf/daml-lf-compilation.js +35 -0
  46. package/dist/daml-lf/index.d.ts +11 -0
  47. package/dist/daml-lf/index.js +10 -0
  48. package/dist/daml-lf/interpreter/daml-lf-builtin-dispatch.d.ts +43 -0
  49. package/dist/daml-lf/interpreter/daml-lf-builtin-dispatch.js +933 -0
  50. package/dist/daml-lf/interpreter/daml-lf-evaluator.d.ts +95 -0
  51. package/dist/daml-lf/interpreter/daml-lf-evaluator.js +1131 -0
  52. package/dist/daml-lf/interpreter/daml-lf-interpreter-scaffold.d.ts +3 -0
  53. package/dist/daml-lf/interpreter/daml-lf-interpreter-scaffold.js +6 -1
  54. package/dist/daml-lf/interpreter/daml-lf-lexical-scope.d.ts +13 -0
  55. package/dist/daml-lf/interpreter/daml-lf-lexical-scope.js +46 -0
  56. package/dist/daml-lf/interpreter/daml-lf-runtime-frame.d.ts +16 -0
  57. package/dist/daml-lf/interpreter/daml-lf-runtime-frame.js +15 -0
  58. package/dist/daml-lf/interpreter/daml-lf-runtime-value.d.ts +21 -0
  59. package/dist/daml-lf/interpreter/daml-lf-runtime-value.js +4 -1
  60. package/dist/daml-lf/interpreter/daml-lf-step-kind.d.ts +7 -0
  61. package/dist/daml-lf/interpreter/daml-lf-step-kind.js +8 -0
  62. package/dist/daml-lf/interpreter/daml-lf-trace-sink.interface.d.ts +30 -0
  63. package/dist/daml-lf/interpreter/daml-lf-trace-sink.interface.js +1 -0
  64. package/dist/daml-lf/model/daml-lf-builtin-type.d.ts +3 -0
  65. package/dist/daml-lf/model/daml-lf-builtin-type.js +3 -0
  66. package/dist/daml-lf/model/daml-lf-choice.d.ts +5 -0
  67. package/dist/daml-lf/model/daml-lf-choice.js +4 -0
  68. package/dist/daml-lf/model/daml-lf-expression-path.d.ts +2 -0
  69. package/dist/daml-lf/model/daml-lf-expression-path.js +81 -0
  70. package/dist/daml-lf/model/daml-lf-expression.d.ts +146 -0
  71. package/dist/daml-lf/model/daml-lf-expression.js +71 -0
  72. package/dist/daml-lf/model/daml-lf-template.d.ts +2 -0
  73. package/dist/daml-lf/model/daml-lf-template.js +2 -0
  74. package/dist/daml-lf/model/daml-lf-type.d.ts +2 -0
  75. package/dist/daml-lf/model/daml-lf-type.js +4 -0
  76. package/dist/daml-lf/model/lf-2-model-mapper.d.ts +5 -0
  77. package/dist/daml-lf/model/lf-2-model-mapper.js +445 -12
  78. package/dist/debugger/errors/replay-determinism.exception.d.ts +3 -0
  79. package/dist/debugger/errors/replay-determinism.exception.js +3 -0
  80. package/dist/debugger/errors/replay-missing-package.exception.d.ts +3 -0
  81. package/dist/debugger/errors/replay-missing-package.exception.js +3 -0
  82. package/dist/debugger/errors/replay-missing-source.exception.d.ts +3 -0
  83. package/dist/debugger/errors/replay-missing-source.exception.js +3 -0
  84. package/dist/debugger/errors/replay-source-map.exception.d.ts +3 -0
  85. package/dist/debugger/errors/replay-source-map.exception.js +3 -0
  86. package/dist/debugger/errors/replay-state-hydration.exception.d.ts +3 -0
  87. package/dist/debugger/errors/replay-state-hydration.exception.js +3 -0
  88. package/dist/debugger/errors/replay-unsupported-lf-construct.exception.d.ts +3 -0
  89. package/dist/debugger/errors/replay-unsupported-lf-construct.exception.js +3 -0
  90. package/dist/debugger/errors/replay-unsupported-update.exception.d.ts +3 -0
  91. package/dist/debugger/errors/replay-unsupported-update.exception.js +3 -0
  92. package/dist/debugger/index.d.ts +31 -0
  93. package/dist/debugger/index.js +31 -0
  94. package/dist/debugger/ledger-replay-debugger-client.d.ts +31 -0
  95. package/dist/debugger/ledger-replay-debugger-client.js +53 -0
  96. package/dist/debugger/replay/ledger-replay-environment-builder.d.ts +95 -0
  97. package/dist/debugger/replay/ledger-replay-environment-builder.js +249 -0
  98. package/dist/debugger/replay/ledger-replay-session-loader.d.ts +78 -0
  99. package/dist/debugger/replay/ledger-replay-session-loader.js +565 -0
  100. package/dist/debugger/replay/replay-artifact-resolver.d.ts +30 -0
  101. package/dist/debugger/replay/replay-artifact-resolver.js +210 -0
  102. package/dist/debugger/replay/replay-determinism-validator.d.ts +12 -0
  103. package/dist/debugger/replay/replay-determinism-validator.js +161 -0
  104. package/dist/debugger/replay/replay-entrypoint-definition-resolver.d.ts +40 -0
  105. package/dist/debugger/replay/replay-entrypoint-definition-resolver.js +337 -0
  106. package/dist/debugger/replay/replay-entrypoint.d.ts +22 -0
  107. package/dist/debugger/replay/replay-entrypoint.js +14 -0
  108. package/dist/debugger/replay/replay-ledger-value-normalizer.d.ts +7 -0
  109. package/dist/debugger/replay/replay-ledger-value-normalizer.js +194 -0
  110. package/dist/debugger/replay/replay-update-loader.d.ts +24 -0
  111. package/dist/debugger/replay/replay-update-loader.js +94 -0
  112. package/dist/debugger/replay/replay-update-visibility-validator.d.ts +19 -0
  113. package/dist/debugger/replay/replay-update-visibility-validator.js +19 -0
  114. package/dist/debugger/session/in-memory-replay-session-store.d.ts +27 -0
  115. package/dist/debugger/session/in-memory-replay-session-store.js +109 -0
  116. package/dist/debugger/session/replay-phase.d.ts +7 -0
  117. package/dist/debugger/session/replay-phase.js +8 -0
  118. package/dist/debugger/session/replay-scope.d.ts +10 -0
  119. package/dist/debugger/session/replay-scope.js +10 -0
  120. package/dist/debugger/session/replay-session-metadata.d.ts +10 -0
  121. package/dist/debugger/session/replay-session-metadata.js +10 -0
  122. package/dist/debugger/session/replay-session-request.d.ts +6 -0
  123. package/dist/debugger/session/replay-session-request.js +10 -0
  124. package/dist/debugger/session/replay-session.d.ts +12 -0
  125. package/dist/debugger/session/replay-session.js +10 -0
  126. package/dist/debugger/session/replay-source-location.d.ts +17 -0
  127. package/dist/debugger/session/replay-source-location.js +16 -0
  128. package/dist/debugger/session/replay-stack-frame.d.ts +8 -0
  129. package/dist/debugger/session/replay-stack-frame.js +8 -0
  130. package/dist/debugger/session/replay-state-delta.d.ts +29 -0
  131. package/dist/debugger/session/replay-state-delta.js +24 -0
  132. package/dist/debugger/session/replay-step-advance-result.d.ts +24 -0
  133. package/dist/debugger/session/replay-step-advance-result.js +16 -0
  134. package/dist/debugger/session/replay-step.d.ts +30 -0
  135. package/dist/debugger/session/replay-step.js +24 -0
  136. package/dist/debugger/session/replay-value-preview.d.ts +8 -0
  137. package/dist/debugger/session/replay-value-preview.js +15 -0
  138. package/dist/debugger/source/daml-source-mapper.d.ts +12 -0
  139. package/dist/debugger/source/daml-source-mapper.js +21 -0
  140. package/dist/debugger/source/dar-source-map-metadata.d.ts +26 -0
  141. package/dist/debugger/source/dar-source-map-metadata.js +10 -0
  142. package/dist/debugger/source/source-coverage-validator.d.ts +8 -0
  143. package/dist/debugger/source/source-coverage-validator.js +16 -0
  144. package/dist/debugger/source/source-indexed-compilation.d.ts +45 -0
  145. package/dist/debugger/source/source-indexed-compilation.js +110 -0
  146. package/dist/debugger/source/source-mapping-precision.d.ts +5 -0
  147. package/dist/debugger/source/source-mapping-precision.js +4 -0
  148. package/dist/index.d.ts +20 -0
  149. package/dist/index.js +12 -0
  150. package/dist/query/cache/memory-query-cache.d.ts +9 -0
  151. package/dist/query/cache/memory-query-cache.js +24 -0
  152. package/dist/query/cache/query-cache-store.d.ts +5 -0
  153. package/dist/query/cache/query-cache-store.js +1 -0
  154. package/dist/query/canton-manager-options.d.ts +17 -0
  155. package/dist/query/canton-manager-options.js +1 -0
  156. package/dist/query/canton-manager.d.ts +11 -0
  157. package/dist/query/canton-manager.js +42 -0
  158. package/dist/query/errors/pqs-query-error.d.ts +10 -0
  159. package/dist/query/errors/pqs-query-error.js +11 -0
  160. package/dist/query/errors/pqs-schema-profile-error.d.ts +3 -0
  161. package/dist/query/errors/pqs-schema-profile-error.js +3 -0
  162. package/dist/query/errors/query-capability-error.d.ts +7 -0
  163. package/dist/query/errors/query-capability-error.js +10 -0
  164. package/dist/query/grpc/grpc-contract-query-client.d.ts +32 -0
  165. package/dist/query/grpc/grpc-contract-query-client.js +126 -0
  166. package/dist/query/model-types.d.ts +258 -0
  167. package/dist/query/model-types.js +14 -0
  168. package/dist/query/pqs/pqs-pool.d.ts +13 -0
  169. package/dist/query/pqs/pqs-pool.js +18 -0
  170. package/dist/query/pqs/pqs-query-client.d.ts +49 -0
  171. package/dist/query/pqs/pqs-query-client.js +324 -0
  172. package/dist/query/pqs/pqs-schema-profile.d.ts +25 -0
  173. package/dist/query/pqs/pqs-schema-profile.js +120 -0
  174. package/dist/query/pqs/pqs-sql-compiler.d.ts +7 -0
  175. package/dist/query/pqs/pqs-sql-compiler.js +132 -0
  176. package/dist/query/pqs/read-only-sql.d.ts +1 -0
  177. package/dist/query/pqs/read-only-sql.js +35 -0
  178. package/dist/query/query-client.d.ts +61 -0
  179. package/dist/query/query-client.js +1 -0
  180. package/dist/query/query-source.d.ts +4 -0
  181. package/dist/query/query-source.js +5 -0
  182. package/dist/services/commands/command-payload-builder.js +3 -3
  183. package/dist/services/commands/command-submission-pipeline.js +1 -7
  184. package/dist/services/party-management/decentralized-party-lifecycle.d.ts +6 -0
  185. package/dist/services/party-management/decentralized-party-lifecycle.js +82 -0
  186. package/dist/services/party-management/party-management-service-client.d.ts +16 -1
  187. package/dist/services/party-management/party-management-service-client.js +142 -1
  188. package/dist/services/topology-manager-write/topology-signed-transaction-assembler.js +4 -0
  189. package/dist/testing/campaign/campaign-artifact.d.ts +20 -0
  190. package/dist/testing/campaign/campaign-artifact.js +147 -0
  191. package/dist/testing/campaign/campaign-definition.d.ts +9 -0
  192. package/dist/testing/campaign/campaign-definition.js +78 -0
  193. package/dist/testing/campaign/campaign-metrics.d.ts +32 -0
  194. package/dist/testing/campaign/campaign-metrics.js +26 -0
  195. package/dist/testing/campaign/campaign-model.d.ts +11 -0
  196. package/dist/testing/campaign/campaign-model.js +21 -0
  197. package/dist/testing/campaign/campaign-runner.d.ts +99 -0
  198. package/dist/testing/campaign/campaign-runner.js +194 -0
  199. package/dist/testing/campaign/campaign-scheduler.d.ts +40 -0
  200. package/dist/testing/campaign/campaign-scheduler.js +75 -0
  201. package/dist/testing/campaign/campaign-types.d.ts +52 -0
  202. package/dist/testing/campaign/campaign-types.js +11 -0
  203. package/dist/testing/daml/daml-action-arbitrary.d.ts +13 -0
  204. package/dist/testing/daml/daml-action-arbitrary.js +24 -0
  205. package/dist/testing/daml/daml-choice-action-arbitrary.d.ts +18 -0
  206. package/dist/testing/daml/daml-choice-action-arbitrary.js +27 -0
  207. package/dist/testing/daml/daml-create-action-arbitrary.d.ts +19 -0
  208. package/dist/testing/daml/daml-create-action-arbitrary.js +34 -0
  209. package/dist/testing/daml/daml-testing-catalog.d.ts +38 -0
  210. package/dist/testing/daml/daml-testing-catalog.js +40 -0
  211. package/dist/testing/daml/daml-value-arbitrary.d.ts +8 -0
  212. package/dist/testing/daml/daml-value-arbitrary.js +43 -0
  213. package/dist/testing/daml/declarative-campaign-arbitrary.d.ts +15 -0
  214. package/dist/testing/daml/declarative-campaign-arbitrary.js +30 -0
  215. package/dist/testing/errors/invariant-campaign-failure.d.ts +24 -0
  216. package/dist/testing/errors/invariant-campaign-failure.js +37 -0
  217. package/dist/testing/errors/testing-configuration-error.d.ts +3 -0
  218. package/dist/testing/errors/testing-configuration-error.js +6 -0
  219. package/dist/testing/handlers/handler.d.ts +19 -0
  220. package/dist/testing/handlers/handler.js +31 -0
  221. package/dist/testing/index.d.ts +22 -0
  222. package/dist/testing/index.js +22 -0
  223. package/dist/testing/runtime/campaign-isolation.d.ts +14 -0
  224. package/dist/testing/runtime/campaign-isolation.js +23 -0
  225. package/dist/testing/runtime/canton-test-runtime.d.ts +58 -0
  226. package/dist/testing/runtime/canton-test-runtime.js +138 -0
  227. package/dist/testing/runtime/declarative-action-executor.d.ts +16 -0
  228. package/dist/testing/runtime/declarative-action-executor.js +41 -0
  229. package/dist/testing/targets/target.d.ts +49 -0
  230. package/dist/testing/targets/target.js +121 -0
  231. package/dist/transports/grpc/grpc-channel-factory.d.ts +4 -0
  232. package/dist/transports/grpc/grpc-channel-factory.js +42 -1
  233. package/dist/transports/grpc/grpc-transport.d.ts +2 -2
  234. package/dist/transports/grpc/grpc-transport.js +42 -3
  235. package/dist/transports/grpc/mappers/commands-mapper.d.ts +10 -2
  236. package/dist/transports/grpc/mappers/commands-mapper.js +30 -12
  237. package/dist/transports/grpc/mappers/contracts-mapper.d.ts +3 -1
  238. package/dist/transports/grpc/mappers/contracts-mapper.js +16 -3
  239. package/dist/transports/grpc/mappers/interactive-command-mapper.d.ts +15 -0
  240. package/dist/transports/grpc/mappers/interactive-command-mapper.js +54 -0
  241. package/dist/transports/grpc/mappers/topology-manager-write-mapper.js +59 -1
  242. package/dist/transports/json/json-transport.d.ts +2 -2
  243. package/dist/transports/json/json-transport.js +2 -2
  244. package/dist/transports/json/mappers/commands-mapper.js +23 -9
  245. package/node/.generated/start-local/additional-config.extra-participants.conf +37 -0
  246. package/node/.generated/start-local/additional-config.extra-validators.conf +35 -0
  247. package/node/.generated/start-local/compose-extra-participants.yaml +147 -0
  248. package/node/.generated/start-local/extra-participants.env +30 -0
  249. package/node/es256-jwt.mjs +177 -0
  250. package/node/start-local.sh +886 -0
  251. package/node/stop-local.sh +200 -0
  252. package/node/test-start-local.sh +354 -0
  253. package/node/test-stop-local.sh +112 -0
  254. package/package.json +21 -2
@@ -0,0 +1,26 @@
1
+ import { SourceMappingPrecision } from "./source-mapping-precision.js";
2
+ export interface DarSourceMapMetadataExecutable {
3
+ packageId: string;
4
+ moduleName: string;
5
+ definitionName: string;
6
+ path: string;
7
+ startLine: number;
8
+ startColumn: number;
9
+ endLine: number;
10
+ endColumn: number;
11
+ precision?: SourceMappingPrecision;
12
+ entrypointKind?: "create" | "exercise";
13
+ templateName?: string;
14
+ choiceName?: string;
15
+ choiceArgumentFieldName?: string;
16
+ }
17
+ export declare class DarSourceMapMetadata {
18
+ readonly packageId?: string;
19
+ readonly importedPackages: readonly string[];
20
+ readonly executables: readonly DarSourceMapMetadataExecutable[];
21
+ constructor(init?: {
22
+ packageId?: string;
23
+ importedPackages?: readonly string[];
24
+ executables?: readonly DarSourceMapMetadataExecutable[];
25
+ });
26
+ }
@@ -0,0 +1,10 @@
1
+ export class DarSourceMapMetadata {
2
+ packageId;
3
+ importedPackages;
4
+ executables;
5
+ constructor(init) {
6
+ this.packageId = init?.packageId;
7
+ this.importedPackages = init?.importedPackages ?? [];
8
+ this.executables = init?.executables ?? [];
9
+ }
10
+ }
@@ -0,0 +1,8 @@
1
+ import { SourceIndexedCompilation } from "./source-indexed-compilation.js";
2
+ export declare class SourceCoverageValidator {
3
+ static validateOrThrow(indexedCompilation: SourceIndexedCompilation, requiredSymbols: readonly {
4
+ packageId: string;
5
+ moduleName: string;
6
+ definitionName: string;
7
+ }[]): void;
8
+ }
@@ -0,0 +1,16 @@
1
+ import { ReplaySourceMapException } from "../errors/replay-source-map.exception.js";
2
+ export class SourceCoverageValidator {
3
+ static validateOrThrow(indexedCompilation, requiredSymbols) {
4
+ for (const symbol of requiredSymbols) {
5
+ try {
6
+ indexedCompilation.getDefinitionSourceOrThrow(symbol.packageId, symbol.moduleName, symbol.definitionName);
7
+ }
8
+ catch (error) {
9
+ if (error instanceof ReplaySourceMapException) {
10
+ throw error;
11
+ }
12
+ throw new ReplaySourceMapException(`failed to validate source coverage for '${symbol.packageId}::${symbol.moduleName}::${symbol.definitionName}'`);
13
+ }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,45 @@
1
+ import { DamlLfCompilation } from "../../daml-lf/daml-lf-compilation.js";
2
+ import { DarSourceBundle } from "../../daml-lf/container/dar-source-bundle.js";
3
+ import { DamlLfExpression } from "../../daml-lf/model/daml-lf-expression.js";
4
+ import { SourceMappingPrecision } from "./source-mapping-precision.js";
5
+ export interface IndexedDefinitionSource {
6
+ packageId: string;
7
+ moduleName: string;
8
+ definitionName: string;
9
+ path: string;
10
+ startLine: number;
11
+ startColumn: number;
12
+ endLine: number;
13
+ endColumn: number;
14
+ precision: SourceMappingPrecision;
15
+ }
16
+ export interface IndexedExecutableSource extends IndexedDefinitionSource {
17
+ entrypointKind?: "create" | "exercise";
18
+ templateName?: string;
19
+ choiceName?: string;
20
+ choiceArgumentFieldName?: string;
21
+ }
22
+ export interface IndexedExpressionSource {
23
+ path: string;
24
+ startLine: number;
25
+ startColumn: number;
26
+ endLine: number;
27
+ endColumn: number;
28
+ }
29
+ export declare class SourceIndexedCompilation {
30
+ readonly compilation: DamlLfCompilation;
31
+ private readonly definitionSources;
32
+ private readonly moduleSources;
33
+ private readonly expressionSources;
34
+ private constructor();
35
+ static createOrThrow(compilation: DamlLfCompilation, sourceBundles: readonly DarSourceBundle[]): SourceIndexedCompilation;
36
+ getDefinitionSourceOrThrow(packageId: string, moduleName: string, definitionName: string): IndexedExecutableSource;
37
+ getModuleSourceOrThrow(packageId: string, moduleName: string): IndexedDefinitionSource;
38
+ getExecutableSources(): readonly IndexedExecutableSource[];
39
+ findExecutableSourceAt(path: string, line: number, column: number): IndexedExecutableSource | undefined;
40
+ getExpressionSource(expression: DamlLfExpression): IndexedExpressionSource | undefined;
41
+ private containsSourceLocation;
42
+ private compareSourceSpecificity;
43
+ private static createDefinitionKey;
44
+ private static createModuleKey;
45
+ }
@@ -0,0 +1,110 @@
1
+ import { getDamlLfExpressionAtPath } from "../../daml-lf/model/daml-lf-expression-path.js";
2
+ import { ReplaySourceMapException } from "../errors/replay-source-map.exception.js";
3
+ import { SourceMappingPrecision, } from "./source-mapping-precision.js";
4
+ export class SourceIndexedCompilation {
5
+ compilation;
6
+ definitionSources = new Map();
7
+ moduleSources = new Map();
8
+ expressionSources = new Map();
9
+ constructor(compilation) {
10
+ this.compilation = compilation;
11
+ }
12
+ static createOrThrow(compilation, sourceBundles) {
13
+ const indexed = new SourceIndexedCompilation(compilation);
14
+ for (const bundle of sourceBundles) {
15
+ for (const executable of bundle.metadata.executables) {
16
+ const source = {
17
+ packageId: executable.packageId,
18
+ moduleName: executable.moduleName,
19
+ definitionName: executable.definitionName,
20
+ path: executable.path,
21
+ startLine: executable.startLine,
22
+ startColumn: executable.startColumn,
23
+ endLine: executable.endLine,
24
+ endColumn: executable.endColumn,
25
+ precision: executable.precision
26
+ ?? SourceMappingPrecision.fallback,
27
+ entrypointKind: executable.entrypointKind,
28
+ templateName: executable.templateName,
29
+ choiceName: executable.choiceName,
30
+ choiceArgumentFieldName: executable.choiceArgumentFieldName,
31
+ };
32
+ indexed.definitionSources.set(SourceIndexedCompilation.createDefinitionKey(executable.packageId, executable.moduleName, executable.definitionName), source);
33
+ indexed.moduleSources.set(SourceIndexedCompilation.createModuleKey(executable.packageId, executable.moduleName), source);
34
+ }
35
+ for (const expressionLocation of bundle.metadata.expressionLocations) {
36
+ if (!Array.isArray(expressionLocation.expressionPath)) {
37
+ throw new ReplaySourceMapException(`expression source mapping for '${expressionLocation.packageId}::${expressionLocation.moduleName}::${expressionLocation.definitionName}' is missing its expression path`);
38
+ }
39
+ const definition = compilation.getValueDefinitionOrThrow(expressionLocation.packageId, expressionLocation.moduleName, expressionLocation.definitionName);
40
+ const expression = getDamlLfExpressionAtPath(definition.expression, expressionLocation.expressionPath);
41
+ if (expression === undefined) {
42
+ throw new ReplaySourceMapException(`invalid expression path for '${expressionLocation.packageId}::${expressionLocation.moduleName}::${expressionLocation.definitionName}'`);
43
+ }
44
+ indexed.expressionSources.set(expression, {
45
+ path: expressionLocation.path,
46
+ startLine: expressionLocation.startLine,
47
+ startColumn: expressionLocation.startColumn,
48
+ endLine: expressionLocation.endLine,
49
+ endColumn: expressionLocation.endColumn,
50
+ });
51
+ }
52
+ }
53
+ return indexed;
54
+ }
55
+ getDefinitionSourceOrThrow(packageId, moduleName, definitionName) {
56
+ const source = this.definitionSources.get(SourceIndexedCompilation.createDefinitionKey(packageId, moduleName, definitionName));
57
+ if (source === undefined) {
58
+ throw new ReplaySourceMapException(`missing source mapping for '${packageId}::${moduleName}::${definitionName}'`);
59
+ }
60
+ return source;
61
+ }
62
+ getModuleSourceOrThrow(packageId, moduleName) {
63
+ const source = this.moduleSources.get(SourceIndexedCompilation.createModuleKey(packageId, moduleName));
64
+ if (source === undefined) {
65
+ throw new ReplaySourceMapException(`missing source mapping for module '${packageId}::${moduleName}'`);
66
+ }
67
+ return source;
68
+ }
69
+ getExecutableSources() {
70
+ return [...this.definitionSources.values()];
71
+ }
72
+ findExecutableSourceAt(path, line, column) {
73
+ return this.getExecutableSources()
74
+ .filter((source) => source.path === path
75
+ && this.containsSourceLocation(source, line, column))
76
+ .sort((left, right) => this.compareSourceSpecificity(left, right))
77
+ .at(0);
78
+ }
79
+ getExpressionSource(expression) {
80
+ return this.expressionSources.get(expression);
81
+ }
82
+ containsSourceLocation(source, line, column) {
83
+ const startsBeforeOrAt = source.startLine < line
84
+ || (source.startLine === line && source.startColumn <= column);
85
+ const endsAfterOrAt = source.endLine > line
86
+ || (source.endLine === line && source.endColumn >= column);
87
+ return startsBeforeOrAt && endsAfterOrAt;
88
+ }
89
+ compareSourceSpecificity(left, right) {
90
+ if (left.startLine !== right.startLine) {
91
+ return right.startLine - left.startLine;
92
+ }
93
+ if (left.startColumn !== right.startColumn) {
94
+ return right.startColumn - left.startColumn;
95
+ }
96
+ if (left.endLine !== right.endLine) {
97
+ return left.endLine - right.endLine;
98
+ }
99
+ if (left.endColumn !== right.endColumn) {
100
+ return left.endColumn - right.endColumn;
101
+ }
102
+ return 0;
103
+ }
104
+ static createDefinitionKey(packageId, moduleName, definitionName) {
105
+ return `${packageId}::${moduleName}::${definitionName}`;
106
+ }
107
+ static createModuleKey(packageId, moduleName) {
108
+ return `${packageId}::${moduleName}`;
109
+ }
110
+ }
@@ -0,0 +1,5 @@
1
+ export declare const SourceMappingPrecision: {
2
+ readonly exact: "exact";
3
+ readonly fallback: "fallback";
4
+ };
5
+ export type SourceMappingPrecision = (typeof SourceMappingPrecision)[keyof typeof SourceMappingPrecision];
@@ -0,0 +1,4 @@
1
+ export const SourceMappingPrecision = {
2
+ exact: "exact",
3
+ fallback: "fallback",
4
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,14 @@
1
1
  export { CantonClient } from "./client/canton-client.js";
2
+ export { CantonManager } from "./query/canton-manager.js";
3
+ export { QuerySource } from "./query/query-source.js";
4
+ export { MemoryQueryCache } from "./query/cache/memory-query-cache.js";
5
+ export { QueryCapabilityError } from "./query/errors/query-capability-error.js";
6
+ export { PqsQueryError } from "./query/errors/pqs-query-error.js";
7
+ export { PqsSchemaProfileError } from "./query/errors/pqs-schema-profile-error.js";
8
+ export type { CantonManagerOptions, PqsQueryOptions, QueryCacheOptions, } from "./query/canton-manager-options.js";
9
+ export type { QueryCacheStore } from "./query/cache/query-cache-store.js";
10
+ export type { ContractFindManyArgs, ContractFindUniqueArgs, ContractCountArgs, ContractRow, ContractTypeRow, EventRow, ExerciseRow, ExerciseTypeRow, PackageRow, TransactionRow, WatermarkRow, RowWhere, RowSelect, RowOrderBy, } from "./query/model-types.js";
11
+ export type { QueryClient, QueryDelegate, QueryCollectionDelegate } from "./query/query-client.js";
2
12
  export { CantonHashingClient } from "./client/canton-hashing-client.js";
3
13
  export { CantonClientOptions } from "./client/canton-client-options.js";
4
14
  export { ExternalPartyActivationClient } from "./client/external-party-activation-client.js";
@@ -72,6 +82,8 @@ export { CommitmentTimeRange } from "./core/types/commitment-time-range.js";
72
82
  export { CounterParticipantInfo } from "./core/types/counter-participant-info.js";
73
83
  export { ContractArchived } from "./core/types/contract-archived.js";
74
84
  export { ContractCreated } from "./core/types/contract-created.js";
85
+ export { DamlNumeric } from "./core/types/daml-numeric.js";
86
+ export { DamlParty } from "./core/types/daml-party.js";
75
87
  export { EventStreamKind } from "./core/types/event-stream-kind.js";
76
88
  export { UserRightKind } from "./core/types/user-right-kind.js";
77
89
  export { IdentityProviderConfig } from "./core/types/identity-provider-config.js";
@@ -186,7 +198,13 @@ export { ExerciseByKeyCommand } from "./core/types/commands/exercise-by-key-comm
186
198
  export { ExerciseCommand } from "./core/types/commands/exercise-command.js";
187
199
  export type { LedgerCommand } from "./core/types/commands/ledger-command.js";
188
200
  export { AddTopologyTransactionsRequest } from "./core/types/requests/add-topology-transactions-request.js";
201
+ export { CreateDecentralizedPartyRequest } from "./core/types/requests/create-decentralized-party-request.js";
202
+ export type { DecentralizedPartyKey, DecentralizedPartySigner, DecentralizedPartySigningRequest } from "./core/types/requests/create-decentralized-party-request.js";
203
+ export { FinalizeDecentralizedPartyRequest, PreparedDecentralizedParty } from "./core/types/requests/finalize-decentralized-party-request.js";
204
+ export type { DecentralizedPartyDetachedSignature, PreparedDecentralizedPartySigningRequest } from "./core/types/requests/finalize-decentralized-party-request.js";
189
205
  export { AllocateExternalPartyRequest } from "./core/types/requests/allocate-external-party-request.js";
206
+ export { CreateExternalPartyRequest, } from "./core/types/requests/create-external-party-request.js";
207
+ export type { ExternalPartySigner, ExternalPartySigningRequest, ExternalPartySigningResult, ExternalPartySigningPayloadKind, } from "./core/types/requests/create-external-party-request.js";
190
208
  export { AllocatePartyRequest } from "./core/types/requests/allocate-party-request.js";
191
209
  export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
192
210
  export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
@@ -384,6 +402,8 @@ export { ValidationError } from "./core/errors/validation-error.js";
384
402
  export { AuthenticationError } from "./core/errors/authentication-error.js";
385
403
  export { AuthorizationError } from "./core/errors/authorization-error.js";
386
404
  export { TransportError } from "./core/errors/transport-error.js";
405
+ export { GrpcTransportError } from "./core/errors/grpc-transport-error.js";
406
+ export type { GrpcErrorMetadata, GrpcStatusDetails, } from "./core/errors/grpc-transport-error.js";
387
407
  export { SigningError } from "./core/errors/signing-error.js";
388
408
  export { TimeoutError } from "./core/errors/timeout-error.js";
389
409
  export { ConflictError } from "./core/errors/conflict-error.js";
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  export { CantonClient } from "./client/canton-client.js";
2
+ export { CantonManager } from "./query/canton-manager.js";
3
+ export { QuerySource } from "./query/query-source.js";
4
+ export { MemoryQueryCache } from "./query/cache/memory-query-cache.js";
5
+ export { QueryCapabilityError } from "./query/errors/query-capability-error.js";
6
+ export { PqsQueryError } from "./query/errors/pqs-query-error.js";
7
+ export { PqsSchemaProfileError } from "./query/errors/pqs-schema-profile-error.js";
2
8
  export { CantonHashingClient } from "./client/canton-hashing-client.js";
3
9
  export { CantonClientOptions } from "./client/canton-client-options.js";
4
10
  export { ExternalPartyActivationClient } from "./client/external-party-activation-client.js";
@@ -68,6 +74,8 @@ export { CommitmentTimeRange } from "./core/types/commitment-time-range.js";
68
74
  export { CounterParticipantInfo } from "./core/types/counter-participant-info.js";
69
75
  export { ContractArchived } from "./core/types/contract-archived.js";
70
76
  export { ContractCreated } from "./core/types/contract-created.js";
77
+ export { DamlNumeric } from "./core/types/daml-numeric.js";
78
+ export { DamlParty } from "./core/types/daml-party.js";
71
79
  export { EventStreamKind } from "./core/types/event-stream-kind.js";
72
80
  export { UserRightKind } from "./core/types/user-right-kind.js";
73
81
  export { IdentityProviderConfig } from "./core/types/identity-provider-config.js";
@@ -180,7 +188,10 @@ export { CreateCommand } from "./core/types/commands/create-command.js";
180
188
  export { ExerciseByKeyCommand } from "./core/types/commands/exercise-by-key-command.js";
181
189
  export { ExerciseCommand } from "./core/types/commands/exercise-command.js";
182
190
  export { AddTopologyTransactionsRequest } from "./core/types/requests/add-topology-transactions-request.js";
191
+ export { CreateDecentralizedPartyRequest } from "./core/types/requests/create-decentralized-party-request.js";
192
+ export { FinalizeDecentralizedPartyRequest, PreparedDecentralizedParty } from "./core/types/requests/finalize-decentralized-party-request.js";
183
193
  export { AllocateExternalPartyRequest } from "./core/types/requests/allocate-external-party-request.js";
194
+ export { CreateExternalPartyRequest, } from "./core/types/requests/create-external-party-request.js";
184
195
  export { AllocatePartyRequest } from "./core/types/requests/allocate-party-request.js";
185
196
  export { AddPartyAsyncArguments } from "./core/types/requests/add-party-async-request.js";
186
197
  export { AddPartyAsyncRequest } from "./core/types/requests/add-party-async-request.js";
@@ -374,6 +385,7 @@ export { ValidationError } from "./core/errors/validation-error.js";
374
385
  export { AuthenticationError } from "./core/errors/authentication-error.js";
375
386
  export { AuthorizationError } from "./core/errors/authorization-error.js";
376
387
  export { TransportError } from "./core/errors/transport-error.js";
388
+ export { GrpcTransportError } from "./core/errors/grpc-transport-error.js";
377
389
  export { SigningError } from "./core/errors/signing-error.js";
378
390
  export { TimeoutError } from "./core/errors/timeout-error.js";
379
391
  export { ConflictError } from "./core/errors/conflict-error.js";
@@ -0,0 +1,9 @@
1
+ import { QueryCacheStore } from "./query-cache-store.js";
2
+ export declare class MemoryQueryCache implements QueryCacheStore {
3
+ private readonly now;
4
+ private readonly entries;
5
+ constructor(now?: () => number);
6
+ getAsync<T>(key: string): Promise<T | undefined>;
7
+ setAsync<T>(key: string, value: T, ttlMs: number): Promise<void>;
8
+ deleteAsync(key: string): Promise<void>;
9
+ }
@@ -0,0 +1,24 @@
1
+ export class MemoryQueryCache {
2
+ now;
3
+ entries = new Map();
4
+ constructor(now = Date.now) {
5
+ this.now = now;
6
+ }
7
+ async getAsync(key) {
8
+ const entry = this.entries.get(key);
9
+ if (entry === undefined) {
10
+ return undefined;
11
+ }
12
+ else if (entry.expiresAt <= this.now()) {
13
+ this.entries.delete(key);
14
+ return undefined;
15
+ }
16
+ return entry.value;
17
+ }
18
+ async setAsync(key, value, ttlMs) {
19
+ this.entries.set(key, { expiresAt: this.now() + ttlMs, value });
20
+ }
21
+ async deleteAsync(key) {
22
+ this.entries.delete(key);
23
+ }
24
+ }
@@ -0,0 +1,5 @@
1
+ export interface QueryCacheStore {
2
+ getAsync<T>(key: string): Promise<T | undefined>;
3
+ setAsync<T>(key: string, value: T, ttlMs: number): Promise<void>;
4
+ deleteAsync(key: string): Promise<void>;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { CantonClientOptions } from "../client/canton-client-options.js";
2
+ import { QueryCacheStore } from "./cache/query-cache-store.js";
3
+ import { QuerySource } from "./query-source.js";
4
+ export interface PqsQueryOptions {
5
+ readonly connectionString: string;
6
+ readonly schema?: string;
7
+ }
8
+ export interface QueryCacheOptions {
9
+ readonly store: QueryCacheStore;
10
+ readonly ttlMs: number;
11
+ }
12
+ export interface CantonManagerOptions {
13
+ readonly grpc: CantonClientOptions;
14
+ readonly querySource: QuerySource;
15
+ readonly pqs?: PqsQueryOptions;
16
+ readonly cache?: QueryCacheOptions;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { CantonClient } from "../client/canton-client.js";
2
+ import { CantonManagerOptions } from "./canton-manager-options.js";
3
+ import { QueryClient } from "./query-client.js";
4
+ export declare class CantonManager {
5
+ readonly grpc: CantonClient;
6
+ readonly query: QueryClient;
7
+ private readonly pqsPool?;
8
+ private disposed;
9
+ constructor(options: CantonManagerOptions);
10
+ disposeAsync(): Promise<void>;
11
+ }
@@ -0,0 +1,42 @@
1
+ import { CantonClient } from "../client/canton-client.js";
2
+ import { TransportKind } from "../core/types/transport-kind.js";
3
+ import { ValidationError } from "../core/errors/validation-error.js";
4
+ import { GrpcContractQueryClient } from "./grpc/grpc-contract-query-client.js";
5
+ import { PqsPool } from "./pqs/pqs-pool.js";
6
+ import { PqsQueryClient } from "./pqs/pqs-query-client.js";
7
+ import { PqsSchemaProfileV1, validatePqsSchemaAsync } from "./pqs/pqs-schema-profile.js";
8
+ import { QuerySource } from "./query-source.js";
9
+ export class CantonManager {
10
+ grpc;
11
+ query;
12
+ pqsPool;
13
+ disposed = false;
14
+ constructor(options) {
15
+ if (options.grpc.transportKind !== TransportKind.grpc) {
16
+ throw new ValidationError("CantonManager requires grpc transport for writes.");
17
+ }
18
+ else if (options.querySource === QuerySource.grpc && options.pqs !== undefined) {
19
+ throw new ValidationError("PQS options require QuerySource.pqs.");
20
+ }
21
+ else if (options.querySource === QuerySource.pqs && options.pqs === undefined) {
22
+ throw new ValidationError("QuerySource.pqs requires PQS options.");
23
+ }
24
+ this.grpc = new CantonClient(options.grpc);
25
+ if (options.querySource === QuerySource.pqs) {
26
+ this.pqsPool = PqsPool.create(options.pqs.connectionString);
27
+ const profile = new PqsSchemaProfileV1(options.pqs.schema);
28
+ this.query = new PqsQueryClient(this.pqsPool.pool, profile, validatePqsSchemaAsync(this.pqsPool.pool, profile));
29
+ }
30
+ else {
31
+ this.query = new GrpcContractQueryClient(this.grpc.stateService, options.cache?.store, options.cache?.ttlMs, options.grpc.ledgerEndpoint ?? "ledger");
32
+ }
33
+ }
34
+ async disposeAsync() {
35
+ if (this.disposed) {
36
+ return;
37
+ }
38
+ this.disposed = true;
39
+ await this.pqsPool?.disposeAsync();
40
+ await this.grpc.disposeAsync();
41
+ }
42
+ }
@@ -0,0 +1,10 @@
1
+ import { CantonError } from "../../core/errors/canton-error.js";
2
+ export declare class PqsQueryError extends CantonError {
3
+ readonly operation: string;
4
+ readonly code?: string;
5
+ constructor(init: {
6
+ operation: string;
7
+ code?: string;
8
+ cause?: unknown;
9
+ });
10
+ }
@@ -0,0 +1,11 @@
1
+ import { CantonError } from "../../core/errors/canton-error.js";
2
+ export class PqsQueryError extends CantonError {
3
+ operation;
4
+ code;
5
+ constructor(init) {
6
+ super(`PQS query ${init.operation} failed${init.code === undefined ? "" : ` (${init.code})`}.`);
7
+ this.operation = init.operation;
8
+ this.code = init.code;
9
+ void init.cause;
10
+ }
11
+ }
@@ -0,0 +1,3 @@
1
+ import { CantonError } from "../../core/errors/canton-error.js";
2
+ export declare class PqsSchemaProfileError extends CantonError {
3
+ }
@@ -0,0 +1,3 @@
1
+ import { CantonError } from "../../core/errors/canton-error.js";
2
+ export class PqsSchemaProfileError extends CantonError {
3
+ }
@@ -0,0 +1,7 @@
1
+ import { CantonError } from "../../core/errors/canton-error.js";
2
+ import { QuerySource } from "../query-source.js";
3
+ export declare class QueryCapabilityError extends CantonError {
4
+ readonly source: QuerySource;
5
+ readonly operation: string;
6
+ constructor(source: QuerySource, operation: string);
7
+ }
@@ -0,0 +1,10 @@
1
+ import { CantonError } from "../../core/errors/canton-error.js";
2
+ export class QueryCapabilityError extends CantonError {
3
+ source;
4
+ operation;
5
+ constructor(source, operation) {
6
+ super(`Query operation ${operation} is not supported by ${source}.`);
7
+ this.source = source;
8
+ this.operation = operation;
9
+ }
10
+ }
@@ -0,0 +1,32 @@
1
+ import { StateServiceClient } from "../../services/state/state-service-client.js";
2
+ import { QueryCacheStore } from "../cache/query-cache-store.js";
3
+ import { ContractCountArgs, ContractFindManyArgs, ContractFindUniqueArgs, ContractRow } from "../model-types.js";
4
+ import { QueryClient } from "../query-client.js";
5
+ import { QuerySource } from "../query-source.js";
6
+ type ActiveContractsReader = Pick<StateServiceClient, "getActiveContractsPageAsync">;
7
+ export declare class GrpcContractQueryClient implements QueryClient {
8
+ private readonly stateService;
9
+ private readonly cache;
10
+ private readonly cacheTtlMs;
11
+ private readonly cacheScope;
12
+ readonly source = QuerySource.grpc;
13
+ readonly contracts: {
14
+ findMany: (args?: ContractFindManyArgs) => Promise<readonly ContractRow[]>;
15
+ findUnique: (args: ContractFindUniqueArgs) => Promise<ContractRow>;
16
+ count: (args?: ContractCountArgs) => Promise<number>;
17
+ aggregate: () => Promise<never>;
18
+ };
19
+ readonly contractTypes: QueryClient["contractTypes"];
20
+ readonly events: QueryClient["events"];
21
+ readonly exercises: QueryClient["exercises"];
22
+ readonly exerciseTypes: QueryClient["exerciseTypes"];
23
+ readonly packages: QueryClient["packages"];
24
+ readonly transactions: QueryClient["transactions"];
25
+ readonly watermark: QueryClient["watermark"];
26
+ constructor(stateService: ActiveContractsReader, cache: QueryCacheStore | undefined, cacheTtlMs: number | undefined, cacheScope: string);
27
+ $queryRaw<TRow>(_sql: string, _values?: readonly unknown[]): Promise<readonly TRow[]>;
28
+ private findManyAsync;
29
+ private unsupported;
30
+ private readSnapshotAsync;
31
+ }
32
+ export {};